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