88dc9fa379c5b644642c49b72f933f141b2700a4
[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 typedef union _RTL_RUN_ONCE {
383 PVOID Ptr;
384 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
385
386 typedef ULONG /* LOGICAL */
387 (NTAPI *PRTL_RUN_ONCE_INIT_FN) (
388 IN OUT PRTL_RUN_ONCE RunOnce,
389 IN OUT PVOID Parameter OPTIONAL,
390 IN OUT PVOID *Context OPTIONAL);
391
392 #endif /* _RTL_RUN_ONCE_DEF */
393
394 typedef enum _TABLE_SEARCH_RESULT {
395 TableEmptyTree,
396 TableFoundNode,
397 TableInsertAsLeft,
398 TableInsertAsRight
399 } TABLE_SEARCH_RESULT;
400
401 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
402 GenericLessThan,
403 GenericGreaterThan,
404 GenericEqual
405 } RTL_GENERIC_COMPARE_RESULTS;
406
407 // Forwarder
408 struct _RTL_AVL_TABLE;
409
410 typedef RTL_GENERIC_COMPARE_RESULTS
411 (NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
412 IN struct _RTL_AVL_TABLE *Table,
413 IN PVOID FirstStruct,
414 IN PVOID SecondStruct);
415
416 typedef PVOID
417 (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
418 IN struct _RTL_AVL_TABLE *Table,
419 IN CLONG ByteSize);
420
421 typedef VOID
422 (NTAPI *PRTL_AVL_FREE_ROUTINE) (
423 IN struct _RTL_AVL_TABLE *Table,
424 IN PVOID Buffer);
425
426 typedef NTSTATUS
427 (NTAPI *PRTL_AVL_MATCH_FUNCTION) (
428 IN struct _RTL_AVL_TABLE *Table,
429 IN PVOID UserData,
430 IN PVOID MatchData);
431
432 typedef struct _RTL_BALANCED_LINKS {
433 struct _RTL_BALANCED_LINKS *Parent;
434 struct _RTL_BALANCED_LINKS *LeftChild;
435 struct _RTL_BALANCED_LINKS *RightChild;
436 CHAR Balance;
437 UCHAR Reserved[3];
438 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
439
440 typedef struct _RTL_AVL_TABLE {
441 RTL_BALANCED_LINKS BalancedRoot;
442 PVOID OrderedPointer;
443 ULONG WhichOrderedElement;
444 ULONG NumberGenericTableElements;
445 ULONG DepthOfTree;
446 PRTL_BALANCED_LINKS RestartKey;
447 ULONG DeleteCount;
448 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
449 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
450 PRTL_AVL_FREE_ROUTINE FreeRoutine;
451 PVOID TableContext;
452 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
453
454 #ifdef RTL_USE_AVL_TABLES
455
456 #undef PRTL_GENERIC_COMPARE_ROUTINE
457 #undef RTL_GENERIC_COMPARE_ROUTINE
458 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
459 #undef RTL_GENERIC_ALLOCATE_ROUTINE
460 #undef PRTL_GENERIC_FREE_ROUTINE
461 #undef RTL_GENERIC_FREE_ROUTINE
462 #undef RTL_GENERIC_TABLE
463 #undef PRTL_GENERIC_TABLE
464
465 #define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE
466 #define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE
467 #define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE
468 #define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE
469 #define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE
470 #define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE
471 #define RTL_GENERIC_TABLE RTL_AVL_TABLE
472 #define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
473
474 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
475 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
476 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
477 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
478 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
479 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
480 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
481 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
482 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
483 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
484 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
485
486 #endif /* RTL_USE_AVL_TABLES */
487
488 typedef struct _RTL_SPLAY_LINKS {
489 struct _RTL_SPLAY_LINKS *Parent;
490 struct _RTL_SPLAY_LINKS *LeftChild;
491 struct _RTL_SPLAY_LINKS *RightChild;
492 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
493
494 #define RtlInitializeSplayLinks(Links) { \
495 PRTL_SPLAY_LINKS _SplayLinks; \
496 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
497 _SplayLinks->Parent = _SplayLinks; \
498 _SplayLinks->LeftChild = NULL; \
499 _SplayLinks->RightChild = NULL; \
500 }
501
502 #define RtlIsLeftChild(Links) \
503 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
504
505 #define RtlIsRightChild(Links) \
506 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
507
508 #define RtlRightChild(Links) \
509 ((PRTL_SPLAY_LINKS)(Links))->RightChild
510
511 #define RtlIsRoot(Links) \
512 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
513
514 #define RtlLeftChild(Links) \
515 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
516
517 #define RtlParent(Links) \
518 ((PRTL_SPLAY_LINKS)(Links))->Parent
519
520 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
521 { \
522 PRTL_SPLAY_LINKS _SplayParent; \
523 PRTL_SPLAY_LINKS _SplayChild; \
524 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
525 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
526 _SplayParent->LeftChild = _SplayChild; \
527 _SplayChild->Parent = _SplayParent; \
528 }
529
530 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
531 { \
532 PRTL_SPLAY_LINKS _SplayParent; \
533 PRTL_SPLAY_LINKS _SplayChild; \
534 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
535 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
536 _SplayParent->RightChild = _SplayChild; \
537 _SplayChild->Parent = _SplayParent; \
538 }
539
540
541 #if (NTDDI_VERSION >= NTDDI_WIN2K)
542
543 NTSYSAPI
544 PRTL_SPLAY_LINKS
545 NTAPI
546 RtlSplay(
547 IN OUT PRTL_SPLAY_LINKS Links);
548
549 NTSYSAPI
550 PRTL_SPLAY_LINKS
551 NTAPI
552 RtlDelete(
553 IN PRTL_SPLAY_LINKS Links);
554
555 NTSYSAPI
556 VOID
557 NTAPI
558 RtlDeleteNoSplay(
559 IN PRTL_SPLAY_LINKS Links,
560 IN OUT PRTL_SPLAY_LINKS *Root);
561
562 NTSYSAPI
563 PRTL_SPLAY_LINKS
564 NTAPI
565 RtlSubtreeSuccessor(
566 IN PRTL_SPLAY_LINKS Links);
567
568 NTSYSAPI
569 PRTL_SPLAY_LINKS
570 NTAPI
571 RtlSubtreePredecessor(
572 IN PRTL_SPLAY_LINKS Links);
573
574 NTSYSAPI
575 PRTL_SPLAY_LINKS
576 NTAPI
577 RtlRealSuccessor(
578 IN PRTL_SPLAY_LINKS Links);
579
580 NTSYSAPI
581 PRTL_SPLAY_LINKS
582 NTAPI
583 RtlRealPredecessor(
584 IN PRTL_SPLAY_LINKS Links);
585
586 #endif
587
588 #if (NTDDI_VERSION >= NTDDI_WINXP)
589
590 NTSYSAPI
591 VOID
592 NTAPI
593 RtlInitializeGenericTableAvl(
594 OUT PRTL_AVL_TABLE Table,
595 IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
596 IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
597 IN PRTL_AVL_FREE_ROUTINE FreeRoutine,
598 IN PVOID TableContext OPTIONAL);
599
600 NTSYSAPI
601 PVOID
602 NTAPI
603 RtlInsertElementGenericTableAvl(
604 IN PRTL_AVL_TABLE Table,
605 IN PVOID Buffer,
606 IN CLONG BufferSize,
607 OUT PBOOLEAN NewElement OPTIONAL);
608
609 NTSYSAPI
610 PVOID
611 NTAPI
612 RtlInsertElementGenericTableFullAvl(
613 IN PRTL_AVL_TABLE Table,
614 IN PVOID Buffer,
615 IN CLONG BufferSize,
616 OUT PBOOLEAN NewElement OPTIONAL,
617 IN PVOID NodeOrParent,
618 IN TABLE_SEARCH_RESULT SearchResult);
619
620 NTSYSAPI
621 BOOLEAN
622 NTAPI
623 RtlDeleteElementGenericTableAvl(
624 IN PRTL_AVL_TABLE Table,
625 IN PVOID Buffer);
626
627 NTSYSAPI
628 PVOID
629 NTAPI
630 RtlLookupElementGenericTableAvl(
631 IN PRTL_AVL_TABLE Table,
632 IN PVOID Buffer);
633
634 NTSYSAPI
635 PVOID
636 NTAPI
637 RtlLookupElementGenericTableFullAvl(
638 IN PRTL_AVL_TABLE Table,
639 IN PVOID Buffer,
640 OUT PVOID *NodeOrParent,
641 OUT TABLE_SEARCH_RESULT *SearchResult);
642
643 NTSYSAPI
644 PVOID
645 NTAPI
646 RtlEnumerateGenericTableAvl(
647 IN PRTL_AVL_TABLE Table,
648 IN BOOLEAN Restart);
649
650 NTSYSAPI
651 PVOID
652 NTAPI
653 RtlEnumerateGenericTableWithoutSplayingAvl(
654 IN PRTL_AVL_TABLE Table,
655 IN OUT PVOID *RestartKey);
656
657 NTSYSAPI
658 PVOID
659 NTAPI
660 RtlLookupFirstMatchingElementGenericTableAvl(
661 IN PRTL_AVL_TABLE Table,
662 IN PVOID Buffer,
663 OUT PVOID *RestartKey);
664
665 NTSYSAPI
666 PVOID
667 NTAPI
668 RtlEnumerateGenericTableLikeADirectory(
669 IN PRTL_AVL_TABLE Table,
670 IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL,
671 IN PVOID MatchData OPTIONAL,
672 IN ULONG NextFlag,
673 IN OUT PVOID *RestartKey,
674 IN OUT PULONG DeleteCount,
675 IN PVOID Buffer);
676
677 NTSYSAPI
678 PVOID
679 NTAPI
680 RtlGetElementGenericTableAvl(
681 IN PRTL_AVL_TABLE Table,
682 IN ULONG I);
683
684 NTSYSAPI
685 ULONG
686 NTAPI
687 RtlNumberGenericTableElementsAvl(
688 IN PRTL_AVL_TABLE Table);
689
690 NTSYSAPI
691 BOOLEAN
692 NTAPI
693 RtlIsGenericTableEmptyAvl(
694 IN PRTL_AVL_TABLE Table);
695
696
697 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
698
699 #if (NTDDI_VERSION >= NTDDI_WIN6)
700
701 NTSYSAPI
702 VOID
703 NTAPI
704 RtlRunOnceInitialize(
705 OUT PRTL_RUN_ONCE RunOnce);
706
707 NTSYSAPI
708 NTSTATUS
709 NTAPI
710 RtlRunOnceExecuteOnce(
711 IN OUT PRTL_RUN_ONCE RunOnce,
712 IN PRTL_RUN_ONCE_INIT_FN InitFn,
713 IN OUT PVOID Parameter OPTIONAL,
714 OUT PVOID *Context OPTIONAL);
715
716 NTSYSAPI
717 NTSTATUS
718 NTAPI
719 RtlRunOnceBeginInitialize(
720 IN OUT PRTL_RUN_ONCE RunOnce,
721 IN ULONG Flags,
722 OUT PVOID *Context OPTIONAL);
723
724 NTSYSAPI
725 NTSTATUS
726 NTAPI
727 RtlRunOnceComplete(
728 IN OUT PRTL_RUN_ONCE RunOnce,
729 IN ULONG Flags,
730 IN PVOID Context OPTIONAL);
731
732 #endif /* (NTDDI_VERSION >= NTDDI_WIN6) */
733
734 struct _LOADER_PARAMETER_BLOCK;
735 struct _CREATE_DISK;
736 struct _DRIVE_LAYOUT_INFORMATION_EX;
737 struct _SET_PARTITION_INFORMATION_EX;
738
739 //
740 // GUID and UUID
741 //
742 #ifndef GUID_DEFINED
743 #include <guiddef.h>
744 #endif
745 typedef GUID UUID;
746
747 #define MAX_WOW64_SHARED_ENTRIES 16
748
749 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
750 #define NX_SUPPORT_POLICY_ALWAYSON 1
751 #define NX_SUPPORT_POLICY_OPTIN 2
752 #define NX_SUPPORT_POLICY_OPTOUT 3
753
754 /*
755 ** IRP function codes
756 */
757
758 #define IRP_MN_QUERY_DIRECTORY 0x01
759 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
760
761 #define IRP_MN_USER_FS_REQUEST 0x00
762 #define IRP_MN_MOUNT_VOLUME 0x01
763 #define IRP_MN_VERIFY_VOLUME 0x02
764 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
765 #define IRP_MN_TRACK_LINK 0x04
766 #define IRP_MN_KERNEL_CALL 0x04
767
768 #define IRP_MN_LOCK 0x01
769 #define IRP_MN_UNLOCK_SINGLE 0x02
770 #define IRP_MN_UNLOCK_ALL 0x03
771 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
772
773 #define IRP_MN_FLUSH_AND_PURGE 0x01
774
775 #define IRP_MN_NORMAL 0x00
776 #define IRP_MN_DPC 0x01
777 #define IRP_MN_MDL 0x02
778 #define IRP_MN_COMPLETE 0x04
779 #define IRP_MN_COMPRESSED 0x08
780
781 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
782 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
783 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
784
785 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
786
787 typedef struct _IO_COUNTERS {
788 ULONGLONG ReadOperationCount;
789 ULONGLONG WriteOperationCount;
790 ULONGLONG OtherOperationCount;
791 ULONGLONG ReadTransferCount;
792 ULONGLONG WriteTransferCount;
793 ULONGLONG OtherTransferCount;
794 } IO_COUNTERS, *PIO_COUNTERS;
795
796 typedef struct _VM_COUNTERS {
797 SIZE_T PeakVirtualSize;
798 SIZE_T VirtualSize;
799 ULONG PageFaultCount;
800 SIZE_T PeakWorkingSetSize;
801 SIZE_T WorkingSetSize;
802 SIZE_T QuotaPeakPagedPoolUsage;
803 SIZE_T QuotaPagedPoolUsage;
804 SIZE_T QuotaPeakNonPagedPoolUsage;
805 SIZE_T QuotaNonPagedPoolUsage;
806 SIZE_T PagefileUsage;
807 SIZE_T PeakPagefileUsage;
808 } VM_COUNTERS, *PVM_COUNTERS;
809
810 typedef struct _VM_COUNTERS_EX
811 {
812 SIZE_T PeakVirtualSize;
813 SIZE_T VirtualSize;
814 ULONG PageFaultCount;
815 SIZE_T PeakWorkingSetSize;
816 SIZE_T WorkingSetSize;
817 SIZE_T QuotaPeakPagedPoolUsage;
818 SIZE_T QuotaPagedPoolUsage;
819 SIZE_T QuotaPeakNonPagedPoolUsage;
820 SIZE_T QuotaNonPagedPoolUsage;
821 SIZE_T PagefileUsage;
822 SIZE_T PeakPagefileUsage;
823 SIZE_T PrivateUsage;
824 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
825
826 typedef struct _POOLED_USAGE_AND_LIMITS
827 {
828 SIZE_T PeakPagedPoolUsage;
829 SIZE_T PagedPoolUsage;
830 SIZE_T PagedPoolLimit;
831 SIZE_T PeakNonPagedPoolUsage;
832 SIZE_T NonPagedPoolUsage;
833 SIZE_T NonPagedPoolLimit;
834 SIZE_T PeakPagefileUsage;
835 SIZE_T PagefileUsage;
836 SIZE_T PagefileLimit;
837 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
838
839 /* DEVICE_OBJECT.Flags */
840
841 #define DO_DEVICE_HAS_NAME 0x00000040
842 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
843 #define DO_LONG_TERM_REQUESTS 0x00000200
844 #define DO_NEVER_LAST_DEVICE 0x00000400
845 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
846 #define DO_SUPPORTS_TRANSACTIONS 0x00040000
847 #define DO_FORCE_NEITHER_IO 0x00080000
848 #define DO_VOLUME_DEVICE_OBJECT 0x00100000
849 #define DO_SYSTEM_SYSTEM_PARTITION 0x00200000
850 #define DO_SYSTEM_CRITICAL_PARTITION 0x00400000
851 #define DO_DISALLOW_EXECUTE 0x00800000
852
853 #define DRVO_REINIT_REGISTERED 0x00000008
854 #define DRVO_INITIALIZED 0x00000010
855 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
856 #define DRVO_LEGACY_RESOURCES 0x00000040
857
858 typedef enum _ARBITER_REQUEST_SOURCE {
859 ArbiterRequestUndefined = -1,
860 ArbiterRequestLegacyReported,
861 ArbiterRequestHalReported,
862 ArbiterRequestLegacyAssigned,
863 ArbiterRequestPnpDetected,
864 ArbiterRequestPnpEnumerated
865 } ARBITER_REQUEST_SOURCE;
866
867 typedef enum _ARBITER_RESULT {
868 ArbiterResultUndefined = -1,
869 ArbiterResultSuccess,
870 ArbiterResultExternalConflict,
871 ArbiterResultNullRequest
872 } ARBITER_RESULT;
873
874 typedef enum _ARBITER_ACTION {
875 ArbiterActionTestAllocation,
876 ArbiterActionRetestAllocation,
877 ArbiterActionCommitAllocation,
878 ArbiterActionRollbackAllocation,
879 ArbiterActionQueryAllocatedResources,
880 ArbiterActionWriteReservedResources,
881 ArbiterActionQueryConflict,
882 ArbiterActionQueryArbitrate,
883 ArbiterActionAddReserved,
884 ArbiterActionBootAllocation
885 } ARBITER_ACTION, *PARBITER_ACTION;
886
887 typedef struct _ARBITER_CONFLICT_INFO {
888 PDEVICE_OBJECT OwningObject;
889 ULONGLONG Start;
890 ULONGLONG End;
891 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
892
893 typedef struct _ARBITER_PARAMETERS {
894 union {
895 struct {
896 IN OUT PLIST_ENTRY ArbitrationList;
897 IN ULONG AllocateFromCount;
898 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
899 } TestAllocation;
900 struct {
901 IN OUT PLIST_ENTRY ArbitrationList;
902 IN ULONG AllocateFromCount;
903 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
904 } RetestAllocation;
905 struct {
906 IN OUT PLIST_ENTRY ArbitrationList;
907 } BootAllocation;
908 struct {
909 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
910 } QueryAllocatedResources;
911 struct {
912 IN PDEVICE_OBJECT PhysicalDeviceObject;
913 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
914 OUT PULONG ConflictCount;
915 OUT PARBITER_CONFLICT_INFO *Conflicts;
916 } QueryConflict;
917 struct {
918 IN PLIST_ENTRY ArbitrationList;
919 } QueryArbitrate;
920 struct {
921 IN PDEVICE_OBJECT ReserveDevice;
922 } AddReserved;
923 } Parameters;
924 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
925
926 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
927
928 typedef struct _ARBITER_LIST_ENTRY {
929 LIST_ENTRY ListEntry;
930 ULONG AlternativeCount;
931 PIO_RESOURCE_DESCRIPTOR Alternatives;
932 PDEVICE_OBJECT PhysicalDeviceObject;
933 ARBITER_REQUEST_SOURCE RequestSource;
934 ULONG Flags;
935 LONG_PTR WorkSpace;
936 INTERFACE_TYPE InterfaceType;
937 ULONG SlotNumber;
938 ULONG BusNumber;
939 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
940 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
941 ARBITER_RESULT Result;
942 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
943
944 typedef NTSTATUS
945 (NTAPI *PARBITER_HANDLER)(
946 IN OUT PVOID Context,
947 IN ARBITER_ACTION Action,
948 IN OUT PARBITER_PARAMETERS Parameters);
949
950 #define ARBITER_PARTIAL 0x00000001
951
952 typedef struct _ARBITER_INTERFACE {
953 USHORT Size;
954 USHORT Version;
955 PVOID Context;
956 PINTERFACE_REFERENCE InterfaceReference;
957 PINTERFACE_DEREFERENCE InterfaceDereference;
958 PARBITER_HANDLER ArbiterHandler;
959 ULONG Flags;
960 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
961
962 typedef enum _HAL_QUERY_INFORMATION_CLASS {
963 HalInstalledBusInformation,
964 HalProfileSourceInformation,
965 HalInformationClassUnused1,
966 HalPowerInformation,
967 HalProcessorSpeedInformation,
968 HalCallbackInformation,
969 HalMapRegisterInformation,
970 HalMcaLogInformation,
971 HalFrameBufferCachingInformation,
972 HalDisplayBiosInformation,
973 HalProcessorFeatureInformation,
974 HalNumaTopologyInterface,
975 HalErrorInformation,
976 HalCmcLogInformation,
977 HalCpeLogInformation,
978 HalQueryMcaInterface,
979 HalQueryAMLIIllegalIOPortAddresses,
980 HalQueryMaxHotPlugMemoryAddress,
981 HalPartitionIpiInterface,
982 HalPlatformInformation,
983 HalQueryProfileSourceList,
984 HalInitLogInformation,
985 HalFrequencyInformation,
986 HalProcessorBrandString,
987 HalHypervisorInformation,
988 HalPlatformTimerInformation,
989 HalAcpiAuditInformation
990 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
991
992 typedef enum _HAL_SET_INFORMATION_CLASS {
993 HalProfileSourceInterval,
994 HalProfileSourceInterruptHandler,
995 HalMcaRegisterDriver,
996 HalKernelErrorHandler,
997 HalCmcRegisterDriver,
998 HalCpeRegisterDriver,
999 HalMcaLog,
1000 HalCmcLog,
1001 HalCpeLog,
1002 HalGenerateCmcInterrupt,
1003 HalProfileSourceTimerHandler,
1004 HalEnlightenment,
1005 HalProfileDpgoSourceInterruptHandler
1006 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
1007
1008 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
1009 KPROFILE_SOURCE Source;
1010 ULONG_PTR Interval;
1011 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
1012
1013 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
1014 KPROFILE_SOURCE Source;
1015 BOOLEAN Supported;
1016 ULONG Interval;
1017 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
1018
1019 typedef struct _MAP_REGISTER_ENTRY {
1020 PVOID MapRegister;
1021 BOOLEAN WriteToDevice;
1022 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
1023
1024 typedef struct _DEBUG_DEVICE_ADDRESS {
1025 UCHAR Type;
1026 BOOLEAN Valid;
1027 UCHAR Reserved[2];
1028 PUCHAR TranslatedAddress;
1029 ULONG Length;
1030 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
1031
1032 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
1033 PHYSICAL_ADDRESS Start;
1034 PHYSICAL_ADDRESS MaxEnd;
1035 PVOID VirtualAddress;
1036 ULONG Length;
1037 BOOLEAN Cached;
1038 BOOLEAN Aligned;
1039 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
1040
1041 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
1042 ULONG Bus;
1043 ULONG Slot;
1044 USHORT Segment;
1045 USHORT VendorID;
1046 USHORT DeviceID;
1047 UCHAR BaseClass;
1048 UCHAR SubClass;
1049 UCHAR ProgIf;
1050 BOOLEAN Initialized;
1051 BOOLEAN Configured;
1052 DEBUG_DEVICE_ADDRESS BaseAddress[6];
1053 DEBUG_MEMORY_REQUIREMENTS Memory;
1054 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
1055
1056 typedef struct _PM_DISPATCH_TABLE {
1057 ULONG Signature;
1058 ULONG Version;
1059 PVOID Function[1];
1060 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
1061
1062 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
1063 TranslateChildToParent,
1064 TranslateParentToChild
1065 } RESOURCE_TRANSLATION_DIRECTION;
1066
1067 typedef NTSTATUS
1068 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
1069 IN OUT PVOID Context,
1070 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
1071 IN RESOURCE_TRANSLATION_DIRECTION Direction,
1072 IN ULONG AlternativesCount OPTIONAL,
1073 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
1074 IN PDEVICE_OBJECT PhysicalDeviceObject,
1075 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
1076
1077 typedef NTSTATUS
1078 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
1079 IN PVOID Context OPTIONAL,
1080 IN PIO_RESOURCE_DESCRIPTOR Source,
1081 IN PDEVICE_OBJECT PhysicalDeviceObject,
1082 OUT PULONG TargetCount,
1083 OUT PIO_RESOURCE_DESCRIPTOR *Target);
1084
1085 typedef struct _TRANSLATOR_INTERFACE {
1086 USHORT Size;
1087 USHORT Version;
1088 PVOID Context;
1089 PINTERFACE_REFERENCE InterfaceReference;
1090 PINTERFACE_DEREFERENCE InterfaceDereference;
1091 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
1092 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
1093 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
1094
1095 typedef VOID
1096 (FASTCALL *pHalExamineMBR)(
1097 IN PDEVICE_OBJECT DeviceObject,
1098 IN ULONG SectorSize,
1099 IN ULONG MBRTypeIdentifier,
1100 OUT PVOID *Buffer);
1101
1102 typedef NTSTATUS
1103 (FASTCALL *pHalIoReadPartitionTable)(
1104 IN PDEVICE_OBJECT DeviceObject,
1105 IN ULONG SectorSize,
1106 IN BOOLEAN ReturnRecognizedPartitions,
1107 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
1108
1109 typedef NTSTATUS
1110 (FASTCALL *pHalIoSetPartitionInformation)(
1111 IN PDEVICE_OBJECT DeviceObject,
1112 IN ULONG SectorSize,
1113 IN ULONG PartitionNumber,
1114 IN ULONG PartitionType);
1115
1116 typedef NTSTATUS
1117 (FASTCALL *pHalIoWritePartitionTable)(
1118 IN PDEVICE_OBJECT DeviceObject,
1119 IN ULONG SectorSize,
1120 IN ULONG SectorsPerTrack,
1121 IN ULONG NumberOfHeads,
1122 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
1123
1124 typedef PBUS_HANDLER
1125 (FASTCALL *pHalHandlerForBus)(
1126 IN INTERFACE_TYPE InterfaceType,
1127 IN ULONG BusNumber);
1128
1129 typedef VOID
1130 (FASTCALL *pHalReferenceBusHandler)(
1131 IN PBUS_HANDLER BusHandler);
1132
1133 typedef NTSTATUS
1134 (NTAPI *pHalQuerySystemInformation)(
1135 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
1136 IN ULONG BufferSize,
1137 IN OUT PVOID Buffer,
1138 OUT PULONG ReturnedLength);
1139
1140 typedef NTSTATUS
1141 (NTAPI *pHalSetSystemInformation)(
1142 IN HAL_SET_INFORMATION_CLASS InformationClass,
1143 IN ULONG BufferSize,
1144 IN PVOID Buffer);
1145
1146 typedef NTSTATUS
1147 (NTAPI *pHalQueryBusSlots)(
1148 IN PBUS_HANDLER BusHandler,
1149 IN ULONG BufferSize,
1150 OUT PULONG SlotNumbers,
1151 OUT PULONG ReturnedLength);
1152
1153 typedef NTSTATUS
1154 (NTAPI *pHalInitPnpDriver)(
1155 VOID);
1156
1157 typedef NTSTATUS
1158 (NTAPI *pHalInitPowerManagement)(
1159 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
1160 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
1161
1162 typedef struct _DMA_ADAPTER*
1163 (NTAPI *pHalGetDmaAdapter)(
1164 IN PVOID Context,
1165 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
1166 OUT PULONG NumberOfMapRegisters);
1167
1168 typedef NTSTATUS
1169 (NTAPI *pHalGetInterruptTranslator)(
1170 IN INTERFACE_TYPE ParentInterfaceType,
1171 IN ULONG ParentBusNumber,
1172 IN INTERFACE_TYPE BridgeInterfaceType,
1173 IN USHORT Size,
1174 IN USHORT Version,
1175 OUT PTRANSLATOR_INTERFACE Translator,
1176 OUT PULONG BridgeBusNumber);
1177
1178 typedef NTSTATUS
1179 (NTAPI *pHalStartMirroring)(
1180 VOID);
1181
1182 typedef NTSTATUS
1183 (NTAPI *pHalEndMirroring)(
1184 IN ULONG PassNumber);
1185
1186 typedef NTSTATUS
1187 (NTAPI *pHalMirrorPhysicalMemory)(
1188 IN PHYSICAL_ADDRESS PhysicalAddress,
1189 IN LARGE_INTEGER NumberOfBytes);
1190
1191 typedef NTSTATUS
1192 (NTAPI *pHalMirrorVerify)(
1193 IN PHYSICAL_ADDRESS PhysicalAddress,
1194 IN LARGE_INTEGER NumberOfBytes);
1195
1196 typedef VOID
1197 (NTAPI *pHalEndOfBoot)(
1198 VOID);
1199
1200 typedef
1201 BOOLEAN
1202 (NTAPI *pHalTranslateBusAddress)(
1203 IN INTERFACE_TYPE InterfaceType,
1204 IN ULONG BusNumber,
1205 IN PHYSICAL_ADDRESS BusAddress,
1206 IN OUT PULONG AddressSpace,
1207 OUT PPHYSICAL_ADDRESS TranslatedAddress);
1208
1209 typedef
1210 NTSTATUS
1211 (NTAPI *pHalAssignSlotResources)(
1212 IN PUNICODE_STRING RegistryPath,
1213 IN PUNICODE_STRING DriverClassName OPTIONAL,
1214 IN PDRIVER_OBJECT DriverObject,
1215 IN PDEVICE_OBJECT DeviceObject,
1216 IN INTERFACE_TYPE BusType,
1217 IN ULONG BusNumber,
1218 IN ULONG SlotNumber,
1219 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
1220
1221 typedef
1222 VOID
1223 (NTAPI *pHalHaltSystem)(
1224 VOID);
1225
1226 typedef
1227 BOOLEAN
1228 (NTAPI *pHalResetDisplay)(
1229 VOID);
1230
1231 typedef
1232 UCHAR
1233 (NTAPI *pHalVectorToIDTEntry)(
1234 ULONG Vector);
1235
1236 typedef
1237 BOOLEAN
1238 (NTAPI *pHalFindBusAddressTranslation)(
1239 IN PHYSICAL_ADDRESS BusAddress,
1240 IN OUT PULONG AddressSpace,
1241 OUT PPHYSICAL_ADDRESS TranslatedAddress,
1242 IN OUT PULONG_PTR Context,
1243 IN BOOLEAN NextBus);
1244
1245 typedef
1246 NTSTATUS
1247 (NTAPI *pKdSetupPciDeviceForDebugging)(
1248 IN PVOID LoaderBlock OPTIONAL,
1249 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
1250
1251 typedef
1252 NTSTATUS
1253 (NTAPI *pKdReleasePciDeviceForDebugging)(
1254 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
1255
1256 typedef
1257 PVOID
1258 (NTAPI *pKdGetAcpiTablePhase0)(
1259 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1260 IN ULONG Signature);
1261
1262 typedef
1263 PVOID
1264 (NTAPI *pHalGetAcpiTable)(
1265 IN ULONG Signature,
1266 IN PCSTR OemId OPTIONAL,
1267 IN PCSTR OemTableId OPTIONAL);
1268
1269 typedef
1270 VOID
1271 (NTAPI *pKdCheckPowerButton)(
1272 VOID);
1273
1274 #if (NTDDI_VERSION >= NTDDI_VISTA)
1275 typedef
1276 PVOID
1277 (NTAPI *pKdMapPhysicalMemory64)(
1278 IN PHYSICAL_ADDRESS PhysicalAddress,
1279 IN ULONG NumberPages,
1280 IN BOOLEAN FlushCurrentTLB);
1281
1282 typedef
1283 VOID
1284 (NTAPI *pKdUnmapVirtualAddress)(
1285 IN PVOID VirtualAddress,
1286 IN ULONG NumberPages,
1287 IN BOOLEAN FlushCurrentTLB);
1288 #else
1289 typedef
1290 PVOID
1291 (NTAPI *pKdMapPhysicalMemory64)(
1292 IN PHYSICAL_ADDRESS PhysicalAddress,
1293 IN ULONG NumberPages);
1294
1295 typedef
1296 VOID
1297 (NTAPI *pKdUnmapVirtualAddress)(
1298 IN PVOID VirtualAddress,
1299 IN ULONG NumberPages);
1300 #endif
1301
1302
1303 typedef
1304 ULONG
1305 (NTAPI *pKdGetPciDataByOffset)(
1306 IN ULONG BusNumber,
1307 IN ULONG SlotNumber,
1308 OUT PVOID Buffer,
1309 IN ULONG Offset,
1310 IN ULONG Length);
1311
1312 typedef
1313 ULONG
1314 (NTAPI *pKdSetPciDataByOffset)(
1315 IN ULONG BusNumber,
1316 IN ULONG SlotNumber,
1317 IN PVOID Buffer,
1318 IN ULONG Offset,
1319 IN ULONG Length);
1320
1321 typedef BOOLEAN
1322 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1323 IN ULONG Columns,
1324 IN ULONG Rows);
1325
1326 typedef
1327 VOID
1328 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
1329 VOID);
1330
1331 typedef
1332 VOID
1333 (NTAPI *pHalSetPciErrorHandlerCallback)(
1334 IN PCI_ERROR_HANDLER_CALLBACK Callback);
1335
1336 #if 1 /* Not present in WDK 7600 */
1337 typedef VOID
1338 (FASTCALL *pHalIoAssignDriveLetters)(
1339 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1340 IN PSTRING NtDeviceName,
1341 OUT PUCHAR NtSystemPath,
1342 OUT PSTRING NtSystemPathString);
1343 #endif
1344
1345 typedef struct {
1346 ULONG Version;
1347 pHalQuerySystemInformation HalQuerySystemInformation;
1348 pHalSetSystemInformation HalSetSystemInformation;
1349 pHalQueryBusSlots HalQueryBusSlots;
1350 ULONG Spare1;
1351 pHalExamineMBR HalExamineMBR;
1352 #if 1 /* Not present in WDK 7600 */
1353 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1354 #endif
1355 pHalIoReadPartitionTable HalIoReadPartitionTable;
1356 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1357 pHalIoWritePartitionTable HalIoWritePartitionTable;
1358 pHalHandlerForBus HalReferenceHandlerForBus;
1359 pHalReferenceBusHandler HalReferenceBusHandler;
1360 pHalReferenceBusHandler HalDereferenceBusHandler;
1361 pHalInitPnpDriver HalInitPnpDriver;
1362 pHalInitPowerManagement HalInitPowerManagement;
1363 pHalGetDmaAdapter HalGetDmaAdapter;
1364 pHalGetInterruptTranslator HalGetInterruptTranslator;
1365 pHalStartMirroring HalStartMirroring;
1366 pHalEndMirroring HalEndMirroring;
1367 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1368 pHalEndOfBoot HalEndOfBoot;
1369 pHalMirrorVerify HalMirrorVerify;
1370 pHalGetAcpiTable HalGetCachedAcpiTable;
1371 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
1372 #if defined(_IA64_)
1373 pHalGetErrorCapList HalGetErrorCapList;
1374 pHalInjectError HalInjectError;
1375 #endif
1376 } HAL_DISPATCH, *PHAL_DISPATCH;
1377
1378 /* GCC/MSVC and WDK compatible declaration */
1379 extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
1380
1381 #if defined(_NTOSKRNL_) || defined(_BLDR_)
1382 #define HALDISPATCH (&HalDispatchTable)
1383 #else
1384 /* This is a WDK compatibility definition */
1385 #define HalDispatchTable (&HalDispatchTable)
1386 #define HALDISPATCH HalDispatchTable
1387 #endif
1388
1389 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
1390 #define HalDispatchTableVersion HALDISPATCH->Version
1391 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1392 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1393 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1394 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1395 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1396 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1397 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1398 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1399 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1400 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1401 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1402 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1403 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1404 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1405 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1406
1407 typedef struct _FILE_ALIGNMENT_INFORMATION {
1408 ULONG AlignmentRequirement;
1409 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1410
1411 typedef struct _FILE_NAME_INFORMATION {
1412 ULONG FileNameLength;
1413 WCHAR FileName[1];
1414 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1415
1416
1417 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1418 ULONG FileAttributes;
1419 ULONG ReparseTag;
1420 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1421
1422 typedef struct _FILE_DISPOSITION_INFORMATION {
1423 BOOLEAN DeleteFile;
1424 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1425
1426 typedef struct _FILE_END_OF_FILE_INFORMATION {
1427 LARGE_INTEGER EndOfFile;
1428 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1429
1430 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1431 LARGE_INTEGER ValidDataLength;
1432 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1433
1434 typedef union _FILE_SEGMENT_ELEMENT {
1435 PVOID64 Buffer;
1436 ULONGLONG Alignment;
1437 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1438
1439 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1440 NTSYSAPI
1441 ULONGLONG
1442 NTAPI
1443 VerSetConditionMask(
1444 IN ULONGLONG ConditionMask,
1445 IN ULONG TypeMask,
1446 IN UCHAR Condition);
1447 #endif
1448
1449 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
1450 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
1451 (TypeBitMask), (ComparisonType)))
1452
1453 /* RtlVerifyVersionInfo() TypeMask */
1454
1455 #define VER_MINORVERSION 0x0000001
1456 #define VER_MAJORVERSION 0x0000002
1457 #define VER_BUILDNUMBER 0x0000004
1458 #define VER_PLATFORMID 0x0000008
1459 #define VER_SERVICEPACKMINOR 0x0000010
1460 #define VER_SERVICEPACKMAJOR 0x0000020
1461 #define VER_SUITENAME 0x0000040
1462 #define VER_PRODUCT_TYPE 0x0000080
1463
1464 /* RtlVerifyVersionInfo() ComparisonType */
1465
1466 #define VER_EQUAL 1
1467 #define VER_GREATER 2
1468 #define VER_GREATER_EQUAL 3
1469 #define VER_LESS 4
1470 #define VER_LESS_EQUAL 5
1471 #define VER_AND 6
1472 #define VER_OR 7
1473
1474 #define VER_CONDITION_MASK 7
1475 #define VER_NUM_BITS_PER_CONDITION_MASK 3
1476
1477 typedef struct _IMAGE_INFO {
1478 _ANONYMOUS_UNION union {
1479 ULONG Properties;
1480 _ANONYMOUS_STRUCT struct {
1481 ULONG ImageAddressingMode:8;
1482 ULONG SystemModeImage:1;
1483 ULONG ImageMappedToAllPids:1;
1484 ULONG ExtendedInfoPresent:1;
1485 ULONG Reserved:22;
1486 } DUMMYSTRUCTNAME;
1487 } DUMMYUNIONNAME;
1488 PVOID ImageBase;
1489 ULONG ImageSelector;
1490 SIZE_T ImageSize;
1491 ULONG ImageSectionNumber;
1492 } IMAGE_INFO, *PIMAGE_INFO;
1493
1494 #define IMAGE_ADDRESSING_MODE_32BIT 3
1495
1496 typedef enum _BUS_DATA_TYPE {
1497 ConfigurationSpaceUndefined = -1,
1498 Cmos,
1499 EisaConfiguration,
1500 Pos,
1501 CbusConfiguration,
1502 PCIConfiguration,
1503 VMEConfiguration,
1504 NuBusConfiguration,
1505 PCMCIAConfiguration,
1506 MPIConfiguration,
1507 MPSAConfiguration,
1508 PNPISAConfiguration,
1509 SgiInternalConfiguration,
1510 MaximumBusDataType
1511 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1512
1513 typedef struct _NT_TIB {
1514 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1515 PVOID StackBase;
1516 PVOID StackLimit;
1517 PVOID SubSystemTib;
1518 _ANONYMOUS_UNION union {
1519 PVOID FiberData;
1520 ULONG Version;
1521 } DUMMYUNIONNAME;
1522 PVOID ArbitraryUserPointer;
1523 struct _NT_TIB *Self;
1524 } NT_TIB, *PNT_TIB;
1525
1526 typedef struct _NT_TIB32 {
1527 ULONG ExceptionList;
1528 ULONG StackBase;
1529 ULONG StackLimit;
1530 ULONG SubSystemTib;
1531 __GNU_EXTENSION union {
1532 ULONG FiberData;
1533 ULONG Version;
1534 };
1535 ULONG ArbitraryUserPointer;
1536 ULONG Self;
1537 } NT_TIB32,*PNT_TIB32;
1538
1539 typedef struct _NT_TIB64 {
1540 ULONG64 ExceptionList;
1541 ULONG64 StackBase;
1542 ULONG64 StackLimit;
1543 ULONG64 SubSystemTib;
1544 __GNU_EXTENSION union {
1545 ULONG64 FiberData;
1546 ULONG Version;
1547 };
1548 ULONG64 ArbitraryUserPointer;
1549 ULONG64 Self;
1550 } NT_TIB64,*PNT_TIB64;
1551
1552 typedef enum _PROCESSINFOCLASS {
1553 ProcessBasicInformation,
1554 ProcessQuotaLimits,
1555 ProcessIoCounters,
1556 ProcessVmCounters,
1557 ProcessTimes,
1558 ProcessBasePriority,
1559 ProcessRaisePriority,
1560 ProcessDebugPort,
1561 ProcessExceptionPort,
1562 ProcessAccessToken,
1563 ProcessLdtInformation,
1564 ProcessLdtSize,
1565 ProcessDefaultHardErrorMode,
1566 ProcessIoPortHandlers,
1567 ProcessPooledUsageAndLimits,
1568 ProcessWorkingSetWatch,
1569 ProcessUserModeIOPL,
1570 ProcessEnableAlignmentFaultFixup,
1571 ProcessPriorityClass,
1572 ProcessWx86Information,
1573 ProcessHandleCount,
1574 ProcessAffinityMask,
1575 ProcessPriorityBoost,
1576 ProcessDeviceMap,
1577 ProcessSessionInformation,
1578 ProcessForegroundInformation,
1579 ProcessWow64Information,
1580 ProcessImageFileName,
1581 ProcessLUIDDeviceMapsEnabled,
1582 ProcessBreakOnTermination,
1583 ProcessDebugObjectHandle,
1584 ProcessDebugFlags,
1585 ProcessHandleTracing,
1586 ProcessIoPriority,
1587 ProcessExecuteFlags,
1588 ProcessTlsInformation,
1589 ProcessCookie,
1590 ProcessImageInformation,
1591 ProcessCycleTime,
1592 ProcessPagePriority,
1593 ProcessInstrumentationCallback,
1594 ProcessThreadStackAllocation,
1595 ProcessWorkingSetWatchEx,
1596 ProcessImageFileNameWin32,
1597 ProcessImageFileMapping,
1598 ProcessAffinityUpdateMode,
1599 ProcessMemoryAllocationMode,
1600 ProcessGroupInformation,
1601 ProcessTokenVirtualizationEnabled,
1602 ProcessConsoleHostProcess,
1603 ProcessWindowInformation,
1604 MaxProcessInfoClass
1605 } PROCESSINFOCLASS;
1606
1607 typedef enum _THREADINFOCLASS {
1608 ThreadBasicInformation,
1609 ThreadTimes,
1610 ThreadPriority,
1611 ThreadBasePriority,
1612 ThreadAffinityMask,
1613 ThreadImpersonationToken,
1614 ThreadDescriptorTableEntry,
1615 ThreadEnableAlignmentFaultFixup,
1616 ThreadEventPair_Reusable,
1617 ThreadQuerySetWin32StartAddress,
1618 ThreadZeroTlsCell,
1619 ThreadPerformanceCount,
1620 ThreadAmILastThread,
1621 ThreadIdealProcessor,
1622 ThreadPriorityBoost,
1623 ThreadSetTlsArrayAddress,
1624 ThreadIsIoPending,
1625 ThreadHideFromDebugger,
1626 ThreadBreakOnTermination,
1627 ThreadSwitchLegacyState,
1628 ThreadIsTerminated,
1629 ThreadLastSystemCall,
1630 ThreadIoPriority,
1631 ThreadCycleTime,
1632 ThreadPagePriority,
1633 ThreadActualBasePriority,
1634 ThreadTebInformation,
1635 ThreadCSwitchMon,
1636 ThreadCSwitchPmu,
1637 ThreadWow64Context,
1638 ThreadGroupInformation,
1639 ThreadUmsInformation,
1640 ThreadCounterProfiling,
1641 ThreadIdealProcessorEx,
1642 MaxThreadInfoClass
1643 } THREADINFOCLASS;
1644
1645 typedef struct _PROCESS_BASIC_INFORMATION {
1646 NTSTATUS ExitStatus;
1647 struct _PEB *PebBaseAddress;
1648 ULONG_PTR AffinityMask;
1649 KPRIORITY BasePriority;
1650 ULONG_PTR UniqueProcessId;
1651 ULONG_PTR InheritedFromUniqueProcessId;
1652 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1653
1654 typedef struct _PROCESS_WS_WATCH_INFORMATION {
1655 PVOID FaultingPc;
1656 PVOID FaultingVa;
1657 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1658
1659 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
1660 __GNU_EXTENSION union {
1661 struct {
1662 HANDLE DirectoryHandle;
1663 } Set;
1664 struct {
1665 ULONG DriveMap;
1666 UCHAR DriveType[32];
1667 } Query;
1668 };
1669 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1670
1671 typedef struct _KERNEL_USER_TIMES {
1672 LARGE_INTEGER CreateTime;
1673 LARGE_INTEGER ExitTime;
1674 LARGE_INTEGER KernelTime;
1675 LARGE_INTEGER UserTime;
1676 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1677
1678 typedef struct _PROCESS_ACCESS_TOKEN {
1679 HANDLE Token;
1680 HANDLE Thread;
1681 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1682
1683 typedef struct _PROCESS_SESSION_INFORMATION {
1684 ULONG SessionId;
1685 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1686
1687 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
1688 IoQueryDeviceIdentifier = 0,
1689 IoQueryDeviceConfigurationData,
1690 IoQueryDeviceComponentInformation,
1691 IoQueryDeviceMaxData
1692 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
1693
1694 typedef struct _DISK_SIGNATURE {
1695 ULONG PartitionStyle;
1696 _ANONYMOUS_UNION union {
1697 struct {
1698 ULONG Signature;
1699 ULONG CheckSum;
1700 } Mbr;
1701 struct {
1702 GUID DiskId;
1703 } Gpt;
1704 } DUMMYUNIONNAME;
1705 } DISK_SIGNATURE, *PDISK_SIGNATURE;
1706
1707 typedef ULONG_PTR
1708 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
1709 IN PVOID Context);
1710
1711 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
1712 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
1713 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
1714 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
1715
1716 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
1717 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
1718 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
1719 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
1720 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
1721
1722 typedef VOID
1723 (NTAPI *PTIMER_APC_ROUTINE)(
1724 IN PVOID TimerContext,
1725 IN ULONG TimerLowValue,
1726 IN LONG TimerHighValue);
1727
1728 typedef struct _KUSER_SHARED_DATA
1729 {
1730 ULONG TickCountLowDeprecated;
1731 ULONG TickCountMultiplier;
1732 volatile KSYSTEM_TIME InterruptTime;
1733 volatile KSYSTEM_TIME SystemTime;
1734 volatile KSYSTEM_TIME TimeZoneBias;
1735 USHORT ImageNumberLow;
1736 USHORT ImageNumberHigh;
1737 WCHAR NtSystemRoot[260];
1738 ULONG MaxStackTraceDepth;
1739 ULONG CryptoExponent;
1740 ULONG TimeZoneId;
1741 ULONG LargePageMinimum;
1742 ULONG Reserved2[7];
1743 NT_PRODUCT_TYPE NtProductType;
1744 BOOLEAN ProductTypeIsValid;
1745 ULONG NtMajorVersion;
1746 ULONG NtMinorVersion;
1747 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1748 ULONG Reserved1;
1749 ULONG Reserved3;
1750 volatile ULONG TimeSlip;
1751 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1752 ULONG AltArchitecturePad[1];
1753 LARGE_INTEGER SystemExpirationDate;
1754 ULONG SuiteMask;
1755 BOOLEAN KdDebuggerEnabled;
1756 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1757 UCHAR NXSupportPolicy;
1758 #endif
1759 volatile ULONG ActiveConsoleId;
1760 volatile ULONG DismountCount;
1761 ULONG ComPlusPackage;
1762 ULONG LastSystemRITEventTickCount;
1763 ULONG NumberOfPhysicalPages;
1764 BOOLEAN SafeBootMode;
1765 #if (NTDDI_VERSION >= NTDDI_WIN7)
1766 union {
1767 UCHAR TscQpcData;
1768 struct {
1769 UCHAR TscQpcEnabled:1;
1770 UCHAR TscQpcSpareFlag:1;
1771 UCHAR TscQpcShift:6;
1772 } DUMMYSTRUCTNAME;
1773 } DUMMYUNIONNAME;
1774 UCHAR TscQpcPad[2];
1775 #endif
1776 #if (NTDDI_VERSION >= NTDDI_VISTA)
1777 union {
1778 ULONG SharedDataFlags;
1779 struct {
1780 ULONG DbgErrorPortPresent:1;
1781 ULONG DbgElevationEnabled:1;
1782 ULONG DbgVirtEnabled:1;
1783 ULONG DbgInstallerDetectEnabled:1;
1784 ULONG DbgSystemDllRelocated:1;
1785 ULONG DbgDynProcessorEnabled:1;
1786 ULONG DbgSEHValidationEnabled:1;
1787 ULONG SpareBits:25;
1788 } DUMMYSTRUCTNAME2;
1789 } DUMMYUNIONNAME2;
1790 #else
1791 ULONG TraceLogging;
1792 #endif
1793 ULONG DataFlagsPad[1];
1794 ULONGLONG TestRetInstruction;
1795 ULONG SystemCall;
1796 ULONG SystemCallReturn;
1797 ULONGLONG SystemCallPad[3];
1798 _ANONYMOUS_UNION union {
1799 volatile KSYSTEM_TIME TickCount;
1800 volatile ULONG64 TickCountQuad;
1801 _ANONYMOUS_STRUCT struct {
1802 ULONG ReservedTickCountOverlay[3];
1803 ULONG TickCountPad[1];
1804 } DUMMYSTRUCTNAME;
1805 } DUMMYUNIONNAME3;
1806 ULONG Cookie;
1807 ULONG CookiePad[1];
1808 #if (NTDDI_VERSION >= NTDDI_WS03)
1809 LONGLONG ConsoleSessionForegroundProcessId;
1810 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
1811 #endif
1812 #if (NTDDI_VERSION >= NTDDI_VISTA)
1813 #if (NTDDI_VERSION >= NTDDI_WIN7)
1814 USHORT UserModeGlobalLogger[16];
1815 #else
1816 USHORT UserModeGlobalLogger[8];
1817 ULONG HeapTracingPid[2];
1818 ULONG CritSecTracingPid[2];
1819 #endif
1820 ULONG ImageFileExecutionOptions;
1821 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1822 ULONG LangGenerationCount;
1823 #else
1824 /* 4 bytes padding */
1825 #endif
1826 ULONGLONG Reserved5;
1827 volatile ULONG64 InterruptTimeBias;
1828 #endif
1829 #if (NTDDI_VERSION >= NTDDI_WIN7)
1830 volatile ULONG64 TscQpcBias;
1831 volatile ULONG ActiveProcessorCount;
1832 volatile USHORT ActiveGroupCount;
1833 USHORT Reserved4;
1834 volatile ULONG AitSamplingValue;
1835 volatile ULONG AppCompatFlag;
1836 ULONGLONG SystemDllNativeRelocation;
1837 ULONG SystemDllWowRelocation;
1838 ULONG XStatePad[1];
1839 XSTATE_CONFIGURATION XState;
1840 #endif
1841 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
1842
1843 extern NTKERNELAPI PVOID MmHighestUserAddress;
1844 extern NTKERNELAPI PVOID MmSystemRangeStart;
1845 extern NTKERNELAPI ULONG MmUserProbeAddress;
1846
1847
1848 #ifdef _X86_
1849
1850 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
1851 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
1852 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
1853 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
1854 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
1855 #else
1856 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
1857 #endif
1858 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
1859 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
1860 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
1861 #if !defined (_X86PAE_)
1862 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
1863 #else
1864 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
1865 #endif
1866
1867 #define KeGetPcr() PCR
1868
1869 #define PCR_MINOR_VERSION 1
1870 #define PCR_MAJOR_VERSION 1
1871
1872 typedef struct _KPCR {
1873 union {
1874 NT_TIB NtTib;
1875 struct {
1876 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
1877 PVOID Used_StackBase;
1878 PVOID Spare2;
1879 PVOID TssCopy;
1880 ULONG ContextSwitches;
1881 KAFFINITY SetMemberCopy;
1882 PVOID Used_Self;
1883 };
1884 };
1885 struct _KPCR *SelfPcr;
1886 struct _KPRCB *Prcb;
1887 KIRQL Irql;
1888 ULONG IRR;
1889 ULONG IrrActive;
1890 ULONG IDR;
1891 PVOID KdVersionBlock;
1892 struct _KIDTENTRY *IDT;
1893 struct _KGDTENTRY *GDT;
1894 struct _KTSS *TSS;
1895 USHORT MajorVersion;
1896 USHORT MinorVersion;
1897 KAFFINITY SetMember;
1898 ULONG StallScaleFactor;
1899 UCHAR SpareUnused;
1900 UCHAR Number;
1901 UCHAR Spare0;
1902 UCHAR SecondLevelCacheAssociativity;
1903 ULONG VdmAlert;
1904 ULONG KernelReserved[14];
1905 ULONG SecondLevelCacheSize;
1906 ULONG HalReserved[16];
1907 } KPCR, *PKPCR;
1908
1909 FORCEINLINE
1910 ULONG
1911 KeGetCurrentProcessorNumber(VOID)
1912 {
1913 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
1914 }
1915
1916 #endif /* _X86_ */
1917
1918 #ifdef _AMD64_
1919
1920 #define PTI_SHIFT 12L
1921 #define PDI_SHIFT 21L
1922 #define PPI_SHIFT 30L
1923 #define PXI_SHIFT 39L
1924 #define PTE_PER_PAGE 512
1925 #define PDE_PER_PAGE 512
1926 #define PPE_PER_PAGE 512
1927 #define PXE_PER_PAGE 512
1928 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
1929 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
1930 #define PPI_MASK (PPE_PER_PAGE - 1)
1931 #define PXI_MASK (PXE_PER_PAGE - 1)
1932
1933 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
1934 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
1935 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
1936 #define PDE_BASE 0xFFFFF6FB40000000ULL
1937 #define PTE_BASE 0xFFFFF68000000000ULL
1938 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
1939 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
1940 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
1941 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
1942
1943 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
1944 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
1945 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
1946 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
1947 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
1948 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
1949
1950 typedef struct _KPCR
1951 {
1952 _ANONYMOUS_UNION union
1953 {
1954 NT_TIB NtTib;
1955 _ANONYMOUS_STRUCT struct
1956 {
1957 union _KGDTENTRY64 *GdtBase;
1958 struct _KTSS64 *TssBase;
1959 ULONG64 UserRsp;
1960 struct _KPCR *Self;
1961 struct _KPRCB *CurrentPrcb;
1962 PKSPIN_LOCK_QUEUE LockArray;
1963 PVOID Used_Self;
1964 };
1965 };
1966 union _KIDTENTRY64 *IdtBase;
1967 ULONG64 Unused[2];
1968 KIRQL Irql;
1969 UCHAR SecondLevelCacheAssociativity;
1970 UCHAR ObsoleteNumber;
1971 UCHAR Fill0;
1972 ULONG Unused0[3];
1973 USHORT MajorVersion;
1974 USHORT MinorVersion;
1975 ULONG StallScaleFactor;
1976 PVOID Unused1[3];
1977 ULONG KernelReserved[15];
1978 ULONG SecondLevelCacheSize;
1979 ULONG HalReserved[16];
1980 ULONG Unused2;
1981 PVOID KdVersionBlock;
1982 PVOID Unused3;
1983 ULONG PcrAlign1[24];
1984 } KPCR, *PKPCR;
1985
1986 FORCEINLINE
1987 PKPCR
1988 KeGetPcr(VOID)
1989 {
1990 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
1991 }
1992
1993 FORCEINLINE
1994 ULONG
1995 KeGetCurrentProcessorNumber(VOID)
1996 {
1997 return (ULONG)__readgsword(0x184);
1998 }
1999
2000 #endif /* _AMD64_ */
2001
2002 typedef enum _INTERLOCKED_RESULT {
2003 ResultNegative = RESULT_NEGATIVE,
2004 ResultZero = RESULT_ZERO,
2005 ResultPositive = RESULT_POSITIVE
2006 } INTERLOCKED_RESULT;
2007
2008 typedef struct _OSVERSIONINFOA {
2009 ULONG dwOSVersionInfoSize;
2010 ULONG dwMajorVersion;
2011 ULONG dwMinorVersion;
2012 ULONG dwBuildNumber;
2013 ULONG dwPlatformId;
2014 CHAR szCSDVersion[128];
2015 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2016
2017 typedef struct _OSVERSIONINFOW {
2018 ULONG dwOSVersionInfoSize;
2019 ULONG dwMajorVersion;
2020 ULONG dwMinorVersion;
2021 ULONG dwBuildNumber;
2022 ULONG dwPlatformId;
2023 WCHAR szCSDVersion[128];
2024 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2025
2026 typedef struct _OSVERSIONINFOEXA {
2027 ULONG dwOSVersionInfoSize;
2028 ULONG dwMajorVersion;
2029 ULONG dwMinorVersion;
2030 ULONG dwBuildNumber;
2031 ULONG dwPlatformId;
2032 CHAR szCSDVersion[128];
2033 USHORT wServicePackMajor;
2034 USHORT wServicePackMinor;
2035 USHORT wSuiteMask;
2036 UCHAR wProductType;
2037 UCHAR wReserved;
2038 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2039
2040 typedef struct _OSVERSIONINFOEXW {
2041 ULONG dwOSVersionInfoSize;
2042 ULONG dwMajorVersion;
2043 ULONG dwMinorVersion;
2044 ULONG dwBuildNumber;
2045 ULONG dwPlatformId;
2046 WCHAR szCSDVersion[128];
2047 USHORT wServicePackMajor;
2048 USHORT wServicePackMinor;
2049 USHORT wSuiteMask;
2050 UCHAR wProductType;
2051 UCHAR wReserved;
2052 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2053
2054 #ifdef UNICODE
2055 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2056 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2057 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2058 typedef OSVERSIONINFOW OSVERSIONINFO;
2059 typedef POSVERSIONINFOW POSVERSIONINFO;
2060 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2061 #else
2062 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2063 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2064 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2065 typedef OSVERSIONINFOA OSVERSIONINFO;
2066 typedef POSVERSIONINFOA POSVERSIONINFO;
2067 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2068 #endif /* UNICODE */
2069
2070 /* Executive Types */
2071
2072 #define PROTECTED_POOL 0x80000000
2073
2074 typedef struct _ZONE_SEGMENT_HEADER {
2075 SINGLE_LIST_ENTRY SegmentList;
2076 PVOID Reserved;
2077 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2078
2079 typedef struct _ZONE_HEADER {
2080 SINGLE_LIST_ENTRY FreeList;
2081 SINGLE_LIST_ENTRY SegmentList;
2082 ULONG BlockSize;
2083 ULONG TotalSegmentSize;
2084 } ZONE_HEADER, *PZONE_HEADER;
2085
2086 /* Executive Functions */
2087
2088 static __inline PVOID
2089 ExAllocateFromZone(
2090 IN PZONE_HEADER Zone)
2091 {
2092 if (Zone->FreeList.Next)
2093 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2094 return (PVOID) Zone->FreeList.Next;
2095 }
2096
2097 static __inline PVOID
2098 ExFreeToZone(
2099 IN PZONE_HEADER Zone,
2100 IN PVOID Block)
2101 {
2102 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2103 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2104 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2105 }
2106
2107 /*
2108 * PVOID
2109 * ExInterlockedAllocateFromZone(
2110 * IN PZONE_HEADER Zone,
2111 * IN PKSPIN_LOCK Lock)
2112 */
2113 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2114 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2115
2116 /* PVOID
2117 * ExInterlockedFreeToZone(
2118 * IN PZONE_HEADER Zone,
2119 * IN PVOID Block,
2120 * IN PKSPIN_LOCK Lock);
2121 */
2122 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2123 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2124
2125 /*
2126 * BOOLEAN
2127 * ExIsFullZone(
2128 * IN PZONE_HEADER Zone)
2129 */
2130 #define ExIsFullZone(Zone) \
2131 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2132
2133 /* BOOLEAN
2134 * ExIsObjectInFirstZoneSegment(
2135 * IN PZONE_HEADER Zone,
2136 * IN PVOID Object);
2137 */
2138 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2139 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2140 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2141 (Zone)->TotalSegmentSize)) )
2142
2143 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2144 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2145 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2146 #define ExDeleteResource ExDeleteResourceLite
2147 #define ExInitializeResource ExInitializeResourceLite
2148 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2149 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2150 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2151 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2152
2153 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2154
2155 NTKERNELAPI
2156 NTSTATUS
2157 NTAPI
2158 ExExtendZone(
2159 IN OUT PZONE_HEADER Zone,
2160 IN OUT PVOID Segment,
2161 IN ULONG SegmentSize);
2162
2163 NTKERNELAPI
2164 NTSTATUS
2165 NTAPI
2166 ExInitializeZone(
2167 OUT PZONE_HEADER Zone,
2168 IN ULONG BlockSize,
2169 IN OUT PVOID InitialSegment,
2170 IN ULONG InitialSegmentSize);
2171
2172 NTKERNELAPI
2173 NTSTATUS
2174 NTAPI
2175 ExInterlockedExtendZone(
2176 IN OUT PZONE_HEADER Zone,
2177 IN OUT PVOID Segment,
2178 IN ULONG SegmentSize,
2179 IN OUT PKSPIN_LOCK Lock);
2180
2181 NTKERNELAPI
2182 NTSTATUS
2183 NTAPI
2184 ExUuidCreate(
2185 OUT UUID *Uuid);
2186
2187 NTKERNELAPI
2188 DECLSPEC_NORETURN
2189 VOID
2190 NTAPI
2191 ExRaiseAccessViolation(
2192 VOID);
2193
2194 NTKERNELAPI
2195 DECLSPEC_NORETURN
2196 VOID
2197 NTAPI
2198 ExRaiseDatatypeMisalignment(
2199 VOID);
2200
2201 #endif
2202
2203 #ifdef _X86_
2204
2205 NTKERNELAPI
2206 INTERLOCKED_RESULT
2207 FASTCALL
2208 Exfi386InterlockedIncrementLong(
2209 IN OUT LONG volatile *Addend);
2210
2211 NTKERNELAPI
2212 INTERLOCKED_RESULT
2213 FASTCALL
2214 Exfi386InterlockedDecrementLong(
2215 IN PLONG Addend);
2216
2217 NTKERNELAPI
2218 ULONG
2219 FASTCALL
2220 Exfi386InterlockedExchangeUlong(
2221 IN PULONG Target,
2222 IN ULONG Value);
2223
2224 #endif /* _X86_ */
2225
2226 #ifndef _ARC_DDK_
2227 #define _ARC_DDK_
2228 typedef enum _CONFIGURATION_TYPE {
2229 ArcSystem,
2230 CentralProcessor,
2231 FloatingPointProcessor,
2232 PrimaryIcache,
2233 PrimaryDcache,
2234 SecondaryIcache,
2235 SecondaryDcache,
2236 SecondaryCache,
2237 EisaAdapter,
2238 TcAdapter,
2239 ScsiAdapter,
2240 DtiAdapter,
2241 MultiFunctionAdapter,
2242 DiskController,
2243 TapeController,
2244 CdromController,
2245 WormController,
2246 SerialController,
2247 NetworkController,
2248 DisplayController,
2249 ParallelController,
2250 PointerController,
2251 KeyboardController,
2252 AudioController,
2253 OtherController,
2254 DiskPeripheral,
2255 FloppyDiskPeripheral,
2256 TapePeripheral,
2257 ModemPeripheral,
2258 MonitorPeripheral,
2259 PrinterPeripheral,
2260 PointerPeripheral,
2261 KeyboardPeripheral,
2262 TerminalPeripheral,
2263 OtherPeripheral,
2264 LinePeripheral,
2265 NetworkPeripheral,
2266 SystemMemory,
2267 DockingInformation,
2268 RealModeIrqRoutingTable,
2269 RealModePCIEnumeration,
2270 MaximumType
2271 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2272 #endif /* !_ARC_DDK_ */
2273
2274 typedef struct _CONTROLLER_OBJECT {
2275 CSHORT Type;
2276 CSHORT Size;
2277 PVOID ControllerExtension;
2278 KDEVICE_QUEUE DeviceWaitQueue;
2279 ULONG Spare1;
2280 LARGE_INTEGER Spare2;
2281 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
2282
2283 typedef struct _CONFIGURATION_INFORMATION {
2284 ULONG DiskCount;
2285 ULONG FloppyCount;
2286 ULONG CdRomCount;
2287 ULONG TapeCount;
2288 ULONG ScsiPortCount;
2289 ULONG SerialCount;
2290 ULONG ParallelCount;
2291 BOOLEAN AtDiskPrimaryAddressClaimed;
2292 BOOLEAN AtDiskSecondaryAddressClaimed;
2293 ULONG Version;
2294 ULONG MediumChangerCount;
2295 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2296
2297 typedef
2298 NTSTATUS
2299 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
2300 IN PVOID Context,
2301 IN PUNICODE_STRING PathName,
2302 IN INTERFACE_TYPE BusType,
2303 IN ULONG BusNumber,
2304 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2305 IN CONFIGURATION_TYPE ControllerType,
2306 IN ULONG ControllerNumber,
2307 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2308 IN CONFIGURATION_TYPE PeripheralType,
2309 IN ULONG PeripheralNumber,
2310 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
2311
2312 typedef
2313 VOID
2314 (NTAPI DRIVER_REINITIALIZE)(
2315 IN struct _DRIVER_OBJECT *DriverObject,
2316 IN PVOID Context,
2317 IN ULONG Count);
2318
2319 typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE;
2320
2321 /** Filesystem runtime library routines **/
2322
2323 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2324 NTKERNELAPI
2325 BOOLEAN
2326 NTAPI
2327 FsRtlIsTotalDeviceFailure(
2328 IN NTSTATUS Status);
2329 #endif
2330
2331 /* Hardware Abstraction Layer Types */
2332
2333 typedef VOID
2334 (NTAPI *PciPin2Line)(
2335 IN struct _BUS_HANDLER *BusHandler,
2336 IN struct _BUS_HANDLER *RootHandler,
2337 IN PCI_SLOT_NUMBER SlotNumber,
2338 IN PPCI_COMMON_CONFIG PciData);
2339
2340 typedef VOID
2341 (NTAPI *PciLine2Pin)(
2342 IN struct _BUS_HANDLER *BusHandler,
2343 IN struct _BUS_HANDLER *RootHandler,
2344 IN PCI_SLOT_NUMBER SlotNumber,
2345 IN PPCI_COMMON_CONFIG PciNewData,
2346 IN PPCI_COMMON_CONFIG PciOldData);
2347
2348 typedef VOID
2349 (NTAPI *PciReadWriteConfig)(
2350 IN struct _BUS_HANDLER *BusHandler,
2351 IN PCI_SLOT_NUMBER Slot,
2352 IN PVOID Buffer,
2353 IN ULONG Offset,
2354 IN ULONG Length);
2355
2356 #define PCI_DATA_TAG ' ICP'
2357 #define PCI_DATA_VERSION 1
2358
2359 typedef struct _PCIBUSDATA {
2360 ULONG Tag;
2361 ULONG Version;
2362 PciReadWriteConfig ReadConfig;
2363 PciReadWriteConfig WriteConfig;
2364 PciPin2Line Pin2Line;
2365 PciLine2Pin Line2Pin;
2366 PCI_SLOT_NUMBER ParentSlot;
2367 PVOID Reserved[4];
2368 } PCIBUSDATA, *PPCIBUSDATA;
2369
2370 /* Hardware Abstraction Layer Functions */
2371
2372 #if !defined(NO_LEGACY_DRIVERS)
2373
2374 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2375
2376 NTHALAPI
2377 NTSTATUS
2378 NTAPI
2379 HalAssignSlotResources(
2380 IN PUNICODE_STRING RegistryPath,
2381 IN PUNICODE_STRING DriverClassName,
2382 IN PDRIVER_OBJECT DriverObject,
2383 IN PDEVICE_OBJECT DeviceObject,
2384 IN INTERFACE_TYPE BusType,
2385 IN ULONG BusNumber,
2386 IN ULONG SlotNumber,
2387 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2388
2389 NTHALAPI
2390 ULONG
2391 NTAPI
2392 HalGetInterruptVector(
2393 IN INTERFACE_TYPE InterfaceType,
2394 IN ULONG BusNumber,
2395 IN ULONG BusInterruptLevel,
2396 IN ULONG BusInterruptVector,
2397 OUT PKIRQL Irql,
2398 OUT PKAFFINITY Affinity);
2399
2400 NTHALAPI
2401 ULONG
2402 NTAPI
2403 HalSetBusData(
2404 IN BUS_DATA_TYPE BusDataType,
2405 IN ULONG BusNumber,
2406 IN ULONG SlotNumber,
2407 IN PVOID Buffer,
2408 IN ULONG Length);
2409
2410 #endif
2411
2412 #endif /* !defined(NO_LEGACY_DRIVERS) */
2413
2414 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2415
2416 NTHALAPI
2417 PADAPTER_OBJECT
2418 NTAPI
2419 HalGetAdapter(
2420 IN PDEVICE_DESCRIPTION DeviceDescription,
2421 IN OUT PULONG NumberOfMapRegisters);
2422
2423 NTHALAPI
2424 BOOLEAN
2425 NTAPI
2426 HalMakeBeep(
2427 IN ULONG Frequency);
2428
2429 VOID
2430 NTAPI
2431 HalPutDmaAdapter(
2432 IN PADAPTER_OBJECT DmaAdapter);
2433
2434 NTHALAPI
2435 VOID
2436 NTAPI
2437 HalAcquireDisplayOwnership(
2438 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
2439
2440 NTHALAPI
2441 ULONG
2442 NTAPI
2443 HalGetBusData(
2444 IN BUS_DATA_TYPE BusDataType,
2445 IN ULONG BusNumber,
2446 IN ULONG SlotNumber,
2447 OUT PVOID Buffer,
2448 IN ULONG Length);
2449
2450 NTHALAPI
2451 ULONG
2452 NTAPI
2453 HalGetBusDataByOffset(
2454 IN BUS_DATA_TYPE BusDataType,
2455 IN ULONG BusNumber,
2456 IN ULONG SlotNumber,
2457 OUT PVOID Buffer,
2458 IN ULONG Offset,
2459 IN ULONG Length);
2460
2461 NTHALAPI
2462 ULONG
2463 NTAPI
2464 HalSetBusDataByOffset(
2465 IN BUS_DATA_TYPE BusDataType,
2466 IN ULONG BusNumber,
2467 IN ULONG SlotNumber,
2468 IN PVOID Buffer,
2469 IN ULONG Offset,
2470 IN ULONG Length);
2471
2472 NTHALAPI
2473 BOOLEAN
2474 NTAPI
2475 HalTranslateBusAddress(
2476 IN INTERFACE_TYPE InterfaceType,
2477 IN ULONG BusNumber,
2478 IN PHYSICAL_ADDRESS BusAddress,
2479 IN OUT PULONG AddressSpace,
2480 OUT PPHYSICAL_ADDRESS TranslatedAddress);
2481
2482 #endif
2483
2484 #if (NTDDI_VERSION >= NTDDI_WINXP)
2485 NTKERNELAPI
2486 VOID
2487 FASTCALL
2488 HalExamineMBR(
2489 IN PDEVICE_OBJECT DeviceObject,
2490 IN ULONG SectorSize,
2491 IN ULONG MBRTypeIdentifier,
2492 OUT PVOID *Buffer);
2493 #endif
2494
2495 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
2496 // nothing here
2497 #else
2498
2499 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2500 //DECLSPEC_DEPRECATED_DDK
2501 NTHALAPI
2502 VOID
2503 NTAPI
2504 IoFreeAdapterChannel(
2505 IN PADAPTER_OBJECT AdapterObject);
2506
2507 //DECLSPEC_DEPRECATED_DDK
2508 NTHALAPI
2509 BOOLEAN
2510 NTAPI
2511 IoFlushAdapterBuffers(
2512 IN PADAPTER_OBJECT AdapterObject,
2513 IN PMDL Mdl,
2514 IN PVOID MapRegisterBase,
2515 IN PVOID CurrentVa,
2516 IN ULONG Length,
2517 IN BOOLEAN WriteToDevice);
2518
2519 //DECLSPEC_DEPRECATED_DDK
2520 NTHALAPI
2521 VOID
2522 NTAPI
2523 IoFreeMapRegisters(
2524 IN PADAPTER_OBJECT AdapterObject,
2525 IN PVOID MapRegisterBase,
2526 IN ULONG NumberOfMapRegisters);
2527
2528 //DECLSPEC_DEPRECATED_DDK
2529 NTHALAPI
2530 PVOID
2531 NTAPI
2532 HalAllocateCommonBuffer(
2533 IN PADAPTER_OBJECT AdapterObject,
2534 IN ULONG Length,
2535 OUT PPHYSICAL_ADDRESS LogicalAddress,
2536 IN BOOLEAN CacheEnabled);
2537
2538 //DECLSPEC_DEPRECATED_DDK
2539 NTHALAPI
2540 VOID
2541 NTAPI
2542 HalFreeCommonBuffer(
2543 IN PADAPTER_OBJECT AdapterObject,
2544 IN ULONG Length,
2545 IN PHYSICAL_ADDRESS LogicalAddress,
2546 IN PVOID VirtualAddress,
2547 IN BOOLEAN CacheEnabled);
2548
2549 //DECLSPEC_DEPRECATED_DDK
2550 NTHALAPI
2551 ULONG
2552 NTAPI
2553 HalReadDmaCounter(
2554 IN PADAPTER_OBJECT AdapterObject);
2555
2556 NTHALAPI
2557 NTSTATUS
2558 NTAPI
2559 HalAllocateAdapterChannel(
2560 IN PADAPTER_OBJECT AdapterObject,
2561 IN PWAIT_CONTEXT_BLOCK Wcb,
2562 IN ULONG NumberOfMapRegisters,
2563 IN PDRIVER_CONTROL ExecutionRoutine);
2564
2565 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2566
2567 #endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */
2568
2569 /* I/O Manager Functions */
2570
2571 /*
2572 * VOID IoAssignArcName(
2573 * IN PUNICODE_STRING ArcName,
2574 * IN PUNICODE_STRING DeviceName);
2575 */
2576 #define IoAssignArcName(_ArcName, _DeviceName) ( \
2577 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
2578
2579 /*
2580 * VOID
2581 * IoDeassignArcName(
2582 * IN PUNICODE_STRING ArcName)
2583 */
2584 #define IoDeassignArcName IoDeleteSymbolicLink
2585
2586 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2587
2588 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
2589 NTKERNELAPI
2590 NTSTATUS
2591 NTAPI
2592 IoAllocateAdapterChannel(
2593 IN PADAPTER_OBJECT AdapterObject,
2594 IN PDEVICE_OBJECT DeviceObject,
2595 IN ULONG NumberOfMapRegisters,
2596 IN PDRIVER_CONTROL ExecutionRoutine,
2597 IN PVOID Context);
2598 #endif
2599
2600 //DECLSPEC_DEPRECATED_DDK
2601 NTHALAPI
2602 PHYSICAL_ADDRESS
2603 NTAPI
2604 IoMapTransfer(
2605 IN PADAPTER_OBJECT AdapterObject,
2606 IN PMDL Mdl,
2607 IN PVOID MapRegisterBase,
2608 IN PVOID CurrentVa,
2609 IN OUT PULONG Length,
2610 IN BOOLEAN WriteToDevice);
2611
2612 NTKERNELAPI
2613 VOID
2614 NTAPI
2615 IoAllocateController(
2616 IN PCONTROLLER_OBJECT ControllerObject,
2617 IN PDEVICE_OBJECT DeviceObject,
2618 IN PDRIVER_CONTROL ExecutionRoutine,
2619 IN PVOID Context OPTIONAL);
2620
2621 NTKERNELAPI
2622 PCONTROLLER_OBJECT
2623 NTAPI
2624 IoCreateController(
2625 IN ULONG Size);
2626
2627 NTKERNELAPI
2628 VOID
2629 NTAPI
2630 IoDeleteController(
2631 IN PCONTROLLER_OBJECT ControllerObject);
2632
2633 NTKERNELAPI
2634 VOID
2635 NTAPI
2636 IoFreeController(
2637 IN PCONTROLLER_OBJECT ControllerObject);
2638
2639 NTKERNELAPI
2640 PCONFIGURATION_INFORMATION
2641 NTAPI
2642 IoGetConfigurationInformation(
2643 VOID);
2644
2645 NTKERNELAPI
2646 PDEVICE_OBJECT
2647 NTAPI
2648 IoGetDeviceToVerify(
2649 IN PETHREAD Thread);
2650
2651 NTKERNELAPI
2652 VOID
2653 NTAPI
2654 IoCancelFileOpen(
2655 IN PDEVICE_OBJECT DeviceObject,
2656 IN PFILE_OBJECT FileObject);
2657
2658 NTKERNELAPI
2659 PGENERIC_MAPPING
2660 NTAPI
2661 IoGetFileObjectGenericMapping(
2662 VOID);
2663
2664 NTKERNELAPI
2665 PIRP
2666 NTAPI
2667 IoMakeAssociatedIrp(
2668 IN PIRP Irp,
2669 IN CCHAR StackSize);
2670
2671 NTKERNELAPI
2672 NTSTATUS
2673 NTAPI
2674 IoQueryDeviceDescription(
2675 IN PINTERFACE_TYPE BusType OPTIONAL,
2676 IN PULONG BusNumber OPTIONAL,
2677 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
2678 IN PULONG ControllerNumber OPTIONAL,
2679 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
2680 IN PULONG PeripheralNumber OPTIONAL,
2681 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
2682 IN OUT PVOID Context OPTIONAL);
2683
2684 NTKERNELAPI
2685 VOID
2686 NTAPI
2687 IoRaiseHardError(
2688 IN PIRP Irp,
2689 IN PVPB Vpb OPTIONAL,
2690 IN PDEVICE_OBJECT RealDeviceObject);
2691
2692 NTKERNELAPI
2693 BOOLEAN
2694 NTAPI
2695 IoRaiseInformationalHardError(
2696 IN NTSTATUS ErrorStatus,
2697 IN PUNICODE_STRING String OPTIONAL,
2698 IN PKTHREAD Thread OPTIONAL);
2699
2700 NTKERNELAPI
2701 VOID
2702 NTAPI
2703 IoRegisterBootDriverReinitialization(
2704 IN PDRIVER_OBJECT DriverObject,
2705 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2706 IN PVOID Context OPTIONAL);
2707
2708 NTKERNELAPI
2709 VOID
2710 NTAPI
2711 IoRegisterDriverReinitialization(
2712 IN PDRIVER_OBJECT DriverObject,
2713 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2714 IN PVOID Context OPTIONAL);
2715
2716 NTKERNELAPI
2717 NTSTATUS
2718 NTAPI
2719 IoAttachDeviceByPointer(
2720 IN PDEVICE_OBJECT SourceDevice,
2721 IN PDEVICE_OBJECT TargetDevice);
2722
2723 NTKERNELAPI
2724 NTSTATUS
2725 NTAPI
2726 IoReportDetectedDevice(
2727 IN PDRIVER_OBJECT DriverObject,
2728 IN INTERFACE_TYPE LegacyBusType,
2729 IN ULONG BusNumber,
2730 IN ULONG SlotNumber,
2731 IN PCM_RESOURCE_LIST ResourceList OPTIONAL,
2732 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
2733 IN BOOLEAN ResourceAssigned,
2734 IN OUT PDEVICE_OBJECT *DeviceObject);
2735
2736 NTKERNELAPI
2737 NTSTATUS
2738 NTAPI
2739 IoReportResourceForDetection(
2740 IN PDRIVER_OBJECT DriverObject,
2741 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2742 IN ULONG DriverListSize OPTIONAL,
2743 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2744 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2745 IN ULONG DeviceListSize OPTIONAL,
2746 OUT PBOOLEAN ConflictDetected);
2747
2748 NTKERNELAPI
2749 NTSTATUS
2750 NTAPI
2751 IoReportResourceUsage(
2752 IN PUNICODE_STRING DriverClassName OPTIONAL,
2753 IN PDRIVER_OBJECT DriverObject,
2754 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2755 IN ULONG DriverListSize OPTIONAL,
2756 IN PDEVICE_OBJECT DeviceObject,
2757 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2758 IN ULONG DeviceListSize OPTIONAL,
2759 IN BOOLEAN OverrideConflict,
2760 OUT PBOOLEAN ConflictDetected);
2761
2762 NTKERNELAPI
2763 VOID
2764 NTAPI
2765 IoSetHardErrorOrVerifyDevice(
2766 IN PIRP Irp,
2767 IN PDEVICE_OBJECT DeviceObject);
2768
2769 NTKERNELAPI
2770 NTSTATUS
2771 NTAPI
2772 IoAssignResources(
2773 IN PUNICODE_STRING RegistryPath,
2774 IN PUNICODE_STRING DriverClassName OPTIONAL,
2775 IN PDRIVER_OBJECT DriverObject,
2776 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2777 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL,
2778 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2779
2780 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2781
2782 #if (NTDDI_VERSION >= NTDDI_WINXP)
2783
2784 NTKERNELAPI
2785 NTSTATUS
2786 NTAPI
2787 IoCreateDisk(
2788 IN PDEVICE_OBJECT DeviceObject,
2789 IN struct _CREATE_DISK* Disk OPTIONAL);
2790
2791 NTKERNELAPI
2792 NTSTATUS
2793 NTAPI
2794 IoReadDiskSignature(
2795 IN PDEVICE_OBJECT DeviceObject,
2796 IN ULONG BytesPerSector,
2797 OUT PDISK_SIGNATURE Signature);
2798
2799 NTKERNELAPI
2800 NTSTATUS
2801 FASTCALL
2802 IoReadPartitionTable(
2803 IN PDEVICE_OBJECT DeviceObject,
2804 IN ULONG SectorSize,
2805 IN BOOLEAN ReturnRecognizedPartitions,
2806 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2807
2808 NTKERNELAPI
2809 NTSTATUS
2810 NTAPI
2811 IoReadPartitionTableEx(
2812 IN PDEVICE_OBJECT DeviceObject,
2813 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
2814
2815 NTKERNELAPI
2816 NTSTATUS
2817 FASTCALL
2818 IoSetPartitionInformation(
2819 IN PDEVICE_OBJECT DeviceObject,
2820 IN ULONG SectorSize,
2821 IN ULONG PartitionNumber,
2822 IN ULONG PartitionType);
2823
2824 NTKERNELAPI
2825 NTSTATUS
2826 NTAPI
2827 IoSetPartitionInformationEx(
2828 IN PDEVICE_OBJECT DeviceObject,
2829 IN ULONG PartitionNumber,
2830 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
2831
2832 NTKERNELAPI
2833 NTSTATUS
2834 NTAPI
2835 IoSetSystemPartition(
2836 IN PUNICODE_STRING VolumeNameString);
2837
2838 NTKERNELAPI
2839 BOOLEAN
2840 NTAPI
2841 IoSetThreadHardErrorMode(
2842 IN BOOLEAN EnableHardErrors);
2843
2844 NTKERNELAPI
2845 NTSTATUS
2846 NTAPI
2847 IoVerifyPartitionTable(
2848 IN PDEVICE_OBJECT DeviceObject,
2849 IN BOOLEAN FixErrors);
2850
2851 NTKERNELAPI
2852 NTSTATUS
2853 NTAPI
2854 IoVolumeDeviceToDosName(
2855 IN PVOID VolumeDeviceObject,
2856 OUT PUNICODE_STRING DosName);
2857
2858 NTKERNELAPI
2859 NTSTATUS
2860 FASTCALL
2861 IoWritePartitionTable(
2862 IN PDEVICE_OBJECT DeviceObject,
2863 IN ULONG SectorSize,
2864 IN ULONG SectorsPerTrack,
2865 IN ULONG NumberOfHeads,
2866 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2867
2868 NTKERNELAPI
2869 NTSTATUS
2870 NTAPI
2871 IoWritePartitionTableEx(
2872 IN PDEVICE_OBJECT DeviceObject,
2873 IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
2874
2875 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2876
2877 /** Kernel debugger routines **/
2878
2879 NTSYSAPI
2880 ULONG
2881 NTAPI
2882 DbgPrompt(
2883 IN PCCH Prompt,
2884 OUT PCH Response,
2885 IN ULONG MaximumResponseLength);
2886
2887 /* Kernel Functions */
2888
2889 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2890
2891 NTKERNELAPI
2892 DECLSPEC_NORETURN
2893 VOID
2894 NTAPI
2895 KeBugCheck(
2896 IN ULONG BugCheckCode);
2897
2898 NTKERNELAPI
2899 LONG
2900 NTAPI
2901 KePulseEvent(
2902 IN OUT PRKEVENT Event,
2903 IN KPRIORITY Increment,
2904 IN BOOLEAN Wait);
2905
2906 NTKERNELAPI
2907 LONG
2908 NTAPI
2909 KeSetBasePriorityThread(
2910 IN OUT PRKTHREAD Thread,
2911 IN LONG Increment);
2912
2913 #endif
2914
2915 /* Memory Manager Types */
2916
2917 typedef struct _PHYSICAL_MEMORY_RANGE {
2918 PHYSICAL_ADDRESS BaseAddress;
2919 LARGE_INTEGER NumberOfBytes;
2920 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
2921
2922 /* Memory Manager Functions */
2923
2924 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2925
2926 NTKERNELAPI
2927 PPHYSICAL_MEMORY_RANGE
2928 NTAPI
2929 MmGetPhysicalMemoryRanges(
2930 VOID);
2931
2932 NTKERNELAPI
2933 PHYSICAL_ADDRESS
2934 NTAPI
2935 MmGetPhysicalAddress(
2936 IN PVOID BaseAddress);
2937
2938 NTKERNELAPI
2939 BOOLEAN
2940 NTAPI
2941 MmIsNonPagedSystemAddressValid(
2942 IN PVOID VirtualAddress);
2943
2944 NTKERNELAPI
2945 PVOID
2946 NTAPI
2947 MmAllocateNonCachedMemory(
2948 IN SIZE_T NumberOfBytes);
2949
2950 NTKERNELAPI
2951 VOID
2952 NTAPI
2953 MmFreeNonCachedMemory(
2954 IN PVOID BaseAddress,
2955 IN SIZE_T NumberOfBytes);
2956
2957 NTKERNELAPI
2958 PVOID
2959 NTAPI
2960 MmGetVirtualForPhysical(
2961 IN PHYSICAL_ADDRESS PhysicalAddress);
2962
2963 NTKERNELAPI
2964 NTSTATUS
2965 NTAPI
2966 MmMapUserAddressesToPage(
2967 IN PVOID BaseAddress,
2968 IN SIZE_T NumberOfBytes,
2969 IN PVOID PageAddress);
2970
2971 NTKERNELAPI
2972 PVOID
2973 NTAPI
2974 MmMapVideoDisplay(
2975 IN PHYSICAL_ADDRESS PhysicalAddress,
2976 IN SIZE_T NumberOfBytes,
2977 IN MEMORY_CACHING_TYPE CacheType);
2978
2979 NTKERNELAPI
2980 NTSTATUS
2981 NTAPI
2982 MmMapViewInSessionSpace(
2983 IN PVOID Section,
2984 OUT PVOID *MappedBase,
2985 IN OUT PSIZE_T ViewSize);
2986
2987 NTKERNELAPI
2988 NTSTATUS
2989 NTAPI
2990 MmMapViewInSystemSpace(
2991 IN PVOID Section,
2992 OUT PVOID *MappedBase,
2993 IN OUT PSIZE_T ViewSize);
2994
2995 NTKERNELAPI
2996 BOOLEAN
2997 NTAPI
2998 MmIsAddressValid(
2999 IN PVOID VirtualAddress);
3000
3001 NTKERNELAPI
3002 BOOLEAN
3003 NTAPI
3004 MmIsThisAnNtAsSystem(
3005 VOID);
3006
3007 NTKERNELAPI
3008 VOID
3009 NTAPI
3010 MmLockPagableSectionByHandle(
3011 IN PVOID ImageSectionHandle);
3012
3013 NTKERNELAPI
3014 NTSTATUS
3015 NTAPI
3016 MmUnmapViewInSessionSpace(
3017 IN PVOID MappedBase);
3018
3019 NTKERNELAPI
3020 NTSTATUS
3021 NTAPI
3022 MmUnmapViewInSystemSpace(
3023 IN PVOID MappedBase);
3024
3025 NTKERNELAPI
3026 VOID
3027 NTAPI
3028 MmUnsecureVirtualMemory(
3029 IN HANDLE SecureHandle);
3030
3031 NTKERNELAPI
3032 NTSTATUS
3033 NTAPI
3034 MmRemovePhysicalMemory(
3035 IN PPHYSICAL_ADDRESS StartAddress,
3036 IN OUT PLARGE_INTEGER NumberOfBytes);
3037
3038 NTKERNELAPI
3039 HANDLE
3040 NTAPI
3041 MmSecureVirtualMemory(
3042 IN PVOID Address,
3043 IN SIZE_T Size,
3044 IN ULONG ProbeMode);
3045
3046 NTKERNELAPI
3047 VOID
3048 NTAPI
3049 MmUnmapVideoDisplay(
3050 IN PVOID BaseAddress,
3051 IN SIZE_T NumberOfBytes);
3052
3053 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3054
3055 /* NtXxx Functions */
3056
3057 NTSYSCALLAPI
3058 NTSTATUS
3059 NTAPI
3060 NtOpenProcess(
3061 OUT PHANDLE ProcessHandle,
3062 IN ACCESS_MASK DesiredAccess,
3063 IN POBJECT_ATTRIBUTES ObjectAttributes,
3064 IN PCLIENT_ID ClientId OPTIONAL);
3065
3066 NTSYSCALLAPI
3067 NTSTATUS
3068 NTAPI
3069 NtQueryInformationProcess(
3070 IN HANDLE ProcessHandle,
3071 IN PROCESSINFOCLASS ProcessInformationClass,
3072 OUT PVOID ProcessInformation OPTIONAL,
3073 IN ULONG ProcessInformationLength,
3074 OUT PULONG ReturnLength OPTIONAL);
3075
3076 /** Process manager types **/
3077
3078 typedef VOID
3079 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
3080 IN HANDLE ParentId,
3081 IN HANDLE ProcessId,
3082 IN BOOLEAN Create);
3083
3084 typedef VOID
3085 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
3086 IN HANDLE ProcessId,
3087 IN HANDLE ThreadId,
3088 IN BOOLEAN Create);
3089
3090 typedef VOID
3091 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
3092 IN PUNICODE_STRING FullImageName,
3093 IN HANDLE ProcessId,
3094 IN PIMAGE_INFO ImageInfo);
3095
3096 /** Process manager routines **/
3097
3098 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3099
3100 NTKERNELAPI
3101 NTSTATUS
3102 NTAPI
3103 PsSetLoadImageNotifyRoutine(
3104 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3105
3106 NTKERNELAPI
3107 NTSTATUS
3108 NTAPI
3109 PsSetCreateThreadNotifyRoutine(
3110 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3111
3112 NTKERNELAPI
3113 NTSTATUS
3114 NTAPI
3115 PsSetCreateProcessNotifyRoutine(
3116 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3117 IN BOOLEAN Remove);
3118
3119 NTKERNELAPI
3120 HANDLE
3121 NTAPI
3122 PsGetCurrentProcessId(
3123 VOID);
3124
3125 NTKERNELAPI
3126 HANDLE
3127 NTAPI
3128 PsGetCurrentThreadId(
3129 VOID);
3130
3131 NTKERNELAPI
3132 BOOLEAN
3133 NTAPI
3134 PsGetVersion(
3135 OUT PULONG MajorVersion OPTIONAL,
3136 OUT PULONG MinorVersion OPTIONAL,
3137 OUT PULONG BuildNumber OPTIONAL,
3138 OUT PUNICODE_STRING CSDVersion OPTIONAL);
3139
3140 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3141
3142 #if (NTDDI_VERSION >= NTDDI_WINXP)
3143
3144 NTKERNELAPI
3145 HANDLE
3146 NTAPI
3147 PsGetProcessId(
3148 IN PEPROCESS Process);
3149
3150 NTKERNELAPI
3151 NTSTATUS
3152 NTAPI
3153 PsRemoveCreateThreadNotifyRoutine(
3154 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3155
3156 NTKERNELAPI
3157 NTSTATUS
3158 NTAPI
3159 PsRemoveLoadImageNotifyRoutine(
3160 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3161
3162 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3163
3164 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
3165
3166 /* RTL Functions */
3167
3168 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3169
3170 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3171 *CallersAddress = (PVOID)_ReturnAddress(); \
3172 *CallersCaller = NULL;
3173 #else
3174
3175 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3176 NTSYSAPI
3177 VOID
3178 NTAPI
3179 RtlGetCallersAddress(
3180 OUT PVOID *CallersAddress,
3181 OUT PVOID *CallersCaller);
3182 #endif
3183
3184 #endif
3185
3186 #if !defined(MIDL_PASS)
3187
3188 FORCEINLINE
3189 LUID
3190 NTAPI_INLINE
3191 RtlConvertLongToLuid(
3192 IN LONG Val)
3193 {
3194 LUID Luid;
3195 LARGE_INTEGER Temp;
3196
3197 Temp.QuadPart = Val;
3198 Luid.LowPart = Temp.u.LowPart;
3199 Luid.HighPart = Temp.u.HighPart;
3200 return Luid;
3201 }
3202
3203 FORCEINLINE
3204 LUID
3205 NTAPI_INLINE
3206 RtlConvertUlongToLuid(
3207 IN ULONG Val)
3208 {
3209 LUID Luid;
3210
3211 Luid.LowPart = Val;
3212 Luid.HighPart = 0;
3213 return Luid;
3214 }
3215
3216 #endif
3217
3218 #if defined(_AMD64_) || defined(_IA64_)
3219 //DECLSPEC_DEPRECATED_DDK_WINXP
3220 __inline
3221 LARGE_INTEGER
3222 NTAPI_INLINE
3223 RtlLargeIntegerDivide(
3224 IN LARGE_INTEGER Dividend,
3225 IN LARGE_INTEGER Divisor,
3226 OUT PLARGE_INTEGER Remainder OPTIONAL)
3227 {
3228 LARGE_INTEGER ret;
3229 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
3230 if (Remainder)
3231 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
3232 return ret;
3233 }
3234
3235 #else
3236
3237 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3238 NTSYSAPI
3239 LARGE_INTEGER
3240 NTAPI
3241 RtlLargeIntegerDivide(
3242 IN LARGE_INTEGER Dividend,
3243 IN LARGE_INTEGER Divisor,
3244 OUT PLARGE_INTEGER Remainder OPTIONAL);
3245 #endif
3246
3247 #endif /* defined(_AMD64_) || defined(_IA64_) */
3248
3249 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3250
3251 NTSYSAPI
3252 BOOLEAN
3253 NTAPI
3254 RtlPrefixUnicodeString(
3255 IN PCUNICODE_STRING String1,
3256 IN PCUNICODE_STRING String2,
3257 IN BOOLEAN CaseInSensitive);
3258
3259 NTSYSAPI
3260 VOID
3261 NTAPI
3262 RtlUpperString(
3263 IN OUT PSTRING DestinationString,
3264 IN const PSTRING SourceString);
3265
3266 NTSYSAPI
3267 NTSTATUS
3268 NTAPI
3269 RtlUpcaseUnicodeString(
3270 IN OUT PUNICODE_STRING DestinationString,
3271 IN PCUNICODE_STRING SourceString,
3272 IN BOOLEAN AllocateDestinationString);
3273
3274 NTSYSAPI
3275 VOID
3276 NTAPI
3277 RtlMapGenericMask(
3278 IN OUT PACCESS_MASK AccessMask,
3279 IN PGENERIC_MAPPING GenericMapping);
3280
3281 NTSYSAPI
3282 NTSTATUS
3283 NTAPI
3284 RtlVolumeDeviceToDosName(
3285 IN PVOID VolumeDeviceObject,
3286 OUT PUNICODE_STRING DosName);
3287
3288 NTSYSAPI
3289 NTSTATUS
3290 NTAPI
3291 RtlGetVersion(
3292 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
3293
3294 NTSYSAPI
3295 NTSTATUS
3296 NTAPI
3297 RtlVerifyVersionInfo(
3298 IN PRTL_OSVERSIONINFOEXW VersionInfo,
3299 IN ULONG TypeMask,
3300 IN ULONGLONG ConditionMask);
3301
3302 NTSYSAPI
3303 LONG
3304 NTAPI
3305 RtlCompareString(
3306 IN const PSTRING String1,
3307 IN const PSTRING String2,
3308 BOOLEAN CaseInSensitive);
3309
3310 NTSYSAPI
3311 VOID
3312 NTAPI
3313 RtlCopyString(
3314 OUT PSTRING DestinationString,
3315 IN const PSTRING SourceString OPTIONAL);
3316
3317 NTSYSAPI
3318 BOOLEAN
3319 NTAPI
3320 RtlEqualString(
3321 IN const PSTRING String1,
3322 IN const PSTRING String2,
3323 IN BOOLEAN CaseInSensitive);
3324
3325 NTSYSAPI
3326 NTSTATUS
3327 NTAPI
3328 RtlCharToInteger(
3329 IN PCSZ String,
3330 IN ULONG Base OPTIONAL,
3331 OUT PULONG Value);
3332
3333 NTSYSAPI
3334 CHAR
3335 NTAPI
3336 RtlUpperChar(
3337 IN CHAR Character);
3338
3339 NTSYSAPI
3340 ULONG
3341 NTAPI
3342 RtlWalkFrameChain(
3343 OUT PVOID *Callers,
3344 IN ULONG Count,
3345 IN ULONG Flags);
3346
3347 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3348
3349 /* Security reference monitor routines */
3350
3351 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3352 NTKERNELAPI
3353 BOOLEAN
3354 NTAPI
3355 SeSinglePrivilegeCheck(
3356 IN LUID PrivilegeValue,
3357 IN KPROCESSOR_MODE PreviousMode);
3358 #endif
3359
3360 /* ZwXxx Functions */
3361
3362 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3363
3364 NTSTATUS
3365 NTAPI
3366 ZwCancelTimer(
3367 IN HANDLE TimerHandle,
3368 OUT PBOOLEAN CurrentState OPTIONAL);
3369
3370 NTSTATUS
3371 NTAPI
3372 ZwCreateTimer(
3373 OUT PHANDLE TimerHandle,
3374 IN ACCESS_MASK DesiredAccess,
3375 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3376 IN TIMER_TYPE TimerType);
3377
3378 NTSTATUS
3379 NTAPI
3380 ZwOpenTimer(
3381 OUT PHANDLE TimerHandle,
3382 IN ACCESS_MASK DesiredAccess,
3383 IN POBJECT_ATTRIBUTES ObjectAttributes);
3384
3385 NTSYSAPI
3386 NTSTATUS
3387 NTAPI
3388 ZwSetInformationThread(
3389 IN HANDLE ThreadHandle,
3390 IN THREADINFOCLASS ThreadInformationClass,
3391 IN PVOID ThreadInformation,
3392 IN ULONG ThreadInformationLength);
3393
3394 NTSTATUS
3395 NTAPI
3396 ZwSetTimer(
3397 IN HANDLE TimerHandle,
3398 IN PLARGE_INTEGER DueTime,
3399 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3400 IN PVOID TimerContext OPTIONAL,
3401 IN BOOLEAN ResumeTimer,
3402 IN LONG Period OPTIONAL,
3403 OUT PBOOLEAN PreviousState OPTIONAL);
3404
3405 #endif
3406
3407 NTSYSAPI
3408 NTSTATUS
3409 NTAPI
3410 ZwDisplayString (
3411 IN PUNICODE_STRING String
3412 );
3413
3414 #if (VER_PRODUCTBUILD >= 2195)
3415
3416 NTSYSAPI
3417 NTSTATUS
3418 NTAPI
3419 ZwPowerInformation (
3420 IN POWER_INFORMATION_LEVEL PowerInformationLevel,
3421 IN PVOID InputBuffer OPTIONAL,
3422 IN ULONG InputBufferLength,
3423 OUT PVOID OutputBuffer OPTIONAL,
3424 IN ULONG OutputBufferLength
3425 );
3426
3427 #endif /* (VER_PRODUCTBUILD >= 2195) */
3428
3429 NTSYSAPI
3430 NTSTATUS
3431 NTAPI
3432 ZwTerminateProcess (
3433 IN HANDLE ProcessHandle OPTIONAL,
3434 IN NTSTATUS ExitStatus
3435 );
3436
3437 NTSYSAPI
3438 NTSTATUS
3439 NTAPI
3440 ZwOpenProcess (
3441 OUT PHANDLE ProcessHandle,
3442 IN ACCESS_MASK DesiredAccess,
3443 IN POBJECT_ATTRIBUTES ObjectAttributes,
3444 IN PCLIENT_ID ClientId OPTIONAL
3445 );
3446
3447 NTSYSAPI
3448 NTSTATUS
3449 NTAPI
3450 ZwQueryVolumeInformationFile(
3451 IN HANDLE FileHandle,
3452 OUT PIO_STATUS_BLOCK IoStatusBlock,
3453 OUT PVOID FsInformation,
3454 IN ULONG Length,
3455 IN FS_INFORMATION_CLASS FsInformationClass);
3456
3457 NTSYSAPI
3458 NTSTATUS
3459 NTAPI
3460 ZwDeviceIoControlFile(
3461 IN HANDLE FileHandle,
3462 IN HANDLE Event OPTIONAL,
3463 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
3464 IN PVOID ApcContext OPTIONAL,
3465 OUT PIO_STATUS_BLOCK IoStatusBlock,
3466 IN ULONG IoControlCode,
3467 IN PVOID InputBuffer OPTIONAL,
3468 IN ULONG InputBufferLength,
3469 OUT PVOID OutputBuffer OPTIONAL,
3470 IN ULONG OutputBufferLength);
3471
3472 #ifdef __cplusplus
3473 }
3474 #endif