1 | /* $Id: nt.h 51945 2014-07-09 00:59:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Header for code using the Native NT API.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2014 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 | #ifndef ___iprt_nt_nt_h___
|
---|
28 | #define ___iprt_nt_nt_h___
|
---|
29 |
|
---|
30 | /** @def IPRT_NT_MAP_TO_ZW
|
---|
31 | * Map Nt calls to Zw calls. In ring-0 the Zw calls let you pass kernel memory
|
---|
32 | * to the APIs (takes care of the previous context checks).
|
---|
33 | */
|
---|
34 | #ifdef DOXYGEN_RUNNING
|
---|
35 | # define IPRT_NT_MAP_TO_ZW
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #ifdef IPRT_NT_MAP_TO_ZW
|
---|
39 | # define NtQueryInformationFile ZwQueryInformationFile
|
---|
40 | # define NtQueryInformationProcess ZwQueryInformationProcess
|
---|
41 | # define NtQueryInformationThread ZwQueryInformationThread
|
---|
42 | # define NtQuerySystemInformation ZwQuerySystemInformation
|
---|
43 | # define NtClose ZwClose
|
---|
44 | # define NtCreateFile ZwCreateFile
|
---|
45 | # define NtReadFile ZwReadFile
|
---|
46 | # define NtWriteFile ZwWriteFile
|
---|
47 | /** @todo this is very incomplete! */
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #include <ntstatus.h>
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Hacks common to both base header sets.
|
---|
54 | */
|
---|
55 | #define NtQueryObject Incomplete_NtQueryObject
|
---|
56 | #define ZwQueryObject Incomplete_ZwQueryObject
|
---|
57 | #define NtSetInformationObject Incomplete_NtSetInformationObject
|
---|
58 | #define _OBJECT_INFORMATION_CLASS Incomplete_OBJECT_INFORMATION_CLASS
|
---|
59 | #define OBJECT_INFORMATION_CLASS Incomplete_OBJECT_INFORMATION_CLASS
|
---|
60 | #define ObjectBasicInformation Incomplete_ObjectBasicInformation
|
---|
61 | #define ObjectTypeInformation Incomplete_ObjectTypeInformation
|
---|
62 |
|
---|
63 |
|
---|
64 | #ifdef IPRT_NT_USE_WINTERNL
|
---|
65 | /*
|
---|
66 | * Use Winternl.h.
|
---|
67 | */
|
---|
68 | # define _FILE_INFORMATION_CLASS IncompleteWinternl_FILE_INFORMATION_CLASS
|
---|
69 | # define FILE_INFORMATION_CLASS IncompleteWinternl_FILE_INFORMATION_CLASS
|
---|
70 | # define FileDirectoryInformation IncompleteWinternl_FileDirectoryInformation
|
---|
71 |
|
---|
72 | # define NtQueryInformationProcess IncompleteWinternl_NtQueryInformationProcess
|
---|
73 | # define NtSetInformationProcess IncompleteWinternl_NtSetInformationProcess
|
---|
74 | # define PROCESSINFOCLASS IncompleteWinternl_PROCESSINFOCLASS
|
---|
75 | # define _PROCESSINFOCLASS IncompleteWinternl_PROCESSINFOCLASS
|
---|
76 | # define PROCESS_BASIC_INFORMATION IncompleteWinternl_PROCESS_BASIC_INFORMATION
|
---|
77 | # define PPROCESS_BASIC_INFORMATION IncompleteWinternl_PPROCESS_BASIC_INFORMATION
|
---|
78 | # define _PROCESS_BASIC_INFORMATION IncompleteWinternl_PROCESS_BASIC_INFORMATION
|
---|
79 | # define ProcessBasicInformation IncompleteWinternl_ProcessBasicInformation
|
---|
80 | # define ProcessDebugPort IncompleteWinternl_ProcessDebugPort
|
---|
81 | # define ProcessWow64Information IncompleteWinternl_ProcessWow64Information
|
---|
82 | # define ProcessImageFileName IncompleteWinternl_ProcessImageFileName
|
---|
83 | # define ProcessBreakOnTermination IncompleteWinternl_ProcessBreakOnTermination
|
---|
84 |
|
---|
85 | # define NtQueryInformationThread IncompleteWinternl_NtQueryInformationThread
|
---|
86 | # define NtSetInformationThread IncompleteWinternl_NtSetInformationThread
|
---|
87 | # define THREADINFOCLASS IncompleteWinternl_THREADINFOCLASS
|
---|
88 | # define _THREADINFOCLASS IncompleteWinternl_THREADINFOCLASS
|
---|
89 | # define ThreadIsIoPending IncompleteWinternl_ThreadIsIoPending
|
---|
90 |
|
---|
91 | # define NtQuerySystemInformation IncompleteWinternl_NtQuerySystemInformation
|
---|
92 | # define NtSetSystemInformation IncompleteWinternl_NtSetSystemInformation
|
---|
93 | # define SYSTEM_INFORMATION_CLASS IncompleteWinternl_SYSTEM_INFORMATION_CLASS
|
---|
94 | # define _SYSTEM_INFORMATION_CLASS IncompleteWinternl_SYSTEM_INFORMATION_CLASS
|
---|
95 | # define SystemBasicInformation IncompleteWinternl_SystemBasicInformation
|
---|
96 | # define SystemPerformanceInformation IncompleteWinternl_SystemPerformanceInformation
|
---|
97 | # define SystemTimeOfDayInformation IncompleteWinternl_SystemTimeOfDayInformation
|
---|
98 | # define SystemProcessInformation IncompleteWinternl_SystemProcessInformation
|
---|
99 | # define SystemProcessorPerformanceInformation IncompleteWinternl_SystemProcessorPerformanceInformation
|
---|
100 | # define SystemInterruptInformation IncompleteWinternl_SystemInterruptInformation
|
---|
101 | # define SystemExceptionInformation IncompleteWinternl_SystemExceptionInformation
|
---|
102 | # define SystemRegistryQuotaInformation IncompleteWinternl_SystemRegistryQuotaInformation
|
---|
103 | # define SystemLookasideInformation IncompleteWinternl_SystemLookasideInformation
|
---|
104 | # define SystemPolicyInformation IncompleteWinternl_SystemPolicyInformation
|
---|
105 |
|
---|
106 |
|
---|
107 | # define WIN32_NO_STATUS
|
---|
108 | # include <windef.h>
|
---|
109 | # include <winnt.h>
|
---|
110 | # include <winternl.h>
|
---|
111 | # undef WIN32_NO_STATUS
|
---|
112 | # include <ntstatus.h>
|
---|
113 |
|
---|
114 |
|
---|
115 | # undef _FILE_INFORMATION_CLASS
|
---|
116 | # undef FILE_INFORMATION_CLASS
|
---|
117 | # undef FileDirectoryInformation
|
---|
118 |
|
---|
119 | # undef NtQueryInformationProcess
|
---|
120 | # undef NtSetInformationProcess
|
---|
121 | # undef PROCESSINFOCLASS
|
---|
122 | # undef _PROCESSINFOCLASS
|
---|
123 | # undef PROCESS_BASIC_INFORMATION
|
---|
124 | # undef PPROCESS_BASIC_INFORMATION
|
---|
125 | # undef _PROCESS_BASIC_INFORMATION
|
---|
126 | # undef ProcessBasicInformation
|
---|
127 | # undef ProcessDebugPort
|
---|
128 | # undef ProcessWow64Information
|
---|
129 | # undef ProcessImageFileName
|
---|
130 | # undef ProcessBreakOnTermination
|
---|
131 |
|
---|
132 | # undef NtQueryInformationThread
|
---|
133 | # undef NtSetInformationThread
|
---|
134 | # undef THREADINFOCLASS
|
---|
135 | # undef _THREADINFOCLASS
|
---|
136 | # undef ThreadIsIoPending
|
---|
137 |
|
---|
138 | # undef NtQuerySystemInformation
|
---|
139 | # undef NtSetSystemInformation
|
---|
140 | # undef SYSTEM_INFORMATION_CLASS
|
---|
141 | # undef _SYSTEM_INFORMATION_CLASS
|
---|
142 | # undef SystemBasicInformation
|
---|
143 | # undef SystemPerformanceInformation
|
---|
144 | # undef SystemTimeOfDayInformation
|
---|
145 | # undef SystemProcessInformation
|
---|
146 | # undef SystemProcessorPerformanceInformation
|
---|
147 | # undef SystemInterruptInformation
|
---|
148 | # undef SystemExceptionInformation
|
---|
149 | # undef SystemRegistryQuotaInformation
|
---|
150 | # undef SystemLookasideInformation
|
---|
151 | # undef SystemPolicyInformation
|
---|
152 |
|
---|
153 | #else
|
---|
154 | /*
|
---|
155 | * Use ntifs.h and wdm.h.
|
---|
156 | */
|
---|
157 | # ifdef RT_ARCH_X86
|
---|
158 | # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
|
---|
159 | # pragma warning(disable : 4163)
|
---|
160 | # endif
|
---|
161 |
|
---|
162 | # include <ntifs.h>
|
---|
163 | # include <wdm.h>
|
---|
164 |
|
---|
165 | # ifdef RT_ARCH_X86
|
---|
166 | # pragma warning(default : 4163)
|
---|
167 | # undef _InterlockedAddLargeStatistic
|
---|
168 | # endif
|
---|
169 |
|
---|
170 | # define IPRT_NT_NEED_API_GROUP_NTIFS
|
---|
171 | #endif
|
---|
172 |
|
---|
173 | #undef NtQueryObject
|
---|
174 | #undef ZwQueryObject
|
---|
175 | #undef NtSetInformationObject
|
---|
176 | #undef _OBJECT_INFORMATION_CLASS
|
---|
177 | #undef OBJECT_INFORMATION_CLASS
|
---|
178 | #undef ObjectBasicInformation
|
---|
179 | #undef ObjectTypeInformation
|
---|
180 |
|
---|
181 | #include <iprt/types.h>
|
---|
182 |
|
---|
183 |
|
---|
184 | /** @name Useful macros
|
---|
185 | * @{ */
|
---|
186 | /** Indicates that we're targetting native NT in the current source. */
|
---|
187 | #define RTNT_USE_NATIVE_NT 1
|
---|
188 | /** Initializes a IO_STATUS_BLOCK. */
|
---|
189 | #define RTNT_IO_STATUS_BLOCK_INITIALIZER { STATUS_FAILED_DRIVER_ENTRY, ~(uintptr_t)42 }
|
---|
190 | /** Similar to INVALID_HANDLE_VALUE in the Windows environment. */
|
---|
191 | #define RTNT_INVALID_HANDLE_VALUE ( (HANDLE)~(uintptr_t)0 )
|
---|
192 | /** @} */
|
---|
193 |
|
---|
194 |
|
---|
195 | /** @name IPRT helper functions for NT
|
---|
196 | * @{ */
|
---|
197 | RT_C_DECLS_BEGIN
|
---|
198 |
|
---|
199 | RTDECL(int) RTNtPathOpen(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs, ULONG fShareAccess,
|
---|
200 | ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
|
---|
201 | PHANDLE phHandle, PULONG_PTR puDisposition);
|
---|
202 | RTDECL(int) RTNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions,
|
---|
203 | ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir);
|
---|
204 | RTDECL(int) RTNtPathClose(HANDLE hHandle);
|
---|
205 |
|
---|
206 | RT_C_DECLS_END
|
---|
207 | /** @} */
|
---|
208 |
|
---|
209 |
|
---|
210 | /** @name NT API delcarations.
|
---|
211 | * @{ */
|
---|
212 | RT_C_DECLS_BEGIN
|
---|
213 |
|
---|
214 | /** @name Process access rights missing in ntddk headers
|
---|
215 | * @{ */
|
---|
216 | #ifndef PROCESS_TERMINATE
|
---|
217 | # define PROCESS_TERMINATE UINT32_C(0x00000001)
|
---|
218 | #endif
|
---|
219 | #ifndef PROCESS_CREATE_THREAD
|
---|
220 | # define PROCESS_CREATE_THREAD UINT32_C(0x00000002)
|
---|
221 | #endif
|
---|
222 | #ifndef PROCESS_SET_SESSIONID
|
---|
223 | # define PROCESS_SET_SESSIONID UINT32_C(0x00000004)
|
---|
224 | #endif
|
---|
225 | #ifndef PROCESS_VM_OPERATION
|
---|
226 | # define PROCESS_VM_OPERATION UINT32_C(0x00000008)
|
---|
227 | #endif
|
---|
228 | #ifndef PROCESS_VM_READ
|
---|
229 | # define PROCESS_VM_READ UINT32_C(0x00000010)
|
---|
230 | #endif
|
---|
231 | #ifndef PROCESS_VM_WRITE
|
---|
232 | # define PROCESS_VM_WRITE UINT32_C(0x00000020)
|
---|
233 | #endif
|
---|
234 | #ifndef PROCESS_DUP_HANDLE
|
---|
235 | # define PROCESS_DUP_HANDLE UINT32_C(0x00000040)
|
---|
236 | #endif
|
---|
237 | #ifndef PROCESS_CREATE_PROCESS
|
---|
238 | # define PROCESS_CREATE_PROCESS UINT32_C(0x00000080)
|
---|
239 | #endif
|
---|
240 | #ifndef PROCESS_SET_QUOTA
|
---|
241 | # define PROCESS_SET_QUOTA UINT32_C(0x00000100)
|
---|
242 | #endif
|
---|
243 | #ifndef PROCESS_SET_INFORMATION
|
---|
244 | # define PROCESS_SET_INFORMATION UINT32_C(0x00000200)
|
---|
245 | #endif
|
---|
246 | #ifndef PROCESS_QUERY_INFORMATION
|
---|
247 | # define PROCESS_QUERY_INFORMATION UINT32_C(0x00000400)
|
---|
248 | #endif
|
---|
249 | #ifndef PROCESS_SUSPEND_RESUME
|
---|
250 | # define PROCESS_SUSPEND_RESUME UINT32_C(0x00000800)
|
---|
251 | #endif
|
---|
252 | #ifndef PROCESS_QUERY_LIMITED_INFORMATION
|
---|
253 | # define PROCESS_QUERY_LIMITED_INFORMATION UINT32_C(0x00001000)
|
---|
254 | #endif
|
---|
255 | #ifndef PROCESS_SET_LIMITED_INFORMATION
|
---|
256 | # define PROCESS_SET_LIMITED_INFORMATION UINT32_C(0x00002000)
|
---|
257 | #endif
|
---|
258 | #define PROCESS_UNKNOWN_4000 UINT32_C(0x00004000)
|
---|
259 | #define PROCESS_UNKNOWN_6000 UINT32_C(0x00008000)
|
---|
260 | #ifndef PROCESS_ALL_ACCESS
|
---|
261 | # define PROCESS_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | UINT32_C(0x0000ffff) )
|
---|
262 | #endif
|
---|
263 | /** @} */
|
---|
264 |
|
---|
265 | /** @name Thread access rights missing in ntddk headers
|
---|
266 | * @{ */
|
---|
267 | #ifndef THREAD_QUERY_INFORMATION
|
---|
268 | # define THREAD_QUERY_INFORMATION UINT32_C(0x00000040)
|
---|
269 | #endif
|
---|
270 | #ifndef THREAD_SET_THREAD_TOKEN
|
---|
271 | # define THREAD_SET_THREAD_TOKEN UINT32_C(0x00000080)
|
---|
272 | #endif
|
---|
273 | #ifndef THREAD_IMPERSONATE
|
---|
274 | # define THREAD_IMPERSONATE UINT32_C(0x00000100)
|
---|
275 | #endif
|
---|
276 | #ifndef THREAD_DIRECT_IMPERSONATION
|
---|
277 | # define THREAD_DIRECT_IMPERSONATION UINT32_C(0x00000200)
|
---|
278 | #endif
|
---|
279 | #ifndef THREAD_RESUME
|
---|
280 | # define THREAD_RESUME UINT32_C(0x00001000)
|
---|
281 | #endif
|
---|
282 | #define THREAD_UNKNOWN_2000 UINT32_C(0x00002000)
|
---|
283 | #define THREAD_UNKNOWN_4000 UINT32_C(0x00004000)
|
---|
284 | #define THREAD_UNKNOWN_8000 UINT32_C(0x00008000)
|
---|
285 | /** @} */
|
---|
286 |
|
---|
287 | /** @name Special handle values.
|
---|
288 | * @{ */
|
---|
289 | #ifndef NtCurrentProcess
|
---|
290 | # define NtCurrentProcess() ( (HANDLE)-(intptr_t)1 )
|
---|
291 | #endif
|
---|
292 | #ifndef NtCurrentThread
|
---|
293 | # define NtCurrentThread() ( (HANDLE)-(intptr_t)2 )
|
---|
294 | #endif
|
---|
295 | #ifndef ZwCurrentProcess
|
---|
296 | # define ZwCurrentProcess() NtCurrentProcess()
|
---|
297 | #endif
|
---|
298 | #ifndef ZwCurrentThread
|
---|
299 | # define ZwCurrentThread() NtCurrentThread()
|
---|
300 | #endif
|
---|
301 | /** @} */
|
---|
302 |
|
---|
303 |
|
---|
304 | /** @name Directory object access rights.
|
---|
305 | * @{ */
|
---|
306 | #ifndef DIRECTORY_QUERY
|
---|
307 | # define DIRECTORY_QUERY UINT32_C(0x00000001)
|
---|
308 | #endif
|
---|
309 | #ifndef DIRECTORY_TRAVERSE
|
---|
310 | # define DIRECTORY_TRAVERSE UINT32_C(0x00000002)
|
---|
311 | #endif
|
---|
312 | #ifndef DIRECTORY_CREATE_OBJECT
|
---|
313 | # define DIRECTORY_CREATE_OBJECT UINT32_C(0x00000004)
|
---|
314 | #endif
|
---|
315 | #ifndef DIRECTORY_CREATE_SUBDIRECTORY
|
---|
316 | # define DIRECTORY_CREATE_SUBDIRECTORY UINT32_C(0x00000008)
|
---|
317 | #endif
|
---|
318 | #ifndef DIRECTORY_ALL_ACCESS
|
---|
319 | # define DIRECTORY_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | UINT32_C(0x0000000f) )
|
---|
320 | #endif
|
---|
321 | /** @} */
|
---|
322 |
|
---|
323 |
|
---|
324 | #ifdef IPRT_NT_USE_WINTERNL
|
---|
325 | typedef struct _CLIENT_ID
|
---|
326 | {
|
---|
327 | HANDLE UniqueProcess;
|
---|
328 | HANDLE UniqueThread;
|
---|
329 | } CLIENT_ID;
|
---|
330 | typedef CLIENT_ID *PCLIENT_ID;
|
---|
331 |
|
---|
332 | NTSYSAPI NTSTATUS NTAPI NtCreateSection(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PLARGE_INTEGER, ULONG, ULONG, HANDLE);
|
---|
333 |
|
---|
334 | typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
|
---|
335 | {
|
---|
336 | ULONG FileSystemAttributes;
|
---|
337 | LONG MaximumComponentNameLength;
|
---|
338 | ULONG FileSystemNameLength;
|
---|
339 | WCHAR FileSystemName[1];
|
---|
340 | } FILE_FS_ATTRIBUTE_INFORMATION;
|
---|
341 | typedef FILE_FS_ATTRIBUTE_INFORMATION *PFILE_FS_ATTRIBUTE_INFORMATION;
|
---|
342 |
|
---|
343 | NTSYSAPI NTSTATUS NTAPI NtOpenProcessToken(HANDLE, ACCESS_MASK, PHANDLE);
|
---|
344 | NTSYSAPI NTSTATUS NTAPI NtOpenThreadToken(HANDLE, ACCESS_MASK, BOOLEAN, PHANDLE);
|
---|
345 |
|
---|
346 | typedef enum _FSINFOCLASS
|
---|
347 | {
|
---|
348 | FileFsVolumeInformation = 1,
|
---|
349 | FileFsLabelInformation,
|
---|
350 | FileFsSizeInformation,
|
---|
351 | FileFsDeviceInformation,
|
---|
352 | FileFsAttributeInformation,
|
---|
353 | FileFsControlInformation,
|
---|
354 | FileFsFullSizeInformation,
|
---|
355 | FileFsObjectIdInformation,
|
---|
356 | FileFsDriverPathInformation,
|
---|
357 | FileFsVolumeFlagsInformation,
|
---|
358 | FileFsSectorSizeInformation,
|
---|
359 | FileFsDataCopyInformation,
|
---|
360 | FileFsMaximumInformation
|
---|
361 | } FS_INFORMATION_CLASS;
|
---|
362 | typedef FS_INFORMATION_CLASS *PFS_INFORMATION_CLASS;
|
---|
363 | NTSYSAPI NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS);
|
---|
364 |
|
---|
365 | typedef struct _FILE_STANDARD_INFORMATION
|
---|
366 | {
|
---|
367 | LARGE_INTEGER AllocationSize;
|
---|
368 | LARGE_INTEGER EndOfFile;
|
---|
369 | ULONG NumberOfLinks;
|
---|
370 | BOOLEAN DeletePending;
|
---|
371 | BOOLEAN Directory;
|
---|
372 | } FILE_STANDARD_INFORMATION;
|
---|
373 | typedef FILE_STANDARD_INFORMATION *PFILE_STANDARD_INFORMATION;
|
---|
374 | typedef enum _FILE_INFORMATION_CLASS
|
---|
375 | {
|
---|
376 | FileDirectoryInformation = 1,
|
---|
377 | FileFullDirectoryInformation,
|
---|
378 | FileBothDirectoryInformation,
|
---|
379 | FileBasicInformation,
|
---|
380 | FileStandardInformation,
|
---|
381 | FileInternalInformation,
|
---|
382 | FileEaInformation,
|
---|
383 | FileAccessInformation,
|
---|
384 | FileNameInformation,
|
---|
385 | FileRenameInformation,
|
---|
386 | FileLinkInformation,
|
---|
387 | FileNamesInformation,
|
---|
388 | FileDispositionInformation,
|
---|
389 | FilePositionInformation,
|
---|
390 | FileFullEaInformation,
|
---|
391 | FileModeInformation,
|
---|
392 | FileAlignmentInformation,
|
---|
393 | FileAllInformation,
|
---|
394 | FileAllocationInformation,
|
---|
395 | FileEndOfFileInformation,
|
---|
396 | FileAlternateNameInformation,
|
---|
397 | FileStreamInformation,
|
---|
398 | FilePipeInformation,
|
---|
399 | FilePipeLocalInformation,
|
---|
400 | FilePipeRemoteInformation,
|
---|
401 | FileMailslotQueryInformation,
|
---|
402 | FileMailslotSetInformation,
|
---|
403 | FileCompressionInformation,
|
---|
404 | FileObjectIdInformation,
|
---|
405 | FileCompletionInformation,
|
---|
406 | FileMoveClusterInformation,
|
---|
407 | FileQuotaInformation,
|
---|
408 | FileReparsePointInformation,
|
---|
409 | FileNetworkOpenInformation,
|
---|
410 | FileAttributeTagInformation,
|
---|
411 | FileTrackingInformation,
|
---|
412 | FileIdBothDirectoryInformation,
|
---|
413 | FileIdFullDirectoryInformation,
|
---|
414 | FileValidDataLengthInformation,
|
---|
415 | FileShortNameInformation,
|
---|
416 | FileIoCompletionNotificationInformation,
|
---|
417 | FileIoStatusBlockRangeInformation,
|
---|
418 | FileIoPriorityHintInformation,
|
---|
419 | FileSfioReserveInformation,
|
---|
420 | FileSfioVolumeInformation,
|
---|
421 | FileHardLinkInformation,
|
---|
422 | FileProcessIdsUsingFileInformation,
|
---|
423 | FileNormalizedNameInformation,
|
---|
424 | FileNetworkPhysicalNameInformation,
|
---|
425 | FileIdGlobalTxDirectoryInformation,
|
---|
426 | FileIsRemoteDeviceInformation,
|
---|
427 | FileUnusedInformation,
|
---|
428 | FileNumaNodeInformation,
|
---|
429 | FileStandardLinkInformation,
|
---|
430 | FileRemoteProtocolInformation,
|
---|
431 | FileRenameInformationBypassAccessCheck,
|
---|
432 | FileLinkInformationBypassAccessCheck,
|
---|
433 | FileVolumeNameInformation,
|
---|
434 | FileIdInformation,
|
---|
435 | FileIdExtdDirectoryInformation,
|
---|
436 | FileReplaceCompletionInformation,
|
---|
437 | FileHardLinkFullIdInformation,
|
---|
438 | FileMaximumInformation
|
---|
439 | } FILE_INFORMATION_CLASS;
|
---|
440 | typedef FILE_INFORMATION_CLASS *PFILE_INFORMATION_CLASS;
|
---|
441 | NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FILE_INFORMATION_CLASS);
|
---|
442 |
|
---|
443 | typedef struct _MEMORY_SECTION_NAME
|
---|
444 | {
|
---|
445 | UNICODE_STRING SectionFileName;
|
---|
446 | WCHAR NameBuffer[1];
|
---|
447 | } MEMORY_SECTION_NAME;
|
---|
448 |
|
---|
449 | #ifdef IPRT_NT_USE_WINTERNL
|
---|
450 | typedef struct _PROCESS_BASIC_INFORMATION
|
---|
451 | {
|
---|
452 | NTSTATUS ExitStatus;
|
---|
453 | PPEB PebBaseAddress;
|
---|
454 | ULONG_PTR AffinityMask;
|
---|
455 | int32_t BasePriority;
|
---|
456 | ULONG_PTR UniqueProcessId;
|
---|
457 | ULONG_PTR InheritedFromUniqueProcessId;
|
---|
458 | } PROCESS_BASIC_INFORMATION;
|
---|
459 | typedef PROCESS_BASIC_INFORMATION *PPROCESS_BASIC_INFORMATION;
|
---|
460 | #endif
|
---|
461 |
|
---|
462 | typedef enum _PROCESSINFOCLASS
|
---|
463 | {
|
---|
464 | ProcessBasicInformation = 0,
|
---|
465 | ProcessQuotaLimits,
|
---|
466 | ProcessIoCounters,
|
---|
467 | ProcessVmCounters,
|
---|
468 | ProcessTimes,
|
---|
469 | ProcessBasePriority,
|
---|
470 | ProcessRaisePriority,
|
---|
471 | ProcessDebugPort,
|
---|
472 | ProcessExceptionPort,
|
---|
473 | ProcessAccessToken,
|
---|
474 | ProcessLdtInformation,
|
---|
475 | ProcessLdtSize,
|
---|
476 | ProcessDefaultHardErrorMode,
|
---|
477 | ProcessIoPortHandlers,
|
---|
478 | ProcessPooledUsageAndLimits,
|
---|
479 | ProcessWorkingSetWatch,
|
---|
480 | ProcessUserModeIOPL,
|
---|
481 | ProcessEnableAlignmentFaultFixup,
|
---|
482 | ProcessPriorityClass,
|
---|
483 | ProcessWx86Information,
|
---|
484 | ProcessHandleCount,
|
---|
485 | ProcessAffinityMask,
|
---|
486 | ProcessPriorityBoost,
|
---|
487 | ProcessDeviceMap,
|
---|
488 | ProcessSessionInformation,
|
---|
489 | ProcessForegroundInformation,
|
---|
490 | ProcessWow64Information,
|
---|
491 | ProcessImageFileName,
|
---|
492 | ProcessLUIDDeviceMapsEnabled,
|
---|
493 | ProcessBreakOnTermination,
|
---|
494 | ProcessDebugObjectHandle,
|
---|
495 | ProcessDebugFlags,
|
---|
496 | ProcessHandleTracing,
|
---|
497 | ProcessIoPriority,
|
---|
498 | ProcessExecuteFlags,
|
---|
499 | ProcessTlsInformation,
|
---|
500 | ProcessCookie,
|
---|
501 | ProcessImageInformation,
|
---|
502 | ProcessCycleTime,
|
---|
503 | ProcessPagePriority,
|
---|
504 | ProcessInstrumentationCallbak,
|
---|
505 | ProcessThreadStackAllocation,
|
---|
506 | ProcessWorkingSetWatchEx,
|
---|
507 | ProcessImageFileNameWin32,
|
---|
508 | ProcessImageFileMapping,
|
---|
509 | ProcessAffinityUpdateMode,
|
---|
510 | ProcessMemoryAllocationMode,
|
---|
511 | ProcessGroupInformation,
|
---|
512 | ProcessTokenVirtualizationEnabled,
|
---|
513 | ProcessConsoleHostProcess,
|
---|
514 | ProcessWindowsInformation,
|
---|
515 | MaxProcessInfoClass
|
---|
516 | } PROCESSINFOCLASS;
|
---|
517 | NTSYSAPI NTSTATUS NTAPI NtQueryInformationProcess(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
|
---|
518 |
|
---|
519 | typedef enum _THREADINFOCLASS
|
---|
520 | {
|
---|
521 | ThreadBasicInformation = 0,
|
---|
522 | ThreadTimes,
|
---|
523 | ThreadPriority,
|
---|
524 | ThreadBasePriority,
|
---|
525 | ThreadAffinityMask,
|
---|
526 | ThreadImpersonationToken,
|
---|
527 | ThreadDescriptorTableEntry,
|
---|
528 | ThreadEnableAlignmentFaultFixup,
|
---|
529 | ThreadEventPair_Reusable,
|
---|
530 | ThreadQuerySetWin32StartAddress,
|
---|
531 | ThreadZeroTlsCell,
|
---|
532 | ThreadPerformanceCount,
|
---|
533 | ThreadAmILastThread,
|
---|
534 | ThreadIdealProcessor,
|
---|
535 | ThreadPriorityBoost,
|
---|
536 | ThreadSetTlsArrayAddress,
|
---|
537 | ThreadIsIoPending,
|
---|
538 | ThreadHideFromDebugger,
|
---|
539 | ThreadBreakOnTermination,
|
---|
540 | ThreadSwitchLegacyState,
|
---|
541 | ThreadIsTerminated,
|
---|
542 | ThreadLastSystemCall,
|
---|
543 | ThreadIoPriority,
|
---|
544 | ThreadCycleTime,
|
---|
545 | ThreadPagePriority,
|
---|
546 | ThreadActualBasePriority,
|
---|
547 | ThreadTebInformation,
|
---|
548 | ThreadCSwitchMon,
|
---|
549 | ThreadCSwitchPmu,
|
---|
550 | ThreadWow64Context,
|
---|
551 | ThreadGroupInformation,
|
---|
552 | ThreadUmsInformation,
|
---|
553 | ThreadCounterProfiling,
|
---|
554 | ThreadIdealProcessorEx,
|
---|
555 | ThreadCpuAccountingInformation,
|
---|
556 | MaxThreadInfoClass
|
---|
557 | } THREADINFOCLASS;
|
---|
558 | NTSYSAPI NTSTATUS NTAPI NtSetInformationThread(HANDLE, THREADINFOCLASS, LPCVOID, ULONG);
|
---|
559 |
|
---|
560 | NTSYSAPI NTSTATUS NTAPI NtQueryInformationToken(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, ULONG, PULONG);
|
---|
561 |
|
---|
562 | NTSYSAPI NTSTATUS NTAPI NtReadFile(HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, PULONG);
|
---|
563 | NTSYSAPI NTSTATUS NTAPI NtWriteFile(HANDLE, HANDLE, PIO_APC_ROUTINE, void const *, PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, PULONG);
|
---|
564 |
|
---|
565 | NTSYSAPI NTSTATUS NTAPI NtReadVirtualMemory(HANDLE, PVOID, PVOID, SIZE_T, PSIZE_T);
|
---|
566 | NTSYSAPI NTSTATUS NTAPI NtWriteVirtualMemory(HANDLE, PVOID, void const *, SIZE_T, PSIZE_T);
|
---|
567 |
|
---|
568 | NTSYSAPI NTSTATUS NTAPI RtlAddAccessAllowedAce(PACL, ULONG, ULONG, PSID);
|
---|
569 | NTSYSAPI NTSTATUS NTAPI RtlCopySid(ULONG, PSID, PSID);
|
---|
570 | NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL, ULONG, ULONG);
|
---|
571 | NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR, ULONG);
|
---|
572 | NTSYSAPI NTSTATUS NTAPI RtlGetVersion(PRTL_OSVERSIONINFOW);
|
---|
573 | NTSYSAPI NTSTATUS NTAPI RtlInitializeSid(PSID, PSID_IDENTIFIER_AUTHORITY, UCHAR);
|
---|
574 | NTSYSAPI NTSTATUS NTAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN);
|
---|
575 | NTSYSAPI PULONG NTAPI RtlSubAuthoritySid(PSID, ULONG);
|
---|
576 |
|
---|
577 | #endif /* IPRT_NT_USE_WINTERNL */
|
---|
578 |
|
---|
579 | typedef enum _OBJECT_INFORMATION_CLASS
|
---|
580 | {
|
---|
581 | ObjectBasicInformation = 0,
|
---|
582 | ObjectNameInformation,
|
---|
583 | ObjectTypeInformation,
|
---|
584 | ObjectAllInformation,
|
---|
585 | ObjectDataInformation
|
---|
586 | } OBJECT_INFORMATION_CLASS;
|
---|
587 | typedef OBJECT_INFORMATION_CLASS *POBJECT_INFORMATION_CLASS;
|
---|
588 | #ifdef IN_RING0
|
---|
589 | # define NtQueryObject ZwQueryObject
|
---|
590 | #endif
|
---|
591 | NTSYSAPI NTSTATUS NTAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
|
---|
592 | NTSYSAPI NTSTATUS NTAPI NtSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
|
---|
593 | NTSYSAPI NTSTATUS NTAPI NtDuplicateObject(HANDLE, HANDLE, HANDLE, PHANDLE, ACCESS_MASK, ULONG, ULONG);
|
---|
594 |
|
---|
595 | NTSYSAPI NTSTATUS NTAPI NtOpenDirectoryObject(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
|
---|
596 |
|
---|
597 | typedef struct _OBJECT_DIRECTORY_INFORMATION
|
---|
598 | {
|
---|
599 | UNICODE_STRING Name;
|
---|
600 | UNICODE_STRING TypeName;
|
---|
601 | } OBJECT_DIRECTORY_INFORMATION;
|
---|
602 | typedef OBJECT_DIRECTORY_INFORMATION *POBJECT_DIRECTORY_INFORMATION;
|
---|
603 | NTSYSAPI NTSTATUS NTAPI NtQueryDirectoryObject(HANDLE, PVOID, ULONG, BOOLEAN, BOOLEAN, PULONG, PULONG);
|
---|
604 |
|
---|
605 | /** Retured by ProcessImageInformation as well as NtQuerySection. */
|
---|
606 | typedef struct _SECTION_IMAGE_INFORMATION
|
---|
607 | {
|
---|
608 | PVOID TransferAddress;
|
---|
609 | ULONG ZeroBits;
|
---|
610 | SIZE_T MaximumStackSize;
|
---|
611 | SIZE_T CommittedStackSize;
|
---|
612 | ULONG SubSystemType;
|
---|
613 | union
|
---|
614 | {
|
---|
615 | struct
|
---|
616 | {
|
---|
617 | USHORT SubSystemMinorVersion;
|
---|
618 | USHORT SubSystemMajorVersion;
|
---|
619 | };
|
---|
620 | ULONG SubSystemVersion;
|
---|
621 | };
|
---|
622 | ULONG GpValue;
|
---|
623 | USHORT ImageCharacteristics;
|
---|
624 | USHORT DllCharacteristics;
|
---|
625 | USHORT Machine;
|
---|
626 | BOOLEAN ImageContainsCode;
|
---|
627 | union /**< Since Vista, used to be a spare BOOLEAN. */
|
---|
628 | {
|
---|
629 | struct
|
---|
630 | {
|
---|
631 | UCHAR ComPlusNativeRead : 1;
|
---|
632 | UCHAR ComPlusILOnly : 1;
|
---|
633 | UCHAR ImageDynamicallyRelocated : 1;
|
---|
634 | UCHAR ImageMAppedFlat : 1;
|
---|
635 | UCHAR Reserved : 4;
|
---|
636 | };
|
---|
637 | UCHAR ImageFlags;
|
---|
638 | };
|
---|
639 | ULONG LoaderFlags;
|
---|
640 | ULONG ImageFileSize; /**< Since XP? */
|
---|
641 | ULONG CheckSum; /**< Since Vista, Used to be a reserved/spare ULONG. */
|
---|
642 | } SECTION_IMAGE_INFORMATION;
|
---|
643 | typedef SECTION_IMAGE_INFORMATION *PSECTION_IMAGE_INFORMATION;
|
---|
644 |
|
---|
645 | typedef enum _SECTION_INFORMATION_CLASS
|
---|
646 | {
|
---|
647 | SectionBasicInformation = 0,
|
---|
648 | SectionImageInformation,
|
---|
649 | MaxSectionInfoClass
|
---|
650 | } SECTION_INFORMATION_CLASS;
|
---|
651 | NTSYSAPI NTSTATUS NTAPI NtQuerySection(HANDLE, SECTION_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
|
---|
652 |
|
---|
653 | NTSYSAPI NTSTATUS NTAPI NtQueryInformationThread(HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG);
|
---|
654 |
|
---|
655 | #ifndef SEC_FILE
|
---|
656 | # define SEC_FILE UINT32_C(0x00800000)
|
---|
657 | #endif
|
---|
658 | #ifndef SEC_IMAGE
|
---|
659 | # define SEC_IMAGE UINT32_C(0x01000000)
|
---|
660 | #endif
|
---|
661 | #ifndef SEC_PROTECTED_IMAGE
|
---|
662 | # define SEC_PROTECTED_IMAGE UINT32_C(0x02000000)
|
---|
663 | #endif
|
---|
664 | #ifndef SEC_NOCACHE
|
---|
665 | # define SEC_NOCACHE UINT32_C(0x10000000)
|
---|
666 | #endif
|
---|
667 | #ifndef MEM_ROTATE
|
---|
668 | # define MEM_ROTATE UINT32_C(0x00800000)
|
---|
669 | #endif
|
---|
670 | typedef enum _MEMORY_INFORMATION_CLASS
|
---|
671 | {
|
---|
672 | MemoryBasicInformation = 0,
|
---|
673 | MemoryWorkingSetList,
|
---|
674 | MemorySectionName,
|
---|
675 | MemoryBasicVlmInformation
|
---|
676 | } MEMORY_INFORMATION_CLASS;
|
---|
677 | #ifdef IN_RING0
|
---|
678 | typedef struct _MEMORY_BASIC_INFORMATION
|
---|
679 | {
|
---|
680 | PVOID BaseAddress;
|
---|
681 | PVOID AllocationBase;
|
---|
682 | ULONG AllocationProtect;
|
---|
683 | SIZE_T RegionSize;
|
---|
684 | ULONG State;
|
---|
685 | ULONG Protect;
|
---|
686 | ULONG Type;
|
---|
687 | } MEMORY_BASIC_INFORMATION;
|
---|
688 | typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION;
|
---|
689 | # define NtQueryVirtualMemory ZwQueryVirtualMemory
|
---|
690 | #endif
|
---|
691 | NTSYSAPI NTSTATUS NTAPI NtQueryVirtualMemory(HANDLE, void const *, MEMORY_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
|
---|
692 |
|
---|
693 | typedef enum _SYSTEM_INFORMATION_CLASS
|
---|
694 | {
|
---|
695 | SystemBasicInformation = 0,
|
---|
696 | SystemCpuInformation,
|
---|
697 | SystemPerformanceInformation,
|
---|
698 | SystemTimeOfDayInformation,
|
---|
699 | SystemInformation_Unknown_4,
|
---|
700 | SystemProcessInformation,
|
---|
701 | SystemInformation_Unknown_6,
|
---|
702 | SystemInformation_Unknown_7,
|
---|
703 | SystemProcessorPerformanceInformation,
|
---|
704 | SystemInformation_Unknown_9,
|
---|
705 | SystemInformation_Unknown_10,
|
---|
706 | SystemModuleInformation,
|
---|
707 | SystemInformation_Unknown_12,
|
---|
708 | SystemInformation_Unknown_13,
|
---|
709 | SystemInformation_Unknown_14,
|
---|
710 | SystemInformation_Unknown_15,
|
---|
711 | SystemHandleInformation,
|
---|
712 | SystemInformation_Unknown_17,
|
---|
713 | SystemPageFileInformation,
|
---|
714 | SystemInformation_Unknown_19,
|
---|
715 | SystemInformation_Unknown_20,
|
---|
716 | SystemCacheInformation,
|
---|
717 | SystemInformation_Unknown_22,
|
---|
718 | SystemInterruptInformation,
|
---|
719 | SystemDpcBehaviourInformation,
|
---|
720 | SystemFullMemoryInformation,
|
---|
721 | SystemLoadGdiDriverInformation, /* 26 */
|
---|
722 | SystemUnloadGdiDriverInformation, /* 27 */
|
---|
723 | SystemTimeAdjustmentInformation,
|
---|
724 | SystemSummaryMemoryInformation,
|
---|
725 | SystemInformation_Unknown_30,
|
---|
726 | SystemInformation_Unknown_31,
|
---|
727 | SystemInformation_Unknown_32,
|
---|
728 | SystemExceptionInformation,
|
---|
729 | SystemCrashDumpStateInformation,
|
---|
730 | SystemKernelDebuggerInformation,
|
---|
731 | SystemContextSwitchInformation,
|
---|
732 | SystemRegistryQuotaInformation,
|
---|
733 | SystemInformation_Unknown_38,
|
---|
734 | SystemInformation_Unknown_39,
|
---|
735 | SystemInformation_Unknown_40,
|
---|
736 | SystemInformation_Unknown_41,
|
---|
737 | SystemInformation_Unknown_42,
|
---|
738 | SystemInformation_Unknown_43,
|
---|
739 | SystemCurrentTimeZoneInformation,
|
---|
740 | SystemLookasideInformation,
|
---|
741 | SystemSetTimeSlipEvent,
|
---|
742 | SystemCreateSession,
|
---|
743 | SystemDeleteSession,
|
---|
744 | SystemInformation_Unknown_49,
|
---|
745 | SystemRangeStartInformation,
|
---|
746 | SystemVerifierInformation,
|
---|
747 | SystemInformation_Unknown_52,
|
---|
748 | SystemSessionProcessInformation,
|
---|
749 | SystemLoadGdiDriverInSystemSpaceInformation, /* 54 */
|
---|
750 | SystemInformation_Unknown_55,
|
---|
751 | SystemInformation_Unknown_56,
|
---|
752 | SystemExtendedProcessInformation,
|
---|
753 | SystemInformation_Unknown_58,
|
---|
754 | SystemInformation_Unknown_59,
|
---|
755 | SystemInformation_Unknown_60,
|
---|
756 | SystemInformation_Unknown_61,
|
---|
757 | SystemInformation_Unknown_62,
|
---|
758 | SystemInformation_Unknown_63,
|
---|
759 | SystemExtendedHandleInformation, /* 64 */
|
---|
760 |
|
---|
761 | /** @todo fill gap. they've added a whole bunch of things */
|
---|
762 | SystemPolicyInformation = 134,
|
---|
763 | SystemInformationClassMax
|
---|
764 | } SYSTEM_INFORMATION_CLASS;
|
---|
765 |
|
---|
766 | #ifdef IPRT_NT_USE_WINTERNL
|
---|
767 | typedef struct _VM_COUNTERS
|
---|
768 | {
|
---|
769 | SIZE_T PeakVirtualSize;
|
---|
770 | SIZE_T VirtualSize;
|
---|
771 | ULONG PageFaultCount;
|
---|
772 | SIZE_T PeakWorkingSetSize;
|
---|
773 | SIZE_T WorkingSetSize;
|
---|
774 | SIZE_T QuotaPeakPagedPoolUsage;
|
---|
775 | SIZE_T QuotaPagedPoolUsage;
|
---|
776 | SIZE_T QuotaPeakNonPagedPoolUsage;
|
---|
777 | SIZE_T QuotaNonPagedPoolUsage;
|
---|
778 | SIZE_T PagefileUsage;
|
---|
779 | SIZE_T PeakPagefileUsage;
|
---|
780 | } VM_COUNTERS;
|
---|
781 | typedef VM_COUNTERS *PVM_COUNTERS;
|
---|
782 | #endif
|
---|
783 |
|
---|
784 | #if 0
|
---|
785 | typedef struct _IO_COUNTERS
|
---|
786 | {
|
---|
787 | ULONGLONG ReadOperationCount;
|
---|
788 | ULONGLONG WriteOperationCount;
|
---|
789 | ULONGLONG OtherOperationCount;
|
---|
790 | ULONGLONG ReadTransferCount;
|
---|
791 | ULONGLONG WriteTransferCount;
|
---|
792 | ULONGLONG OtherTransferCount;
|
---|
793 | } IO_COUNTERS;
|
---|
794 | typedef IO_COUNTERS *PIO_COUNTERS;
|
---|
795 | #endif
|
---|
796 |
|
---|
797 | typedef struct _RTNT_SYSTEM_PROCESS_INFORMATION
|
---|
798 | {
|
---|
799 | ULONG NextEntryOffset; /**< 0x00 / 0x00 */
|
---|
800 | ULONG NumberOfThreads; /**< 0x04 / 0x04 */
|
---|
801 | LARGE_INTEGER Reserved1[3]; /**< 0x08 / 0x08 */
|
---|
802 | LARGE_INTEGER CreationTime; /**< 0x20 / 0x20 */
|
---|
803 | LARGE_INTEGER UserTime; /**< 0x28 / 0x28 */
|
---|
804 | LARGE_INTEGER KernelTime; /**< 0x30 / 0x30 */
|
---|
805 | UNICODE_STRING ProcessName; /**< 0x38 / 0x38 Clean unicode encoding? */
|
---|
806 | int32_t BasePriority; /**< 0x40 / 0x48 */
|
---|
807 | HANDLE UniqueProcessId; /**< 0x44 / 0x50 */
|
---|
808 | HANDLE ParentProcessId; /**< 0x48 / 0x58 */
|
---|
809 | ULONG HandleCount; /**< 0x4c / 0x60 */
|
---|
810 | ULONG Reserved2; /**< 0x50 / 0x64 Session ID? */
|
---|
811 | ULONG_PTR Reserved3; /**< 0x54 / 0x68 */
|
---|
812 | VM_COUNTERS VmCounters; /**< 0x58 / 0x70 */
|
---|
813 | IO_COUNTERS IoCounters; /**< 0x88 / 0xd0 Might not be present in earlier windows versions. */
|
---|
814 | /* After this follows the threads, then the ProcessName.Buffer. */
|
---|
815 | } RTNT_SYSTEM_PROCESS_INFORMATION;
|
---|
816 | typedef RTNT_SYSTEM_PROCESS_INFORMATION *PRTNT_SYSTEM_PROCESS_INFORMATION;
|
---|
817 | #ifndef IPRT_NT_USE_WINTERNL
|
---|
818 | typedef RTNT_SYSTEM_PROCESS_INFORMATION SYSTEM_PROCESS_INFORMATION ;
|
---|
819 | typedef SYSTEM_PROCESS_INFORMATION *PSYSTEM_PROCESS_INFORMATION;
|
---|
820 | #endif
|
---|
821 |
|
---|
822 | typedef struct _SYSTEM_HANDLE_ENTRY_INFO
|
---|
823 | {
|
---|
824 | USHORT UniqueProcessId;
|
---|
825 | USHORT CreatorBackTraceIndex;
|
---|
826 | UCHAR ObjectTypeIndex;
|
---|
827 | UCHAR HandleAttributes;
|
---|
828 | USHORT HandleValue;
|
---|
829 | PVOID Object;
|
---|
830 | ULONG GrantedAccess;
|
---|
831 | } SYSTEM_HANDLE_ENTRY_INFO;
|
---|
832 | typedef SYSTEM_HANDLE_ENTRY_INFO *PSYSTEM_HANDLE_ENTRY_INFO;
|
---|
833 |
|
---|
834 | /** Returned by SystemHandleInformation */
|
---|
835 | typedef struct _SYSTEM_HANDLE_INFORMATION
|
---|
836 | {
|
---|
837 | ULONG NumberOfHandles;
|
---|
838 | SYSTEM_HANDLE_ENTRY_INFO Handles[1];
|
---|
839 | } SYSTEM_HANDLE_INFORMATION;
|
---|
840 | typedef SYSTEM_HANDLE_INFORMATION *PSYSTEM_HANDLE_INFORMATION;
|
---|
841 |
|
---|
842 | /** Extended handle information entry.
|
---|
843 | * @remarks 3 x PVOID + 4 x ULONG = 28 bytes on 32-bit / 40 bytes on 64-bit */
|
---|
844 | typedef struct _SYSTEM_HANDLE_ENTRY_INFO_EX
|
---|
845 | {
|
---|
846 | PVOID Object;
|
---|
847 | HANDLE UniqueProcessId;
|
---|
848 | HANDLE HandleValue;
|
---|
849 | ACCESS_MASK GrantedAccess;
|
---|
850 | USHORT CreatorBackTraceIndex;
|
---|
851 | USHORT ObjectTypeIndex;
|
---|
852 | ULONG HandleAttributes;
|
---|
853 | ULONG Reserved;
|
---|
854 | } SYSTEM_HANDLE_ENTRY_INFO_EX;
|
---|
855 | typedef SYSTEM_HANDLE_ENTRY_INFO_EX *PSYSTEM_HANDLE_ENTRY_INFO_EX;
|
---|
856 |
|
---|
857 | /** Returned by SystemExtendedHandleInformation. */
|
---|
858 | typedef struct _SYSTEM_HANDLE_INFORMATION_EX
|
---|
859 | {
|
---|
860 | ULONG_PTR NumberOfHandles;
|
---|
861 | ULONG_PTR Reserved;
|
---|
862 | SYSTEM_HANDLE_ENTRY_INFO_EX Handles[1];
|
---|
863 | } SYSTEM_HANDLE_INFORMATION_EX;
|
---|
864 | typedef SYSTEM_HANDLE_INFORMATION_EX *PSYSTEM_HANDLE_INFORMATION_EX;
|
---|
865 |
|
---|
866 | /** Input to SystemSessionProcessInformation. */
|
---|
867 | typedef struct _SYSTEM_SESSION_PROCESS_INFORMATION
|
---|
868 | {
|
---|
869 | ULONG SessionId;
|
---|
870 | ULONG BufferLength;
|
---|
871 | /** Return buffer, SYSTEM_PROCESS_INFORMATION entries. */
|
---|
872 | PVOID Buffer;
|
---|
873 | } SYSTEM_SESSION_PROCESS_INFORMATION;
|
---|
874 | typedef SYSTEM_SESSION_PROCESS_INFORMATION *PSYSTEM_SESSION_PROCESS_INFORMATION;
|
---|
875 |
|
---|
876 | NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
|
---|
877 |
|
---|
878 | NTSYSAPI NTSTATUS NTAPI NtDelayExecution(BOOLEAN, PLARGE_INTEGER);
|
---|
879 | NTSYSAPI NTSTATUS NTAPI NtYieldExecution(void);
|
---|
880 |
|
---|
881 | NTSYSAPI NTSTATUS NTAPI RtlAddAccessDeniedAce(PACL, ULONG, ULONG, PSID);
|
---|
882 |
|
---|
883 | RT_C_DECLS_END
|
---|
884 | /** @} */
|
---|
885 |
|
---|
886 |
|
---|
887 | #if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
|
---|
888 | /** @name NT Kernel APIs
|
---|
889 | * @{ */
|
---|
890 | NTSYSAPI BOOLEAN NTAPI ObFindHandleForObject(PEPROCESS pProcess, PVOID pvObject, POBJECT_TYPE pObjectType,
|
---|
891 | PVOID pvOptionalConditions, PHANDLE phFound);
|
---|
892 | NTSYSAPI NTSTATUS NTAPI ObReferenceObjectByName(PUNICODE_STRING pObjectPath, ULONG fAttributes, PACCESS_STATE pAccessState,
|
---|
893 | ACCESS_MASK fDesiredAccess, POBJECT_TYPE pObjectType,
|
---|
894 | KPROCESSOR_MODE enmAccessMode, PVOID pvParseContext, PVOID *ppvObject);
|
---|
895 | NTSYSAPI HANDLE NTAPI PsGetProcessInheritedFromUniqueProcessId(PEPROCESS);
|
---|
896 | NTSYSAPI UCHAR * NTAPI PsGetProcessImageFileName(PEPROCESS);
|
---|
897 | NTSYSAPI BOOLEAN NTAPI PsIsProcessBeingDebugged(PEPROCESS);
|
---|
898 | NTSYSAPI ULONG NTAPI PsGetProcessSessionId(PEPROCESS);
|
---|
899 | extern DECLIMPORT(POBJECT_TYPE *) LpcPortObjectType; /**< In vista+ this is the ALPC port object type. */
|
---|
900 | extern DECLIMPORT(POBJECT_TYPE *) LpcWaitablePortObjectType; /**< In vista+ this is the ALPC port object type. */
|
---|
901 |
|
---|
902 | /** @ */
|
---|
903 | #endif /* IN_RING0 */
|
---|
904 |
|
---|
905 | #endif
|
---|
906 |
|
---|