[NTDDK]
[reactos.git] / include / ddk / ntddk.h
1 /*
2 * ntddk.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * DEFINES:
22 * DBG - Debugging enabled/disabled (0/1)
23 * POOL_TAGGING - Enable pool tagging
24 * _X86_ - X86 environment
25 */
26
27 #pragma once
28
29 #define _NTDDK_
30
31 #if !defined(_NTHAL_) && !defined(_NTIFS_)
32 #define _NTDDK_INCLUDED_
33 #define _DDK_DRIVER_
34 #endif
35
36 /* Dependencies */
37
38 #define NT_INCLUDED
39 #define _CTYPE_DISABLE_MACROS
40
41 #include <wdm.h>
42 #include <excpt.h>
43 #include <ntdef.h>
44 #include <ntstatus.h>
45
46 /* FIXME
47 #include <bugcodes.h>
48 #include <ntiologc.h>
49 */
50
51 #include <stdarg.h> // FIXME
52 #include <basetyps.h> // FIXME
53
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 typedef struct _BUS_HANDLER *PBUS_HANDLER;
60 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
61 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
62 #if defined(_NTHAL_INCLUDED_)
63 typedef struct _KPROCESS *PEPROCESS;
64 typedef struct _ETHREAD *PETHREAD;
65 typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
66 #elif defined(_NTIFS_INCLUDED_)
67 typedef struct _KPROCESS *PEPROCESS;
68 typedef struct _KTHREAD *PETHREAD;
69 #else
70 typedef struct _EPROCESS *PEPROCESS;
71 typedef struct _ETHREAD *PETHREAD;
72 #endif
73 typedef struct _IO_TIMER *PIO_TIMER;
74 typedef struct _KINTERRUPT *PKINTERRUPT;
75 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
76 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
77 typedef struct _PEB *PPEB;
78 typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
79 typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
80
81 #ifdef _WIN64
82 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
83 #else
84 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
85 #endif
86
87 #define PsGetCurrentProcess IoGetCurrentProcess
88
89 #if (NTDDI_VERSION >= NTDDI_VISTA)
90 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
91 #elif (NTDDI_VERSION >= NTDDI_WINXP)
92 extern NTSYSAPI CCHAR KeNumberProcessors;
93 #else
94 extern PCCHAR KeNumberProcessors;
95 #endif
96
97 /* FIXME
98 #include <mce.h>
99 */
100
101 #ifdef _X86_
102
103 #define KERNEL_STACK_SIZE 12288
104 #define KERNEL_LARGE_STACK_SIZE 61440
105 #define KERNEL_LARGE_STACK_COMMIT 12288
106
107 #define SIZE_OF_80387_REGISTERS 80
108
109 #if !defined(RC_INVOKED)
110
111 #define CONTEXT_i386 0x10000
112 #define CONTEXT_i486 0x10000
113 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
114 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
115 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
116 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
117 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
118 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
119
120 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
121 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
122 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
123 CONTEXT_EXTENDED_REGISTERS)
124
125 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L)
126
127 #endif /* !defined(RC_INVOKED) */
128
129 typedef struct _FLOATING_SAVE_AREA {
130 ULONG ControlWord;
131 ULONG StatusWord;
132 ULONG TagWord;
133 ULONG ErrorOffset;
134 ULONG ErrorSelector;
135 ULONG DataOffset;
136 ULONG DataSelector;
137 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
138 ULONG Cr0NpxState;
139 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
140
141 #include "pshpack4.h"
142 typedef struct _CONTEXT {
143 ULONG ContextFlags;
144 ULONG Dr0;
145 ULONG Dr1;
146 ULONG Dr2;
147 ULONG Dr3;
148 ULONG Dr6;
149 ULONG Dr7;
150 FLOATING_SAVE_AREA FloatSave;
151 ULONG SegGs;
152 ULONG SegFs;
153 ULONG SegEs;
154 ULONG SegDs;
155 ULONG Edi;
156 ULONG Esi;
157 ULONG Ebx;
158 ULONG Edx;
159 ULONG Ecx;
160 ULONG Eax;
161 ULONG Ebp;
162 ULONG Eip;
163 ULONG SegCs;
164 ULONG EFlags;
165 ULONG Esp;
166 ULONG SegSs;
167 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
168 } CONTEXT, *PCONTEXT;
169 #include "poppack.h"
170
171 #endif /* _X86_ */
172
173 #ifdef _AMD64_
174
175 #define KERNEL_STACK_SIZE 0x6000
176 #define KERNEL_LARGE_STACK_SIZE 0x12000
177 #define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
178
179 #define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
180
181 #define EXCEPTION_READ_FAULT 0
182 #define EXCEPTION_WRITE_FAULT 1
183 #define EXCEPTION_EXECUTE_FAULT 8
184
185 #if !defined(RC_INVOKED)
186
187 #define CONTEXT_AMD64 0x100000
188
189 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
190 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
191 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
192 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
193 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
194
195 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
196 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
197
198 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
199
200 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
201 #define CONTEXT_SERVICE_ACTIVE 0x10000000
202 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
203 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
204
205 #endif /* !defined(RC_INVOKED) */
206
207 #define INITIAL_MXCSR 0x1f80
208 #define INITIAL_FPCSR 0x027f
209
210 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
211 ULONG64 P1Home;
212 ULONG64 P2Home;
213 ULONG64 P3Home;
214 ULONG64 P4Home;
215 ULONG64 P5Home;
216 ULONG64 P6Home;
217 ULONG ContextFlags;
218 ULONG MxCsr;
219 USHORT SegCs;
220 USHORT SegDs;
221 USHORT SegEs;
222 USHORT SegFs;
223 USHORT SegGs;
224 USHORT SegSs;
225 ULONG EFlags;
226 ULONG64 Dr0;
227 ULONG64 Dr1;
228 ULONG64 Dr2;
229 ULONG64 Dr3;
230 ULONG64 Dr6;
231 ULONG64 Dr7;
232 ULONG64 Rax;
233 ULONG64 Rcx;
234 ULONG64 Rdx;
235 ULONG64 Rbx;
236 ULONG64 Rsp;
237 ULONG64 Rbp;
238 ULONG64 Rsi;
239 ULONG64 Rdi;
240 ULONG64 R8;
241 ULONG64 R9;
242 ULONG64 R10;
243 ULONG64 R11;
244 ULONG64 R12;
245 ULONG64 R13;
246 ULONG64 R14;
247 ULONG64 R15;
248 ULONG64 Rip;
249 union {
250 XMM_SAVE_AREA32 FltSave;
251 struct {
252 M128A Header[2];
253 M128A Legacy[8];
254 M128A Xmm0;
255 M128A Xmm1;
256 M128A Xmm2;
257 M128A Xmm3;
258 M128A Xmm4;
259 M128A Xmm5;
260 M128A Xmm6;
261 M128A Xmm7;
262 M128A Xmm8;
263 M128A Xmm9;
264 M128A Xmm10;
265 M128A Xmm11;
266 M128A Xmm12;
267 M128A Xmm13;
268 M128A Xmm14;
269 M128A Xmm15;
270 } DUMMYSTRUCTNAME;
271 } DUMMYUNIONNAME;
272 M128A VectorRegister[26];
273 ULONG64 VectorControl;
274 ULONG64 DebugControl;
275 ULONG64 LastBranchToRip;
276 ULONG64 LastBranchFromRip;
277 ULONG64 LastExceptionToRip;
278 ULONG64 LastExceptionFromRip;
279 } CONTEXT, *PCONTEXT;
280
281 #endif /* _AMD64_ */
282
283 typedef enum _WELL_KNOWN_SID_TYPE {
284 WinNullSid = 0,
285 WinWorldSid = 1,
286 WinLocalSid = 2,
287 WinCreatorOwnerSid = 3,
288 WinCreatorGroupSid = 4,
289 WinCreatorOwnerServerSid = 5,
290 WinCreatorGroupServerSid = 6,
291 WinNtAuthoritySid = 7,
292 WinDialupSid = 8,
293 WinNetworkSid = 9,
294 WinBatchSid = 10,
295 WinInteractiveSid = 11,
296 WinServiceSid = 12,
297 WinAnonymousSid = 13,
298 WinProxySid = 14,
299 WinEnterpriseControllersSid = 15,
300 WinSelfSid = 16,
301 WinAuthenticatedUserSid = 17,
302 WinRestrictedCodeSid = 18,
303 WinTerminalServerSid = 19,
304 WinRemoteLogonIdSid = 20,
305 WinLogonIdsSid = 21,
306 WinLocalSystemSid = 22,
307 WinLocalServiceSid = 23,
308 WinNetworkServiceSid = 24,
309 WinBuiltinDomainSid = 25,
310 WinBuiltinAdministratorsSid = 26,
311 WinBuiltinUsersSid = 27,
312 WinBuiltinGuestsSid = 28,
313 WinBuiltinPowerUsersSid = 29,
314 WinBuiltinAccountOperatorsSid = 30,
315 WinBuiltinSystemOperatorsSid = 31,
316 WinBuiltinPrintOperatorsSid = 32,
317 WinBuiltinBackupOperatorsSid = 33,
318 WinBuiltinReplicatorSid = 34,
319 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
320 WinBuiltinRemoteDesktopUsersSid = 36,
321 WinBuiltinNetworkConfigurationOperatorsSid = 37,
322 WinAccountAdministratorSid = 38,
323 WinAccountGuestSid = 39,
324 WinAccountKrbtgtSid = 40,
325 WinAccountDomainAdminsSid = 41,
326 WinAccountDomainUsersSid = 42,
327 WinAccountDomainGuestsSid = 43,
328 WinAccountComputersSid = 44,
329 WinAccountControllersSid = 45,
330 WinAccountCertAdminsSid = 46,
331 WinAccountSchemaAdminsSid = 47,
332 WinAccountEnterpriseAdminsSid = 48,
333 WinAccountPolicyAdminsSid = 49,
334 WinAccountRasAndIasServersSid = 50,
335 WinNTLMAuthenticationSid = 51,
336 WinDigestAuthenticationSid = 52,
337 WinSChannelAuthenticationSid = 53,
338 WinThisOrganizationSid = 54,
339 WinOtherOrganizationSid = 55,
340 WinBuiltinIncomingForestTrustBuildersSid = 56,
341 WinBuiltinPerfMonitoringUsersSid = 57,
342 WinBuiltinPerfLoggingUsersSid = 58,
343 WinBuiltinAuthorizationAccessSid = 59,
344 WinBuiltinTerminalServerLicenseServersSid = 60,
345 WinBuiltinDCOMUsersSid = 61,
346 WinBuiltinIUsersSid = 62,
347 WinIUserSid = 63,
348 WinBuiltinCryptoOperatorsSid = 64,
349 WinUntrustedLabelSid = 65,
350 WinLowLabelSid = 66,
351 WinMediumLabelSid = 67,
352 WinHighLabelSid = 68,
353 WinSystemLabelSid = 69,
354 WinWriteRestrictedCodeSid = 70,
355 WinCreatorOwnerRightsSid = 71,
356 WinCacheablePrincipalsGroupSid = 72,
357 WinNonCacheablePrincipalsGroupSid = 73,
358 WinEnterpriseReadonlyControllersSid = 74,
359 WinAccountReadonlyControllersSid = 75,
360 WinBuiltinEventLogReadersGroup = 76,
361 WinNewEnterpriseReadonlyControllersSid = 77,
362 WinBuiltinCertSvcDComAccessGroup = 78,
363 WinMediumPlusLabelSid = 79,
364 WinLocalLogonSid = 80,
365 WinConsoleLogonSid = 81,
366 WinThisOrganizationCertificateSid = 82,
367 } WELL_KNOWN_SID_TYPE;
368
369 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
370
371 #ifndef _RTL_RUN_ONCE_DEF
372 #define _RTL_RUN_ONCE_DEF
373
374 #define RTL_RUN_ONCE_INIT {0}
375
376 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL
377 #define RTL_RUN_ONCE_ASYNC 0x00000002UL
378 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL
379
380 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
381
382 #define RTL_HASH_ALLOCATED_HEADER 0x00000001
383
384 #define RTL_HASH_RESERVED_SIGNATURE 0
385
386 /* RtlVerifyVersionInfo() ComparisonType */
387
388 #define VER_EQUAL 1
389 #define VER_GREATER 2
390 #define VER_GREATER_EQUAL 3
391 #define VER_LESS 4
392 #define VER_LESS_EQUAL 5
393 #define VER_AND 6
394 #define VER_OR 7
395
396 #define VER_CONDITION_MASK 7
397 #define VER_NUM_BITS_PER_CONDITION_MASK 3
398
399 /* RtlVerifyVersionInfo() TypeMask */
400
401 #define VER_MINORVERSION 0x0000001
402 #define VER_MAJORVERSION 0x0000002
403 #define VER_BUILDNUMBER 0x0000004
404 #define VER_PLATFORMID 0x0000008
405 #define VER_SERVICEPACKMINOR 0x0000010
406 #define VER_SERVICEPACKMAJOR 0x0000020
407 #define VER_SUITENAME 0x0000040
408 #define VER_PRODUCT_TYPE 0x0000080
409
410 #define VER_NT_WORKSTATION 0x0000001
411 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
412 #define VER_NT_SERVER 0x0000003
413
414 #define VER_PLATFORM_WIN32s 0
415 #define VER_PLATFORM_WIN32_WINDOWS 1
416 #define VER_PLATFORM_WIN32_NT 2
417
418 typedef union _RTL_RUN_ONCE {
419 PVOID Ptr;
420 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
421
422 typedef ULONG /* LOGICAL */
423 (NTAPI *PRTL_RUN_ONCE_INIT_FN) (
424 IN OUT PRTL_RUN_ONCE RunOnce,
425 IN OUT PVOID Parameter OPTIONAL,
426 IN OUT PVOID *Context OPTIONAL);
427
428 #endif /* _RTL_RUN_ONCE_DEF */
429
430 typedef enum _TABLE_SEARCH_RESULT {
431 TableEmptyTree,
432 TableFoundNode,
433 TableInsertAsLeft,
434 TableInsertAsRight
435 } TABLE_SEARCH_RESULT;
436
437 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
438 GenericLessThan,
439 GenericGreaterThan,
440 GenericEqual
441 } RTL_GENERIC_COMPARE_RESULTS;
442
443 // Forwarder
444 struct _RTL_AVL_TABLE;
445
446 typedef RTL_GENERIC_COMPARE_RESULTS
447 (NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
448 IN struct _RTL_AVL_TABLE *Table,
449 IN PVOID FirstStruct,
450 IN PVOID SecondStruct);
451
452 typedef PVOID
453 (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
454 IN struct _RTL_AVL_TABLE *Table,
455 IN CLONG ByteSize);
456
457 typedef VOID
458 (NTAPI *PRTL_AVL_FREE_ROUTINE) (
459 IN struct _RTL_AVL_TABLE *Table,
460 IN PVOID Buffer);
461
462 typedef NTSTATUS
463 (NTAPI *PRTL_AVL_MATCH_FUNCTION) (
464 IN struct _RTL_AVL_TABLE *Table,
465 IN PVOID UserData,
466 IN PVOID MatchData);
467
468 typedef struct _RTL_BALANCED_LINKS {
469 struct _RTL_BALANCED_LINKS *Parent;
470 struct _RTL_BALANCED_LINKS *LeftChild;
471 struct _RTL_BALANCED_LINKS *RightChild;
472 CHAR Balance;
473 UCHAR Reserved[3];
474 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
475
476 typedef struct _RTL_AVL_TABLE {
477 RTL_BALANCED_LINKS BalancedRoot;
478 PVOID OrderedPointer;
479 ULONG WhichOrderedElement;
480 ULONG NumberGenericTableElements;
481 ULONG DepthOfTree;
482 PRTL_BALANCED_LINKS RestartKey;
483 ULONG DeleteCount;
484 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
485 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
486 PRTL_AVL_FREE_ROUTINE FreeRoutine;
487 PVOID TableContext;
488 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
489
490 #ifndef RTL_USE_AVL_TABLES
491
492 struct _RTL_GENERIC_TABLE;
493
494 typedef RTL_GENERIC_COMPARE_RESULTS
495 (NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
496 IN struct _RTL_GENERIC_TABLE *Table,
497 IN PVOID FirstStruct,
498 IN PVOID SecondStruct);
499
500 typedef PVOID
501 (NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
502 IN struct _RTL_GENERIC_TABLE *Table,
503 IN CLONG ByteSize);
504
505 typedef VOID
506 (NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
507 IN struct _RTL_GENERIC_TABLE *Table,
508 IN PVOID Buffer);
509
510 typedef struct _RTL_GENERIC_TABLE {
511 PRTL_SPLAY_LINKS TableRoot;
512 LIST_ENTRY InsertOrderList;
513 PLIST_ENTRY OrderedPointer;
514 ULONG WhichOrderedElement;
515 ULONG NumberGenericTableElements;
516 PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
517 PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
518 PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
519 PVOID TableContext;
520 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
521
522 #if (NTDDI_VERSION >= NTDDI_WIN2K)
523
524 NTSYSAPI
525 VOID
526 NTAPI
527 RtlInitializeGenericTable(
528 OUT PRTL_GENERIC_TABLE Table,
529 IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine,
530 IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine,
531 IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine,
532 IN PVOID TableContext OPTIONAL);
533
534 NTSYSAPI
535 PVOID
536 NTAPI
537 RtlInsertElementGenericTable(
538 IN PRTL_GENERIC_TABLE Table,
539 IN PVOID Buffer,
540 IN CLONG BufferSize,
541 OUT PBOOLEAN NewElement OPTIONAL);
542
543 NTSYSAPI
544 PVOID
545 NTAPI
546 RtlInsertElementGenericTableFull(
547 IN PRTL_GENERIC_TABLE Table,
548 IN PVOID Buffer,
549 IN CLONG BufferSize,
550 OUT PBOOLEAN NewElement OPTIONAL,
551 IN PVOID NodeOrParent,
552 IN TABLE_SEARCH_RESULT SearchResult);
553
554 NTSYSAPI
555 BOOLEAN
556 NTAPI
557 RtlDeleteElementGenericTable(
558 IN PRTL_GENERIC_TABLE Table,
559 IN PVOID Buffer);
560
561 NTSYSAPI
562 PVOID
563 NTAPI
564 RtlLookupElementGenericTable(
565 IN PRTL_GENERIC_TABLE Table,
566 IN PVOID Buffer);
567
568 NTSYSAPI
569 PVOID
570 NTAPI
571 RtlLookupElementGenericTableFull(
572 IN PRTL_GENERIC_TABLE Table,
573 IN PVOID Buffer,
574 OUT PVOID *NodeOrParent,
575 OUT TABLE_SEARCH_RESULT *SearchResult);
576
577 NTSYSAPI
578 PVOID
579 NTAPI
580 RtlEnumerateGenericTable(
581 IN PRTL_GENERIC_TABLE Table,
582 IN BOOLEAN Restart);
583
584 NTSYSAPI
585 PVOID
586 NTAPI
587 RtlEnumerateGenericTableWithoutSplaying(
588 IN PRTL_GENERIC_TABLE Table,
589 IN OUT PVOID *RestartKey);
590
591 NTSYSAPI
592 PVOID
593 NTAPI
594 RtlGetElementGenericTable(
595 IN PRTL_GENERIC_TABLE Table,
596 IN ULONG I);
597
598 NTSYSAPI
599 ULONG
600 NTAPI
601 RtlNumberGenericTableElements(
602 IN PRTL_GENERIC_TABLE Table);
603
604 NTSYSAPI
605 BOOLEAN
606 NTAPI
607 RtlIsGenericTableEmpty(
608 IN PRTL_GENERIC_TABLE Table);
609
610 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
611
612 #endif /* RTL_USE_AVL_TABLES */
613
614 #ifdef RTL_USE_AVL_TABLES
615
616 #undef PRTL_GENERIC_COMPARE_ROUTINE
617 #undef RTL_GENERIC_COMPARE_ROUTINE
618 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
619 #undef RTL_GENERIC_ALLOCATE_ROUTINE
620 #undef PRTL_GENERIC_FREE_ROUTINE
621 #undef RTL_GENERIC_FREE_ROUTINE
622 #undef RTL_GENERIC_TABLE
623 #undef PRTL_GENERIC_TABLE
624
625 #define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE
626 #define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE
627 #define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE
628 #define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE
629 #define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE
630 #define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE
631 #define RTL_GENERIC_TABLE RTL_AVL_TABLE
632 #define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
633
634 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
635 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
636 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
637 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
638 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
639 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
640 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
641 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
642 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
643 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
644 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
645
646 #endif /* RTL_USE_AVL_TABLES */
647
648 typedef struct _RTL_SPLAY_LINKS {
649 struct _RTL_SPLAY_LINKS *Parent;
650 struct _RTL_SPLAY_LINKS *LeftChild;
651 struct _RTL_SPLAY_LINKS *RightChild;
652 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
653
654 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY {
655 LIST_ENTRY Linkage;
656 ULONG_PTR Signature;
657 } RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY;
658
659 typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT {
660 PLIST_ENTRY ChainHead;
661 PLIST_ENTRY PrevLinkage;
662 ULONG_PTR Signature;
663 } RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT;
664
665 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR {
666 RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry;
667 PLIST_ENTRY ChainHead;
668 ULONG BucketIndex;
669 } RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR;
670
671 typedef struct _RTL_DYNAMIC_HASH_TABLE {
672 ULONG Flags;
673 ULONG Shift;
674 ULONG TableSize;
675 ULONG Pivot;
676 ULONG DivisorMask;
677 ULONG NumEntries;
678 ULONG NonEmptyBuckets;
679 ULONG NumEnumerators;
680 PVOID Directory;
681 } RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE;
682
683 typedef struct _OSVERSIONINFOA {
684 ULONG dwOSVersionInfoSize;
685 ULONG dwMajorVersion;
686 ULONG dwMinorVersion;
687 ULONG dwBuildNumber;
688 ULONG dwPlatformId;
689 CHAR szCSDVersion[128];
690 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
691
692 typedef struct _OSVERSIONINFOW {
693 ULONG dwOSVersionInfoSize;
694 ULONG dwMajorVersion;
695 ULONG dwMinorVersion;
696 ULONG dwBuildNumber;
697 ULONG dwPlatformId;
698 WCHAR szCSDVersion[128];
699 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
700
701 typedef struct _OSVERSIONINFOEXA {
702 ULONG dwOSVersionInfoSize;
703 ULONG dwMajorVersion;
704 ULONG dwMinorVersion;
705 ULONG dwBuildNumber;
706 ULONG dwPlatformId;
707 CHAR szCSDVersion[128];
708 USHORT wServicePackMajor;
709 USHORT wServicePackMinor;
710 USHORT wSuiteMask;
711 UCHAR wProductType;
712 UCHAR wReserved;
713 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
714
715 typedef struct _OSVERSIONINFOEXW {
716 ULONG dwOSVersionInfoSize;
717 ULONG dwMajorVersion;
718 ULONG dwMinorVersion;
719 ULONG dwBuildNumber;
720 ULONG dwPlatformId;
721 WCHAR szCSDVersion[128];
722 USHORT wServicePackMajor;
723 USHORT wServicePackMinor;
724 USHORT wSuiteMask;
725 UCHAR wProductType;
726 UCHAR wReserved;
727 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
728
729 #ifdef UNICODE
730 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
731 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
732 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
733 typedef OSVERSIONINFOW OSVERSIONINFO;
734 typedef POSVERSIONINFOW POSVERSIONINFO;
735 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
736 #else
737 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
738 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
739 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
740 typedef OSVERSIONINFOA OSVERSIONINFO;
741 typedef POSVERSIONINFOA POSVERSIONINFO;
742 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
743 #endif /* UNICODE */
744
745 #define HASH_ENTRY_KEY(x) ((x)->Signature)
746
747 #define RtlInitializeSplayLinks(Links) { \
748 PRTL_SPLAY_LINKS _SplayLinks; \
749 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
750 _SplayLinks->Parent = _SplayLinks; \
751 _SplayLinks->LeftChild = NULL; \
752 _SplayLinks->RightChild = NULL; \
753 }
754
755 #define RtlIsLeftChild(Links) \
756 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
757
758 #define RtlIsRightChild(Links) \
759 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
760
761 #define RtlRightChild(Links) \
762 ((PRTL_SPLAY_LINKS)(Links))->RightChild
763
764 #define RtlIsRoot(Links) \
765 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
766
767 #define RtlLeftChild(Links) \
768 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
769
770 #define RtlParent(Links) \
771 ((PRTL_SPLAY_LINKS)(Links))->Parent
772
773 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
774 { \
775 PRTL_SPLAY_LINKS _SplayParent; \
776 PRTL_SPLAY_LINKS _SplayChild; \
777 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
778 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
779 _SplayParent->LeftChild = _SplayChild; \
780 _SplayChild->Parent = _SplayParent; \
781 }
782
783 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
784 { \
785 PRTL_SPLAY_LINKS _SplayParent; \
786 PRTL_SPLAY_LINKS _SplayChild; \
787 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
788 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
789 _SplayParent->RightChild = _SplayChild; \
790 _SplayChild->Parent = _SplayParent; \
791 }
792
793 #define RtlEqualLuid(L1, L2) (((L1)->LowPart == (L2)->LowPart) && \
794 ((L1)->HighPart == (L2)->HighPart))
795
796 #define RtlIsZeroLuid(L1) ((BOOLEAN) (((L1)->LowPart | (L1)->HighPart) == 0))
797
798 #if !defined(MIDL_PASS)
799
800 FORCEINLINE
801 LUID
802 NTAPI_INLINE
803 RtlConvertLongToLuid(
804 IN LONG Val)
805 {
806 LUID Luid;
807 LARGE_INTEGER Temp;
808
809 Temp.QuadPart = Val;
810 Luid.LowPart = Temp.u.LowPart;
811 Luid.HighPart = Temp.u.HighPart;
812 return Luid;
813 }
814
815 FORCEINLINE
816 LUID
817 NTAPI_INLINE
818 RtlConvertUlongToLuid(
819 IN ULONG Val)
820 {
821 LUID Luid;
822
823 Luid.LowPart = Val;
824 Luid.HighPart = 0;
825 return Luid;
826 }
827
828 #endif /* !defined(MIDL_PASS) */
829
830 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
831 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
832 *CallersAddress = (PVOID)_ReturnAddress(); \
833 *CallersCaller = NULL;
834 #else
835 #if (NTDDI_VERSION >= NTDDI_WIN2K)
836 NTSYSAPI
837 VOID
838 NTAPI
839 RtlGetCallersAddress(
840 OUT PVOID *CallersAddress,
841 OUT PVOID *CallersCaller);
842 #endif
843 #endif
844
845 #if (NTDDI_VERSION >= NTDDI_WIN2K)
846
847 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
848
849 NTSYSAPI
850 PRTL_SPLAY_LINKS
851 NTAPI
852 RtlSplay(
853 IN OUT PRTL_SPLAY_LINKS Links);
854
855 NTSYSAPI
856 PRTL_SPLAY_LINKS
857 NTAPI
858 RtlDelete(
859 IN PRTL_SPLAY_LINKS Links);
860
861 NTSYSAPI
862 VOID
863 NTAPI
864 RtlDeleteNoSplay(
865 IN PRTL_SPLAY_LINKS Links,
866 IN OUT PRTL_SPLAY_LINKS *Root);
867
868 NTSYSAPI
869 PRTL_SPLAY_LINKS
870 NTAPI
871 RtlSubtreeSuccessor(
872 IN PRTL_SPLAY_LINKS Links);
873
874 NTSYSAPI
875 PRTL_SPLAY_LINKS
876 NTAPI
877 RtlSubtreePredecessor(
878 IN PRTL_SPLAY_LINKS Links);
879
880 NTSYSAPI
881 PRTL_SPLAY_LINKS
882 NTAPI
883 RtlRealSuccessor(
884 IN PRTL_SPLAY_LINKS Links);
885
886 NTSYSAPI
887 PRTL_SPLAY_LINKS
888 NTAPI
889 RtlRealPredecessor(
890 IN PRTL_SPLAY_LINKS Links);
891
892 NTSYSAPI
893 BOOLEAN
894 NTAPI
895 RtlPrefixUnicodeString(
896 IN PCUNICODE_STRING String1,
897 IN PCUNICODE_STRING String2,
898 IN BOOLEAN CaseInSensitive);
899
900 NTSYSAPI
901 VOID
902 NTAPI
903 RtlUpperString(
904 IN OUT PSTRING DestinationString,
905 IN const PSTRING SourceString);
906
907 NTSYSAPI
908 NTSTATUS
909 NTAPI
910 RtlUpcaseUnicodeString(
911 IN OUT PUNICODE_STRING DestinationString,
912 IN PCUNICODE_STRING SourceString,
913 IN BOOLEAN AllocateDestinationString);
914
915 NTSYSAPI
916 VOID
917 NTAPI
918 RtlMapGenericMask(
919 IN OUT PACCESS_MASK AccessMask,
920 IN PGENERIC_MAPPING GenericMapping);
921
922 NTSYSAPI
923 NTSTATUS
924 NTAPI
925 RtlVolumeDeviceToDosName(
926 IN PVOID VolumeDeviceObject,
927 OUT PUNICODE_STRING DosName);
928
929 NTSYSAPI
930 NTSTATUS
931 NTAPI
932 RtlGetVersion(
933 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
934
935 NTSYSAPI
936 NTSTATUS
937 NTAPI
938 RtlVerifyVersionInfo(
939 IN PRTL_OSVERSIONINFOEXW VersionInfo,
940 IN ULONG TypeMask,
941 IN ULONGLONG ConditionMask);
942
943 NTSYSAPI
944 LONG
945 NTAPI
946 RtlCompareString(
947 IN const PSTRING String1,
948 IN const PSTRING String2,
949 IN BOOLEAN CaseInSensitive);
950
951 NTSYSAPI
952 VOID
953 NTAPI
954 RtlCopyString(
955 OUT PSTRING DestinationString,
956 IN const PSTRING SourceString OPTIONAL);
957
958 NTSYSAPI
959 BOOLEAN
960 NTAPI
961 RtlEqualString(
962 IN const PSTRING String1,
963 IN const PSTRING String2,
964 IN BOOLEAN CaseInSensitive);
965
966 NTSYSAPI
967 NTSTATUS
968 NTAPI
969 RtlCharToInteger(
970 IN PCSZ String,
971 IN ULONG Base OPTIONAL,
972 OUT PULONG Value);
973
974 NTSYSAPI
975 CHAR
976 NTAPI
977 RtlUpperChar(
978 IN CHAR Character);
979
980 NTSYSAPI
981 ULONG
982 NTAPI
983 RtlWalkFrameChain(
984 OUT PVOID *Callers,
985 IN ULONG Count,
986 IN ULONG Flags);
987
988 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
989
990 #if (NTDDI_VERSION >= NTDDI_WINXP)
991
992 NTSYSAPI
993 VOID
994 NTAPI
995 RtlInitializeGenericTableAvl(
996 OUT PRTL_AVL_TABLE Table,
997 IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
998 IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
999 IN PRTL_AVL_FREE_ROUTINE FreeRoutine,
1000 IN PVOID TableContext OPTIONAL);
1001
1002 NTSYSAPI
1003 PVOID
1004 NTAPI
1005 RtlInsertElementGenericTableAvl(
1006 IN PRTL_AVL_TABLE Table,
1007 IN PVOID Buffer,
1008 IN CLONG BufferSize,
1009 OUT PBOOLEAN NewElement OPTIONAL);
1010
1011 NTSYSAPI
1012 PVOID
1013 NTAPI
1014 RtlInsertElementGenericTableFullAvl(
1015 IN PRTL_AVL_TABLE Table,
1016 IN PVOID Buffer,
1017 IN CLONG BufferSize,
1018 OUT PBOOLEAN NewElement OPTIONAL,
1019 IN PVOID NodeOrParent,
1020 IN TABLE_SEARCH_RESULT SearchResult);
1021
1022 NTSYSAPI
1023 BOOLEAN
1024 NTAPI
1025 RtlDeleteElementGenericTableAvl(
1026 IN PRTL_AVL_TABLE Table,
1027 IN PVOID Buffer);
1028
1029 NTSYSAPI
1030 PVOID
1031 NTAPI
1032 RtlLookupElementGenericTableAvl(
1033 IN PRTL_AVL_TABLE Table,
1034 IN PVOID Buffer);
1035
1036 NTSYSAPI
1037 PVOID
1038 NTAPI
1039 RtlLookupElementGenericTableFullAvl(
1040 IN PRTL_AVL_TABLE Table,
1041 IN PVOID Buffer,
1042 OUT PVOID *NodeOrParent,
1043 OUT TABLE_SEARCH_RESULT *SearchResult);
1044
1045 NTSYSAPI
1046 PVOID
1047 NTAPI
1048 RtlEnumerateGenericTableAvl(
1049 IN PRTL_AVL_TABLE Table,
1050 IN BOOLEAN Restart);
1051
1052 NTSYSAPI
1053 PVOID
1054 NTAPI
1055 RtlEnumerateGenericTableWithoutSplayingAvl(
1056 IN PRTL_AVL_TABLE Table,
1057 IN OUT PVOID *RestartKey);
1058
1059 NTSYSAPI
1060 PVOID
1061 NTAPI
1062 RtlLookupFirstMatchingElementGenericTableAvl(
1063 IN PRTL_AVL_TABLE Table,
1064 IN PVOID Buffer,
1065 OUT PVOID *RestartKey);
1066
1067 NTSYSAPI
1068 PVOID
1069 NTAPI
1070 RtlEnumerateGenericTableLikeADirectory(
1071 IN PRTL_AVL_TABLE Table,
1072 IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL,
1073 IN PVOID MatchData OPTIONAL,
1074 IN ULONG NextFlag,
1075 IN OUT PVOID *RestartKey,
1076 IN OUT PULONG DeleteCount,
1077 IN PVOID Buffer);
1078
1079 NTSYSAPI
1080 PVOID
1081 NTAPI
1082 RtlGetElementGenericTableAvl(
1083 IN PRTL_AVL_TABLE Table,
1084 IN ULONG I);
1085
1086 NTSYSAPI
1087 ULONG
1088 NTAPI
1089 RtlNumberGenericTableElementsAvl(
1090 IN PRTL_AVL_TABLE Table);
1091
1092 NTSYSAPI
1093 BOOLEAN
1094 NTAPI
1095 RtlIsGenericTableEmptyAvl(
1096 IN PRTL_AVL_TABLE Table);
1097
1098
1099 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
1100
1101 #if (NTDDI_VERSION >= NTDDI_VISTA)
1102
1103 NTSYSAPI
1104 VOID
1105 NTAPI
1106 RtlRunOnceInitialize(
1107 OUT PRTL_RUN_ONCE RunOnce);
1108
1109 NTSYSAPI
1110 NTSTATUS
1111 NTAPI
1112 RtlRunOnceExecuteOnce(
1113 IN OUT PRTL_RUN_ONCE RunOnce,
1114 IN PRTL_RUN_ONCE_INIT_FN InitFn,
1115 IN OUT PVOID Parameter OPTIONAL,
1116 OUT PVOID *Context OPTIONAL);
1117
1118 NTSYSAPI
1119 NTSTATUS
1120 NTAPI
1121 RtlRunOnceBeginInitialize(
1122 IN OUT PRTL_RUN_ONCE RunOnce,
1123 IN ULONG Flags,
1124 OUT PVOID *Context OPTIONAL);
1125
1126 NTSYSAPI
1127 NTSTATUS
1128 NTAPI
1129 RtlRunOnceComplete(
1130 IN OUT PRTL_RUN_ONCE RunOnce,
1131 IN ULONG Flags,
1132 IN PVOID Context OPTIONAL);
1133
1134 NTSYSAPI
1135 BOOLEAN
1136 NTAPI
1137 RtlGetProductInfo(
1138 IN ULONG OSMajorVersion,
1139 IN ULONG OSMinorVersion,
1140 IN ULONG SpMajorVersion,
1141 IN ULONG SpMinorVersion,
1142 OUT PULONG ReturnedProductType);
1143
1144 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1145
1146 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
1147
1148 #if (NTDDI_VERSION >= NTDDI_WIN7)
1149
1150 FORCEINLINE
1151 VOID
1152 NTAPI
1153 RtlInitHashTableContext(
1154 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context)
1155 {
1156 Context->ChainHead = NULL;
1157 Context->PrevLinkage = NULL;
1158 }
1159
1160 FORCEINLINE
1161 VOID
1162 NTAPI
1163 RtlInitHashTableContextFromEnumerator(
1164 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context,
1165 IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator)
1166 {
1167 Context->ChainHead = Enumerator->ChainHead;
1168 Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink;
1169 }
1170
1171 FORCEINLINE
1172 VOID
1173 NTAPI
1174 RtlReleaseHashTableContext(
1175 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context)
1176 {
1177 UNREFERENCED_PARAMETER(Context);
1178 return;
1179 }
1180
1181 FORCEINLINE
1182 ULONG
1183 NTAPI
1184 RtlTotalBucketsHashTable(
1185 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
1186 {
1187 return HashTable->TableSize;
1188 }
1189
1190 FORCEINLINE
1191 ULONG
1192 NTAPI
1193 RtlNonEmptyBucketsHashTable(
1194 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
1195 {
1196 return HashTable->NonEmptyBuckets;
1197 }
1198
1199 FORCEINLINE
1200 ULONG
1201 NTAPI
1202 RtlEmptyBucketsHashTable(
1203 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
1204 {
1205 return HashTable->TableSize - HashTable->NonEmptyBuckets;
1206 }
1207
1208 FORCEINLINE
1209 ULONG
1210 NTAPI
1211 RtlTotalEntriesHashTable(
1212 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
1213 {
1214 return HashTable->NumEntries;
1215 }
1216
1217 FORCEINLINE
1218 ULONG
1219 NTAPI
1220 RtlActiveEnumeratorsHashTable(
1221 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
1222 {
1223 return HashTable->NumEnumerators;
1224 }
1225
1226 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1227
1228 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
1229
1230 #if (NTDDI_VERSION >= NTDDI_WIN7)
1231
1232 NTSYSAPI
1233 BOOLEAN
1234 NTAPI
1235 RtlCreateHashTable(
1236 IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL,
1237 IN ULONG Shift,
1238 IN ULONG Flags);
1239
1240 NTSYSAPI
1241 VOID
1242 NTAPI
1243 RtlDeleteHashTable(
1244 IN PRTL_DYNAMIC_HASH_TABLE HashTable);
1245
1246 NTSYSAPI
1247 BOOLEAN
1248 NTAPI
1249 RtlInsertEntryHashTable(
1250 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1251 IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry,
1252 IN ULONG_PTR Signature,
1253 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL);
1254
1255 NTSYSAPI
1256 BOOLEAN
1257 NTAPI
1258 RtlRemoveEntryHashTable(
1259 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1260 IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry,
1261 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL);
1262
1263 NTSYSAPI
1264 PRTL_DYNAMIC_HASH_TABLE_ENTRY
1265 NTAPI
1266 RtlLookupEntryHashTable(
1267 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1268 IN ULONG_PTR Signature,
1269 OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL);
1270
1271 NTSYSAPI
1272 PRTL_DYNAMIC_HASH_TABLE_ENTRY
1273 NTAPI
1274 RtlGetNextEntryHashTable(
1275 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1276 IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context);
1277
1278 NTSYSAPI
1279 BOOLEAN
1280 NTAPI
1281 RtlInitEnumerationHashTable(
1282 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1283 OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
1284
1285 NTSYSAPI
1286 PRTL_DYNAMIC_HASH_TABLE_ENTRY
1287 NTAPI
1288 RtlEnumerateEntryHashTable(
1289 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1290 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
1291
1292 NTSYSAPI
1293 VOID
1294 NTAPI
1295 RtlEndEnumerationHashTable(
1296 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1297 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
1298
1299 NTSYSAPI
1300 BOOLEAN
1301 NTAPI
1302 RtlInitWeakEnumerationHashTable(
1303 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1304 OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
1305
1306 NTSYSAPI
1307 PRTL_DYNAMIC_HASH_TABLE_ENTRY
1308 NTAPI
1309 RtlWeaklyEnumerateEntryHashTable(
1310 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1311 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
1312
1313 NTSYSAPI
1314 VOID
1315 NTAPI
1316 RtlEndWeakEnumerationHashTable(
1317 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
1318 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
1319
1320 NTSYSAPI
1321 BOOLEAN
1322 NTAPI
1323 RtlExpandHashTable(
1324 IN PRTL_DYNAMIC_HASH_TABLE HashTable);
1325
1326 NTSYSAPI
1327 BOOLEAN
1328 NTAPI
1329 RtlContractHashTable(
1330 IN PRTL_DYNAMIC_HASH_TABLE HashTable);
1331
1332 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1333
1334 #if defined(_AMD64_) || defined(_IA64_)
1335 //DECLSPEC_DEPRECATED_DDK_WINXP
1336 FORCEINLINE
1337 LARGE_INTEGER
1338 NTAPI_INLINE
1339 RtlLargeIntegerDivide(
1340 IN LARGE_INTEGER Dividend,
1341 IN LARGE_INTEGER Divisor,
1342 OUT PLARGE_INTEGER Remainder OPTIONAL)
1343 {
1344 LARGE_INTEGER ret;
1345 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
1346 if (Remainder)
1347 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
1348 return ret;
1349 }
1350
1351 #else
1352
1353 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1354 NTSYSAPI
1355 LARGE_INTEGER
1356 NTAPI
1357 RtlLargeIntegerDivide(
1358 IN LARGE_INTEGER Dividend,
1359 IN LARGE_INTEGER Divisor,
1360 OUT PLARGE_INTEGER Remainder OPTIONAL);
1361 #endif
1362
1363 #endif /* defined(_AMD64_) || defined(_IA64_) */
1364
1365 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
1366 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
1367 (TypeBitMask), (ComparisonType)))
1368
1369 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1370 NTSYSAPI
1371 ULONGLONG
1372 NTAPI
1373 VerSetConditionMask(
1374 IN ULONGLONG ConditionMask,
1375 IN ULONG TypeMask,
1376 IN UCHAR Condition);
1377 #endif
1378
1379 /** Kernel debugger routines **/
1380
1381 NTSYSAPI
1382 ULONG
1383 NTAPI
1384 DbgPrompt(
1385 IN PCCH Prompt,
1386 OUT PCH Response,
1387 IN ULONG MaximumResponseLength);
1388
1389 #if (NTDDI_VERSION >= NTDDI_WIN7)
1390
1391 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000
1392 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000
1393 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \
1394 (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \
1395 FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX)
1396
1397 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200
1398 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300
1399 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300
1400
1401 #else
1402
1403 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
1404 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
1405 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
1406
1407 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL
1408 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL
1409 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK
1410
1411 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1412
1413 #define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \
1414 FILE_READ_ONLY_DEVICE | \
1415 FILE_FLOPPY_DISKETTE | \
1416 FILE_WRITE_ONCE_MEDIA | \
1417 FILE_DEVICE_SECURE_OPEN )
1418
1419 typedef struct _FILE_ALIGNMENT_INFORMATION {
1420 ULONG AlignmentRequirement;
1421 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1422
1423 typedef struct _FILE_NAME_INFORMATION {
1424 ULONG FileNameLength;
1425 WCHAR FileName[1];
1426 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1427
1428
1429 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1430 ULONG FileAttributes;
1431 ULONG ReparseTag;
1432 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1433
1434 typedef struct _FILE_DISPOSITION_INFORMATION {
1435 BOOLEAN DeleteFile;
1436 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1437
1438 typedef struct _FILE_END_OF_FILE_INFORMATION {
1439 LARGE_INTEGER EndOfFile;
1440 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1441
1442 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1443 LARGE_INTEGER ValidDataLength;
1444 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1445
1446 typedef struct _FILE_FS_LABEL_INFORMATION {
1447 ULONG VolumeLabelLength;
1448 WCHAR VolumeLabel[1];
1449 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
1450
1451 typedef struct _FILE_FS_VOLUME_INFORMATION {
1452 LARGE_INTEGER VolumeCreationTime;
1453 ULONG VolumeSerialNumber;
1454 ULONG VolumeLabelLength;
1455 BOOLEAN SupportsObjects;
1456 WCHAR VolumeLabel[1];
1457 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
1458
1459 typedef struct _FILE_FS_SIZE_INFORMATION {
1460 LARGE_INTEGER TotalAllocationUnits;
1461 LARGE_INTEGER AvailableAllocationUnits;
1462 ULONG SectorsPerAllocationUnit;
1463 ULONG BytesPerSector;
1464 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
1465
1466 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
1467 LARGE_INTEGER TotalAllocationUnits;
1468 LARGE_INTEGER CallerAvailableAllocationUnits;
1469 LARGE_INTEGER ActualAvailableAllocationUnits;
1470 ULONG SectorsPerAllocationUnit;
1471 ULONG BytesPerSector;
1472 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
1473
1474 typedef struct _FILE_FS_OBJECTID_INFORMATION {
1475 UCHAR ObjectId[16];
1476 UCHAR ExtendedInfo[48];
1477 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
1478
1479 typedef union _FILE_SEGMENT_ELEMENT {
1480 PVOID64 Buffer;
1481 ULONGLONG Alignment;
1482 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1483
1484 #define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
1485 #define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
1486 #define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
1487
1488 typedef enum _BUS_DATA_TYPE {
1489 ConfigurationSpaceUndefined = -1,
1490 Cmos,
1491 EisaConfiguration,
1492 Pos,
1493 CbusConfiguration,
1494 PCIConfiguration,
1495 VMEConfiguration,
1496 NuBusConfiguration,
1497 PCMCIAConfiguration,
1498 MPIConfiguration,
1499 MPSAConfiguration,
1500 PNPISAConfiguration,
1501 SgiInternalConfiguration,
1502 MaximumBusDataType
1503 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1504
1505 typedef struct _KEY_NAME_INFORMATION {
1506 ULONG NameLength;
1507 WCHAR Name[1];
1508 } KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
1509
1510 typedef struct _KEY_CACHED_INFORMATION {
1511 LARGE_INTEGER LastWriteTime;
1512 ULONG TitleIndex;
1513 ULONG SubKeys;
1514 ULONG MaxNameLen;
1515 ULONG Values;
1516 ULONG MaxValueNameLen;
1517 ULONG MaxValueDataLen;
1518 ULONG NameLength;
1519 } KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
1520
1521 typedef struct _KEY_VIRTUALIZATION_INFORMATION {
1522 ULONG VirtualizationCandidate:1;
1523 ULONG VirtualizationEnabled:1;
1524 ULONG VirtualTarget:1;
1525 ULONG VirtualStore:1;
1526 ULONG VirtualSource:1;
1527 ULONG Reserved:27;
1528 } KEY_VIRTUALIZATION_INFORMATION, *PKEY_VIRTUALIZATION_INFORMATION;
1529
1530 #define THREAD_CSWITCH_PMU_DISABLE FALSE
1531 #define THREAD_CSWITCH_PMU_ENABLE TRUE
1532
1533 #define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
1534
1535 #define PROCESS_HANDLE_TRACING_MAX_STACKS 16
1536
1537 typedef struct _NT_TIB {
1538 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1539 PVOID StackBase;
1540 PVOID StackLimit;
1541 PVOID SubSystemTib;
1542 _ANONYMOUS_UNION union {
1543 PVOID FiberData;
1544 ULONG Version;
1545 } DUMMYUNIONNAME;
1546 PVOID ArbitraryUserPointer;
1547 struct _NT_TIB *Self;
1548 } NT_TIB, *PNT_TIB;
1549
1550 typedef struct _NT_TIB32 {
1551 ULONG ExceptionList;
1552 ULONG StackBase;
1553 ULONG StackLimit;
1554 ULONG SubSystemTib;
1555 __GNU_EXTENSION union {
1556 ULONG FiberData;
1557 ULONG Version;
1558 };
1559 ULONG ArbitraryUserPointer;
1560 ULONG Self;
1561 } NT_TIB32,*PNT_TIB32;
1562
1563 typedef struct _NT_TIB64 {
1564 ULONG64 ExceptionList;
1565 ULONG64 StackBase;
1566 ULONG64 StackLimit;
1567 ULONG64 SubSystemTib;
1568 __GNU_EXTENSION union {
1569 ULONG64 FiberData;
1570 ULONG Version;
1571 };
1572 ULONG64 ArbitraryUserPointer;
1573 ULONG64 Self;
1574 } NT_TIB64,*PNT_TIB64;
1575
1576 typedef enum _PROCESSINFOCLASS {
1577 ProcessBasicInformation,
1578 ProcessQuotaLimits,
1579 ProcessIoCounters,
1580 ProcessVmCounters,
1581 ProcessTimes,
1582 ProcessBasePriority,
1583 ProcessRaisePriority,
1584 ProcessDebugPort,
1585 ProcessExceptionPort,
1586 ProcessAccessToken,
1587 ProcessLdtInformation,
1588 ProcessLdtSize,
1589 ProcessDefaultHardErrorMode,
1590 ProcessIoPortHandlers,
1591 ProcessPooledUsageAndLimits,
1592 ProcessWorkingSetWatch,
1593 ProcessUserModeIOPL,
1594 ProcessEnableAlignmentFaultFixup,
1595 ProcessPriorityClass,
1596 ProcessWx86Information,
1597 ProcessHandleCount,
1598 ProcessAffinityMask,
1599 ProcessPriorityBoost,
1600 ProcessDeviceMap,
1601 ProcessSessionInformation,
1602 ProcessForegroundInformation,
1603 ProcessWow64Information,
1604 ProcessImageFileName,
1605 ProcessLUIDDeviceMapsEnabled,
1606 ProcessBreakOnTermination,
1607 ProcessDebugObjectHandle,
1608 ProcessDebugFlags,
1609 ProcessHandleTracing,
1610 ProcessIoPriority,
1611 ProcessExecuteFlags,
1612 ProcessTlsInformation,
1613 ProcessCookie,
1614 ProcessImageInformation,
1615 ProcessCycleTime,
1616 ProcessPagePriority,
1617 ProcessInstrumentationCallback,
1618 ProcessThreadStackAllocation,
1619 ProcessWorkingSetWatchEx,
1620 ProcessImageFileNameWin32,
1621 ProcessImageFileMapping,
1622 ProcessAffinityUpdateMode,
1623 ProcessMemoryAllocationMode,
1624 ProcessGroupInformation,
1625 ProcessTokenVirtualizationEnabled,
1626 ProcessConsoleHostProcess,
1627 ProcessWindowInformation,
1628 MaxProcessInfoClass
1629 } PROCESSINFOCLASS;
1630
1631 typedef enum _THREADINFOCLASS {
1632 ThreadBasicInformation,
1633 ThreadTimes,
1634 ThreadPriority,
1635 ThreadBasePriority,
1636 ThreadAffinityMask,
1637 ThreadImpersonationToken,
1638 ThreadDescriptorTableEntry,
1639 ThreadEnableAlignmentFaultFixup,
1640 ThreadEventPair_Reusable,
1641 ThreadQuerySetWin32StartAddress,
1642 ThreadZeroTlsCell,
1643 ThreadPerformanceCount,
1644 ThreadAmILastThread,
1645 ThreadIdealProcessor,
1646 ThreadPriorityBoost,
1647 ThreadSetTlsArrayAddress,
1648 ThreadIsIoPending,
1649 ThreadHideFromDebugger,
1650 ThreadBreakOnTermination,
1651 ThreadSwitchLegacyState,
1652 ThreadIsTerminated,
1653 ThreadLastSystemCall,
1654 ThreadIoPriority,
1655 ThreadCycleTime,
1656 ThreadPagePriority,
1657 ThreadActualBasePriority,
1658 ThreadTebInformation,
1659 ThreadCSwitchMon,
1660 ThreadCSwitchPmu,
1661 ThreadWow64Context,
1662 ThreadGroupInformation,
1663 ThreadUmsInformation,
1664 ThreadCounterProfiling,
1665 ThreadIdealProcessorEx,
1666 MaxThreadInfoClass
1667 } THREADINFOCLASS;
1668
1669 typedef struct _PAGE_PRIORITY_INFORMATION {
1670 ULONG PagePriority;
1671 } PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION;
1672
1673 typedef struct _PROCESS_WS_WATCH_INFORMATION {
1674 PVOID FaultingPc;
1675 PVOID FaultingVa;
1676 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1677
1678 typedef struct _PROCESS_BASIC_INFORMATION {
1679 NTSTATUS ExitStatus;
1680 struct _PEB *PebBaseAddress;
1681 ULONG_PTR AffinityMask;
1682 KPRIORITY BasePriority;
1683 ULONG_PTR UniqueProcessId;
1684 ULONG_PTR InheritedFromUniqueProcessId;
1685 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1686
1687 typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION {
1688 SIZE_T Size;
1689 PROCESS_BASIC_INFORMATION BasicInfo;
1690 union {
1691 ULONG Flags;
1692 struct {
1693 ULONG IsProtectedProcess:1;
1694 ULONG IsWow64Process:1;
1695 ULONG IsProcessDeleting:1;
1696 ULONG IsCrossSessionCreate:1;
1697 ULONG SpareBits:28;
1698 } DUMMYSTRUCTNAME;
1699 } DUMMYUNIONNAME;
1700 } PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION;
1701
1702 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
1703 __GNU_EXTENSION union {
1704 struct {
1705 HANDLE DirectoryHandle;
1706 } Set;
1707 struct {
1708 ULONG DriveMap;
1709 UCHAR DriveType[32];
1710 } Query;
1711 };
1712 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1713
1714 typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
1715 union {
1716 struct {
1717 HANDLE DirectoryHandle;
1718 } Set;
1719 struct {
1720 ULONG DriveMap;
1721 UCHAR DriveType[32];
1722 } Query;
1723 } DUMMYUNIONNAME;
1724 ULONG Flags;
1725 } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
1726
1727 typedef struct _PROCESS_SESSION_INFORMATION {
1728 ULONG SessionId;
1729 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1730
1731 typedef struct _PROCESS_HANDLE_TRACING_ENABLE {
1732 ULONG Flags;
1733 } PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE;
1734
1735 typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX {
1736 ULONG Flags;
1737 ULONG TotalSlots;
1738 } PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX;
1739
1740 typedef struct _PROCESS_HANDLE_TRACING_ENTRY {
1741 HANDLE Handle;
1742 CLIENT_ID ClientId;
1743 ULONG Type;
1744 PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS];
1745 } PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY;
1746
1747 typedef struct _PROCESS_HANDLE_TRACING_QUERY {
1748 HANDLE Handle;
1749 ULONG TotalTraces;
1750 PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1];
1751 } PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY;
1752
1753 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
1754 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
1755 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
1756 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
1757 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
1758
1759 typedef struct _QUOTA_LIMITS {
1760 SIZE_T PagedPoolLimit;
1761 SIZE_T NonPagedPoolLimit;
1762 SIZE_T MinimumWorkingSetSize;
1763 SIZE_T MaximumWorkingSetSize;
1764 SIZE_T PagefileLimit;
1765 LARGE_INTEGER TimeLimit;
1766 } QUOTA_LIMITS, *PQUOTA_LIMITS;
1767
1768 typedef union _RATE_QUOTA_LIMIT {
1769 ULONG RateData;
1770 struct {
1771 ULONG RatePercent:7;
1772 ULONG Reserved0:25;
1773 } DUMMYSTRUCTNAME;
1774 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
1775
1776 typedef struct _QUOTA_LIMITS_EX {
1777 SIZE_T PagedPoolLimit;
1778 SIZE_T NonPagedPoolLimit;
1779 SIZE_T MinimumWorkingSetSize;
1780 SIZE_T MaximumWorkingSetSize;
1781 SIZE_T PagefileLimit;
1782 LARGE_INTEGER TimeLimit;
1783 SIZE_T WorkingSetLimit;
1784 SIZE_T Reserved2;
1785 SIZE_T Reserved3;
1786 SIZE_T Reserved4;
1787 ULONG Flags;
1788 RATE_QUOTA_LIMIT CpuRateLimit;
1789 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
1790
1791 typedef struct _IO_COUNTERS {
1792 ULONGLONG ReadOperationCount;
1793 ULONGLONG WriteOperationCount;
1794 ULONGLONG OtherOperationCount;
1795 ULONGLONG ReadTransferCount;
1796 ULONGLONG WriteTransferCount;
1797 ULONGLONG OtherTransferCount;
1798 } IO_COUNTERS, *PIO_COUNTERS;
1799
1800 typedef struct _VM_COUNTERS {
1801 SIZE_T PeakVirtualSize;
1802 SIZE_T VirtualSize;
1803 ULONG PageFaultCount;
1804 SIZE_T PeakWorkingSetSize;
1805 SIZE_T WorkingSetSize;
1806 SIZE_T QuotaPeakPagedPoolUsage;
1807 SIZE_T QuotaPagedPoolUsage;
1808 SIZE_T QuotaPeakNonPagedPoolUsage;
1809 SIZE_T QuotaNonPagedPoolUsage;
1810 SIZE_T PagefileUsage;
1811 SIZE_T PeakPagefileUsage;
1812 } VM_COUNTERS, *PVM_COUNTERS;
1813
1814 typedef struct _VM_COUNTERS_EX {
1815 SIZE_T PeakVirtualSize;
1816 SIZE_T VirtualSize;
1817 ULONG PageFaultCount;
1818 SIZE_T PeakWorkingSetSize;
1819 SIZE_T WorkingSetSize;
1820 SIZE_T QuotaPeakPagedPoolUsage;
1821 SIZE_T QuotaPagedPoolUsage;
1822 SIZE_T QuotaPeakNonPagedPoolUsage;
1823 SIZE_T QuotaNonPagedPoolUsage;
1824 SIZE_T PagefileUsage;
1825 SIZE_T PeakPagefileUsage;
1826 SIZE_T PrivateUsage;
1827 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
1828
1829 #define MAX_HW_COUNTERS 16
1830 #define THREAD_PROFILING_FLAG_DISPATCH 0x00000001
1831
1832 typedef enum _HARDWARE_COUNTER_TYPE {
1833 PMCCounter,
1834 MaxHardwareCounterType
1835 } HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
1836
1837 typedef struct _HARDWARE_COUNTER {
1838 HARDWARE_COUNTER_TYPE Type;
1839 ULONG Reserved;
1840 ULONG64 Index;
1841 } HARDWARE_COUNTER, *PHARDWARE_COUNTER;
1842
1843 typedef struct _POOLED_USAGE_AND_LIMITS {
1844 SIZE_T PeakPagedPoolUsage;
1845 SIZE_T PagedPoolUsage;
1846 SIZE_T PagedPoolLimit;
1847 SIZE_T PeakNonPagedPoolUsage;
1848 SIZE_T NonPagedPoolUsage;
1849 SIZE_T NonPagedPoolLimit;
1850 SIZE_T PeakPagefileUsage;
1851 SIZE_T PagefileUsage;
1852 SIZE_T PagefileLimit;
1853 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
1854
1855 typedef struct _PROCESS_ACCESS_TOKEN {
1856 HANDLE Token;
1857 HANDLE Thread;
1858 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1859
1860 #define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL
1861 #define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1))
1862
1863 typedef struct _PROCESS_EXCEPTION_PORT {
1864 IN HANDLE ExceptionPortHandle;
1865 IN OUT ULONG StateFlags;
1866 } PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT;
1867
1868 typedef struct _KERNEL_USER_TIMES {
1869 LARGE_INTEGER CreateTime;
1870 LARGE_INTEGER ExitTime;
1871 LARGE_INTEGER KernelTime;
1872 LARGE_INTEGER UserTime;
1873 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1874
1875 /* NtXxx Functions */
1876
1877 NTSYSCALLAPI
1878 NTSTATUS
1879 NTAPI
1880 NtOpenProcess(
1881 OUT PHANDLE ProcessHandle,
1882 IN ACCESS_MASK DesiredAccess,
1883 IN POBJECT_ATTRIBUTES ObjectAttributes,
1884 IN PCLIENT_ID ClientId OPTIONAL);
1885
1886 NTSYSCALLAPI
1887 NTSTATUS
1888 NTAPI
1889 NtQueryInformationProcess(
1890 IN HANDLE ProcessHandle,
1891 IN PROCESSINFOCLASS ProcessInformationClass,
1892 OUT PVOID ProcessInformation OPTIONAL,
1893 IN ULONG ProcessInformationLength,
1894 OUT PULONG ReturnLength OPTIONAL);
1895
1896 struct _LOADER_PARAMETER_BLOCK;
1897 struct _CREATE_DISK;
1898 struct _DRIVE_LAYOUT_INFORMATION_EX;
1899 struct _SET_PARTITION_INFORMATION_EX;
1900
1901 //
1902 // GUID and UUID
1903 //
1904 #ifndef GUID_DEFINED
1905 #include <guiddef.h>
1906 #endif
1907 typedef GUID UUID;
1908
1909 #define MAX_WOW64_SHARED_ENTRIES 16
1910
1911 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1912 #define NX_SUPPORT_POLICY_ALWAYSON 1
1913 #define NX_SUPPORT_POLICY_OPTIN 2
1914 #define NX_SUPPORT_POLICY_OPTOUT 3
1915
1916 /*
1917 ** IRP function codes
1918 */
1919
1920 #define IRP_MN_QUERY_DIRECTORY 0x01
1921 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
1922
1923 #define IRP_MN_USER_FS_REQUEST 0x00
1924 #define IRP_MN_MOUNT_VOLUME 0x01
1925 #define IRP_MN_VERIFY_VOLUME 0x02
1926 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
1927 #define IRP_MN_TRACK_LINK 0x04
1928 #define IRP_MN_KERNEL_CALL 0x04
1929
1930 #define IRP_MN_LOCK 0x01
1931 #define IRP_MN_UNLOCK_SINGLE 0x02
1932 #define IRP_MN_UNLOCK_ALL 0x03
1933 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
1934
1935 #define IRP_MN_FLUSH_AND_PURGE 0x01
1936
1937 #define IRP_MN_NORMAL 0x00
1938 #define IRP_MN_DPC 0x01
1939 #define IRP_MN_MDL 0x02
1940 #define IRP_MN_COMPLETE 0x04
1941 #define IRP_MN_COMPRESSED 0x08
1942
1943 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
1944 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
1945 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
1946
1947 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
1948
1949 /* DEVICE_OBJECT.Flags */
1950
1951 #define DO_DEVICE_HAS_NAME 0x00000040
1952 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
1953 #define DO_LONG_TERM_REQUESTS 0x00000200
1954 #define DO_NEVER_LAST_DEVICE 0x00000400
1955 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
1956 #define DO_SUPPORTS_TRANSACTIONS 0x00040000
1957 #define DO_FORCE_NEITHER_IO 0x00080000
1958 #define DO_VOLUME_DEVICE_OBJECT 0x00100000
1959 #define DO_SYSTEM_SYSTEM_PARTITION 0x00200000
1960 #define DO_SYSTEM_CRITICAL_PARTITION 0x00400000
1961 #define DO_DISALLOW_EXECUTE 0x00800000
1962
1963 #define DRVO_REINIT_REGISTERED 0x00000008
1964 #define DRVO_INITIALIZED 0x00000010
1965 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
1966 #define DRVO_LEGACY_RESOURCES 0x00000040
1967
1968 typedef enum _ARBITER_REQUEST_SOURCE {
1969 ArbiterRequestUndefined = -1,
1970 ArbiterRequestLegacyReported,
1971 ArbiterRequestHalReported,
1972 ArbiterRequestLegacyAssigned,
1973 ArbiterRequestPnpDetected,
1974 ArbiterRequestPnpEnumerated
1975 } ARBITER_REQUEST_SOURCE;
1976
1977 typedef enum _ARBITER_RESULT {
1978 ArbiterResultUndefined = -1,
1979 ArbiterResultSuccess,
1980 ArbiterResultExternalConflict,
1981 ArbiterResultNullRequest
1982 } ARBITER_RESULT;
1983
1984 typedef enum _ARBITER_ACTION {
1985 ArbiterActionTestAllocation,
1986 ArbiterActionRetestAllocation,
1987 ArbiterActionCommitAllocation,
1988 ArbiterActionRollbackAllocation,
1989 ArbiterActionQueryAllocatedResources,
1990 ArbiterActionWriteReservedResources,
1991 ArbiterActionQueryConflict,
1992 ArbiterActionQueryArbitrate,
1993 ArbiterActionAddReserved,
1994 ArbiterActionBootAllocation
1995 } ARBITER_ACTION, *PARBITER_ACTION;
1996
1997 typedef struct _ARBITER_CONFLICT_INFO {
1998 PDEVICE_OBJECT OwningObject;
1999 ULONGLONG Start;
2000 ULONGLONG End;
2001 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
2002
2003 typedef struct _ARBITER_PARAMETERS {
2004 union {
2005 struct {
2006 IN OUT PLIST_ENTRY ArbitrationList;
2007 IN ULONG AllocateFromCount;
2008 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2009 } TestAllocation;
2010 struct {
2011 IN OUT PLIST_ENTRY ArbitrationList;
2012 IN ULONG AllocateFromCount;
2013 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2014 } RetestAllocation;
2015 struct {
2016 IN OUT PLIST_ENTRY ArbitrationList;
2017 } BootAllocation;
2018 struct {
2019 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
2020 } QueryAllocatedResources;
2021 struct {
2022 IN PDEVICE_OBJECT PhysicalDeviceObject;
2023 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
2024 OUT PULONG ConflictCount;
2025 OUT PARBITER_CONFLICT_INFO *Conflicts;
2026 } QueryConflict;
2027 struct {
2028 IN PLIST_ENTRY ArbitrationList;
2029 } QueryArbitrate;
2030 struct {
2031 IN PDEVICE_OBJECT ReserveDevice;
2032 } AddReserved;
2033 } Parameters;
2034 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
2035
2036 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
2037
2038 typedef struct _ARBITER_LIST_ENTRY {
2039 LIST_ENTRY ListEntry;
2040 ULONG AlternativeCount;
2041 PIO_RESOURCE_DESCRIPTOR Alternatives;
2042 PDEVICE_OBJECT PhysicalDeviceObject;
2043 ARBITER_REQUEST_SOURCE RequestSource;
2044 ULONG Flags;
2045 LONG_PTR WorkSpace;
2046 INTERFACE_TYPE InterfaceType;
2047 ULONG SlotNumber;
2048 ULONG BusNumber;
2049 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
2050 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
2051 ARBITER_RESULT Result;
2052 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
2053
2054 typedef NTSTATUS
2055 (NTAPI *PARBITER_HANDLER)(
2056 IN OUT PVOID Context,
2057 IN ARBITER_ACTION Action,
2058 IN OUT PARBITER_PARAMETERS Parameters);
2059
2060 #define ARBITER_PARTIAL 0x00000001
2061
2062 typedef struct _ARBITER_INTERFACE {
2063 USHORT Size;
2064 USHORT Version;
2065 PVOID Context;
2066 PINTERFACE_REFERENCE InterfaceReference;
2067 PINTERFACE_DEREFERENCE InterfaceDereference;
2068 PARBITER_HANDLER ArbiterHandler;
2069 ULONG Flags;
2070 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
2071
2072 typedef enum _HAL_QUERY_INFORMATION_CLASS {
2073 HalInstalledBusInformation,
2074 HalProfileSourceInformation,
2075 HalInformationClassUnused1,
2076 HalPowerInformation,
2077 HalProcessorSpeedInformation,
2078 HalCallbackInformation,
2079 HalMapRegisterInformation,
2080 HalMcaLogInformation,
2081 HalFrameBufferCachingInformation,
2082 HalDisplayBiosInformation,
2083 HalProcessorFeatureInformation,
2084 HalNumaTopologyInterface,
2085 HalErrorInformation,
2086 HalCmcLogInformation,
2087 HalCpeLogInformation,
2088 HalQueryMcaInterface,
2089 HalQueryAMLIIllegalIOPortAddresses,
2090 HalQueryMaxHotPlugMemoryAddress,
2091 HalPartitionIpiInterface,
2092 HalPlatformInformation,
2093 HalQueryProfileSourceList,
2094 HalInitLogInformation,
2095 HalFrequencyInformation,
2096 HalProcessorBrandString,
2097 HalHypervisorInformation,
2098 HalPlatformTimerInformation,
2099 HalAcpiAuditInformation
2100 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
2101
2102 typedef enum _HAL_SET_INFORMATION_CLASS {
2103 HalProfileSourceInterval,
2104 HalProfileSourceInterruptHandler,
2105 HalMcaRegisterDriver,
2106 HalKernelErrorHandler,
2107 HalCmcRegisterDriver,
2108 HalCpeRegisterDriver,
2109 HalMcaLog,
2110 HalCmcLog,
2111 HalCpeLog,
2112 HalGenerateCmcInterrupt,
2113 HalProfileSourceTimerHandler,
2114 HalEnlightenment,
2115 HalProfileDpgoSourceInterruptHandler
2116 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
2117
2118 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
2119 KPROFILE_SOURCE Source;
2120 ULONG_PTR Interval;
2121 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
2122
2123 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
2124 KPROFILE_SOURCE Source;
2125 BOOLEAN Supported;
2126 ULONG Interval;
2127 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
2128
2129 typedef struct _MAP_REGISTER_ENTRY {
2130 PVOID MapRegister;
2131 BOOLEAN WriteToDevice;
2132 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
2133
2134 typedef struct _DEBUG_DEVICE_ADDRESS {
2135 UCHAR Type;
2136 BOOLEAN Valid;
2137 UCHAR Reserved[2];
2138 PUCHAR TranslatedAddress;
2139 ULONG Length;
2140 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
2141
2142 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
2143 PHYSICAL_ADDRESS Start;
2144 PHYSICAL_ADDRESS MaxEnd;
2145 PVOID VirtualAddress;
2146 ULONG Length;
2147 BOOLEAN Cached;
2148 BOOLEAN Aligned;
2149 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
2150
2151 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
2152 ULONG Bus;
2153 ULONG Slot;
2154 USHORT Segment;
2155 USHORT VendorID;
2156 USHORT DeviceID;
2157 UCHAR BaseClass;
2158 UCHAR SubClass;
2159 UCHAR ProgIf;
2160 BOOLEAN Initialized;
2161 BOOLEAN Configured;
2162 DEBUG_DEVICE_ADDRESS BaseAddress[6];
2163 DEBUG_MEMORY_REQUIREMENTS Memory;
2164 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
2165
2166 typedef struct _PM_DISPATCH_TABLE {
2167 ULONG Signature;
2168 ULONG Version;
2169 PVOID Function[1];
2170 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
2171
2172 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
2173 TranslateChildToParent,
2174 TranslateParentToChild
2175 } RESOURCE_TRANSLATION_DIRECTION;
2176
2177 typedef NTSTATUS
2178 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
2179 IN OUT PVOID Context,
2180 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
2181 IN RESOURCE_TRANSLATION_DIRECTION Direction,
2182 IN ULONG AlternativesCount OPTIONAL,
2183 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
2184 IN PDEVICE_OBJECT PhysicalDeviceObject,
2185 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
2186
2187 typedef NTSTATUS
2188 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
2189 IN PVOID Context OPTIONAL,
2190 IN PIO_RESOURCE_DESCRIPTOR Source,
2191 IN PDEVICE_OBJECT PhysicalDeviceObject,
2192 OUT PULONG TargetCount,
2193 OUT PIO_RESOURCE_DESCRIPTOR *Target);
2194
2195 typedef struct _TRANSLATOR_INTERFACE {
2196 USHORT Size;
2197 USHORT Version;
2198 PVOID Context;
2199 PINTERFACE_REFERENCE InterfaceReference;
2200 PINTERFACE_DEREFERENCE InterfaceDereference;
2201 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
2202 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
2203 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
2204
2205 typedef VOID
2206 (FASTCALL *pHalExamineMBR)(
2207 IN PDEVICE_OBJECT DeviceObject,
2208 IN ULONG SectorSize,
2209 IN ULONG MBRTypeIdentifier,
2210 OUT PVOID *Buffer);
2211
2212 typedef NTSTATUS
2213 (FASTCALL *pHalIoReadPartitionTable)(
2214 IN PDEVICE_OBJECT DeviceObject,
2215 IN ULONG SectorSize,
2216 IN BOOLEAN ReturnRecognizedPartitions,
2217 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2218
2219 typedef NTSTATUS
2220 (FASTCALL *pHalIoSetPartitionInformation)(
2221 IN PDEVICE_OBJECT DeviceObject,
2222 IN ULONG SectorSize,
2223 IN ULONG PartitionNumber,
2224 IN ULONG PartitionType);
2225
2226 typedef NTSTATUS
2227 (FASTCALL *pHalIoWritePartitionTable)(
2228 IN PDEVICE_OBJECT DeviceObject,
2229 IN ULONG SectorSize,
2230 IN ULONG SectorsPerTrack,
2231 IN ULONG NumberOfHeads,
2232 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2233
2234 typedef PBUS_HANDLER
2235 (FASTCALL *pHalHandlerForBus)(
2236 IN INTERFACE_TYPE InterfaceType,
2237 IN ULONG BusNumber);
2238
2239 typedef VOID
2240 (FASTCALL *pHalReferenceBusHandler)(
2241 IN PBUS_HANDLER BusHandler);
2242
2243 typedef NTSTATUS
2244 (NTAPI *pHalQuerySystemInformation)(
2245 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
2246 IN ULONG BufferSize,
2247 IN OUT PVOID Buffer,
2248 OUT PULONG ReturnedLength);
2249
2250 typedef NTSTATUS
2251 (NTAPI *pHalSetSystemInformation)(
2252 IN HAL_SET_INFORMATION_CLASS InformationClass,
2253 IN ULONG BufferSize,
2254 IN PVOID Buffer);
2255
2256 typedef NTSTATUS
2257 (NTAPI *pHalQueryBusSlots)(
2258 IN PBUS_HANDLER BusHandler,
2259 IN ULONG BufferSize,
2260 OUT PULONG SlotNumbers,
2261 OUT PULONG ReturnedLength);
2262
2263 typedef NTSTATUS
2264 (NTAPI *pHalInitPnpDriver)(
2265 VOID);
2266
2267 typedef NTSTATUS
2268 (NTAPI *pHalInitPowerManagement)(
2269 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
2270 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
2271
2272 typedef struct _DMA_ADAPTER*
2273 (NTAPI *pHalGetDmaAdapter)(
2274 IN PVOID Context,
2275 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
2276 OUT PULONG NumberOfMapRegisters);
2277
2278 typedef NTSTATUS
2279 (NTAPI *pHalGetInterruptTranslator)(
2280 IN INTERFACE_TYPE ParentInterfaceType,
2281 IN ULONG ParentBusNumber,
2282 IN INTERFACE_TYPE BridgeInterfaceType,
2283 IN USHORT Size,
2284 IN USHORT Version,
2285 OUT PTRANSLATOR_INTERFACE Translator,
2286 OUT PULONG BridgeBusNumber);
2287
2288 typedef NTSTATUS
2289 (NTAPI *pHalStartMirroring)(
2290 VOID);
2291
2292 typedef NTSTATUS
2293 (NTAPI *pHalEndMirroring)(
2294 IN ULONG PassNumber);
2295
2296 typedef NTSTATUS
2297 (NTAPI *pHalMirrorPhysicalMemory)(
2298 IN PHYSICAL_ADDRESS PhysicalAddress,
2299 IN LARGE_INTEGER NumberOfBytes);
2300
2301 typedef NTSTATUS
2302 (NTAPI *pHalMirrorVerify)(
2303 IN PHYSICAL_ADDRESS PhysicalAddress,
2304 IN LARGE_INTEGER NumberOfBytes);
2305
2306 typedef VOID
2307 (NTAPI *pHalEndOfBoot)(
2308 VOID);
2309
2310 typedef
2311 BOOLEAN
2312 (NTAPI *pHalTranslateBusAddress)(
2313 IN INTERFACE_TYPE InterfaceType,
2314 IN ULONG BusNumber,
2315 IN PHYSICAL_ADDRESS BusAddress,
2316 IN OUT PULONG AddressSpace,
2317 OUT PPHYSICAL_ADDRESS TranslatedAddress);
2318
2319 typedef
2320 NTSTATUS
2321 (NTAPI *pHalAssignSlotResources)(
2322 IN PUNICODE_STRING RegistryPath,
2323 IN PUNICODE_STRING DriverClassName OPTIONAL,
2324 IN PDRIVER_OBJECT DriverObject,
2325 IN PDEVICE_OBJECT DeviceObject,
2326 IN INTERFACE_TYPE BusType,
2327 IN ULONG BusNumber,
2328 IN ULONG SlotNumber,
2329 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2330
2331 typedef
2332 VOID
2333 (NTAPI *pHalHaltSystem)(
2334 VOID);
2335
2336 typedef
2337 BOOLEAN
2338 (NTAPI *pHalResetDisplay)(
2339 VOID);
2340
2341 typedef
2342 UCHAR
2343 (NTAPI *pHalVectorToIDTEntry)(
2344 ULONG Vector);
2345
2346 typedef
2347 BOOLEAN
2348 (NTAPI *pHalFindBusAddressTranslation)(
2349 IN PHYSICAL_ADDRESS BusAddress,
2350 IN OUT PULONG AddressSpace,
2351 OUT PPHYSICAL_ADDRESS TranslatedAddress,
2352 IN OUT PULONG_PTR Context,
2353 IN BOOLEAN NextBus);
2354
2355 typedef
2356 NTSTATUS
2357 (NTAPI *pKdSetupPciDeviceForDebugging)(
2358 IN PVOID LoaderBlock OPTIONAL,
2359 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2360
2361 typedef
2362 NTSTATUS
2363 (NTAPI *pKdReleasePciDeviceForDebugging)(
2364 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2365
2366 typedef
2367 PVOID
2368 (NTAPI *pKdGetAcpiTablePhase0)(
2369 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2370 IN ULONG Signature);
2371
2372 typedef
2373 PVOID
2374 (NTAPI *pHalGetAcpiTable)(
2375 IN ULONG Signature,
2376 IN PCSTR OemId OPTIONAL,
2377 IN PCSTR OemTableId OPTIONAL);
2378
2379 typedef
2380 VOID
2381 (NTAPI *pKdCheckPowerButton)(
2382 VOID);
2383
2384 #if (NTDDI_VERSION >= NTDDI_VISTA)
2385 typedef
2386 PVOID
2387 (NTAPI *pKdMapPhysicalMemory64)(
2388 IN PHYSICAL_ADDRESS PhysicalAddress,
2389 IN ULONG NumberPages,
2390 IN BOOLEAN FlushCurrentTLB);
2391
2392 typedef
2393 VOID
2394 (NTAPI *pKdUnmapVirtualAddress)(
2395 IN PVOID VirtualAddress,
2396 IN ULONG NumberPages,
2397 IN BOOLEAN FlushCurrentTLB);
2398 #else
2399 typedef
2400 PVOID
2401 (NTAPI *pKdMapPhysicalMemory64)(
2402 IN PHYSICAL_ADDRESS PhysicalAddress,
2403 IN ULONG NumberPages);
2404
2405 typedef
2406 VOID
2407 (NTAPI *pKdUnmapVirtualAddress)(
2408 IN PVOID VirtualAddress,
2409 IN ULONG NumberPages);
2410 #endif
2411
2412
2413 typedef
2414 ULONG
2415 (NTAPI *pKdGetPciDataByOffset)(
2416 IN ULONG BusNumber,
2417 IN ULONG SlotNumber,
2418 OUT PVOID Buffer,
2419 IN ULONG Offset,
2420 IN ULONG Length);
2421
2422 typedef
2423 ULONG
2424 (NTAPI *pKdSetPciDataByOffset)(
2425 IN ULONG BusNumber,
2426 IN ULONG SlotNumber,
2427 IN PVOID Buffer,
2428 IN ULONG Offset,
2429 IN ULONG Length);
2430
2431 typedef BOOLEAN
2432 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
2433 IN ULONG Columns,
2434 IN ULONG Rows);
2435
2436 typedef
2437 VOID
2438 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
2439 VOID);
2440
2441 typedef
2442 VOID
2443 (NTAPI *pHalSetPciErrorHandlerCallback)(
2444 IN PCI_ERROR_HANDLER_CALLBACK Callback);
2445
2446 #if 1 /* Not present in WDK 7600 */
2447 typedef VOID
2448 (FASTCALL *pHalIoAssignDriveLetters)(
2449 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2450 IN PSTRING NtDeviceName,
2451 OUT PUCHAR NtSystemPath,
2452 OUT PSTRING NtSystemPathString);
2453 #endif
2454
2455 typedef struct {
2456 ULONG Version;
2457 pHalQuerySystemInformation HalQuerySystemInformation;
2458 pHalSetSystemInformation HalSetSystemInformation;
2459 pHalQueryBusSlots HalQueryBusSlots;
2460 ULONG Spare1;
2461 pHalExamineMBR HalExamineMBR;
2462 #if 1 /* Not present in WDK 7600 */
2463 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
2464 #endif
2465 pHalIoReadPartitionTable HalIoReadPartitionTable;
2466 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
2467 pHalIoWritePartitionTable HalIoWritePartitionTable;
2468 pHalHandlerForBus HalReferenceHandlerForBus;
2469 pHalReferenceBusHandler HalReferenceBusHandler;
2470 pHalReferenceBusHandler HalDereferenceBusHandler;
2471 pHalInitPnpDriver HalInitPnpDriver;
2472 pHalInitPowerManagement HalInitPowerManagement;
2473 pHalGetDmaAdapter HalGetDmaAdapter;
2474 pHalGetInterruptTranslator HalGetInterruptTranslator;
2475 pHalStartMirroring HalStartMirroring;
2476 pHalEndMirroring HalEndMirroring;
2477 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
2478 pHalEndOfBoot HalEndOfBoot;
2479 pHalMirrorVerify HalMirrorVerify;
2480 pHalGetAcpiTable HalGetCachedAcpiTable;
2481 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
2482 #if defined(_IA64_)
2483 pHalGetErrorCapList HalGetErrorCapList;
2484 pHalInjectError HalInjectError;
2485 #endif
2486 } HAL_DISPATCH, *PHAL_DISPATCH;
2487
2488 /* GCC/MSVC and WDK compatible declaration */
2489 extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
2490
2491 #if defined(_NTOSKRNL_) || defined(_BLDR_)
2492 #define HALDISPATCH (&HalDispatchTable)
2493 #else
2494 /* This is a WDK compatibility definition */
2495 #define HalDispatchTable (&HalDispatchTable)
2496 #define HALDISPATCH HalDispatchTable
2497 #endif
2498
2499 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
2500 #define HalDispatchTableVersion HALDISPATCH->Version
2501 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
2502 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
2503 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
2504 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
2505 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
2506 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
2507 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
2508 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
2509 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
2510 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
2511 #define HalStartMirroring HALDISPATCH->HalStartMirroring
2512 #define HalEndMirroring HALDISPATCH->HalEndMirroring
2513 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
2514 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
2515 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
2516
2517 typedef struct _IMAGE_INFO {
2518 _ANONYMOUS_UNION union {
2519 ULONG Properties;
2520 _ANONYMOUS_STRUCT struct {
2521 ULONG ImageAddressingMode:8;
2522 ULONG SystemModeImage:1;
2523 ULONG ImageMappedToAllPids:1;
2524 ULONG ExtendedInfoPresent:1;
2525 ULONG Reserved:22;
2526 } DUMMYSTRUCTNAME;
2527 } DUMMYUNIONNAME;
2528 PVOID ImageBase;
2529 ULONG ImageSelector;
2530 SIZE_T ImageSize;
2531 ULONG ImageSectionNumber;
2532 } IMAGE_INFO, *PIMAGE_INFO;
2533
2534 #define IMAGE_ADDRESSING_MODE_32BIT 3
2535
2536 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
2537 IoQueryDeviceIdentifier = 0,
2538 IoQueryDeviceConfigurationData,
2539 IoQueryDeviceComponentInformation,
2540 IoQueryDeviceMaxData
2541 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
2542
2543 typedef struct _DISK_SIGNATURE {
2544 ULONG PartitionStyle;
2545 _ANONYMOUS_UNION union {
2546 struct {
2547 ULONG Signature;
2548 ULONG CheckSum;
2549 } Mbr;
2550 struct {
2551 GUID DiskId;
2552 } Gpt;
2553 } DUMMYUNIONNAME;
2554 } DISK_SIGNATURE, *PDISK_SIGNATURE;
2555
2556 typedef ULONG_PTR
2557 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
2558 IN PVOID Context);
2559
2560 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
2561 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
2562 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
2563 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
2564
2565 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
2566 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
2567 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
2568 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
2569 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
2570
2571 typedef VOID
2572 (NTAPI *PTIMER_APC_ROUTINE)(
2573 IN PVOID TimerContext,
2574 IN ULONG TimerLowValue,
2575 IN LONG TimerHighValue);
2576
2577 typedef struct _KUSER_SHARED_DATA
2578 {
2579 ULONG TickCountLowDeprecated;
2580 ULONG TickCountMultiplier;
2581 volatile KSYSTEM_TIME InterruptTime;
2582 volatile KSYSTEM_TIME SystemTime;
2583 volatile KSYSTEM_TIME TimeZoneBias;
2584 USHORT ImageNumberLow;
2585 USHORT ImageNumberHigh;
2586 WCHAR NtSystemRoot[260];
2587 ULONG MaxStackTraceDepth;
2588 ULONG CryptoExponent;
2589 ULONG TimeZoneId;
2590 ULONG LargePageMinimum;
2591 ULONG Reserved2[7];
2592 NT_PRODUCT_TYPE NtProductType;
2593 BOOLEAN ProductTypeIsValid;
2594 ULONG NtMajorVersion;
2595 ULONG NtMinorVersion;
2596 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
2597 ULONG Reserved1;
2598 ULONG Reserved3;
2599 volatile ULONG TimeSlip;
2600 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
2601 ULONG AltArchitecturePad[1];
2602 LARGE_INTEGER SystemExpirationDate;
2603 ULONG SuiteMask;
2604 BOOLEAN KdDebuggerEnabled;
2605 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
2606 UCHAR NXSupportPolicy;
2607 #endif
2608 volatile ULONG ActiveConsoleId;
2609 volatile ULONG DismountCount;
2610 ULONG ComPlusPackage;
2611 ULONG LastSystemRITEventTickCount;
2612 ULONG NumberOfPhysicalPages;
2613 BOOLEAN SafeBootMode;
2614 #if (NTDDI_VERSION >= NTDDI_WIN7)
2615 union {
2616 UCHAR TscQpcData;
2617 struct {
2618 UCHAR TscQpcEnabled:1;
2619 UCHAR TscQpcSpareFlag:1;
2620 UCHAR TscQpcShift:6;
2621 } DUMMYSTRUCTNAME;
2622 } DUMMYUNIONNAME;
2623 UCHAR TscQpcPad[2];
2624 #endif
2625 #if (NTDDI_VERSION >= NTDDI_VISTA)
2626 union {
2627 ULONG SharedDataFlags;
2628 struct {
2629 ULONG DbgErrorPortPresent:1;
2630 ULONG DbgElevationEnabled:1;
2631 ULONG DbgVirtEnabled:1;
2632 ULONG DbgInstallerDetectEnabled:1;
2633 ULONG DbgSystemDllRelocated:1;
2634 ULONG DbgDynProcessorEnabled:1;
2635 ULONG DbgSEHValidationEnabled:1;
2636 ULONG SpareBits:25;
2637 } DUMMYSTRUCTNAME2;
2638 } DUMMYUNIONNAME2;
2639 #else
2640 ULONG TraceLogging;
2641 #endif
2642 ULONG DataFlagsPad[1];
2643 ULONGLONG TestRetInstruction;
2644 ULONG SystemCall;
2645 ULONG SystemCallReturn;
2646 ULONGLONG SystemCallPad[3];
2647 _ANONYMOUS_UNION union {
2648 volatile KSYSTEM_TIME TickCount;
2649 volatile ULONG64 TickCountQuad;
2650 _ANONYMOUS_STRUCT struct {
2651 ULONG ReservedTickCountOverlay[3];
2652 ULONG TickCountPad[1];
2653 } DUMMYSTRUCTNAME;
2654 } DUMMYUNIONNAME3;
2655 ULONG Cookie;
2656 ULONG CookiePad[1];
2657 #if (NTDDI_VERSION >= NTDDI_WS03)
2658 LONGLONG ConsoleSessionForegroundProcessId;
2659 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
2660 #endif
2661 #if (NTDDI_VERSION >= NTDDI_VISTA)
2662 #if (NTDDI_VERSION >= NTDDI_WIN7)
2663 USHORT UserModeGlobalLogger[16];
2664 #else
2665 USHORT UserModeGlobalLogger[8];
2666 ULONG HeapTracingPid[2];
2667 ULONG CritSecTracingPid[2];
2668 #endif
2669 ULONG ImageFileExecutionOptions;
2670 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
2671 ULONG LangGenerationCount;
2672 #else
2673 /* 4 bytes padding */
2674 #endif
2675 ULONGLONG Reserved5;
2676 volatile ULONG64 InterruptTimeBias;
2677 #endif
2678 #if (NTDDI_VERSION >= NTDDI_WIN7)
2679 volatile ULONG64 TscQpcBias;
2680 volatile ULONG ActiveProcessorCount;
2681 volatile USHORT ActiveGroupCount;
2682 USHORT Reserved4;
2683 volatile ULONG AitSamplingValue;
2684 volatile ULONG AppCompatFlag;
2685 ULONGLONG SystemDllNativeRelocation;
2686 ULONG SystemDllWowRelocation;
2687 ULONG XStatePad[1];
2688 XSTATE_CONFIGURATION XState;
2689 #endif
2690 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
2691
2692 extern NTKERNELAPI PVOID MmHighestUserAddress;
2693 extern NTKERNELAPI PVOID MmSystemRangeStart;
2694 extern NTKERNELAPI ULONG MmUserProbeAddress;
2695
2696
2697 #ifdef _X86_
2698
2699 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2700 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2701 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
2702 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
2703 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
2704 #else
2705 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2706 #endif
2707 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2708 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
2709 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
2710 #if !defined (_X86PAE_)
2711 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
2712 #else
2713 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
2714 #endif
2715
2716 #define KeGetPcr() PCR
2717
2718 #define PCR_MINOR_VERSION 1
2719 #define PCR_MAJOR_VERSION 1
2720
2721 typedef struct _KPCR {
2722 union {
2723 NT_TIB NtTib;
2724 struct {
2725 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
2726 PVOID Used_StackBase;
2727 PVOID Spare2;
2728 PVOID TssCopy;
2729 ULONG ContextSwitches;
2730 KAFFINITY SetMemberCopy;
2731 PVOID Used_Self;
2732 };
2733 };
2734 struct _KPCR *SelfPcr;
2735 struct _KPRCB *Prcb;
2736 KIRQL Irql;
2737 ULONG IRR;
2738 ULONG IrrActive;
2739 ULONG IDR;
2740 PVOID KdVersionBlock;
2741 struct _KIDTENTRY *IDT;
2742 struct _KGDTENTRY *GDT;
2743 struct _KTSS *TSS;
2744 USHORT MajorVersion;
2745 USHORT MinorVersion;
2746 KAFFINITY SetMember;
2747 ULONG StallScaleFactor;
2748 UCHAR SpareUnused;
2749 UCHAR Number;
2750 UCHAR Spare0;
2751 UCHAR SecondLevelCacheAssociativity;
2752 ULONG VdmAlert;
2753 ULONG KernelReserved[14];
2754 ULONG SecondLevelCacheSize;
2755 ULONG HalReserved[16];
2756 } KPCR, *PKPCR;
2757
2758 FORCEINLINE
2759 ULONG
2760 KeGetCurrentProcessorNumber(VOID)
2761 {
2762 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
2763 }
2764
2765 #endif /* _X86_ */
2766
2767 #ifdef _AMD64_
2768
2769 #define PTI_SHIFT 12L
2770 #define PDI_SHIFT 21L
2771 #define PPI_SHIFT 30L
2772 #define PXI_SHIFT 39L
2773 #define PTE_PER_PAGE 512
2774 #define PDE_PER_PAGE 512
2775 #define PPE_PER_PAGE 512
2776 #define PXE_PER_PAGE 512
2777 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
2778 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
2779 #define PPI_MASK (PPE_PER_PAGE - 1)
2780 #define PXI_MASK (PXE_PER_PAGE - 1)
2781
2782 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
2783 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
2784 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
2785 #define PDE_BASE 0xFFFFF6FB40000000ULL
2786 #define PTE_BASE 0xFFFFF68000000000ULL
2787 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
2788 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
2789 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
2790 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
2791
2792 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2793 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2794 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2795 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2796 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
2797 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
2798
2799 typedef struct _KPCR
2800 {
2801 _ANONYMOUS_UNION union
2802 {
2803 NT_TIB NtTib;
2804 _ANONYMOUS_STRUCT struct
2805 {
2806 union _KGDTENTRY64 *GdtBase;
2807 struct _KTSS64 *TssBase;
2808 ULONG64 UserRsp;
2809 struct _KPCR *Self;
2810 struct _KPRCB *CurrentPrcb;
2811 PKSPIN_LOCK_QUEUE LockArray;
2812 PVOID Used_Self;
2813 };
2814 };
2815 union _KIDTENTRY64 *IdtBase;
2816 ULONG64 Unused[2];
2817 KIRQL Irql;
2818 UCHAR SecondLevelCacheAssociativity;
2819 UCHAR ObsoleteNumber;
2820 UCHAR Fill0;
2821 ULONG Unused0[3];
2822 USHORT MajorVersion;
2823 USHORT MinorVersion;
2824 ULONG StallScaleFactor;
2825 PVOID Unused1[3];
2826 ULONG KernelReserved[15];
2827 ULONG SecondLevelCacheSize;
2828 ULONG HalReserved[16];
2829 ULONG Unused2;
2830 PVOID KdVersionBlock;
2831 PVOID Unused3;
2832 ULONG PcrAlign1[24];
2833 } KPCR, *PKPCR;
2834
2835 FORCEINLINE
2836 PKPCR
2837 KeGetPcr(VOID)
2838 {
2839 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
2840 }
2841
2842 FORCEINLINE
2843 ULONG
2844 KeGetCurrentProcessorNumber(VOID)
2845 {
2846 return (ULONG)__readgsword(0x184);
2847 }
2848
2849 #endif /* _AMD64_ */
2850
2851 typedef enum _INTERLOCKED_RESULT {
2852 ResultNegative = RESULT_NEGATIVE,
2853 ResultZero = RESULT_ZERO,
2854 ResultPositive = RESULT_POSITIVE
2855 } INTERLOCKED_RESULT;
2856
2857 /* Executive Types */
2858
2859 #define PROTECTED_POOL 0x80000000
2860
2861 typedef struct _ZONE_SEGMENT_HEADER {
2862 SINGLE_LIST_ENTRY SegmentList;
2863 PVOID Reserved;
2864 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2865
2866 typedef struct _ZONE_HEADER {
2867 SINGLE_LIST_ENTRY FreeList;
2868 SINGLE_LIST_ENTRY SegmentList;
2869 ULONG BlockSize;
2870 ULONG TotalSegmentSize;
2871 } ZONE_HEADER, *PZONE_HEADER;
2872
2873 /* Executive Functions */
2874
2875 static __inline PVOID
2876 ExAllocateFromZone(
2877 IN PZONE_HEADER Zone)
2878 {
2879 if (Zone->FreeList.Next)
2880 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2881 return (PVOID) Zone->FreeList.Next;
2882 }
2883
2884 static __inline PVOID
2885 ExFreeToZone(
2886 IN PZONE_HEADER Zone,
2887 IN PVOID Block)
2888 {
2889 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2890 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2891 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2892 }
2893
2894 /*
2895 * PVOID
2896 * ExInterlockedAllocateFromZone(
2897 * IN PZONE_HEADER Zone,
2898 * IN PKSPIN_LOCK Lock)
2899 */
2900 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2901 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2902
2903 /* PVOID
2904 * ExInterlockedFreeToZone(
2905 * IN PZONE_HEADER Zone,
2906 * IN PVOID Block,
2907 * IN PKSPIN_LOCK Lock);
2908 */
2909 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2910 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2911
2912 /*
2913 * BOOLEAN
2914 * ExIsFullZone(
2915 * IN PZONE_HEADER Zone)
2916 */
2917 #define ExIsFullZone(Zone) \
2918 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2919
2920 /* BOOLEAN
2921 * ExIsObjectInFirstZoneSegment(
2922 * IN PZONE_HEADER Zone,
2923 * IN PVOID Object);
2924 */
2925 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2926 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2927 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2928 (Zone)->TotalSegmentSize)) )
2929
2930 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2931 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2932 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2933 #define ExDeleteResource ExDeleteResourceLite
2934 #define ExInitializeResource ExInitializeResourceLite
2935 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2936 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2937 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2938 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2939
2940 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2941
2942 NTKERNELAPI
2943 NTSTATUS
2944 NTAPI
2945 ExExtendZone(
2946 IN OUT PZONE_HEADER Zone,
2947 IN OUT PVOID Segment,
2948 IN ULONG SegmentSize);
2949
2950 NTKERNELAPI
2951 NTSTATUS
2952 NTAPI
2953 ExInitializeZone(
2954 OUT PZONE_HEADER Zone,
2955 IN ULONG BlockSize,
2956 IN OUT PVOID InitialSegment,
2957 IN ULONG InitialSegmentSize);
2958
2959 NTKERNELAPI
2960 NTSTATUS
2961 NTAPI
2962 ExInterlockedExtendZone(
2963 IN OUT PZONE_HEADER Zone,
2964 IN OUT PVOID Segment,
2965 IN ULONG SegmentSize,
2966 IN OUT PKSPIN_LOCK Lock);
2967
2968 NTKERNELAPI
2969 NTSTATUS
2970 NTAPI
2971 ExUuidCreate(
2972 OUT UUID *Uuid);
2973
2974 NTKERNELAPI
2975 DECLSPEC_NORETURN
2976 VOID
2977 NTAPI
2978 ExRaiseAccessViolation(
2979 VOID);
2980
2981 NTKERNELAPI
2982 DECLSPEC_NORETURN
2983 VOID
2984 NTAPI
2985 ExRaiseDatatypeMisalignment(
2986 VOID);
2987
2988 #endif
2989
2990 #ifdef _X86_
2991
2992 NTKERNELAPI
2993 INTERLOCKED_RESULT
2994 FASTCALL
2995 Exfi386InterlockedIncrementLong(
2996 IN OUT LONG volatile *Addend);
2997
2998 NTKERNELAPI
2999 INTERLOCKED_RESULT
3000 FASTCALL
3001 Exfi386InterlockedDecrementLong(
3002 IN PLONG Addend);
3003
3004 NTKERNELAPI
3005 ULONG
3006 FASTCALL
3007 Exfi386InterlockedExchangeUlong(
3008 IN PULONG Target,
3009 IN ULONG Value);
3010
3011 #endif /* _X86_ */
3012
3013 #ifndef _ARC_DDK_
3014 #define _ARC_DDK_
3015 typedef enum _CONFIGURATION_TYPE {
3016 ArcSystem,
3017 CentralProcessor,
3018 FloatingPointProcessor,
3019 PrimaryIcache,
3020 PrimaryDcache,
3021 SecondaryIcache,
3022 SecondaryDcache,
3023 SecondaryCache,
3024 EisaAdapter,
3025 TcAdapter,
3026 ScsiAdapter,
3027 DtiAdapter,
3028 MultiFunctionAdapter,
3029 DiskController,
3030 TapeController,
3031 CdromController,
3032 WormController,
3033 SerialController,
3034 NetworkController,
3035 DisplayController,
3036 ParallelController,
3037 PointerController,
3038 KeyboardController,
3039 AudioController,
3040 OtherController,
3041 DiskPeripheral,
3042 FloppyDiskPeripheral,
3043 TapePeripheral,
3044 ModemPeripheral,
3045 MonitorPeripheral,
3046 PrinterPeripheral,
3047 PointerPeripheral,
3048 KeyboardPeripheral,
3049 TerminalPeripheral,
3050 OtherPeripheral,
3051 LinePeripheral,
3052 NetworkPeripheral,
3053 SystemMemory,
3054 DockingInformation,
3055 RealModeIrqRoutingTable,
3056 RealModePCIEnumeration,
3057 MaximumType
3058 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
3059 #endif /* !_ARC_DDK_ */
3060
3061 typedef struct _CONTROLLER_OBJECT {
3062 CSHORT Type;
3063 CSHORT Size;
3064 PVOID ControllerExtension;
3065 KDEVICE_QUEUE DeviceWaitQueue;
3066 ULONG Spare1;
3067 LARGE_INTEGER Spare2;
3068 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
3069
3070 typedef struct _CONFIGURATION_INFORMATION {
3071 ULONG DiskCount;
3072 ULONG FloppyCount;
3073 ULONG CdRomCount;
3074 ULONG TapeCount;
3075 ULONG ScsiPortCount;
3076 ULONG SerialCount;
3077 ULONG ParallelCount;
3078 BOOLEAN AtDiskPrimaryAddressClaimed;
3079 BOOLEAN AtDiskSecondaryAddressClaimed;
3080 ULONG Version;
3081 ULONG MediumChangerCount;
3082 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
3083
3084 typedef
3085 NTSTATUS
3086 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
3087 IN PVOID Context,
3088 IN PUNICODE_STRING PathName,
3089 IN INTERFACE_TYPE BusType,
3090 IN ULONG BusNumber,
3091 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
3092 IN CONFIGURATION_TYPE ControllerType,
3093 IN ULONG ControllerNumber,
3094 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
3095 IN CONFIGURATION_TYPE PeripheralType,
3096 IN ULONG PeripheralNumber,
3097 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
3098
3099 typedef
3100 VOID
3101 (NTAPI DRIVER_REINITIALIZE)(
3102 IN struct _DRIVER_OBJECT *DriverObject,
3103 IN PVOID Context,
3104 IN ULONG Count);
3105
3106 typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE;
3107
3108 /** Filesystem runtime library routines **/
3109
3110 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3111 NTKERNELAPI
3112 BOOLEAN
3113 NTAPI
3114 FsRtlIsTotalDeviceFailure(
3115 IN NTSTATUS Status);
3116 #endif
3117
3118 /* Hardware Abstraction Layer Types */
3119
3120 typedef VOID
3121 (NTAPI *PciPin2Line)(
3122 IN struct _BUS_HANDLER *BusHandler,
3123 IN struct _BUS_HANDLER *RootHandler,
3124 IN PCI_SLOT_NUMBER SlotNumber,
3125 IN PPCI_COMMON_CONFIG PciData);
3126
3127 typedef VOID
3128 (NTAPI *PciLine2Pin)(
3129 IN struct _BUS_HANDLER *BusHandler,
3130 IN struct _BUS_HANDLER *RootHandler,
3131 IN PCI_SLOT_NUMBER SlotNumber,
3132 IN PPCI_COMMON_CONFIG PciNewData,
3133 IN PPCI_COMMON_CONFIG PciOldData);
3134
3135 typedef VOID
3136 (NTAPI *PciReadWriteConfig)(
3137 IN struct _BUS_HANDLER *BusHandler,
3138 IN PCI_SLOT_NUMBER Slot,
3139 IN PVOID Buffer,
3140 IN ULONG Offset,
3141 IN ULONG Length);
3142
3143 #define PCI_DATA_TAG ' ICP'
3144 #define PCI_DATA_VERSION 1
3145
3146 typedef struct _PCIBUSDATA {
3147 ULONG Tag;
3148 ULONG Version;
3149 PciReadWriteConfig ReadConfig;
3150 PciReadWriteConfig WriteConfig;
3151 PciPin2Line Pin2Line;
3152 PciLine2Pin Line2Pin;
3153 PCI_SLOT_NUMBER ParentSlot;
3154 PVOID Reserved[4];
3155 } PCIBUSDATA, *PPCIBUSDATA;
3156
3157 /* Hardware Abstraction Layer Functions */
3158
3159 #if !defined(NO_LEGACY_DRIVERS)
3160
3161 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3162
3163 NTHALAPI
3164 NTSTATUS
3165 NTAPI
3166 HalAssignSlotResources(
3167 IN PUNICODE_STRING RegistryPath,
3168 IN PUNICODE_STRING DriverClassName,
3169 IN PDRIVER_OBJECT DriverObject,
3170 IN PDEVICE_OBJECT DeviceObject,
3171 IN INTERFACE_TYPE BusType,
3172 IN ULONG BusNumber,
3173 IN ULONG SlotNumber,
3174 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3175
3176 NTHALAPI
3177 ULONG
3178 NTAPI
3179 HalGetInterruptVector(
3180 IN INTERFACE_TYPE InterfaceType,
3181 IN ULONG BusNumber,
3182 IN ULONG BusInterruptLevel,
3183 IN ULONG BusInterruptVector,
3184 OUT PKIRQL Irql,
3185 OUT PKAFFINITY Affinity);
3186
3187 NTHALAPI
3188 ULONG
3189 NTAPI
3190 HalSetBusData(
3191 IN BUS_DATA_TYPE BusDataType,
3192 IN ULONG BusNumber,
3193 IN ULONG SlotNumber,
3194 IN PVOID Buffer,
3195 IN ULONG Length);
3196
3197 #endif
3198
3199 #endif /* !defined(NO_LEGACY_DRIVERS) */
3200
3201 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3202
3203 NTHALAPI
3204 PADAPTER_OBJECT
3205 NTAPI
3206 HalGetAdapter(
3207 IN PDEVICE_DESCRIPTION DeviceDescription,
3208 IN OUT PULONG NumberOfMapRegisters);
3209
3210 NTHALAPI
3211 BOOLEAN
3212 NTAPI
3213 HalMakeBeep(
3214 IN ULONG Frequency);
3215
3216 VOID
3217 NTAPI
3218 HalPutDmaAdapter(
3219 IN PADAPTER_OBJECT DmaAdapter);
3220
3221 NTHALAPI
3222 VOID
3223 NTAPI
3224 HalAcquireDisplayOwnership(
3225 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
3226
3227 NTHALAPI
3228 ULONG
3229 NTAPI
3230 HalGetBusData(
3231 IN BUS_DATA_TYPE BusDataType,
3232 IN ULONG BusNumber,
3233 IN ULONG SlotNumber,
3234 OUT PVOID Buffer,
3235 IN ULONG Length);
3236
3237 NTHALAPI
3238 ULONG
3239 NTAPI
3240 HalGetBusDataByOffset(
3241 IN BUS_DATA_TYPE BusDataType,
3242 IN ULONG BusNumber,
3243 IN ULONG SlotNumber,
3244 OUT PVOID Buffer,
3245 IN ULONG Offset,
3246 IN ULONG Length);
3247
3248 NTHALAPI
3249 ULONG
3250 NTAPI
3251 HalSetBusDataByOffset(
3252 IN BUS_DATA_TYPE BusDataType,
3253 IN ULONG BusNumber,
3254 IN ULONG SlotNumber,
3255 IN PVOID Buffer,
3256 IN ULONG Offset,
3257 IN ULONG Length);
3258
3259 NTHALAPI
3260 BOOLEAN
3261 NTAPI
3262 HalTranslateBusAddress(
3263 IN INTERFACE_TYPE InterfaceType,
3264 IN ULONG BusNumber,
3265 IN PHYSICAL_ADDRESS BusAddress,
3266 IN OUT PULONG AddressSpace,
3267 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3268
3269 #endif
3270
3271 #if (NTDDI_VERSION >= NTDDI_WINXP)
3272 NTKERNELAPI
3273 VOID
3274 FASTCALL
3275 HalExamineMBR(
3276 IN PDEVICE_OBJECT DeviceObject,
3277 IN ULONG SectorSize,
3278 IN ULONG MBRTypeIdentifier,
3279 OUT PVOID *Buffer);
3280 #endif
3281
3282 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
3283 // nothing here
3284 #else
3285
3286 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3287 //DECLSPEC_DEPRECATED_DDK
3288 NTHALAPI
3289 VOID
3290 NTAPI
3291 IoFreeAdapterChannel(
3292 IN PADAPTER_OBJECT AdapterObject);
3293
3294 //DECLSPEC_DEPRECATED_DDK
3295 NTHALAPI
3296 BOOLEAN
3297 NTAPI
3298 IoFlushAdapterBuffers(
3299 IN PADAPTER_OBJECT AdapterObject,
3300 IN PMDL Mdl,
3301 IN PVOID MapRegisterBase,
3302 IN PVOID CurrentVa,
3303 IN ULONG Length,
3304 IN BOOLEAN WriteToDevice);
3305
3306 //DECLSPEC_DEPRECATED_DDK
3307 NTHALAPI
3308 VOID
3309 NTAPI
3310 IoFreeMapRegisters(
3311 IN PADAPTER_OBJECT AdapterObject,
3312 IN PVOID MapRegisterBase,
3313 IN ULONG NumberOfMapRegisters);
3314
3315 //DECLSPEC_DEPRECATED_DDK
3316 NTHALAPI
3317 PVOID
3318 NTAPI
3319 HalAllocateCommonBuffer(
3320 IN PADAPTER_OBJECT AdapterObject,
3321 IN ULONG Length,
3322 OUT PPHYSICAL_ADDRESS LogicalAddress,
3323 IN BOOLEAN CacheEnabled);
3324
3325 //DECLSPEC_DEPRECATED_DDK
3326 NTHALAPI
3327 VOID
3328 NTAPI
3329 HalFreeCommonBuffer(
3330 IN PADAPTER_OBJECT AdapterObject,
3331 IN ULONG Length,
3332 IN PHYSICAL_ADDRESS LogicalAddress,
3333 IN PVOID VirtualAddress,
3334 IN BOOLEAN CacheEnabled);
3335
3336 //DECLSPEC_DEPRECATED_DDK
3337 NTHALAPI
3338 ULONG
3339 NTAPI
3340 HalReadDmaCounter(
3341 IN PADAPTER_OBJECT AdapterObject);
3342
3343 NTHALAPI
3344 NTSTATUS
3345 NTAPI
3346 HalAllocateAdapterChannel(
3347 IN PADAPTER_OBJECT AdapterObject,
3348 IN PWAIT_CONTEXT_BLOCK Wcb,
3349 IN ULONG NumberOfMapRegisters,
3350 IN PDRIVER_CONTROL ExecutionRoutine);
3351
3352 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3353
3354 #endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */
3355
3356 /* I/O Manager Functions */
3357
3358 /*
3359 * VOID IoAssignArcName(
3360 * IN PUNICODE_STRING ArcName,
3361 * IN PUNICODE_STRING DeviceName);
3362 */
3363 #define IoAssignArcName(_ArcName, _DeviceName) ( \
3364 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
3365
3366 /*
3367 * VOID
3368 * IoDeassignArcName(
3369 * IN PUNICODE_STRING ArcName)
3370 */
3371 #define IoDeassignArcName IoDeleteSymbolicLink
3372
3373 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3374
3375 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
3376 NTKERNELAPI
3377 NTSTATUS
3378 NTAPI
3379 IoAllocateAdapterChannel(
3380 IN PADAPTER_OBJECT AdapterObject,
3381 IN PDEVICE_OBJECT DeviceObject,
3382 IN ULONG NumberOfMapRegisters,
3383 IN PDRIVER_CONTROL ExecutionRoutine,
3384 IN PVOID Context);
3385 #endif
3386
3387 //DECLSPEC_DEPRECATED_DDK
3388 NTHALAPI
3389 PHYSICAL_ADDRESS
3390 NTAPI
3391 IoMapTransfer(
3392 IN PADAPTER_OBJECT AdapterObject,
3393 IN PMDL Mdl,
3394 IN PVOID MapRegisterBase,
3395 IN PVOID CurrentVa,
3396 IN OUT PULONG Length,
3397 IN BOOLEAN WriteToDevice);
3398
3399 NTKERNELAPI
3400 VOID
3401 NTAPI
3402 IoAllocateController(
3403 IN PCONTROLLER_OBJECT ControllerObject,
3404 IN PDEVICE_OBJECT DeviceObject,
3405 IN PDRIVER_CONTROL ExecutionRoutine,
3406 IN PVOID Context OPTIONAL);
3407
3408 NTKERNELAPI
3409 PCONTROLLER_OBJECT
3410 NTAPI
3411 IoCreateController(
3412 IN ULONG Size);
3413
3414 NTKERNELAPI
3415 VOID
3416 NTAPI
3417 IoDeleteController(
3418 IN PCONTROLLER_OBJECT ControllerObject);
3419
3420 NTKERNELAPI
3421 VOID
3422 NTAPI
3423 IoFreeController(
3424 IN PCONTROLLER_OBJECT ControllerObject);
3425
3426 NTKERNELAPI
3427 PCONFIGURATION_INFORMATION
3428 NTAPI
3429 IoGetConfigurationInformation(
3430 VOID);
3431
3432 NTKERNELAPI
3433 PDEVICE_OBJECT
3434 NTAPI
3435 IoGetDeviceToVerify(
3436 IN PETHREAD Thread);
3437
3438 NTKERNELAPI
3439 VOID
3440 NTAPI
3441 IoCancelFileOpen(
3442 IN PDEVICE_OBJECT DeviceObject,
3443 IN PFILE_OBJECT FileObject);
3444
3445 NTKERNELAPI
3446 PGENERIC_MAPPING
3447 NTAPI
3448 IoGetFileObjectGenericMapping(
3449 VOID);
3450
3451 NTKERNELAPI
3452 PIRP
3453 NTAPI
3454 IoMakeAssociatedIrp(
3455 IN PIRP Irp,
3456 IN CCHAR StackSize);
3457
3458 NTKERNELAPI
3459 NTSTATUS
3460 NTAPI
3461 IoQueryDeviceDescription(
3462 IN PINTERFACE_TYPE BusType OPTIONAL,
3463 IN PULONG BusNumber OPTIONAL,
3464 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
3465 IN PULONG ControllerNumber OPTIONAL,
3466 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
3467 IN PULONG PeripheralNumber OPTIONAL,
3468 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
3469 IN OUT PVOID Context OPTIONAL);
3470
3471 NTKERNELAPI
3472 VOID
3473 NTAPI
3474 IoRaiseHardError(
3475 IN PIRP Irp,
3476 IN PVPB Vpb OPTIONAL,
3477 IN PDEVICE_OBJECT RealDeviceObject);
3478
3479 NTKERNELAPI
3480 BOOLEAN
3481 NTAPI
3482 IoRaiseInformationalHardError(
3483 IN NTSTATUS ErrorStatus,
3484 IN PUNICODE_STRING String OPTIONAL,
3485 IN PKTHREAD Thread OPTIONAL);
3486
3487 NTKERNELAPI
3488 VOID
3489 NTAPI
3490 IoRegisterBootDriverReinitialization(
3491 IN PDRIVER_OBJECT DriverObject,
3492 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3493 IN PVOID Context OPTIONAL);
3494
3495 NTKERNELAPI
3496 VOID
3497 NTAPI
3498 IoRegisterDriverReinitialization(
3499 IN PDRIVER_OBJECT DriverObject,
3500 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3501 IN PVOID Context OPTIONAL);
3502
3503 NTKERNELAPI
3504 NTSTATUS
3505 NTAPI
3506 IoAttachDeviceByPointer(
3507 IN PDEVICE_OBJECT SourceDevice,
3508 IN PDEVICE_OBJECT TargetDevice);
3509
3510 NTKERNELAPI
3511 NTSTATUS
3512 NTAPI
3513 IoReportDetectedDevice(
3514 IN PDRIVER_OBJECT DriverObject,
3515 IN INTERFACE_TYPE LegacyBusType,
3516 IN ULONG BusNumber,
3517 IN ULONG SlotNumber,
3518 IN PCM_RESOURCE_LIST ResourceList OPTIONAL,
3519 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
3520 IN BOOLEAN ResourceAssigned,
3521 IN OUT PDEVICE_OBJECT *DeviceObject);
3522
3523 NTKERNELAPI
3524 NTSTATUS
3525 NTAPI
3526 IoReportResourceForDetection(
3527 IN PDRIVER_OBJECT DriverObject,
3528 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
3529 IN ULONG DriverListSize OPTIONAL,
3530 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3531 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
3532 IN ULONG DeviceListSize OPTIONAL,
3533 OUT PBOOLEAN ConflictDetected);
3534
3535 NTKERNELAPI
3536 NTSTATUS
3537 NTAPI
3538 IoReportResourceUsage(
3539 IN PUNICODE_STRING DriverClassName OPTIONAL,
3540 IN PDRIVER_OBJECT DriverObject,
3541 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
3542 IN ULONG DriverListSize OPTIONAL,
3543 IN PDEVICE_OBJECT DeviceObject,
3544 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
3545 IN ULONG DeviceListSize OPTIONAL,
3546 IN BOOLEAN OverrideConflict,
3547 OUT PBOOLEAN ConflictDetected);
3548
3549 NTKERNELAPI
3550 VOID
3551 NTAPI
3552 IoSetHardErrorOrVerifyDevice(
3553 IN PIRP Irp,
3554 IN PDEVICE_OBJECT DeviceObject);
3555
3556 NTKERNELAPI
3557 NTSTATUS
3558 NTAPI
3559 IoAssignResources(
3560 IN PUNICODE_STRING RegistryPath,
3561 IN PUNICODE_STRING DriverClassName OPTIONAL,
3562 IN PDRIVER_OBJECT DriverObject,
3563 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3564 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL,
3565 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3566
3567 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3568
3569 #if (NTDDI_VERSION >= NTDDI_WINXP)
3570
3571 NTKERNELAPI
3572 NTSTATUS
3573 NTAPI
3574 IoCreateDisk(
3575 IN PDEVICE_OBJECT DeviceObject,
3576 IN struct _CREATE_DISK* Disk OPTIONAL);
3577
3578 NTKERNELAPI
3579 NTSTATUS
3580 NTAPI
3581 IoReadDiskSignature(
3582 IN PDEVICE_OBJECT DeviceObject,
3583 IN ULONG BytesPerSector,
3584 OUT PDISK_SIGNATURE Signature);
3585
3586 NTKERNELAPI
3587 NTSTATUS
3588 FASTCALL
3589 IoReadPartitionTable(
3590 IN PDEVICE_OBJECT DeviceObject,
3591 IN ULONG SectorSize,
3592 IN BOOLEAN ReturnRecognizedPartitions,
3593 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
3594
3595 NTKERNELAPI
3596 NTSTATUS
3597 NTAPI
3598 IoReadPartitionTableEx(
3599 IN PDEVICE_OBJECT DeviceObject,
3600 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
3601
3602 NTKERNELAPI
3603 NTSTATUS
3604 FASTCALL
3605 IoSetPartitionInformation(
3606 IN PDEVICE_OBJECT DeviceObject,
3607 IN ULONG SectorSize,
3608 IN ULONG PartitionNumber,
3609 IN ULONG PartitionType);
3610
3611 NTKERNELAPI
3612 NTSTATUS
3613 NTAPI
3614 IoSetPartitionInformationEx(
3615 IN PDEVICE_OBJECT DeviceObject,
3616 IN ULONG PartitionNumber,
3617 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
3618
3619 NTKERNELAPI
3620 NTSTATUS
3621 NTAPI
3622 IoSetSystemPartition(
3623 IN PUNICODE_STRING VolumeNameString);
3624
3625 NTKERNELAPI
3626 BOOLEAN
3627 NTAPI
3628 IoSetThreadHardErrorMode(
3629 IN BOOLEAN EnableHardErrors);
3630
3631 NTKERNELAPI
3632 NTSTATUS
3633 NTAPI
3634 IoVerifyPartitionTable(
3635 IN PDEVICE_OBJECT DeviceObject,
3636 IN BOOLEAN FixErrors);
3637
3638 NTKERNELAPI
3639 NTSTATUS
3640 NTAPI
3641 IoVolumeDeviceToDosName(
3642 IN PVOID VolumeDeviceObject,
3643 OUT PUNICODE_STRING DosName);
3644
3645 NTKERNELAPI
3646 NTSTATUS
3647 FASTCALL
3648 IoWritePartitionTable(
3649 IN PDEVICE_OBJECT DeviceObject,
3650 IN ULONG SectorSize,
3651 IN ULONG SectorsPerTrack,
3652 IN ULONG NumberOfHeads,
3653 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
3654
3655 NTKERNELAPI
3656 NTSTATUS
3657 NTAPI
3658 IoWritePartitionTableEx(
3659 IN PDEVICE_OBJECT DeviceObject,
3660 IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
3661
3662 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3663
3664 /* Kernel Functions */
3665
3666 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3667
3668 NTKERNELAPI
3669 DECLSPEC_NORETURN
3670 VOID
3671 NTAPI
3672 KeBugCheck(
3673 IN ULONG BugCheckCode);
3674
3675 NTKERNELAPI
3676 LONG
3677 NTAPI
3678 KePulseEvent(
3679 IN OUT PRKEVENT Event,
3680 IN KPRIORITY Increment,
3681 IN BOOLEAN Wait);
3682
3683 NTKERNELAPI
3684 LONG
3685 NTAPI
3686 KeSetBasePriorityThread(
3687 IN OUT PRKTHREAD Thread,
3688 IN LONG Increment);
3689
3690 #endif
3691
3692 /* Memory Manager Types */
3693
3694 typedef struct _PHYSICAL_MEMORY_RANGE {
3695 PHYSICAL_ADDRESS BaseAddress;
3696 LARGE_INTEGER NumberOfBytes;
3697 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3698
3699 /* Memory Manager Functions */
3700
3701 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3702
3703 NTKERNELAPI
3704 PPHYSICAL_MEMORY_RANGE
3705 NTAPI
3706 MmGetPhysicalMemoryRanges(
3707 VOID);
3708
3709 NTKERNELAPI
3710 PHYSICAL_ADDRESS
3711 NTAPI
3712 MmGetPhysicalAddress(
3713 IN PVOID BaseAddress);
3714
3715 NTKERNELAPI
3716 BOOLEAN
3717 NTAPI
3718 MmIsNonPagedSystemAddressValid(
3719 IN PVOID VirtualAddress);
3720
3721 NTKERNELAPI
3722 PVOID
3723 NTAPI
3724 MmAllocateNonCachedMemory(
3725 IN SIZE_T NumberOfBytes);
3726
3727 NTKERNELAPI
3728 VOID
3729 NTAPI
3730 MmFreeNonCachedMemory(
3731 IN PVOID BaseAddress,
3732 IN SIZE_T NumberOfBytes);
3733
3734 NTKERNELAPI
3735 PVOID
3736 NTAPI
3737 MmGetVirtualForPhysical(
3738 IN PHYSICAL_ADDRESS PhysicalAddress);
3739
3740 NTKERNELAPI
3741 NTSTATUS
3742 NTAPI
3743 MmMapUserAddressesToPage(
3744 IN PVOID BaseAddress,
3745 IN SIZE_T NumberOfBytes,
3746 IN PVOID PageAddress);
3747
3748 NTKERNELAPI
3749 PVOID
3750 NTAPI
3751 MmMapVideoDisplay(
3752 IN PHYSICAL_ADDRESS PhysicalAddress,
3753 IN SIZE_T NumberOfBytes,
3754 IN MEMORY_CACHING_TYPE CacheType);
3755
3756 NTKERNELAPI
3757 NTSTATUS
3758 NTAPI
3759 MmMapViewInSessionSpace(
3760 IN PVOID Section,
3761 OUT PVOID *MappedBase,
3762 IN OUT PSIZE_T ViewSize);
3763
3764 NTKERNELAPI
3765 NTSTATUS
3766 NTAPI
3767 MmMapViewInSystemSpace(
3768 IN PVOID Section,
3769 OUT PVOID *MappedBase,
3770 IN OUT PSIZE_T ViewSize);
3771
3772 NTKERNELAPI
3773 BOOLEAN
3774 NTAPI
3775 MmIsAddressValid(
3776 IN PVOID VirtualAddress);
3777
3778 NTKERNELAPI
3779 BOOLEAN
3780 NTAPI
3781 MmIsThisAnNtAsSystem(
3782 VOID);
3783
3784 NTKERNELAPI
3785 VOID
3786 NTAPI
3787 MmLockPagableSectionByHandle(
3788 IN PVOID ImageSectionHandle);
3789
3790 NTKERNELAPI
3791 NTSTATUS
3792 NTAPI
3793 MmUnmapViewInSessionSpace(
3794 IN PVOID MappedBase);
3795
3796 NTKERNELAPI
3797 NTSTATUS
3798 NTAPI
3799 MmUnmapViewInSystemSpace(
3800 IN PVOID MappedBase);
3801
3802 NTKERNELAPI
3803 VOID
3804 NTAPI
3805 MmUnsecureVirtualMemory(
3806 IN HANDLE SecureHandle);
3807
3808 NTKERNELAPI
3809 NTSTATUS
3810 NTAPI
3811 MmRemovePhysicalMemory(
3812 IN PPHYSICAL_ADDRESS StartAddress,
3813 IN OUT PLARGE_INTEGER NumberOfBytes);
3814
3815 NTKERNELAPI
3816 HANDLE
3817 NTAPI
3818 MmSecureVirtualMemory(
3819 IN PVOID Address,
3820 IN SIZE_T Size,
3821 IN ULONG ProbeMode);
3822
3823 NTKERNELAPI
3824 VOID
3825 NTAPI
3826 MmUnmapVideoDisplay(
3827 IN PVOID BaseAddress,
3828 IN SIZE_T NumberOfBytes);
3829
3830 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3831
3832 /** Process manager types **/
3833
3834 typedef VOID
3835 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
3836 IN HANDLE ParentId,
3837 IN HANDLE ProcessId,
3838 IN BOOLEAN Create);
3839
3840 typedef VOID
3841 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
3842 IN HANDLE ProcessId,
3843 IN HANDLE ThreadId,
3844 IN BOOLEAN Create);
3845
3846 typedef VOID
3847 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
3848 IN PUNICODE_STRING FullImageName,
3849 IN HANDLE ProcessId,
3850 IN PIMAGE_INFO ImageInfo);
3851
3852 /** Process manager routines **/
3853
3854 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3855
3856 NTKERNELAPI
3857 NTSTATUS
3858 NTAPI
3859 PsSetLoadImageNotifyRoutine(
3860 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3861
3862 NTKERNELAPI
3863 NTSTATUS
3864 NTAPI
3865 PsSetCreateThreadNotifyRoutine(
3866 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3867
3868 NTKERNELAPI
3869 NTSTATUS
3870 NTAPI
3871 PsSetCreateProcessNotifyRoutine(
3872 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3873 IN BOOLEAN Remove);
3874
3875 NTKERNELAPI
3876 HANDLE
3877 NTAPI
3878 PsGetCurrentProcessId(
3879 VOID);
3880
3881 NTKERNELAPI
3882 HANDLE
3883 NTAPI
3884 PsGetCurrentThreadId(
3885 VOID);
3886
3887 NTKERNELAPI
3888 BOOLEAN
3889 NTAPI
3890 PsGetVersion(
3891 OUT PULONG MajorVersion OPTIONAL,
3892 OUT PULONG MinorVersion OPTIONAL,
3893 OUT PULONG BuildNumber OPTIONAL,
3894 OUT PUNICODE_STRING CSDVersion OPTIONAL);
3895
3896 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3897
3898 #if (NTDDI_VERSION >= NTDDI_WINXP)
3899
3900 NTKERNELAPI
3901 HANDLE
3902 NTAPI
3903 PsGetProcessId(
3904 IN PEPROCESS Process);
3905
3906 NTKERNELAPI
3907 NTSTATUS
3908 NTAPI
3909 PsRemoveCreateThreadNotifyRoutine(
3910 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3911
3912 NTKERNELAPI
3913 NTSTATUS
3914 NTAPI
3915 PsRemoveLoadImageNotifyRoutine(
3916 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3917
3918 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3919
3920 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
3921
3922 /* Security reference monitor routines */
3923
3924 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3925 NTKERNELAPI
3926 BOOLEAN
3927 NTAPI
3928 SeSinglePrivilegeCheck(
3929 IN LUID PrivilegeValue,
3930 IN KPROCESSOR_MODE PreviousMode);
3931 #endif
3932
3933 /* ZwXxx Functions */
3934
3935 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3936
3937 NTSTATUS
3938 NTAPI
3939 ZwCancelTimer(
3940 IN HANDLE TimerHandle,
3941 OUT PBOOLEAN CurrentState OPTIONAL);
3942
3943 NTSTATUS
3944 NTAPI
3945 ZwCreateTimer(
3946 OUT PHANDLE TimerHandle,
3947 IN ACCESS_MASK DesiredAccess,
3948 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3949 IN TIMER_TYPE TimerType);
3950
3951 NTSTATUS
3952 NTAPI
3953 ZwOpenTimer(
3954 OUT PHANDLE TimerHandle,
3955 IN ACCESS_MASK DesiredAccess,
3956 IN POBJECT_ATTRIBUTES ObjectAttributes);
3957
3958 NTSYSAPI
3959 NTSTATUS
3960 NTAPI
3961 ZwSetInformationThread(
3962 IN HANDLE ThreadHandle,
3963 IN THREADINFOCLASS ThreadInformationClass,
3964 IN PVOID ThreadInformation,
3965 IN ULONG ThreadInformationLength);
3966
3967 NTSTATUS
3968 NTAPI
3969 ZwSetTimer(
3970 IN HANDLE TimerHandle,
3971 IN PLARGE_INTEGER DueTime,
3972 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3973 IN PVOID TimerContext OPTIONAL,
3974 IN BOOLEAN ResumeTimer,
3975 IN LONG Period OPTIONAL,
3976 OUT PBOOLEAN PreviousState OPTIONAL);
3977
3978 #endif
3979
3980 NTSYSAPI
3981 NTSTATUS
3982 NTAPI
3983 ZwDisplayString (
3984 IN PUNICODE_STRING String
3985 );
3986
3987 #if (VER_PRODUCTBUILD >= 2195)
3988
3989 NTSYSAPI
3990 NTSTATUS
3991 NTAPI
3992 ZwPowerInformation (
3993 IN POWER_INFORMATION_LEVEL PowerInformationLevel,
3994 IN PVOID InputBuffer OPTIONAL,
3995 IN ULONG InputBufferLength,
3996 OUT PVOID OutputBuffer OPTIONAL,
3997 IN ULONG OutputBufferLength
3998 );
3999
4000 #endif /* (VER_PRODUCTBUILD >= 2195) */
4001
4002 NTSYSAPI
4003 NTSTATUS
4004 NTAPI
4005 ZwTerminateProcess (
4006 IN HANDLE ProcessHandle OPTIONAL,
4007 IN NTSTATUS ExitStatus
4008 );
4009
4010 NTSYSAPI
4011 NTSTATUS
4012 NTAPI
4013 ZwOpenProcess (
4014 OUT PHANDLE ProcessHandle,
4015 IN ACCESS_MASK DesiredAccess,
4016 IN POBJECT_ATTRIBUTES ObjectAttributes,
4017 IN PCLIENT_ID ClientId OPTIONAL