VirtualBox

source: kBuild/trunk/src/lib/nt/ntstuff.h@ 2708

Last change on this file since 2708 was 2708, checked in by bird, 12 years ago

Optimized ftsfake.c for windows (similar things can be done for OS/2, if we care).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.2 KB
Line 
1/* $Id: ntstuff.h 2708 2013-11-21 10:26:40Z bird $ */
2/** @file
3 * Definitions, types, prototypes and globals for NT.
4 */
5
6/*
7 * Copyright (c) 2005-2013 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
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
32#ifndef ___nt_ntstuff_h
33#define ___nt_ntstuff_h
34
35#define timeval timeval_Windows
36#define WIN32_NO_STATUS
37#include <Windows.h>
38#undef WIN32_NO_STATUS
39#include <ntstatus.h>
40#undef timeval
41
42
43/** @defgroup grp_nt_ntstuff NT Stuff
44 * @{ */
45
46typedef LONG MY_NTSTATUS;
47typedef ULONG MY_ACCESS_MASK;
48
49typedef struct MY_IO_STATUS_BLOCK
50{
51 union
52 {
53 MY_NTSTATUS Status;
54 PVOID Pointer;
55 } u;
56 ULONG_PTR Information;
57} MY_IO_STATUS_BLOCK;
58
59typedef VOID WINAPI MY_IO_APC_ROUTINE(PVOID, MY_IO_STATUS_BLOCK *, ULONG);
60
61typedef struct MY_UNICODE_STRING
62{
63 USHORT Length;
64 USHORT MaximumLength;
65 PWSTR Buffer;
66} MY_UNICODE_STRING;
67
68typedef struct MY_STRING
69{
70 USHORT Length;
71 USHORT MaximumLength;
72 PCHAR Buffer;
73} MY_STRING;
74typedef MY_STRING MY_ANSI_STRING;
75
76typedef struct MY_OBJECT_ATTRIBUTES
77{
78 ULONG Length;
79 HANDLE RootDirectory;
80 MY_UNICODE_STRING *ObjectName;
81 ULONG Attributes;
82 PVOID SecurityDescriptor;
83 PVOID SecurityQualityOfService;
84} MY_OBJECT_ATTRIBUTES;
85
86#define MyInitializeObjectAttributes(a_pAttr, a_pName, a_fAttribs, a_hRoot, a_pSecDesc) \
87 do { \
88 (a_pAttr)->Length = sizeof(MY_OBJECT_ATTRIBUTES); \
89 (a_pAttr)->RootDirectory = (a_hRoot); \
90 (a_pAttr)->Attributes = (a_fAttribs); \
91 (a_pAttr)->ObjectName = (a_pName); \
92 (a_pAttr)->SecurityDescriptor = (a_pSecDesc); \
93 (a_pAttr)->SecurityQualityOfService = NULL; \
94 } while (0)
95
96
97
98typedef struct MY_FILE_BASIC_INFORMATION
99{
100 LARGE_INTEGER CreationTime;
101 LARGE_INTEGER LastAccessTime;
102 LARGE_INTEGER LastWriteTime;
103 LARGE_INTEGER ChangeTime;
104 ULONG FileAttributes;
105} MY_FILE_BASIC_INFORMATION;
106
107typedef struct MY_FILE_STANDARD_INFORMATION
108{
109 LARGE_INTEGER AllocationSize;
110 LARGE_INTEGER EndOfFile;
111 ULONG NumberOfLinks;
112 BOOLEAN DeletePending;
113 BOOLEAN Directory;
114} MY_FILE_STANDARD_INFORMATION;
115
116typedef struct MY_FILE_INTERNAL_INFORMATION
117{
118 LARGE_INTEGER IndexNumber;
119} MY_FILE_INTERNAL_INFORMATION;
120
121typedef struct MY_FILE_EA_INFORMATION
122{
123 ULONG EaSize;
124} MY_FILE_EA_INFORMATION;
125
126typedef struct MY_FILE_ACCESS_INFORMATION
127{
128 ACCESS_MASK AccessFlags;
129} MY_FILE_ACCESS_INFORMATION;
130
131typedef struct MY_FILE_POSITION_INFORMATION
132{
133 LARGE_INTEGER CurrentByteOffset;
134} MY_FILE_POSITION_INFORMATION;
135
136typedef struct MY_FILE_MODE_INFORMATION
137{
138 ULONG Mode;
139} MY_FILE_MODE_INFORMATION;
140
141typedef struct MY_FILE_ALIGNMENT_INFORMATION
142{
143 ULONG AlignmentRequirement;
144} MY_FILE_ALIGNMENT_INFORMATION;
145
146typedef struct MY_FILE_NAME_INFORMATION
147{
148 ULONG FileNameLength;
149 WCHAR FileName[1];
150} MY_FILE_NAME_INFORMATION;
151
152typedef struct MY_FILE_ALL_INFORMATION
153{
154 MY_FILE_BASIC_INFORMATION BasicInformation;
155 MY_FILE_STANDARD_INFORMATION StandardInformation;
156 MY_FILE_INTERNAL_INFORMATION InternalInformation;
157 MY_FILE_EA_INFORMATION EaInformation;
158 MY_FILE_ACCESS_INFORMATION AccessInformation;
159 MY_FILE_POSITION_INFORMATION PositionInformation;
160 MY_FILE_MODE_INFORMATION ModeInformation;
161 MY_FILE_ALIGNMENT_INFORMATION AlignmentInformation;
162 MY_FILE_NAME_INFORMATION NameInformation;
163} MY_FILE_ALL_INFORMATION;
164
165typedef struct MY_FILE_ATTRIBUTE_TAG_INFORMATION
166{
167 ULONG FileAttributes;
168 ULONG ReparseTag;
169} MY_FILE_ATTRIBUTE_TAG_INFORMATION;
170
171
172typedef struct MY_FILE_NAMES_INFORMATION
173{
174 ULONG NextEntryOffset;
175 ULONG FileIndex;
176 ULONG FileNameLength;
177 WCHAR FileName[1];
178} MY_FILE_NAMES_INFORMATION;
179/** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */
180#define MIN_SIZEOF_MY_FILE_NAMES_INFORMATION (4 + 4 + 4)
181
182
183typedef struct MY_FILE_ID_FULL_DIR_INFORMATION
184{
185 ULONG NextEntryOffset;
186 ULONG FileIndex;
187 LARGE_INTEGER CreationTime;
188 LARGE_INTEGER LastAccessTime;
189 LARGE_INTEGER LastWriteTime;
190 LARGE_INTEGER ChangeTime;
191 LARGE_INTEGER EndOfFile;
192 LARGE_INTEGER AllocationSize;
193 ULONG FileAttributes;
194 ULONG FileNameLength;
195 ULONG EaSize;
196 LARGE_INTEGER FileId;
197 WCHAR FileName[1];
198} MY_FILE_ID_FULL_DIR_INFORMATION;
199/** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */
200#define MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION ( (size_t)&((MY_FILE_ID_FULL_DIR_INFORMATION *)0)->FileName )
201
202
203typedef enum MY_FILE_INFORMATION_CLASS
204{
205 MyFileDirectoryInformation = 1,
206 MyFileFullDirectoryInformation, /* = 2 */
207 MyFileBothDirectoryInformation, /* = 3 */
208 MyFileBasicInformation, /* = 4 */
209 MyFileStandardInformation, /* = 5 */
210 MyFileInternalInformation, /* = 6 */
211 MyFileEaInformation, /* = 7 */
212 MyFileAccessInformation, /* = 8 */
213 MyFileNameInformation, /* = 9 */
214 MyFileRenameInformation, /* = 10 */
215 MyFileLinkInformation, /* = 11 */
216 MyFileNamesInformation, /* = 12 */
217 MyFileDispositionInformation, /* = 13 */
218 MyFilePositionInformation, /* = 14 */
219 MyFileFullEaInformation, /* = 15 */
220 MyFileModeInformation, /* = 16 */
221 MyFileAlignmentInformation, /* = 17 */
222 MyFileAllInformation, /* = 18 */
223 MyFileAllocationInformation, /* = 19 */
224 MyFileEndOfFileInformation, /* = 20 */
225 MyFileAlternateNameInformation, /* = 21 */
226 MyFileStreamInformation, /* = 22 */
227 MyFilePipeInformation, /* = 23 */
228 MyFilePipeLocalInformation, /* = 24 */
229 MyFilePipeRemoteInformation, /* = 25 */
230 MyFileMailslotQueryInformation, /* = 26 */
231 MyFileMailslotSetInformation, /* = 27 */
232 MyFileCompressionInformation, /* = 28 */
233 MyFileObjectIdInformation, /* = 29 */
234 MyFileCompletionInformation, /* = 30 */
235 MyFileMoveClusterInformation, /* = 31 */
236 MyFileQuotaInformation, /* = 32 */
237 MyFileReparsePointInformation, /* = 33 */
238 MyFileNetworkOpenInformation, /* = 34 */
239 MyFileAttributeTagInformation, /* = 35 */
240 MyFileTrackingInformation, /* = 36 */
241 MyFileIdBothDirectoryInformation, /* = 37 */
242 MyFileIdFullDirectoryInformation, /* = 38 */
243 MyFileValidDataLengthInformation, /* = 39 */
244 MyFileShortNameInformation, /* = 40 */
245 MyFileIoCompletionNotificationInformation, /* = 41 */
246 MyFileIoStatusBlockRangeInformation, /* = 42 */
247 MyFileIoPriorityHintInformation, /* = 43 */
248 MyFileSfioReserveInformation, /* = 44 */
249 MyFileSfioVolumeInformation, /* = 45 */
250 MyFileHardLinkInformation, /* = 46 */
251 MyFileProcessIdsUsingFileInformation, /* = 47 */
252 MyFileNormalizedNameInformation, /* = 48 */
253 MyFileNetworkPhysicalNameInformation, /* = 49 */
254 MyFileIdGlobalTxDirectoryInformation, /* = 50 */
255 MyFileIsRemoteDeviceInformation, /* = 51 */
256 MyFileAttributeCacheInformation, /* = 52 */
257 MyFileNumaNodeInformation, /* = 53 */
258 MyFileStandardLinkInformation, /* = 54 */
259 MyFileRemoteProtocolInformation, /* = 55 */
260 MyFileMaximumInformation
261} MY_FILE_INFORMATION_CLASS;
262
263
264typedef struct MY_FILE_FS_VOLUME_INFORMATION
265{
266 LARGE_INTEGER VolumeCreationTime;
267 ULONG VolumeSerialNumber;
268 ULONG VolumeLabelLength;
269 BOOLEAN SupportsObjects;
270 WCHAR VolumeLabel[1];
271} MY_FILE_FS_VOLUME_INFORMATION;
272
273typedef enum MY_FSINFOCLASS
274{
275 MyFileFsVolumeInformation = 1,
276 MyFileFsLabelInformation, /* = 2 */
277 MyFileFsSizeInformation, /* = 3 */
278 MyFileFsDeviceInformation, /* = 4 */
279 MyFileFsAttributeInformation, /* = 5 */
280 MyFileFsControlInformation, /* = 6 */
281 MyFileFsFullSizeInformation, /* = 7 */
282 MyFileFsObjectIdInformation, /* = 8 */
283 MyFileFsDriverPathInformation, /* = 9 */
284 MyFileFsVolumeFlagsInformation, /* = 10 */
285 MyFileFsMaximumInformation
286} MY_FS_INFORMATION_CLASS;
287
288
289typedef struct MY_RTLP_CURDIR_REF
290{
291 LONG RefCount;
292 HANDLE Handle;
293} MY_RTLP_CURDIR_REF;
294
295typedef struct MY_RTL_RELATIVE_NAME_U
296{
297 MY_UNICODE_STRING RelativeName;
298 HANDLE ContainingDirectory;
299 MY_RTLP_CURDIR_REF CurDirRef;
300} MY_RTL_RELATIVE_NAME_U;
301
302
303#ifndef OBJ_INHERIT
304# define OBJ_INHERIT 0x00000002U
305# define OBJ_PERMANENT 0x00000010U
306# define OBJ_EXCLUSIVE 0x00000020U
307# define OBJ_CASE_INSENSITIVE 0x00000040U
308# define OBJ_OPENIF 0x00000080U
309# define OBJ_OPENLINK 0x00000100U
310# define OBJ_KERNEL_HANDLE 0x00000200U
311# define OBJ_FORCE_ACCESS_CHECK 0x00000400U
312# define OBJ_VALID_ATTRIBUTES 0x000007f2U
313#endif
314
315#ifndef FILE_OPEN
316# define FILE_SUPERSEDE 0x00000000U
317# define FILE_OPEN 0x00000001U
318# define FILE_CREATE 0x00000002U
319# define FILE_OPEN_IF 0x00000003U
320# define FILE_OVERWRITE 0x00000004U
321# define FILE_OVERWRITE_IF 0x00000005U
322# define FILE_MAXIMUM_DISPOSITION 0x00000005U
323#endif
324
325#ifndef FILE_DIRECTORY_FILE
326# define FILE_DIRECTORY_FILE 0x00000001U
327# define FILE_WRITE_THROUGH 0x00000002U
328# define FILE_SEQUENTIAL_ONLY 0x00000004U
329# define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008U
330# define FILE_SYNCHRONOUS_IO_ALERT 0x00000010U
331# define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020U
332# define FILE_NON_DIRECTORY_FILE 0x00000040U
333# define FILE_CREATE_TREE_CONNECTION 0x00000080U
334# define FILE_COMPLETE_IF_OPLOCKED 0x00000100U
335# define FILE_NO_EA_KNOWLEDGE 0x00000200U
336# define FILE_OPEN_REMOTE_INSTANCE 0x00000400U
337# define FILE_RANDOM_ACCESS 0x00000800U
338# define FILE_DELETE_ON_CLOSE 0x00001000U
339# define FILE_OPEN_BY_FILE_ID 0x00002000U
340# define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000U
341# define FILE_NO_COMPRESSION 0x00008000U
342# define FILE_RESERVE_OPFILTER 0x00100000U
343# define FILE_OPEN_REPARSE_POINT 0x00200000U
344# define FILE_OPEN_NO_RECALL 0x00400000U
345# define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000U
346#endif
347
348
349/** @name NT status codes and associated macros.
350 * @{ */
351#define MY_NT_SUCCESS(a_ntRc) ((MY_NTSTATUS)(a_ntRc) >= 0)
352#define MY_NT_FAILURE(a_ntRc) ((MY_NTSTATUS)(a_ntRc) < 0)
353#define MY_STATUS_NO_MORE_FILES ((MY_NTSTATUS)0x80000006)
354/** @} */
355
356
357/*******************************************************************************
358* Global Variables *
359*******************************************************************************/
360extern MY_NTSTATUS (WINAPI * g_pfnNtClose)(HANDLE);
361extern MY_NTSTATUS (WINAPI * g_pfnNtCreateFile)(PHANDLE, MY_ACCESS_MASK, MY_OBJECT_ATTRIBUTES *, MY_IO_STATUS_BLOCK *,
362 PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG);
363extern MY_NTSTATUS (WINAPI * g_pfnNtQueryInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *,
364 PVOID, LONG, MY_FILE_INFORMATION_CLASS);
365extern MY_NTSTATUS (WINAPI * g_pfnNtQueryVolumeInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *,
366 PVOID, LONG, MY_FS_INFORMATION_CLASS);
367extern MY_NTSTATUS (WINAPI * g_pfnNtQueryDirectoryFile)(HANDLE, HANDLE, MY_IO_APC_ROUTINE *, PVOID, MY_IO_STATUS_BLOCK *,
368 PVOID, ULONG, MY_FILE_INFORMATION_CLASS, BOOLEAN,
369 MY_UNICODE_STRING *, BOOLEAN);
370extern BOOLEAN (WINAPI * g_pfnRtlDosPathNameToNtPathName_U)(PCWSTR, MY_UNICODE_STRING *, PCWSTR *, MY_RTL_RELATIVE_NAME_U *);
371extern MY_NTSTATUS (WINAPI * g_pfnRtlAnsiStringToUnicodeString)(MY_UNICODE_STRING *, MY_ANSI_STRING const *, BOOLEAN);
372
373
374/** @} */
375
376#endif
377
Note: See TracBrowser for help on using the repository browser.

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