1 | /* $Id: internal-r3-nt.h 47535 2013-08-05 01:54:25Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Internal Header for the Native NT code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | #ifndef ___internal_r3_nt_h___
|
---|
29 | #define ___internal_r3_nt_h___
|
---|
30 |
|
---|
31 |
|
---|
32 | /*******************************************************************************
|
---|
33 | * Header Files *
|
---|
34 | *******************************************************************************/
|
---|
35 | #include <ntstatus.h>
|
---|
36 | #ifdef IPRT_NT_USE_WINTERNL
|
---|
37 | # define WIN32_NO_STATUS
|
---|
38 | # include <windef.h>
|
---|
39 | # include <winnt.h>
|
---|
40 | # include <winternl.h>
|
---|
41 | # define IPRT_NT_NEED_API_GROUP_1
|
---|
42 |
|
---|
43 | #elif defined(IPRT_NT_USE_WDM)
|
---|
44 | # include <wdm.h>
|
---|
45 | # define IPRT_NT_NEED_API_GROUP_1
|
---|
46 |
|
---|
47 | #else
|
---|
48 | # include <ntifs.h>
|
---|
49 | #endif
|
---|
50 | #include "internal/iprt.h"
|
---|
51 |
|
---|
52 |
|
---|
53 | /*******************************************************************************
|
---|
54 | * Defined Constants And Macros *
|
---|
55 | *******************************************************************************/
|
---|
56 | /** Indicates that we're targetting native NT in the current source. */
|
---|
57 | #define RT_USE_NATIVE_NT 1
|
---|
58 | /** Initializes a IO_STATUS_BLOCK. */
|
---|
59 | #define MY_IO_STATUS_BLOCK_INITIALIZER { STATUS_FAILED_DRIVER_ENTRY, ~(uintptr_t)42 }
|
---|
60 | /** Similar to INVALID_HANDLE_VALUE in the Windows environment. */
|
---|
61 | #define MY_INVALID_HANDLE_VALUE ( (HANDLE)~(uintptr_t)0 )
|
---|
62 |
|
---|
63 | #ifdef DEBUG_bird
|
---|
64 | /** Enables the "\\!\" NT path pass thru as well as hacks for listing NT object
|
---|
65 | * directories. */
|
---|
66 | # define IPRT_WITH_NT_PATH_PASSTHRU 1
|
---|
67 | #endif
|
---|
68 |
|
---|
69 |
|
---|
70 | /*******************************************************************************
|
---|
71 | * Internal Functions *
|
---|
72 | *******************************************************************************/
|
---|
73 | int rtNtPathOpen(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs, ULONG fShareAccess,
|
---|
74 | ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
|
---|
75 | PHANDLE phHandle, PULONG_PTR puDisposition);
|
---|
76 | int rtNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions,
|
---|
77 | ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir);
|
---|
78 | int rtNtPathClose(HANDLE hHandle);
|
---|
79 |
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Internal helper for comparing a WCHAR string with a char string.
|
---|
83 | *
|
---|
84 | * @returns @c true if equal, @c false if not.
|
---|
85 | * @param pwsz1 The first string.
|
---|
86 | * @param cb1 The length of the first string, in bytes.
|
---|
87 | * @param psz2 The second string.
|
---|
88 | * @param cch2 The length of the second string.
|
---|
89 | */
|
---|
90 | DECLINLINE(bool) rtNtCompWideStrAndAscii(WCHAR const *pwsz1, size_t cch1, const char *psz2, size_t cch2)
|
---|
91 | {
|
---|
92 | if (cch1 != cch2 * 2)
|
---|
93 | return false;
|
---|
94 | while (cch2-- > 0)
|
---|
95 | {
|
---|
96 | unsigned ch1 = *pwsz1++;
|
---|
97 | unsigned ch2 = (unsigned char)*psz2++;
|
---|
98 | if (ch1 != ch2)
|
---|
99 | return false;
|
---|
100 | }
|
---|
101 | return true;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | /*******************************************************************************
|
---|
106 | * NT APIs *
|
---|
107 | *******************************************************************************/
|
---|
108 |
|
---|
109 | RT_C_DECLS_BEGIN
|
---|
110 |
|
---|
111 | #ifdef IPRT_NT_NEED_API_GROUP_1
|
---|
112 |
|
---|
113 | typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
|
---|
114 | {
|
---|
115 | ULONG FileSystemAttributes;
|
---|
116 | LONG MaximumComponentNameLength;
|
---|
117 | ULONG FileSystemNameLength;
|
---|
118 | WCHAR FileSystemName[1];
|
---|
119 | } FILE_FS_ATTRIBUTE_INFORMATION;
|
---|
120 | typedef FILE_FS_ATTRIBUTE_INFORMATION *PFILE_FS_ATTRIBUTE_INFORMATION;
|
---|
121 | extern "C" NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS);
|
---|
122 |
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | NTSTATUS NTAPI NtOpenDirectoryObject(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
|
---|
126 |
|
---|
127 | typedef struct _OBJECT_DIRECTORY_INFORMATION
|
---|
128 | {
|
---|
129 | UNICODE_STRING Name;
|
---|
130 | UNICODE_STRING TypeName;
|
---|
131 | } OBJECT_DIRECTORY_INFORMATION;
|
---|
132 | typedef OBJECT_DIRECTORY_INFORMATION *POBJECT_DIRECTORY_INFORMATION;
|
---|
133 |
|
---|
134 | NTSTATUS NTAPI NtQueryDirectoryObject(HANDLE, PVOID, ULONG, BOOLEAN, BOOLEAN, PULONG, PULONG);
|
---|
135 |
|
---|
136 |
|
---|
137 | RT_C_DECLS_END
|
---|
138 |
|
---|
139 | #endif
|
---|
140 |
|
---|