0e02581425da731fc078583e6f61a93b23cdd096
[reactos.git] / reactos / 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 #ifndef _NTDDK_
28 #define _NTDDK_
29
30 #if !defined(_NTHAL_) && !defined(_NTIFS_)
31 #define _NTDDK_INCLUDED_
32 #define _DDK_DRIVER_
33 #endif
34
35 /* Dependencies */
36
37 #define NT_INCLUDED
38 #define _CTYPE_DISABLE_MACROS
39
40 #include <wdm.h>
41 #include <excpt.h>
42 #include <ntdef.h>
43 #include <ntstatus.h>
44
45 /* FIXME
46 #include <bugcodes.h>
47 #include <ntiologc.h>
48 */
49
50 #include <stdarg.h> // FIXME
51 #include <basetyps.h> // FIXME
52
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 struct _LOADER_PARAMETER_BLOCK;
59 struct _CREATE_DISK;
60 struct _DRIVE_LAYOUT_INFORMATION_EX;
61 struct _SET_PARTITION_INFORMATION_EX;
62
63 //
64 // GUID and UUID
65 //
66 #ifndef GUID_DEFINED
67 #include <guiddef.h>
68 #endif
69 typedef GUID UUID;
70
71 typedef struct _BUS_HANDLER *PBUS_HANDLER;
72
73 typedef struct _PEB *PPEB;
74
75 #ifndef _NTIMAGE_
76
77 typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
78 typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
79
80 #ifdef _WIN64
81 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
82 #else
83 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
84 #endif
85
86 #endif /* _NTIMAGE_ */
87
88 #define EXCEPTION_READ_FAULT 0
89 #define EXCEPTION_WRITE_FAULT 1
90 #define EXCEPTION_EXECUTE_FAULT 8
91
92 #if (NTDDI_VERSION >= NTDDI_VISTA)
93 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
94 #elif (NTDDI_VERSION >= NTDDI_WINXP)
95 extern NTSYSAPI CCHAR KeNumberProcessors;
96 #else
97 extern PCCHAR KeNumberProcessors;
98 #endif
99
100 #define MAX_WOW64_SHARED_ENTRIES 16
101
102 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
103 #define NX_SUPPORT_POLICY_ALWAYSON 1
104 #define NX_SUPPORT_POLICY_OPTIN 2
105 #define NX_SUPPORT_POLICY_OPTOUT 3
106
107 /*
108 ** IRP function codes
109 */
110
111 #define IRP_MN_QUERY_DIRECTORY 0x01
112 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
113
114 #define IRP_MN_USER_FS_REQUEST 0x00
115 #define IRP_MN_MOUNT_VOLUME 0x01
116 #define IRP_MN_VERIFY_VOLUME 0x02
117 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
118 #define IRP_MN_TRACK_LINK 0x04
119 #define IRP_MN_KERNEL_CALL 0x04
120
121 #define IRP_MN_LOCK 0x01
122 #define IRP_MN_UNLOCK_SINGLE 0x02
123 #define IRP_MN_UNLOCK_ALL 0x03
124 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
125
126 #define IRP_MN_FLUSH_AND_PURGE 0x01
127
128 #define IRP_MN_NORMAL 0x00
129 #define IRP_MN_DPC 0x01
130 #define IRP_MN_MDL 0x02
131 #define IRP_MN_COMPLETE 0x04
132 #define IRP_MN_COMPRESSED 0x08
133
134 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
135 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
136 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
137
138 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
139
140 typedef struct _IO_COUNTERS {
141 ULONGLONG ReadOperationCount;
142 ULONGLONG WriteOperationCount;
143 ULONGLONG OtherOperationCount;
144 ULONGLONG ReadTransferCount;
145 ULONGLONG WriteTransferCount;
146 ULONGLONG OtherTransferCount;
147 } IO_COUNTERS, *PIO_COUNTERS;
148
149 typedef struct _VM_COUNTERS {
150 SIZE_T PeakVirtualSize;
151 SIZE_T VirtualSize;
152 ULONG PageFaultCount;
153 SIZE_T PeakWorkingSetSize;
154 SIZE_T WorkingSetSize;
155 SIZE_T QuotaPeakPagedPoolUsage;
156 SIZE_T QuotaPagedPoolUsage;
157 SIZE_T QuotaPeakNonPagedPoolUsage;
158 SIZE_T QuotaNonPagedPoolUsage;
159 SIZE_T PagefileUsage;
160 SIZE_T PeakPagefileUsage;
161 } VM_COUNTERS, *PVM_COUNTERS;
162
163 typedef struct _VM_COUNTERS_EX
164 {
165 SIZE_T PeakVirtualSize;
166 SIZE_T VirtualSize;
167 ULONG PageFaultCount;
168 SIZE_T PeakWorkingSetSize;
169 SIZE_T WorkingSetSize;
170 SIZE_T QuotaPeakPagedPoolUsage;
171 SIZE_T QuotaPagedPoolUsage;
172 SIZE_T QuotaPeakNonPagedPoolUsage;
173 SIZE_T QuotaNonPagedPoolUsage;
174 SIZE_T PagefileUsage;
175 SIZE_T PeakPagefileUsage;
176 SIZE_T PrivateUsage;
177 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
178
179 typedef struct _POOLED_USAGE_AND_LIMITS
180 {
181 SIZE_T PeakPagedPoolUsage;
182 SIZE_T PagedPoolUsage;
183 SIZE_T PagedPoolLimit;
184 SIZE_T PeakNonPagedPoolUsage;
185 SIZE_T NonPagedPoolUsage;
186 SIZE_T NonPagedPoolLimit;
187 SIZE_T PeakPagefileUsage;
188 SIZE_T PagefileUsage;
189 SIZE_T PagefileLimit;
190 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
191
192 /* DEVICE_OBJECT.Flags */
193
194 #define DO_VERIFY_VOLUME 0x00000002
195 #define DO_BUFFERED_IO 0x00000004
196 #define DO_EXCLUSIVE 0x00000008
197 #define DO_DIRECT_IO 0x00000010
198 #define DO_MAP_IO_BUFFER 0x00000020
199 #define DO_DEVICE_HAS_NAME 0x00000040
200 #define DO_DEVICE_INITIALIZING 0x00000080
201 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
202 #define DO_LONG_TERM_REQUESTS 0x00000200
203 #define DO_NEVER_LAST_DEVICE 0x00000400
204 #define DO_SHUTDOWN_REGISTERED 0x00000800
205 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
206 #define DO_POWER_PAGABLE 0x00002000
207 #define DO_POWER_INRUSH 0x00004000
208 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
209 #define DO_SUPPORTS_TRANSACTIONS 0x00040000
210 #define DO_FORCE_NEITHER_IO 0x00080000
211 #define DO_VOLUME_DEVICE_OBJECT 0x00100000
212 #define DO_SYSTEM_SYSTEM_PARTITION 0x00200000
213 #define DO_SYSTEM_CRITICAL_PARTITION 0x00400000
214 #define DO_DISALLOW_EXECUTE 0x00800000
215
216 #define DRVO_REINIT_REGISTERED 0x00000008
217 #define DRVO_INITIALIZED 0x00000010
218 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
219 #define DRVO_LEGACY_RESOURCES 0x00000040
220
221 typedef enum _ARBITER_REQUEST_SOURCE {
222 ArbiterRequestUndefined = -1,
223 ArbiterRequestLegacyReported,
224 ArbiterRequestHalReported,
225 ArbiterRequestLegacyAssigned,
226 ArbiterRequestPnpDetected,
227 ArbiterRequestPnpEnumerated
228 } ARBITER_REQUEST_SOURCE;
229
230 typedef enum _ARBITER_RESULT {
231 ArbiterResultUndefined = -1,
232 ArbiterResultSuccess,
233 ArbiterResultExternalConflict,
234 ArbiterResultNullRequest
235 } ARBITER_RESULT;
236
237 typedef enum _ARBITER_ACTION {
238 ArbiterActionTestAllocation,
239 ArbiterActionRetestAllocation,
240 ArbiterActionCommitAllocation,
241 ArbiterActionRollbackAllocation,
242 ArbiterActionQueryAllocatedResources,
243 ArbiterActionWriteReservedResources,
244 ArbiterActionQueryConflict,
245 ArbiterActionQueryArbitrate,
246 ArbiterActionAddReserved,
247 ArbiterActionBootAllocation
248 } ARBITER_ACTION, *PARBITER_ACTION;
249
250 typedef struct _ARBITER_CONFLICT_INFO {
251 PDEVICE_OBJECT OwningObject;
252 ULONGLONG Start;
253 ULONGLONG End;
254 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
255
256 typedef struct _ARBITER_PARAMETERS {
257 union {
258 struct {
259 IN OUT PLIST_ENTRY ArbitrationList;
260 IN ULONG AllocateFromCount;
261 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
262 } TestAllocation;
263 struct {
264 IN OUT PLIST_ENTRY ArbitrationList;
265 IN ULONG AllocateFromCount;
266 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
267 } RetestAllocation;
268 struct {
269 IN OUT PLIST_ENTRY ArbitrationList;
270 } BootAllocation;
271 struct {
272 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
273 } QueryAllocatedResources;
274 struct {
275 IN PDEVICE_OBJECT PhysicalDeviceObject;
276 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
277 OUT PULONG ConflictCount;
278 OUT PARBITER_CONFLICT_INFO *Conflicts;
279 } QueryConflict;
280 struct {
281 IN PLIST_ENTRY ArbitrationList;
282 } QueryArbitrate;
283 struct {
284 IN PDEVICE_OBJECT ReserveDevice;
285 } AddReserved;
286 } Parameters;
287 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
288
289 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
290
291 typedef struct _ARBITER_LIST_ENTRY {
292 LIST_ENTRY ListEntry;
293 ULONG AlternativeCount;
294 PIO_RESOURCE_DESCRIPTOR Alternatives;
295 PDEVICE_OBJECT PhysicalDeviceObject;
296 ARBITER_REQUEST_SOURCE RequestSource;
297 ULONG Flags;
298 LONG_PTR WorkSpace;
299 INTERFACE_TYPE InterfaceType;
300 ULONG SlotNumber;
301 ULONG BusNumber;
302 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
303 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
304 ARBITER_RESULT Result;
305 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
306
307 typedef NTSTATUS
308 (NTAPI *PARBITER_HANDLER)(
309 IN OUT PVOID Context,
310 IN ARBITER_ACTION Action,
311 IN OUT PARBITER_PARAMETERS Parameters);
312
313 #define ARBITER_PARTIAL 0x00000001
314
315 typedef struct _ARBITER_INTERFACE {
316 USHORT Size;
317 USHORT Version;
318 PVOID Context;
319 PINTERFACE_REFERENCE InterfaceReference;
320 PINTERFACE_DEREFERENCE InterfaceDereference;
321 PARBITER_HANDLER ArbiterHandler;
322 ULONG Flags;
323 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
324
325 typedef struct _PCI_AGP_CAPABILITY {
326 PCI_CAPABILITIES_HEADER Header;
327 USHORT Minor:4;
328 USHORT Major:4;
329 USHORT Rsvd1:8;
330 struct _PCI_AGP_STATUS {
331 ULONG Rate:3;
332 ULONG Agp3Mode:1;
333 ULONG FastWrite:1;
334 ULONG FourGB:1;
335 ULONG HostTransDisable:1;
336 ULONG Gart64:1;
337 ULONG ITA_Coherent:1;
338 ULONG SideBandAddressing:1;
339 ULONG CalibrationCycle:3;
340 ULONG AsyncRequestSize:3;
341 ULONG Rsvd1:1;
342 ULONG Isoch:1;
343 ULONG Rsvd2:6;
344 ULONG RequestQueueDepthMaximum:8;
345 } AGPStatus;
346 struct _PCI_AGP_COMMAND {
347 ULONG Rate:3;
348 ULONG Rsvd1:1;
349 ULONG FastWriteEnable:1;
350 ULONG FourGBEnable:1;
351 ULONG Rsvd2:1;
352 ULONG Gart64:1;
353 ULONG AGPEnable:1;
354 ULONG SBAEnable:1;
355 ULONG CalibrationCycle:3;
356 ULONG AsyncReqSize:3;
357 ULONG Rsvd3:8;
358 ULONG RequestQueueDepth:8;
359 } AGPCommand;
360 } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
361
362 typedef enum _EXTENDED_AGP_REGISTER {
363 IsochStatus,
364 AgpControl,
365 ApertureSize,
366 AperturePageSize,
367 GartLow,
368 GartHigh,
369 IsochCommand
370 } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
371
372 typedef struct _PCI_AGP_ISOCH_STATUS {
373 ULONG ErrorCode:2;
374 ULONG Rsvd1:1;
375 ULONG Isoch_L:3;
376 ULONG Isoch_Y:2;
377 ULONG Isoch_N:8;
378 ULONG Rsvd2:16;
379 } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
380
381 typedef struct _PCI_AGP_CONTROL {
382 ULONG Rsvd1:7;
383 ULONG GTLB_Enable:1;
384 ULONG AP_Enable:1;
385 ULONG CAL_Disable:1;
386 ULONG Rsvd2:22;
387 } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
388
389 typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
390 USHORT PageSizeMask:11;
391 USHORT Rsvd1:1;
392 USHORT PageSizeSelect:4;
393 } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
394
395 typedef struct _PCI_AGP_ISOCH_COMMAND {
396 USHORT Rsvd1:6;
397 USHORT Isoch_Y:2;
398 USHORT Isoch_N:8;
399 } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
400
401 typedef struct PCI_AGP_EXTENDED_CAPABILITY {
402 PCI_AGP_ISOCH_STATUS IsochStatus;
403 PCI_AGP_CONTROL AgpControl;
404 USHORT ApertureSize;
405 PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
406 ULONG GartLow;
407 ULONG GartHigh;
408 PCI_AGP_ISOCH_COMMAND IsochCommand;
409 } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
410
411 #define PCI_AGP_RATE_1X 0x1
412 #define PCI_AGP_RATE_2X 0x2
413 #define PCI_AGP_RATE_4X 0x4
414
415 #define PCIX_MODE_CONVENTIONAL_PCI 0x0
416 #define PCIX_MODE1_66MHZ 0x1
417 #define PCIX_MODE1_100MHZ 0x2
418 #define PCIX_MODE1_133MHZ 0x3
419 #define PCIX_MODE2_266_66MHZ 0x9
420 #define PCIX_MODE2_266_100MHZ 0xA
421 #define PCIX_MODE2_266_133MHZ 0xB
422 #define PCIX_MODE2_533_66MHZ 0xD
423 #define PCIX_MODE2_533_100MHZ 0xE
424 #define PCIX_MODE2_533_133MHZ 0xF
425
426 #define PCIX_VERSION_MODE1_ONLY 0x0
427 #define PCIX_VERSION_MODE2_ECC 0x1
428 #define PCIX_VERSION_DUAL_MODE_ECC 0x2
429
430 typedef struct _PCIX_BRIDGE_CAPABILITY {
431 PCI_CAPABILITIES_HEADER Header;
432 union {
433 struct {
434 USHORT Bus64Bit:1;
435 USHORT Bus133MHzCapable:1;
436 USHORT SplitCompletionDiscarded:1;
437 USHORT UnexpectedSplitCompletion:1;
438 USHORT SplitCompletionOverrun:1;
439 USHORT SplitRequestDelayed:1;
440 USHORT BusModeFrequency:4;
441 USHORT Rsvd:2;
442 USHORT Version:2;
443 USHORT Bus266MHzCapable:1;
444 USHORT Bus533MHzCapable:1;
445 } DUMMYSTRUCTNAME;
446 USHORT AsUSHORT;
447 } SecondaryStatus;
448 union {
449 struct {
450 ULONG FunctionNumber:3;
451 ULONG DeviceNumber:5;
452 ULONG BusNumber:8;
453 ULONG Device64Bit:1;
454 ULONG Device133MHzCapable:1;
455 ULONG SplitCompletionDiscarded:1;
456 ULONG UnexpectedSplitCompletion:1;
457 ULONG SplitCompletionOverrun:1;
458 ULONG SplitRequestDelayed:1;
459 ULONG Rsvd:7;
460 ULONG DIMCapable:1;
461 ULONG Device266MHzCapable:1;
462 ULONG Device533MHzCapable:1;
463 } DUMMYSTRUCTNAME;
464 ULONG AsULONG;
465 } BridgeStatus;
466 USHORT UpstreamSplitTransactionCapacity;
467 USHORT UpstreamSplitTransactionLimit;
468 USHORT DownstreamSplitTransactionCapacity;
469 USHORT DownstreamSplitTransactionLimit;
470 union {
471 struct {
472 ULONG SelectSecondaryRegisters:1;
473 ULONG ErrorPresentInOtherBank:1;
474 ULONG AdditionalCorrectableError:1;
475 ULONG AdditionalUncorrectableError:1;
476 ULONG ErrorPhase:3;
477 ULONG ErrorCorrected:1;
478 ULONG Syndrome:8;
479 ULONG ErrorFirstCommand:4;
480 ULONG ErrorSecondCommand:4;
481 ULONG ErrorUpperAttributes:4;
482 ULONG ControlUpdateEnable:1;
483 ULONG Rsvd:1;
484 ULONG DisableSingleBitCorrection:1;
485 ULONG EccMode:1;
486 } DUMMYSTRUCTNAME;
487 ULONG AsULONG;
488 } EccControlStatus;
489 ULONG EccFirstAddress;
490 ULONG EccSecondAddress;
491 ULONG EccAttribute;
492 } PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY;
493
494 typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY {
495 PCI_CAPABILITIES_HEADER Header;
496 USHORT Reserved;
497 USHORT SubVendorID;
498 USHORT SubSystemID;
499 } PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY;
500
501 #define OSC_FIRMWARE_FAILURE 0x02
502 #define OSC_UNRECOGNIZED_UUID 0x04
503 #define OSC_UNRECOGNIZED_REVISION 0x08
504 #define OSC_CAPABILITIES_MASKED 0x10
505
506 #define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01
507
508 typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD {
509 union {
510 struct {
511 ULONG ExtendedConfigOpRegions:1;
512 ULONG ActiveStatePowerManagement:1;
513 ULONG ClockPowerManagement:1;
514 ULONG SegmentGroups:1;
515 ULONG MessageSignaledInterrupts:1;
516 ULONG WindowsHardwareErrorArchitecture:1;
517 ULONG Reserved:26;
518 } DUMMYSTRUCTNAME;
519 ULONG AsULONG;
520 } u;
521 } PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD;
522
523 typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD {
524 union {
525 struct {
526 ULONG ExpressNativeHotPlug:1;
527 ULONG ShpcNativeHotPlug:1;
528 ULONG ExpressNativePME:1;
529 ULONG ExpressAdvancedErrorReporting:1;
530 ULONG ExpressCapabilityStructure:1;
531 ULONG Reserved:27;
532 } DUMMYSTRUCTNAME;
533 ULONG AsULONG;
534 } u;
535 } PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD;
536
537 typedef enum _PCI_HARDWARE_INTERFACE {
538 PciConventional,
539 PciXMode1,
540 PciXMode2,
541 PciExpress
542 } PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE;
543
544 typedef enum {
545 BusWidth32Bits,
546 BusWidth64Bits
547 } PCI_BUS_WIDTH;
548
549 typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY {
550 PCI_HARDWARE_INTERFACE SecondaryInterface;
551 struct {
552 BOOLEAN BusCapabilitiesFound;
553 ULONG CurrentSpeedAndMode;
554 ULONG SupportedSpeedsAndModes;
555 BOOLEAN DeviceIDMessagingCapable;
556 PCI_BUS_WIDTH SecondaryBusWidth;
557 } DUMMYSTRUCTNAME;
558 PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport;
559 PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest;
560 PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted;
561 } PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY;
562
563 typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER {
564 struct {
565 USHORT CapabilityVersion:4;
566 USHORT DeviceType:4;
567 USHORT SlotImplemented:1;
568 USHORT InterruptMessageNumber:5;
569 USHORT Rsvd:2;
570 } DUMMYSTRUCTNAME;
571 USHORT AsUSHORT;
572 } PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER;
573
574 typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER {
575 struct {
576 ULONG MaxPayloadSizeSupported:3;
577 ULONG PhantomFunctionsSupported:2;
578 ULONG ExtendedTagSupported:1;
579 ULONG L0sAcceptableLatency:3;
580 ULONG L1AcceptableLatency:3;
581 ULONG Undefined:3;
582 ULONG RoleBasedErrorReporting:1;
583 ULONG Rsvd1:2;
584 ULONG CapturedSlotPowerLimit:8;
585 ULONG CapturedSlotPowerLimitScale:2;
586 ULONG Rsvd2:4;
587 } DUMMYSTRUCTNAME;
588 ULONG AsULONG;
589 } PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER;
590
591 #define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07;
592
593 typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER {
594 struct {
595 USHORT CorrectableErrorEnable:1;
596 USHORT NonFatalErrorEnable:1;
597 USHORT FatalErrorEnable:1;
598 USHORT UnsupportedRequestErrorEnable:1;
599 USHORT EnableRelaxedOrder:1;
600 USHORT MaxPayloadSize:3;
601 USHORT ExtendedTagEnable:1;
602 USHORT PhantomFunctionsEnable:1;
603 USHORT AuxPowerEnable:1;
604 USHORT NoSnoopEnable:1;
605 USHORT MaxReadRequestSize:3;
606 USHORT BridgeConfigRetryEnable:1;
607 } DUMMYSTRUCTNAME;
608 USHORT AsUSHORT;
609 } PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER;
610
611 #define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F;
612
613 typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER {
614 struct {
615 USHORT CorrectableErrorDetected:1;
616 USHORT NonFatalErrorDetected:1;
617 USHORT FatalErrorDetected:1;
618 USHORT UnsupportedRequestDetected:1;
619 USHORT AuxPowerDetected:1;
620 USHORT TransactionsPending:1;
621 USHORT Rsvd:10;
622 } DUMMYSTRUCTNAME;
623 USHORT AsUSHORT;
624 } PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER;
625
626 typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER {
627 struct {
628 ULONG MaximumLinkSpeed:4;
629 ULONG MaximumLinkWidth:6;
630 ULONG ActiveStatePMSupport:2;
631 ULONG L0sExitLatency:3;
632 ULONG L1ExitLatency:3;
633 ULONG ClockPowerManagement:1;
634 ULONG SurpriseDownErrorReportingCapable:1;
635 ULONG DataLinkLayerActiveReportingCapable:1;
636 ULONG Rsvd:3;
637 ULONG PortNumber:8;
638 } DUMMYSTRUCTNAME;
639 ULONG AsULONG;
640 } PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER;
641
642 typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER {
643 struct {
644 USHORT ActiveStatePMControl:2;
645 USHORT Rsvd1:1;
646 USHORT ReadCompletionBoundary:1;
647 USHORT LinkDisable:1;
648 USHORT RetrainLink:1;
649 USHORT CommonClockConfig:1;
650 USHORT ExtendedSynch:1;
651 USHORT EnableClockPowerManagement:1;
652 USHORT Rsvd2:7;
653 } DUMMYSTRUCTNAME;
654 USHORT AsUSHORT;
655 } PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER;
656
657 typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER {
658 struct {
659 USHORT LinkSpeed:4;
660 USHORT LinkWidth:6;
661 USHORT Undefined:1;
662 USHORT LinkTraining:1;
663 USHORT SlotClockConfig:1;
664 USHORT DataLinkLayerActive:1;
665 USHORT Rsvd:2;
666 } DUMMYSTRUCTNAME;
667 USHORT AsUSHORT;
668 } PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER;
669
670 typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER {
671 struct {
672 ULONG AttentionButtonPresent:1;
673 ULONG PowerControllerPresent:1;
674 ULONG MRLSensorPresent:1;
675 ULONG AttentionIndicatorPresent:1;
676 ULONG PowerIndicatorPresent:1;
677 ULONG HotPlugSurprise:1;
678 ULONG HotPlugCapable:1;
679 ULONG SlotPowerLimit:8;
680 ULONG SlotPowerLimitScale:2;
681 ULONG ElectromechanicalLockPresent:1;
682 ULONG NoCommandCompletedSupport:1;
683 ULONG PhysicalSlotNumber:13;
684 } DUMMYSTRUCTNAME;
685 ULONG AsULONG;
686 } PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER;
687
688 typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER {
689 struct {
690 USHORT AttentionButtonEnable:1;
691 USHORT PowerFaultDetectEnable:1;
692 USHORT MRLSensorEnable:1;
693 USHORT PresenceDetectEnable:1;
694 USHORT CommandCompletedEnable:1;
695 USHORT HotPlugInterruptEnable:1;
696 USHORT AttentionIndicatorControl:2;
697 USHORT PowerIndicatorControl:2;
698 USHORT PowerControllerControl:1;
699 USHORT ElectromechanicalLockControl:1;
700 USHORT DataLinkStateChangeEnable:1;
701 USHORT Rsvd:3;
702 } DUMMYSTRUCTNAME;
703 USHORT AsUSHORT;
704 } PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER;
705
706 #if 0 // Someone (testbot? RosBE for linux?) doesn't like too many types it seems...
707 typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER {
708 struct {
709 USHORT AttentionButtonPressed:1;
710 USHORT PowerFaultDetected:1;
711 USHORT MRLSensorChanged:1;
712 USHORT PresenceDetectChanged:1;
713 USHORT CommandCompleted:1;
714 USHORT MRLSensorState:1;
715 USHORT PresenceDetectState:1;
716 USHORT ElectromechanicalLockEngaged:1;
717 USHORT DataLinkStateChanged:1;
718 USHORT Rsvd:7;
719 } DUMMYSTRUCTNAME;
720 USHORT AsUSHORT;
721 } PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER;
722
723 typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER {
724 struct {
725 USHORT CorrectableSerrEnable:1;
726 USHORT NonFatalSerrEnable:1;
727 USHORT FatalSerrEnable:1;
728 USHORT PMEInterruptEnable:1;
729 USHORT CRSSoftwareVisibilityEnable:1;
730 USHORT Rsvd:11;
731 } DUMMYSTRUCTNAME;
732 USHORT AsUSHORT;
733 } PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER;
734
735 typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER {
736 struct {
737 USHORT CRSSoftwareVisibility:1;
738 USHORT Rsvd:15;
739 } DUMMYSTRUCTNAME;
740 USHORT AsUSHORT;
741 } PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER;
742
743 typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER {
744 struct {
745 ULONG PMERequestorId:16;
746 ULONG PMEStatus:1;
747 ULONG PMEPending:1;
748 ULONG Rsvd:14;
749 } DUMMYSTRUCTNAME;
750 ULONG AsULONG;
751 } PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER;
752
753 typedef struct _PCI_EXPRESS_CAPABILITY {
754 PCI_CAPABILITIES_HEADER Header;
755 PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities;
756 PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities;
757 PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl;
758 PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus;
759 PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities;
760 PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl;
761 PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus;
762 PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities;
763 PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl;
764 PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus;
765 PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl;
766 PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities;
767 PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus;
768 } PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY;
769
770 typedef enum {
771 MRLClosed = 0,
772 MRLOpen
773 } PCI_EXPRESS_MRL_STATE;
774
775 typedef enum {
776 SlotEmpty = 0,
777 CardPresent
778 } PCI_EXPRESS_CARD_PRESENCE;
779
780 typedef enum {
781 IndicatorOn = 1,
782 IndicatorBlink,
783 IndicatorOff
784 } PCI_EXPRESS_INDICATOR_STATE;
785
786 typedef enum {
787 PowerOn = 0,
788 PowerOff
789 } PCI_EXPRESS_POWER_STATE;
790
791 typedef enum {
792 L0sEntrySupport = 1,
793 L0sAndL1EntrySupport = 3
794 } PCI_EXPRESS_ASPM_SUPPORT;
795
796 typedef enum {
797 L0sAndL1EntryDisabled,
798 L0sEntryEnabled,
799 L1EntryEnabled,
800 L0sAndL1EntryEnabled
801 } PCI_EXPRESS_ASPM_CONTROL;
802
803 typedef enum {
804 L0s_Below64ns = 0,
805 L0s_64ns_128ns,
806 L0s_128ns_256ns,
807 L0s_256ns_512ns,
808 L0s_512ns_1us,
809 L0s_1us_2us,
810 L0s_2us_4us,
811 L0s_Above4us
812 } PCI_EXPRESS_L0s_EXIT_LATENCY;
813
814 typedef enum {
815 L1_Below1us = 0,
816 L1_1us_2us,
817 L1_2us_4us,
818 L1_4us_8us,
819 L1_8us_16us,
820 L1_16us_32us,
821 L1_32us_64us,
822 L1_Above64us
823 } PCI_EXPRESS_L1_EXIT_LATENCY;
824
825 typedef enum {
826 PciExpressEndpoint = 0,
827 PciExpressLegacyEndpoint,
828 PciExpressRootPort = 4,
829 PciExpressUpstreamSwitchPort,
830 PciExpressDownstreamSwitchPort,
831 PciExpressToPciXBridge,
832 PciXToExpressBridge,
833 PciExpressRootComplexIntegratedEndpoint,
834 PciExpressRootComplexEventCollector
835 } PCI_EXPRESS_DEVICE_TYPE;
836
837 typedef enum {
838 MaxPayload128Bytes = 0,
839 MaxPayload256Bytes,
840 MaxPayload512Bytes,
841 MaxPayload1024Bytes,
842 MaxPayload2048Bytes,
843 MaxPayload4096Bytes
844 } PCI_EXPRESS_MAX_PAYLOAD_SIZE;
845
846 typedef union _PCI_EXPRESS_PME_REQUESTOR_ID {
847 struct {
848 USHORT FunctionNumber:3;
849 USHORT DeviceNumber:5;
850 USHORT BusNumber:8;
851 } DUMMYSTRUCTNAME;
852 USHORT AsUSHORT;
853 } PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID;
854
855 #if defined(_WIN64)
856
857 #ifndef USE_DMA_MACROS
858 #define USE_DMA_MACROS
859 #endif
860
861 #ifndef NO_LEGACY_DRIVERS
862 #define NO_LEGACY_DRIVERS
863 #endif
864
865 #endif /* defined(_WIN64) */
866
867 typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE {
868 ResourceTypeSingle = 0,
869 ResourceTypeRange,
870 ResourceTypeExtendedCounterConfiguration,
871 ResourceTypeOverflow,
872 ResourceTypeMax
873 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE;
874
875 typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR {
876 PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type;
877 ULONG Flags;
878 union {
879 ULONG CounterIndex;
880 ULONG ExtendedRegisterAddress;
881 struct {
882 ULONG Begin;
883 ULONG End;
884 } Range;
885 } u;
886 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR;
887
888 typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST {
889 ULONG Count;
890 PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY];
891 } PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST;
892
893 #ifndef _PCIINTRF_X_
894 #define _PCIINTRF_X_
895
896 typedef ULONG
897 (NTAPI *PCI_READ_WRITE_CONFIG)(
898 IN PVOID Context,
899 IN ULONG BusOffset,
900 IN ULONG Slot,
901 IN PVOID Buffer,
902 IN ULONG Offset,
903 IN ULONG Length);
904
905 typedef VOID
906 (NTAPI *PCI_PIN_TO_LINE)(
907 IN PVOID Context,
908 IN PPCI_COMMON_CONFIG PciData);
909
910 typedef VOID
911 (NTAPI *PCI_LINE_TO_PIN)(
912 IN PVOID Context,
913 IN PPCI_COMMON_CONFIG PciNewData,
914 IN PPCI_COMMON_CONFIG PciOldData);
915
916 typedef VOID
917 (NTAPI *PCI_ROOT_BUS_CAPABILITY)(
918 IN PVOID Context,
919 OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability);
920
921 typedef VOID
922 (NTAPI *PCI_EXPRESS_WAKE_CONTROL)(
923 IN PVOID Context,
924 IN BOOLEAN EnableWake);
925
926 typedef struct _PCI_BUS_INTERFACE_STANDARD {
927 USHORT Size;
928 USHORT Version;
929 PVOID Context;
930 PINTERFACE_REFERENCE InterfaceReference;
931 PINTERFACE_DEREFERENCE InterfaceDereference;
932 PCI_READ_WRITE_CONFIG ReadConfig;
933 PCI_READ_WRITE_CONFIG WriteConfig;
934 PCI_PIN_TO_LINE PinToLine;
935 PCI_LINE_TO_PIN LineToPin;
936 PCI_ROOT_BUS_CAPABILITY RootBusCapability;
937 PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl;
938 } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
939
940 #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
941
942 #endif /* _PCIINTRF_X_ */
943
944 #if (NTDDI_VERSION >= NTDDI_WIN7)
945
946 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000
947 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000
948 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \
949 (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \
950 FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX)
951
952 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200
953 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300
954 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300
955
956 #else
957
958 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
959 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
960 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
961
962 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL
963 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL
964 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK
965
966 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
967
968 #endif // 0
969
970 typedef enum _HAL_QUERY_INFORMATION_CLASS {
971 HalInstalledBusInformation,
972 HalProfileSourceInformation,
973 HalInformationClassUnused1,
974 HalPowerInformation,
975 HalProcessorSpeedInformation,
976 HalCallbackInformation,
977 HalMapRegisterInformation,
978 HalMcaLogInformation,
979 HalFrameBufferCachingInformation,
980 HalDisplayBiosInformation,
981 HalProcessorFeatureInformation,
982 HalNumaTopologyInterface,
983 HalErrorInformation,
984 HalCmcLogInformation,
985 HalCpeLogInformation,
986 HalQueryMcaInterface,
987 HalQueryAMLIIllegalIOPortAddresses,
988 HalQueryMaxHotPlugMemoryAddress,
989 HalPartitionIpiInterface,
990 HalPlatformInformation,
991 HalQueryProfileSourceList,
992 HalInitLogInformation,
993 HalFrequencyInformation,
994 HalProcessorBrandString,
995 HalHypervisorInformation,
996 HalPlatformTimerInformation,
997 HalAcpiAuditInformation
998 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
999
1000 typedef enum _HAL_SET_INFORMATION_CLASS {
1001 HalProfileSourceInterval,
1002 HalProfileSourceInterruptHandler,
1003 HalMcaRegisterDriver,
1004 HalKernelErrorHandler,
1005 HalCmcRegisterDriver,
1006 HalCpeRegisterDriver,
1007 HalMcaLog,
1008 HalCmcLog,
1009 HalCpeLog,
1010 HalGenerateCmcInterrupt,
1011 HalProfileSourceTimerHandler,
1012 HalEnlightenment,
1013 HalProfileDpgoSourceInterruptHandler
1014 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
1015
1016 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
1017 KPROFILE_SOURCE Source;
1018 ULONG_PTR Interval;
1019 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
1020
1021 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
1022 KPROFILE_SOURCE Source;
1023 BOOLEAN Supported;
1024 ULONG Interval;
1025 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
1026
1027 typedef struct _MAP_REGISTER_ENTRY {
1028 PVOID MapRegister;
1029 BOOLEAN WriteToDevice;
1030 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
1031
1032 typedef struct _DEBUG_DEVICE_ADDRESS {
1033 UCHAR Type;
1034 BOOLEAN Valid;
1035 UCHAR Reserved[2];
1036 PUCHAR TranslatedAddress;
1037 ULONG Length;
1038 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
1039
1040 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
1041 PHYSICAL_ADDRESS Start;
1042 PHYSICAL_ADDRESS MaxEnd;
1043 PVOID VirtualAddress;
1044 ULONG Length;
1045 BOOLEAN Cached;
1046 BOOLEAN Aligned;
1047 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
1048
1049 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
1050 ULONG Bus;
1051 ULONG Slot;
1052 USHORT Segment;
1053 USHORT VendorID;
1054 USHORT DeviceID;
1055 UCHAR BaseClass;
1056 UCHAR SubClass;
1057 UCHAR ProgIf;
1058 BOOLEAN Initialized;
1059 BOOLEAN Configured;
1060 DEBUG_DEVICE_ADDRESS BaseAddress[6];
1061 DEBUG_MEMORY_REQUIREMENTS Memory;
1062 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
1063
1064 typedef struct _PM_DISPATCH_TABLE {
1065 ULONG Signature;
1066 ULONG Version;
1067 PVOID Function[1];
1068 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
1069
1070 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
1071 TranslateChildToParent,
1072 TranslateParentToChild
1073 } RESOURCE_TRANSLATION_DIRECTION;
1074
1075 typedef NTSTATUS
1076 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
1077 IN OUT PVOID Context,
1078 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
1079 IN RESOURCE_TRANSLATION_DIRECTION Direction,
1080 IN ULONG AlternativesCount OPTIONAL,
1081 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
1082 IN PDEVICE_OBJECT PhysicalDeviceObject,
1083 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
1084
1085 typedef NTSTATUS
1086 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
1087 IN PVOID Context OPTIONAL,
1088 IN PIO_RESOURCE_DESCRIPTOR Source,
1089 IN PDEVICE_OBJECT PhysicalDeviceObject,
1090 OUT PULONG TargetCount,
1091 OUT PIO_RESOURCE_DESCRIPTOR *Target);
1092
1093 typedef struct _TRANSLATOR_INTERFACE {
1094 USHORT Size;
1095 USHORT Version;
1096 PVOID Context;
1097 PINTERFACE_REFERENCE InterfaceReference;
1098 PINTERFACE_DEREFERENCE InterfaceDereference;
1099 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
1100 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
1101 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
1102
1103 typedef VOID
1104 (FASTCALL *pHalExamineMBR)(
1105 IN PDEVICE_OBJECT DeviceObject,
1106 IN ULONG SectorSize,
1107 IN ULONG MBRTypeIdentifier,
1108 OUT PVOID *Buffer);
1109
1110 typedef NTSTATUS
1111 (FASTCALL *pHalIoReadPartitionTable)(
1112 IN PDEVICE_OBJECT DeviceObject,
1113 IN ULONG SectorSize,
1114 IN BOOLEAN ReturnRecognizedPartitions,
1115 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
1116
1117 typedef NTSTATUS
1118 (FASTCALL *pHalIoSetPartitionInformation)(
1119 IN PDEVICE_OBJECT DeviceObject,
1120 IN ULONG SectorSize,
1121 IN ULONG PartitionNumber,
1122 IN ULONG PartitionType);
1123
1124 typedef NTSTATUS
1125 (FASTCALL *pHalIoWritePartitionTable)(
1126 IN PDEVICE_OBJECT DeviceObject,
1127 IN ULONG SectorSize,
1128 IN ULONG SectorsPerTrack,
1129 IN ULONG NumberOfHeads,
1130 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
1131
1132 typedef PBUS_HANDLER
1133 (FASTCALL *pHalHandlerForBus)(
1134 IN INTERFACE_TYPE InterfaceType,
1135 IN ULONG BusNumber);
1136
1137 typedef VOID
1138 (FASTCALL *pHalReferenceBusHandler)(
1139 IN PBUS_HANDLER BusHandler);
1140
1141 typedef NTSTATUS
1142 (NTAPI *pHalQuerySystemInformation)(
1143 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
1144 IN ULONG BufferSize,
1145 IN OUT PVOID Buffer,
1146 OUT PULONG ReturnedLength);
1147
1148 typedef NTSTATUS
1149 (NTAPI *pHalSetSystemInformation)(
1150 IN HAL_SET_INFORMATION_CLASS InformationClass,
1151 IN ULONG BufferSize,
1152 IN PVOID Buffer);
1153
1154 typedef NTSTATUS
1155 (NTAPI *pHalQueryBusSlots)(
1156 IN PBUS_HANDLER BusHandler,
1157 IN ULONG BufferSize,
1158 OUT PULONG SlotNumbers,
1159 OUT PULONG ReturnedLength);
1160
1161 typedef NTSTATUS
1162 (NTAPI *pHalInitPnpDriver)(
1163 VOID);
1164
1165 typedef NTSTATUS
1166 (NTAPI *pHalInitPowerManagement)(
1167 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
1168 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
1169
1170 typedef struct _DMA_ADAPTER*
1171 (NTAPI *pHalGetDmaAdapter)(
1172 IN PVOID Context,
1173 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
1174 OUT PULONG NumberOfMapRegisters);
1175
1176 typedef NTSTATUS
1177 (NTAPI *pHalGetInterruptTranslator)(
1178 IN INTERFACE_TYPE ParentInterfaceType,
1179 IN ULONG ParentBusNumber,
1180 IN INTERFACE_TYPE BridgeInterfaceType,
1181 IN USHORT Size,
1182 IN USHORT Version,
1183 OUT PTRANSLATOR_INTERFACE Translator,
1184 OUT PULONG BridgeBusNumber);
1185
1186 typedef NTSTATUS
1187 (NTAPI *pHalStartMirroring)(
1188 VOID);
1189
1190 typedef NTSTATUS
1191 (NTAPI *pHalEndMirroring)(
1192 IN ULONG PassNumber);
1193
1194 typedef NTSTATUS
1195 (NTAPI *pHalMirrorPhysicalMemory)(
1196 IN PHYSICAL_ADDRESS PhysicalAddress,
1197 IN LARGE_INTEGER NumberOfBytes);
1198
1199 typedef NTSTATUS
1200 (NTAPI *pHalMirrorVerify)(
1201 IN PHYSICAL_ADDRESS PhysicalAddress,
1202 IN LARGE_INTEGER NumberOfBytes);
1203
1204 typedef VOID
1205 (NTAPI *pHalEndOfBoot)(
1206 VOID);
1207
1208 typedef
1209 BOOLEAN
1210 (NTAPI *pHalTranslateBusAddress)(
1211 IN INTERFACE_TYPE InterfaceType,
1212 IN ULONG BusNumber,
1213 IN PHYSICAL_ADDRESS BusAddress,
1214 IN OUT PULONG AddressSpace,
1215 OUT PPHYSICAL_ADDRESS TranslatedAddress);
1216
1217 typedef
1218 NTSTATUS
1219 (NTAPI *pHalAssignSlotResources)(
1220 IN PUNICODE_STRING RegistryPath,
1221 IN PUNICODE_STRING DriverClassName OPTIONAL,
1222 IN PDRIVER_OBJECT DriverObject,
1223 IN PDEVICE_OBJECT DeviceObject,
1224 IN INTERFACE_TYPE BusType,
1225 IN ULONG BusNumber,
1226 IN ULONG SlotNumber,
1227 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
1228
1229 typedef
1230 VOID
1231 (NTAPI *pHalHaltSystem)(
1232 VOID);
1233
1234 typedef
1235 BOOLEAN
1236 (NTAPI *pHalResetDisplay)(
1237 VOID);
1238
1239 typedef
1240 UCHAR
1241 (NTAPI *pHalVectorToIDTEntry)(
1242 ULONG Vector);
1243
1244 typedef
1245 BOOLEAN
1246 (NTAPI *pHalFindBusAddressTranslation)(
1247 IN PHYSICAL_ADDRESS BusAddress,
1248 IN OUT PULONG AddressSpace,
1249 OUT PPHYSICAL_ADDRESS TranslatedAddress,
1250 IN OUT PULONG_PTR Context,
1251 IN BOOLEAN NextBus);
1252
1253 typedef
1254 NTSTATUS
1255 (NTAPI *pKdSetupPciDeviceForDebugging)(
1256 IN PVOID LoaderBlock OPTIONAL,
1257 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
1258
1259 typedef
1260 NTSTATUS
1261 (NTAPI *pKdReleasePciDeviceForDebugging)(
1262 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
1263
1264 typedef
1265 PVOID
1266 (NTAPI *pKdGetAcpiTablePhase0)(
1267 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1268 IN ULONG Signature);
1269
1270 typedef
1271 PVOID
1272 (NTAPI *pHalGetAcpiTable)(
1273 IN ULONG Signature,
1274 IN PCSTR OemId OPTIONAL,
1275 IN PCSTR OemTableId OPTIONAL);
1276
1277 typedef
1278 VOID
1279 (NTAPI *pKdCheckPowerButton)(
1280 VOID);
1281
1282 #if (NTDDI_VERSION >= NTDDI_VISTA)
1283 typedef
1284 PVOID
1285 (NTAPI *pKdMapPhysicalMemory64)(
1286 IN PHYSICAL_ADDRESS PhysicalAddress,
1287 IN ULONG NumberPages,
1288 IN BOOLEAN FlushCurrentTLB);
1289
1290 typedef
1291 VOID
1292 (NTAPI *pKdUnmapVirtualAddress)(
1293 IN PVOID VirtualAddress,
1294 IN ULONG NumberPages,
1295 IN BOOLEAN FlushCurrentTLB);
1296 #else
1297 typedef
1298 PVOID
1299 (NTAPI *pKdMapPhysicalMemory64)(
1300 IN PHYSICAL_ADDRESS PhysicalAddress,
1301 IN ULONG NumberPages);
1302
1303 typedef
1304 VOID
1305 (NTAPI *pKdUnmapVirtualAddress)(
1306 IN PVOID VirtualAddress,
1307 IN ULONG NumberPages);
1308 #endif
1309
1310
1311 typedef
1312 ULONG
1313 (NTAPI *pKdGetPciDataByOffset)(
1314 IN ULONG BusNumber,
1315 IN ULONG SlotNumber,
1316 OUT PVOID Buffer,
1317 IN ULONG Offset,
1318 IN ULONG Length);
1319
1320 typedef
1321 ULONG
1322 (NTAPI *pKdSetPciDataByOffset)(
1323 IN ULONG BusNumber,
1324 IN ULONG SlotNumber,
1325 IN PVOID Buffer,
1326 IN ULONG Offset,
1327 IN ULONG Length);
1328
1329 typedef BOOLEAN
1330 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1331 IN ULONG Columns,
1332 IN ULONG Rows);
1333
1334 typedef
1335 VOID
1336 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
1337 VOID);
1338
1339 typedef
1340 VOID
1341 (NTAPI *pHalSetPciErrorHandlerCallback)(
1342 IN PCI_ERROR_HANDLER_CALLBACK Callback);
1343
1344 #if 1 /* Not present in WDK 7600 */
1345 typedef VOID
1346 (FASTCALL *pHalIoAssignDriveLetters)(
1347 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1348 IN PSTRING NtDeviceName,
1349 OUT PUCHAR NtSystemPath,
1350 OUT PSTRING NtSystemPathString);
1351 #endif
1352
1353 typedef struct {
1354 ULONG Version;
1355 pHalQuerySystemInformation HalQuerySystemInformation;
1356 pHalSetSystemInformation HalSetSystemInformation;
1357 pHalQueryBusSlots HalQueryBusSlots;
1358 ULONG Spare1;
1359 pHalExamineMBR HalExamineMBR;
1360 #if 1 /* Not present in WDK 7600 */
1361 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1362 #endif
1363 pHalIoReadPartitionTable HalIoReadPartitionTable;
1364 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1365 pHalIoWritePartitionTable HalIoWritePartitionTable;
1366 pHalHandlerForBus HalReferenceHandlerForBus;
1367 pHalReferenceBusHandler HalReferenceBusHandler;
1368 pHalReferenceBusHandler HalDereferenceBusHandler;
1369 pHalInitPnpDriver HalInitPnpDriver;
1370 pHalInitPowerManagement HalInitPowerManagement;
1371 pHalGetDmaAdapter HalGetDmaAdapter;
1372 pHalGetInterruptTranslator HalGetInterruptTranslator;
1373 pHalStartMirroring HalStartMirroring;
1374 pHalEndMirroring HalEndMirroring;
1375 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1376 pHalEndOfBoot HalEndOfBoot;
1377 pHalMirrorVerify HalMirrorVerify;
1378 pHalGetAcpiTable HalGetCachedAcpiTable;
1379 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
1380 #if defined(_IA64_)
1381 pHalGetErrorCapList HalGetErrorCapList;
1382 pHalInjectError HalInjectError;
1383 #endif
1384 } HAL_DISPATCH, *PHAL_DISPATCH;
1385
1386 /* GCC/MSVC and WDK compatible declaration */
1387 extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
1388
1389 #if defined(_NTOSKRNL_) || defined(_BLDR_)
1390 #define HALDISPATCH (&HalDispatchTable)
1391 #else
1392 /* This is a WDK compatibility definition */
1393 #define HalDispatchTable (&HalDispatchTable)
1394 #define HALDISPATCH HalDispatchTable
1395 #endif
1396
1397 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
1398 #define HalDispatchTableVersion HALDISPATCH->Version
1399 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1400 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1401 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1402 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1403 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1404 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1405 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1406 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1407 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1408 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1409 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1410 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1411 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1412 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1413 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1414
1415 typedef struct _FILE_ALIGNMENT_INFORMATION {
1416 ULONG AlignmentRequirement;
1417 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1418
1419 typedef struct _FILE_NAME_INFORMATION {
1420 ULONG FileNameLength;
1421 WCHAR FileName[1];
1422 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1423
1424
1425 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1426 ULONG FileAttributes;
1427 ULONG ReparseTag;
1428 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1429
1430 typedef struct _FILE_DISPOSITION_INFORMATION {
1431 BOOLEAN DeleteFile;
1432 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1433
1434 typedef struct _FILE_END_OF_FILE_INFORMATION {
1435 LARGE_INTEGER EndOfFile;
1436 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1437
1438 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1439 LARGE_INTEGER ValidDataLength;
1440 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1441
1442 typedef union _FILE_SEGMENT_ELEMENT {
1443 PVOID64 Buffer;
1444 ULONGLONG Alignment;
1445 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1446
1447 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
1448
1449 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1450 NTSYSAPI
1451 ULONGLONG
1452 NTAPI
1453 VerSetConditionMask(
1454 IN ULONGLONG ConditionMask,
1455 IN ULONG TypeMask,
1456 IN UCHAR Condition);
1457 #endif
1458
1459 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
1460 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
1461 (TypeBitMask), (ComparisonType)))
1462
1463 /* RtlVerifyVersionInfo() TypeMask */
1464
1465 #define VER_MINORVERSION 0x0000001
1466 #define VER_MAJORVERSION 0x0000002
1467 #define VER_BUILDNUMBER 0x0000004
1468 #define VER_PLATFORMID 0x0000008
1469 #define VER_SERVICEPACKMINOR 0x0000010
1470 #define VER_SERVICEPACKMAJOR 0x0000020
1471 #define VER_SUITENAME 0x0000040
1472 #define VER_PRODUCT_TYPE 0x0000080
1473
1474 /* RtlVerifyVersionInfo() ComparisonType */
1475
1476 #define VER_EQUAL 1
1477 #define VER_GREATER 2
1478 #define VER_GREATER_EQUAL 3
1479 #define VER_LESS 4
1480 #define VER_LESS_EQUAL 5
1481 #define VER_AND 6
1482 #define VER_OR 7
1483
1484 #define VER_CONDITION_MASK 7
1485 #define VER_NUM_BITS_PER_CONDITION_MASK 3
1486
1487 typedef struct _IMAGE_INFO {
1488 _ANONYMOUS_UNION union {
1489 ULONG Properties;
1490 _ANONYMOUS_STRUCT struct {
1491 ULONG ImageAddressingMode:8;
1492 ULONG SystemModeImage:1;
1493 ULONG ImageMappedToAllPids:1;
1494 ULONG ExtendedInfoPresent:1;
1495 ULONG Reserved:22;
1496 } DUMMYSTRUCTNAME;
1497 } DUMMYUNIONNAME;
1498 PVOID ImageBase;
1499 ULONG ImageSelector;
1500 SIZE_T ImageSize;
1501 ULONG ImageSectionNumber;
1502 } IMAGE_INFO, *PIMAGE_INFO;
1503
1504 #define IMAGE_ADDRESSING_MODE_32BIT 3
1505
1506 typedef enum _BUS_DATA_TYPE {
1507 ConfigurationSpaceUndefined = -1,
1508 Cmos,
1509 EisaConfiguration,
1510 Pos,
1511 CbusConfiguration,
1512 PCIConfiguration,
1513 VMEConfiguration,
1514 NuBusConfiguration,
1515 PCMCIAConfiguration,
1516 MPIConfiguration,
1517 MPSAConfiguration,
1518 PNPISAConfiguration,
1519 SgiInternalConfiguration,
1520 MaximumBusDataType
1521 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1522
1523 typedef struct _NT_TIB {
1524 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1525 PVOID StackBase;
1526 PVOID StackLimit;
1527 PVOID SubSystemTib;
1528 _ANONYMOUS_UNION union {
1529 PVOID FiberData;
1530 ULONG Version;
1531 } DUMMYUNIONNAME;
1532 PVOID ArbitraryUserPointer;
1533 struct _NT_TIB *Self;
1534 } NT_TIB, *PNT_TIB;
1535
1536 typedef struct _NT_TIB32 {
1537 ULONG ExceptionList;
1538 ULONG StackBase;
1539 ULONG StackLimit;
1540 ULONG SubSystemTib;
1541 __GNU_EXTENSION union {
1542 ULONG FiberData;
1543 ULONG Version;
1544 };
1545 ULONG ArbitraryUserPointer;
1546 ULONG Self;
1547 } NT_TIB32,*PNT_TIB32;
1548
1549 typedef struct _NT_TIB64 {
1550 ULONG64 ExceptionList;
1551 ULONG64 StackBase;
1552 ULONG64 StackLimit;
1553 ULONG64 SubSystemTib;
1554 __GNU_EXTENSION union {
1555 ULONG64 FiberData;
1556 ULONG Version;
1557 };
1558 ULONG64 ArbitraryUserPointer;
1559 ULONG64 Self;
1560 } NT_TIB64,*PNT_TIB64;
1561
1562 typedef enum _PROCESSINFOCLASS {
1563 ProcessBasicInformation,
1564 ProcessQuotaLimits,
1565 ProcessIoCounters,
1566 ProcessVmCounters,
1567 ProcessTimes,
1568 ProcessBasePriority,
1569 ProcessRaisePriority,
1570 ProcessDebugPort,
1571 ProcessExceptionPort,
1572 ProcessAccessToken,
1573 ProcessLdtInformation,
1574 ProcessLdtSize,
1575 ProcessDefaultHardErrorMode,
1576 ProcessIoPortHandlers,
1577 ProcessPooledUsageAndLimits,
1578 ProcessWorkingSetWatch,
1579 ProcessUserModeIOPL,
1580 ProcessEnableAlignmentFaultFixup,
1581 ProcessPriorityClass,
1582 ProcessWx86Information,
1583 ProcessHandleCount,
1584 ProcessAffinityMask,
1585 ProcessPriorityBoost,
1586 ProcessDeviceMap,
1587 ProcessSessionInformation,
1588 ProcessForegroundInformation,
1589 ProcessWow64Information,
1590 ProcessImageFileName,
1591 ProcessLUIDDeviceMapsEnabled,
1592 ProcessBreakOnTermination,
1593 ProcessDebugObjectHandle,
1594 ProcessDebugFlags,
1595 ProcessHandleTracing,
1596 ProcessIoPriority,
1597 ProcessExecuteFlags,
1598 ProcessTlsInformation,
1599 ProcessCookie,
1600 ProcessImageInformation,
1601 ProcessCycleTime,
1602 ProcessPagePriority,
1603 ProcessInstrumentationCallback,
1604 ProcessThreadStackAllocation,
1605 ProcessWorkingSetWatchEx,
1606 ProcessImageFileNameWin32,
1607 ProcessImageFileMapping,
1608 ProcessAffinityUpdateMode,
1609 ProcessMemoryAllocationMode,
1610 ProcessGroupInformation,
1611 ProcessTokenVirtualizationEnabled,
1612 ProcessConsoleHostProcess,
1613 ProcessWindowInformation,
1614 MaxProcessInfoClass
1615 } PROCESSINFOCLASS;
1616
1617 typedef enum _THREADINFOCLASS {
1618 ThreadBasicInformation,
1619 ThreadTimes,
1620 ThreadPriority,
1621 ThreadBasePriority,
1622 ThreadAffinityMask,
1623 ThreadImpersonationToken,
1624 ThreadDescriptorTableEntry,
1625 ThreadEnableAlignmentFaultFixup,
1626 ThreadEventPair_Reusable,
1627 ThreadQuerySetWin32StartAddress,
1628 ThreadZeroTlsCell,
1629 ThreadPerformanceCount,
1630 ThreadAmILastThread,
1631 ThreadIdealProcessor,
1632 ThreadPriorityBoost,
1633 ThreadSetTlsArrayAddress,
1634 ThreadIsIoPending,
1635 ThreadHideFromDebugger,
1636 ThreadBreakOnTermination,
1637 ThreadSwitchLegacyState,
1638 ThreadIsTerminated,
1639 ThreadLastSystemCall,
1640 ThreadIoPriority,
1641 ThreadCycleTime,
1642 ThreadPagePriority,
1643 ThreadActualBasePriority,
1644 ThreadTebInformation,
1645 ThreadCSwitchMon,
1646 ThreadCSwitchPmu,
1647 ThreadWow64Context,
1648 ThreadGroupInformation,
1649 ThreadUmsInformation,
1650 ThreadCounterProfiling,
1651 ThreadIdealProcessorEx,
1652 MaxThreadInfoClass
1653 } THREADINFOCLASS;
1654
1655 typedef struct _PROCESS_BASIC_INFORMATION {
1656 NTSTATUS ExitStatus;
1657 struct _PEB *PebBaseAddress;
1658 ULONG_PTR AffinityMask;
1659 KPRIORITY BasePriority;
1660 ULONG_PTR UniqueProcessId;
1661 ULONG_PTR InheritedFromUniqueProcessId;
1662 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1663
1664 typedef struct _PROCESS_WS_WATCH_INFORMATION {
1665 PVOID FaultingPc;
1666 PVOID FaultingVa;
1667 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1668
1669 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
1670 __GNU_EXTENSION union {
1671 struct {
1672 HANDLE DirectoryHandle;
1673 } Set;
1674 struct {
1675 ULONG DriveMap;
1676 UCHAR DriveType[32];
1677 } Query;
1678 };
1679 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1680
1681 typedef struct _KERNEL_USER_TIMES {
1682 LARGE_INTEGER CreateTime;
1683 LARGE_INTEGER ExitTime;
1684 LARGE_INTEGER KernelTime;
1685 LARGE_INTEGER UserTime;
1686 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1687
1688 typedef struct _PROCESS_ACCESS_TOKEN {
1689 HANDLE Token;
1690 HANDLE Thread;
1691 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1692
1693 typedef struct _PROCESS_SESSION_INFORMATION {
1694 ULONG SessionId;
1695 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1696
1697 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
1698 IoQueryDeviceIdentifier = 0,
1699 IoQueryDeviceConfigurationData,
1700 IoQueryDeviceComponentInformation,
1701 IoQueryDeviceMaxData
1702 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
1703
1704 typedef struct _DISK_SIGNATURE {
1705 ULONG PartitionStyle;
1706 _ANONYMOUS_UNION union {
1707 struct {
1708 ULONG Signature;
1709 ULONG CheckSum;
1710 } Mbr;
1711 struct {
1712 GUID DiskId;
1713 } Gpt;
1714 } DUMMYUNIONNAME;
1715 } DISK_SIGNATURE, *PDISK_SIGNATURE;
1716
1717 typedef ULONG_PTR
1718 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
1719 IN PVOID Context);
1720
1721 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
1722 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
1723 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
1724 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
1725
1726 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
1727 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
1728 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
1729 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
1730 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
1731
1732 typedef VOID
1733 (NTAPI *PTIMER_APC_ROUTINE)(
1734 IN PVOID TimerContext,
1735 IN ULONG TimerLowValue,
1736 IN LONG TimerHighValue);
1737
1738 typedef struct _KUSER_SHARED_DATA
1739 {
1740 ULONG TickCountLowDeprecated;
1741 ULONG TickCountMultiplier;
1742 volatile KSYSTEM_TIME InterruptTime;
1743 volatile KSYSTEM_TIME SystemTime;
1744 volatile KSYSTEM_TIME TimeZoneBias;
1745 USHORT ImageNumberLow;
1746 USHORT ImageNumberHigh;
1747 WCHAR NtSystemRoot[260];
1748 ULONG MaxStackTraceDepth;
1749 ULONG CryptoExponent;
1750 ULONG TimeZoneId;
1751 ULONG LargePageMinimum;
1752 ULONG Reserved2[7];
1753 NT_PRODUCT_TYPE NtProductType;
1754 BOOLEAN ProductTypeIsValid;
1755 ULONG NtMajorVersion;
1756 ULONG NtMinorVersion;
1757 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1758 ULONG Reserved1;
1759 ULONG Reserved3;
1760 volatile ULONG TimeSlip;
1761 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1762 ULONG AltArchitecturePad[1];
1763 LARGE_INTEGER SystemExpirationDate;
1764 ULONG SuiteMask;
1765 BOOLEAN KdDebuggerEnabled;
1766 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1767 UCHAR NXSupportPolicy;
1768 #endif
1769 volatile ULONG ActiveConsoleId;
1770 volatile ULONG DismountCount;
1771 ULONG ComPlusPackage;
1772 ULONG LastSystemRITEventTickCount;
1773 ULONG NumberOfPhysicalPages;
1774 BOOLEAN SafeBootMode;
1775 #if (NTDDI_VERSION >= NTDDI_WIN7)
1776 union {
1777 UCHAR TscQpcData;
1778 struct {
1779 UCHAR TscQpcEnabled:1;
1780 UCHAR TscQpcSpareFlag:1;
1781 UCHAR TscQpcShift:6;
1782 } DUMMYSTRUCTNAME;
1783 } DUMMYUNIONNAME;
1784 UCHAR TscQpcPad[2];
1785 #endif
1786 #if (NTDDI_VERSION >= NTDDI_VISTA)
1787 union {
1788 ULONG SharedDataFlags;
1789 struct {
1790 ULONG DbgErrorPortPresent:1;
1791 ULONG DbgElevationEnabled:1;
1792 ULONG DbgVirtEnabled:1;
1793 ULONG DbgInstallerDetectEnabled:1;
1794 ULONG DbgSystemDllRelocated:1;
1795 ULONG DbgDynProcessorEnabled:1;
1796 ULONG DbgSEHValidationEnabled:1;
1797 ULONG SpareBits:25;
1798 } DUMMYSTRUCTNAME2;
1799 } DUMMYUNIONNAME2;
1800 #else
1801 ULONG TraceLogging;
1802 #endif
1803 ULONG DataFlagsPad[1];
1804 ULONGLONG TestRetInstruction;
1805 ULONG SystemCall;
1806 ULONG SystemCallReturn;
1807 ULONGLONG SystemCallPad[3];
1808 _ANONYMOUS_UNION union {
1809 volatile KSYSTEM_TIME TickCount;
1810 volatile ULONG64 TickCountQuad;
1811 _ANONYMOUS_STRUCT struct {
1812 ULONG ReservedTickCountOverlay[3];
1813 ULONG TickCountPad[1];
1814 } DUMMYSTRUCTNAME;
1815 } DUMMYUNIONNAME3;
1816 ULONG Cookie;
1817 ULONG CookiePad[1];
1818 #if (NTDDI_VERSION >= NTDDI_WS03)
1819 LONGLONG ConsoleSessionForegroundProcessId;
1820 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
1821 #endif
1822 #if (NTDDI_VERSION >= NTDDI_VISTA)
1823 #if (NTDDI_VERSION >= NTDDI_WIN7)
1824 USHORT UserModeGlobalLogger[16];
1825 #else
1826 USHORT UserModeGlobalLogger[8];
1827 ULONG HeapTracingPid[2];
1828 ULONG CritSecTracingPid[2];
1829 #endif
1830 ULONG ImageFileExecutionOptions;
1831 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1832 ULONG LangGenerationCount;
1833 #else
1834 /* 4 bytes padding */
1835 #endif
1836 ULONGLONG Reserved5;
1837 volatile ULONG64 InterruptTimeBias;
1838 #endif
1839 #if (NTDDI_VERSION >= NTDDI_WIN7)
1840 volatile ULONG64 TscQpcBias;
1841 volatile ULONG ActiveProcessorCount;
1842 volatile USHORT ActiveGroupCount;
1843 USHORT Reserved4;
1844 volatile ULONG AitSamplingValue;
1845 volatile ULONG AppCompatFlag;
1846 ULONGLONG SystemDllNativeRelocation;
1847 ULONG SystemDllWowRelocation;
1848 ULONG XStatePad[1];
1849 XSTATE_CONFIGURATION XState;
1850 #endif
1851 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
1852
1853 extern NTKERNELAPI PVOID MmHighestUserAddress;
1854 extern NTKERNELAPI PVOID MmSystemRangeStart;
1855 extern NTKERNELAPI ULONG MmUserProbeAddress;
1856
1857
1858 #ifdef _X86_
1859
1860 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
1861 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
1862 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
1863 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
1864 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
1865 #else
1866 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
1867 #endif
1868 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
1869 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
1870 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
1871 #if !defined (_X86PAE_)
1872 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
1873 #else
1874 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
1875 #endif
1876
1877 #define KeGetPcr() PCR
1878
1879 #define KERNEL_STACK_SIZE 12288
1880 #define KERNEL_LARGE_STACK_SIZE 61440
1881 #define KERNEL_LARGE_STACK_COMMIT 12288
1882
1883 #define SIZE_OF_80387_REGISTERS 80
1884
1885 #define PCR_MINOR_VERSION 1
1886 #define PCR_MAJOR_VERSION 1
1887
1888 #if !defined(RC_INVOKED)
1889
1890 #define CONTEXT_i386 0x10000
1891 #define CONTEXT_i486 0x10000
1892 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
1893 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
1894 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
1895 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
1896 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
1897 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
1898
1899 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
1900
1901 #endif /* !defined(RC_INVOKED) */
1902
1903 typedef struct _KPCR {
1904 union {
1905 NT_TIB NtTib;
1906 struct {
1907 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
1908 PVOID Used_StackBase;
1909 PVOID Spare2;
1910 PVOID TssCopy;
1911 ULONG ContextSwitches;
1912 KAFFINITY SetMemberCopy;
1913 PVOID Used_Self;
1914 };
1915 };
1916 struct _KPCR *SelfPcr;
1917 struct _KPRCB *Prcb;
1918 KIRQL Irql;
1919 ULONG IRR;
1920 ULONG IrrActive;
1921 ULONG IDR;
1922 PVOID KdVersionBlock;
1923 struct _KIDTENTRY *IDT;
1924 struct _KGDTENTRY *GDT;
1925 struct _KTSS *TSS;
1926 USHORT MajorVersion;
1927 USHORT MinorVersion;
1928 KAFFINITY SetMember;
1929 ULONG StallScaleFactor;
1930 UCHAR SpareUnused;
1931 UCHAR Number;
1932 UCHAR Spare0;
1933 UCHAR SecondLevelCacheAssociativity;
1934 ULONG VdmAlert;
1935 ULONG KernelReserved[14];
1936 ULONG SecondLevelCacheSize;
1937 ULONG HalReserved[16];
1938 } KPCR, *PKPCR;
1939
1940 FORCEINLINE
1941 ULONG
1942 KeGetCurrentProcessorNumber(VOID)
1943 {
1944 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
1945 }
1946
1947 typedef struct _FLOATING_SAVE_AREA {
1948 ULONG ControlWord;
1949 ULONG StatusWord;
1950 ULONG TagWord;
1951 ULONG ErrorOffset;
1952 ULONG ErrorSelector;
1953 ULONG DataOffset;
1954 ULONG DataSelector;
1955 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
1956 ULONG Cr0NpxState;
1957 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1958
1959 #include "pshpack4.h"
1960 typedef struct _CONTEXT {
1961 ULONG ContextFlags;
1962 ULONG Dr0;
1963 ULONG Dr1;
1964 ULONG Dr2;
1965 ULONG Dr3;
1966 ULONG Dr6;
1967 ULONG Dr7;
1968 FLOATING_SAVE_AREA FloatSave;
1969 ULONG SegGs;
1970 ULONG SegFs;
1971 ULONG SegEs;
1972 ULONG SegDs;
1973 ULONG Edi;
1974 ULONG Esi;
1975 ULONG Ebx;
1976 ULONG Edx;
1977 ULONG Ecx;
1978 ULONG Eax;
1979 ULONG Ebp;
1980 ULONG Eip;
1981 ULONG SegCs;
1982 ULONG EFlags;
1983 ULONG Esp;
1984 ULONG SegSs;
1985 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
1986 } CONTEXT;
1987 #include "poppack.h"
1988
1989 #endif /* _X86_ */
1990
1991 #ifdef _AMD64_
1992
1993 #define PTI_SHIFT 12L
1994 #define PDI_SHIFT 21L
1995 #define PPI_SHIFT 30L
1996 #define PXI_SHIFT 39L
1997 #define PTE_PER_PAGE 512
1998 #define PDE_PER_PAGE 512
1999 #define PPE_PER_PAGE 512
2000 #define PXE_PER_PAGE 512
2001 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
2002 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
2003 #define PPI_MASK (PPE_PER_PAGE - 1)
2004 #define PXI_MASK (PXE_PER_PAGE - 1)
2005
2006 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
2007 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
2008 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
2009 #define PDE_BASE 0xFFFFF6FB40000000ULL
2010 #define PTE_BASE 0xFFFFF68000000000ULL
2011 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
2012 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
2013 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
2014 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
2015
2016 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2017 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2018 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2019 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2020 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
2021 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
2022
2023 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
2024 ULONG64 P1Home;
2025 ULONG64 P2Home;
2026 ULONG64 P3Home;
2027 ULONG64 P4Home;
2028 ULONG64 P5Home;
2029 ULONG64 P6Home;
2030
2031 /* Control flags */
2032 ULONG ContextFlags;
2033 ULONG MxCsr;
2034
2035 /* Segment */
2036 USHORT SegCs;
2037 USHORT SegDs;
2038 USHORT SegEs;
2039 USHORT SegFs;
2040 USHORT SegGs;
2041 USHORT SegSs;
2042 ULONG EFlags;
2043
2044 /* Debug */
2045 ULONG64 Dr0;
2046 ULONG64 Dr1;
2047 ULONG64 Dr2;
2048 ULONG64 Dr3;
2049 ULONG64 Dr6;
2050 ULONG64 Dr7;
2051
2052 /* Integer */
2053 ULONG64 Rax;
2054 ULONG64 Rcx;
2055 ULONG64 Rdx;
2056 ULONG64 Rbx;
2057 ULONG64 Rsp;
2058 ULONG64 Rbp;
2059 ULONG64 Rsi;
2060 ULONG64 Rdi;
2061 ULONG64 R8;
2062 ULONG64 R9;
2063 ULONG64 R10;
2064 ULONG64 R11;
2065 ULONG64 R12;
2066 ULONG64 R13;
2067 ULONG64 R14;
2068 ULONG64 R15;
2069
2070 /* Counter */
2071 ULONG64 Rip;
2072
2073 /* Floating point */
2074 union {
2075 XMM_SAVE_AREA32 FltSave;
2076 struct {
2077 M128A Header[2];
2078 M128A Legacy[8];
2079 M128A Xmm0;
2080 M128A Xmm1;
2081 M128A Xmm2;
2082 M128A Xmm3;
2083 M128A Xmm4;
2084 M128A Xmm5;
2085 M128A Xmm6;
2086 M128A Xmm7;
2087 M128A Xmm8;
2088 M128A Xmm9;
2089 M128A Xmm10;
2090 M128A Xmm11;
2091 M128A Xmm12;
2092 M128A Xmm13;
2093 M128A Xmm14;
2094 M128A Xmm15;
2095 } DUMMYSTRUCTNAME;
2096 } DUMMYUNIONNAME;
2097
2098 /* Vector */
2099 M128A VectorRegister[26];
2100 ULONG64 VectorControl;
2101
2102 /* Debug control */
2103 ULONG64 DebugControl;
2104 ULONG64 LastBranchToRip;
2105 ULONG64 LastBranchFromRip;
2106 ULONG64 LastExceptionToRip;
2107 ULONG64 LastExceptionFromRip;
2108 } CONTEXT;
2109
2110 typedef struct _KPCR
2111 {
2112 _ANONYMOUS_UNION union
2113 {
2114 NT_TIB NtTib;
2115 _ANONYMOUS_STRUCT struct
2116 {
2117 union _KGDTENTRY64 *GdtBase;
2118 struct _KTSS64 *TssBase;
2119 ULONG64 UserRsp;
2120 struct _KPCR *Self;
2121 struct _KPRCB *CurrentPrcb;
2122 PKSPIN_LOCK_QUEUE LockArray;
2123 PVOID Used_Self;
2124 };
2125 };
2126 union _KIDTENTRY64 *IdtBase;
2127 ULONG64 Unused[2];
2128 KIRQL Irql;
2129 UCHAR SecondLevelCacheAssociativity;
2130 UCHAR ObsoleteNumber;
2131 UCHAR Fill0;
2132 ULONG Unused0[3];
2133 USHORT MajorVersion;
2134 USHORT MinorVersion;
2135 ULONG StallScaleFactor;
2136 PVOID Unused1[3];
2137 ULONG KernelReserved[15];
2138 ULONG SecondLevelCacheSize;
2139 ULONG HalReserved[16];
2140 ULONG Unused2;
2141 PVOID KdVersionBlock;
2142 PVOID Unused3;
2143 ULONG PcrAlign1[24];
2144 } KPCR, *PKPCR;
2145
2146 FORCEINLINE
2147 PKPCR
2148 KeGetPcr(VOID)
2149 {
2150 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
2151 }
2152
2153 FORCEINLINE
2154 ULONG
2155 KeGetCurrentProcessorNumber(VOID)
2156 {
2157 return (ULONG)__readgsword(0x184);
2158 }
2159
2160 #if !defined(RC_INVOKED)
2161
2162 #define CONTEXT_AMD64 0x100000
2163
2164 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
2165 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
2166 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
2167 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
2168 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
2169
2170 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2171 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2172
2173 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
2174
2175 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2176 #define CONTEXT_SERVICE_ACTIVE 0x10000000
2177 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2178 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2179
2180 #endif /* RC_INVOKED */
2181
2182 #endif /* _AMD64_ */
2183
2184 typedef enum _INTERLOCKED_RESULT {
2185 ResultNegative = RESULT_NEGATIVE,
2186 ResultZero = RESULT_ZERO,
2187 ResultPositive = RESULT_POSITIVE
2188 } INTERLOCKED_RESULT;
2189
2190 typedef struct _OSVERSIONINFOA {
2191 ULONG dwOSVersionInfoSize;
2192 ULONG dwMajorVersion;
2193 ULONG dwMinorVersion;
2194 ULONG dwBuildNumber;
2195 ULONG dwPlatformId;
2196 CHAR szCSDVersion[128];
2197 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2198
2199 typedef struct _OSVERSIONINFOW {
2200 ULONG dwOSVersionInfoSize;
2201 ULONG dwMajorVersion;
2202 ULONG dwMinorVersion;
2203 ULONG dwBuildNumber;
2204 ULONG dwPlatformId;
2205 WCHAR szCSDVersion[128];
2206 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2207
2208 typedef struct _OSVERSIONINFOEXA {
2209 ULONG dwOSVersionInfoSize;
2210 ULONG dwMajorVersion;
2211 ULONG dwMinorVersion;
2212 ULONG dwBuildNumber;
2213 ULONG dwPlatformId;
2214 CHAR szCSDVersion[128];
2215 USHORT wServicePackMajor;
2216 USHORT wServicePackMinor;
2217 USHORT wSuiteMask;
2218 UCHAR wProductType;
2219 UCHAR wReserved;
2220 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2221
2222 typedef struct _OSVERSIONINFOEXW {
2223 ULONG dwOSVersionInfoSize;
2224 ULONG dwMajorVersion;
2225 ULONG dwMinorVersion;
2226 ULONG dwBuildNumber;
2227 ULONG dwPlatformId;
2228 WCHAR szCSDVersion[128];
2229 USHORT wServicePackMajor;
2230 USHORT wServicePackMinor;
2231 USHORT wSuiteMask;
2232 UCHAR wProductType;
2233 UCHAR wReserved;
2234 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2235
2236 #ifdef UNICODE
2237 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2238 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2239 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2240 typedef OSVERSIONINFOW OSVERSIONINFO;
2241 typedef POSVERSIONINFOW POSVERSIONINFO;
2242 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2243 #else
2244 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2245 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2246 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2247 typedef OSVERSIONINFOA OSVERSIONINFO;
2248 typedef POSVERSIONINFOA POSVERSIONINFO;
2249 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2250 #endif /* UNICODE */
2251
2252 /* Executive Types */
2253
2254 #define PROTECTED_POOL 0x80000000
2255
2256 typedef struct _ZONE_SEGMENT_HEADER {
2257 SINGLE_LIST_ENTRY SegmentList;
2258 PVOID Reserved;
2259 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2260
2261 typedef struct _ZONE_HEADER {
2262 SINGLE_LIST_ENTRY FreeList;
2263 SINGLE_LIST_ENTRY SegmentList;
2264 ULONG BlockSize;
2265 ULONG TotalSegmentSize;
2266 } ZONE_HEADER, *PZONE_HEADER;
2267
2268 /* Executive Functions */
2269
2270 static __inline PVOID
2271 ExAllocateFromZone(
2272 IN PZONE_HEADER Zone)
2273 {
2274 if (Zone->FreeList.Next)
2275 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2276 return (PVOID) Zone->FreeList.Next;
2277 }
2278
2279 static __inline PVOID
2280 ExFreeToZone(
2281 IN PZONE_HEADER Zone,
2282 IN PVOID Block)
2283 {
2284 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2285 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2286 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2287 }
2288
2289 /*
2290 * PVOID
2291 * ExInterlockedAllocateFromZone(
2292 * IN PZONE_HEADER Zone,
2293 * IN PKSPIN_LOCK Lock)
2294 */
2295 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2296 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2297
2298 /* PVOID
2299 * ExInterlockedFreeToZone(
2300 * IN PZONE_HEADER Zone,
2301 * IN PVOID Block,
2302 * IN PKSPIN_LOCK Lock);
2303 */
2304 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2305 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2306
2307 /*
2308 * BOOLEAN
2309 * ExIsFullZone(
2310 * IN PZONE_HEADER Zone)
2311 */
2312 #define ExIsFullZone(Zone) \
2313 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2314
2315 /* BOOLEAN
2316 * ExIsObjectInFirstZoneSegment(
2317 * IN PZONE_HEADER Zone,
2318 * IN PVOID Object);
2319 */
2320 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2321 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2322 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2323 (Zone)->TotalSegmentSize)) )
2324
2325 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2326 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2327 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2328 #define ExDeleteResource ExDeleteResourceLite
2329 #define ExInitializeResource ExInitializeResourceLite
2330 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2331 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2332 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2333 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2334
2335 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2336
2337 NTKERNELAPI
2338 NTSTATUS
2339 NTAPI
2340 ExExtendZone(
2341 IN OUT PZONE_HEADER Zone,
2342 IN OUT PVOID Segment,
2343 IN ULONG SegmentSize);
2344
2345 NTKERNELAPI
2346 NTSTATUS
2347 NTAPI
2348 ExInitializeZone(
2349 OUT PZONE_HEADER Zone,
2350 IN ULONG BlockSize,
2351 IN OUT PVOID InitialSegment,
2352 IN ULONG InitialSegmentSize);
2353
2354 NTKERNELAPI
2355 NTSTATUS
2356 NTAPI
2357 ExInterlockedExtendZone(
2358 IN OUT PZONE_HEADER Zone,
2359 IN OUT PVOID Segment,
2360 IN ULONG SegmentSize,
2361 IN OUT PKSPIN_LOCK Lock);
2362
2363 NTKERNELAPI
2364 NTSTATUS
2365 NTAPI
2366 ExUuidCreate(
2367 OUT UUID *Uuid);
2368
2369 NTKERNELAPI
2370 DECLSPEC_NORETURN
2371 VOID
2372 NTAPI
2373 ExRaiseAccessViolation(
2374 VOID);
2375
2376 NTKERNELAPI
2377 DECLSPEC_NORETURN
2378 VOID
2379 NTAPI
2380 ExRaiseDatatypeMisalignment(
2381 VOID);
2382
2383 #endif
2384
2385 #ifdef _X86_
2386
2387 NTKERNELAPI
2388 INTERLOCKED_RESULT
2389 FASTCALL
2390 Exfi386InterlockedIncrementLong(
2391 IN OUT LONG volatile *Addend);
2392
2393 NTKERNELAPI
2394 INTERLOCKED_RESULT
2395 FASTCALL
2396 Exfi386InterlockedDecrementLong(
2397 IN PLONG Addend);
2398
2399 NTKERNELAPI
2400 ULONG
2401 FASTCALL
2402 Exfi386InterlockedExchangeUlong(
2403 IN PULONG Target,
2404 IN ULONG Value);
2405
2406 #endif /* _X86_ */
2407
2408 #ifndef _ARC_DDK_
2409 #define _ARC_DDK_
2410 typedef enum _CONFIGURATION_TYPE {
2411 ArcSystem,
2412 CentralProcessor,
2413 FloatingPointProcessor,
2414 PrimaryIcache,
2415 PrimaryDcache,
2416 SecondaryIcache,
2417 SecondaryDcache,
2418 SecondaryCache,
2419 EisaAdapter,
2420 TcAdapter,
2421 ScsiAdapter,
2422 DtiAdapter,
2423 MultiFunctionAdapter,
2424 DiskController,
2425 TapeController,
2426 CdromController,
2427 WormController,
2428 SerialController,
2429 NetworkController,
2430 DisplayController,
2431 ParallelController,
2432 PointerController,
2433 KeyboardController,
2434 AudioController,
2435 OtherController,
2436 DiskPeripheral,
2437 FloppyDiskPeripheral,
2438 TapePeripheral,
2439 ModemPeripheral,
2440 MonitorPeripheral,
2441 PrinterPeripheral,
2442 PointerPeripheral,
2443 KeyboardPeripheral,
2444 TerminalPeripheral,
2445 OtherPeripheral,
2446 LinePeripheral,
2447 NetworkPeripheral,
2448 SystemMemory,
2449 DockingInformation,
2450 RealModeIrqRoutingTable,
2451 RealModePCIEnumeration,
2452 MaximumType
2453 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2454 #endif /* !_ARC_DDK_ */
2455
2456 typedef struct _CONTROLLER_OBJECT {
2457 CSHORT Type;
2458 CSHORT Size;
2459 PVOID ControllerExtension;
2460 KDEVICE_QUEUE DeviceWaitQueue;
2461 ULONG Spare1;
2462 LARGE_INTEGER Spare2;
2463 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
2464
2465 typedef struct _CONFIGURATION_INFORMATION {
2466 ULONG DiskCount;
2467 ULONG FloppyCount;
2468 ULONG CdRomCount;
2469 ULONG TapeCount;
2470 ULONG ScsiPortCount;
2471 ULONG SerialCount;
2472 ULONG ParallelCount;
2473 BOOLEAN AtDiskPrimaryAddressClaimed;
2474 BOOLEAN AtDiskSecondaryAddressClaimed;
2475 ULONG Version;
2476 ULONG MediumChangerCount;
2477 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2478
2479 typedef
2480 NTSTATUS
2481 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
2482 IN PVOID Context,
2483 IN PUNICODE_STRING PathName,
2484 IN INTERFACE_TYPE BusType,
2485 IN ULONG BusNumber,
2486 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2487 IN CONFIGURATION_TYPE ControllerType,
2488 IN ULONG ControllerNumber,
2489 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2490 IN CONFIGURATION_TYPE PeripheralType,
2491 IN ULONG PeripheralNumber,
2492 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
2493
2494 typedef
2495 VOID
2496 (NTAPI DRIVER_REINITIALIZE)(
2497 IN struct _DRIVER_OBJECT *DriverObject,
2498 IN PVOID Context,
2499 IN ULONG Count);
2500
2501 typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE;
2502
2503 /** Filesystem runtime library routines **/
2504
2505 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2506 NTKERNELAPI
2507 BOOLEAN
2508 NTAPI
2509 FsRtlIsTotalDeviceFailure(
2510 IN NTSTATUS Status);
2511 #endif
2512
2513 /* Hardware Abstraction Layer Types */
2514
2515 typedef VOID
2516 (NTAPI *PciPin2Line)(
2517 IN struct _BUS_HANDLER *BusHandler,
2518 IN struct _BUS_HANDLER *RootHandler,
2519 IN PCI_SLOT_NUMBER SlotNumber,
2520 IN PPCI_COMMON_CONFIG PciData);
2521
2522 typedef VOID
2523 (NTAPI *PciLine2Pin)(
2524 IN struct _BUS_HANDLER *BusHandler,
2525 IN struct _BUS_HANDLER *RootHandler,
2526 IN PCI_SLOT_NUMBER SlotNumber,
2527 IN PPCI_COMMON_CONFIG PciNewData,
2528 IN PPCI_COMMON_CONFIG PciOldData);
2529
2530 typedef VOID
2531 (NTAPI *PciReadWriteConfig)(
2532 IN struct _BUS_HANDLER *BusHandler,
2533 IN PCI_SLOT_NUMBER Slot,
2534 IN PVOID Buffer,
2535 IN ULONG Offset,
2536 IN ULONG Length);
2537
2538 #define PCI_DATA_TAG ' ICP'
2539 #define PCI_DATA_VERSION 1
2540
2541 typedef struct _PCIBUSDATA {
2542 ULONG Tag;
2543 ULONG Version;
2544 PciReadWriteConfig ReadConfig;
2545 PciReadWriteConfig WriteConfig;
2546 PciPin2Line Pin2Line;
2547 PciLine2Pin Line2Pin;
2548 PCI_SLOT_NUMBER ParentSlot;
2549 PVOID Reserved[4];
2550 } PCIBUSDATA, *PPCIBUSDATA;
2551
2552 /* Hardware Abstraction Layer Functions */
2553
2554 #if !defined(NO_LEGACY_DRIVERS)
2555
2556 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2557
2558 NTHALAPI
2559 NTSTATUS
2560 NTAPI
2561 HalAssignSlotResources(
2562 IN PUNICODE_STRING RegistryPath,
2563 IN PUNICODE_STRING DriverClassName,
2564 IN PDRIVER_OBJECT DriverObject,
2565 IN PDEVICE_OBJECT DeviceObject,
2566 IN INTERFACE_TYPE BusType,
2567 IN ULONG BusNumber,
2568 IN ULONG SlotNumber,
2569 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2570
2571 NTHALAPI
2572 ULONG
2573 NTAPI
2574 HalGetInterruptVector(
2575 IN INTERFACE_TYPE InterfaceType,
2576 IN ULONG BusNumber,
2577 IN ULONG BusInterruptLevel,
2578 IN ULONG BusInterruptVector,
2579 OUT PKIRQL Irql,
2580 OUT PKAFFINITY Affinity);
2581
2582 NTHALAPI
2583 ULONG
2584 NTAPI
2585 HalSetBusData(
2586 IN BUS_DATA_TYPE BusDataType,
2587 IN ULONG BusNumber,
2588 IN ULONG SlotNumber,
2589 IN PVOID Buffer,
2590 IN ULONG Length);
2591
2592 #endif
2593
2594 #endif /* !defined(NO_LEGACY_DRIVERS) */
2595
2596 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2597
2598 NTHALAPI
2599 PADAPTER_OBJECT
2600 NTAPI
2601 HalGetAdapter(
2602 IN PDEVICE_DESCRIPTION DeviceDescription,
2603 IN OUT PULONG NumberOfMapRegisters);
2604
2605 NTHALAPI
2606 BOOLEAN
2607 NTAPI
2608 HalMakeBeep(
2609 IN ULONG Frequency);
2610
2611 VOID
2612 NTAPI
2613 HalPutDmaAdapter(
2614 IN PADAPTER_OBJECT DmaAdapter);
2615
2616 NTHALAPI
2617 VOID
2618 NTAPI
2619 HalAcquireDisplayOwnership(
2620 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
2621
2622 NTHALAPI
2623 ULONG
2624 NTAPI
2625 HalGetBusData(
2626 IN BUS_DATA_TYPE BusDataType,
2627 IN ULONG BusNumber,
2628 IN ULONG SlotNumber,
2629 OUT PVOID Buffer,
2630 IN ULONG Length);
2631
2632 NTHALAPI
2633 ULONG
2634 NTAPI
2635 HalGetBusDataByOffset(
2636 IN BUS_DATA_TYPE BusDataType,
2637 IN ULONG BusNumber,
2638 IN ULONG SlotNumber,
2639 OUT PVOID Buffer,
2640 IN ULONG Offset,
2641 IN ULONG Length);
2642
2643 NTHALAPI
2644 ULONG
2645 NTAPI
2646 HalSetBusDataByOffset(
2647 IN BUS_DATA_TYPE BusDataType,
2648 IN ULONG BusNumber,
2649 IN ULONG SlotNumber,
2650 IN PVOID Buffer,
2651 IN ULONG Offset,
2652 IN ULONG Length);
2653
2654 NTHALAPI
2655 BOOLEAN
2656 NTAPI
2657 HalTranslateBusAddress(
2658 IN INTERFACE_TYPE InterfaceType,
2659 IN ULONG BusNumber,
2660 IN PHYSICAL_ADDRESS BusAddress,
2661 IN OUT PULONG AddressSpace,
2662 OUT PPHYSICAL_ADDRESS TranslatedAddress);
2663
2664 #endif
2665
2666 #if (NTDDI_VERSION >= NTDDI_WINXP)
2667 NTKERNELAPI
2668 VOID
2669 FASTCALL
2670 HalExamineMBR(
2671 IN PDEVICE_OBJECT DeviceObject,
2672 IN ULONG SectorSize,
2673 IN ULONG MBRTypeIdentifier,
2674 OUT PVOID *Buffer);
2675 #endif
2676
2677 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
2678 // nothing here
2679 #else
2680
2681 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2682 //DECLSPEC_DEPRECATED_DDK
2683 NTHALAPI
2684 VOID
2685 NTAPI
2686 IoFreeAdapterChannel(
2687 IN PADAPTER_OBJECT AdapterObject);
2688
2689 //DECLSPEC_DEPRECATED_DDK
2690 NTHALAPI
2691 BOOLEAN
2692 NTAPI
2693 IoFlushAdapterBuffers(
2694 IN PADAPTER_OBJECT AdapterObject,
2695 IN PMDL Mdl,
2696 IN PVOID MapRegisterBase,
2697 IN PVOID CurrentVa,
2698 IN ULONG Length,
2699 IN BOOLEAN WriteToDevice);
2700
2701 //DECLSPEC_DEPRECATED_DDK
2702 NTHALAPI
2703 VOID
2704 NTAPI
2705 IoFreeMapRegisters(
2706 IN PADAPTER_OBJECT AdapterObject,
2707 IN PVOID MapRegisterBase,
2708 IN ULONG NumberOfMapRegisters);
2709
2710 //DECLSPEC_DEPRECATED_DDK
2711 NTHALAPI
2712 PVOID
2713 NTAPI
2714 HalAllocateCommonBuffer(
2715 IN PADAPTER_OBJECT AdapterObject,
2716 IN ULONG Length,
2717 OUT PPHYSICAL_ADDRESS LogicalAddress,
2718 IN BOOLEAN CacheEnabled);
2719
2720 //DECLSPEC_DEPRECATED_DDK
2721 NTHALAPI
2722 VOID
2723 NTAPI
2724 HalFreeCommonBuffer(
2725 IN PADAPTER_OBJECT AdapterObject,
2726 IN ULONG Length,
2727 IN PHYSICAL_ADDRESS LogicalAddress,
2728 IN PVOID VirtualAddress,
2729 IN BOOLEAN CacheEnabled);
2730
2731 //DECLSPEC_DEPRECATED_DDK
2732 NTHALAPI
2733 ULONG
2734 NTAPI
2735 HalReadDmaCounter(
2736 IN PADAPTER_OBJECT AdapterObject);
2737
2738 NTHALAPI
2739 NTSTATUS
2740 NTAPI
2741 HalAllocateAdapterChannel(
2742 IN PADAPTER_OBJECT AdapterObject,
2743 IN PWAIT_CONTEXT_BLOCK Wcb,
2744 IN ULONG NumberOfMapRegisters,
2745 IN PDRIVER_CONTROL ExecutionRoutine);
2746
2747 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2748
2749 #endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */
2750
2751 /* I/O Manager Functions */
2752
2753 /*
2754 * VOID IoAssignArcName(
2755 * IN PUNICODE_STRING ArcName,
2756 * IN PUNICODE_STRING DeviceName);
2757 */
2758 #define IoAssignArcName(_ArcName, _DeviceName) ( \
2759 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
2760
2761 /*
2762 * VOID
2763 * IoDeassignArcName(
2764 * IN PUNICODE_STRING ArcName)
2765 */
2766 #define IoDeassignArcName IoDeleteSymbolicLink
2767
2768 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2769
2770 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
2771 NTKERNELAPI
2772 NTSTATUS
2773 NTAPI
2774 IoAllocateAdapterChannel(
2775 IN PADAPTER_OBJECT AdapterObject,
2776 IN PDEVICE_OBJECT DeviceObject,
2777 IN ULONG NumberOfMapRegisters,
2778 IN PDRIVER_CONTROL ExecutionRoutine,
2779 IN PVOID Context);
2780 #endif
2781
2782 #if !defined(DMA_MACROS_DEFINED)
2783 //DECLSPEC_DEPRECATED_DDK
2784 NTHALAPI
2785 PHYSICAL_ADDRESS
2786 NTAPI
2787 IoMapTransfer(
2788 IN PADAPTER_OBJECT AdapterObject,
2789 IN PMDL Mdl,
2790 IN PVOID MapRegisterBase,
2791 IN PVOID CurrentVa,
2792 IN OUT PULONG Length,
2793 IN BOOLEAN WriteToDevice);
2794 #endif
2795
2796 NTKERNELAPI
2797 VOID
2798 NTAPI
2799 IoAllocateController(
2800 IN PCONTROLLER_OBJECT ControllerObject,
2801 IN PDEVICE_OBJECT DeviceObject,
2802 IN PDRIVER_CONTROL ExecutionRoutine,
2803 IN PVOID Context OPTIONAL);
2804
2805 NTKERNELAPI
2806 PCONTROLLER_OBJECT
2807 NTAPI
2808 IoCreateController(
2809 IN ULONG Size);
2810
2811 NTKERNELAPI
2812 VOID
2813 NTAPI
2814 IoDeleteController(
2815 IN PCONTROLLER_OBJECT ControllerObject);
2816
2817 NTKERNELAPI
2818 VOID
2819 NTAPI
2820 IoFreeController(
2821 IN PCONTROLLER_OBJECT ControllerObject);
2822
2823 NTKERNELAPI
2824 PCONFIGURATION_INFORMATION
2825 NTAPI
2826 IoGetConfigurationInformation(
2827 VOID);
2828
2829 NTKERNELAPI
2830 PDEVICE_OBJECT
2831 NTAPI
2832 IoGetDeviceToVerify(
2833 IN PETHREAD Thread);
2834
2835 NTKERNELAPI
2836 VOID
2837 NTAPI
2838 IoCancelFileOpen(
2839 IN PDEVICE_OBJECT DeviceObject,
2840 IN PFILE_OBJECT FileObject);
2841
2842 NTKERNELAPI
2843 PGENERIC_MAPPING
2844 NTAPI
2845 IoGetFileObjectGenericMapping(
2846 VOID);
2847
2848 NTKERNELAPI
2849 PIRP
2850 NTAPI
2851 IoMakeAssociatedIrp(
2852 IN PIRP Irp,
2853 IN CCHAR StackSize);
2854
2855 NTKERNELAPI
2856 NTSTATUS
2857 NTAPI
2858 IoQueryDeviceDescription(
2859 IN PINTERFACE_TYPE BusType OPTIONAL,
2860 IN PULONG BusNumber OPTIONAL,
2861 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
2862 IN PULONG ControllerNumber OPTIONAL,
2863 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
2864 IN PULONG PeripheralNumber OPTIONAL,
2865 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
2866 IN OUT PVOID Context OPTIONAL);
2867
2868 NTKERNELAPI
2869 VOID
2870 NTAPI
2871 IoRaiseHardError(
2872 IN PIRP Irp,
2873 IN PVPB Vpb OPTIONAL,
2874 IN PDEVICE_OBJECT RealDeviceObject);
2875
2876 NTKERNELAPI
2877 BOOLEAN
2878 NTAPI
2879 IoRaiseInformationalHardError(
2880 IN NTSTATUS ErrorStatus,
2881 IN PUNICODE_STRING String OPTIONAL,
2882 IN PKTHREAD Thread OPTIONAL);
2883
2884 NTKERNELAPI
2885 VOID
2886 NTAPI
2887 IoRegisterBootDriverReinitialization(
2888 IN PDRIVER_OBJECT DriverObject,
2889 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2890 IN PVOID Context OPTIONAL);
2891
2892 NTKERNELAPI
2893 VOID
2894 NTAPI
2895 IoRegisterDriverReinitialization(
2896 IN PDRIVER_OBJECT DriverObject,
2897 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2898 IN PVOID Context OPTIONAL);
2899
2900 NTKERNELAPI
2901 NTSTATUS
2902 NTAPI
2903 IoAttachDeviceByPointer(
2904 IN PDEVICE_OBJECT SourceDevice,
2905 IN PDEVICE_OBJECT TargetDevice);
2906
2907 NTKERNELAPI
2908 NTSTATUS
2909 NTAPI
2910 IoReportDetectedDevice(
2911 IN PDRIVER_OBJECT DriverObject,
2912 IN INTERFACE_TYPE LegacyBusType,
2913 IN ULONG BusNumber,
2914 IN ULONG SlotNumber,
2915 IN PCM_RESOURCE_LIST ResourceList OPTIONAL,
2916 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
2917 IN BOOLEAN ResourceAssigned,
2918 IN OUT PDEVICE_OBJECT *DeviceObject);
2919
2920 NTKERNELAPI
2921 NTSTATUS
2922 NTAPI
2923 IoReportResourceForDetection(
2924 IN PDRIVER_OBJECT DriverObject,
2925 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2926 IN ULONG DriverListSize OPTIONAL,
2927 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2928 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2929 IN ULONG DeviceListSize OPTIONAL,
2930 OUT PBOOLEAN ConflictDetected);
2931
2932 NTKERNELAPI
2933 NTSTATUS
2934 NTAPI
2935 IoReportResourceUsage(
2936 IN PUNICODE_STRING DriverClassName OPTIONAL,
2937 IN PDRIVER_OBJECT DriverObject,
2938 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2939 IN ULONG DriverListSize OPTIONAL,
2940 IN PDEVICE_OBJECT DeviceObject,
2941 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2942 IN ULONG DeviceListSize OPTIONAL,
2943 IN BOOLEAN OverrideConflict,
2944 OUT PBOOLEAN ConflictDetected);
2945
2946 NTKERNELAPI
2947 VOID
2948 NTAPI
2949 IoSetHardErrorOrVerifyDevice(
2950 IN PIRP Irp,
2951 IN PDEVICE_OBJECT DeviceObject);
2952
2953 NTKERNELAPI
2954 NTSTATUS
2955 NTAPI
2956 IoAssignResources(
2957 IN PUNICODE_STRING RegistryPath,
2958 IN PUNICODE_STRING DriverClassName OPTIONAL,
2959 IN PDRIVER_OBJECT DriverObject,
2960 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2961 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL,
2962 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2963
2964 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2965
2966 #if (NTDDI_VERSION >= NTDDI_WINXP)
2967
2968 NTKERNELAPI
2969 NTSTATUS
2970 NTAPI
2971 IoCreateDisk(
2972 IN PDEVICE_OBJECT DeviceObject,
2973 IN struct _CREATE_DISK* Disk OPTIONAL);
2974
2975 NTKERNELAPI
2976 NTSTATUS
2977 NTAPI
2978 IoReadDiskSignature(
2979 IN PDEVICE_OBJECT DeviceObject,
2980 IN ULONG BytesPerSector,
2981 OUT PDISK_SIGNATURE Signature);
2982
2983 NTKERNELAPI
2984 NTSTATUS
2985 FASTCALL
2986 IoReadPartitionTable(
2987 IN PDEVICE_OBJECT DeviceObject,
2988 IN ULONG SectorSize,
2989 IN BOOLEAN ReturnRecognizedPartitions,
2990 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2991
2992 NTKERNELAPI
2993 NTSTATUS
2994 NTAPI
2995 IoReadPartitionTableEx(
2996 IN PDEVICE_OBJECT DeviceObject,
2997 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
2998
2999 NTKERNELAPI
3000 NTSTATUS
3001 FASTCALL
3002 IoSetPartitionInformation(
3003 IN PDEVICE_OBJECT DeviceObject,
3004 IN ULONG SectorSize,
3005 IN ULONG PartitionNumber,
3006 IN ULONG PartitionType);
3007
3008 NTKERNELAPI
3009 NTSTATUS
3010 NTAPI
3011 IoSetPartitionInformationEx(
3012 IN PDEVICE_OBJECT DeviceObject,
3013 IN ULONG PartitionNumber,
3014 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
3015
3016 NTKERNELAPI
3017 NTSTATUS
3018 NTAPI
3019 IoSetSystemPartition(
3020 IN PUNICODE_STRING VolumeNameString);
3021
3022 NTKERNELAPI
3023 BOOLEAN
3024 NTAPI
3025 IoSetThreadHardErrorMode(
3026 IN BOOLEAN EnableHardErrors);
3027
3028 NTKERNELAPI
3029 NTSTATUS
3030 NTAPI
3031 IoVerifyPartitionTable(
3032 IN PDEVICE_OBJECT DeviceObject,
3033 IN BOOLEAN FixErrors);
3034
3035 NTKERNELAPI
3036 NTSTATUS
3037 NTAPI
3038 IoVolumeDeviceToDosName(
3039 IN PVOID VolumeDeviceObject,
3040 OUT PUNICODE_STRING DosName);
3041
3042 NTKERNELAPI
3043 NTSTATUS
3044 FASTCALL
3045 IoWritePartitionTable(
3046 IN PDEVICE_OBJECT DeviceObject,
3047 IN ULONG SectorSize,
3048 IN ULONG SectorsPerTrack,
3049 IN ULONG NumberOfHeads,
3050 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
3051
3052 NTKERNELAPI
3053 NTSTATUS
3054 NTAPI
3055 IoWritePartitionTableEx(
3056 IN PDEVICE_OBJECT DeviceObject,
3057 IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
3058
3059 NTKERNELAPI
3060 NTSTATUS
3061 NTAPI
3062 IoAttachDeviceToDeviceStackSafe(
3063 IN PDEVICE_OBJECT SourceDevice,
3064 IN PDEVICE_OBJECT TargetDevice,
3065 OUT PDEVICE_OBJECT *AttachedToDeviceObject);
3066
3067 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3068
3069 /** Kernel debugger routines **/
3070
3071 NTSYSAPI
3072 ULONG
3073 NTAPI
3074 DbgPrompt(
3075 IN PCCH Prompt,
3076 OUT PCH Response,
3077 IN ULONG MaximumResponseLength);
3078
3079 /* Kernel Functions */
3080
3081 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3082
3083 NTKERNELAPI
3084 DECLSPEC_NORETURN
3085 VOID
3086 NTAPI
3087 KeBugCheck(
3088 IN ULONG BugCheckCode);
3089
3090 NTKERNELAPI
3091 LONG
3092 NTAPI
3093 KePulseEvent(
3094 IN OUT PRKEVENT Event,
3095 IN KPRIORITY Increment,
3096 IN BOOLEAN Wait);
3097
3098 NTKERNELAPI
3099 LONG
3100 NTAPI
3101 KeSetBasePriorityThread(
3102 IN OUT PRKTHREAD Thread,
3103 IN LONG Increment);
3104
3105 #endif
3106
3107 /* Memory Manager Types */
3108
3109 typedef struct _PHYSICAL_MEMORY_RANGE {
3110 PHYSICAL_ADDRESS BaseAddress;
3111 LARGE_INTEGER NumberOfBytes;
3112 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3113
3114 /* Memory Manager Functions */
3115
3116 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3117
3118 NTKERNELAPI
3119 PPHYSICAL_MEMORY_RANGE
3120 NTAPI
3121 MmGetPhysicalMemoryRanges(
3122 VOID);
3123
3124 NTKERNELAPI
3125 PHYSICAL_ADDRESS
3126 NTAPI
3127 MmGetPhysicalAddress(
3128 IN PVOID BaseAddress);
3129
3130 NTKERNELAPI
3131 BOOLEAN
3132 NTAPI
3133 MmIsNonPagedSystemAddressValid(
3134 IN PVOID VirtualAddress);
3135
3136 NTKERNELAPI
3137 PVOID
3138 NTAPI
3139 MmAllocateNonCachedMemory(
3140 IN SIZE_T NumberOfBytes);
3141
3142 NTKERNELAPI
3143 VOID
3144 NTAPI
3145 MmFreeNonCachedMemory(
3146 IN PVOID BaseAddress,
3147 IN SIZE_T NumberOfBytes);
3148
3149 NTKERNELAPI
3150 PVOID
3151 NTAPI
3152 MmGetVirtualForPhysical(
3153 IN PHYSICAL_ADDRESS PhysicalAddress);
3154
3155 NTKERNELAPI
3156 NTSTATUS
3157 NTAPI
3158 MmMapUserAddressesToPage(
3159 IN PVOID BaseAddress,
3160 IN SIZE_T NumberOfBytes,
3161 IN PVOID PageAddress);
3162
3163 NTKERNELAPI
3164 PVOID
3165 NTAPI
3166 MmMapVideoDisplay(
3167 IN PHYSICAL_ADDRESS PhysicalAddress,
3168 IN SIZE_T NumberOfBytes,
3169 IN MEMORY_CACHING_TYPE CacheType);
3170
3171 NTKERNELAPI
3172 NTSTATUS
3173 NTAPI
3174 MmMapViewInSessionSpace(
3175 IN PVOID Section,
3176 OUT PVOID *MappedBase,
3177 IN OUT PSIZE_T ViewSize);
3178
3179 NTKERNELAPI
3180 NTSTATUS
3181 NTAPI
3182 MmMapViewInSystemSpace(
3183 IN PVOID Section,
3184 OUT PVOID *MappedBase,
3185 IN OUT PSIZE_T ViewSize);
3186
3187 NTKERNELAPI
3188 BOOLEAN
3189 NTAPI
3190 MmIsAddressValid(
3191 IN PVOID VirtualAddress);
3192
3193 NTKERNELAPI
3194 BOOLEAN
3195 NTAPI
3196 MmIsThisAnNtAsSystem(
3197 VOID);
3198
3199 NTKERNELAPI
3200 VOID
3201 NTAPI
3202 MmLockPagableSectionByHandle(
3203 IN PVOID ImageSectionHandle);
3204
3205 NTKERNELAPI
3206 NTSTATUS
3207 NTAPI
3208 MmUnmapViewInSessionSpace(
3209 IN PVOID MappedBase);
3210
3211 NTKERNELAPI
3212 NTSTATUS
3213 NTAPI
3214 MmUnmapViewInSystemSpace(
3215 IN PVOID MappedBase);
3216
3217 NTKERNELAPI
3218 VOID
3219 NTAPI
3220 MmUnsecureVirtualMemory(
3221 IN HANDLE SecureHandle);
3222
3223 NTKERNELAPI
3224 NTSTATUS
3225 NTAPI
3226 MmRemovePhysicalMemory(
3227 IN PPHYSICAL_ADDRESS StartAddress,
3228 IN OUT PLARGE_INTEGER NumberOfBytes);
3229
3230 NTKERNELAPI
3231 HANDLE
3232 NTAPI
3233 MmSecureVirtualMemory(
3234 IN PVOID Address,
3235 IN SIZE_T Size,
3236 IN ULONG ProbeMode);
3237
3238 NTKERNELAPI
3239 VOID
3240 NTAPI
3241 MmUnmapVideoDisplay(
3242 IN PVOID BaseAddress,
3243 IN SIZE_T NumberOfBytes);
3244
3245 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3246
3247 /* NtXxx Functions */
3248
3249 NTSYSCALLAPI
3250 NTSTATUS
3251 NTAPI
3252 NtOpenProcess(
3253 OUT PHANDLE ProcessHandle,
3254 IN ACCESS_MASK DesiredAccess,
3255 IN POBJECT_ATTRIBUTES ObjectAttributes,
3256 IN PCLIENT_ID ClientId OPTIONAL);
3257
3258 NTSYSCALLAPI
3259 NTSTATUS
3260 NTAPI
3261 NtQueryInformationProcess(
3262 IN HANDLE ProcessHandle,
3263 IN PROCESSINFOCLASS ProcessInformationClass,
3264 OUT PVOID ProcessInformation OPTIONAL,
3265 IN ULONG ProcessInformationLength,
3266 OUT PULONG ReturnLength OPTIONAL);
3267
3268 /** Process manager types **/
3269
3270 typedef VOID
3271 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
3272 IN HANDLE ParentId,
3273 IN HANDLE ProcessId,
3274 IN BOOLEAN Create);
3275
3276 typedef VOID
3277 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
3278 IN HANDLE ProcessId,
3279 IN HANDLE ThreadId,
3280 IN BOOLEAN Create);
3281
3282 typedef VOID
3283 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
3284 IN PUNICODE_STRING FullImageName,
3285 IN HANDLE ProcessId,
3286 IN PIMAGE_INFO ImageInfo);
3287
3288 /** Process manager routines **/
3289
3290 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3291
3292 NTKERNELAPI
3293 NTSTATUS
3294 NTAPI
3295 PsSetLoadImageNotifyRoutine(
3296 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3297
3298 NTKERNELAPI
3299 NTSTATUS
3300 NTAPI
3301 PsSetCreateThreadNotifyRoutine(
3302 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3303
3304 NTKERNELAPI
3305 NTSTATUS
3306 NTAPI
3307 PsSetCreateProcessNotifyRoutine(
3308 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3309 IN BOOLEAN Remove);
3310
3311 NTKERNELAPI
3312 HANDLE
3313 NTAPI
3314 PsGetCurrentProcessId(
3315 VOID);
3316
3317 NTKERNELAPI
3318 HANDLE
3319 NTAPI
3320 PsGetCurrentThreadId(
3321 VOID);
3322
3323 NTKERNELAPI
3324 BOOLEAN
3325 NTAPI
3326 PsGetVersion(
3327 OUT PULONG MajorVersion OPTIONAL,
3328 OUT PULONG MinorVersion OPTIONAL,
3329 OUT PULONG BuildNumber OPTIONAL,
3330 OUT PUNICODE_STRING CSDVersion OPTIONAL);
3331
3332 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3333
3334 #if (NTDDI_VERSION >= NTDDI_WINXP)
3335
3336 NTKERNELAPI
3337 HANDLE
3338 NTAPI
3339 PsGetProcessId(
3340 IN PEPROCESS Process);
3341
3342 NTKERNELAPI
3343 NTSTATUS
3344 NTAPI
3345 PsRemoveCreateThreadNotifyRoutine(
3346 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3347
3348 NTKERNELAPI
3349 NTSTATUS
3350 NTAPI
3351 PsRemoveLoadImageNotifyRoutine(
3352 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3353
3354 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3355
3356 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
3357
3358 /* RTL Types */
3359
3360 typedef struct _RTL_SPLAY_LINKS {
3361 struct _RTL_SPLAY_LINKS *Parent;
3362 struct _RTL_SPLAY_LINKS *LeftChild;
3363 struct _RTL_SPLAY_LINKS *RightChild;
3364 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
3365
3366 /* RTL Functions */
3367
3368 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3369
3370 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3371 *CallersAddress = (PVOID)_ReturnAddress(); \
3372 *CallersCaller = NULL;
3373 #else
3374
3375 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3376 NTSYSAPI
3377 VOID
3378 NTAPI
3379 RtlGetCallersAddress(
3380 OUT PVOID *CallersAddress,
3381 OUT PVOID *CallersCaller);
3382 #endif
3383
3384 #endif
3385
3386 #if !defined(MIDL_PASS)
3387
3388 FORCEINLINE
3389 LUID
3390 NTAPI_INLINE
3391 RtlConvertLongToLuid(
3392 IN LONG Val)
3393 {
3394 LUID Luid;
3395 LARGE_INTEGER Temp;
3396
3397 Temp.QuadPart = Val;
3398 Luid.LowPart = Temp.u.LowPart;
3399 Luid.HighPart = Temp.u.HighPart;
3400 return Luid;
3401 }
3402
3403 FORCEINLINE
3404 LUID
3405 NTAPI_INLINE
3406 RtlConvertUlongToLuid(
3407 IN ULONG Val)
3408 {
3409 LUID Luid;
3410
3411 Luid.LowPart = Val;
3412 Luid.HighPart = 0;
3413 return Luid;
3414 }
3415
3416 #endif
3417
3418 #if defined(_AMD64_) || defined(_IA64_)
3419 //DECLSPEC_DEPRECATED_DDK_WINXP
3420 FORCEINLINE
3421 LARGE_INTEGER
3422 NTAPI_INLINE
3423 RtlLargeIntegerDivide(
3424 IN LARGE_INTEGER Dividend,
3425 IN LARGE_INTEGER Divisor,
3426 OUT PLARGE_INTEGER Remainder OPTIONAL)
3427 {
3428 LARGE_INTEGER ret;
3429 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
3430 if (Remainder)
3431 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
3432 return ret;
3433 }
3434
3435 #else
3436
3437 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3438 NTSYSAPI
3439 LARGE_INTEGER
3440 NTAPI
3441 RtlLargeIntegerDivide(
3442 IN LARGE_INTEGER Dividend,
3443 IN LARGE_INTEGER Divisor,
3444 OUT PLARGE_INTEGER Remainder OPTIONAL);
3445 #endif
3446
3447 #endif /* defined(_AMD64_) || defined(_IA64_) */
3448
3449 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3450
3451 NTSYSAPI
3452 BOOLEAN
3453 NTAPI
3454 RtlPrefixUnicodeString(
3455 IN PCUNICODE_STRING String1,
3456 IN PCUNICODE_STRING String2,
3457 IN BOOLEAN CaseInSensitive);
3458
3459 NTSYSAPI
3460 VOID
3461 NTAPI
3462 RtlUpperString(
3463 IN OUT PSTRING DestinationString,
3464 IN const PSTRING SourceString);
3465
3466 NTSYSAPI
3467 NTSTATUS
3468 NTAPI
3469 RtlUpcaseUnicodeString(
3470 IN OUT PUNICODE_STRING DestinationString,
3471 IN PCUNICODE_STRING SourceString,
3472 IN BOOLEAN AllocateDestinationString);
3473
3474 NTSYSAPI
3475 VOID
3476 NTAPI
3477 RtlMapGenericMask(
3478 IN OUT PACCESS_MASK AccessMask,
3479 IN PGENERIC_MAPPING GenericMapping);
3480
3481 NTSYSAPI
3482 NTSTATUS
3483 NTAPI
3484 RtlVolumeDeviceToDosName(
3485 IN PVOID VolumeDeviceObject,
3486 OUT PUNICODE_STRING DosName);
3487
3488 NTSYSAPI
3489 NTSTATUS
3490 NTAPI
3491 RtlGetVersion(
3492 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
3493
3494 NTSYSAPI
3495 NTSTATUS
3496 NTAPI
3497 RtlVerifyVersionInfo(
3498 IN PRTL_OSVERSIONINFOEXW VersionInfo,
3499 IN ULONG TypeMask,
3500 IN ULONGLONG ConditionMask);
3501
3502 NTSYSAPI
3503 LONG
3504 NTAPI
3505 RtlCompareString(
3506 IN const PSTRING String1,
3507 IN const PSTRING String2,
3508 BOOLEAN CaseInSensitive);
3509
3510 NTSYSAPI
3511 VOID
3512 NTAPI
3513 RtlCopyString(
3514 OUT PSTRING DestinationString,
3515 IN const PSTRING SourceString OPTIONAL);
3516
3517 NTSYSAPI
3518 BOOLEAN
3519 NTAPI
3520 RtlEqualString(
3521 IN const PSTRING String1,
3522 IN const PSTRING String2,
3523 IN BOOLEAN CaseInSensitive);
3524
3525 NTSYSAPI
3526 NTSTATUS
3527 NTAPI
3528 RtlCharToInteger(
3529 IN PCSZ String,
3530 IN ULONG Base OPTIONAL,
3531 OUT PULONG Value);
3532
3533 NTSYSAPI
3534 CHAR
3535 NTAPI
3536 RtlUpperChar(
3537 IN CHAR Character);
3538
3539 NTSYSAPI
3540 ULONG
3541 NTAPI
3542 RtlWalkFrameChain(
3543 OUT PVOID *Callers,
3544 IN ULONG Count,
3545 IN ULONG Flags);
3546
3547 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3548
3549 /* Security reference monitor routines */
3550
3551 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3552 NTKERNELAPI
3553 BOOLEAN
3554 NTAPI
3555 SeSinglePrivilegeCheck(
3556 IN LUID PrivilegeValue,
3557 IN KPROCESSOR_MODE PreviousMode);
3558 #endif
3559
3560 /* ZwXxx Functions */
3561
3562 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3563
3564 NTSTATUS
3565 NTAPI
3566 ZwCancelTimer(
3567 IN HANDLE TimerHandle,
3568 OUT PBOOLEAN CurrentState OPTIONAL);
3569
3570 NTSTATUS
3571 NTAPI
3572 ZwCreateTimer(
3573 OUT PHANDLE TimerHandle,
3574 IN ACCESS_MASK DesiredAccess,
3575 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3576 IN TIMER_TYPE TimerType);
3577
3578 NTSTATUS
3579 NTAPI
3580 ZwOpenTimer(
3581 OUT PHANDLE TimerHandle,
3582 IN ACCESS_MASK DesiredAccess,
3583 IN POBJECT_ATTRIBUTES ObjectAttributes);
3584
3585 NTSYSAPI
3586 NTSTATUS
3587 NTAPI
3588 ZwSetInformationThread(
3589 IN HANDLE ThreadHandle,
3590 IN THREADINFOCLASS ThreadInformationClass,
3591 IN PVOID ThreadInformation,
3592 IN ULONG ThreadInformationLength);
3593
3594 NTSTATUS
3595 NTAPI
3596 ZwSetTimer(
3597 IN HANDLE TimerHandle,
3598 IN PLARGE_INTEGER DueTime,
3599 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3600 IN PVOID TimerContext OPTIONAL,
3601 IN BOOLEAN ResumeTimer,
3602 IN LONG Period OPTIONAL,
3603 OUT PBOOLEAN PreviousState OPTIONAL);
3604
3605 #endif
3606
3607 typedef struct _QUOTA_LIMITS {
3608 SIZE_T PagedPoolLimit;
3609 SIZE_T NonPagedPoolLimit;
3610 SIZE_T MinimumWorkingSetSize;
3611 SIZE_T MaximumWorkingSetSize;
3612 SIZE_T PagefileLimit;
3613 LARGE_INTEGER TimeLimit;
3614 } QUOTA_LIMITS, *PQUOTA_LIMITS;
3615
3616 struct _RTL_GENERIC_COMPARE_ROUTINE;
3617 struct _RTL_GENERIC_ALLOCATE_ROUTINE;
3618 struct _RTL_GENERIC_FREE_ROUTINE;
3619
3620 typedef struct _RTL_GENERIC_TABLE {
3621 PRTL_SPLAY_LINKS TableRoot;
3622 LIST_ENTRY InsertOrderList;
3623 PLIST_ENTRY OrderedPointer;
3624 ULONG WhichOrderedElement;
3625 ULONG NumberGenericTableElements;
3626 struct _RTL_GENERIC_COMPARE_ROUTINE *CompareRoutine;
3627 struct _RTL_GENERIC_ALLOCATE_ROUTINE *AllocateRoutine;
3628 struct _RTL_GENERIC_FREE_ROUTINE *FreeRoutine;
3629 PVOID TableContext;
3630 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
3631
3632 typedef enum _TABLE_SEARCH_RESULT {
3633 TableEmptyTree,
3634 TableFoundNode,
3635 TableInsertAsLeft,
3636 TableInsertAsRight
3637 } TABLE_SEARCH_RESULT;
3638
3639 typedef struct _FILE_FS_SIZE_INFORMATION {
3640 LARGE_INTEGER TotalAllocationUnits;
3641 LARGE_INTEGER AvailableAllocationUnits;
3642 ULONG SectorsPerAllocationUnit;
3643 ULONG BytesPerSector;
3644 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
3645
3646 #define IO_CHECK_CREATE_PARAMETERS 0x0200
3647 #define IO_ATTACH_DEVICE 0x0400
3648 #define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800
3649
3650 typedef struct _FILE_FS_VOLUME_INFORMATION {
3651 LARGE_INTEGER VolumeCreationTime;
3652 ULONG VolumeSerialNumber;
3653 ULONG VolumeLabelLength;
3654 BOOLEAN SupportsObjects;
3655 WCHAR VolumeLabel[1];
3656 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
3657
3658 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
3659 LARGE_INTEGER TotalAllocationUnits;
3660 LARGE_INTEGER CallerAvailableAllocationUnits;
3661 LARGE_INTEGER ActualAvailableAllocationUnits;
3662 ULONG SectorsPerAllocationUnit;
3663 ULONG BytesPerSector;
3664 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
3665
3666 typedef struct _FILE_FS_OBJECTID_INFORMATION {
3667 UCHAR ObjectId[16];
3668 UCHAR ExtendedInfo[48];
3669 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
3670
3671 typedef struct _FILE_FS_LABEL_INFORMATION {
3672 ULONG VolumeLabelLength;
3673 WCHAR VolumeLabel[1];
3674 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
3675
3676 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
3677 GenericLessThan,
3678 GenericGreaterThan,
3679 GenericEqual
3680 } RTL_GENERIC_COMPARE_RESULTS;
3681
3682 // Forwarder
3683 struct _RTL_AVL_TABLE;
3684
3685 typedef RTL_GENERIC_COMPARE_RESULTS
3686 (NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
3687 IN struct _RTL_AVL_TABLE *Table,
3688 IN PVOID FirstStruct,
3689 IN PVOID SecondStruct);
3690
3691 typedef PVOID
3692 (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
3693 IN struct _RTL_AVL_TABLE *Table,
3694 IN CLONG ByteSize);
3695
3696 typedef VOID
3697 (NTAPI *PRTL_AVL_FREE_ROUTINE) (
3698 IN struct _RTL_AVL_TABLE *Table,
3699 IN PVOID Buffer);
3700
3701 typedef NTSTATUS
3702 (NTAPI *PRTL_AVL_MATCH_FUNCTION) (
3703 IN struct _RTL_AVL_TABLE *Table,
3704 IN PVOID UserData,
3705 IN PVOID MatchData);
3706
3707 typedef struct _RTL_BALANCED_LINKS {
3708 struct _RTL_BALANCED_LINKS *Parent;
3709 struct _RTL_BALANCED_LINKS *LeftChild;
3710 struct _RTL_BALANCED_LINKS *RightChild;
3711 CHAR Balance;
3712 UCHAR Reserved[3];
3713 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
3714
3715 typedef struct _RTL_AVL_TABLE {
3716 RTL_BALANCED_LINKS BalancedRoot;
3717 PVOID OrderedPointer;
3718 ULONG WhichOrderedElement;
3719 ULONG NumberGenericTableElements;
3720 ULONG DepthOfTree;
3721 PRTL_BALANCED_LINKS RestartKey;
3722 ULONG DeleteCount;
3723 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
3724 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
3725 PRTL_AVL_FREE_ROUTINE FreeRoutine;
3726 PVOID TableContext;
3727 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
3728
3729 #ifndef RTL_USE_AVL_TABLES
3730
3731 struct _RTL_GENERIC_TABLE;
3732
3733 typedef RTL_GENERIC_COMPARE_RESULTS
3734 (NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
3735 IN struct _RTL_GENERIC_TABLE *Table,
3736 IN PVOID FirstStruct,
3737 IN PVOID SecondStruct);
3738
3739 typedef PVOID
3740 (NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
3741 IN struct _RTL_GENERIC_TABLE *Table,
3742 IN CLONG ByteSize);
3743
3744 typedef VOID
3745 (NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
3746 IN struct _RTL_GENERIC_TABLE *Table,
3747 IN PVOID Buffer);
3748
3749 #endif /* !RTL_USE_AVL_TABLES */
3750
3751 NTSYSAPI
3752 VOID
3753 NTAPI
3754 RtlInitializeGenericTableAvl(
3755 OUT PRTL_AVL_TABLE Table,
3756 IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
3757 IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
3758 IN PRTL_AVL_FREE_ROUTINE FreeRoutine,
3759 IN PVOID TableContext OPTIONAL);
3760
3761 #ifdef __cplusplus
3762 }
3763 #endif
3764
3765
3766 #endif /* _NTDDK_ */