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