5e0252db114da635aed35c9479a9ad17d907c488
[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 typedef struct _NT_TIB {
1531 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1532 PVOID StackBase;
1533 PVOID StackLimit;
1534 PVOID SubSystemTib;
1535 _ANONYMOUS_UNION union {
1536 PVOID FiberData;
1537 ULONG Version;
1538 } DUMMYUNIONNAME;
1539 PVOID ArbitraryUserPointer;
1540 struct _NT_TIB *Self;
1541 } NT_TIB, *PNT_TIB;
1542
1543 typedef struct _NT_TIB32 {
1544 ULONG ExceptionList;
1545 ULONG StackBase;
1546 ULONG StackLimit;
1547 ULONG SubSystemTib;
1548 __GNU_EXTENSION union {
1549 ULONG FiberData;
1550 ULONG Version;
1551 };
1552 ULONG ArbitraryUserPointer;
1553 ULONG Self;
1554 } NT_TIB32,*PNT_TIB32;
1555
1556 typedef struct _NT_TIB64 {
1557 ULONG64 ExceptionList;
1558 ULONG64 StackBase;
1559 ULONG64 StackLimit;
1560 ULONG64 SubSystemTib;
1561 __GNU_EXTENSION union {
1562 ULONG64 FiberData;
1563 ULONG Version;
1564 };
1565 ULONG64 ArbitraryUserPointer;
1566 ULONG64 Self;
1567 } NT_TIB64,*PNT_TIB64;
1568
1569 typedef enum _PROCESSINFOCLASS {
1570 ProcessBasicInformation,
1571 ProcessQuotaLimits,
1572 ProcessIoCounters,
1573 ProcessVmCounters,
1574 ProcessTimes,
1575 ProcessBasePriority,
1576 ProcessRaisePriority,
1577 ProcessDebugPort,
1578 ProcessExceptionPort,
1579 ProcessAccessToken,
1580 ProcessLdtInformation,
1581 ProcessLdtSize,
1582 ProcessDefaultHardErrorMode,
1583 ProcessIoPortHandlers,
1584 ProcessPooledUsageAndLimits,
1585 ProcessWorkingSetWatch,
1586 ProcessUserModeIOPL,
1587 ProcessEnableAlignmentFaultFixup,
1588 ProcessPriorityClass,
1589 ProcessWx86Information,
1590 ProcessHandleCount,
1591 ProcessAffinityMask,
1592 ProcessPriorityBoost,
1593 ProcessDeviceMap,
1594 ProcessSessionInformation,
1595 ProcessForegroundInformation,
1596 ProcessWow64Information,
1597 ProcessImageFileName,
1598 ProcessLUIDDeviceMapsEnabled,
1599 ProcessBreakOnTermination,
1600 ProcessDebugObjectHandle,
1601 ProcessDebugFlags,
1602 ProcessHandleTracing,
1603 ProcessIoPriority,
1604 ProcessExecuteFlags,
1605 ProcessTlsInformation,
1606 ProcessCookie,
1607 ProcessImageInformation,
1608 ProcessCycleTime,
1609 ProcessPagePriority,
1610 ProcessInstrumentationCallback,
1611 ProcessThreadStackAllocation,
1612 ProcessWorkingSetWatchEx,
1613 ProcessImageFileNameWin32,
1614 ProcessImageFileMapping,
1615 ProcessAffinityUpdateMode,
1616 ProcessMemoryAllocationMode,
1617 ProcessGroupInformation,
1618 ProcessTokenVirtualizationEnabled,
1619 ProcessConsoleHostProcess,
1620 ProcessWindowInformation,
1621 MaxProcessInfoClass
1622 } PROCESSINFOCLASS;
1623
1624 typedef enum _THREADINFOCLASS {
1625 ThreadBasicInformation,
1626 ThreadTimes,
1627 ThreadPriority,
1628 ThreadBasePriority,
1629 ThreadAffinityMask,
1630 ThreadImpersonationToken,
1631 ThreadDescriptorTableEntry,
1632 ThreadEnableAlignmentFaultFixup,
1633 ThreadEventPair_Reusable,
1634 ThreadQuerySetWin32StartAddress,
1635 ThreadZeroTlsCell,
1636 ThreadPerformanceCount,
1637 ThreadAmILastThread,
1638 ThreadIdealProcessor,
1639 ThreadPriorityBoost,
1640 ThreadSetTlsArrayAddress,
1641 ThreadIsIoPending,
1642 ThreadHideFromDebugger,
1643 ThreadBreakOnTermination,
1644 ThreadSwitchLegacyState,
1645 ThreadIsTerminated,
1646 ThreadLastSystemCall,
1647 ThreadIoPriority,
1648 ThreadCycleTime,
1649 ThreadPagePriority,
1650 ThreadActualBasePriority,
1651 ThreadTebInformation,
1652 ThreadCSwitchMon,
1653 ThreadCSwitchPmu,
1654 ThreadWow64Context,
1655 ThreadGroupInformation,
1656 ThreadUmsInformation,
1657 ThreadCounterProfiling,
1658 ThreadIdealProcessorEx,
1659 MaxThreadInfoClass
1660 } THREADINFOCLASS;
1661
1662 #define THREAD_CSWITCH_PMU_DISABLE FALSE
1663 #define THREAD_CSWITCH_PMU_ENABLE TRUE
1664
1665 struct _LOADER_PARAMETER_BLOCK;
1666 struct _CREATE_DISK;
1667 struct _DRIVE_LAYOUT_INFORMATION_EX;
1668 struct _SET_PARTITION_INFORMATION_EX;
1669
1670 //
1671 // GUID and UUID
1672 //
1673 #ifndef GUID_DEFINED
1674 #include <guiddef.h>
1675 #endif
1676 typedef GUID UUID;
1677
1678 #define MAX_WOW64_SHARED_ENTRIES 16
1679
1680 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1681 #define NX_SUPPORT_POLICY_ALWAYSON 1
1682 #define NX_SUPPORT_POLICY_OPTIN 2
1683 #define NX_SUPPORT_POLICY_OPTOUT 3
1684
1685 /*
1686 ** IRP function codes
1687 */
1688
1689 #define IRP_MN_QUERY_DIRECTORY 0x01
1690 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
1691
1692 #define IRP_MN_USER_FS_REQUEST 0x00
1693 #define IRP_MN_MOUNT_VOLUME 0x01
1694 #define IRP_MN_VERIFY_VOLUME 0x02
1695 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
1696 #define IRP_MN_TRACK_LINK 0x04
1697 #define IRP_MN_KERNEL_CALL 0x04
1698
1699 #define IRP_MN_LOCK 0x01
1700 #define IRP_MN_UNLOCK_SINGLE 0x02
1701 #define IRP_MN_UNLOCK_ALL 0x03
1702 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
1703
1704 #define IRP_MN_FLUSH_AND_PURGE 0x01
1705
1706 #define IRP_MN_NORMAL 0x00
1707 #define IRP_MN_DPC 0x01
1708 #define IRP_MN_MDL 0x02
1709 #define IRP_MN_COMPLETE 0x04
1710 #define IRP_MN_COMPRESSED 0x08
1711
1712 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
1713 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
1714 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
1715
1716 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
1717
1718 typedef struct _IO_COUNTERS {
1719 ULONGLONG ReadOperationCount;
1720 ULONGLONG WriteOperationCount;
1721 ULONGLONG OtherOperationCount;
1722 ULONGLONG ReadTransferCount;
1723 ULONGLONG WriteTransferCount;
1724 ULONGLONG OtherTransferCount;
1725 } IO_COUNTERS, *PIO_COUNTERS;
1726
1727 typedef struct _VM_COUNTERS {
1728 SIZE_T PeakVirtualSize;
1729 SIZE_T VirtualSize;
1730 ULONG PageFaultCount;
1731 SIZE_T PeakWorkingSetSize;
1732 SIZE_T WorkingSetSize;
1733 SIZE_T QuotaPeakPagedPoolUsage;
1734 SIZE_T QuotaPagedPoolUsage;
1735 SIZE_T QuotaPeakNonPagedPoolUsage;
1736 SIZE_T QuotaNonPagedPoolUsage;
1737 SIZE_T PagefileUsage;
1738 SIZE_T PeakPagefileUsage;
1739 } VM_COUNTERS, *PVM_COUNTERS;
1740
1741 typedef struct _VM_COUNTERS_EX
1742 {
1743 SIZE_T PeakVirtualSize;
1744 SIZE_T VirtualSize;
1745 ULONG PageFaultCount;
1746 SIZE_T PeakWorkingSetSize;
1747 SIZE_T WorkingSetSize;
1748 SIZE_T QuotaPeakPagedPoolUsage;
1749 SIZE_T QuotaPagedPoolUsage;
1750 SIZE_T QuotaPeakNonPagedPoolUsage;
1751 SIZE_T QuotaNonPagedPoolUsage;
1752 SIZE_T PagefileUsage;
1753 SIZE_T PeakPagefileUsage;
1754 SIZE_T PrivateUsage;
1755 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
1756
1757 typedef struct _POOLED_USAGE_AND_LIMITS
1758 {
1759 SIZE_T PeakPagedPoolUsage;
1760 SIZE_T PagedPoolUsage;
1761 SIZE_T PagedPoolLimit;
1762 SIZE_T PeakNonPagedPoolUsage;
1763 SIZE_T NonPagedPoolUsage;
1764 SIZE_T NonPagedPoolLimit;
1765 SIZE_T PeakPagefileUsage;
1766 SIZE_T PagefileUsage;
1767 SIZE_T PagefileLimit;
1768 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
1769
1770 /* DEVICE_OBJECT.Flags */
1771
1772 #define DO_DEVICE_HAS_NAME 0x00000040
1773 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
1774 #define DO_LONG_TERM_REQUESTS 0x00000200
1775 #define DO_NEVER_LAST_DEVICE 0x00000400
1776 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
1777 #define DO_SUPPORTS_TRANSACTIONS 0x00040000
1778 #define DO_FORCE_NEITHER_IO 0x00080000
1779 #define DO_VOLUME_DEVICE_OBJECT 0x00100000
1780 #define DO_SYSTEM_SYSTEM_PARTITION 0x00200000
1781 #define DO_SYSTEM_CRITICAL_PARTITION 0x00400000
1782 #define DO_DISALLOW_EXECUTE 0x00800000
1783
1784 #define DRVO_REINIT_REGISTERED 0x00000008
1785 #define DRVO_INITIALIZED 0x00000010
1786 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
1787 #define DRVO_LEGACY_RESOURCES 0x00000040
1788
1789 typedef enum _ARBITER_REQUEST_SOURCE {
1790 ArbiterRequestUndefined = -1,
1791 ArbiterRequestLegacyReported,
1792 ArbiterRequestHalReported,
1793 ArbiterRequestLegacyAssigned,
1794 ArbiterRequestPnpDetected,
1795 ArbiterRequestPnpEnumerated
1796 } ARBITER_REQUEST_SOURCE;
1797
1798 typedef enum _ARBITER_RESULT {
1799 ArbiterResultUndefined = -1,
1800 ArbiterResultSuccess,
1801 ArbiterResultExternalConflict,
1802 ArbiterResultNullRequest
1803 } ARBITER_RESULT;
1804
1805 typedef enum _ARBITER_ACTION {
1806 ArbiterActionTestAllocation,
1807 ArbiterActionRetestAllocation,
1808 ArbiterActionCommitAllocation,
1809 ArbiterActionRollbackAllocation,
1810 ArbiterActionQueryAllocatedResources,
1811 ArbiterActionWriteReservedResources,
1812 ArbiterActionQueryConflict,
1813 ArbiterActionQueryArbitrate,
1814 ArbiterActionAddReserved,
1815 ArbiterActionBootAllocation
1816 } ARBITER_ACTION, *PARBITER_ACTION;
1817
1818 typedef struct _ARBITER_CONFLICT_INFO {
1819 PDEVICE_OBJECT OwningObject;
1820 ULONGLONG Start;
1821 ULONGLONG End;
1822 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
1823
1824 typedef struct _ARBITER_PARAMETERS {
1825 union {
1826 struct {
1827 IN OUT PLIST_ENTRY ArbitrationList;
1828 IN ULONG AllocateFromCount;
1829 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
1830 } TestAllocation;
1831 struct {
1832 IN OUT PLIST_ENTRY ArbitrationList;
1833 IN ULONG AllocateFromCount;
1834 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
1835 } RetestAllocation;
1836 struct {
1837 IN OUT PLIST_ENTRY ArbitrationList;
1838 } BootAllocation;
1839 struct {
1840 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
1841 } QueryAllocatedResources;
1842 struct {
1843 IN PDEVICE_OBJECT PhysicalDeviceObject;
1844 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
1845 OUT PULONG ConflictCount;
1846 OUT PARBITER_CONFLICT_INFO *Conflicts;
1847 } QueryConflict;
1848 struct {
1849 IN PLIST_ENTRY ArbitrationList;
1850 } QueryArbitrate;
1851 struct {
1852 IN PDEVICE_OBJECT ReserveDevice;
1853 } AddReserved;
1854 } Parameters;
1855 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
1856
1857 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
1858
1859 typedef struct _ARBITER_LIST_ENTRY {
1860 LIST_ENTRY ListEntry;
1861 ULONG AlternativeCount;
1862 PIO_RESOURCE_DESCRIPTOR Alternatives;
1863 PDEVICE_OBJECT PhysicalDeviceObject;
1864 ARBITER_REQUEST_SOURCE RequestSource;
1865 ULONG Flags;
1866 LONG_PTR WorkSpace;
1867 INTERFACE_TYPE InterfaceType;
1868 ULONG SlotNumber;
1869 ULONG BusNumber;
1870 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
1871 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
1872 ARBITER_RESULT Result;
1873 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
1874
1875 typedef NTSTATUS
1876 (NTAPI *PARBITER_HANDLER)(
1877 IN OUT PVOID Context,
1878 IN ARBITER_ACTION Action,
1879 IN OUT PARBITER_PARAMETERS Parameters);
1880
1881 #define ARBITER_PARTIAL 0x00000001
1882
1883 typedef struct _ARBITER_INTERFACE {
1884 USHORT Size;
1885 USHORT Version;
1886 PVOID Context;
1887 PINTERFACE_REFERENCE InterfaceReference;
1888 PINTERFACE_DEREFERENCE InterfaceDereference;
1889 PARBITER_HANDLER ArbiterHandler;
1890 ULONG Flags;
1891 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
1892
1893 typedef enum _HAL_QUERY_INFORMATION_CLASS {
1894 HalInstalledBusInformation,
1895 HalProfileSourceInformation,
1896 HalInformationClassUnused1,
1897 HalPowerInformation,
1898 HalProcessorSpeedInformation,
1899 HalCallbackInformation,
1900 HalMapRegisterInformation,
1901 HalMcaLogInformation,
1902 HalFrameBufferCachingInformation,
1903 HalDisplayBiosInformation,
1904 HalProcessorFeatureInformation,
1905 HalNumaTopologyInterface,
1906 HalErrorInformation,
1907 HalCmcLogInformation,
1908 HalCpeLogInformation,
1909 HalQueryMcaInterface,
1910 HalQueryAMLIIllegalIOPortAddresses,
1911 HalQueryMaxHotPlugMemoryAddress,
1912 HalPartitionIpiInterface,
1913 HalPlatformInformation,
1914 HalQueryProfileSourceList,
1915 HalInitLogInformation,
1916 HalFrequencyInformation,
1917 HalProcessorBrandString,
1918 HalHypervisorInformation,
1919 HalPlatformTimerInformation,
1920 HalAcpiAuditInformation
1921 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
1922
1923 typedef enum _HAL_SET_INFORMATION_CLASS {
1924 HalProfileSourceInterval,
1925 HalProfileSourceInterruptHandler,
1926 HalMcaRegisterDriver,
1927 HalKernelErrorHandler,
1928 HalCmcRegisterDriver,
1929 HalCpeRegisterDriver,
1930 HalMcaLog,
1931 HalCmcLog,
1932 HalCpeLog,
1933 HalGenerateCmcInterrupt,
1934 HalProfileSourceTimerHandler,
1935 HalEnlightenment,
1936 HalProfileDpgoSourceInterruptHandler
1937 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
1938
1939 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
1940 KPROFILE_SOURCE Source;
1941 ULONG_PTR Interval;
1942 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
1943
1944 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
1945 KPROFILE_SOURCE Source;
1946 BOOLEAN Supported;
1947 ULONG Interval;
1948 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
1949
1950 typedef struct _MAP_REGISTER_ENTRY {
1951 PVOID MapRegister;
1952 BOOLEAN WriteToDevice;
1953 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
1954
1955 typedef struct _DEBUG_DEVICE_ADDRESS {
1956 UCHAR Type;
1957 BOOLEAN Valid;
1958 UCHAR Reserved[2];
1959 PUCHAR TranslatedAddress;
1960 ULONG Length;
1961 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
1962
1963 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
1964 PHYSICAL_ADDRESS Start;
1965 PHYSICAL_ADDRESS MaxEnd;
1966 PVOID VirtualAddress;
1967 ULONG Length;
1968 BOOLEAN Cached;
1969 BOOLEAN Aligned;
1970 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
1971
1972 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
1973 ULONG Bus;
1974 ULONG Slot;
1975 USHORT Segment;
1976 USHORT VendorID;
1977 USHORT DeviceID;
1978 UCHAR BaseClass;
1979 UCHAR SubClass;
1980 UCHAR ProgIf;
1981 BOOLEAN Initialized;
1982 BOOLEAN Configured;
1983 DEBUG_DEVICE_ADDRESS BaseAddress[6];
1984 DEBUG_MEMORY_REQUIREMENTS Memory;
1985 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
1986
1987 typedef struct _PM_DISPATCH_TABLE {
1988 ULONG Signature;
1989 ULONG Version;
1990 PVOID Function[1];
1991 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
1992
1993 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
1994 TranslateChildToParent,
1995 TranslateParentToChild
1996 } RESOURCE_TRANSLATION_DIRECTION;
1997
1998 typedef NTSTATUS
1999 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
2000 IN OUT PVOID Context,
2001 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
2002 IN RESOURCE_TRANSLATION_DIRECTION Direction,
2003 IN ULONG AlternativesCount OPTIONAL,
2004 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
2005 IN PDEVICE_OBJECT PhysicalDeviceObject,
2006 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
2007
2008 typedef NTSTATUS
2009 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
2010 IN PVOID Context OPTIONAL,
2011 IN PIO_RESOURCE_DESCRIPTOR Source,
2012 IN PDEVICE_OBJECT PhysicalDeviceObject,
2013 OUT PULONG TargetCount,
2014 OUT PIO_RESOURCE_DESCRIPTOR *Target);
2015
2016 typedef struct _TRANSLATOR_INTERFACE {
2017 USHORT Size;
2018 USHORT Version;
2019 PVOID Context;
2020 PINTERFACE_REFERENCE InterfaceReference;
2021 PINTERFACE_DEREFERENCE InterfaceDereference;
2022 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
2023 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
2024 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
2025
2026 typedef VOID
2027 (FASTCALL *pHalExamineMBR)(
2028 IN PDEVICE_OBJECT DeviceObject,
2029 IN ULONG SectorSize,
2030 IN ULONG MBRTypeIdentifier,
2031 OUT PVOID *Buffer);
2032
2033 typedef NTSTATUS
2034 (FASTCALL *pHalIoReadPartitionTable)(
2035 IN PDEVICE_OBJECT DeviceObject,
2036 IN ULONG SectorSize,
2037 IN BOOLEAN ReturnRecognizedPartitions,
2038 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2039
2040 typedef NTSTATUS
2041 (FASTCALL *pHalIoSetPartitionInformation)(
2042 IN PDEVICE_OBJECT DeviceObject,
2043 IN ULONG SectorSize,
2044 IN ULONG PartitionNumber,
2045 IN ULONG PartitionType);
2046
2047 typedef NTSTATUS
2048 (FASTCALL *pHalIoWritePartitionTable)(
2049 IN PDEVICE_OBJECT DeviceObject,
2050 IN ULONG SectorSize,
2051 IN ULONG SectorsPerTrack,
2052 IN ULONG NumberOfHeads,
2053 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2054
2055 typedef PBUS_HANDLER
2056 (FASTCALL *pHalHandlerForBus)(
2057 IN INTERFACE_TYPE InterfaceType,
2058 IN ULONG BusNumber);
2059
2060 typedef VOID
2061 (FASTCALL *pHalReferenceBusHandler)(
2062 IN PBUS_HANDLER BusHandler);
2063
2064 typedef NTSTATUS
2065 (NTAPI *pHalQuerySystemInformation)(
2066 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
2067 IN ULONG BufferSize,
2068 IN OUT PVOID Buffer,
2069 OUT PULONG ReturnedLength);
2070
2071 typedef NTSTATUS
2072 (NTAPI *pHalSetSystemInformation)(
2073 IN HAL_SET_INFORMATION_CLASS InformationClass,
2074 IN ULONG BufferSize,
2075 IN PVOID Buffer);
2076
2077 typedef NTSTATUS
2078 (NTAPI *pHalQueryBusSlots)(
2079 IN PBUS_HANDLER BusHandler,
2080 IN ULONG BufferSize,
2081 OUT PULONG SlotNumbers,
2082 OUT PULONG ReturnedLength);
2083
2084 typedef NTSTATUS
2085 (NTAPI *pHalInitPnpDriver)(
2086 VOID);
2087
2088 typedef NTSTATUS
2089 (NTAPI *pHalInitPowerManagement)(
2090 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
2091 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
2092
2093 typedef struct _DMA_ADAPTER*
2094 (NTAPI *pHalGetDmaAdapter)(
2095 IN PVOID Context,
2096 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
2097 OUT PULONG NumberOfMapRegisters);
2098
2099 typedef NTSTATUS
2100 (NTAPI *pHalGetInterruptTranslator)(
2101 IN INTERFACE_TYPE ParentInterfaceType,
2102 IN ULONG ParentBusNumber,
2103 IN INTERFACE_TYPE BridgeInterfaceType,
2104 IN USHORT Size,
2105 IN USHORT Version,
2106 OUT PTRANSLATOR_INTERFACE Translator,
2107 OUT PULONG BridgeBusNumber);
2108
2109 typedef NTSTATUS
2110 (NTAPI *pHalStartMirroring)(
2111 VOID);
2112
2113 typedef NTSTATUS
2114 (NTAPI *pHalEndMirroring)(
2115 IN ULONG PassNumber);
2116
2117 typedef NTSTATUS
2118 (NTAPI *pHalMirrorPhysicalMemory)(
2119 IN PHYSICAL_ADDRESS PhysicalAddress,
2120 IN LARGE_INTEGER NumberOfBytes);
2121
2122 typedef NTSTATUS
2123 (NTAPI *pHalMirrorVerify)(
2124 IN PHYSICAL_ADDRESS PhysicalAddress,
2125 IN LARGE_INTEGER NumberOfBytes);
2126
2127 typedef VOID
2128 (NTAPI *pHalEndOfBoot)(
2129 VOID);
2130
2131 typedef
2132 BOOLEAN
2133 (NTAPI *pHalTranslateBusAddress)(
2134 IN INTERFACE_TYPE InterfaceType,
2135 IN ULONG BusNumber,
2136 IN PHYSICAL_ADDRESS BusAddress,
2137 IN OUT PULONG AddressSpace,
2138 OUT PPHYSICAL_ADDRESS TranslatedAddress);
2139
2140 typedef
2141 NTSTATUS
2142 (NTAPI *pHalAssignSlotResources)(
2143 IN PUNICODE_STRING RegistryPath,
2144 IN PUNICODE_STRING DriverClassName OPTIONAL,
2145 IN PDRIVER_OBJECT DriverObject,
2146 IN PDEVICE_OBJECT DeviceObject,
2147 IN INTERFACE_TYPE BusType,
2148 IN ULONG BusNumber,
2149 IN ULONG SlotNumber,
2150 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2151
2152 typedef
2153 VOID
2154 (NTAPI *pHalHaltSystem)(
2155 VOID);
2156
2157 typedef
2158 BOOLEAN
2159 (NTAPI *pHalResetDisplay)(
2160 VOID);
2161
2162 typedef
2163 UCHAR
2164 (NTAPI *pHalVectorToIDTEntry)(
2165 ULONG Vector);
2166
2167 typedef
2168 BOOLEAN
2169 (NTAPI *pHalFindBusAddressTranslation)(
2170 IN PHYSICAL_ADDRESS BusAddress,
2171 IN OUT PULONG AddressSpace,
2172 OUT PPHYSICAL_ADDRESS TranslatedAddress,
2173 IN OUT PULONG_PTR Context,
2174 IN BOOLEAN NextBus);
2175
2176 typedef
2177 NTSTATUS
2178 (NTAPI *pKdSetupPciDeviceForDebugging)(
2179 IN PVOID LoaderBlock OPTIONAL,
2180 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2181
2182 typedef
2183 NTSTATUS
2184 (NTAPI *pKdReleasePciDeviceForDebugging)(
2185 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2186
2187 typedef
2188 PVOID
2189 (NTAPI *pKdGetAcpiTablePhase0)(
2190 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2191 IN ULONG Signature);
2192
2193 typedef
2194 PVOID
2195 (NTAPI *pHalGetAcpiTable)(
2196 IN ULONG Signature,
2197 IN PCSTR OemId OPTIONAL,
2198 IN PCSTR OemTableId OPTIONAL);
2199
2200 typedef
2201 VOID
2202 (NTAPI *pKdCheckPowerButton)(
2203 VOID);
2204
2205 #if (NTDDI_VERSION >= NTDDI_VISTA)
2206 typedef
2207 PVOID
2208 (NTAPI *pKdMapPhysicalMemory64)(
2209 IN PHYSICAL_ADDRESS PhysicalAddress,
2210 IN ULONG NumberPages,
2211 IN BOOLEAN FlushCurrentTLB);
2212
2213 typedef
2214 VOID
2215 (NTAPI *pKdUnmapVirtualAddress)(
2216 IN PVOID VirtualAddress,
2217 IN ULONG NumberPages,
2218 IN BOOLEAN FlushCurrentTLB);
2219 #else
2220 typedef
2221 PVOID
2222 (NTAPI *pKdMapPhysicalMemory64)(
2223 IN PHYSICAL_ADDRESS PhysicalAddress,
2224 IN ULONG NumberPages);
2225
2226 typedef
2227 VOID
2228 (NTAPI *pKdUnmapVirtualAddress)(
2229 IN PVOID VirtualAddress,
2230 IN ULONG NumberPages);
2231 #endif
2232
2233
2234 typedef
2235 ULONG
2236 (NTAPI *pKdGetPciDataByOffset)(
2237 IN ULONG BusNumber,
2238 IN ULONG SlotNumber,
2239 OUT PVOID Buffer,
2240 IN ULONG Offset,
2241 IN ULONG Length);
2242
2243 typedef
2244 ULONG
2245 (NTAPI *pKdSetPciDataByOffset)(
2246 IN ULONG BusNumber,
2247 IN ULONG SlotNumber,
2248 IN PVOID Buffer,
2249 IN ULONG Offset,
2250 IN ULONG Length);
2251
2252 typedef BOOLEAN
2253 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
2254 IN ULONG Columns,
2255 IN ULONG Rows);
2256
2257 typedef
2258 VOID
2259 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
2260 VOID);
2261
2262 typedef
2263 VOID
2264 (NTAPI *pHalSetPciErrorHandlerCallback)(
2265 IN PCI_ERROR_HANDLER_CALLBACK Callback);
2266
2267 #if 1 /* Not present in WDK 7600 */
2268 typedef VOID
2269 (FASTCALL *pHalIoAssignDriveLetters)(
2270 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2271 IN PSTRING NtDeviceName,
2272 OUT PUCHAR NtSystemPath,
2273 OUT PSTRING NtSystemPathString);
2274 #endif
2275
2276 typedef struct {
2277 ULONG Version;
2278 pHalQuerySystemInformation HalQuerySystemInformation;
2279 pHalSetSystemInformation HalSetSystemInformation;
2280 pHalQueryBusSlots HalQueryBusSlots;
2281 ULONG Spare1;
2282 pHalExamineMBR HalExamineMBR;
2283 #if 1 /* Not present in WDK 7600 */
2284 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
2285 #endif
2286 pHalIoReadPartitionTable HalIoReadPartitionTable;
2287 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
2288 pHalIoWritePartitionTable HalIoWritePartitionTable;
2289 pHalHandlerForBus HalReferenceHandlerForBus;
2290 pHalReferenceBusHandler HalReferenceBusHandler;
2291 pHalReferenceBusHandler HalDereferenceBusHandler;
2292 pHalInitPnpDriver HalInitPnpDriver;
2293 pHalInitPowerManagement HalInitPowerManagement;
2294 pHalGetDmaAdapter HalGetDmaAdapter;
2295 pHalGetInterruptTranslator HalGetInterruptTranslator;
2296 pHalStartMirroring HalStartMirroring;
2297 pHalEndMirroring HalEndMirroring;
2298 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
2299 pHalEndOfBoot HalEndOfBoot;
2300 pHalMirrorVerify HalMirrorVerify;
2301 pHalGetAcpiTable HalGetCachedAcpiTable;
2302 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
2303 #if defined(_IA64_)
2304 pHalGetErrorCapList HalGetErrorCapList;
2305 pHalInjectError HalInjectError;
2306 #endif
2307 } HAL_DISPATCH, *PHAL_DISPATCH;
2308
2309 /* GCC/MSVC and WDK compatible declaration */
2310 extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
2311
2312 #if defined(_NTOSKRNL_) || defined(_BLDR_)
2313 #define HALDISPATCH (&HalDispatchTable)
2314 #else
2315 /* This is a WDK compatibility definition */
2316 #define HalDispatchTable (&HalDispatchTable)
2317 #define HALDISPATCH HalDispatchTable
2318 #endif
2319
2320 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
2321 #define HalDispatchTableVersion HALDISPATCH->Version
2322 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
2323 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
2324 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
2325 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
2326 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
2327 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
2328 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
2329 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
2330 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
2331 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
2332 #define HalStartMirroring HALDISPATCH->HalStartMirroring
2333 #define HalEndMirroring HALDISPATCH->HalEndMirroring
2334 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
2335 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
2336 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
2337
2338 typedef struct _IMAGE_INFO {
2339 _ANONYMOUS_UNION union {
2340 ULONG Properties;
2341 _ANONYMOUS_STRUCT struct {
2342 ULONG ImageAddressingMode:8;
2343 ULONG SystemModeImage:1;
2344 ULONG ImageMappedToAllPids:1;
2345 ULONG ExtendedInfoPresent:1;
2346 ULONG Reserved:22;
2347 } DUMMYSTRUCTNAME;
2348 } DUMMYUNIONNAME;
2349 PVOID ImageBase;
2350 ULONG ImageSelector;
2351 SIZE_T ImageSize;
2352 ULONG ImageSectionNumber;
2353 } IMAGE_INFO, *PIMAGE_INFO;
2354
2355 #define IMAGE_ADDRESSING_MODE_32BIT 3
2356
2357 typedef struct _PROCESS_BASIC_INFORMATION {
2358 NTSTATUS ExitStatus;
2359 struct _PEB *PebBaseAddress;
2360 ULONG_PTR AffinityMask;
2361 KPRIORITY BasePriority;
2362 ULONG_PTR UniqueProcessId;
2363 ULONG_PTR InheritedFromUniqueProcessId;
2364 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
2365
2366 typedef struct _PROCESS_WS_WATCH_INFORMATION {
2367 PVOID FaultingPc;
2368 PVOID FaultingVa;
2369 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
2370
2371 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
2372 __GNU_EXTENSION union {
2373 struct {
2374 HANDLE DirectoryHandle;
2375 } Set;
2376 struct {
2377 ULONG DriveMap;
2378 UCHAR DriveType[32];
2379 } Query;
2380 };
2381 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
2382
2383 typedef struct _KERNEL_USER_TIMES {
2384 LARGE_INTEGER CreateTime;
2385 LARGE_INTEGER ExitTime;
2386 LARGE_INTEGER KernelTime;
2387 LARGE_INTEGER UserTime;
2388 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
2389
2390 typedef struct _PROCESS_ACCESS_TOKEN {
2391 HANDLE Token;
2392 HANDLE Thread;
2393 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
2394
2395 typedef struct _PROCESS_SESSION_INFORMATION {
2396 ULONG SessionId;
2397 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
2398
2399 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
2400 IoQueryDeviceIdentifier = 0,
2401 IoQueryDeviceConfigurationData,
2402 IoQueryDeviceComponentInformation,
2403 IoQueryDeviceMaxData
2404 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
2405
2406 typedef struct _DISK_SIGNATURE {
2407 ULONG PartitionStyle;
2408 _ANONYMOUS_UNION union {
2409 struct {
2410 ULONG Signature;
2411 ULONG CheckSum;
2412 } Mbr;
2413 struct {
2414 GUID DiskId;
2415 } Gpt;
2416 } DUMMYUNIONNAME;
2417 } DISK_SIGNATURE, *PDISK_SIGNATURE;
2418
2419 typedef ULONG_PTR
2420 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
2421 IN PVOID Context);
2422
2423 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
2424 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
2425 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
2426 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
2427
2428 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
2429 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
2430 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
2431 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
2432 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
2433
2434 typedef VOID
2435 (NTAPI *PTIMER_APC_ROUTINE)(
2436 IN PVOID TimerContext,
2437 IN ULONG TimerLowValue,
2438 IN LONG TimerHighValue);
2439
2440 typedef struct _KUSER_SHARED_DATA
2441 {
2442 ULONG TickCountLowDeprecated;
2443 ULONG TickCountMultiplier;
2444 volatile KSYSTEM_TIME InterruptTime;
2445 volatile KSYSTEM_TIME SystemTime;
2446 volatile KSYSTEM_TIME TimeZoneBias;
2447 USHORT ImageNumberLow;
2448 USHORT ImageNumberHigh;
2449 WCHAR NtSystemRoot[260];
2450 ULONG MaxStackTraceDepth;
2451 ULONG CryptoExponent;
2452 ULONG TimeZoneId;
2453 ULONG LargePageMinimum;
2454 ULONG Reserved2[7];
2455 NT_PRODUCT_TYPE NtProductType;
2456 BOOLEAN ProductTypeIsValid;
2457 ULONG NtMajorVersion;
2458 ULONG NtMinorVersion;
2459 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
2460 ULONG Reserved1;
2461 ULONG Reserved3;
2462 volatile ULONG TimeSlip;
2463 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
2464 ULONG AltArchitecturePad[1];
2465 LARGE_INTEGER SystemExpirationDate;
2466 ULONG SuiteMask;
2467 BOOLEAN KdDebuggerEnabled;
2468 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
2469 UCHAR NXSupportPolicy;
2470 #endif
2471 volatile ULONG ActiveConsoleId;
2472 volatile ULONG DismountCount;
2473 ULONG ComPlusPackage;
2474 ULONG LastSystemRITEventTickCount;
2475 ULONG NumberOfPhysicalPages;
2476 BOOLEAN SafeBootMode;
2477 #if (NTDDI_VERSION >= NTDDI_WIN7)
2478 union {
2479 UCHAR TscQpcData;
2480 struct {
2481 UCHAR TscQpcEnabled:1;
2482 UCHAR TscQpcSpareFlag:1;
2483 UCHAR TscQpcShift:6;
2484 } DUMMYSTRUCTNAME;
2485 } DUMMYUNIONNAME;
2486 UCHAR TscQpcPad[2];
2487 #endif
2488 #if (NTDDI_VERSION >= NTDDI_VISTA)
2489 union {
2490 ULONG SharedDataFlags;
2491 struct {
2492 ULONG DbgErrorPortPresent:1;
2493 ULONG DbgElevationEnabled:1;
2494 ULONG DbgVirtEnabled:1;
2495 ULONG DbgInstallerDetectEnabled:1;
2496 ULONG DbgSystemDllRelocated:1;
2497 ULONG DbgDynProcessorEnabled:1;
2498 ULONG DbgSEHValidationEnabled:1;
2499 ULONG SpareBits:25;
2500 } DUMMYSTRUCTNAME2;
2501 } DUMMYUNIONNAME2;
2502 #else
2503 ULONG TraceLogging;
2504 #endif
2505 ULONG DataFlagsPad[1];
2506 ULONGLONG TestRetInstruction;
2507 ULONG SystemCall;
2508 ULONG SystemCallReturn;
2509 ULONGLONG SystemCallPad[3];
2510 _ANONYMOUS_UNION union {
2511 volatile KSYSTEM_TIME TickCount;
2512 volatile ULONG64 TickCountQuad;
2513 _ANONYMOUS_STRUCT struct {
2514 ULONG ReservedTickCountOverlay[3];
2515 ULONG TickCountPad[1];
2516 } DUMMYSTRUCTNAME;
2517 } DUMMYUNIONNAME3;
2518 ULONG Cookie;
2519 ULONG CookiePad[1];
2520 #if (NTDDI_VERSION >= NTDDI_WS03)
2521 LONGLONG ConsoleSessionForegroundProcessId;
2522 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
2523 #endif
2524 #if (NTDDI_VERSION >= NTDDI_VISTA)
2525 #if (NTDDI_VERSION >= NTDDI_WIN7)
2526 USHORT UserModeGlobalLogger[16];
2527 #else
2528 USHORT UserModeGlobalLogger[8];
2529 ULONG HeapTracingPid[2];
2530 ULONG CritSecTracingPid[2];
2531 #endif
2532 ULONG ImageFileExecutionOptions;
2533 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
2534 ULONG LangGenerationCount;
2535 #else
2536 /* 4 bytes padding */
2537 #endif
2538 ULONGLONG Reserved5;
2539 volatile ULONG64 InterruptTimeBias;
2540 #endif
2541 #if (NTDDI_VERSION >= NTDDI_WIN7)
2542 volatile ULONG64 TscQpcBias;
2543 volatile ULONG ActiveProcessorCount;
2544 volatile USHORT ActiveGroupCount;
2545 USHORT Reserved4;
2546 volatile ULONG AitSamplingValue;
2547 volatile ULONG AppCompatFlag;
2548 ULONGLONG SystemDllNativeRelocation;
2549 ULONG SystemDllWowRelocation;
2550 ULONG XStatePad[1];
2551 XSTATE_CONFIGURATION XState;
2552 #endif
2553 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
2554
2555 extern NTKERNELAPI PVOID MmHighestUserAddress;
2556 extern NTKERNELAPI PVOID MmSystemRangeStart;
2557 extern NTKERNELAPI ULONG MmUserProbeAddress;
2558
2559
2560 #ifdef _X86_
2561
2562 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2563 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2564 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
2565 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
2566 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
2567 #else
2568 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2569 #endif
2570 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2571 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
2572 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
2573 #if !defined (_X86PAE_)
2574 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
2575 #else
2576 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
2577 #endif
2578
2579 #define KeGetPcr() PCR
2580
2581 #define PCR_MINOR_VERSION 1
2582 #define PCR_MAJOR_VERSION 1
2583
2584 typedef struct _KPCR {
2585 union {
2586 NT_TIB NtTib;
2587 struct {
2588 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
2589 PVOID Used_StackBase;
2590 PVOID Spare2;
2591 PVOID TssCopy;
2592 ULONG ContextSwitches;
2593 KAFFINITY SetMemberCopy;
2594 PVOID Used_Self;
2595 };
2596 };
2597 struct _KPCR *SelfPcr;
2598 struct _KPRCB *Prcb;
2599 KIRQL Irql;
2600 ULONG IRR;
2601 ULONG IrrActive;
2602 ULONG IDR;
2603 PVOID KdVersionBlock;
2604 struct _KIDTENTRY *IDT;
2605 struct _KGDTENTRY *GDT;
2606 struct _KTSS *TSS;
2607 USHORT MajorVersion;
2608 USHORT MinorVersion;
2609 KAFFINITY SetMember;
2610 ULONG StallScaleFactor;
2611 UCHAR SpareUnused;
2612 UCHAR Number;
2613 UCHAR Spare0;
2614 UCHAR SecondLevelCacheAssociativity;
2615 ULONG VdmAlert;
2616 ULONG KernelReserved[14];
2617 ULONG SecondLevelCacheSize;
2618 ULONG HalReserved[16];
2619 } KPCR, *PKPCR;
2620
2621 FORCEINLINE
2622 ULONG
2623 KeGetCurrentProcessorNumber(VOID)
2624 {
2625 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
2626 }
2627
2628 #endif /* _X86_ */
2629
2630 #ifdef _AMD64_
2631
2632 #define PTI_SHIFT 12L
2633 #define PDI_SHIFT 21L
2634 #define PPI_SHIFT 30L
2635 #define PXI_SHIFT 39L
2636 #define PTE_PER_PAGE 512
2637 #define PDE_PER_PAGE 512
2638 #define PPE_PER_PAGE 512
2639 #define PXE_PER_PAGE 512
2640 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
2641 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
2642 #define PPI_MASK (PPE_PER_PAGE - 1)
2643 #define PXI_MASK (PXE_PER_PAGE - 1)
2644
2645 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
2646 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
2647 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
2648 #define PDE_BASE 0xFFFFF6FB40000000ULL
2649 #define PTE_BASE 0xFFFFF68000000000ULL
2650 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
2651 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
2652 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
2653 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
2654
2655 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2656 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2657 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2658 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2659 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
2660 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
2661
2662 typedef struct _KPCR
2663 {
2664 _ANONYMOUS_UNION union
2665 {
2666 NT_TIB NtTib;
2667 _ANONYMOUS_STRUCT struct
2668 {
2669 union _KGDTENTRY64 *GdtBase;
2670 struct _KTSS64 *TssBase;
2671 ULONG64 UserRsp;
2672 struct _KPCR *Self;
2673 struct _KPRCB *CurrentPrcb;
2674 PKSPIN_LOCK_QUEUE LockArray;
2675 PVOID Used_Self;
2676 };
2677 };
2678 union _KIDTENTRY64 *IdtBase;
2679 ULONG64 Unused[2];
2680 KIRQL Irql;
2681 UCHAR SecondLevelCacheAssociativity;
2682 UCHAR ObsoleteNumber;
2683 UCHAR Fill0;
2684 ULONG Unused0[3];
2685 USHORT MajorVersion;
2686 USHORT MinorVersion;
2687 ULONG StallScaleFactor;
2688 PVOID Unused1[3];
2689 ULONG KernelReserved[15];
2690 ULONG SecondLevelCacheSize;
2691 ULONG HalReserved[16];
2692 ULONG Unused2;
2693 PVOID KdVersionBlock;
2694 PVOID Unused3;
2695 ULONG PcrAlign1[24];
2696 } KPCR, *PKPCR;
2697
2698 FORCEINLINE
2699 PKPCR
2700 KeGetPcr(VOID)
2701 {
2702 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
2703 }
2704
2705 FORCEINLINE
2706 ULONG
2707 KeGetCurrentProcessorNumber(VOID)
2708 {
2709 return (ULONG)__readgsword(0x184);
2710 }
2711
2712 #endif /* _AMD64_ */
2713
2714 typedef enum _INTERLOCKED_RESULT {
2715 ResultNegative = RESULT_NEGATIVE,
2716 ResultZero = RESULT_ZERO,
2717 ResultPositive = RESULT_POSITIVE
2718 } INTERLOCKED_RESULT;
2719
2720 /* Executive Types */
2721
2722 #define PROTECTED_POOL 0x80000000
2723
2724 typedef struct _ZONE_SEGMENT_HEADER {
2725 SINGLE_LIST_ENTRY SegmentList;
2726 PVOID Reserved;
2727 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2728
2729 typedef struct _ZONE_HEADER {
2730 SINGLE_LIST_ENTRY FreeList;
2731 SINGLE_LIST_ENTRY SegmentList;
2732 ULONG BlockSize;
2733 ULONG TotalSegmentSize;
2734 } ZONE_HEADER, *PZONE_HEADER;
2735
2736 /* Executive Functions */
2737
2738 static __inline PVOID
2739 ExAllocateFromZone(
2740 IN PZONE_HEADER Zone)
2741 {
2742 if (Zone->FreeList.Next)
2743 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2744 return (PVOID) Zone->FreeList.Next;
2745 }
2746
2747 static __inline PVOID
2748 ExFreeToZone(
2749 IN PZONE_HEADER Zone,
2750 IN PVOID Block)
2751 {
2752 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2753 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2754 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2755 }
2756
2757 /*
2758 * PVOID
2759 * ExInterlockedAllocateFromZone(
2760 * IN PZONE_HEADER Zone,
2761 * IN PKSPIN_LOCK Lock)
2762 */
2763 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2764 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2765
2766 /* PVOID
2767 * ExInterlockedFreeToZone(
2768 * IN PZONE_HEADER Zone,
2769 * IN PVOID Block,
2770 * IN PKSPIN_LOCK Lock);
2771 */
2772 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2773 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2774
2775 /*
2776 * BOOLEAN
2777 * ExIsFullZone(
2778 * IN PZONE_HEADER Zone)
2779 */
2780 #define ExIsFullZone(Zone) \
2781 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2782
2783 /* BOOLEAN
2784 * ExIsObjectInFirstZoneSegment(
2785 * IN PZONE_HEADER Zone,
2786 * IN PVOID Object);
2787 */
2788 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2789 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2790 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2791 (Zone)->TotalSegmentSize)) )
2792
2793 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2794 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2795 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2796 #define ExDeleteResource ExDeleteResourceLite
2797 #define ExInitializeResource ExInitializeResourceLite
2798 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2799 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2800 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2801 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2802
2803 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2804
2805 NTKERNELAPI
2806 NTSTATUS
2807 NTAPI
2808 ExExtendZone(
2809 IN OUT PZONE_HEADER Zone,
2810 IN OUT PVOID Segment,
2811 IN ULONG SegmentSize);
2812
2813 NTKERNELAPI
2814 NTSTATUS
2815 NTAPI
2816 ExInitializeZone(
2817 OUT PZONE_HEADER Zone,
2818 IN ULONG BlockSize,
2819 IN OUT PVOID InitialSegment,
2820 IN ULONG InitialSegmentSize);
2821
2822 NTKERNELAPI
2823 NTSTATUS
2824 NTAPI
2825 ExInterlockedExtendZone(
2826 IN OUT PZONE_HEADER Zone,
2827 IN OUT PVOID Segment,
2828 IN ULONG SegmentSize,
2829 IN OUT PKSPIN_LOCK Lock);
2830
2831 NTKERNELAPI
2832 NTSTATUS
2833 NTAPI
2834 ExUuidCreate(
2835 OUT UUID *Uuid);
2836
2837 NTKERNELAPI
2838 DECLSPEC_NORETURN
2839 VOID
2840 NTAPI
2841 ExRaiseAccessViolation(
2842 VOID);
2843
2844 NTKERNELAPI
2845 DECLSPEC_NORETURN
2846 VOID
2847 NTAPI
2848 ExRaiseDatatypeMisalignment(
2849 VOID);
2850
2851 #endif
2852
2853 #ifdef _X86_
2854
2855 NTKERNELAPI
2856 INTERLOCKED_RESULT
2857 FASTCALL
2858 Exfi386InterlockedIncrementLong(
2859 IN OUT LONG volatile *Addend);
2860
2861 NTKERNELAPI
2862 INTERLOCKED_RESULT
2863 FASTCALL
2864 Exfi386InterlockedDecrementLong(
2865 IN PLONG Addend);
2866
2867 NTKERNELAPI
2868 ULONG
2869 FASTCALL
2870 Exfi386InterlockedExchangeUlong(
2871 IN PULONG Target,
2872 IN ULONG Value);
2873
2874 #endif /* _X86_ */
2875
2876 #ifndef _ARC_DDK_
2877 #define _ARC_DDK_
2878 typedef enum _CONFIGURATION_TYPE {
2879 ArcSystem,
2880 CentralProcessor,
2881 FloatingPointProcessor,
2882 PrimaryIcache,
2883 PrimaryDcache,
2884 SecondaryIcache,
2885 SecondaryDcache,
2886 SecondaryCache,
2887 EisaAdapter,
2888 TcAdapter,
2889 ScsiAdapter,
2890 DtiAdapter,
2891 MultiFunctionAdapter,
2892 DiskController,
2893 TapeController,
2894 CdromController,
2895 WormController,
2896 SerialController,
2897 NetworkController,
2898 DisplayController,
2899 ParallelController,
2900 PointerController,
2901 KeyboardController,
2902 AudioController,
2903 OtherController,
2904 DiskPeripheral,
2905 FloppyDiskPeripheral,
2906 TapePeripheral,
2907 ModemPeripheral,
2908 MonitorPeripheral,
2909 PrinterPeripheral,
2910 PointerPeripheral,
2911 KeyboardPeripheral,
2912 TerminalPeripheral,
2913 OtherPeripheral,
2914 LinePeripheral,
2915 NetworkPeripheral,
2916 SystemMemory,
2917 DockingInformation,
2918 RealModeIrqRoutingTable,
2919 RealModePCIEnumeration,
2920 MaximumType
2921 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2922 #endif /* !_ARC_DDK_ */
2923
2924 typedef struct _CONTROLLER_OBJECT {
2925 CSHORT Type;
2926 CSHORT Size;
2927 PVOID ControllerExtension;
2928 KDEVICE_QUEUE DeviceWaitQueue;
2929 ULONG Spare1;
2930 LARGE_INTEGER Spare2;
2931 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
2932
2933 typedef struct _CONFIGURATION_INFORMATION {
2934 ULONG DiskCount;
2935 ULONG FloppyCount;
2936 ULONG CdRomCount;
2937 ULONG TapeCount;
2938 ULONG ScsiPortCount;
2939 ULONG SerialCount;
2940 ULONG ParallelCount;
2941 BOOLEAN AtDiskPrimaryAddressClaimed;
2942 BOOLEAN AtDiskSecondaryAddressClaimed;
2943 ULONG Version;
2944 ULONG MediumChangerCount;
2945 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2946
2947 typedef
2948 NTSTATUS
2949 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
2950 IN PVOID Context,
2951 IN PUNICODE_STRING PathName,
2952 IN INTERFACE_TYPE BusType,
2953 IN ULONG BusNumber,
2954 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2955 IN CONFIGURATION_TYPE ControllerType,
2956 IN ULONG ControllerNumber,
2957 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2958 IN CONFIGURATION_TYPE PeripheralType,
2959 IN ULONG PeripheralNumber,
2960 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
2961
2962 typedef
2963 VOID
2964 (NTAPI DRIVER_REINITIALIZE)(
2965 IN struct _DRIVER_OBJECT *DriverObject,
2966 IN PVOID Context,
2967 IN ULONG Count);
2968
2969 typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE;
2970
2971 /** Filesystem runtime library routines **/
2972
2973 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2974 NTKERNELAPI
2975 BOOLEAN
2976 NTAPI
2977 FsRtlIsTotalDeviceFailure(
2978 IN NTSTATUS Status);
2979 #endif
2980
2981 /* Hardware Abstraction Layer Types */
2982
2983 typedef VOID
2984 (NTAPI *PciPin2Line)(
2985 IN struct _BUS_HANDLER *BusHandler,
2986 IN struct _BUS_HANDLER *RootHandler,
2987 IN PCI_SLOT_NUMBER SlotNumber,
2988 IN PPCI_COMMON_CONFIG PciData);
2989
2990 typedef VOID
2991 (NTAPI *PciLine2Pin)(
2992 IN struct _BUS_HANDLER *BusHandler,
2993 IN struct _BUS_HANDLER *RootHandler,
2994 IN PCI_SLOT_NUMBER SlotNumber,
2995 IN PPCI_COMMON_CONFIG PciNewData,
2996 IN PPCI_COMMON_CONFIG PciOldData);
2997
2998 typedef VOID
2999 (NTAPI *PciReadWriteConfig)(
3000 IN struct _BUS_HANDLER *BusHandler,
3001 IN PCI_SLOT_NUMBER Slot,
3002 IN PVOID Buffer,
3003 IN ULONG Offset,
3004 IN ULONG Length);
3005
3006 #define PCI_DATA_TAG ' ICP'
3007 #define PCI_DATA_VERSION 1
3008
3009 typedef struct _PCIBUSDATA {
3010 ULONG Tag;
3011 ULONG Version;
3012 PciReadWriteConfig ReadConfig;
3013 PciReadWriteConfig WriteConfig;
3014 PciPin2Line Pin2Line;
3015 PciLine2Pin Line2Pin;
3016 PCI_SLOT_NUMBER ParentSlot;
3017 PVOID Reserved[4];
3018 } PCIBUSDATA, *PPCIBUSDATA;
3019
3020 /* Hardware Abstraction Layer Functions */
3021
3022 #if !defined(NO_LEGACY_DRIVERS)
3023
3024 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3025
3026 NTHALAPI
3027 NTSTATUS
3028 NTAPI
3029 HalAssignSlotResources(
3030 IN PUNICODE_STRING RegistryPath,
3031 IN PUNICODE_STRING DriverClassName,
3032 IN PDRIVER_OBJECT DriverObject,
3033 IN PDEVICE_OBJECT DeviceObject,
3034 IN INTERFACE_TYPE BusType,
3035 IN ULONG BusNumber,
3036 IN ULONG SlotNumber,
3037 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3038
3039 NTHALAPI
3040 ULONG
3041 NTAPI
3042 HalGetInterruptVector(
3043 IN INTERFACE_TYPE InterfaceType,
3044 IN ULONG BusNumber,
3045 IN ULONG BusInterruptLevel,
3046 IN ULONG BusInterruptVector,
3047 OUT PKIRQL Irql,
3048 OUT PKAFFINITY Affinity);
3049
3050 NTHALAPI
3051 ULONG
3052 NTAPI
3053 HalSetBusData(
3054 IN BUS_DATA_TYPE BusDataType,
3055 IN ULONG BusNumber,
3056 IN ULONG SlotNumber,
3057 IN PVOID Buffer,
3058 IN ULONG Length);
3059
3060 #endif
3061
3062 #endif /* !defined(NO_LEGACY_DRIVERS) */
3063
3064 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3065
3066 NTHALAPI
3067 PADAPTER_OBJECT
3068 NTAPI
3069 HalGetAdapter(
3070 IN PDEVICE_DESCRIPTION DeviceDescription,
3071 IN OUT PULONG NumberOfMapRegisters);
3072
3073 NTHALAPI
3074 BOOLEAN
3075 NTAPI
3076 HalMakeBeep(
3077 IN ULONG Frequency);
3078
3079 VOID
3080 NTAPI
3081 HalPutDmaAdapter(
3082 IN PADAPTER_OBJECT DmaAdapter);
3083
3084 NTHALAPI
3085 VOID
3086 NTAPI
3087 HalAcquireDisplayOwnership(
3088 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
3089
3090 NTHALAPI
3091 ULONG
3092 NTAPI
3093 HalGetBusData(
3094 IN BUS_DATA_TYPE BusDataType,
3095 IN ULONG BusNumber,
3096 IN ULONG SlotNumber,
3097 OUT PVOID Buffer,
3098 IN ULONG Length);
3099
3100 NTHALAPI
3101 ULONG
3102 NTAPI
3103 HalGetBusDataByOffset(
3104 IN BUS_DATA_TYPE BusDataType,
3105 IN ULONG BusNumber,
3106 IN ULONG SlotNumber,
3107 OUT PVOID Buffer,
3108 IN ULONG Offset,
3109 IN ULONG Length);
3110
3111 NTHALAPI
3112 ULONG
3113 NTAPI
3114 HalSetBusDataByOffset(
3115 IN BUS_DATA_TYPE BusDataType,
3116 IN ULONG BusNumber,
3117 IN ULONG SlotNumber,
3118 IN PVOID Buffer,
3119 IN ULONG Offset,
3120 IN ULONG Length);
3121
3122 NTHALAPI
3123 BOOLEAN
3124 NTAPI
3125 HalTranslateBusAddress(
3126 IN INTERFACE_TYPE InterfaceType,
3127 IN ULONG BusNumber,
3128 IN PHYSICAL_ADDRESS BusAddress,
3129 IN OUT PULONG AddressSpace,
3130 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3131
3132 #endif
3133
3134 #if (NTDDI_VERSION >= NTDDI_WINXP)
3135 NTKERNELAPI
3136 VOID
3137 FASTCALL
3138 HalExamineMBR(
3139 IN PDEVICE_OBJECT DeviceObject,
3140 IN ULONG SectorSize,
3141 IN ULONG MBRTypeIdentifier,
3142 OUT PVOID *Buffer);
3143 #endif
3144
3145 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
3146 // nothing here
3147 #else
3148
3149 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3150 //DECLSPEC_DEPRECATED_DDK
3151 NTHALAPI
3152 VOID
3153 NTAPI
3154 IoFreeAdapterChannel(
3155 IN PADAPTER_OBJECT AdapterObject);
3156
3157 //DECLSPEC_DEPRECATED_DDK
3158 NTHALAPI
3159 BOOLEAN
3160 NTAPI
3161 IoFlushAdapterBuffers(
3162 IN PADAPTER_OBJECT AdapterObject,
3163 IN PMDL Mdl,
3164 IN PVOID MapRegisterBase,
3165 IN PVOID CurrentVa,
3166 IN ULONG Length,
3167 IN BOOLEAN WriteToDevice);
3168
3169 //DECLSPEC_DEPRECATED_DDK
3170 NTHALAPI
3171 VOID
3172 NTAPI
3173 IoFreeMapRegisters(
3174 IN PADAPTER_OBJECT AdapterObject,
3175 IN PVOID MapRegisterBase,
3176 IN ULONG NumberOfMapRegisters);
3177
3178 //DECLSPEC_DEPRECATED_DDK
3179 NTHALAPI
3180 PVOID
3181 NTAPI
3182 HalAllocateCommonBuffer(
3183 IN PADAPTER_OBJECT AdapterObject,
3184 IN ULONG Length,
3185 OUT PPHYSICAL_ADDRESS LogicalAddress,
3186 IN BOOLEAN CacheEnabled);
3187
3188 //DECLSPEC_DEPRECATED_DDK
3189 NTHALAPI
3190 VOID
3191 NTAPI
3192 HalFreeCommonBuffer(
3193 IN PADAPTER_OBJECT AdapterObject,
3194 IN ULONG Length,
3195 IN PHYSICAL_ADDRESS LogicalAddress,
3196 IN PVOID VirtualAddress,
3197 IN BOOLEAN CacheEnabled);
3198
3199 //DECLSPEC_DEPRECATED_DDK
3200 NTHALAPI
3201 ULONG
3202 NTAPI
3203 HalReadDmaCounter(
3204 IN PADAPTER_OBJECT AdapterObject);
3205
3206 NTHALAPI
3207 NTSTATUS
3208 NTAPI
3209 HalAllocateAdapterChannel(
3210 IN PADAPTER_OBJECT AdapterObject,
3211 IN PWAIT_CONTEXT_BLOCK Wcb,
3212 IN ULONG NumberOfMapRegisters,
3213 IN PDRIVER_CONTROL ExecutionRoutine);
3214
3215 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3216
3217 #endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */
3218
3219 /* I/O Manager Functions */
3220
3221 /*
3222 * VOID IoAssignArcName(
3223 * IN PUNICODE_STRING ArcName,
3224 * IN PUNICODE_STRING DeviceName);
3225 */
3226 #define IoAssignArcName(_ArcName, _DeviceName) ( \
3227 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
3228
3229 /*
3230 * VOID
3231 * IoDeassignArcName(
3232 * IN PUNICODE_STRING ArcName)
3233 */
3234 #define IoDeassignArcName IoDeleteSymbolicLink
3235
3236 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3237
3238 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
3239 NTKERNELAPI
3240 NTSTATUS
3241 NTAPI
3242 IoAllocateAdapterChannel(
3243 IN PADAPTER_OBJECT AdapterObject,
3244 IN PDEVICE_OBJECT DeviceObject,
3245 IN ULONG NumberOfMapRegisters,
3246 IN PDRIVER_CONTROL ExecutionRoutine,
3247 IN PVOID Context);
3248 #endif
3249
3250 //DECLSPEC_DEPRECATED_DDK
3251 NTHALAPI
3252 PHYSICAL_ADDRESS
3253 NTAPI
3254 IoMapTransfer(
3255 IN PADAPTER_OBJECT AdapterObject,
3256 IN PMDL Mdl,
3257 IN PVOID MapRegisterBase,
3258 IN PVOID CurrentVa,
3259 IN OUT PULONG Length,
3260 IN BOOLEAN WriteToDevice);
3261
3262 NTKERNELAPI
3263 VOID
3264 NTAPI
3265 IoAllocateController(
3266 IN PCONTROLLER_OBJECT ControllerObject,
3267 IN PDEVICE_OBJECT DeviceObject,
3268 IN PDRIVER_CONTROL ExecutionRoutine,
3269 IN PVOID Context OPTIONAL);
3270
3271 NTKERNELAPI
3272 PCONTROLLER_OBJECT
3273 NTAPI
3274 IoCreateController(
3275 IN ULONG Size);
3276
3277 NTKERNELAPI
3278 VOID
3279 NTAPI
3280 IoDeleteController(
3281 IN PCONTROLLER_OBJECT ControllerObject);
3282
3283 NTKERNELAPI
3284 VOID
3285 NTAPI
3286 IoFreeController(
3287 IN PCONTROLLER_OBJECT ControllerObject);
3288
3289 NTKERNELAPI
3290 PCONFIGURATION_INFORMATION
3291 NTAPI
3292 IoGetConfigurationInformation(
3293 VOID);
3294
3295 NTKERNELAPI
3296 PDEVICE_OBJECT
3297 NTAPI
3298 IoGetDeviceToVerify(
3299 IN PETHREAD Thread);
3300
3301 NTKERNELAPI
3302 VOID
3303 NTAPI
3304 IoCancelFileOpen(
3305 IN PDEVICE_OBJECT DeviceObject,
3306 IN PFILE_OBJECT FileObject);
3307
3308 NTKERNELAPI
3309 PGENERIC_MAPPING
3310 NTAPI
3311 IoGetFileObjectGenericMapping(
3312 VOID);
3313
3314 NTKERNELAPI
3315 PIRP
3316 NTAPI
3317 IoMakeAssociatedIrp(
3318 IN PIRP Irp,
3319 IN CCHAR StackSize);
3320
3321 NTKERNELAPI
3322 NTSTATUS
3323 NTAPI
3324 IoQueryDeviceDescription(
3325 IN PINTERFACE_TYPE BusType OPTIONAL,
3326 IN PULONG BusNumber OPTIONAL,
3327 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
3328 IN PULONG ControllerNumber OPTIONAL,
3329 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
3330 IN PULONG PeripheralNumber OPTIONAL,
3331 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
3332 IN OUT PVOID Context OPTIONAL);
3333
3334 NTKERNELAPI
3335 VOID
3336 NTAPI
3337 IoRaiseHardError(
3338 IN PIRP Irp,
3339 IN PVPB Vpb OPTIONAL,
3340 IN PDEVICE_OBJECT RealDeviceObject);
3341
3342 NTKERNELAPI
3343 BOOLEAN
3344 NTAPI
3345 IoRaiseInformationalHardError(
3346 IN NTSTATUS ErrorStatus,
3347 IN PUNICODE_STRING String OPTIONAL,
3348 IN PKTHREAD Thread OPTIONAL);
3349
3350 NTKERNELAPI
3351 VOID
3352 NTAPI
3353 IoRegisterBootDriverReinitialization(
3354 IN PDRIVER_OBJECT DriverObject,
3355 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3356 IN PVOID Context OPTIONAL);
3357
3358 NTKERNELAPI
3359 VOID
3360 NTAPI
3361 IoRegisterDriverReinitialization(
3362 IN PDRIVER_OBJECT DriverObject,
3363 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3364 IN PVOID Context OPTIONAL);
3365
3366 NTKERNELAPI
3367 NTSTATUS
3368 NTAPI
3369 IoAttachDeviceByPointer(
3370 IN PDEVICE_OBJECT SourceDevice,
3371 IN PDEVICE_OBJECT TargetDevice);
3372
3373 NTKERNELAPI
3374 NTSTATUS
3375 NTAPI
3376 IoReportDetectedDevice(
3377 IN PDRIVER_OBJECT DriverObject,
3378 IN INTERFACE_TYPE LegacyBusType,
3379 IN ULONG BusNumber,
3380 IN ULONG SlotNumber,
3381 IN PCM_RESOURCE_LIST ResourceList OPTIONAL,
3382 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
3383 IN BOOLEAN ResourceAssigned,
3384 IN OUT PDEVICE_OBJECT *DeviceObject);
3385
3386 NTKERNELAPI
3387 NTSTATUS
3388 NTAPI
3389 IoReportResourceForDetection(
3390 IN PDRIVER_OBJECT DriverObject,
3391 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
3392 IN ULONG DriverListSize OPTIONAL,
3393 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3394 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
3395 IN ULONG DeviceListSize OPTIONAL,
3396 OUT PBOOLEAN ConflictDetected);
3397
3398 NTKERNELAPI
3399 NTSTATUS
3400 NTAPI
3401 IoReportResourceUsage(
3402 IN PUNICODE_STRING DriverClassName OPTIONAL,
3403 IN PDRIVER_OBJECT DriverObject,
3404 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
3405 IN ULONG DriverListSize OPTIONAL,
3406 IN PDEVICE_OBJECT DeviceObject,
3407 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
3408 IN ULONG DeviceListSize OPTIONAL,
3409 IN BOOLEAN OverrideConflict,
3410 OUT PBOOLEAN ConflictDetected);
3411
3412 NTKERNELAPI
3413 VOID
3414 NTAPI
3415 IoSetHardErrorOrVerifyDevice(
3416 IN PIRP Irp,
3417 IN PDEVICE_OBJECT DeviceObject);
3418
3419 NTKERNELAPI
3420 NTSTATUS
3421 NTAPI
3422 IoAssignResources(
3423 IN PUNICODE_STRING RegistryPath,
3424 IN PUNICODE_STRING DriverClassName OPTIONAL,
3425 IN PDRIVER_OBJECT DriverObject,
3426 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3427 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL,
3428 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3429
3430 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3431
3432 #if (NTDDI_VERSION >= NTDDI_WINXP)
3433
3434 NTKERNELAPI
3435 NTSTATUS
3436 NTAPI
3437 IoCreateDisk(
3438 IN PDEVICE_OBJECT DeviceObject,
3439 IN struct _CREATE_DISK* Disk OPTIONAL);
3440
3441 NTKERNELAPI
3442 NTSTATUS
3443 NTAPI
3444 IoReadDiskSignature(
3445 IN PDEVICE_OBJECT DeviceObject,
3446 IN ULONG BytesPerSector,
3447 OUT PDISK_SIGNATURE Signature);
3448
3449 NTKERNELAPI
3450 NTSTATUS
3451 FASTCALL
3452 IoReadPartitionTable(
3453 IN PDEVICE_OBJECT DeviceObject,
3454 IN ULONG SectorSize,
3455 IN BOOLEAN ReturnRecognizedPartitions,
3456 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
3457
3458 NTKERNELAPI
3459 NTSTATUS
3460 NTAPI
3461 IoReadPartitionTableEx(
3462 IN PDEVICE_OBJECT DeviceObject,
3463 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
3464
3465 NTKERNELAPI
3466 NTSTATUS
3467 FASTCALL
3468 IoSetPartitionInformation(
3469 IN PDEVICE_OBJECT DeviceObject,
3470 IN ULONG SectorSize,
3471 IN ULONG PartitionNumber,
3472 IN ULONG PartitionType);
3473
3474 NTKERNELAPI
3475 NTSTATUS
3476 NTAPI
3477 IoSetPartitionInformationEx(
3478 IN PDEVICE_OBJECT DeviceObject,
3479 IN ULONG PartitionNumber,
3480 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
3481
3482 NTKERNELAPI
3483 NTSTATUS
3484 NTAPI
3485 IoSetSystemPartition(
3486 IN PUNICODE_STRING VolumeNameString);
3487
3488 NTKERNELAPI
3489 BOOLEAN
3490 NTAPI
3491 IoSetThreadHardErrorMode(
3492 IN BOOLEAN EnableHardErrors);
3493
3494 NTKERNELAPI
3495 NTSTATUS
3496 NTAPI
3497 IoVerifyPartitionTable(
3498 IN PDEVICE_OBJECT DeviceObject,
3499 IN BOOLEAN FixErrors);
3500
3501 NTKERNELAPI
3502 NTSTATUS
3503 NTAPI
3504 IoVolumeDeviceToDosName(
3505 IN PVOID VolumeDeviceObject,
3506 OUT PUNICODE_STRING DosName);
3507
3508 NTKERNELAPI
3509 NTSTATUS
3510 FASTCALL
3511 IoWritePartitionTable(
3512 IN PDEVICE_OBJECT DeviceObject,
3513 IN ULONG SectorSize,
3514 IN ULONG SectorsPerTrack,
3515 IN ULONG NumberOfHeads,
3516 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
3517
3518 NTKERNELAPI
3519 NTSTATUS
3520 NTAPI
3521 IoWritePartitionTableEx(
3522 IN PDEVICE_OBJECT DeviceObject,
3523 IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
3524
3525 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3526
3527 /* Kernel Functions */
3528
3529 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3530
3531 NTKERNELAPI
3532 DECLSPEC_NORETURN
3533 VOID
3534 NTAPI
3535 KeBugCheck(
3536 IN ULONG BugCheckCode);
3537
3538 NTKERNELAPI
3539 LONG
3540 NTAPI
3541 KePulseEvent(
3542 IN OUT PRKEVENT Event,
3543 IN KPRIORITY Increment,
3544 IN BOOLEAN Wait);
3545
3546 NTKERNELAPI
3547 LONG
3548 NTAPI
3549 KeSetBasePriorityThread(
3550 IN OUT PRKTHREAD Thread,
3551 IN LONG Increment);
3552
3553 #endif
3554
3555 /* Memory Manager Types */
3556
3557 typedef struct _PHYSICAL_MEMORY_RANGE {
3558 PHYSICAL_ADDRESS BaseAddress;
3559 LARGE_INTEGER NumberOfBytes;
3560 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3561
3562 /* Memory Manager Functions */
3563
3564 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3565
3566 NTKERNELAPI
3567 PPHYSICAL_MEMORY_RANGE
3568 NTAPI
3569 MmGetPhysicalMemoryRanges(
3570 VOID);
3571
3572 NTKERNELAPI
3573 PHYSICAL_ADDRESS
3574 NTAPI
3575 MmGetPhysicalAddress(
3576 IN PVOID BaseAddress);
3577
3578 NTKERNELAPI
3579 BOOLEAN
3580 NTAPI
3581 MmIsNonPagedSystemAddressValid(
3582 IN PVOID VirtualAddress);
3583
3584 NTKERNELAPI
3585 PVOID
3586 NTAPI
3587 MmAllocateNonCachedMemory(
3588 IN SIZE_T NumberOfBytes);
3589
3590 NTKERNELAPI
3591 VOID
3592 NTAPI
3593 MmFreeNonCachedMemory(
3594 IN PVOID BaseAddress,
3595 IN SIZE_T NumberOfBytes);
3596
3597 NTKERNELAPI
3598 PVOID
3599 NTAPI
3600 MmGetVirtualForPhysical(
3601 IN PHYSICAL_ADDRESS PhysicalAddress);
3602
3603 NTKERNELAPI
3604 NTSTATUS
3605 NTAPI
3606 MmMapUserAddressesToPage(
3607 IN PVOID BaseAddress,
3608 IN SIZE_T NumberOfBytes,
3609 IN PVOID PageAddress);
3610
3611 NTKERNELAPI
3612 PVOID
3613 NTAPI
3614 MmMapVideoDisplay(
3615 IN PHYSICAL_ADDRESS PhysicalAddress,
3616 IN SIZE_T NumberOfBytes,
3617 IN MEMORY_CACHING_TYPE CacheType);
3618
3619 NTKERNELAPI
3620 NTSTATUS
3621 NTAPI
3622 MmMapViewInSessionSpace(
3623 IN PVOID Section,
3624 OUT PVOID *MappedBase,
3625 IN OUT PSIZE_T ViewSize);
3626
3627 NTKERNELAPI
3628 NTSTATUS
3629 NTAPI
3630 MmMapViewInSystemSpace(
3631 IN PVOID Section,
3632 OUT PVOID *MappedBase,
3633 IN OUT PSIZE_T ViewSize);
3634
3635 NTKERNELAPI
3636 BOOLEAN
3637 NTAPI
3638 MmIsAddressValid(
3639 IN PVOID VirtualAddress);
3640
3641 NTKERNELAPI
3642 BOOLEAN
3643 NTAPI
3644 MmIsThisAnNtAsSystem(
3645 VOID);
3646
3647 NTKERNELAPI
3648 VOID
3649 NTAPI
3650 MmLockPagableSectionByHandle(
3651 IN PVOID ImageSectionHandle);
3652
3653 NTKERNELAPI
3654 NTSTATUS
3655 NTAPI
3656 MmUnmapViewInSessionSpace(
3657 IN PVOID MappedBase);
3658
3659 NTKERNELAPI
3660 NTSTATUS
3661 NTAPI
3662 MmUnmapViewInSystemSpace(
3663 IN PVOID MappedBase);
3664
3665 NTKERNELAPI
3666 VOID
3667 NTAPI
3668 MmUnsecureVirtualMemory(
3669 IN HANDLE SecureHandle);
3670
3671 NTKERNELAPI
3672 NTSTATUS
3673 NTAPI
3674 MmRemovePhysicalMemory(
3675 IN PPHYSICAL_ADDRESS StartAddress,
3676 IN OUT PLARGE_INTEGER NumberOfBytes);
3677
3678 NTKERNELAPI
3679 HANDLE
3680 NTAPI
3681 MmSecureVirtualMemory(
3682 IN PVOID Address,
3683 IN SIZE_T Size,
3684 IN ULONG ProbeMode);
3685
3686 NTKERNELAPI
3687 VOID
3688 NTAPI
3689 MmUnmapVideoDisplay(
3690 IN PVOID BaseAddress,
3691 IN SIZE_T NumberOfBytes);
3692
3693 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3694
3695 /* NtXxx Functions */
3696
3697 NTSYSCALLAPI
3698 NTSTATUS
3699 NTAPI
3700 NtOpenProcess(
3701 OUT PHANDLE ProcessHandle,
3702 IN ACCESS_MASK DesiredAccess,
3703 IN POBJECT_ATTRIBUTES ObjectAttributes,
3704 IN PCLIENT_ID ClientId OPTIONAL);
3705
3706 NTSYSCALLAPI
3707 NTSTATUS
3708 NTAPI
3709 NtQueryInformationProcess(
3710 IN HANDLE ProcessHandle,
3711 IN PROCESSINFOCLASS ProcessInformationClass,
3712 OUT PVOID ProcessInformation OPTIONAL,
3713 IN ULONG ProcessInformationLength,
3714 OUT PULONG ReturnLength OPTIONAL);
3715
3716 /** Process manager types **/
3717
3718 typedef VOID
3719 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
3720 IN HANDLE ParentId,
3721 IN HANDLE ProcessId,
3722 IN BOOLEAN Create);
3723
3724 typedef VOID
3725 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
3726 IN HANDLE ProcessId,
3727 IN HANDLE ThreadId,
3728 IN BOOLEAN Create);
3729
3730 typedef VOID
3731 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
3732 IN PUNICODE_STRING FullImageName,
3733 IN HANDLE ProcessId,
3734 IN PIMAGE_INFO ImageInfo);
3735
3736 /** Process manager routines **/
3737
3738 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3739
3740 NTKERNELAPI
3741 NTSTATUS
3742 NTAPI
3743 PsSetLoadImageNotifyRoutine(
3744 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3745
3746 NTKERNELAPI
3747 NTSTATUS
3748 NTAPI
3749 PsSetCreateThreadNotifyRoutine(
3750 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3751
3752 NTKERNELAPI
3753 NTSTATUS
3754 NTAPI
3755 PsSetCreateProcessNotifyRoutine(
3756 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3757 IN BOOLEAN Remove);
3758
3759 NTKERNELAPI
3760 HANDLE
3761 NTAPI
3762 PsGetCurrentProcessId(
3763 VOID);
3764
3765 NTKERNELAPI
3766 HANDLE
3767 NTAPI
3768 PsGetCurrentThreadId(
3769 VOID);
3770
3771 NTKERNELAPI
3772 BOOLEAN
3773 NTAPI
3774 PsGetVersion(
3775 OUT PULONG MajorVersion OPTIONAL,
3776 OUT PULONG MinorVersion OPTIONAL,
3777 OUT PULONG BuildNumber OPTIONAL,
3778 OUT PUNICODE_STRING CSDVersion OPTIONAL);
3779
3780 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3781
3782 #if (NTDDI_VERSION >= NTDDI_WINXP)
3783
3784 NTKERNELAPI
3785 HANDLE
3786 NTAPI
3787 PsGetProcessId(
3788 IN PEPROCESS Process);
3789
3790 NTKERNELAPI
3791 NTSTATUS
3792 NTAPI
3793 PsRemoveCreateThreadNotifyRoutine(
3794 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3795
3796 NTKERNELAPI
3797 NTSTATUS
3798 NTAPI
3799 PsRemoveLoadImageNotifyRoutine(
3800 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3801
3802 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3803
3804 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
3805
3806 /* Security reference monitor routines */
3807
3808 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3809 NTKERNELAPI
3810 BOOLEAN
3811 NTAPI
3812 SeSinglePrivilegeCheck(
3813 IN LUID PrivilegeValue,
3814 IN KPROCESSOR_MODE PreviousMode);
3815 #endif
3816
3817 /* ZwXxx Functions */
3818
3819 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3820
3821 NTSTATUS
3822 NTAPI
3823 ZwCancelTimer(
3824 IN HANDLE TimerHandle,
3825 OUT PBOOLEAN CurrentState OPTIONAL);
3826
3827 NTSTATUS
3828 NTAPI
3829 ZwCreateTimer(
3830 OUT PHANDLE TimerHandle,
3831 IN ACCESS_MASK DesiredAccess,
3832 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3833 IN TIMER_TYPE TimerType);
3834
3835 NTSTATUS
3836 NTAPI
3837 ZwOpenTimer(
3838 OUT PHANDLE TimerHandle,
3839 IN ACCESS_MASK DesiredAccess,
3840 IN POBJECT_ATTRIBUTES ObjectAttributes);
3841
3842 NTSYSAPI
3843 NTSTATUS
3844 NTAPI
3845 ZwSetInformationThread(
3846 IN HANDLE ThreadHandle,
3847 IN THREADINFOCLASS ThreadInformationClass,
3848 IN PVOID ThreadInformation,
3849 IN ULONG ThreadInformationLength);
3850
3851 NTSTATUS
3852 NTAPI
3853 ZwSetTimer(
3854 IN HANDLE TimerHandle,
3855 IN PLARGE_INTEGER DueTime,
3856 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3857 IN PVOID TimerContext OPTIONAL,
3858 IN BOOLEAN ResumeTimer,
3859 IN LONG Period OPTIONAL,
3860 OUT PBOOLEAN PreviousState OPTIONAL);
3861
3862 #endif
3863
3864 NTSYSAPI
3865 NTSTATUS
3866 NTAPI
3867 ZwDisplayString (
3868 IN PUNICODE_STRING String
3869 );
3870
3871 #if (VER_PRODUCTBUILD >= 2195)
3872
3873 NTSYSAPI
3874 NTSTATUS
3875 NTAPI
3876 ZwPowerInformation (
3877 IN POWER_INFORMATION_LEVEL PowerInformationLevel,
3878 IN PVOID InputBuffer OPTIONAL,
3879 IN ULONG InputBufferLength,
3880 OUT PVOID OutputBuffer OPTIONAL,
3881 IN ULONG OutputBufferLength
3882 );
3883
3884 #endif /* (VER_PRODUCTBUILD >= 2195) */
3885
3886 NTSYSAPI
3887 NTSTATUS
3888 NTAPI
3889 ZwTerminateProcess (
3890 IN HANDLE ProcessHandle OPTIONAL,
3891 IN NTSTATUS ExitStatus
3892 );
3893
3894 NTSYSAPI
3895 NTSTATUS
3896 NTAPI
3897 ZwOpenProcess (
3898 OUT PHANDLE ProcessHandle,
3899 IN ACCESS_MASK DesiredAccess,
3900 IN POBJECT_ATTRIBUTES ObjectAttributes,
3901 IN PCLIENT_ID ClientId OPTIONAL
3902 );
3903
3904 NTSYSAPI
3905 NTSTATUS
3906 NTAPI
3907 ZwQueryVolumeInformationFile(
3908 IN HANDLE FileHandle,
3909 OUT PIO_STATUS_BLOCK IoStatusBlock,
3910 OUT PVOID FsInformation,
3911 IN ULONG Length,
3912 IN FS_INFORMATION_CLASS FsInformationClass);
3913
3914 NTSYSAPI
3915 NTSTATUS
3916 NTAPI
3917 ZwDeviceIoControlFile(
3918 IN HANDLE FileHandle,
3919 IN HANDLE Event OPTIONAL,
3920 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
3921 IN PVOID ApcContext OPTIONAL,
3922 OUT PIO_STATUS_BLOCK IoStatusBlock,
3923 IN ULONG IoControlCode,
3924 IN PVOID InputBuffer OPTIONAL,
3925 IN ULONG InputBufferLength,
3926 OUT PVOID OutputBuffer OPTIONAL,
3927 IN ULONG OutputBufferLength);
3928
3929 #ifdef __cplusplus
3930 }
3931 #endif