[DDK]
[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 typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE {
856 ResourceTypeSingle = 0,
857 ResourceTypeRange,
858 ResourceTypeExtendedCounterConfiguration,
859 ResourceTypeOverflow,
860 ResourceTypeMax
861 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE;
862
863 typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR {
864 PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type;
865 ULONG Flags;
866 union {
867 ULONG CounterIndex;
868 ULONG ExtendedRegisterAddress;
869 struct {
870 ULONG Begin;
871 ULONG End;
872 } Range;
873 } u;
874 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR;
875
876 typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST {
877 ULONG Count;
878 PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY];
879 } PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST;
880
881 #ifndef _PCIINTRF_X_
882 #define _PCIINTRF_X_
883
884 typedef ULONG
885 (NTAPI *PCI_READ_WRITE_CONFIG)(
886 IN PVOID Context,
887 IN ULONG BusOffset,
888 IN ULONG Slot,
889 IN PVOID Buffer,
890 IN ULONG Offset,
891 IN ULONG Length);
892
893 typedef VOID
894 (NTAPI *PCI_PIN_TO_LINE)(
895 IN PVOID Context,
896 IN PPCI_COMMON_CONFIG PciData);
897
898 typedef VOID
899 (NTAPI *PCI_LINE_TO_PIN)(
900 IN PVOID Context,
901 IN PPCI_COMMON_CONFIG PciNewData,
902 IN PPCI_COMMON_CONFIG PciOldData);
903
904 typedef VOID
905 (NTAPI *PCI_ROOT_BUS_CAPABILITY)(
906 IN PVOID Context,
907 OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability);
908
909 typedef VOID
910 (NTAPI *PCI_EXPRESS_WAKE_CONTROL)(
911 IN PVOID Context,
912 IN BOOLEAN EnableWake);
913
914 typedef struct _PCI_BUS_INTERFACE_STANDARD {
915 USHORT Size;
916 USHORT Version;
917 PVOID Context;
918 PINTERFACE_REFERENCE InterfaceReference;
919 PINTERFACE_DEREFERENCE InterfaceDereference;
920 PCI_READ_WRITE_CONFIG ReadConfig;
921 PCI_READ_WRITE_CONFIG WriteConfig;
922 PCI_PIN_TO_LINE PinToLine;
923 PCI_LINE_TO_PIN LineToPin;
924 PCI_ROOT_BUS_CAPABILITY RootBusCapability;
925 PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl;
926 } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
927
928 #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
929
930 #endif /* _PCIINTRF_X_ */
931
932 #if (NTDDI_VERSION >= NTDDI_WIN7)
933
934 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000
935 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000
936 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \
937 (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \
938 FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX)
939
940 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200
941 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300
942 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300
943
944 #else
945
946 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
947 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
948 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
949
950 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL
951 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL
952 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK
953
954 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
955
956 #endif // 0
957
958 typedef enum _HAL_QUERY_INFORMATION_CLASS {
959 HalInstalledBusInformation,
960 HalProfileSourceInformation,
961 HalInformationClassUnused1,
962 HalPowerInformation,
963 HalProcessorSpeedInformation,
964 HalCallbackInformation,
965 HalMapRegisterInformation,
966 HalMcaLogInformation,
967 HalFrameBufferCachingInformation,
968 HalDisplayBiosInformation,
969 HalProcessorFeatureInformation,
970 HalNumaTopologyInterface,
971 HalErrorInformation,
972 HalCmcLogInformation,
973 HalCpeLogInformation,
974 HalQueryMcaInterface,
975 HalQueryAMLIIllegalIOPortAddresses,
976 HalQueryMaxHotPlugMemoryAddress,
977 HalPartitionIpiInterface,
978 HalPlatformInformation,
979 HalQueryProfileSourceList,
980 HalInitLogInformation,
981 HalFrequencyInformation,
982 HalProcessorBrandString,
983 HalHypervisorInformation,
984 HalPlatformTimerInformation,
985 HalAcpiAuditInformation
986 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
987
988 typedef enum _HAL_SET_INFORMATION_CLASS {
989 HalProfileSourceInterval,
990 HalProfileSourceInterruptHandler,
991 HalMcaRegisterDriver,
992 HalKernelErrorHandler,
993 HalCmcRegisterDriver,
994 HalCpeRegisterDriver,
995 HalMcaLog,
996 HalCmcLog,
997 HalCpeLog,
998 HalGenerateCmcInterrupt,
999 HalProfileSourceTimerHandler,
1000 HalEnlightenment,
1001 HalProfileDpgoSourceInterruptHandler
1002 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
1003
1004 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
1005 KPROFILE_SOURCE Source;
1006 ULONG_PTR Interval;
1007 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
1008
1009 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
1010 KPROFILE_SOURCE Source;
1011 BOOLEAN Supported;
1012 ULONG Interval;
1013 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
1014
1015 typedef struct _MAP_REGISTER_ENTRY {
1016 PVOID MapRegister;
1017 BOOLEAN WriteToDevice;
1018 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
1019
1020 typedef struct _DEBUG_DEVICE_ADDRESS {
1021 UCHAR Type;
1022 BOOLEAN Valid;
1023 UCHAR Reserved[2];
1024 PUCHAR TranslatedAddress;
1025 ULONG Length;
1026 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
1027
1028 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
1029 PHYSICAL_ADDRESS Start;
1030 PHYSICAL_ADDRESS MaxEnd;
1031 PVOID VirtualAddress;
1032 ULONG Length;
1033 BOOLEAN Cached;
1034 BOOLEAN Aligned;
1035 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
1036
1037 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
1038 ULONG Bus;
1039 ULONG Slot;
1040 USHORT Segment;
1041 USHORT VendorID;
1042 USHORT DeviceID;
1043 UCHAR BaseClass;
1044 UCHAR SubClass;
1045 UCHAR ProgIf;
1046 BOOLEAN Initialized;
1047 BOOLEAN Configured;
1048 DEBUG_DEVICE_ADDRESS BaseAddress[6];
1049 DEBUG_MEMORY_REQUIREMENTS Memory;
1050 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
1051
1052 typedef struct _PM_DISPATCH_TABLE {
1053 ULONG Signature;
1054 ULONG Version;
1055 PVOID Function[1];
1056 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
1057
1058 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
1059 TranslateChildToParent,
1060 TranslateParentToChild
1061 } RESOURCE_TRANSLATION_DIRECTION;
1062
1063 typedef NTSTATUS
1064 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
1065 IN OUT PVOID Context,
1066 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
1067 IN RESOURCE_TRANSLATION_DIRECTION Direction,
1068 IN ULONG AlternativesCount OPTIONAL,
1069 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
1070 IN PDEVICE_OBJECT PhysicalDeviceObject,
1071 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
1072
1073 typedef NTSTATUS
1074 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
1075 IN PVOID Context OPTIONAL,
1076 IN PIO_RESOURCE_DESCRIPTOR Source,
1077 IN PDEVICE_OBJECT PhysicalDeviceObject,
1078 OUT PULONG TargetCount,
1079 OUT PIO_RESOURCE_DESCRIPTOR *Target);
1080
1081 typedef struct _TRANSLATOR_INTERFACE {
1082 USHORT Size;
1083 USHORT Version;
1084 PVOID Context;
1085 PINTERFACE_REFERENCE InterfaceReference;
1086 PINTERFACE_DEREFERENCE InterfaceDereference;
1087 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
1088 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
1089 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
1090
1091 typedef VOID
1092 (FASTCALL *pHalExamineMBR)(
1093 IN PDEVICE_OBJECT DeviceObject,
1094 IN ULONG SectorSize,
1095 IN ULONG MBRTypeIdentifier,
1096 OUT PVOID *Buffer);
1097
1098 typedef NTSTATUS
1099 (FASTCALL *pHalIoReadPartitionTable)(
1100 IN PDEVICE_OBJECT DeviceObject,
1101 IN ULONG SectorSize,
1102 IN BOOLEAN ReturnRecognizedPartitions,
1103 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
1104
1105 typedef NTSTATUS
1106 (FASTCALL *pHalIoSetPartitionInformation)(
1107 IN PDEVICE_OBJECT DeviceObject,
1108 IN ULONG SectorSize,
1109 IN ULONG PartitionNumber,
1110 IN ULONG PartitionType);
1111
1112 typedef NTSTATUS
1113 (FASTCALL *pHalIoWritePartitionTable)(
1114 IN PDEVICE_OBJECT DeviceObject,
1115 IN ULONG SectorSize,
1116 IN ULONG SectorsPerTrack,
1117 IN ULONG NumberOfHeads,
1118 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
1119
1120 typedef PBUS_HANDLER
1121 (FASTCALL *pHalHandlerForBus)(
1122 IN INTERFACE_TYPE InterfaceType,
1123 IN ULONG BusNumber);
1124
1125 typedef VOID
1126 (FASTCALL *pHalReferenceBusHandler)(
1127 IN PBUS_HANDLER BusHandler);
1128
1129 typedef NTSTATUS
1130 (NTAPI *pHalQuerySystemInformation)(
1131 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
1132 IN ULONG BufferSize,
1133 IN OUT PVOID Buffer,
1134 OUT PULONG ReturnedLength);
1135
1136 typedef NTSTATUS
1137 (NTAPI *pHalSetSystemInformation)(
1138 IN HAL_SET_INFORMATION_CLASS InformationClass,
1139 IN ULONG BufferSize,
1140 IN PVOID Buffer);
1141
1142 typedef NTSTATUS
1143 (NTAPI *pHalQueryBusSlots)(
1144 IN PBUS_HANDLER BusHandler,
1145 IN ULONG BufferSize,
1146 OUT PULONG SlotNumbers,
1147 OUT PULONG ReturnedLength);
1148
1149 typedef NTSTATUS
1150 (NTAPI *pHalInitPnpDriver)(
1151 VOID);
1152
1153 typedef NTSTATUS
1154 (NTAPI *pHalInitPowerManagement)(
1155 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
1156 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
1157
1158 typedef struct _DMA_ADAPTER*
1159 (NTAPI *pHalGetDmaAdapter)(
1160 IN PVOID Context,
1161 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
1162 OUT PULONG NumberOfMapRegisters);
1163
1164 typedef NTSTATUS
1165 (NTAPI *pHalGetInterruptTranslator)(
1166 IN INTERFACE_TYPE ParentInterfaceType,
1167 IN ULONG ParentBusNumber,
1168 IN INTERFACE_TYPE BridgeInterfaceType,
1169 IN USHORT Size,
1170 IN USHORT Version,
1171 OUT PTRANSLATOR_INTERFACE Translator,
1172 OUT PULONG BridgeBusNumber);
1173
1174 typedef NTSTATUS
1175 (NTAPI *pHalStartMirroring)(
1176 VOID);
1177
1178 typedef NTSTATUS
1179 (NTAPI *pHalEndMirroring)(
1180 IN ULONG PassNumber);
1181
1182 typedef NTSTATUS
1183 (NTAPI *pHalMirrorPhysicalMemory)(
1184 IN PHYSICAL_ADDRESS PhysicalAddress,
1185 IN LARGE_INTEGER NumberOfBytes);
1186
1187 typedef NTSTATUS
1188 (NTAPI *pHalMirrorVerify)(
1189 IN PHYSICAL_ADDRESS PhysicalAddress,
1190 IN LARGE_INTEGER NumberOfBytes);
1191
1192 typedef VOID
1193 (NTAPI *pHalEndOfBoot)(
1194 VOID);
1195
1196 typedef
1197 BOOLEAN
1198 (NTAPI *pHalTranslateBusAddress)(
1199 IN INTERFACE_TYPE InterfaceType,
1200 IN ULONG BusNumber,
1201 IN PHYSICAL_ADDRESS BusAddress,
1202 IN OUT PULONG AddressSpace,
1203 OUT PPHYSICAL_ADDRESS TranslatedAddress);
1204
1205 typedef
1206 NTSTATUS
1207 (NTAPI *pHalAssignSlotResources)(
1208 IN PUNICODE_STRING RegistryPath,
1209 IN PUNICODE_STRING DriverClassName OPTIONAL,
1210 IN PDRIVER_OBJECT DriverObject,
1211 IN PDEVICE_OBJECT DeviceObject,
1212 IN INTERFACE_TYPE BusType,
1213 IN ULONG BusNumber,
1214 IN ULONG SlotNumber,
1215 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
1216
1217 typedef
1218 VOID
1219 (NTAPI *pHalHaltSystem)(
1220 VOID);
1221
1222 typedef
1223 BOOLEAN
1224 (NTAPI *pHalResetDisplay)(
1225 VOID);
1226
1227 typedef
1228 UCHAR
1229 (NTAPI *pHalVectorToIDTEntry)(
1230 ULONG Vector);
1231
1232 typedef
1233 BOOLEAN
1234 (NTAPI *pHalFindBusAddressTranslation)(
1235 IN PHYSICAL_ADDRESS BusAddress,
1236 IN OUT PULONG AddressSpace,
1237 OUT PPHYSICAL_ADDRESS TranslatedAddress,
1238 IN OUT PULONG_PTR Context,
1239 IN BOOLEAN NextBus);
1240
1241 typedef
1242 NTSTATUS
1243 (NTAPI *pKdSetupPciDeviceForDebugging)(
1244 IN PVOID LoaderBlock OPTIONAL,
1245 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
1246
1247 typedef
1248 NTSTATUS
1249 (NTAPI *pKdReleasePciDeviceForDebugging)(
1250 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
1251
1252 typedef
1253 PVOID
1254 (NTAPI *pKdGetAcpiTablePhase0)(
1255 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1256 IN ULONG Signature);
1257
1258 typedef
1259 PVOID
1260 (NTAPI *pHalGetAcpiTable)(
1261 IN ULONG Signature,
1262 IN PCSTR OemId OPTIONAL,
1263 IN PCSTR OemTableId OPTIONAL);
1264
1265 typedef
1266 VOID
1267 (NTAPI *pKdCheckPowerButton)(
1268 VOID);
1269
1270 #if (NTDDI_VERSION >= NTDDI_VISTA)
1271 typedef
1272 PVOID
1273 (NTAPI *pKdMapPhysicalMemory64)(
1274 IN PHYSICAL_ADDRESS PhysicalAddress,
1275 IN ULONG NumberPages,
1276 IN BOOLEAN FlushCurrentTLB);
1277
1278 typedef
1279 VOID
1280 (NTAPI *pKdUnmapVirtualAddress)(
1281 IN PVOID VirtualAddress,
1282 IN ULONG NumberPages,
1283 IN BOOLEAN FlushCurrentTLB);
1284 #else
1285 typedef
1286 PVOID
1287 (NTAPI *pKdMapPhysicalMemory64)(
1288 IN PHYSICAL_ADDRESS PhysicalAddress,
1289 IN ULONG NumberPages);
1290
1291 typedef
1292 VOID
1293 (NTAPI *pKdUnmapVirtualAddress)(
1294 IN PVOID VirtualAddress,
1295 IN ULONG NumberPages);
1296 #endif
1297
1298
1299 typedef
1300 ULONG
1301 (NTAPI *pKdGetPciDataByOffset)(
1302 IN ULONG BusNumber,
1303 IN ULONG SlotNumber,
1304 OUT PVOID Buffer,
1305 IN ULONG Offset,
1306 IN ULONG Length);
1307
1308 typedef
1309 ULONG
1310 (NTAPI *pKdSetPciDataByOffset)(
1311 IN ULONG BusNumber,
1312 IN ULONG SlotNumber,
1313 IN PVOID Buffer,
1314 IN ULONG Offset,
1315 IN ULONG Length);
1316
1317 typedef BOOLEAN
1318 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1319 IN ULONG Columns,
1320 IN ULONG Rows);
1321
1322 typedef
1323 VOID
1324 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
1325 VOID);
1326
1327 typedef
1328 VOID
1329 (NTAPI *pHalSetPciErrorHandlerCallback)(
1330 IN PCI_ERROR_HANDLER_CALLBACK Callback);
1331
1332 #if 1 /* Not present in WDK 7600 */
1333 typedef VOID
1334 (FASTCALL *pHalIoAssignDriveLetters)(
1335 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1336 IN PSTRING NtDeviceName,
1337 OUT PUCHAR NtSystemPath,
1338 OUT PSTRING NtSystemPathString);
1339 #endif
1340
1341 typedef struct {
1342 ULONG Version;
1343 pHalQuerySystemInformation HalQuerySystemInformation;
1344 pHalSetSystemInformation HalSetSystemInformation;
1345 pHalQueryBusSlots HalQueryBusSlots;
1346 ULONG Spare1;
1347 pHalExamineMBR HalExamineMBR;
1348 #if 1 /* Not present in WDK 7600 */
1349 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1350 #endif
1351 pHalIoReadPartitionTable HalIoReadPartitionTable;
1352 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1353 pHalIoWritePartitionTable HalIoWritePartitionTable;
1354 pHalHandlerForBus HalReferenceHandlerForBus;
1355 pHalReferenceBusHandler HalReferenceBusHandler;
1356 pHalReferenceBusHandler HalDereferenceBusHandler;
1357 pHalInitPnpDriver HalInitPnpDriver;
1358 pHalInitPowerManagement HalInitPowerManagement;
1359 pHalGetDmaAdapter HalGetDmaAdapter;
1360 pHalGetInterruptTranslator HalGetInterruptTranslator;
1361 pHalStartMirroring HalStartMirroring;
1362 pHalEndMirroring HalEndMirroring;
1363 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1364 pHalEndOfBoot HalEndOfBoot;
1365 pHalMirrorVerify HalMirrorVerify;
1366 pHalGetAcpiTable HalGetCachedAcpiTable;
1367 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
1368 #if defined(_IA64_)
1369 pHalGetErrorCapList HalGetErrorCapList;
1370 pHalInjectError HalInjectError;
1371 #endif
1372 } HAL_DISPATCH, *PHAL_DISPATCH;
1373
1374 /* GCC/MSVC and WDK compatible declaration */
1375 extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
1376
1377 #if defined(_NTOSKRNL_) || defined(_BLDR_)
1378 #define HALDISPATCH (&HalDispatchTable)
1379 #else
1380 /* This is a WDK compatibility definition */
1381 #define HalDispatchTable (&HalDispatchTable)
1382 #define HALDISPATCH HalDispatchTable
1383 #endif
1384
1385 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
1386 #define HalDispatchTableVersion HALDISPATCH->Version
1387 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1388 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1389 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1390 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1391 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1392 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1393 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1394 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1395 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1396 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1397 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1398 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1399 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1400 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1401 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1402
1403 typedef struct _FILE_ALIGNMENT_INFORMATION {
1404 ULONG AlignmentRequirement;
1405 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1406
1407 typedef struct _FILE_NAME_INFORMATION {
1408 ULONG FileNameLength;
1409 WCHAR FileName[1];
1410 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1411
1412
1413 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1414 ULONG FileAttributes;
1415 ULONG ReparseTag;
1416 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1417
1418 typedef struct _FILE_DISPOSITION_INFORMATION {
1419 BOOLEAN DeleteFile;
1420 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1421
1422 typedef struct _FILE_END_OF_FILE_INFORMATION {
1423 LARGE_INTEGER EndOfFile;
1424 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1425
1426 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1427 LARGE_INTEGER ValidDataLength;
1428 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1429
1430 typedef union _FILE_SEGMENT_ELEMENT {
1431 PVOID64 Buffer;
1432 ULONGLONG Alignment;
1433 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1434
1435 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
1436
1437 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1438 NTSYSAPI
1439 ULONGLONG
1440 NTAPI
1441 VerSetConditionMask(
1442 IN ULONGLONG ConditionMask,
1443 IN ULONG TypeMask,
1444 IN UCHAR Condition);
1445 #endif
1446
1447 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
1448 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
1449 (TypeBitMask), (ComparisonType)))
1450
1451 /* RtlVerifyVersionInfo() TypeMask */
1452
1453 #define VER_MINORVERSION 0x0000001
1454 #define VER_MAJORVERSION 0x0000002
1455 #define VER_BUILDNUMBER 0x0000004
1456 #define VER_PLATFORMID 0x0000008
1457 #define VER_SERVICEPACKMINOR 0x0000010
1458 #define VER_SERVICEPACKMAJOR 0x0000020
1459 #define VER_SUITENAME 0x0000040
1460 #define VER_PRODUCT_TYPE 0x0000080
1461
1462 /* RtlVerifyVersionInfo() ComparisonType */
1463
1464 #define VER_EQUAL 1
1465 #define VER_GREATER 2
1466 #define VER_GREATER_EQUAL 3
1467 #define VER_LESS 4
1468 #define VER_LESS_EQUAL 5
1469 #define VER_AND 6
1470 #define VER_OR 7
1471
1472 #define VER_CONDITION_MASK 7
1473 #define VER_NUM_BITS_PER_CONDITION_MASK 3
1474
1475 typedef struct _IMAGE_INFO {
1476 _ANONYMOUS_UNION union {
1477 ULONG Properties;
1478 _ANONYMOUS_STRUCT struct {
1479 ULONG ImageAddressingMode:8;
1480 ULONG SystemModeImage:1;
1481 ULONG ImageMappedToAllPids:1;
1482 ULONG ExtendedInfoPresent:1;
1483 ULONG Reserved:22;
1484 } DUMMYSTRUCTNAME;
1485 } DUMMYUNIONNAME;
1486 PVOID ImageBase;
1487 ULONG ImageSelector;
1488 SIZE_T ImageSize;
1489 ULONG ImageSectionNumber;
1490 } IMAGE_INFO, *PIMAGE_INFO;
1491
1492 #define IMAGE_ADDRESSING_MODE_32BIT 3
1493
1494 typedef enum _BUS_DATA_TYPE {
1495 ConfigurationSpaceUndefined = -1,
1496 Cmos,
1497 EisaConfiguration,
1498 Pos,
1499 CbusConfiguration,
1500 PCIConfiguration,
1501 VMEConfiguration,
1502 NuBusConfiguration,
1503 PCMCIAConfiguration,
1504 MPIConfiguration,
1505 MPSAConfiguration,
1506 PNPISAConfiguration,
1507 SgiInternalConfiguration,
1508 MaximumBusDataType
1509 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1510
1511 typedef struct _NT_TIB {
1512 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1513 PVOID StackBase;
1514 PVOID StackLimit;
1515 PVOID SubSystemTib;
1516 _ANONYMOUS_UNION union {
1517 PVOID FiberData;
1518 ULONG Version;
1519 } DUMMYUNIONNAME;
1520 PVOID ArbitraryUserPointer;
1521 struct _NT_TIB *Self;
1522 } NT_TIB, *PNT_TIB;
1523
1524 typedef struct _NT_TIB32 {
1525 ULONG ExceptionList;
1526 ULONG StackBase;
1527 ULONG StackLimit;
1528 ULONG SubSystemTib;
1529 __GNU_EXTENSION union {
1530 ULONG FiberData;
1531 ULONG Version;
1532 };
1533 ULONG ArbitraryUserPointer;
1534 ULONG Self;
1535 } NT_TIB32,*PNT_TIB32;
1536
1537 typedef struct _NT_TIB64 {
1538 ULONG64 ExceptionList;
1539 ULONG64 StackBase;
1540 ULONG64 StackLimit;
1541 ULONG64 SubSystemTib;
1542 __GNU_EXTENSION union {
1543 ULONG64 FiberData;
1544 ULONG Version;
1545 };
1546 ULONG64 ArbitraryUserPointer;
1547 ULONG64 Self;
1548 } NT_TIB64,*PNT_TIB64;
1549
1550 typedef enum _PROCESSINFOCLASS {
1551 ProcessBasicInformation,
1552 ProcessQuotaLimits,
1553 ProcessIoCounters,
1554 ProcessVmCounters,
1555 ProcessTimes,
1556 ProcessBasePriority,
1557 ProcessRaisePriority,
1558 ProcessDebugPort,
1559 ProcessExceptionPort,
1560 ProcessAccessToken,
1561 ProcessLdtInformation,
1562 ProcessLdtSize,
1563 ProcessDefaultHardErrorMode,
1564 ProcessIoPortHandlers,
1565 ProcessPooledUsageAndLimits,
1566 ProcessWorkingSetWatch,
1567 ProcessUserModeIOPL,
1568 ProcessEnableAlignmentFaultFixup,
1569 ProcessPriorityClass,
1570 ProcessWx86Information,
1571 ProcessHandleCount,
1572 ProcessAffinityMask,
1573 ProcessPriorityBoost,
1574 ProcessDeviceMap,
1575 ProcessSessionInformation,
1576 ProcessForegroundInformation,
1577 ProcessWow64Information,
1578 ProcessImageFileName,
1579 ProcessLUIDDeviceMapsEnabled,
1580 ProcessBreakOnTermination,
1581 ProcessDebugObjectHandle,
1582 ProcessDebugFlags,
1583 ProcessHandleTracing,
1584 ProcessIoPriority,
1585 ProcessExecuteFlags,
1586 ProcessTlsInformation,
1587 ProcessCookie,
1588 ProcessImageInformation,
1589 ProcessCycleTime,
1590 ProcessPagePriority,
1591 ProcessInstrumentationCallback,
1592 ProcessThreadStackAllocation,
1593 ProcessWorkingSetWatchEx,
1594 ProcessImageFileNameWin32,
1595 ProcessImageFileMapping,
1596 ProcessAffinityUpdateMode,
1597 ProcessMemoryAllocationMode,
1598 ProcessGroupInformation,
1599 ProcessTokenVirtualizationEnabled,
1600 ProcessConsoleHostProcess,
1601 ProcessWindowInformation,
1602 MaxProcessInfoClass
1603 } PROCESSINFOCLASS;
1604
1605 typedef enum _THREADINFOCLASS {
1606 ThreadBasicInformation,
1607 ThreadTimes,
1608 ThreadPriority,
1609 ThreadBasePriority,
1610 ThreadAffinityMask,
1611 ThreadImpersonationToken,
1612 ThreadDescriptorTableEntry,
1613 ThreadEnableAlignmentFaultFixup,
1614 ThreadEventPair_Reusable,
1615 ThreadQuerySetWin32StartAddress,
1616 ThreadZeroTlsCell,
1617 ThreadPerformanceCount,
1618 ThreadAmILastThread,
1619 ThreadIdealProcessor,
1620 ThreadPriorityBoost,
1621 ThreadSetTlsArrayAddress,
1622 ThreadIsIoPending,
1623 ThreadHideFromDebugger,
1624 ThreadBreakOnTermination,
1625 ThreadSwitchLegacyState,
1626 ThreadIsTerminated,
1627 ThreadLastSystemCall,
1628 ThreadIoPriority,
1629 ThreadCycleTime,
1630 ThreadPagePriority,
1631 ThreadActualBasePriority,
1632 ThreadTebInformation,
1633 ThreadCSwitchMon,
1634 ThreadCSwitchPmu,
1635 ThreadWow64Context,
1636 ThreadGroupInformation,
1637 ThreadUmsInformation,
1638 ThreadCounterProfiling,
1639 ThreadIdealProcessorEx,
1640 MaxThreadInfoClass
1641 } THREADINFOCLASS;
1642
1643 typedef struct _PROCESS_BASIC_INFORMATION {
1644 NTSTATUS ExitStatus;
1645 struct _PEB *PebBaseAddress;
1646 ULONG_PTR AffinityMask;
1647 KPRIORITY BasePriority;
1648 ULONG_PTR UniqueProcessId;
1649 ULONG_PTR InheritedFromUniqueProcessId;
1650 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1651
1652 typedef struct _PROCESS_WS_WATCH_INFORMATION {
1653 PVOID FaultingPc;
1654 PVOID FaultingVa;
1655 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1656
1657 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
1658 __GNU_EXTENSION union {
1659 struct {
1660 HANDLE DirectoryHandle;
1661 } Set;
1662 struct {
1663 ULONG DriveMap;
1664 UCHAR DriveType[32];
1665 } Query;
1666 };
1667 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1668
1669 typedef struct _KERNEL_USER_TIMES {
1670 LARGE_INTEGER CreateTime;
1671 LARGE_INTEGER ExitTime;
1672 LARGE_INTEGER KernelTime;
1673 LARGE_INTEGER UserTime;
1674 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1675
1676 typedef struct _PROCESS_ACCESS_TOKEN {
1677 HANDLE Token;
1678 HANDLE Thread;
1679 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1680
1681 typedef struct _PROCESS_SESSION_INFORMATION {
1682 ULONG SessionId;
1683 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1684
1685 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
1686 IoQueryDeviceIdentifier = 0,
1687 IoQueryDeviceConfigurationData,
1688 IoQueryDeviceComponentInformation,
1689 IoQueryDeviceMaxData
1690 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
1691
1692 typedef struct _DISK_SIGNATURE {
1693 ULONG PartitionStyle;
1694 _ANONYMOUS_UNION union {
1695 struct {
1696 ULONG Signature;
1697 ULONG CheckSum;
1698 } Mbr;
1699 struct {
1700 GUID DiskId;
1701 } Gpt;
1702 } DUMMYUNIONNAME;
1703 } DISK_SIGNATURE, *PDISK_SIGNATURE;
1704
1705 typedef ULONG_PTR
1706 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
1707 IN PVOID Context);
1708
1709 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
1710 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
1711 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
1712 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
1713
1714 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
1715 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
1716 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
1717 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
1718 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
1719
1720 typedef VOID
1721 (NTAPI *PTIMER_APC_ROUTINE)(
1722 IN PVOID TimerContext,
1723 IN ULONG TimerLowValue,
1724 IN LONG TimerHighValue);
1725
1726 typedef struct _KUSER_SHARED_DATA
1727 {
1728 ULONG TickCountLowDeprecated;
1729 ULONG TickCountMultiplier;
1730 volatile KSYSTEM_TIME InterruptTime;
1731 volatile KSYSTEM_TIME SystemTime;
1732 volatile KSYSTEM_TIME TimeZoneBias;
1733 USHORT ImageNumberLow;
1734 USHORT ImageNumberHigh;
1735 WCHAR NtSystemRoot[260];
1736 ULONG MaxStackTraceDepth;
1737 ULONG CryptoExponent;
1738 ULONG TimeZoneId;
1739 ULONG LargePageMinimum;
1740 ULONG Reserved2[7];
1741 NT_PRODUCT_TYPE NtProductType;
1742 BOOLEAN ProductTypeIsValid;
1743 ULONG NtMajorVersion;
1744 ULONG NtMinorVersion;
1745 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1746 ULONG Reserved1;
1747 ULONG Reserved3;
1748 volatile ULONG TimeSlip;
1749 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1750 ULONG AltArchitecturePad[1];
1751 LARGE_INTEGER SystemExpirationDate;
1752 ULONG SuiteMask;
1753 BOOLEAN KdDebuggerEnabled;
1754 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1755 UCHAR NXSupportPolicy;
1756 #endif
1757 volatile ULONG ActiveConsoleId;
1758 volatile ULONG DismountCount;
1759 ULONG ComPlusPackage;
1760 ULONG LastSystemRITEventTickCount;
1761 ULONG NumberOfPhysicalPages;
1762 BOOLEAN SafeBootMode;
1763 #if (NTDDI_VERSION >= NTDDI_WIN7)
1764 union {
1765 UCHAR TscQpcData;
1766 struct {
1767 UCHAR TscQpcEnabled:1;
1768 UCHAR TscQpcSpareFlag:1;
1769 UCHAR TscQpcShift:6;
1770 } DUMMYSTRUCTNAME;
1771 } DUMMYUNIONNAME;
1772 UCHAR TscQpcPad[2];
1773 #endif
1774 #if (NTDDI_VERSION >= NTDDI_VISTA)
1775 union {
1776 ULONG SharedDataFlags;
1777 struct {
1778 ULONG DbgErrorPortPresent:1;
1779 ULONG DbgElevationEnabled:1;
1780 ULONG DbgVirtEnabled:1;
1781 ULONG DbgInstallerDetectEnabled:1;
1782 ULONG DbgSystemDllRelocated:1;
1783 ULONG DbgDynProcessorEnabled:1;
1784 ULONG DbgSEHValidationEnabled:1;
1785 ULONG SpareBits:25;
1786 } DUMMYSTRUCTNAME2;
1787 } DUMMYUNIONNAME2;
1788 #else
1789 ULONG TraceLogging;
1790 #endif
1791 ULONG DataFlagsPad[1];
1792 ULONGLONG TestRetInstruction;
1793 ULONG SystemCall;
1794 ULONG SystemCallReturn;
1795 ULONGLONG SystemCallPad[3];
1796 _ANONYMOUS_UNION union {
1797 volatile KSYSTEM_TIME TickCount;
1798 volatile ULONG64 TickCountQuad;
1799 _ANONYMOUS_STRUCT struct {
1800 ULONG ReservedTickCountOverlay[3];
1801 ULONG TickCountPad[1];
1802 } DUMMYSTRUCTNAME;
1803 } DUMMYUNIONNAME3;
1804 ULONG Cookie;
1805 ULONG CookiePad[1];
1806 #if (NTDDI_VERSION >= NTDDI_WS03)
1807 LONGLONG ConsoleSessionForegroundProcessId;
1808 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
1809 #endif
1810 #if (NTDDI_VERSION >= NTDDI_VISTA)
1811 #if (NTDDI_VERSION >= NTDDI_WIN7)
1812 USHORT UserModeGlobalLogger[16];
1813 #else
1814 USHORT UserModeGlobalLogger[8];
1815 ULONG HeapTracingPid[2];
1816 ULONG CritSecTracingPid[2];
1817 #endif
1818 ULONG ImageFileExecutionOptions;
1819 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1820 ULONG LangGenerationCount;
1821 #else
1822 /* 4 bytes padding */
1823 #endif
1824 ULONGLONG Reserved5;
1825 volatile ULONG64 InterruptTimeBias;
1826 #endif
1827 #if (NTDDI_VERSION >= NTDDI_WIN7)
1828 volatile ULONG64 TscQpcBias;
1829 volatile ULONG ActiveProcessorCount;
1830 volatile USHORT ActiveGroupCount;
1831 USHORT Reserved4;
1832 volatile ULONG AitSamplingValue;
1833 volatile ULONG AppCompatFlag;
1834 ULONGLONG SystemDllNativeRelocation;
1835 ULONG SystemDllWowRelocation;
1836 ULONG XStatePad[1];
1837 XSTATE_CONFIGURATION XState;
1838 #endif
1839 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
1840
1841 extern NTKERNELAPI PVOID MmHighestUserAddress;
1842 extern NTKERNELAPI PVOID MmSystemRangeStart;
1843 extern NTKERNELAPI ULONG MmUserProbeAddress;
1844
1845
1846 #ifdef _X86_
1847
1848 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
1849 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
1850 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
1851 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
1852 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
1853 #else
1854 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
1855 #endif
1856 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
1857 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
1858 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
1859 #if !defined (_X86PAE_)
1860 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
1861 #else
1862 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
1863 #endif
1864
1865 #define KeGetPcr() PCR
1866
1867 #define KERNEL_STACK_SIZE 12288
1868 #define KERNEL_LARGE_STACK_SIZE 61440
1869 #define KERNEL_LARGE_STACK_COMMIT 12288
1870
1871 #define SIZE_OF_80387_REGISTERS 80
1872
1873 #define PCR_MINOR_VERSION 1
1874 #define PCR_MAJOR_VERSION 1
1875
1876 #if !defined(RC_INVOKED)
1877
1878 #define CONTEXT_i386 0x10000
1879 #define CONTEXT_i486 0x10000
1880 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
1881 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
1882 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
1883 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
1884 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
1885 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
1886
1887 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
1888
1889 #endif /* !defined(RC_INVOKED) */
1890
1891 typedef struct _KPCR {
1892 union {
1893 NT_TIB NtTib;
1894 struct {
1895 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
1896 PVOID Used_StackBase;
1897 PVOID Spare2;
1898 PVOID TssCopy;
1899 ULONG ContextSwitches;
1900 KAFFINITY SetMemberCopy;
1901 PVOID Used_Self;
1902 };
1903 };
1904 struct _KPCR *SelfPcr;
1905 struct _KPRCB *Prcb;
1906 KIRQL Irql;
1907 ULONG IRR;
1908 ULONG IrrActive;
1909 ULONG IDR;
1910 PVOID KdVersionBlock;
1911 struct _KIDTENTRY *IDT;
1912 struct _KGDTENTRY *GDT;
1913 struct _KTSS *TSS;
1914 USHORT MajorVersion;
1915 USHORT MinorVersion;
1916 KAFFINITY SetMember;
1917 ULONG StallScaleFactor;
1918 UCHAR SpareUnused;
1919 UCHAR Number;
1920 UCHAR Spare0;
1921 UCHAR SecondLevelCacheAssociativity;
1922 ULONG VdmAlert;
1923 ULONG KernelReserved[14];
1924 ULONG SecondLevelCacheSize;
1925 ULONG HalReserved[16];
1926 } KPCR, *PKPCR;
1927
1928 FORCEINLINE
1929 ULONG
1930 KeGetCurrentProcessorNumber(VOID)
1931 {
1932 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
1933 }
1934
1935 typedef struct _FLOATING_SAVE_AREA {
1936 ULONG ControlWord;
1937 ULONG StatusWord;
1938 ULONG TagWord;
1939 ULONG ErrorOffset;
1940 ULONG ErrorSelector;
1941 ULONG DataOffset;
1942 ULONG DataSelector;
1943 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
1944 ULONG Cr0NpxState;
1945 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1946
1947 #include "pshpack4.h"
1948 typedef struct _CONTEXT {
1949 ULONG ContextFlags;
1950 ULONG Dr0;
1951 ULONG Dr1;
1952 ULONG Dr2;
1953 ULONG Dr3;
1954 ULONG Dr6;
1955 ULONG Dr7;
1956 FLOATING_SAVE_AREA FloatSave;
1957 ULONG SegGs;
1958 ULONG SegFs;
1959 ULONG SegEs;
1960 ULONG SegDs;
1961 ULONG Edi;
1962 ULONG Esi;
1963 ULONG Ebx;
1964 ULONG Edx;
1965 ULONG Ecx;
1966 ULONG Eax;
1967 ULONG Ebp;
1968 ULONG Eip;
1969 ULONG SegCs;
1970 ULONG EFlags;
1971 ULONG Esp;
1972 ULONG SegSs;
1973 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
1974 } CONTEXT;
1975 #include "poppack.h"
1976
1977 #endif /* _X86_ */
1978
1979 #ifdef _AMD64_
1980
1981 #define PTI_SHIFT 12L
1982 #define PDI_SHIFT 21L
1983 #define PPI_SHIFT 30L
1984 #define PXI_SHIFT 39L
1985 #define PTE_PER_PAGE 512
1986 #define PDE_PER_PAGE 512
1987 #define PPE_PER_PAGE 512
1988 #define PXE_PER_PAGE 512
1989 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
1990 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
1991 #define PPI_MASK (PPE_PER_PAGE - 1)
1992 #define PXI_MASK (PXE_PER_PAGE - 1)
1993
1994 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
1995 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
1996 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
1997 #define PDE_BASE 0xFFFFF6FB40000000ULL
1998 #define PTE_BASE 0xFFFFF68000000000ULL
1999 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
2000 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
2001 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
2002 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
2003
2004 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2005 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2006 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2007 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2008 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
2009 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
2010
2011 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
2012 ULONG64 P1Home;
2013 ULONG64 P2Home;
2014 ULONG64 P3Home;
2015 ULONG64 P4Home;
2016 ULONG64 P5Home;
2017 ULONG64 P6Home;
2018
2019 /* Control flags */
2020 ULONG ContextFlags;
2021 ULONG MxCsr;
2022
2023 /* Segment */
2024 USHORT SegCs;
2025 USHORT SegDs;
2026 USHORT SegEs;
2027 USHORT SegFs;
2028 USHORT SegGs;
2029 USHORT SegSs;
2030 ULONG EFlags;
2031
2032 /* Debug */
2033 ULONG64 Dr0;
2034 ULONG64 Dr1;
2035 ULONG64 Dr2;
2036 ULONG64 Dr3;
2037 ULONG64 Dr6;
2038 ULONG64 Dr7;
2039
2040 /* Integer */
2041 ULONG64 Rax;
2042 ULONG64 Rcx;
2043 ULONG64 Rdx;
2044 ULONG64 Rbx;
2045 ULONG64 Rsp;
2046 ULONG64 Rbp;
2047 ULONG64 Rsi;
2048 ULONG64 Rdi;
2049 ULONG64 R8;
2050 ULONG64 R9;
2051 ULONG64 R10;
2052 ULONG64 R11;
2053 ULONG64 R12;
2054 ULONG64 R13;
2055 ULONG64 R14;
2056 ULONG64 R15;
2057
2058 /* Counter */
2059 ULONG64 Rip;
2060
2061 /* Floating point */
2062 union {
2063 XMM_SAVE_AREA32 FltSave;
2064 struct {
2065 M128A Header[2];
2066 M128A Legacy[8];
2067 M128A Xmm0;
2068 M128A Xmm1;
2069 M128A Xmm2;
2070 M128A Xmm3;
2071 M128A Xmm4;
2072 M128A Xmm5;
2073 M128A Xmm6;
2074 M128A Xmm7;
2075 M128A Xmm8;
2076 M128A Xmm9;
2077 M128A Xmm10;
2078 M128A Xmm11;
2079 M128A Xmm12;
2080 M128A Xmm13;
2081 M128A Xmm14;
2082 M128A Xmm15;
2083 } DUMMYSTRUCTNAME;
2084 } DUMMYUNIONNAME;
2085
2086 /* Vector */
2087 M128A VectorRegister[26];
2088 ULONG64 VectorControl;
2089
2090 /* Debug control */
2091 ULONG64 DebugControl;
2092 ULONG64 LastBranchToRip;
2093 ULONG64 LastBranchFromRip;
2094 ULONG64 LastExceptionToRip;
2095 ULONG64 LastExceptionFromRip;
2096 } CONTEXT;
2097
2098 typedef struct _KPCR
2099 {
2100 _ANONYMOUS_UNION union
2101 {
2102 NT_TIB NtTib;
2103 _ANONYMOUS_STRUCT struct
2104 {
2105 union _KGDTENTRY64 *GdtBase;
2106 struct _KTSS64 *TssBase;
2107 ULONG64 UserRsp;
2108 struct _KPCR *Self;
2109 struct _KPRCB *CurrentPrcb;
2110 PKSPIN_LOCK_QUEUE LockArray;
2111 PVOID Used_Self;
2112 };
2113 };
2114 union _KIDTENTRY64 *IdtBase;
2115 ULONG64 Unused[2];
2116 KIRQL Irql;
2117 UCHAR SecondLevelCacheAssociativity;
2118 UCHAR ObsoleteNumber;
2119 UCHAR Fill0;
2120 ULONG Unused0[3];
2121 USHORT MajorVersion;
2122 USHORT MinorVersion;
2123 ULONG StallScaleFactor;
2124 PVOID Unused1[3];
2125 ULONG KernelReserved[15];
2126 ULONG SecondLevelCacheSize;
2127 ULONG HalReserved[16];
2128 ULONG Unused2;
2129 PVOID KdVersionBlock;
2130 PVOID Unused3;
2131 ULONG PcrAlign1[24];
2132 } KPCR, *PKPCR;
2133
2134 FORCEINLINE
2135 PKPCR
2136 KeGetPcr(VOID)
2137 {
2138 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
2139 }
2140
2141 FORCEINLINE
2142 ULONG
2143 KeGetCurrentProcessorNumber(VOID)
2144 {
2145 return (ULONG)__readgsword(0x184);
2146 }
2147
2148 #if !defined(RC_INVOKED)
2149
2150 #define CONTEXT_AMD64 0x100000
2151
2152 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
2153 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
2154 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
2155 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
2156 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
2157
2158 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2159 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2160
2161 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
2162
2163 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2164 #define CONTEXT_SERVICE_ACTIVE 0x10000000
2165 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2166 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2167
2168 #endif /* RC_INVOKED */
2169
2170 #endif /* _AMD64_ */
2171
2172 typedef enum _INTERLOCKED_RESULT {
2173 ResultNegative = RESULT_NEGATIVE,
2174 ResultZero = RESULT_ZERO,
2175 ResultPositive = RESULT_POSITIVE
2176 } INTERLOCKED_RESULT;
2177
2178 typedef struct _OSVERSIONINFOA {
2179 ULONG dwOSVersionInfoSize;
2180 ULONG dwMajorVersion;
2181 ULONG dwMinorVersion;
2182 ULONG dwBuildNumber;
2183 ULONG dwPlatformId;
2184 CHAR szCSDVersion[128];
2185 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2186
2187 typedef struct _OSVERSIONINFOW {
2188 ULONG dwOSVersionInfoSize;
2189 ULONG dwMajorVersion;
2190 ULONG dwMinorVersion;
2191 ULONG dwBuildNumber;
2192 ULONG dwPlatformId;
2193 WCHAR szCSDVersion[128];
2194 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2195
2196 typedef struct _OSVERSIONINFOEXA {
2197 ULONG dwOSVersionInfoSize;
2198 ULONG dwMajorVersion;
2199 ULONG dwMinorVersion;
2200 ULONG dwBuildNumber;
2201 ULONG dwPlatformId;
2202 CHAR szCSDVersion[128];
2203 USHORT wServicePackMajor;
2204 USHORT wServicePackMinor;
2205 USHORT wSuiteMask;
2206 UCHAR wProductType;
2207 UCHAR wReserved;
2208 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2209
2210 typedef struct _OSVERSIONINFOEXW {
2211 ULONG dwOSVersionInfoSize;
2212 ULONG dwMajorVersion;
2213 ULONG dwMinorVersion;
2214 ULONG dwBuildNumber;
2215 ULONG dwPlatformId;
2216 WCHAR szCSDVersion[128];
2217 USHORT wServicePackMajor;
2218 USHORT wServicePackMinor;
2219 USHORT wSuiteMask;
2220 UCHAR wProductType;
2221 UCHAR wReserved;
2222 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2223
2224 #ifdef UNICODE
2225 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2226 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2227 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2228 typedef OSVERSIONINFOW OSVERSIONINFO;
2229 typedef POSVERSIONINFOW POSVERSIONINFO;
2230 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2231 #else
2232 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2233 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2234 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2235 typedef OSVERSIONINFOA OSVERSIONINFO;
2236 typedef POSVERSIONINFOA POSVERSIONINFO;
2237 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2238 #endif /* UNICODE */
2239
2240 /* Executive Types */
2241
2242 #define PROTECTED_POOL 0x80000000
2243
2244 typedef struct _ZONE_SEGMENT_HEADER {
2245 SINGLE_LIST_ENTRY SegmentList;
2246 PVOID Reserved;
2247 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2248
2249 typedef struct _ZONE_HEADER {
2250 SINGLE_LIST_ENTRY FreeList;
2251 SINGLE_LIST_ENTRY SegmentList;
2252 ULONG BlockSize;
2253 ULONG TotalSegmentSize;
2254 } ZONE_HEADER, *PZONE_HEADER;
2255
2256 /* Executive Functions */
2257
2258 static __inline PVOID
2259 ExAllocateFromZone(
2260 IN PZONE_HEADER Zone)
2261 {
2262 if (Zone->FreeList.Next)
2263 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2264 return (PVOID) Zone->FreeList.Next;
2265 }
2266
2267 static __inline PVOID
2268 ExFreeToZone(
2269 IN PZONE_HEADER Zone,
2270 IN PVOID Block)
2271 {
2272 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2273 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2274 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2275 }
2276
2277 /*
2278 * PVOID
2279 * ExInterlockedAllocateFromZone(
2280 * IN PZONE_HEADER Zone,
2281 * IN PKSPIN_LOCK Lock)
2282 */
2283 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2284 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2285
2286 /* PVOID
2287 * ExInterlockedFreeToZone(
2288 * IN PZONE_HEADER Zone,
2289 * IN PVOID Block,
2290 * IN PKSPIN_LOCK Lock);
2291 */
2292 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2293 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2294
2295 /*
2296 * BOOLEAN
2297 * ExIsFullZone(
2298 * IN PZONE_HEADER Zone)
2299 */
2300 #define ExIsFullZone(Zone) \
2301 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2302
2303 /* BOOLEAN
2304 * ExIsObjectInFirstZoneSegment(
2305 * IN PZONE_HEADER Zone,
2306 * IN PVOID Object);
2307 */
2308 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2309 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2310 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2311 (Zone)->TotalSegmentSize)) )
2312
2313 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2314 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2315 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2316 #define ExDeleteResource ExDeleteResourceLite
2317 #define ExInitializeResource ExInitializeResourceLite
2318 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2319 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2320 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2321 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2322
2323 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2324
2325 NTKERNELAPI
2326 NTSTATUS
2327 NTAPI
2328 ExExtendZone(
2329 IN OUT PZONE_HEADER Zone,
2330 IN OUT PVOID Segment,
2331 IN ULONG SegmentSize);
2332
2333 NTKERNELAPI
2334 NTSTATUS
2335 NTAPI
2336 ExInitializeZone(
2337 OUT PZONE_HEADER Zone,
2338 IN ULONG BlockSize,
2339 IN OUT PVOID InitialSegment,
2340 IN ULONG InitialSegmentSize);
2341
2342 NTKERNELAPI
2343 NTSTATUS
2344 NTAPI
2345 ExInterlockedExtendZone(
2346 IN OUT PZONE_HEADER Zone,
2347 IN OUT PVOID Segment,
2348 IN ULONG SegmentSize,
2349 IN OUT PKSPIN_LOCK Lock);
2350
2351 NTKERNELAPI
2352 NTSTATUS
2353 NTAPI
2354 ExUuidCreate(
2355 OUT UUID *Uuid);
2356
2357 NTKERNELAPI
2358 DECLSPEC_NORETURN
2359 VOID
2360 NTAPI
2361 ExRaiseAccessViolation(
2362 VOID);
2363
2364 NTKERNELAPI
2365 DECLSPEC_NORETURN
2366 VOID
2367 NTAPI
2368 ExRaiseDatatypeMisalignment(
2369 VOID);
2370
2371 #endif
2372
2373 #ifdef _X86_
2374
2375 NTKERNELAPI
2376 INTERLOCKED_RESULT
2377 FASTCALL
2378 Exfi386InterlockedIncrementLong(
2379 IN OUT LONG volatile *Addend);
2380
2381 NTKERNELAPI
2382 INTERLOCKED_RESULT
2383 FASTCALL
2384 Exfi386InterlockedDecrementLong(
2385 IN PLONG Addend);
2386
2387 NTKERNELAPI
2388 ULONG
2389 FASTCALL
2390 Exfi386InterlockedExchangeUlong(
2391 IN PULONG Target,
2392 IN ULONG Value);
2393
2394 #endif /* _X86_ */
2395
2396 #ifndef _ARC_DDK_
2397 #define _ARC_DDK_
2398 typedef enum _CONFIGURATION_TYPE {
2399 ArcSystem,
2400 CentralProcessor,
2401 FloatingPointProcessor,
2402 PrimaryIcache,
2403 PrimaryDcache,
2404 SecondaryIcache,
2405 SecondaryDcache,
2406 SecondaryCache,
2407 EisaAdapter,
2408 TcAdapter,
2409 ScsiAdapter,
2410 DtiAdapter,
2411 MultiFunctionAdapter,
2412 DiskController,
2413 TapeController,
2414 CdromController,
2415 WormController,
2416 SerialController,
2417 NetworkController,
2418 DisplayController,
2419 ParallelController,
2420 PointerController,
2421 KeyboardController,
2422 AudioController,
2423 OtherController,
2424 DiskPeripheral,
2425 FloppyDiskPeripheral,
2426 TapePeripheral,
2427 ModemPeripheral,
2428 MonitorPeripheral,
2429 PrinterPeripheral,
2430 PointerPeripheral,
2431 KeyboardPeripheral,
2432 TerminalPeripheral,
2433 OtherPeripheral,
2434 LinePeripheral,
2435 NetworkPeripheral,
2436 SystemMemory,
2437 DockingInformation,
2438 RealModeIrqRoutingTable,
2439 RealModePCIEnumeration,
2440 MaximumType
2441 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2442 #endif /* !_ARC_DDK_ */
2443
2444 typedef struct _CONTROLLER_OBJECT {
2445 CSHORT Type;
2446 CSHORT Size;
2447 PVOID ControllerExtension;
2448 KDEVICE_QUEUE DeviceWaitQueue;
2449 ULONG Spare1;
2450 LARGE_INTEGER Spare2;
2451 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
2452
2453 typedef struct _CONFIGURATION_INFORMATION {
2454 ULONG DiskCount;
2455 ULONG FloppyCount;
2456 ULONG CdRomCount;
2457 ULONG TapeCount;
2458 ULONG ScsiPortCount;
2459 ULONG SerialCount;
2460 ULONG ParallelCount;
2461 BOOLEAN AtDiskPrimaryAddressClaimed;
2462 BOOLEAN AtDiskSecondaryAddressClaimed;
2463 ULONG Version;
2464 ULONG MediumChangerCount;
2465 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2466
2467 typedef
2468 NTSTATUS
2469 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
2470 IN PVOID Context,
2471 IN PUNICODE_STRING PathName,
2472 IN INTERFACE_TYPE BusType,
2473 IN ULONG BusNumber,
2474 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2475 IN CONFIGURATION_TYPE ControllerType,
2476 IN ULONG ControllerNumber,
2477 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2478 IN CONFIGURATION_TYPE PeripheralType,
2479 IN ULONG PeripheralNumber,
2480 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
2481
2482 typedef
2483 VOID
2484 (NTAPI DRIVER_REINITIALIZE)(
2485 IN struct _DRIVER_OBJECT *DriverObject,
2486 IN PVOID Context,
2487 IN ULONG Count);
2488
2489 typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE;
2490
2491 /** Filesystem runtime library routines **/
2492
2493 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2494 NTKERNELAPI
2495 BOOLEAN
2496 NTAPI
2497 FsRtlIsTotalDeviceFailure(
2498 IN NTSTATUS Status);
2499 #endif
2500
2501 /* Hardware Abstraction Layer Types */
2502
2503 typedef VOID
2504 (NTAPI *PciPin2Line)(
2505 IN struct _BUS_HANDLER *BusHandler,
2506 IN struct _BUS_HANDLER *RootHandler,
2507 IN PCI_SLOT_NUMBER SlotNumber,
2508 IN PPCI_COMMON_CONFIG PciData);
2509
2510 typedef VOID
2511 (NTAPI *PciLine2Pin)(
2512 IN struct _BUS_HANDLER *BusHandler,
2513 IN struct _BUS_HANDLER *RootHandler,
2514 IN PCI_SLOT_NUMBER SlotNumber,
2515 IN PPCI_COMMON_CONFIG PciNewData,
2516 IN PPCI_COMMON_CONFIG PciOldData);
2517
2518 typedef VOID
2519 (NTAPI *PciReadWriteConfig)(
2520 IN struct _BUS_HANDLER *BusHandler,
2521 IN PCI_SLOT_NUMBER Slot,
2522 IN PVOID Buffer,
2523 IN ULONG Offset,
2524 IN ULONG Length);
2525
2526 #define PCI_DATA_TAG ' ICP'
2527 #define PCI_DATA_VERSION 1
2528
2529 typedef struct _PCIBUSDATA {
2530 ULONG Tag;
2531 ULONG Version;
2532 PciReadWriteConfig ReadConfig;
2533 PciReadWriteConfig WriteConfig;
2534 PciPin2Line Pin2Line;
2535 PciLine2Pin Line2Pin;
2536 PCI_SLOT_NUMBER ParentSlot;
2537 PVOID Reserved[4];
2538 } PCIBUSDATA, *PPCIBUSDATA;
2539
2540 /* Hardware Abstraction Layer Functions */
2541
2542 #if !defined(NO_LEGACY_DRIVERS)
2543
2544 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2545
2546 NTHALAPI
2547 NTSTATUS
2548 NTAPI
2549 HalAssignSlotResources(
2550 IN PUNICODE_STRING RegistryPath,
2551 IN PUNICODE_STRING DriverClassName,
2552 IN PDRIVER_OBJECT DriverObject,
2553 IN PDEVICE_OBJECT DeviceObject,
2554 IN INTERFACE_TYPE BusType,
2555 IN ULONG BusNumber,
2556 IN ULONG SlotNumber,
2557 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2558
2559 NTHALAPI
2560 ULONG
2561 NTAPI
2562 HalGetInterruptVector(
2563 IN INTERFACE_TYPE InterfaceType,
2564 IN ULONG BusNumber,
2565 IN ULONG BusInterruptLevel,
2566 IN ULONG BusInterruptVector,
2567 OUT PKIRQL Irql,
2568 OUT PKAFFINITY Affinity);
2569
2570 NTHALAPI
2571 ULONG
2572 NTAPI
2573 HalSetBusData(
2574 IN BUS_DATA_TYPE BusDataType,
2575 IN ULONG BusNumber,
2576 IN ULONG SlotNumber,
2577 IN PVOID Buffer,
2578 IN ULONG Length);
2579
2580 #endif
2581
2582 #endif /* !defined(NO_LEGACY_DRIVERS) */
2583
2584 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2585
2586 NTHALAPI
2587 PADAPTER_OBJECT
2588 NTAPI
2589 HalGetAdapter(
2590 IN PDEVICE_DESCRIPTION DeviceDescription,
2591 IN OUT PULONG NumberOfMapRegisters);
2592
2593 NTHALAPI
2594 BOOLEAN
2595 NTAPI
2596 HalMakeBeep(
2597 IN ULONG Frequency);
2598
2599 VOID
2600 NTAPI
2601 HalPutDmaAdapter(
2602 IN PADAPTER_OBJECT DmaAdapter);
2603
2604 NTHALAPI
2605 VOID
2606 NTAPI
2607 HalAcquireDisplayOwnership(
2608 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
2609
2610 NTHALAPI
2611 ULONG
2612 NTAPI
2613 HalGetBusData(
2614 IN BUS_DATA_TYPE BusDataType,
2615 IN ULONG BusNumber,
2616 IN ULONG SlotNumber,
2617 OUT PVOID Buffer,
2618 IN ULONG Length);
2619
2620 NTHALAPI
2621 ULONG
2622 NTAPI
2623 HalGetBusDataByOffset(
2624 IN BUS_DATA_TYPE BusDataType,
2625 IN ULONG BusNumber,
2626 IN ULONG SlotNumber,
2627 OUT PVOID Buffer,
2628 IN ULONG Offset,
2629 IN ULONG Length);
2630
2631 NTHALAPI
2632 ULONG
2633 NTAPI
2634 HalSetBusDataByOffset(
2635 IN BUS_DATA_TYPE BusDataType,
2636 IN ULONG BusNumber,
2637 IN ULONG SlotNumber,
2638 IN PVOID Buffer,
2639 IN ULONG Offset,
2640 IN ULONG Length);
2641
2642 NTHALAPI
2643 BOOLEAN
2644 NTAPI
2645 HalTranslateBusAddress(
2646 IN INTERFACE_TYPE InterfaceType,
2647 IN ULONG BusNumber,
2648 IN PHYSICAL_ADDRESS BusAddress,
2649 IN OUT PULONG AddressSpace,
2650 OUT PPHYSICAL_ADDRESS TranslatedAddress);
2651
2652 #endif
2653
2654 #if (NTDDI_VERSION >= NTDDI_WINXP)
2655 NTKERNELAPI
2656 VOID
2657 FASTCALL
2658 HalExamineMBR(
2659 IN PDEVICE_OBJECT DeviceObject,
2660 IN ULONG SectorSize,
2661 IN ULONG MBRTypeIdentifier,
2662 OUT PVOID *Buffer);
2663 #endif
2664
2665 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
2666 // nothing here
2667 #else
2668
2669 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2670 //DECLSPEC_DEPRECATED_DDK
2671 NTHALAPI
2672 VOID
2673 NTAPI
2674 IoFreeAdapterChannel(
2675 IN PADAPTER_OBJECT AdapterObject);
2676
2677 //DECLSPEC_DEPRECATED_DDK
2678 NTHALAPI
2679 BOOLEAN
2680 NTAPI
2681 IoFlushAdapterBuffers(
2682 IN PADAPTER_OBJECT AdapterObject,
2683 IN PMDL Mdl,
2684 IN PVOID MapRegisterBase,
2685 IN PVOID CurrentVa,
2686 IN ULONG Length,
2687 IN BOOLEAN WriteToDevice);
2688
2689 //DECLSPEC_DEPRECATED_DDK
2690 NTHALAPI
2691 VOID
2692 NTAPI
2693 IoFreeMapRegisters(
2694 IN PADAPTER_OBJECT AdapterObject,
2695 IN PVOID MapRegisterBase,
2696 IN ULONG NumberOfMapRegisters);
2697
2698 //DECLSPEC_DEPRECATED_DDK
2699 NTHALAPI
2700 PVOID
2701 NTAPI
2702 HalAllocateCommonBuffer(
2703 IN PADAPTER_OBJECT AdapterObject,
2704 IN ULONG Length,
2705 OUT PPHYSICAL_ADDRESS LogicalAddress,
2706 IN BOOLEAN CacheEnabled);
2707
2708 //DECLSPEC_DEPRECATED_DDK
2709 NTHALAPI
2710 VOID
2711 NTAPI
2712 HalFreeCommonBuffer(
2713 IN PADAPTER_OBJECT AdapterObject,
2714 IN ULONG Length,
2715 IN PHYSICAL_ADDRESS LogicalAddress,
2716 IN PVOID VirtualAddress,
2717 IN BOOLEAN CacheEnabled);
2718
2719 //DECLSPEC_DEPRECATED_DDK
2720 NTHALAPI
2721 ULONG
2722 NTAPI
2723 HalReadDmaCounter(
2724 IN PADAPTER_OBJECT AdapterObject);
2725
2726 NTHALAPI
2727 NTSTATUS
2728 NTAPI
2729 HalAllocateAdapterChannel(
2730 IN PADAPTER_OBJECT AdapterObject,
2731 IN PWAIT_CONTEXT_BLOCK Wcb,
2732 IN ULONG NumberOfMapRegisters,
2733 IN PDRIVER_CONTROL ExecutionRoutine);
2734
2735 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2736
2737 #endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */
2738
2739 /* I/O Manager Functions */
2740
2741 /*
2742 * VOID IoAssignArcName(
2743 * IN PUNICODE_STRING ArcName,
2744 * IN PUNICODE_STRING DeviceName);
2745 */
2746 #define IoAssignArcName(_ArcName, _DeviceName) ( \
2747 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
2748
2749 /*
2750 * VOID
2751 * IoDeassignArcName(
2752 * IN PUNICODE_STRING ArcName)
2753 */
2754 #define IoDeassignArcName IoDeleteSymbolicLink
2755
2756 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2757
2758 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
2759 NTKERNELAPI
2760 NTSTATUS
2761 NTAPI
2762 IoAllocateAdapterChannel(
2763 IN PADAPTER_OBJECT AdapterObject,
2764 IN PDEVICE_OBJECT DeviceObject,
2765 IN ULONG NumberOfMapRegisters,
2766 IN PDRIVER_CONTROL ExecutionRoutine,
2767 IN PVOID Context);
2768 #endif
2769
2770 #if !defined(DMA_MACROS_DEFINED)
2771 //DECLSPEC_DEPRECATED_DDK
2772 NTHALAPI
2773 PHYSICAL_ADDRESS
2774 NTAPI
2775 IoMapTransfer(
2776 IN PADAPTER_OBJECT AdapterObject,
2777 IN PMDL Mdl,
2778 IN PVOID MapRegisterBase,
2779 IN PVOID CurrentVa,
2780 IN OUT PULONG Length,
2781 IN BOOLEAN WriteToDevice);
2782 #endif
2783
2784 NTKERNELAPI
2785 VOID
2786 NTAPI
2787 IoAllocateController(
2788 IN PCONTROLLER_OBJECT ControllerObject,
2789 IN PDEVICE_OBJECT DeviceObject,
2790 IN PDRIVER_CONTROL ExecutionRoutine,
2791 IN PVOID Context OPTIONAL);
2792
2793 NTKERNELAPI
2794 PCONTROLLER_OBJECT
2795 NTAPI
2796 IoCreateController(
2797 IN ULONG Size);
2798
2799 NTKERNELAPI
2800 VOID
2801 NTAPI
2802 IoDeleteController(
2803 IN PCONTROLLER_OBJECT ControllerObject);
2804
2805 NTKERNELAPI
2806 VOID
2807 NTAPI
2808 IoFreeController(
2809 IN PCONTROLLER_OBJECT ControllerObject);
2810
2811 NTKERNELAPI
2812 PCONFIGURATION_INFORMATION
2813 NTAPI
2814 IoGetConfigurationInformation(
2815 VOID);
2816
2817 NTKERNELAPI
2818 PDEVICE_OBJECT
2819 NTAPI
2820 IoGetDeviceToVerify(
2821 IN PETHREAD Thread);
2822
2823 NTKERNELAPI
2824 VOID
2825 NTAPI
2826 IoCancelFileOpen(
2827 IN PDEVICE_OBJECT DeviceObject,
2828 IN PFILE_OBJECT FileObject);
2829
2830 NTKERNELAPI
2831 PGENERIC_MAPPING
2832 NTAPI
2833 IoGetFileObjectGenericMapping(
2834 VOID);
2835
2836 NTKERNELAPI
2837 PIRP
2838 NTAPI
2839 IoMakeAssociatedIrp(
2840 IN PIRP Irp,
2841 IN CCHAR StackSize);
2842
2843 NTKERNELAPI
2844 NTSTATUS
2845 NTAPI
2846 IoQueryDeviceDescription(
2847 IN PINTERFACE_TYPE BusType OPTIONAL,
2848 IN PULONG BusNumber OPTIONAL,
2849 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
2850 IN PULONG ControllerNumber OPTIONAL,
2851 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
2852 IN PULONG PeripheralNumber OPTIONAL,
2853 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
2854 IN OUT PVOID Context OPTIONAL);
2855
2856 NTKERNELAPI
2857 VOID
2858 NTAPI
2859 IoRaiseHardError(
2860 IN PIRP Irp,
2861 IN PVPB Vpb OPTIONAL,
2862 IN PDEVICE_OBJECT RealDeviceObject);
2863
2864 NTKERNELAPI
2865 BOOLEAN
2866 NTAPI
2867 IoRaiseInformationalHardError(
2868 IN NTSTATUS ErrorStatus,
2869 IN PUNICODE_STRING String OPTIONAL,
2870 IN PKTHREAD Thread OPTIONAL);
2871
2872 NTKERNELAPI
2873 VOID
2874 NTAPI
2875 IoRegisterBootDriverReinitialization(
2876 IN PDRIVER_OBJECT DriverObject,
2877 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2878 IN PVOID Context OPTIONAL);
2879
2880 NTKERNELAPI
2881 VOID
2882 NTAPI
2883 IoRegisterDriverReinitialization(
2884 IN PDRIVER_OBJECT DriverObject,
2885 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2886 IN PVOID Context OPTIONAL);
2887
2888 NTKERNELAPI
2889 NTSTATUS
2890 NTAPI
2891 IoAttachDeviceByPointer(
2892 IN PDEVICE_OBJECT SourceDevice,
2893 IN PDEVICE_OBJECT TargetDevice);
2894
2895 NTKERNELAPI
2896 NTSTATUS
2897 NTAPI
2898 IoReportDetectedDevice(
2899 IN PDRIVER_OBJECT DriverObject,
2900 IN INTERFACE_TYPE LegacyBusType,
2901 IN ULONG BusNumber,
2902 IN ULONG SlotNumber,
2903 IN PCM_RESOURCE_LIST ResourceList OPTIONAL,
2904 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
2905 IN BOOLEAN ResourceAssigned,
2906 IN OUT PDEVICE_OBJECT *DeviceObject);
2907
2908 NTKERNELAPI
2909 NTSTATUS
2910 NTAPI
2911 IoReportResourceForDetection(
2912 IN PDRIVER_OBJECT DriverObject,
2913 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2914 IN ULONG DriverListSize OPTIONAL,
2915 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2916 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2917 IN ULONG DeviceListSize OPTIONAL,
2918 OUT PBOOLEAN ConflictDetected);
2919
2920 NTKERNELAPI
2921 NTSTATUS
2922 NTAPI
2923 IoReportResourceUsage(
2924 IN PUNICODE_STRING DriverClassName OPTIONAL,
2925 IN PDRIVER_OBJECT DriverObject,
2926 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2927 IN ULONG DriverListSize OPTIONAL,
2928 IN PDEVICE_OBJECT DeviceObject,
2929 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2930 IN ULONG DeviceListSize OPTIONAL,
2931 IN BOOLEAN OverrideConflict,
2932 OUT PBOOLEAN ConflictDetected);
2933
2934 NTKERNELAPI
2935 VOID
2936 NTAPI
2937 IoSetHardErrorOrVerifyDevice(
2938 IN PIRP Irp,
2939 IN PDEVICE_OBJECT DeviceObject);
2940
2941 NTKERNELAPI
2942 NTSTATUS
2943 NTAPI
2944 IoAssignResources(
2945 IN PUNICODE_STRING RegistryPath,
2946 IN PUNICODE_STRING DriverClassName OPTIONAL,
2947 IN PDRIVER_OBJECT DriverObject,
2948 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2949 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL,
2950 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2951
2952 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2953
2954 #if (NTDDI_VERSION >= NTDDI_WINXP)
2955
2956 NTKERNELAPI
2957 NTSTATUS
2958 NTAPI
2959 IoCreateDisk(
2960 IN PDEVICE_OBJECT DeviceObject,
2961 IN struct _CREATE_DISK* Disk OPTIONAL);
2962
2963 NTKERNELAPI
2964 NTSTATUS
2965 NTAPI
2966 IoReadDiskSignature(
2967 IN PDEVICE_OBJECT DeviceObject,
2968 IN ULONG BytesPerSector,
2969 OUT PDISK_SIGNATURE Signature);
2970
2971 NTKERNELAPI
2972 NTSTATUS
2973 FASTCALL
2974 IoReadPartitionTable(
2975 IN PDEVICE_OBJECT DeviceObject,
2976 IN ULONG SectorSize,
2977 IN BOOLEAN ReturnRecognizedPartitions,
2978 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2979
2980 NTKERNELAPI
2981 NTSTATUS
2982 NTAPI
2983 IoReadPartitionTableEx(
2984 IN PDEVICE_OBJECT DeviceObject,
2985 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
2986
2987 NTKERNELAPI
2988 NTSTATUS
2989 FASTCALL
2990 IoSetPartitionInformation(
2991 IN PDEVICE_OBJECT DeviceObject,
2992 IN ULONG SectorSize,
2993 IN ULONG PartitionNumber,
2994 IN ULONG PartitionType);
2995
2996 NTKERNELAPI
2997 NTSTATUS
2998 NTAPI
2999 IoSetPartitionInformationEx(
3000 IN PDEVICE_OBJECT DeviceObject,
3001 IN ULONG PartitionNumber,
3002 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
3003
3004 NTKERNELAPI
3005 NTSTATUS
3006 NTAPI
3007 IoSetSystemPartition(
3008 IN PUNICODE_STRING VolumeNameString);
3009
3010 NTKERNELAPI
3011 BOOLEAN
3012 NTAPI
3013 IoSetThreadHardErrorMode(
3014 IN BOOLEAN EnableHardErrors);
3015
3016 NTKERNELAPI
3017 NTSTATUS
3018 NTAPI
3019 IoVerifyPartitionTable(
3020 IN PDEVICE_OBJECT DeviceObject,
3021 IN BOOLEAN FixErrors);
3022
3023 NTKERNELAPI
3024 NTSTATUS
3025 NTAPI
3026 IoVolumeDeviceToDosName(
3027 IN PVOID VolumeDeviceObject,
3028 OUT PUNICODE_STRING DosName);
3029
3030 NTKERNELAPI
3031 NTSTATUS
3032 FASTCALL
3033 IoWritePartitionTable(
3034 IN PDEVICE_OBJECT DeviceObject,
3035 IN ULONG SectorSize,
3036 IN ULONG SectorsPerTrack,
3037 IN ULONG NumberOfHeads,
3038 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
3039
3040 NTKERNELAPI
3041 NTSTATUS
3042 NTAPI
3043 IoWritePartitionTableEx(
3044 IN PDEVICE_OBJECT DeviceObject,
3045 IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
3046
3047 NTKERNELAPI
3048 NTSTATUS
3049 NTAPI
3050 IoAttachDeviceToDeviceStackSafe(
3051 IN PDEVICE_OBJECT SourceDevice,
3052 IN PDEVICE_OBJECT TargetDevice,
3053 OUT PDEVICE_OBJECT *AttachedToDeviceObject);
3054
3055 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3056
3057 /** Kernel debugger routines **/
3058
3059 NTSYSAPI
3060 ULONG
3061 NTAPI
3062 DbgPrompt(
3063 IN PCCH Prompt,
3064 OUT PCH Response,
3065 IN ULONG MaximumResponseLength);
3066
3067 /* Kernel Functions */
3068
3069 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3070
3071 NTKERNELAPI
3072 DECLSPEC_NORETURN
3073 VOID
3074 NTAPI
3075 KeBugCheck(
3076 IN ULONG BugCheckCode);
3077
3078 NTKERNELAPI
3079 LONG
3080 NTAPI
3081 KePulseEvent(
3082 IN OUT PRKEVENT Event,
3083 IN KPRIORITY Increment,
3084 IN BOOLEAN Wait);
3085
3086 NTKERNELAPI
3087 LONG
3088 NTAPI
3089 KeSetBasePriorityThread(
3090 IN OUT PRKTHREAD Thread,
3091 IN LONG Increment);
3092
3093 #endif
3094
3095 /* Memory Manager Types */
3096
3097 typedef struct _PHYSICAL_MEMORY_RANGE {
3098 PHYSICAL_ADDRESS BaseAddress;
3099 LARGE_INTEGER NumberOfBytes;
3100 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3101
3102 /* Memory Manager Functions */
3103
3104 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3105
3106 NTKERNELAPI
3107 PPHYSICAL_MEMORY_RANGE
3108 NTAPI
3109 MmGetPhysicalMemoryRanges(
3110 VOID);
3111
3112 NTKERNELAPI
3113 PHYSICAL_ADDRESS
3114 NTAPI
3115 MmGetPhysicalAddress(
3116 IN PVOID BaseAddress);
3117
3118 NTKERNELAPI
3119 BOOLEAN
3120 NTAPI
3121 MmIsNonPagedSystemAddressValid(
3122 IN PVOID VirtualAddress);
3123
3124 NTKERNELAPI
3125 PVOID
3126 NTAPI
3127 MmAllocateNonCachedMemory(
3128 IN SIZE_T NumberOfBytes);
3129
3130 NTKERNELAPI
3131 VOID
3132 NTAPI
3133 MmFreeNonCachedMemory(
3134 IN PVOID BaseAddress,
3135 IN SIZE_T NumberOfBytes);
3136
3137 NTKERNELAPI
3138 PVOID
3139 NTAPI
3140 MmGetVirtualForPhysical(
3141 IN PHYSICAL_ADDRESS PhysicalAddress);
3142
3143 NTKERNELAPI
3144 NTSTATUS
3145 NTAPI
3146 MmMapUserAddressesToPage(
3147 IN PVOID BaseAddress,
3148 IN SIZE_T NumberOfBytes,
3149 IN PVOID PageAddress);
3150
3151 NTKERNELAPI
3152 PVOID
3153 NTAPI
3154 MmMapVideoDisplay(
3155 IN PHYSICAL_ADDRESS PhysicalAddress,
3156 IN SIZE_T NumberOfBytes,
3157 IN MEMORY_CACHING_TYPE CacheType);
3158
3159 NTKERNELAPI
3160 NTSTATUS
3161 NTAPI
3162 MmMapViewInSessionSpace(
3163 IN PVOID Section,
3164 OUT PVOID *MappedBase,
3165 IN OUT PSIZE_T ViewSize);
3166
3167 NTKERNELAPI
3168 NTSTATUS
3169 NTAPI
3170 MmMapViewInSystemSpace(
3171 IN PVOID Section,
3172 OUT PVOID *MappedBase,
3173 IN OUT PSIZE_T ViewSize);
3174
3175 NTKERNELAPI
3176 BOOLEAN
3177 NTAPI
3178 MmIsAddressValid(
3179 IN PVOID VirtualAddress);
3180
3181 NTKERNELAPI
3182 BOOLEAN
3183 NTAPI
3184 MmIsThisAnNtAsSystem(
3185 VOID);
3186
3187 NTKERNELAPI
3188 VOID
3189 NTAPI
3190 MmLockPagableSectionByHandle(
3191 IN PVOID ImageSectionHandle);
3192
3193 NTKERNELAPI
3194 NTSTATUS
3195 NTAPI
3196 MmUnmapViewInSessionSpace(
3197 IN PVOID MappedBase);
3198
3199 NTKERNELAPI
3200 NTSTATUS
3201 NTAPI
3202 MmUnmapViewInSystemSpace(
3203 IN PVOID MappedBase);
3204
3205 NTKERNELAPI
3206 VOID
3207 NTAPI
3208 MmUnsecureVirtualMemory(
3209 IN HANDLE SecureHandle);
3210
3211 NTKERNELAPI
3212 NTSTATUS
3213 NTAPI
3214 MmRemovePhysicalMemory(
3215 IN PPHYSICAL_ADDRESS StartAddress,
3216 IN OUT PLARGE_INTEGER NumberOfBytes);
3217
3218 NTKERNELAPI
3219 HANDLE
3220 NTAPI
3221 MmSecureVirtualMemory(
3222 IN PVOID Address,
3223 IN SIZE_T Size,
3224 IN ULONG ProbeMode);
3225
3226 NTKERNELAPI
3227 VOID
3228 NTAPI
3229 MmUnmapVideoDisplay(
3230 IN PVOID BaseAddress,
3231 IN SIZE_T NumberOfBytes);
3232
3233 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3234
3235 /* NtXxx Functions */
3236
3237 NTSYSCALLAPI
3238 NTSTATUS
3239 NTAPI
3240 NtOpenProcess(
3241 OUT PHANDLE ProcessHandle,
3242 IN ACCESS_MASK DesiredAccess,
3243 IN POBJECT_ATTRIBUTES ObjectAttributes,
3244 IN PCLIENT_ID ClientId OPTIONAL);
3245
3246 NTSYSCALLAPI
3247 NTSTATUS
3248 NTAPI
3249 NtQueryInformationProcess(
3250 IN HANDLE ProcessHandle,
3251 IN PROCESSINFOCLASS ProcessInformationClass,
3252 OUT PVOID ProcessInformation OPTIONAL,
3253 IN ULONG ProcessInformationLength,
3254 OUT PULONG ReturnLength OPTIONAL);
3255
3256 /** Process manager types **/
3257
3258 typedef VOID
3259 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
3260 IN HANDLE ParentId,
3261 IN HANDLE ProcessId,
3262 IN BOOLEAN Create);
3263
3264 typedef VOID
3265 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
3266 IN HANDLE ProcessId,
3267 IN HANDLE ThreadId,
3268 IN BOOLEAN Create);
3269
3270 typedef VOID
3271 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
3272 IN PUNICODE_STRING FullImageName,
3273 IN HANDLE ProcessId,
3274 IN PIMAGE_INFO ImageInfo);
3275
3276 /** Process manager routines **/
3277
3278 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3279
3280 NTKERNELAPI
3281 NTSTATUS
3282 NTAPI
3283 PsSetLoadImageNotifyRoutine(
3284 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3285
3286 NTKERNELAPI
3287 NTSTATUS
3288 NTAPI
3289 PsSetCreateThreadNotifyRoutine(
3290 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3291
3292 NTKERNELAPI
3293 NTSTATUS
3294 NTAPI
3295 PsSetCreateProcessNotifyRoutine(
3296 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3297 IN BOOLEAN Remove);
3298
3299 NTKERNELAPI
3300 HANDLE
3301 NTAPI
3302 PsGetCurrentProcessId(
3303 VOID);
3304
3305 NTKERNELAPI
3306 HANDLE
3307 NTAPI
3308 PsGetCurrentThreadId(
3309 VOID);
3310
3311 NTKERNELAPI
3312 BOOLEAN
3313 NTAPI
3314 PsGetVersion(
3315 OUT PULONG MajorVersion OPTIONAL,
3316 OUT PULONG MinorVersion OPTIONAL,
3317 OUT PULONG BuildNumber OPTIONAL,
3318 OUT PUNICODE_STRING CSDVersion OPTIONAL);
3319
3320 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3321
3322 #if (NTDDI_VERSION >= NTDDI_WINXP)
3323
3324 NTKERNELAPI
3325 HANDLE
3326 NTAPI
3327 PsGetProcessId(
3328 IN PEPROCESS Process);
3329
3330 NTKERNELAPI
3331 NTSTATUS
3332 NTAPI
3333 PsRemoveCreateThreadNotifyRoutine(
3334 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3335
3336 NTKERNELAPI
3337 NTSTATUS
3338 NTAPI
3339 PsRemoveLoadImageNotifyRoutine(
3340 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3341
3342 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3343
3344 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
3345
3346 /* RTL Types */
3347
3348 typedef struct _RTL_SPLAY_LINKS {
3349 struct _RTL_SPLAY_LINKS *Parent;
3350 struct _RTL_SPLAY_LINKS *LeftChild;
3351 struct _RTL_SPLAY_LINKS *RightChild;
3352 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
3353
3354 /* RTL Functions */
3355
3356 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3357
3358 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3359 *CallersAddress = (PVOID)_ReturnAddress(); \
3360 *CallersCaller = NULL;
3361 #else
3362
3363 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3364 NTSYSAPI
3365 VOID
3366 NTAPI
3367 RtlGetCallersAddress(
3368 OUT PVOID *CallersAddress,
3369 OUT PVOID *CallersCaller);
3370 #endif
3371
3372 #endif
3373
3374 #if !defined(MIDL_PASS)
3375
3376 FORCEINLINE
3377 LUID
3378 NTAPI_INLINE
3379 RtlConvertLongToLuid(
3380 IN LONG Val)
3381 {
3382 LUID Luid;
3383 LARGE_INTEGER Temp;
3384
3385 Temp.QuadPart = Val;
3386 Luid.LowPart = Temp.u.LowPart;
3387 Luid.HighPart = Temp.u.HighPart;
3388 return Luid;
3389 }
3390
3391 FORCEINLINE
3392 LUID
3393 NTAPI_INLINE
3394 RtlConvertUlongToLuid(
3395 IN ULONG Val)
3396 {
3397 LUID Luid;
3398
3399 Luid.LowPart = Val;
3400 Luid.HighPart = 0;
3401 return Luid;
3402 }
3403
3404 #endif
3405
3406 #if defined(_AMD64_) || defined(_IA64_)
3407 //DECLSPEC_DEPRECATED_DDK_WINXP
3408 FORCEINLINE
3409 LARGE_INTEGER
3410 NTAPI_INLINE
3411 RtlLargeIntegerDivide(
3412 IN LARGE_INTEGER Dividend,
3413 IN LARGE_INTEGER Divisor,
3414 OUT PLARGE_INTEGER Remainder OPTIONAL)
3415 {
3416 LARGE_INTEGER ret;
3417 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
3418 if (Remainder)
3419 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
3420 return ret;
3421 }
3422
3423 #else
3424
3425 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3426 NTSYSAPI
3427 LARGE_INTEGER
3428 NTAPI
3429 RtlLargeIntegerDivide(
3430 IN LARGE_INTEGER Dividend,
3431 IN LARGE_INTEGER Divisor,
3432 OUT PLARGE_INTEGER Remainder OPTIONAL);
3433 #endif
3434
3435 #endif /* defined(_AMD64_) || defined(_IA64_) */
3436
3437 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3438
3439 NTSYSAPI
3440 BOOLEAN
3441 NTAPI
3442 RtlPrefixUnicodeString(
3443 IN PCUNICODE_STRING String1,
3444 IN PCUNICODE_STRING String2,
3445 IN BOOLEAN CaseInSensitive);
3446
3447 NTSYSAPI
3448 VOID
3449 NTAPI
3450 RtlUpperString(
3451 IN OUT PSTRING DestinationString,
3452 IN const PSTRING SourceString);
3453
3454 NTSYSAPI
3455 NTSTATUS
3456 NTAPI
3457 RtlUpcaseUnicodeString(
3458 IN OUT PUNICODE_STRING DestinationString,
3459 IN PCUNICODE_STRING SourceString,
3460 IN BOOLEAN AllocateDestinationString);
3461
3462 NTSYSAPI
3463 VOID
3464 NTAPI
3465 RtlMapGenericMask(
3466 IN OUT PACCESS_MASK AccessMask,
3467 IN PGENERIC_MAPPING GenericMapping);
3468
3469 NTSYSAPI
3470 NTSTATUS
3471 NTAPI
3472 RtlVolumeDeviceToDosName(
3473 IN PVOID VolumeDeviceObject,
3474 OUT PUNICODE_STRING DosName);
3475
3476 NTSYSAPI
3477 NTSTATUS
3478 NTAPI
3479 RtlGetVersion(
3480 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
3481
3482 NTSYSAPI
3483 NTSTATUS
3484 NTAPI
3485 RtlVerifyVersionInfo(
3486 IN PRTL_OSVERSIONINFOEXW VersionInfo,
3487 IN ULONG TypeMask,
3488 IN ULONGLONG ConditionMask);
3489
3490 NTSYSAPI
3491 LONG
3492 NTAPI
3493 RtlCompareString(
3494 IN const PSTRING String1,
3495 IN const PSTRING String2,
3496 BOOLEAN CaseInSensitive);
3497
3498 NTSYSAPI
3499 VOID
3500 NTAPI
3501 RtlCopyString(
3502 OUT PSTRING DestinationString,
3503 IN const PSTRING SourceString OPTIONAL);
3504
3505 NTSYSAPI
3506 BOOLEAN
3507 NTAPI
3508 RtlEqualString(
3509 IN const PSTRING String1,
3510 IN const PSTRING String2,
3511 IN BOOLEAN CaseInSensitive);
3512
3513 NTSYSAPI
3514 NTSTATUS
3515 NTAPI
3516 RtlCharToInteger(
3517 IN PCSZ String,
3518 IN ULONG Base OPTIONAL,
3519 OUT PULONG Value);
3520
3521 NTSYSAPI
3522 CHAR
3523 NTAPI
3524 RtlUpperChar(
3525 IN CHAR Character);
3526
3527 NTSYSAPI
3528 ULONG
3529 NTAPI
3530 RtlWalkFrameChain(
3531 OUT PVOID *Callers,
3532 IN ULONG Count,
3533 IN ULONG Flags);
3534
3535 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3536
3537 /* Security reference monitor routines */
3538
3539 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3540 NTKERNELAPI
3541 BOOLEAN
3542 NTAPI
3543 SeSinglePrivilegeCheck(
3544 IN LUID PrivilegeValue,
3545 IN KPROCESSOR_MODE PreviousMode);
3546 #endif
3547
3548 /* ZwXxx Functions */
3549
3550 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3551
3552 NTSTATUS
3553 NTAPI
3554 ZwCancelTimer(
3555 IN HANDLE TimerHandle,
3556 OUT PBOOLEAN CurrentState OPTIONAL);
3557
3558 NTSTATUS
3559 NTAPI
3560 ZwCreateTimer(
3561 OUT PHANDLE TimerHandle,
3562 IN ACCESS_MASK DesiredAccess,
3563 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3564 IN TIMER_TYPE TimerType);
3565
3566 NTSTATUS
3567 NTAPI
3568 ZwOpenTimer(
3569 OUT PHANDLE TimerHandle,
3570 IN ACCESS_MASK DesiredAccess,
3571 IN POBJECT_ATTRIBUTES ObjectAttributes);
3572
3573 NTSYSAPI
3574 NTSTATUS
3575 NTAPI
3576 ZwSetInformationThread(
3577 IN HANDLE ThreadHandle,
3578 IN THREADINFOCLASS ThreadInformationClass,
3579 IN PVOID ThreadInformation,
3580 IN ULONG ThreadInformationLength);
3581
3582 NTSTATUS
3583 NTAPI
3584 ZwSetTimer(
3585 IN HANDLE TimerHandle,
3586 IN PLARGE_INTEGER DueTime,
3587 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3588 IN PVOID TimerContext OPTIONAL,
3589 IN BOOLEAN ResumeTimer,
3590 IN LONG Period OPTIONAL,
3591 OUT PBOOLEAN PreviousState OPTIONAL);
3592
3593 #endif
3594
3595 typedef struct _QUOTA_LIMITS {
3596 SIZE_T PagedPoolLimit;
3597 SIZE_T NonPagedPoolLimit;
3598 SIZE_T MinimumWorkingSetSize;
3599 SIZE_T MaximumWorkingSetSize;
3600 SIZE_T PagefileLimit;
3601 LARGE_INTEGER TimeLimit;
3602 } QUOTA_LIMITS, *PQUOTA_LIMITS;
3603
3604 struct _RTL_GENERIC_COMPARE_ROUTINE;
3605 struct _RTL_GENERIC_ALLOCATE_ROUTINE;
3606 struct _RTL_GENERIC_FREE_ROUTINE;
3607
3608 typedef struct _RTL_GENERIC_TABLE {
3609 PRTL_SPLAY_LINKS TableRoot;
3610 LIST_ENTRY InsertOrderList;
3611 PLIST_ENTRY OrderedPointer;
3612 ULONG WhichOrderedElement;
3613 ULONG NumberGenericTableElements;
3614 struct _RTL_GENERIC_COMPARE_ROUTINE *CompareRoutine;
3615 struct _RTL_GENERIC_ALLOCATE_ROUTINE *AllocateRoutine;
3616 struct _RTL_GENERIC_FREE_ROUTINE *FreeRoutine;
3617 PVOID TableContext;
3618 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
3619
3620 typedef enum _TABLE_SEARCH_RESULT {
3621 TableEmptyTree,
3622 TableFoundNode,
3623 TableInsertAsLeft,
3624 TableInsertAsRight
3625 } TABLE_SEARCH_RESULT;
3626
3627 typedef struct _FILE_FS_SIZE_INFORMATION {
3628 LARGE_INTEGER TotalAllocationUnits;
3629 LARGE_INTEGER AvailableAllocationUnits;
3630 ULONG SectorsPerAllocationUnit;
3631 ULONG BytesPerSector;
3632 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
3633
3634 #define IO_CHECK_CREATE_PARAMETERS 0x0200
3635 #define IO_ATTACH_DEVICE 0x0400
3636 #define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800
3637
3638 typedef struct _FILE_FS_VOLUME_INFORMATION {
3639 LARGE_INTEGER VolumeCreationTime;
3640 ULONG VolumeSerialNumber;
3641 ULONG VolumeLabelLength;
3642 BOOLEAN SupportsObjects;
3643 WCHAR VolumeLabel[1];
3644 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
3645
3646 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
3647 LARGE_INTEGER TotalAllocationUnits;
3648 LARGE_INTEGER CallerAvailableAllocationUnits;
3649 LARGE_INTEGER ActualAvailableAllocationUnits;
3650 ULONG SectorsPerAllocationUnit;
3651 ULONG BytesPerSector;
3652 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
3653
3654 typedef struct _FILE_FS_OBJECTID_INFORMATION {
3655 UCHAR ObjectId[16];
3656 UCHAR ExtendedInfo[48];
3657 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
3658
3659 typedef struct _FILE_FS_LABEL_INFORMATION {
3660 ULONG VolumeLabelLength;
3661 WCHAR VolumeLabel[1];
3662 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
3663
3664 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
3665 GenericLessThan,
3666 GenericGreaterThan,
3667 GenericEqual
3668 } RTL_GENERIC_COMPARE_RESULTS;
3669
3670 // Forwarder
3671 struct _RTL_AVL_TABLE;
3672
3673 typedef RTL_GENERIC_COMPARE_RESULTS
3674 (NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
3675 IN struct _RTL_AVL_TABLE *Table,
3676 IN PVOID FirstStruct,
3677 IN PVOID SecondStruct);
3678
3679 typedef PVOID
3680 (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
3681 IN struct _RTL_AVL_TABLE *Table,
3682 IN CLONG ByteSize);
3683
3684 typedef VOID
3685 (NTAPI *PRTL_AVL_FREE_ROUTINE) (
3686 IN struct _RTL_AVL_TABLE *Table,
3687 IN PVOID Buffer);
3688
3689 typedef NTSTATUS
3690 (NTAPI *PRTL_AVL_MATCH_FUNCTION) (
3691 IN struct _RTL_AVL_TABLE *Table,
3692 IN PVOID UserData,
3693 IN PVOID MatchData);
3694
3695 typedef struct _RTL_BALANCED_LINKS {
3696 struct _RTL_BALANCED_LINKS *Parent;
3697 struct _RTL_BALANCED_LINKS *LeftChild;
3698 struct _RTL_BALANCED_LINKS *RightChild;
3699 CHAR Balance;
3700 UCHAR Reserved[3];
3701 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
3702
3703 typedef struct _RTL_AVL_TABLE {
3704 RTL_BALANCED_LINKS BalancedRoot;
3705 PVOID OrderedPointer;
3706 ULONG WhichOrderedElement;
3707 ULONG NumberGenericTableElements;
3708 ULONG DepthOfTree;
3709 PRTL_BALANCED_LINKS RestartKey;
3710 ULONG DeleteCount;
3711 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
3712 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
3713 PRTL_AVL_FREE_ROUTINE FreeRoutine;
3714 PVOID TableContext;
3715 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
3716
3717 #ifndef RTL_USE_AVL_TABLES
3718
3719 struct _RTL_GENERIC_TABLE;
3720
3721 typedef RTL_GENERIC_COMPARE_RESULTS
3722 (NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
3723 IN struct _RTL_GENERIC_TABLE *Table,
3724 IN PVOID FirstStruct,
3725 IN PVOID SecondStruct);
3726
3727 typedef PVOID
3728 (NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
3729 IN struct _RTL_GENERIC_TABLE *Table,
3730 IN CLONG ByteSize);
3731
3732 typedef VOID
3733 (NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
3734 IN struct _RTL_GENERIC_TABLE *Table,
3735 IN PVOID Buffer);
3736
3737 #endif /* !RTL_USE_AVL_TABLES */
3738
3739 NTSYSAPI
3740 VOID
3741 NTAPI
3742 RtlInitializeGenericTableAvl(
3743 OUT PRTL_AVL_TABLE Table,
3744 IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
3745 IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
3746 IN PRTL_AVL_FREE_ROUTINE FreeRoutine,
3747 IN PVOID TableContext OPTIONAL);
3748
3749 #ifdef __cplusplus
3750 }
3751 #endif
3752
3753
3754 #endif /* _NTDDK_ */