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