VirtualBox

source: kBuild/trunk/src/lib/nt/nthlp.h@ 2997

Last change on this file since 2997 was 2997, checked in by bird, 8 years ago

rm.c: Use fts_dirfd on windows.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1/* $Id: nthlp.h 2997 2016-11-01 23:28:02Z bird $ */
2/** @file
3 * MSC + NT helper functions.
4 */
5
6/*
7 * Copyright (c) 2005-2013 knut st. osmundsen <[email protected]>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 *
27 * Alternatively, the content of this file may be used under the terms of the
28 * GPL version 2 or later, or LGPL version 2.1 or later.
29 */
30
31#ifndef ___nt_nthlp_h
32#define ___nt_nthlp_h
33
34#include "ntstuff.h"
35#include "nttypes.h"
36
37
38/** Lazy resolving of the NTDLL imports. */
39#define birdResolveImports() do { if (g_fResolvedNtImports) {} else birdResolveImportsWorker(); } while (0)
40void birdResolveImportsWorker(void);
41extern int g_fResolvedNtImports;
42
43void *birdTmpAlloc(size_t cb);
44void birdTmpFree(void *pv);
45
46void *birdMemAlloc(size_t cb);
47void *birdMemAllocZ(size_t cb);
48void birdMemFree(void *pv);
49
50int birdSetErrnoFromNt(MY_NTSTATUS rcNt);
51int birdSetErrnoFromWin32(DWORD dwErr);
52int birdSetErrnoToNoMem(void);
53int birdSetErrnoToInvalidArg(void);
54int birdSetErrnoToBadFileNo(void);
55
56
57HANDLE birdOpenFile(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
58 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs);
59HANDLE birdOpenFileW(const wchar_t *pwszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
60 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs);
61HANDLE birdOpenFileEx(HANDLE hRoot, const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
62 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs);
63HANDLE birdOpenFileExW(HANDLE hRoot, const wchar_t *pwszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
64 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs);
65HANDLE birdOpenParentDir(HANDLE hRoot, const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
66 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
67 MY_UNICODE_STRING *pNameUniStr);
68HANDLE birdOpenParentDirW(HANDLE hRoot, const wchar_t *pwszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
69 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
70 MY_UNICODE_STRING *pNameUniStr);
71MY_NTSTATUS birdOpenFileUniStr(HANDLE hRoot, MY_UNICODE_STRING *pNtPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs,
72 ULONG fShareAccess, ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
73 HANDLE *phFile);
74HANDLE birdOpenCurrentDirectory(void);
75void birdCloseFile(HANDLE hFile);
76int birdDosToNtPath(const char *pszPath, MY_UNICODE_STRING *pNtPath);
77int birdDosToRelativeNtPath(const char *pszPath, MY_UNICODE_STRING *pNtPath);
78void birdFreeNtPath(MY_UNICODE_STRING *pNtPath);
79
80
81static __inline void birdNtTimeToTimeSpec(__int64 iNtTime, BirdTimeSpec_T *pTimeSpec)
82{
83 iNtTime -= BIRD_NT_EPOCH_OFFSET_UNIX_100NS;
84 pTimeSpec->tv_sec = iNtTime / 10000000;
85 pTimeSpec->tv_nsec = (iNtTime % 10000000) * 100;
86}
87
88
89#endif
90
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette