1 | /*++ BUILD Version: 0121 // Increment this if a change has global effects
|
---|
2 |
|
---|
3 | Copyright (c) Microsoft Corporation. All rights reserved.
|
---|
4 |
|
---|
5 | Module Name:
|
---|
6 |
|
---|
7 | ntddk.h
|
---|
8 |
|
---|
9 | Abstract:
|
---|
10 |
|
---|
11 | This module defines the NT types, constants, and functions that are
|
---|
12 | exposed to device drivers.
|
---|
13 |
|
---|
14 | Revision History:
|
---|
15 |
|
---|
16 | --*/
|
---|
17 |
|
---|
18 | #ifndef _NTDDK_
|
---|
19 | #define _NTDDK_
|
---|
20 |
|
---|
21 | #ifndef RC_INVOKED
|
---|
22 | #if _MSC_VER < 1300
|
---|
23 | #error Compiler version not supported by Windows DDK
|
---|
24 | #endif
|
---|
25 | #endif // RC_INVOKED
|
---|
26 |
|
---|
27 | #define NT_INCLUDED
|
---|
28 | #define _CTYPE_DISABLE_MACROS
|
---|
29 |
|
---|
30 | #include <excpt.h>
|
---|
31 | #include <ntdef.h>
|
---|
32 | #include <ntstatus.h>
|
---|
33 | #include <bugcodes.h>
|
---|
34 | #include <ntiologc.h>
|
---|
35 | //
|
---|
36 | // Kernel Mutex Level Numbers (must be globally assigned within executive)
|
---|
37 | // The third token in the name is the sub-component name that defines and
|
---|
38 | // uses the level number.
|
---|
39 | //
|
---|
40 |
|
---|
41 | //
|
---|
42 | // Used by Vdm for protecting io simulation structures
|
---|
43 | //
|
---|
44 |
|
---|
45 | #define MUTEX_LEVEL_VDM_IO (ULONG)0x00000001
|
---|
46 |
|
---|
47 | #define MUTEX_LEVEL_EX_PROFILE (ULONG)0x00000040
|
---|
48 |
|
---|
49 | //
|
---|
50 | // The LANMAN Redirector uses the file system major function, but defines
|
---|
51 | // it's own mutex levels. We can do this safely because we know that the
|
---|
52 | // local filesystem will never call the remote filesystem and vice versa.
|
---|
53 | //
|
---|
54 |
|
---|
55 | #define MUTEX_LEVEL_RDR_FILESYS_DATABASE (ULONG)0x10100000
|
---|
56 | #define MUTEX_LEVEL_RDR_FILESYS_SECURITY (ULONG)0x10100001
|
---|
57 |
|
---|
58 | //
|
---|
59 | // File System levels.
|
---|
60 | //
|
---|
61 |
|
---|
62 | #define MUTEX_LEVEL_FILESYSTEM_RAW_VCB (ULONG)0x11000006
|
---|
63 |
|
---|
64 | //
|
---|
65 | // In the NT STREAMS environment, a mutex is used to serialize open, close
|
---|
66 | // and Scheduler threads executing in a subsystem-parallelized stack.
|
---|
67 | //
|
---|
68 |
|
---|
69 | #define MUTEX_LEVEL_STREAMS_SUBSYS (ULONG)0x11001001
|
---|
70 |
|
---|
71 | //
|
---|
72 | // Mutex level used by LDT support on x86
|
---|
73 | //
|
---|
74 |
|
---|
75 | #define MUTEX_LEVEL_PS_LDT (ULONG)0x1F000000
|
---|
76 |
|
---|
77 | //
|
---|
78 | // Define types that are not exported.
|
---|
79 | //
|
---|
80 |
|
---|
81 | typedef struct _BUS_HANDLER *PBUS_HANDLER;
|
---|
82 | typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
|
---|
83 | typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
|
---|
84 | typedef struct _EPROCESS *PEPROCESS;
|
---|
85 | typedef struct _ETHREAD *PETHREAD;
|
---|
86 | typedef struct _IO_TIMER *PIO_TIMER;
|
---|
87 | typedef struct _KINTERRUPT *PKINTERRUPT;
|
---|
88 | typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
|
---|
89 | typedef struct _OBJECT_TYPE *POBJECT_TYPE;
|
---|
90 | typedef struct _PEB *PPEB;
|
---|
91 |
|
---|
92 | #if defined(_M_AMD64)
|
---|
93 |
|
---|
94 | PKTHREAD
|
---|
95 | NTAPI
|
---|
96 | KeGetCurrentThread(
|
---|
97 | VOID
|
---|
98 | );
|
---|
99 |
|
---|
100 | #endif // defined(_M_AMD64)
|
---|
101 |
|
---|
102 | #if defined(_M_IX86)
|
---|
103 | PKTHREAD NTAPI KeGetCurrentThread();
|
---|
104 | #endif // defined(_M_IX86)
|
---|
105 |
|
---|
106 | #if defined(_M_IA64)
|
---|
107 |
|
---|
108 | //
|
---|
109 | // Define Address of Processor Control Registers.
|
---|
110 | //
|
---|
111 |
|
---|
112 | #define KIPCR ((ULONG_PTR)(KADDRESS_BASE + 0xffff0000)) // kernel address of first PCR
|
---|
113 |
|
---|
114 | //
|
---|
115 | // Define Pointer to Processor Control Registers.
|
---|
116 | //
|
---|
117 |
|
---|
118 | #define PCR ((volatile KPCR * const)KIPCR)
|
---|
119 |
|
---|
120 | PKTHREAD NTAPI KeGetCurrentThread();
|
---|
121 |
|
---|
122 | #endif // defined(_M_IA64)
|
---|
123 |
|
---|
124 | #define PsGetCurrentProcess() IoGetCurrentProcess()
|
---|
125 | #define PsGetCurrentThread() ((PETHREAD) (KeGetCurrentThread()))
|
---|
126 | extern NTSYSAPI CCHAR KeNumberProcessors;
|
---|
127 |
|
---|
128 | #include <mce.h>
|
---|
129 |
|
---|
130 | #ifndef FAR
|
---|
131 | #define FAR
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | //
|
---|
135 | // Define alignment macros to align structure sizes and pointers up and down.
|
---|
136 | //
|
---|
137 |
|
---|
138 | #define ALIGN_DOWN(length, type) \
|
---|
139 | ((ULONG)(length) & ~(sizeof(type) - 1))
|
---|
140 |
|
---|
141 | #define ALIGN_UP(length, type) \
|
---|
142 | (ALIGN_DOWN(((ULONG)(length) + sizeof(type) - 1), type))
|
---|
143 |
|
---|
144 | #define ALIGN_DOWN_POINTER(address, type) \
|
---|
145 | ((PVOID)((ULONG_PTR)(address) & ~((ULONG_PTR)sizeof(type) - 1)))
|
---|
146 |
|
---|
147 | #define ALIGN_UP_POINTER(address, type) \
|
---|
148 | (ALIGN_DOWN_POINTER(((ULONG_PTR)(address) + sizeof(type) - 1), type))
|
---|
149 |
|
---|
150 | //@@@AH 20041106 not available in NT4SP0
|
---|
151 | //#define POOL_TAGGING 1
|
---|
152 |
|
---|
153 | #ifndef DBG
|
---|
154 | #define DBG 0
|
---|
155 | #endif
|
---|
156 |
|
---|
157 | #if DBG
|
---|
158 | #define IF_DEBUG if (TRUE)
|
---|
159 | #else
|
---|
160 | #define IF_DEBUG if (FALSE)
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | #if DEVL
|
---|
164 |
|
---|
165 |
|
---|
166 | extern ULONG NtGlobalFlag;
|
---|
167 |
|
---|
168 | #define IF_NTOS_DEBUG( FlagName ) \
|
---|
169 | if (NtGlobalFlag & (FLG_ ## FlagName))
|
---|
170 |
|
---|
171 | #else
|
---|
172 | #define IF_NTOS_DEBUG( FlagName ) if (FALSE)
|
---|
173 | #endif
|
---|
174 |
|
---|
175 | //
|
---|
176 | // Kernel definitions that need to be here for forward reference purposes
|
---|
177 | //
|
---|
178 |
|
---|
179 |
|
---|
180 | //
|
---|
181 | // Processor modes.
|
---|
182 | //
|
---|
183 |
|
---|
184 | typedef CCHAR KPROCESSOR_MODE;
|
---|
185 |
|
---|
186 | typedef enum _MODE {
|
---|
187 | KernelMode,
|
---|
188 | UserMode,
|
---|
189 | MaximumMode
|
---|
190 | } MODE;
|
---|
191 |
|
---|
192 |
|
---|
193 | //
|
---|
194 | // APC function types
|
---|
195 | //
|
---|
196 |
|
---|
197 | //
|
---|
198 | // Put in an empty definition for the KAPC so that the
|
---|
199 | // routines can reference it before it is declared.
|
---|
200 | //
|
---|
201 |
|
---|
202 | struct _KAPC;
|
---|
203 |
|
---|
204 | typedef
|
---|
205 | VOID
|
---|
206 | (*PKNORMAL_ROUTINE) (
|
---|
207 | IN PVOID NormalContext,
|
---|
208 | IN PVOID SystemArgument1,
|
---|
209 | IN PVOID SystemArgument2
|
---|
210 | );
|
---|
211 |
|
---|
212 | typedef
|
---|
213 | VOID
|
---|
214 | (*PKKERNEL_ROUTINE) (
|
---|
215 | IN struct _KAPC *Apc,
|
---|
216 | IN OUT PKNORMAL_ROUTINE *NormalRoutine,
|
---|
217 | IN OUT PVOID *NormalContext,
|
---|
218 | IN OUT PVOID *SystemArgument1,
|
---|
219 | IN OUT PVOID *SystemArgument2
|
---|
220 | );
|
---|
221 |
|
---|
222 | typedef
|
---|
223 | VOID
|
---|
224 | (*PKRUNDOWN_ROUTINE) (
|
---|
225 | IN struct _KAPC *Apc
|
---|
226 | );
|
---|
227 |
|
---|
228 | typedef
|
---|
229 | BOOLEAN
|
---|
230 | (*PKSYNCHRONIZE_ROUTINE) (
|
---|
231 | IN PVOID SynchronizeContext
|
---|
232 | );
|
---|
233 |
|
---|
234 | typedef
|
---|
235 | BOOLEAN
|
---|
236 | (*PKTRANSFER_ROUTINE) (
|
---|
237 | VOID
|
---|
238 | );
|
---|
239 |
|
---|
240 | //
|
---|
241 | //
|
---|
242 | // Asynchronous Procedure Call (APC) object
|
---|
243 | //
|
---|
244 | //
|
---|
245 |
|
---|
246 | typedef struct _KAPC {
|
---|
247 | CSHORT Type;
|
---|
248 | CSHORT Size;
|
---|
249 | ULONG Spare0;
|
---|
250 | struct _KTHREAD *Thread;
|
---|
251 | LIST_ENTRY ApcListEntry;
|
---|
252 | PKKERNEL_ROUTINE KernelRoutine;
|
---|
253 | PKRUNDOWN_ROUTINE RundownRoutine;
|
---|
254 | PKNORMAL_ROUTINE NormalRoutine;
|
---|
255 | PVOID NormalContext;
|
---|
256 |
|
---|
257 | //
|
---|
258 | // N.B. The following two members MUST be together.
|
---|
259 | //
|
---|
260 |
|
---|
261 | PVOID SystemArgument1;
|
---|
262 | PVOID SystemArgument2;
|
---|
263 | CCHAR ApcStateIndex;
|
---|
264 | KPROCESSOR_MODE ApcMode;
|
---|
265 | BOOLEAN Inserted;
|
---|
266 | } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
|
---|
267 |
|
---|
268 |
|
---|
269 | //
|
---|
270 | // DPC routine
|
---|
271 | //
|
---|
272 |
|
---|
273 | struct _KDPC;
|
---|
274 |
|
---|
275 | typedef
|
---|
276 | VOID
|
---|
277 | (*PKDEFERRED_ROUTINE) (
|
---|
278 | IN struct _KDPC *Dpc,
|
---|
279 | IN PVOID DeferredContext,
|
---|
280 | IN PVOID SystemArgument1,
|
---|
281 | IN PVOID SystemArgument2
|
---|
282 | );
|
---|
283 |
|
---|
284 | //
|
---|
285 | // Define DPC importance.
|
---|
286 | //
|
---|
287 | // LowImportance - Queue DPC at end of target DPC queue.
|
---|
288 | // MediumImportance - Queue DPC at end of target DPC queue.
|
---|
289 | // HighImportance - Queue DPC at front of target DPC DPC queue.
|
---|
290 | //
|
---|
291 | // If there is currently a DPC active on the target processor, or a DPC
|
---|
292 | // interrupt has already been requested on the target processor when a
|
---|
293 | // DPC is queued, then no further action is necessary. The DPC will be
|
---|
294 | // executed on the target processor when its queue entry is processed.
|
---|
295 | //
|
---|
296 | // If there is not a DPC active on the target processor and a DPC interrupt
|
---|
297 | // has not been requested on the target processor, then the exact treatment
|
---|
298 | // of the DPC is dependent on whether the host system is a UP system or an
|
---|
299 | // MP system.
|
---|
300 | //
|
---|
301 | // UP system.
|
---|
302 | //
|
---|
303 | // If the DPC is of medium or high importance, the current DPC queue depth
|
---|
304 | // is greater than the maximum target depth, or current DPC request rate is
|
---|
305 | // less the minimum target rate, then a DPC interrupt is requested on the
|
---|
306 | // host processor and the DPC will be processed when the interrupt occurs.
|
---|
307 | // Otherwise, no DPC interrupt is requested and the DPC execution will be
|
---|
308 | // delayed until the DPC queue depth is greater that the target depth or the
|
---|
309 | // minimum DPC rate is less than the target rate.
|
---|
310 | //
|
---|
311 | // MP system.
|
---|
312 | //
|
---|
313 | // If the DPC is being queued to another processor and the depth of the DPC
|
---|
314 | // queue on the target processor is greater than the maximum target depth or
|
---|
315 | // the DPC is of high importance, then a DPC interrupt is requested on the
|
---|
316 | // target processor and the DPC will be processed when the interrupt occurs.
|
---|
317 | // Otherwise, the DPC execution will be delayed on the target processor until
|
---|
318 | // the DPC queue depth on the target processor is greater that the maximum
|
---|
319 | // target depth or the minimum DPC rate on the target processor is less than
|
---|
320 | // the target minimum rate.
|
---|
321 | //
|
---|
322 | // If the DPC is being queued to the current processor and the DPC is not of
|
---|
323 | // low importance, the current DPC queue depth is greater than the maximum
|
---|
324 | // target depth, or the minimum DPC rate is less than the minimum target rate,
|
---|
325 | // then a DPC interrupt is request on the current processor and the DPV will
|
---|
326 | // be processed whne the interrupt occurs. Otherwise, no DPC interrupt is
|
---|
327 | // requested and the DPC execution will be delayed until the DPC queue depth
|
---|
328 | // is greater that the target depth or the minimum DPC rate is less than the
|
---|
329 | // target rate.
|
---|
330 | //
|
---|
331 |
|
---|
332 | typedef enum _KDPC_IMPORTANCE {
|
---|
333 | LowImportance,
|
---|
334 | MediumImportance,
|
---|
335 | HighImportance
|
---|
336 | } KDPC_IMPORTANCE;
|
---|
337 |
|
---|
338 | //
|
---|
339 | // Define DPC type indices.
|
---|
340 | //
|
---|
341 |
|
---|
342 | #define DPC_NORMAL 0
|
---|
343 | #define DPC_THREADED 1
|
---|
344 |
|
---|
345 | //
|
---|
346 | // Deferred Procedure Call (DPC) object
|
---|
347 | //
|
---|
348 |
|
---|
349 | typedef struct _KDPC {
|
---|
350 | CSHORT Type;
|
---|
351 | UCHAR Number;
|
---|
352 | UCHAR Importance;
|
---|
353 | LIST_ENTRY DpcListEntry;
|
---|
354 | PKDEFERRED_ROUTINE DeferredRoutine;
|
---|
355 | PVOID DeferredContext;
|
---|
356 | PVOID SystemArgument1;
|
---|
357 | PVOID SystemArgument2;
|
---|
358 | PVOID DpcData;
|
---|
359 | } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
|
---|
360 |
|
---|
361 | //
|
---|
362 | // Interprocessor interrupt worker routine function prototype.
|
---|
363 | //
|
---|
364 |
|
---|
365 | typedef PVOID PKIPI_CONTEXT;
|
---|
366 |
|
---|
367 | typedef
|
---|
368 | VOID
|
---|
369 | (*PKIPI_WORKER)(
|
---|
370 | IN PKIPI_CONTEXT PacketContext,
|
---|
371 | IN PVOID Parameter1,
|
---|
372 | IN PVOID Parameter2,
|
---|
373 | IN PVOID Parameter3
|
---|
374 | );
|
---|
375 |
|
---|
376 | //
|
---|
377 | // Define interprocessor interrupt performance counters.
|
---|
378 | //
|
---|
379 |
|
---|
380 | typedef struct _KIPI_COUNTS {
|
---|
381 | ULONG Freeze;
|
---|
382 | ULONG Packet;
|
---|
383 | ULONG DPC;
|
---|
384 | ULONG APC;
|
---|
385 | ULONG FlushSingleTb;
|
---|
386 | ULONG FlushMultipleTb;
|
---|
387 | ULONG FlushEntireTb;
|
---|
388 | ULONG GenericCall;
|
---|
389 | ULONG ChangeColor;
|
---|
390 | ULONG SweepDcache;
|
---|
391 | ULONG SweepIcache;
|
---|
392 | ULONG SweepIcacheRange;
|
---|
393 | ULONG FlushIoBuffers;
|
---|
394 | ULONG GratuitousDPC;
|
---|
395 | } KIPI_COUNTS, *PKIPI_COUNTS;
|
---|
396 |
|
---|
397 |
|
---|
398 | //
|
---|
399 | // I/O system definitions.
|
---|
400 | //
|
---|
401 | // Define a Memory Descriptor List (MDL)
|
---|
402 | //
|
---|
403 | // An MDL describes pages in a virtual buffer in terms of physical pages. The
|
---|
404 | // pages associated with the buffer are described in an array that is allocated
|
---|
405 | // just after the MDL header structure itself.
|
---|
406 | //
|
---|
407 | // One simply calculates the base of the array by adding one to the base
|
---|
408 | // MDL pointer:
|
---|
409 | //
|
---|
410 | // Pages = (PPFN_NUMBER) (Mdl + 1);
|
---|
411 | //
|
---|
412 | // Notice that while in the context of the subject thread, the base virtual
|
---|
413 | // address of a buffer mapped by an MDL may be referenced using the following:
|
---|
414 | //
|
---|
415 | // Mdl->StartVa | Mdl->ByteOffset
|
---|
416 | //
|
---|
417 |
|
---|
418 |
|
---|
419 | typedef struct _MDL {
|
---|
420 | struct _MDL *Next;
|
---|
421 | CSHORT Size;
|
---|
422 | CSHORT MdlFlags;
|
---|
423 | struct _EPROCESS *Process;
|
---|
424 | PVOID MappedSystemVa;
|
---|
425 | PVOID StartVa;
|
---|
426 | ULONG ByteCount;
|
---|
427 | ULONG ByteOffset;
|
---|
428 | } MDL, *PMDL;
|
---|
429 |
|
---|
430 | #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
|
---|
431 | #define MDL_PAGES_LOCKED 0x0002
|
---|
432 | #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
|
---|
433 | #define MDL_ALLOCATED_FIXED_SIZE 0x0008
|
---|
434 | #define MDL_PARTIAL 0x0010
|
---|
435 | #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
|
---|
436 | #define MDL_IO_PAGE_READ 0x0040
|
---|
437 | #define MDL_WRITE_OPERATION 0x0080
|
---|
438 | #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
|
---|
439 | #define MDL_FREE_EXTRA_PTES 0x0200
|
---|
440 | #define MDL_DESCRIBES_AWE 0x0400
|
---|
441 | #define MDL_IO_SPACE 0x0800
|
---|
442 | #define MDL_NETWORK_HEADER 0x1000
|
---|
443 | #define MDL_MAPPING_CAN_FAIL 0x2000
|
---|
444 | #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
|
---|
445 |
|
---|
446 |
|
---|
447 | #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
|
---|
448 | MDL_PAGES_LOCKED | \
|
---|
449 | MDL_SOURCE_IS_NONPAGED_POOL | \
|
---|
450 | MDL_PARTIAL_HAS_BEEN_MAPPED | \
|
---|
451 | MDL_PARENT_MAPPED_SYSTEM_VA | \
|
---|
452 | MDL_SYSTEM_VA | \
|
---|
453 | MDL_IO_SPACE )
|
---|
454 |
|
---|
455 |
|
---|
456 | //
|
---|
457 | // switch to DBG when appropriate
|
---|
458 | //
|
---|
459 |
|
---|
460 | #ifdef DEBUG
|
---|
461 | #define PAGED_CODE() \
|
---|
462 | { if (KeGetCurrentIrql() > APC_LEVEL) { \
|
---|
463 | KdPrint(( "EX: Pageable code called at IRQL %d\n", KeGetCurrentIrql() )); \
|
---|
464 | Log(("i8042prt: %s: EXECPTION: IOCTL_MRX_VBOX_GETGLOBALCONN: Pageable code called at IRQL = %d! This driver will raise a bugcheck now ....\n", __FUNCTION__, KeGetCurrentIrql())); \
|
---|
465 | ASSERT(FALSE); \
|
---|
466 | } \
|
---|
467 | }
|
---|
468 | #else
|
---|
469 | #define PAGED_CODE() NOP_FUNCTION;
|
---|
470 | #endif
|
---|
471 |
|
---|
472 | #define NTKERNELAPI DECLSPEC_IMPORT
|
---|
473 | #if !defined(_NTHAL_) && !defined(_BLDR_)
|
---|
474 |
|
---|
475 | #define NTHALAPI DECLSPEC_IMPORT // wdm ntndis ntifs ntosp
|
---|
476 |
|
---|
477 | #else
|
---|
478 |
|
---|
479 | #define NTHALAPI // nthal
|
---|
480 |
|
---|
481 | #endif
|
---|
482 | //
|
---|
483 | // Common dispatcher object header
|
---|
484 | //
|
---|
485 | // N.B. The size field contains the number of dwords in the structure.
|
---|
486 | //
|
---|
487 |
|
---|
488 | typedef struct _DISPATCHER_HEADER {
|
---|
489 | union {
|
---|
490 | struct {
|
---|
491 | UCHAR Type;
|
---|
492 | UCHAR Absolute;
|
---|
493 | UCHAR Size;
|
---|
494 | union {
|
---|
495 | UCHAR Inserted;
|
---|
496 | BOOLEAN DebugActive;
|
---|
497 | };
|
---|
498 | };
|
---|
499 |
|
---|
500 | volatile LONG Lock;
|
---|
501 | };
|
---|
502 |
|
---|
503 | LONG SignalState;
|
---|
504 | LIST_ENTRY WaitListHead;
|
---|
505 | } DISPATCHER_HEADER;
|
---|
506 |
|
---|
507 | //
|
---|
508 | // Event object
|
---|
509 | //
|
---|
510 |
|
---|
511 | typedef struct _KEVENT {
|
---|
512 | DISPATCHER_HEADER Header;
|
---|
513 | } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
|
---|
514 |
|
---|
515 | //
|
---|
516 | // Timer object
|
---|
517 | //
|
---|
518 |
|
---|
519 | typedef struct _KTIMER {
|
---|
520 | DISPATCHER_HEADER Header;
|
---|
521 | ULARGE_INTEGER DueTime;
|
---|
522 | LIST_ENTRY TimerListEntry;
|
---|
523 | struct _KDPC *Dpc;
|
---|
524 | LONG Period;
|
---|
525 | } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
|
---|
526 |
|
---|
527 | typedef enum _LOCK_OPERATION {
|
---|
528 | IoReadAccess,
|
---|
529 | IoWriteAccess,
|
---|
530 | IoModifyAccess
|
---|
531 | } LOCK_OPERATION;
|
---|
532 |
|
---|
533 |
|
---|
534 | #ifdef _X86_
|
---|
535 |
|
---|
536 | //
|
---|
537 | // Disable these two pragmas that evaluate to "sti" "cli" on x86 so that driver
|
---|
538 | // writers to not leave them inadvertently in their code.
|
---|
539 | //
|
---|
540 |
|
---|
541 | #if !defined(MIDL_PASS)
|
---|
542 | #if !defined(RC_INVOKED)
|
---|
543 |
|
---|
544 | #if _MSC_VER >= 1200
|
---|
545 | #pragma warning(push)
|
---|
546 | #endif
|
---|
547 | #pragma warning(disable:4164) // disable C4164 warning so that apps that
|
---|
548 | // build with /Od don't get weird errors !
|
---|
549 | #ifdef _M_IX86
|
---|
550 | #pragma function(_enable)
|
---|
551 | #pragma function(_disable)
|
---|
552 | #endif
|
---|
553 |
|
---|
554 | #if _MSC_VER >= 1200
|
---|
555 | #pragma warning(pop)
|
---|
556 | #else
|
---|
557 | #pragma warning(default:4164) // reenable C4164 warning
|
---|
558 | #endif
|
---|
559 |
|
---|
560 | #endif
|
---|
561 | #endif
|
---|
562 |
|
---|
563 |
|
---|
564 | #if !defined(MIDL_PASS) || defined(_M_IX86)
|
---|
565 |
|
---|
566 | #if (_MSC_FULL_VER >= 13012035)
|
---|
567 |
|
---|
568 | //
|
---|
569 | // Define bit scan intrinsics.
|
---|
570 | //
|
---|
571 |
|
---|
572 | //#define BitScanForward _BitScanForward
|
---|
573 | //#define BitScanReverse _BitScanReverse
|
---|
574 |
|
---|
575 | //BOOLEAN
|
---|
576 | //_BitScanForward (
|
---|
577 | // OUT ULONG *Index,
|
---|
578 | // IN ULONG Mask
|
---|
579 | // );
|
---|
580 |
|
---|
581 | //BOOLEAN
|
---|
582 | //_BitScanReverse (
|
---|
583 | // OUT ULONG *Index,
|
---|
584 | // IN ULONG Mask
|
---|
585 | // );
|
---|
586 |
|
---|
587 |
|
---|
588 | //#pragma intrinsic(_BitScanForward)
|
---|
589 | //#pragma intrinsic(_BitScanReverse)
|
---|
590 |
|
---|
591 | //
|
---|
592 | // Define FS referencing intrinsics
|
---|
593 | //
|
---|
594 | #ifdef __cplusplus
|
---|
595 | extern "C" {
|
---|
596 | #endif
|
---|
597 |
|
---|
598 | UCHAR
|
---|
599 | __readfsbyte (
|
---|
600 | IN ULONG Offset
|
---|
601 | );
|
---|
602 |
|
---|
603 | USHORT
|
---|
604 | __readfsword (
|
---|
605 | IN ULONG Offset
|
---|
606 | );
|
---|
607 |
|
---|
608 | ULONG
|
---|
609 | __readfsdword (
|
---|
610 | IN ULONG Offset
|
---|
611 | );
|
---|
612 |
|
---|
613 | VOID
|
---|
614 | __writefsbyte (
|
---|
615 | IN ULONG Offset,
|
---|
616 | IN UCHAR Data
|
---|
617 | );
|
---|
618 |
|
---|
619 | VOID
|
---|
620 | __writefsword (
|
---|
621 | IN ULONG Offset,
|
---|
622 | IN USHORT Data
|
---|
623 | );
|
---|
624 |
|
---|
625 | VOID
|
---|
626 | __writefsdword (
|
---|
627 | IN ULONG Offset,
|
---|
628 | IN ULONG Data
|
---|
629 | );
|
---|
630 |
|
---|
631 | #ifdef __cplusplus
|
---|
632 | }
|
---|
633 | #endif
|
---|
634 |
|
---|
635 | #pragma intrinsic(__readfsbyte)
|
---|
636 | #pragma intrinsic(__readfsword)
|
---|
637 | #pragma intrinsic(__readfsdword)
|
---|
638 | #pragma intrinsic(__writefsbyte)
|
---|
639 | #pragma intrinsic(__writefsword)
|
---|
640 | #pragma intrinsic(__writefsdword)
|
---|
641 |
|
---|
642 | #endif
|
---|
643 |
|
---|
644 | #endif
|
---|
645 |
|
---|
646 | //
|
---|
647 | // Size of kernel mode stack.
|
---|
648 | //
|
---|
649 |
|
---|
650 | #define KERNEL_STACK_SIZE 12288
|
---|
651 |
|
---|
652 | //
|
---|
653 | // Define size of large kernel mode stack for callbacks.
|
---|
654 | //
|
---|
655 |
|
---|
656 | #define KERNEL_LARGE_STACK_SIZE 61440
|
---|
657 |
|
---|
658 | //
|
---|
659 | // Define number of pages to initialize in a large kernel stack.
|
---|
660 | //
|
---|
661 |
|
---|
662 | #define KERNEL_LARGE_STACK_COMMIT 12288
|
---|
663 |
|
---|
664 | #ifdef _X86_
|
---|
665 |
|
---|
666 | #if !defined(MIDL_PASS) && defined(_M_IX86)
|
---|
667 |
|
---|
668 | FORCEINLINE
|
---|
669 | VOID
|
---|
670 | MemoryBarrier (
|
---|
671 | VOID
|
---|
672 | )
|
---|
673 | {
|
---|
674 | LONG Barrier;
|
---|
675 | __asm {
|
---|
676 | xchg Barrier, eax
|
---|
677 | }
|
---|
678 | }
|
---|
679 |
|
---|
680 | #define YieldProcessor() __asm { rep nop }
|
---|
681 |
|
---|
682 | //
|
---|
683 | // Prefetch is not supported on all x86 processors.
|
---|
684 | //
|
---|
685 |
|
---|
686 | #define PreFetchCacheLine(l, a)
|
---|
687 |
|
---|
688 | //
|
---|
689 | // PreFetchCacheLine level defines.
|
---|
690 | //
|
---|
691 |
|
---|
692 | #define PF_TEMPORAL_LEVEL_1
|
---|
693 | #define PF_NON_TEMPORAL_LEVEL_ALL
|
---|
694 | #endif
|
---|
695 |
|
---|
696 |
|
---|
697 |
|
---|
698 | //
|
---|
699 | // Define the size of the 80387 save area, which is in the context frame.
|
---|
700 | //
|
---|
701 |
|
---|
702 | #define SIZE_OF_80387_REGISTERS 80
|
---|
703 |
|
---|
704 | //
|
---|
705 | // The following flags control the contents of the CONTEXT structure.
|
---|
706 | //
|
---|
707 |
|
---|
708 | #if !defined(RC_INVOKED)
|
---|
709 |
|
---|
710 | #define CONTEXT_i386 0x00010000 // this assumes that i386 and
|
---|
711 | #define CONTEXT_i486 0x00010000 // i486 have identical context records
|
---|
712 |
|
---|
713 |
|
---|
714 |
|
---|
715 | #define CONTEXT_CONTROL (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
|
---|
716 | #define CONTEXT_INTEGER (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
|
---|
717 | #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS
|
---|
718 | #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x00000008L) // 387 state
|
---|
719 | #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L) // DB 0-3,6,7
|
---|
720 | #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x00000020L) // cpu specific extensions
|
---|
721 |
|
---|
722 | #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER |\
|
---|
723 | CONTEXT_SEGMENTS)
|
---|
724 |
|
---|
725 | #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
|
---|
726 |
|
---|
727 |
|
---|
728 |
|
---|
729 | #endif
|
---|
730 |
|
---|
731 | #define MAXIMUM_SUPPORTED_EXTENSION 512
|
---|
732 |
|
---|
733 | typedef struct _FLOATING_SAVE_AREA {
|
---|
734 | ULONG ControlWord;
|
---|
735 | ULONG StatusWord;
|
---|
736 | ULONG TagWord;
|
---|
737 | ULONG ErrorOffset;
|
---|
738 | ULONG ErrorSelector;
|
---|
739 | ULONG DataOffset;
|
---|
740 | ULONG DataSelector;
|
---|
741 | UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
|
---|
742 | ULONG Cr0NpxState;
|
---|
743 | } FLOATING_SAVE_AREA;
|
---|
744 |
|
---|
745 | typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
|
---|
746 |
|
---|
747 | //
|
---|
748 | // Context Frame
|
---|
749 | //
|
---|
750 | // This frame has a several purposes: 1) it is used as an argument to
|
---|
751 | // NtContinue, 2) is is used to construct a call frame for APC delivery,
|
---|
752 | // and 3) it is used in the user level thread creation routines.
|
---|
753 | //
|
---|
754 | // The layout of the record conforms to a standard call frame.
|
---|
755 | //
|
---|
756 |
|
---|
757 | typedef struct _CONTEXT {
|
---|
758 |
|
---|
759 | //
|
---|
760 | // The flags values within this flag control the contents of
|
---|
761 | // a CONTEXT record.
|
---|
762 | //
|
---|
763 | // If the context record is used as an input parameter, then
|
---|
764 | // for each portion of the context record controlled by a flag
|
---|
765 | // whose value is set, it is assumed that that portion of the
|
---|
766 | // context record contains valid context. If the context record
|
---|
767 | // is being used to modify a threads context, then only that
|
---|
768 | // portion of the threads context will be modified.
|
---|
769 | //
|
---|
770 | // If the context record is used as an IN OUT parameter to capture
|
---|
771 | // the context of a thread, then only those portions of the thread's
|
---|
772 | // context corresponding to set flags will be returned.
|
---|
773 | //
|
---|
774 | // The context record is never used as an OUT only parameter.
|
---|
775 | //
|
---|
776 |
|
---|
777 | ULONG ContextFlags;
|
---|
778 |
|
---|
779 | //
|
---|
780 | // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
|
---|
781 | // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
|
---|
782 | // included in CONTEXT_FULL.
|
---|
783 | //
|
---|
784 |
|
---|
785 | ULONG Dr0;
|
---|
786 | ULONG Dr1;
|
---|
787 | ULONG Dr2;
|
---|
788 | ULONG Dr3;
|
---|
789 | ULONG Dr6;
|
---|
790 | ULONG Dr7;
|
---|
791 |
|
---|
792 | //
|
---|
793 | // This section is specified/returned if the
|
---|
794 | // ContextFlags word contains the flag CONTEXT_FLOATING_POINT.
|
---|
795 | //
|
---|
796 |
|
---|
797 | FLOATING_SAVE_AREA FloatSave;
|
---|
798 |
|
---|
799 | //
|
---|
800 | // This section is specified/returned if the
|
---|
801 | // ContextFlags word contains the flag CONTEXT_SEGMENTS.
|
---|
802 | //
|
---|
803 |
|
---|
804 | ULONG SegGs;
|
---|
805 | ULONG SegFs;
|
---|
806 | ULONG SegEs;
|
---|
807 | ULONG SegDs;
|
---|
808 |
|
---|
809 | //
|
---|
810 | // This section is specified/returned if the
|
---|
811 | // ContextFlags word contains the flag CONTEXT_INTEGER.
|
---|
812 | //
|
---|
813 |
|
---|
814 | ULONG Edi;
|
---|
815 | ULONG Esi;
|
---|
816 | ULONG Ebx;
|
---|
817 | ULONG Edx;
|
---|
818 | ULONG Ecx;
|
---|
819 | ULONG Eax;
|
---|
820 |
|
---|
821 | //
|
---|
822 | // This section is specified/returned if the
|
---|
823 | // ContextFlags word contains the flag CONTEXT_CONTROL.
|
---|
824 | //
|
---|
825 |
|
---|
826 | ULONG Ebp;
|
---|
827 | ULONG Eip;
|
---|
828 | ULONG SegCs; // MUST BE SANITIZED
|
---|
829 | ULONG EFlags; // MUST BE SANITIZED
|
---|
830 | ULONG Esp;
|
---|
831 | ULONG SegSs;
|
---|
832 |
|
---|
833 | //
|
---|
834 | // This section is specified/returned if the ContextFlags word
|
---|
835 | // contains the flag CONTEXT_EXTENDED_REGISTERS.
|
---|
836 | // The format and contexts are processor specific
|
---|
837 | //
|
---|
838 |
|
---|
839 | UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
|
---|
840 |
|
---|
841 | } CONTEXT;
|
---|
842 |
|
---|
843 |
|
---|
844 |
|
---|
845 | typedef CONTEXT *PCONTEXT;
|
---|
846 |
|
---|
847 |
|
---|
848 |
|
---|
849 | #endif //_X86_
|
---|
850 |
|
---|
851 | #endif // _X86_
|
---|
852 |
|
---|
853 | #if defined(_AMD64_)
|
---|
854 |
|
---|
855 |
|
---|
856 | #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
---|
857 |
|
---|
858 | //
|
---|
859 | // Define bit test intrinsics.
|
---|
860 | //
|
---|
861 |
|
---|
862 | #ifdef __cplusplus
|
---|
863 | extern "C" {
|
---|
864 | #endif
|
---|
865 |
|
---|
866 | #define BitTest _bittest
|
---|
867 | #define BitTestAndComplement _bittestandcomplement
|
---|
868 | #define BitTestAndSet _bittestandset
|
---|
869 | #define BitTestAndReset _bittestandreset
|
---|
870 | #define InterlockedBitTestAndSet _interlockedbittestandset
|
---|
871 | #define InterlockedBitTestAndReset _interlockedbittestandreset
|
---|
872 |
|
---|
873 | #define BitTest64 _bittest64
|
---|
874 | #define BitTestAndComplement64 _bittestandcomplement64
|
---|
875 | #define BitTestAndSet64 _bittestandset64
|
---|
876 | #define BitTestAndReset64 _bittestandreset64
|
---|
877 | #define InterlockedBitTestAndSet64 _interlockedbittestandset64
|
---|
878 | #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
|
---|
879 |
|
---|
880 | BOOLEAN
|
---|
881 | _bittest (
|
---|
882 | IN LONG *Base,
|
---|
883 | IN LONG Offset
|
---|
884 | );
|
---|
885 |
|
---|
886 | BOOLEAN
|
---|
887 | _bittestandcomplement (
|
---|
888 | IN LONG *Base,
|
---|
889 | IN LONG Offset
|
---|
890 | );
|
---|
891 |
|
---|
892 | BOOLEAN
|
---|
893 | _bittestandset (
|
---|
894 | IN LONG *Base,
|
---|
895 | IN LONG Offset
|
---|
896 | );
|
---|
897 |
|
---|
898 | BOOLEAN
|
---|
899 | _bittestandreset (
|
---|
900 | IN LONG *Base,
|
---|
901 | IN LONG Offset
|
---|
902 | );
|
---|
903 |
|
---|
904 | BOOLEAN
|
---|
905 | _interlockedbittestandset (
|
---|
906 | IN LONG *Base,
|
---|
907 | IN LONG Offset
|
---|
908 | );
|
---|
909 |
|
---|
910 | BOOLEAN
|
---|
911 | _interlockedbittestandreset (
|
---|
912 | IN LONG *Base,
|
---|
913 | IN LONG Offset
|
---|
914 | );
|
---|
915 |
|
---|
916 | BOOLEAN
|
---|
917 | _bittest64 (
|
---|
918 | IN LONG64 *Base,
|
---|
919 | IN LONG64 Offset
|
---|
920 | );
|
---|
921 |
|
---|
922 | BOOLEAN
|
---|
923 | _bittestandcomplement64 (
|
---|
924 | IN LONG64 *Base,
|
---|
925 | IN LONG64 Offset
|
---|
926 | );
|
---|
927 |
|
---|
928 | BOOLEAN
|
---|
929 | _bittestandset64 (
|
---|
930 | IN LONG64 *Base,
|
---|
931 | IN LONG64 Offset
|
---|
932 | );
|
---|
933 |
|
---|
934 | BOOLEAN
|
---|
935 | _bittestandreset64 (
|
---|
936 | IN LONG64 *Base,
|
---|
937 | IN LONG64 Offset
|
---|
938 | );
|
---|
939 |
|
---|
940 | BOOLEAN
|
---|
941 | _interlockedbittestandset64 (
|
---|
942 | IN LONG64 *Base,
|
---|
943 | IN LONG64 Offset
|
---|
944 | );
|
---|
945 |
|
---|
946 | BOOLEAN
|
---|
947 | _interlockedbittestandreset64 (
|
---|
948 | IN LONG64 *Base,
|
---|
949 | IN LONG64 Offset
|
---|
950 | );
|
---|
951 |
|
---|
952 | #pragma intrinsic(_bittest)
|
---|
953 | #pragma intrinsic(_bittestandcomplement)
|
---|
954 | #pragma intrinsic(_bittestandset)
|
---|
955 | #pragma intrinsic(_bittestandreset)
|
---|
956 | #pragma intrinsic(_interlockedbittestandset)
|
---|
957 | #pragma intrinsic(_interlockedbittestandreset)
|
---|
958 |
|
---|
959 | #pragma intrinsic(_bittest64)
|
---|
960 | #pragma intrinsic(_bittestandcomplement64)
|
---|
961 | #pragma intrinsic(_bittestandset64)
|
---|
962 | #pragma intrinsic(_bittestandreset64)
|
---|
963 | #pragma intrinsic(_interlockedbittestandset64)
|
---|
964 | #pragma intrinsic(_interlockedbittestandreset64)
|
---|
965 |
|
---|
966 | //
|
---|
967 | // Define bit scan intrinsics.
|
---|
968 | //
|
---|
969 |
|
---|
970 | #define BitScanForward _BitScanForward
|
---|
971 | #define BitScanReverse _BitScanReverse
|
---|
972 | #define BitScanForward64 _BitScanForward64
|
---|
973 | #define BitScanReverse64 _BitScanReverse64
|
---|
974 |
|
---|
975 | BOOLEAN
|
---|
976 | _BitScanForward (
|
---|
977 | OUT ULONG *Index,
|
---|
978 | IN ULONG Mask
|
---|
979 | );
|
---|
980 |
|
---|
981 | BOOLEAN
|
---|
982 | _BitScanReverse (
|
---|
983 | OUT ULONG *Index,
|
---|
984 | IN ULONG Mask
|
---|
985 | );
|
---|
986 |
|
---|
987 | BOOLEAN
|
---|
988 | _BitScanForward64 (
|
---|
989 | OUT ULONG *Index,
|
---|
990 | IN ULONG64 Mask
|
---|
991 | );
|
---|
992 |
|
---|
993 | BOOLEAN
|
---|
994 | _BitScanReverse64 (
|
---|
995 | OUT ULONG *Index,
|
---|
996 | IN ULONG64 Mask
|
---|
997 | );
|
---|
998 |
|
---|
999 | #pragma intrinsic(_BitScanForward)
|
---|
1000 | #pragma intrinsic(_BitScanReverse)
|
---|
1001 | #pragma intrinsic(_BitScanForward64)
|
---|
1002 | #pragma intrinsic(_BitScanReverse64)
|
---|
1003 |
|
---|
1004 | //
|
---|
1005 | // Define function to flush a cache line.
|
---|
1006 | //
|
---|
1007 |
|
---|
1008 | #define CacheLineFlush(Address) _mm_clflush(Address)
|
---|
1009 |
|
---|
1010 | VOID
|
---|
1011 | _mm_clflush (
|
---|
1012 | PVOID Address
|
---|
1013 | );
|
---|
1014 |
|
---|
1015 | #pragma intrinsic(_mm_clflush)
|
---|
1016 |
|
---|
1017 | //
|
---|
1018 | // Define memory fence intrinsics
|
---|
1019 | //
|
---|
1020 |
|
---|
1021 | #define LoadFence _mm_lfence
|
---|
1022 | #define MemoryFence _mm_mfence
|
---|
1023 | #define StoreFence _mm_sfence
|
---|
1024 |
|
---|
1025 | VOID
|
---|
1026 | _mm_lfence (
|
---|
1027 | VOID
|
---|
1028 | );
|
---|
1029 |
|
---|
1030 | VOID
|
---|
1031 | _mm_mfence (
|
---|
1032 | VOID
|
---|
1033 | );
|
---|
1034 |
|
---|
1035 | VOID
|
---|
1036 | _mm_sfence (
|
---|
1037 | VOID
|
---|
1038 | );
|
---|
1039 |
|
---|
1040 | void
|
---|
1041 | _mm_prefetch(
|
---|
1042 | CHAR CONST *a,
|
---|
1043 | int sel
|
---|
1044 | );
|
---|
1045 |
|
---|
1046 | /* constants for use with _mm_prefetch */
|
---|
1047 | #define _MM_HINT_T0 1
|
---|
1048 | #define _MM_HINT_T1 2
|
---|
1049 | #define _MM_HINT_T2 3
|
---|
1050 | #define _MM_HINT_NTA 0
|
---|
1051 |
|
---|
1052 | #pragma intrinsic(_mm_prefetch)
|
---|
1053 | #pragma intrinsic(_mm_lfence)
|
---|
1054 | #pragma intrinsic(_mm_mfence)
|
---|
1055 | #pragma intrinsic(_mm_sfence)
|
---|
1056 |
|
---|
1057 | #define YieldProcessor()
|
---|
1058 | #define MemoryBarrier _mm_mfence
|
---|
1059 | #define PreFetchCacheLine(l, a) _mm_prefetch((CHAR CONST *) a, l)
|
---|
1060 |
|
---|
1061 | //
|
---|
1062 | // PreFetchCacheLine level defines.
|
---|
1063 | //
|
---|
1064 |
|
---|
1065 | #define PF_TEMPORAL_LEVEL_1 _MM_HINT_T0
|
---|
1066 | #define PF_NON_TEMPORAL_LEVEL_ALL _MM_HINT_NTA
|
---|
1067 |
|
---|
1068 | //
|
---|
1069 | // Define function to get the caller's EFLAGs value.
|
---|
1070 | //
|
---|
1071 |
|
---|
1072 | #define GetCallersEflags() __getcallerseflags()
|
---|
1073 |
|
---|
1074 | unsigned __int32
|
---|
1075 | __getcallerseflags (
|
---|
1076 | VOID
|
---|
1077 | );
|
---|
1078 |
|
---|
1079 | #pragma intrinsic(__getcallerseflags)
|
---|
1080 |
|
---|
1081 | //
|
---|
1082 | // Define function to read the value of the time stamp counter
|
---|
1083 | //
|
---|
1084 |
|
---|
1085 | #define ReadTimeStampCounter() __rdtsc()
|
---|
1086 |
|
---|
1087 | ULONG64
|
---|
1088 | __rdtsc (
|
---|
1089 | VOID
|
---|
1090 | );
|
---|
1091 |
|
---|
1092 | #pragma intrinsic(__rdtsc)
|
---|
1093 |
|
---|
1094 | //
|
---|
1095 | // Define functions to move strings as bytes, words, dwords, and qwords.
|
---|
1096 | //
|
---|
1097 |
|
---|
1098 | VOID
|
---|
1099 | __movsb (
|
---|
1100 | IN PUCHAR Destination,
|
---|
1101 | IN PUCHAR Source,
|
---|
1102 | IN SIZE_T Count
|
---|
1103 | );
|
---|
1104 |
|
---|
1105 | VOID
|
---|
1106 | __movsw (
|
---|
1107 | IN PUSHORT Destination,
|
---|
1108 | IN PUSHORT Source,
|
---|
1109 | IN SIZE_T Count
|
---|
1110 | );
|
---|
1111 |
|
---|
1112 | VOID
|
---|
1113 | __movsd (
|
---|
1114 | IN PULONG Destination,
|
---|
1115 | IN PULONG Source,
|
---|
1116 | IN SIZE_T Count
|
---|
1117 | );
|
---|
1118 |
|
---|
1119 | VOID
|
---|
1120 | __movsq (
|
---|
1121 | IN PULONGLONG Destination,
|
---|
1122 | IN PULONGLONG Source,
|
---|
1123 | IN SIZE_T Count
|
---|
1124 | );
|
---|
1125 |
|
---|
1126 | #pragma intrinsic(__movsb)
|
---|
1127 | #pragma intrinsic(__movsw)
|
---|
1128 | #pragma intrinsic(__movsd)
|
---|
1129 | #pragma intrinsic(__movsq)
|
---|
1130 |
|
---|
1131 | //
|
---|
1132 | // Define functions to store strings as bytes, words, dwords, and qwords.
|
---|
1133 | //
|
---|
1134 |
|
---|
1135 | VOID
|
---|
1136 | __stosb (
|
---|
1137 | IN PUCHAR Destination,
|
---|
1138 | IN UCHAR Value,
|
---|
1139 | IN SIZE_T Count
|
---|
1140 | );
|
---|
1141 |
|
---|
1142 | VOID
|
---|
1143 | __stosw (
|
---|
1144 | IN PUSHORT Destination,
|
---|
1145 | IN USHORT Value,
|
---|
1146 | IN SIZE_T Count
|
---|
1147 | );
|
---|
1148 |
|
---|
1149 | VOID
|
---|
1150 | __stosd (
|
---|
1151 | IN PULONG Destination,
|
---|
1152 | IN ULONG Value,
|
---|
1153 | IN SIZE_T Count
|
---|
1154 | );
|
---|
1155 |
|
---|
1156 | VOID
|
---|
1157 | __stosq (
|
---|
1158 | IN PULONG64 Destination,
|
---|
1159 | IN ULONG64 Value,
|
---|
1160 | IN SIZE_T Count
|
---|
1161 | );
|
---|
1162 |
|
---|
1163 | #pragma intrinsic(__stosb)
|
---|
1164 | #pragma intrinsic(__stosw)
|
---|
1165 | #pragma intrinsic(__stosd)
|
---|
1166 | #pragma intrinsic(__stosq)
|
---|
1167 |
|
---|
1168 | //
|
---|
1169 | // Define functions to capture the high 64-bits of a 128-bit multiply.
|
---|
1170 | //
|
---|
1171 |
|
---|
1172 | #define MultiplyHigh __mulh
|
---|
1173 | #define UnsignedMultiplyHigh __umulh
|
---|
1174 |
|
---|
1175 | LONGLONG
|
---|
1176 | MultiplyHigh (
|
---|
1177 | IN LONGLONG Multiplier,
|
---|
1178 | IN LONGLONG Multiplicand
|
---|
1179 | );
|
---|
1180 |
|
---|
1181 | ULONGLONG
|
---|
1182 | UnsignedMultiplyHigh (
|
---|
1183 | IN ULONGLONG Multiplier,
|
---|
1184 | IN ULONGLONG Multiplicand
|
---|
1185 | );
|
---|
1186 |
|
---|
1187 | #pragma intrinsic(__mulh)
|
---|
1188 | #pragma intrinsic(__umulh)
|
---|
1189 |
|
---|
1190 | //
|
---|
1191 | // Define functions to read and write the uer TEB and the system PCR/PRCB.
|
---|
1192 | //
|
---|
1193 |
|
---|
1194 | UCHAR
|
---|
1195 | __readgsbyte (
|
---|
1196 | IN ULONG Offset
|
---|
1197 | );
|
---|
1198 |
|
---|
1199 | USHORT
|
---|
1200 | __readgsword (
|
---|
1201 | IN ULONG Offset
|
---|
1202 | );
|
---|
1203 |
|
---|
1204 | ULONG
|
---|
1205 | __readgsdword (
|
---|
1206 | IN ULONG Offset
|
---|
1207 | );
|
---|
1208 |
|
---|
1209 | ULONG64
|
---|
1210 | __readgsqword (
|
---|
1211 | IN ULONG Offset
|
---|
1212 | );
|
---|
1213 |
|
---|
1214 | VOID
|
---|
1215 | __writegsbyte (
|
---|
1216 | IN ULONG Offset,
|
---|
1217 | IN UCHAR Data
|
---|
1218 | );
|
---|
1219 |
|
---|
1220 | VOID
|
---|
1221 | __writegsword (
|
---|
1222 | IN ULONG Offset,
|
---|
1223 | IN USHORT Data
|
---|
1224 | );
|
---|
1225 |
|
---|
1226 | VOID
|
---|
1227 | __writegsdword (
|
---|
1228 | IN ULONG Offset,
|
---|
1229 | IN ULONG Data
|
---|
1230 | );
|
---|
1231 |
|
---|
1232 | VOID
|
---|
1233 | __writegsqword (
|
---|
1234 | IN ULONG Offset,
|
---|
1235 | IN ULONG64 Data
|
---|
1236 | );
|
---|
1237 |
|
---|
1238 | #pragma intrinsic(__readgsbyte)
|
---|
1239 | #pragma intrinsic(__readgsword)
|
---|
1240 | #pragma intrinsic(__readgsdword)
|
---|
1241 | #pragma intrinsic(__readgsqword)
|
---|
1242 | #pragma intrinsic(__writegsbyte)
|
---|
1243 | #pragma intrinsic(__writegsword)
|
---|
1244 | #pragma intrinsic(__writegsdword)
|
---|
1245 | #pragma intrinsic(__writegsqword)
|
---|
1246 |
|
---|
1247 | #ifdef __cplusplus
|
---|
1248 | }
|
---|
1249 | #endif
|
---|
1250 |
|
---|
1251 | #endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
---|
1252 |
|
---|
1253 | //
|
---|
1254 | // Size of kernel mode stack.
|
---|
1255 | //
|
---|
1256 |
|
---|
1257 | #define KERNEL_STACK_SIZE 0x6000
|
---|
1258 |
|
---|
1259 | //
|
---|
1260 | // Define size of large kernel mode stack for callbacks.
|
---|
1261 | //
|
---|
1262 |
|
---|
1263 | #define KERNEL_LARGE_STACK_SIZE 0xf000
|
---|
1264 |
|
---|
1265 | //
|
---|
1266 | // Define number of pages to initialize in a large kernel stack.
|
---|
1267 | //
|
---|
1268 |
|
---|
1269 | #define KERNEL_LARGE_STACK_COMMIT 0x5000
|
---|
1270 |
|
---|
1271 | //
|
---|
1272 | // Define the size of the stack used for processing an MCA exception.
|
---|
1273 | //
|
---|
1274 |
|
---|
1275 | #define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
|
---|
1276 |
|
---|
1277 | //
|
---|
1278 | // The following flags control the contents of the CONTEXT structure.
|
---|
1279 | //
|
---|
1280 |
|
---|
1281 | #if !defined(RC_INVOKED)
|
---|
1282 |
|
---|
1283 | #define CONTEXT_AMD64 0x100000
|
---|
1284 |
|
---|
1285 |
|
---|
1286 |
|
---|
1287 | #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
|
---|
1288 | #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
|
---|
1289 | #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
|
---|
1290 | #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
|
---|
1291 | #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
|
---|
1292 |
|
---|
1293 | #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
|
---|
1294 |
|
---|
1295 | #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
|
---|
1296 |
|
---|
1297 |
|
---|
1298 |
|
---|
1299 | #endif // !defined(RC_INVOKED)
|
---|
1300 |
|
---|
1301 | //
|
---|
1302 | // Define initial MxCsr control.
|
---|
1303 | //
|
---|
1304 |
|
---|
1305 | #define INITIAL_MXCSR 0x1f80 // initial MXCSR value
|
---|
1306 |
|
---|
1307 | //
|
---|
1308 | // Define 128-bit 16-byte aligned xmm register type.
|
---|
1309 | //
|
---|
1310 |
|
---|
1311 | typedef struct DECLSPEC_ALIGN(16) _M128 {
|
---|
1312 | ULONGLONG Low;
|
---|
1313 | LONGLONG High;
|
---|
1314 | } M128, *PM128;
|
---|
1315 |
|
---|
1316 | //
|
---|
1317 | // Format of data for fnsave/frstor instructions.
|
---|
1318 | //
|
---|
1319 | // This structure is used to store the legacy floating point state.
|
---|
1320 | //
|
---|
1321 |
|
---|
1322 | typedef struct _LEGACY_SAVE_AREA {
|
---|
1323 | USHORT ControlWord;
|
---|
1324 | USHORT Reserved0;
|
---|
1325 | USHORT StatusWord;
|
---|
1326 | USHORT Reserved1;
|
---|
1327 | USHORT TagWord;
|
---|
1328 | USHORT Reserved2;
|
---|
1329 | ULONG ErrorOffset;
|
---|
1330 | USHORT ErrorSelector;
|
---|
1331 | USHORT ErrorOpcode;
|
---|
1332 | ULONG DataOffset;
|
---|
1333 | USHORT DataSelector;
|
---|
1334 | USHORT Reserved3;
|
---|
1335 | UCHAR FloatRegisters[8 * 10];
|
---|
1336 | } LEGACY_SAVE_AREA, *PLEGACY_SAVE_AREA;
|
---|
1337 |
|
---|
1338 | #define LEGACY_SAVE_AREA_LENGTH ((sizeof(LEGACY_SAVE_AREA) + 15) & ~15)
|
---|
1339 |
|
---|
1340 | //
|
---|
1341 | // Context Frame
|
---|
1342 | //
|
---|
1343 | // This frame has a several purposes: 1) it is used as an argument to
|
---|
1344 | // NtContinue, 2) is is used to construct a call frame for APC delivery,
|
---|
1345 | // and 3) it is used in the user level thread creation routines.
|
---|
1346 | //
|
---|
1347 | //
|
---|
1348 | // The flags field within this record controls the contents of a CONTEXT
|
---|
1349 | // record.
|
---|
1350 | //
|
---|
1351 | // If the context record is used as an input parameter, then for each
|
---|
1352 | // portion of the context record controlled by a flag whose value is
|
---|
1353 | // set, it is assumed that that portion of the context record contains
|
---|
1354 | // valid context. If the context record is being used to modify a threads
|
---|
1355 | // context, then only that portion of the threads context is modified.
|
---|
1356 | //
|
---|
1357 | // If the context record is used as an output parameter to capture the
|
---|
1358 | // context of a thread, then only those portions of the thread's context
|
---|
1359 | // corresponding to set flags will be returned.
|
---|
1360 | //
|
---|
1361 | // CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
|
---|
1362 | //
|
---|
1363 | // CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
|
---|
1364 | //
|
---|
1365 | // CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
|
---|
1366 | //
|
---|
1367 | // CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
|
---|
1368 | //
|
---|
1369 | // CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
|
---|
1370 | // Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
|
---|
1371 | //
|
---|
1372 |
|
---|
1373 | typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
|
---|
1374 |
|
---|
1375 | //
|
---|
1376 | // Register parameter home addresses.
|
---|
1377 | //
|
---|
1378 |
|
---|
1379 | ULONG64 P1Home;
|
---|
1380 | ULONG64 P2Home;
|
---|
1381 | ULONG64 P3Home;
|
---|
1382 | ULONG64 P4Home;
|
---|
1383 | ULONG64 P5Home;
|
---|
1384 | ULONG64 P6Home;
|
---|
1385 |
|
---|
1386 | //
|
---|
1387 | // Control flags.
|
---|
1388 | //
|
---|
1389 |
|
---|
1390 | ULONG ContextFlags;
|
---|
1391 | ULONG MxCsr;
|
---|
1392 |
|
---|
1393 | //
|
---|
1394 | // Segment Registers and processor flags.
|
---|
1395 | //
|
---|
1396 |
|
---|
1397 | USHORT SegCs;
|
---|
1398 | USHORT SegDs;
|
---|
1399 | USHORT SegEs;
|
---|
1400 | USHORT SegFs;
|
---|
1401 | USHORT SegGs;
|
---|
1402 | USHORT SegSs;
|
---|
1403 | ULONG EFlags;
|
---|
1404 |
|
---|
1405 | //
|
---|
1406 | // Debug registers
|
---|
1407 | //
|
---|
1408 |
|
---|
1409 | ULONG64 Dr0;
|
---|
1410 | ULONG64 Dr1;
|
---|
1411 | ULONG64 Dr2;
|
---|
1412 | ULONG64 Dr3;
|
---|
1413 | ULONG64 Dr6;
|
---|
1414 | ULONG64 Dr7;
|
---|
1415 |
|
---|
1416 | //
|
---|
1417 | // Integer registers.
|
---|
1418 | //
|
---|
1419 |
|
---|
1420 | ULONG64 Rax;
|
---|
1421 | ULONG64 Rcx;
|
---|
1422 | ULONG64 Rdx;
|
---|
1423 | ULONG64 Rbx;
|
---|
1424 | ULONG64 Rsp;
|
---|
1425 | ULONG64 Rbp;
|
---|
1426 | ULONG64 Rsi;
|
---|
1427 | ULONG64 Rdi;
|
---|
1428 | ULONG64 R8;
|
---|
1429 | ULONG64 R9;
|
---|
1430 | ULONG64 R10;
|
---|
1431 | ULONG64 R11;
|
---|
1432 | ULONG64 R12;
|
---|
1433 | ULONG64 R13;
|
---|
1434 | ULONG64 R14;
|
---|
1435 | ULONG64 R15;
|
---|
1436 |
|
---|
1437 | //
|
---|
1438 | // Program counter.
|
---|
1439 | //
|
---|
1440 |
|
---|
1441 | ULONG64 Rip;
|
---|
1442 |
|
---|
1443 | //
|
---|
1444 | // MMX/floating point state.
|
---|
1445 | //
|
---|
1446 |
|
---|
1447 | M128 Xmm0;
|
---|
1448 | M128 Xmm1;
|
---|
1449 | M128 Xmm2;
|
---|
1450 | M128 Xmm3;
|
---|
1451 | M128 Xmm4;
|
---|
1452 | M128 Xmm5;
|
---|
1453 | M128 Xmm6;
|
---|
1454 | M128 Xmm7;
|
---|
1455 | M128 Xmm8;
|
---|
1456 | M128 Xmm9;
|
---|
1457 | M128 Xmm10;
|
---|
1458 | M128 Xmm11;
|
---|
1459 | M128 Xmm12;
|
---|
1460 | M128 Xmm13;
|
---|
1461 | M128 Xmm14;
|
---|
1462 | M128 Xmm15;
|
---|
1463 |
|
---|
1464 | //
|
---|
1465 | // Legacy floating point state.
|
---|
1466 | //
|
---|
1467 |
|
---|
1468 | LEGACY_SAVE_AREA FltSave;
|
---|
1469 | ULONG Fill;
|
---|
1470 |
|
---|
1471 | //
|
---|
1472 | // Special debug control registers.
|
---|
1473 | //
|
---|
1474 |
|
---|
1475 | ULONG64 DebugControl;
|
---|
1476 | ULONG64 LastBranchToRip;
|
---|
1477 | ULONG64 LastBranchFromRip;
|
---|
1478 | ULONG64 LastExceptionToRip;
|
---|
1479 | ULONG64 LastExceptionFromRip;
|
---|
1480 | ULONG64 Fill1;
|
---|
1481 | } CONTEXT, *PCONTEXT;
|
---|
1482 |
|
---|
1483 |
|
---|
1484 | #endif // _AMD64_
|
---|
1485 |
|
---|
1486 |
|
---|
1487 | #ifdef _IA64_
|
---|
1488 |
|
---|
1489 | //
|
---|
1490 | // Define size of kernel mode stack.
|
---|
1491 | //
|
---|
1492 |
|
---|
1493 | #define KERNEL_STACK_SIZE 0x8000
|
---|
1494 |
|
---|
1495 | //
|
---|
1496 | // Define size of large kernel mode stack for callbacks.
|
---|
1497 | //
|
---|
1498 |
|
---|
1499 | #define KERNEL_LARGE_STACK_SIZE 0x1A000
|
---|
1500 |
|
---|
1501 | //
|
---|
1502 | // Define number of pages to initialize in a large kernel stack.
|
---|
1503 | //
|
---|
1504 |
|
---|
1505 | #define KERNEL_LARGE_STACK_COMMIT 0x8000
|
---|
1506 |
|
---|
1507 | //
|
---|
1508 | // Define size of kernel mode backing store stack.
|
---|
1509 | //
|
---|
1510 |
|
---|
1511 | #define KERNEL_BSTORE_SIZE 0x8000
|
---|
1512 |
|
---|
1513 | //
|
---|
1514 | // Define size of large kernel mode backing store for callbacks.
|
---|
1515 | //
|
---|
1516 |
|
---|
1517 | #define KERNEL_LARGE_BSTORE_SIZE 0x10000
|
---|
1518 |
|
---|
1519 | //
|
---|
1520 | // Define number of pages to initialize in a large kernel backing store.
|
---|
1521 | //
|
---|
1522 |
|
---|
1523 | #define KERNEL_LARGE_BSTORE_COMMIT 0x8000
|
---|
1524 |
|
---|
1525 | //
|
---|
1526 | // Define base address for kernel and user space.
|
---|
1527 | //
|
---|
1528 |
|
---|
1529 | #define UREGION_INDEX 0
|
---|
1530 |
|
---|
1531 | #define KREGION_INDEX 7
|
---|
1532 |
|
---|
1533 | #define UADDRESS_BASE ((ULONGLONG)UREGION_INDEX << 61)
|
---|
1534 |
|
---|
1535 |
|
---|
1536 | #define KADDRESS_BASE ((ULONGLONG)KREGION_INDEX << 61)
|
---|
1537 |
|
---|
1538 |
|
---|
1539 | void
|
---|
1540 | __yield(
|
---|
1541 | void
|
---|
1542 | );
|
---|
1543 |
|
---|
1544 | void
|
---|
1545 | __mf(
|
---|
1546 | void
|
---|
1547 | );
|
---|
1548 |
|
---|
1549 | void
|
---|
1550 | __lfetch(
|
---|
1551 | int Level,
|
---|
1552 | VOID CONST *Address
|
---|
1553 | );
|
---|
1554 |
|
---|
1555 | void
|
---|
1556 | __lfetchfault(
|
---|
1557 | int Level,
|
---|
1558 | VOID CONST *Address
|
---|
1559 | );
|
---|
1560 |
|
---|
1561 | //
|
---|
1562 | // __lfetch control defines.
|
---|
1563 | //
|
---|
1564 |
|
---|
1565 | #define MD_LFHINT_NONE 0x00
|
---|
1566 | #define MD_LFHINT_NT1 0x01
|
---|
1567 | #define MD_LFHINT_NT2 0x02
|
---|
1568 | #define MD_LFHINT_NTA 0x03
|
---|
1569 |
|
---|
1570 | #pragma intrinsic (__yield)
|
---|
1571 | #pragma intrinsic (__lfetch)
|
---|
1572 | #pragma intrinsic (__lfetchfault)
|
---|
1573 | #pragma intrinsic (__mf)
|
---|
1574 |
|
---|
1575 |
|
---|
1576 | #define YieldProcessor __yield
|
---|
1577 | #define MemoryBarrier __mf
|
---|
1578 | #define PreFetchCacheLine __lfetch
|
---|
1579 |
|
---|
1580 | //
|
---|
1581 | // PreFetchCacheLine level defines.
|
---|
1582 | //
|
---|
1583 |
|
---|
1584 | #define PF_TEMPORAL_LEVEL_1 MD_LFHINT_NONE
|
---|
1585 | #define PF_NON_TEMPORAL_LEVEL_ALL MD_LFHINT_NTA
|
---|
1586 |
|
---|
1587 |
|
---|
1588 | //
|
---|
1589 | // The following flags control the contents of the CONTEXT structure.
|
---|
1590 | //
|
---|
1591 |
|
---|
1592 | #if !defined(RC_INVOKED)
|
---|
1593 |
|
---|
1594 | #define CONTEXT_IA64 0x00080000
|
---|
1595 |
|
---|
1596 | #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001L)
|
---|
1597 | #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002L)
|
---|
1598 | #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004L)
|
---|
1599 | #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008L)
|
---|
1600 | #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010L)
|
---|
1601 | #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020L) // Includes StIPSR
|
---|
1602 |
|
---|
1603 |
|
---|
1604 | #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
|
---|
1605 | #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
|
---|
1606 | #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
|
---|
1607 |
|
---|
1608 | #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
|
---|
1609 | #define CONTEXT_SERVICE_ACTIVE 0x10000000
|
---|
1610 | #define CONTEXT_EXCEPTION_REQUEST 0x40000000
|
---|
1611 | #define CONTEXT_EXCEPTION_REPORTING 0x80000000
|
---|
1612 |
|
---|
1613 | #endif // !defined(RC_INVOKED)
|
---|
1614 |
|
---|
1615 | //
|
---|
1616 | // Context Frame
|
---|
1617 | //
|
---|
1618 | // This frame has a several purposes: 1) it is used as an argument to
|
---|
1619 | // NtContinue, 2) it is used to construct a call frame for APC delivery,
|
---|
1620 | // 3) it is used to construct a call frame for exception dispatching
|
---|
1621 | // in user mode, 4) it is used in the user level thread creation
|
---|
1622 | // routines, and 5) it is used to to pass thread state to debuggers.
|
---|
1623 | //
|
---|
1624 | // N.B. Because this record is used as a call frame, it must be EXACTLY
|
---|
1625 | // a multiple of 16 bytes in length and aligned on a 16-byte boundary.
|
---|
1626 | //
|
---|
1627 |
|
---|
1628 | typedef struct _CONTEXT {
|
---|
1629 |
|
---|
1630 | //
|
---|
1631 | // The flags values within this flag control the contents of
|
---|
1632 | // a CONTEXT record.
|
---|
1633 | //
|
---|
1634 | // If the context record is used as an input parameter, then
|
---|
1635 | // for each portion of the context record controlled by a flag
|
---|
1636 | // whose value is set, it is assumed that that portion of the
|
---|
1637 | // context record contains valid context. If the context record
|
---|
1638 | // is being used to modify a thread's context, then only that
|
---|
1639 | // portion of the threads context will be modified.
|
---|
1640 | //
|
---|
1641 | // If the context record is used as an IN OUT parameter to capture
|
---|
1642 | // the context of a thread, then only those portions of the thread's
|
---|
1643 | // context corresponding to set flags will be returned.
|
---|
1644 | //
|
---|
1645 | // The context record is never used as an OUT only parameter.
|
---|
1646 | //
|
---|
1647 |
|
---|
1648 | ULONG ContextFlags;
|
---|
1649 | ULONG Fill1[3]; // for alignment of following on 16-byte boundary
|
---|
1650 |
|
---|
1651 | //
|
---|
1652 | // This section is specified/returned if the ContextFlags word contains
|
---|
1653 | // the flag CONTEXT_DEBUG.
|
---|
1654 | //
|
---|
1655 | // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
|
---|
1656 | //
|
---|
1657 |
|
---|
1658 | ULONGLONG DbI0;
|
---|
1659 | ULONGLONG DbI1;
|
---|
1660 | ULONGLONG DbI2;
|
---|
1661 | ULONGLONG DbI3;
|
---|
1662 | ULONGLONG DbI4;
|
---|
1663 | ULONGLONG DbI5;
|
---|
1664 | ULONGLONG DbI6;
|
---|
1665 | ULONGLONG DbI7;
|
---|
1666 |
|
---|
1667 | ULONGLONG DbD0;
|
---|
1668 | ULONGLONG DbD1;
|
---|
1669 | ULONGLONG DbD2;
|
---|
1670 | ULONGLONG DbD3;
|
---|
1671 | ULONGLONG DbD4;
|
---|
1672 | ULONGLONG DbD5;
|
---|
1673 | ULONGLONG DbD6;
|
---|
1674 | ULONGLONG DbD7;
|
---|
1675 |
|
---|
1676 | //
|
---|
1677 | // This section is specified/returned if the ContextFlags word contains
|
---|
1678 | // the flag CONTEXT_LOWER_FLOATING_POINT.
|
---|
1679 | //
|
---|
1680 |
|
---|
1681 | FLOAT128 FltS0;
|
---|
1682 | FLOAT128 FltS1;
|
---|
1683 | FLOAT128 FltS2;
|
---|
1684 | FLOAT128 FltS3;
|
---|
1685 | FLOAT128 FltT0;
|
---|
1686 | FLOAT128 FltT1;
|
---|
1687 | FLOAT128 FltT2;
|
---|
1688 | FLOAT128 FltT3;
|
---|
1689 | FLOAT128 FltT4;
|
---|
1690 | FLOAT128 FltT5;
|
---|
1691 | FLOAT128 FltT6;
|
---|
1692 | FLOAT128 FltT7;
|
---|
1693 | FLOAT128 FltT8;
|
---|
1694 | FLOAT128 FltT9;
|
---|
1695 |
|
---|
1696 | //
|
---|
1697 | // This section is specified/returned if the ContextFlags word contains
|
---|
1698 | // the flag CONTEXT_HIGHER_FLOATING_POINT.
|
---|
1699 | //
|
---|
1700 |
|
---|
1701 | FLOAT128 FltS4;
|
---|
1702 | FLOAT128 FltS5;
|
---|
1703 | FLOAT128 FltS6;
|
---|
1704 | FLOAT128 FltS7;
|
---|
1705 | FLOAT128 FltS8;
|
---|
1706 | FLOAT128 FltS9;
|
---|
1707 | FLOAT128 FltS10;
|
---|
1708 | FLOAT128 FltS11;
|
---|
1709 | FLOAT128 FltS12;
|
---|
1710 | FLOAT128 FltS13;
|
---|
1711 | FLOAT128 FltS14;
|
---|
1712 | FLOAT128 FltS15;
|
---|
1713 | FLOAT128 FltS16;
|
---|
1714 | FLOAT128 FltS17;
|
---|
1715 | FLOAT128 FltS18;
|
---|
1716 | FLOAT128 FltS19;
|
---|
1717 |
|
---|
1718 | FLOAT128 FltF32;
|
---|
1719 | FLOAT128 FltF33;
|
---|
1720 | FLOAT128 FltF34;
|
---|
1721 | FLOAT128 FltF35;
|
---|
1722 | FLOAT128 FltF36;
|
---|
1723 | FLOAT128 FltF37;
|
---|
1724 | FLOAT128 FltF38;
|
---|
1725 | FLOAT128 FltF39;
|
---|
1726 |
|
---|
1727 | FLOAT128 FltF40;
|
---|
1728 | FLOAT128 FltF41;
|
---|
1729 | FLOAT128 FltF42;
|
---|
1730 | FLOAT128 FltF43;
|
---|
1731 | FLOAT128 FltF44;
|
---|
1732 | FLOAT128 FltF45;
|
---|
1733 | FLOAT128 FltF46;
|
---|
1734 | FLOAT128 FltF47;
|
---|
1735 | FLOAT128 FltF48;
|
---|
1736 | FLOAT128 FltF49;
|
---|
1737 |
|
---|
1738 | FLOAT128 FltF50;
|
---|
1739 | FLOAT128 FltF51;
|
---|
1740 | FLOAT128 FltF52;
|
---|
1741 | FLOAT128 FltF53;
|
---|
1742 | FLOAT128 FltF54;
|
---|
1743 | FLOAT128 FltF55;
|
---|
1744 | FLOAT128 FltF56;
|
---|
1745 | FLOAT128 FltF57;
|
---|
1746 | FLOAT128 FltF58;
|
---|
1747 | FLOAT128 FltF59;
|
---|
1748 |
|
---|
1749 | FLOAT128 FltF60;
|
---|
1750 | FLOAT128 FltF61;
|
---|
1751 | FLOAT128 FltF62;
|
---|
1752 | FLOAT128 FltF63;
|
---|
1753 | FLOAT128 FltF64;
|
---|
1754 | FLOAT128 FltF65;
|
---|
1755 | FLOAT128 FltF66;
|
---|
1756 | FLOAT128 FltF67;
|
---|
1757 | FLOAT128 FltF68;
|
---|
1758 | FLOAT128 FltF69;
|
---|
1759 |
|
---|
1760 | FLOAT128 FltF70;
|
---|
1761 | FLOAT128 FltF71;
|
---|
1762 | FLOAT128 FltF72;
|
---|
1763 | FLOAT128 FltF73;
|
---|
1764 | FLOAT128 FltF74;
|
---|
1765 | FLOAT128 FltF75;
|
---|
1766 | FLOAT128 FltF76;
|
---|
1767 | FLOAT128 FltF77;
|
---|
1768 | FLOAT128 FltF78;
|
---|
1769 | FLOAT128 FltF79;
|
---|
1770 |
|
---|
1771 | FLOAT128 FltF80;
|
---|
1772 | FLOAT128 FltF81;
|
---|
1773 | FLOAT128 FltF82;
|
---|
1774 | FLOAT128 FltF83;
|
---|
1775 | FLOAT128 FltF84;
|
---|
1776 | FLOAT128 FltF85;
|
---|
1777 | FLOAT128 FltF86;
|
---|
1778 | FLOAT128 FltF87;
|
---|
1779 | FLOAT128 FltF88;
|
---|
1780 | FLOAT128 FltF89;
|
---|
1781 |
|
---|
1782 | FLOAT128 FltF90;
|
---|
1783 | FLOAT128 FltF91;
|
---|
1784 | FLOAT128 FltF92;
|
---|
1785 | FLOAT128 FltF93;
|
---|
1786 | FLOAT128 FltF94;
|
---|
1787 | FLOAT128 FltF95;
|
---|
1788 | FLOAT128 FltF96;
|
---|
1789 | FLOAT128 FltF97;
|
---|
1790 | FLOAT128 FltF98;
|
---|
1791 | FLOAT128 FltF99;
|
---|
1792 |
|
---|
1793 | FLOAT128 FltF100;
|
---|
1794 | FLOAT128 FltF101;
|
---|
1795 | FLOAT128 FltF102;
|
---|
1796 | FLOAT128 FltF103;
|
---|
1797 | FLOAT128 FltF104;
|
---|
1798 | FLOAT128 FltF105;
|
---|
1799 | FLOAT128 FltF106;
|
---|
1800 | FLOAT128 FltF107;
|
---|
1801 | FLOAT128 FltF108;
|
---|
1802 | FLOAT128 FltF109;
|
---|
1803 |
|
---|
1804 | FLOAT128 FltF110;
|
---|
1805 | FLOAT128 FltF111;
|
---|
1806 | FLOAT128 FltF112;
|
---|
1807 | FLOAT128 FltF113;
|
---|
1808 | FLOAT128 FltF114;
|
---|
1809 | FLOAT128 FltF115;
|
---|
1810 | FLOAT128 FltF116;
|
---|
1811 | FLOAT128 FltF117;
|
---|
1812 | FLOAT128 FltF118;
|
---|
1813 | FLOAT128 FltF119;
|
---|
1814 |
|
---|
1815 | FLOAT128 FltF120;
|
---|
1816 | FLOAT128 FltF121;
|
---|
1817 | FLOAT128 FltF122;
|
---|
1818 | FLOAT128 FltF123;
|
---|
1819 | FLOAT128 FltF124;
|
---|
1820 | FLOAT128 FltF125;
|
---|
1821 | FLOAT128 FltF126;
|
---|
1822 | FLOAT128 FltF127;
|
---|
1823 |
|
---|
1824 | //
|
---|
1825 | // This section is specified/returned if the ContextFlags word contains
|
---|
1826 | // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
|
---|
1827 | //
|
---|
1828 |
|
---|
1829 | ULONGLONG StFPSR; // FP status
|
---|
1830 |
|
---|
1831 | //
|
---|
1832 | // This section is specified/returned if the ContextFlags word contains
|
---|
1833 | // the flag CONTEXT_INTEGER.
|
---|
1834 | //
|
---|
1835 | // N.B. The registers gp, sp, rp are part of the control context
|
---|
1836 | //
|
---|
1837 |
|
---|
1838 | ULONGLONG IntGp; // r1, volatile
|
---|
1839 | ULONGLONG IntT0; // r2-r3, volatile
|
---|
1840 | ULONGLONG IntT1; //
|
---|
1841 | ULONGLONG IntS0; // r4-r7, preserved
|
---|
1842 | ULONGLONG IntS1;
|
---|
1843 | ULONGLONG IntS2;
|
---|
1844 | ULONGLONG IntS3;
|
---|
1845 | ULONGLONG IntV0; // r8, volatile
|
---|
1846 | ULONGLONG IntT2; // r9-r11, volatile
|
---|
1847 | ULONGLONG IntT3;
|
---|
1848 | ULONGLONG IntT4;
|
---|
1849 | ULONGLONG IntSp; // stack pointer (r12), special
|
---|
1850 | ULONGLONG IntTeb; // teb (r13), special
|
---|
1851 | ULONGLONG IntT5; // r14-r31, volatile
|
---|
1852 | ULONGLONG IntT6;
|
---|
1853 | ULONGLONG IntT7;
|
---|
1854 | ULONGLONG IntT8;
|
---|
1855 | ULONGLONG IntT9;
|
---|
1856 | ULONGLONG IntT10;
|
---|
1857 | ULONGLONG IntT11;
|
---|
1858 | ULONGLONG IntT12;
|
---|
1859 | ULONGLONG IntT13;
|
---|
1860 | ULONGLONG IntT14;
|
---|
1861 | ULONGLONG IntT15;
|
---|
1862 | ULONGLONG IntT16;
|
---|
1863 | ULONGLONG IntT17;
|
---|
1864 | ULONGLONG IntT18;
|
---|
1865 | ULONGLONG IntT19;
|
---|
1866 | ULONGLONG IntT20;
|
---|
1867 | ULONGLONG IntT21;
|
---|
1868 | ULONGLONG IntT22;
|
---|
1869 |
|
---|
1870 | ULONGLONG IntNats; // Nat bits for r1-r31
|
---|
1871 | // r1-r31 in bits 1 thru 31.
|
---|
1872 | ULONGLONG Preds; // predicates, preserved
|
---|
1873 |
|
---|
1874 | ULONGLONG BrRp; // return pointer, b0, preserved
|
---|
1875 | ULONGLONG BrS0; // b1-b5, preserved
|
---|
1876 | ULONGLONG BrS1;
|
---|
1877 | ULONGLONG BrS2;
|
---|
1878 | ULONGLONG BrS3;
|
---|
1879 | ULONGLONG BrS4;
|
---|
1880 | ULONGLONG BrT0; // b6-b7, volatile
|
---|
1881 | ULONGLONG BrT1;
|
---|
1882 |
|
---|
1883 | //
|
---|
1884 | // This section is specified/returned if the ContextFlags word contains
|
---|
1885 | // the flag CONTEXT_CONTROL.
|
---|
1886 | //
|
---|
1887 |
|
---|
1888 | // Other application registers
|
---|
1889 | ULONGLONG ApUNAT; // User Nat collection register, preserved
|
---|
1890 | ULONGLONG ApLC; // Loop counter register, preserved
|
---|
1891 | ULONGLONG ApEC; // Epilog counter register, preserved
|
---|
1892 | ULONGLONG ApCCV; // CMPXCHG value register, volatile
|
---|
1893 | ULONGLONG ApDCR; // Default control register (TBD)
|
---|
1894 |
|
---|
1895 | // Register stack info
|
---|
1896 | ULONGLONG RsPFS; // Previous function state, preserved
|
---|
1897 | ULONGLONG RsBSP; // Backing store pointer, preserved
|
---|
1898 | ULONGLONG RsBSPSTORE;
|
---|
1899 | ULONGLONG RsRSC; // RSE configuration, volatile
|
---|
1900 | ULONGLONG RsRNAT; // RSE Nat collection register, preserved
|
---|
1901 |
|
---|
1902 | // Trap Status Information
|
---|
1903 | ULONGLONG StIPSR; // Interruption Processor Status
|
---|
1904 | ULONGLONG StIIP; // Interruption IP
|
---|
1905 | ULONGLONG StIFS; // Interruption Function State
|
---|
1906 |
|
---|
1907 | // iA32 related control registers
|
---|
1908 | ULONGLONG StFCR; // copy of Ar21
|
---|
1909 | ULONGLONG Eflag; // Eflag copy of Ar24
|
---|
1910 | ULONGLONG SegCSD; // iA32 CSDescriptor (Ar25)
|
---|
1911 | ULONGLONG SegSSD; // iA32 SSDescriptor (Ar26)
|
---|
1912 | ULONGLONG Cflag; // Cr0+Cr4 copy of Ar27
|
---|
1913 | ULONGLONG StFSR; // x86 FP status (copy of AR28)
|
---|
1914 | ULONGLONG StFIR; // x86 FP status (copy of AR29)
|
---|
1915 | ULONGLONG StFDR; // x86 FP status (copy of AR30)
|
---|
1916 |
|
---|
1917 | ULONGLONG UNUSEDPACK; // added to pack StFDR to 16-bytes
|
---|
1918 |
|
---|
1919 | } CONTEXT, *PCONTEXT;
|
---|
1920 |
|
---|
1921 | //
|
---|
1922 | // Plabel descriptor structure definition
|
---|
1923 | //
|
---|
1924 |
|
---|
1925 | typedef struct _PLABEL_DESCRIPTOR {
|
---|
1926 | ULONGLONG EntryPoint;
|
---|
1927 | ULONGLONG GlobalPointer;
|
---|
1928 | } PLABEL_DESCRIPTOR, *PPLABEL_DESCRIPTOR;
|
---|
1929 |
|
---|
1930 |
|
---|
1931 |
|
---|
1932 | #endif // _IA64_
|
---|
1933 | //
|
---|
1934 | // Define an access token from a programmer's viewpoint. The structure is
|
---|
1935 | // completely opaque and the programer is only allowed to have pointers
|
---|
1936 | // to tokens.
|
---|
1937 | //
|
---|
1938 |
|
---|
1939 | typedef PVOID PACCESS_TOKEN;
|
---|
1940 |
|
---|
1941 | //
|
---|
1942 | // Pointer to a SECURITY_DESCRIPTOR opaque data type.
|
---|
1943 | //
|
---|
1944 |
|
---|
1945 | typedef PVOID PSECURITY_DESCRIPTOR;
|
---|
1946 |
|
---|
1947 | //
|
---|
1948 | // Define a pointer to the Security ID data type (an opaque data type)
|
---|
1949 | //
|
---|
1950 |
|
---|
1951 | typedef PVOID PSID;
|
---|
1952 |
|
---|
1953 | typedef ULONG ACCESS_MASK;
|
---|
1954 | typedef ACCESS_MASK *PACCESS_MASK;
|
---|
1955 |
|
---|
1956 |
|
---|
1957 | //
|
---|
1958 | // The following are masks for the predefined standard access types
|
---|
1959 | //
|
---|
1960 |
|
---|
1961 | #define DELETE (0x00010000L)
|
---|
1962 | #define READ_CONTROL (0x00020000L)
|
---|
1963 | #define WRITE_DAC (0x00040000L)
|
---|
1964 | #define WRITE_OWNER (0x00080000L)
|
---|
1965 | #define SYNCHRONIZE (0x00100000L)
|
---|
1966 |
|
---|
1967 | #define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
|
---|
1968 |
|
---|
1969 | #define STANDARD_RIGHTS_READ (READ_CONTROL)
|
---|
1970 | #define STANDARD_RIGHTS_WRITE (READ_CONTROL)
|
---|
1971 | #define STANDARD_RIGHTS_EXECUTE (READ_CONTROL)
|
---|
1972 |
|
---|
1973 | #define STANDARD_RIGHTS_ALL (0x001F0000L)
|
---|
1974 |
|
---|
1975 | #define SPECIFIC_RIGHTS_ALL (0x0000FFFFL)
|
---|
1976 |
|
---|
1977 | //
|
---|
1978 | // AccessSystemAcl access type
|
---|
1979 | //
|
---|
1980 |
|
---|
1981 | #define ACCESS_SYSTEM_SECURITY (0x01000000L)
|
---|
1982 |
|
---|
1983 | //
|
---|
1984 | // MaximumAllowed access type
|
---|
1985 | //
|
---|
1986 |
|
---|
1987 | #define MAXIMUM_ALLOWED (0x02000000L)
|
---|
1988 |
|
---|
1989 | //
|
---|
1990 | // These are the generic rights.
|
---|
1991 | //
|
---|
1992 |
|
---|
1993 | #define GENERIC_READ (0x80000000L)
|
---|
1994 | #define GENERIC_WRITE (0x40000000L)
|
---|
1995 | #define GENERIC_EXECUTE (0x20000000L)
|
---|
1996 | #define GENERIC_ALL (0x10000000L)
|
---|
1997 |
|
---|
1998 |
|
---|
1999 | //
|
---|
2000 | // Define the generic mapping array. This is used to denote the
|
---|
2001 | // mapping of each generic access right to a specific access mask.
|
---|
2002 | //
|
---|
2003 |
|
---|
2004 | typedef struct _GENERIC_MAPPING {
|
---|
2005 | ACCESS_MASK GenericRead;
|
---|
2006 | ACCESS_MASK GenericWrite;
|
---|
2007 | ACCESS_MASK GenericExecute;
|
---|
2008 | ACCESS_MASK GenericAll;
|
---|
2009 | } GENERIC_MAPPING;
|
---|
2010 | typedef GENERIC_MAPPING *PGENERIC_MAPPING;
|
---|
2011 |
|
---|
2012 |
|
---|
2013 |
|
---|
2014 | ////////////////////////////////////////////////////////////////////////
|
---|
2015 | // //
|
---|
2016 | // LUID_AND_ATTRIBUTES //
|
---|
2017 | // //
|
---|
2018 | ////////////////////////////////////////////////////////////////////////
|
---|
2019 | //
|
---|
2020 | //
|
---|
2021 |
|
---|
2022 |
|
---|
2023 | #include <pshpack4.h>
|
---|
2024 |
|
---|
2025 | typedef struct _LUID_AND_ATTRIBUTES {
|
---|
2026 | LUID Luid;
|
---|
2027 | ULONG Attributes;
|
---|
2028 | } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
|
---|
2029 | typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
|
---|
2030 | typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
|
---|
2031 |
|
---|
2032 | #include <poppack.h>
|
---|
2033 |
|
---|
2034 |
|
---|
2035 | typedef enum {
|
---|
2036 |
|
---|
2037 | WinNullSid = 0,
|
---|
2038 | WinWorldSid = 1,
|
---|
2039 | WinLocalSid = 2,
|
---|
2040 | WinCreatorOwnerSid = 3,
|
---|
2041 | WinCreatorGroupSid = 4,
|
---|
2042 | WinCreatorOwnerServerSid = 5,
|
---|
2043 | WinCreatorGroupServerSid = 6,
|
---|
2044 | WinNtAuthoritySid = 7,
|
---|
2045 | WinDialupSid = 8,
|
---|
2046 | WinNetworkSid = 9,
|
---|
2047 | WinBatchSid = 10,
|
---|
2048 | WinInteractiveSid = 11,
|
---|
2049 | WinServiceSid = 12,
|
---|
2050 | WinAnonymousSid = 13,
|
---|
2051 | WinProxySid = 14,
|
---|
2052 | WinEnterpriseControllersSid = 15,
|
---|
2053 | WinSelfSid = 16,
|
---|
2054 | WinAuthenticatedUserSid = 17,
|
---|
2055 | WinRestrictedCodeSid = 18,
|
---|
2056 | WinTerminalServerSid = 19,
|
---|
2057 | WinRemoteLogonIdSid = 20,
|
---|
2058 | WinLogonIdsSid = 21,
|
---|
2059 | WinLocalSystemSid = 22,
|
---|
2060 | WinLocalServiceSid = 23,
|
---|
2061 | WinNetworkServiceSid = 24,
|
---|
2062 | WinBuiltinDomainSid = 25,
|
---|
2063 | WinBuiltinAdministratorsSid = 26,
|
---|
2064 | WinBuiltinUsersSid = 27,
|
---|
2065 | WinBuiltinGuestsSid = 28,
|
---|
2066 | WinBuiltinPowerUsersSid = 29,
|
---|
2067 | WinBuiltinAccountOperatorsSid = 30,
|
---|
2068 | WinBuiltinSystemOperatorsSid = 31,
|
---|
2069 | WinBuiltinPrintOperatorsSid = 32,
|
---|
2070 | WinBuiltinBackupOperatorsSid = 33,
|
---|
2071 | WinBuiltinReplicatorSid = 34,
|
---|
2072 | WinBuiltinPreWindows2000CompatibleAccessSid = 35,
|
---|
2073 | WinBuiltinRemoteDesktopUsersSid = 36,
|
---|
2074 | WinBuiltinNetworkConfigurationOperatorsSid = 37,
|
---|
2075 | WinAccountAdministratorSid = 38,
|
---|
2076 | WinAccountGuestSid = 39,
|
---|
2077 | WinAccountKrbtgtSid = 40,
|
---|
2078 | WinAccountDomainAdminsSid = 41,
|
---|
2079 | WinAccountDomainUsersSid = 42,
|
---|
2080 | WinAccountDomainGuestsSid = 43,
|
---|
2081 | WinAccountComputersSid = 44,
|
---|
2082 | WinAccountControllersSid = 45,
|
---|
2083 | WinAccountCertAdminsSid = 46,
|
---|
2084 | WinAccountSchemaAdminsSid = 47,
|
---|
2085 | WinAccountEnterpriseAdminsSid = 48,
|
---|
2086 | WinAccountPolicyAdminsSid = 49,
|
---|
2087 | WinAccountRasAndIasServersSid = 50,
|
---|
2088 | WinNTLMAuthenticationSid = 51,
|
---|
2089 | WinDigestAuthenticationSid = 52,
|
---|
2090 | WinSChannelAuthenticationSid = 53,
|
---|
2091 | WinThisOrganizationSid = 54,
|
---|
2092 | WinOtherOrganizationSid = 55,
|
---|
2093 | WinBuiltinIncomingForestTrustBuildersSid = 56,
|
---|
2094 | WinBuiltinPerfMonitoringUsersSid = 57,
|
---|
2095 | WinBuiltinPerfLoggingUsersSid = 58,
|
---|
2096 | WinBuiltinAuthorizationAccessSid = 59,
|
---|
2097 | WinBuiltinTerminalServerLicenseServersSid = 60,
|
---|
2098 |
|
---|
2099 | } WELL_KNOWN_SID_TYPE;
|
---|
2100 |
|
---|
2101 | // This is the *current* ACL revision
|
---|
2102 |
|
---|
2103 | #define ACL_REVISION (2)
|
---|
2104 | #define ACL_REVISION_DS (4)
|
---|
2105 |
|
---|
2106 | // This is the history of ACL revisions. Add a new one whenever
|
---|
2107 | // ACL_REVISION is updated
|
---|
2108 |
|
---|
2109 | #define ACL_REVISION1 (1)
|
---|
2110 | #define MIN_ACL_REVISION ACL_REVISION2
|
---|
2111 | #define ACL_REVISION2 (2)
|
---|
2112 | #define ACL_REVISION3 (3)
|
---|
2113 | #define ACL_REVISION4 (4)
|
---|
2114 | #define MAX_ACL_REVISION ACL_REVISION4
|
---|
2115 |
|
---|
2116 | typedef struct _ACL {
|
---|
2117 | UCHAR AclRevision;
|
---|
2118 | UCHAR Sbz1;
|
---|
2119 | USHORT AclSize;
|
---|
2120 | USHORT AceCount;
|
---|
2121 | USHORT Sbz2;
|
---|
2122 | } ACL;
|
---|
2123 | typedef ACL *PACL;
|
---|
2124 |
|
---|
2125 | //
|
---|
2126 | // Current security descriptor revision value
|
---|
2127 | //
|
---|
2128 |
|
---|
2129 | #define SECURITY_DESCRIPTOR_REVISION (1)
|
---|
2130 | #define SECURITY_DESCRIPTOR_REVISION1 (1)
|
---|
2131 |
|
---|
2132 | //
|
---|
2133 | // Privilege attributes
|
---|
2134 | //
|
---|
2135 |
|
---|
2136 | #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
|
---|
2137 | #define SE_PRIVILEGE_ENABLED (0x00000002L)
|
---|
2138 | #define SE_PRIVILEGE_REMOVED (0X00000004L)
|
---|
2139 | #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
|
---|
2140 |
|
---|
2141 | //
|
---|
2142 | // Privilege Set Control flags
|
---|
2143 | //
|
---|
2144 |
|
---|
2145 | #define PRIVILEGE_SET_ALL_NECESSARY (1)
|
---|
2146 |
|
---|
2147 | //
|
---|
2148 | // Privilege Set - This is defined for a privilege set of one.
|
---|
2149 | // If more than one privilege is needed, then this structure
|
---|
2150 | // will need to be allocated with more space.
|
---|
2151 | //
|
---|
2152 | // Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
|
---|
2153 | // structure (defined in se.h)
|
---|
2154 | //
|
---|
2155 |
|
---|
2156 | typedef struct _PRIVILEGE_SET {
|
---|
2157 | ULONG PrivilegeCount;
|
---|
2158 | ULONG Control;
|
---|
2159 | LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
|
---|
2160 | } PRIVILEGE_SET, * PPRIVILEGE_SET;
|
---|
2161 |
|
---|
2162 | //
|
---|
2163 | // These must be converted to LUIDs before use.
|
---|
2164 | //
|
---|
2165 |
|
---|
2166 | #define SE_MIN_WELL_KNOWN_PRIVILEGE (2L)
|
---|
2167 | #define SE_CREATE_TOKEN_PRIVILEGE (2L)
|
---|
2168 | #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE (3L)
|
---|
2169 | #define SE_LOCK_MEMORY_PRIVILEGE (4L)
|
---|
2170 | #define SE_INCREASE_QUOTA_PRIVILEGE (5L)
|
---|
2171 |
|
---|
2172 |
|
---|
2173 | //
|
---|
2174 | // Unsolicited Input is obsolete and unused.
|
---|
2175 | //
|
---|
2176 |
|
---|
2177 | #define SE_UNSOLICITED_INPUT_PRIVILEGE (6L)
|
---|
2178 |
|
---|
2179 |
|
---|
2180 | #define SE_MACHINE_ACCOUNT_PRIVILEGE (6L)
|
---|
2181 | #define SE_TCB_PRIVILEGE (7L)
|
---|
2182 | #define SE_SECURITY_PRIVILEGE (8L)
|
---|
2183 | #define SE_TAKE_OWNERSHIP_PRIVILEGE (9L)
|
---|
2184 | #define SE_LOAD_DRIVER_PRIVILEGE (10L)
|
---|
2185 | #define SE_SYSTEM_PROFILE_PRIVILEGE (11L)
|
---|
2186 | #define SE_SYSTEMTIME_PRIVILEGE (12L)
|
---|
2187 | #define SE_PROF_SINGLE_PROCESS_PRIVILEGE (13L)
|
---|
2188 | #define SE_INC_BASE_PRIORITY_PRIVILEGE (14L)
|
---|
2189 | #define SE_CREATE_PAGEFILE_PRIVILEGE (15L)
|
---|
2190 | #define SE_CREATE_PERMANENT_PRIVILEGE (16L)
|
---|
2191 | #define SE_BACKUP_PRIVILEGE (17L)
|
---|
2192 | #define SE_RESTORE_PRIVILEGE (18L)
|
---|
2193 | #define SE_SHUTDOWN_PRIVILEGE (19L)
|
---|
2194 | #define SE_DEBUG_PRIVILEGE (20L)
|
---|
2195 | #define SE_AUDIT_PRIVILEGE (21L)
|
---|
2196 | #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE (22L)
|
---|
2197 | #define SE_CHANGE_NOTIFY_PRIVILEGE (23L)
|
---|
2198 | #define SE_REMOTE_SHUTDOWN_PRIVILEGE (24L)
|
---|
2199 | #define SE_UNDOCK_PRIVILEGE (25L)
|
---|
2200 | #define SE_SYNC_AGENT_PRIVILEGE (26L)
|
---|
2201 | #define SE_ENABLE_DELEGATION_PRIVILEGE (27L)
|
---|
2202 | #define SE_MANAGE_VOLUME_PRIVILEGE (28L)
|
---|
2203 | #define SE_IMPERSONATE_PRIVILEGE (29L)
|
---|
2204 | #define SE_CREATE_GLOBAL_PRIVILEGE (30L)
|
---|
2205 | #define SE_MAX_WELL_KNOWN_PRIVILEGE (SE_CREATE_GLOBAL_PRIVILEGE)
|
---|
2206 |
|
---|
2207 | //
|
---|
2208 | // Impersonation Level
|
---|
2209 | //
|
---|
2210 | // Impersonation level is represented by a pair of bits in Windows.
|
---|
2211 | // If a new impersonation level is added or lowest value is changed from
|
---|
2212 | // 0 to something else, fix the Windows CreateFile call.
|
---|
2213 | //
|
---|
2214 |
|
---|
2215 | typedef enum _SECURITY_IMPERSONATION_LEVEL {
|
---|
2216 | SecurityAnonymous,
|
---|
2217 | SecurityIdentification,
|
---|
2218 | SecurityImpersonation,
|
---|
2219 | SecurityDelegation
|
---|
2220 | } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
|
---|
2221 |
|
---|
2222 | #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
|
---|
2223 | #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
|
---|
2224 | #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
|
---|
2225 | #define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
|
---|
2226 | //
|
---|
2227 | // Security Tracking Mode
|
---|
2228 | //
|
---|
2229 |
|
---|
2230 | #define SECURITY_DYNAMIC_TRACKING (TRUE)
|
---|
2231 | #define SECURITY_STATIC_TRACKING (FALSE)
|
---|
2232 |
|
---|
2233 | typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
|
---|
2234 | * PSECURITY_CONTEXT_TRACKING_MODE;
|
---|
2235 |
|
---|
2236 |
|
---|
2237 |
|
---|
2238 | //
|
---|
2239 | // Quality Of Service
|
---|
2240 | //
|
---|
2241 |
|
---|
2242 | typedef struct _SECURITY_QUALITY_OF_SERVICE {
|
---|
2243 | ULONG Length;
|
---|
2244 | SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
|
---|
2245 | SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
|
---|
2246 | BOOLEAN EffectiveOnly;
|
---|
2247 | } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE;
|
---|
2248 |
|
---|
2249 |
|
---|
2250 | //
|
---|
2251 | // Used to represent information related to a thread impersonation
|
---|
2252 | //
|
---|
2253 |
|
---|
2254 | typedef struct _SE_IMPERSONATION_STATE {
|
---|
2255 | PACCESS_TOKEN Token;
|
---|
2256 | BOOLEAN CopyOnOpen;
|
---|
2257 | BOOLEAN EffectiveOnly;
|
---|
2258 | SECURITY_IMPERSONATION_LEVEL Level;
|
---|
2259 | } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
|
---|
2260 |
|
---|
2261 |
|
---|
2262 | typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
|
---|
2263 |
|
---|
2264 | #define OWNER_SECURITY_INFORMATION (0x00000001L)
|
---|
2265 | #define GROUP_SECURITY_INFORMATION (0x00000002L)
|
---|
2266 | #define DACL_SECURITY_INFORMATION (0x00000004L)
|
---|
2267 | #define SACL_SECURITY_INFORMATION (0x00000008L)
|
---|
2268 |
|
---|
2269 | #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
|
---|
2270 | #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
|
---|
2271 | #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
|
---|
2272 | #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
|
---|
2273 |
|
---|
2274 |
|
---|
2275 | #define LOW_PRIORITY 0 // Lowest thread priority level
|
---|
2276 | #define LOW_REALTIME_PRIORITY 16 // Lowest realtime priority level
|
---|
2277 | #define HIGH_PRIORITY 31 // Highest thread priority level
|
---|
2278 | #define MAXIMUM_PRIORITY 32 // Number of thread priority levels
|
---|
2279 |
|
---|
2280 | #define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects
|
---|
2281 |
|
---|
2282 | #define MAXIMUM_SUSPEND_COUNT MAXCHAR // Maximum times thread can be suspended
|
---|
2283 |
|
---|
2284 |
|
---|
2285 | //
|
---|
2286 | // Define system time structure.
|
---|
2287 | //
|
---|
2288 |
|
---|
2289 | typedef struct _KSYSTEM_TIME {
|
---|
2290 | ULONG LowPart;
|
---|
2291 | LONG High1Time;
|
---|
2292 | LONG High2Time;
|
---|
2293 | } KSYSTEM_TIME, *PKSYSTEM_TIME;
|
---|
2294 |
|
---|
2295 | //
|
---|
2296 | // Thread priority
|
---|
2297 | //
|
---|
2298 |
|
---|
2299 | typedef LONG KPRIORITY;
|
---|
2300 |
|
---|
2301 | //
|
---|
2302 | // Spin Lock
|
---|
2303 | //
|
---|
2304 |
|
---|
2305 |
|
---|
2306 |
|
---|
2307 | typedef ULONG_PTR KSPIN_LOCK;
|
---|
2308 | typedef KSPIN_LOCK *PKSPIN_LOCK;
|
---|
2309 |
|
---|
2310 |
|
---|
2311 |
|
---|
2312 | //
|
---|
2313 | // Define per processor lock queue structure.
|
---|
2314 | //
|
---|
2315 | // N.B. The lock field of the spin lock queue structure contains the address
|
---|
2316 | // of the associated kernel spin lock, an owner bit, and a lock bit. Bit
|
---|
2317 | // 0 of the spin lock address is the wait bit and bit 1 is the owner bit.
|
---|
2318 | // The use of this field is such that the bits can be set and cleared
|
---|
2319 | // noninterlocked, however, the back pointer must be preserved.
|
---|
2320 | //
|
---|
2321 | // The lock wait bit is set when a processor enqueues itself on the lock
|
---|
2322 | // queue and it is not the only entry in the queue. The processor will
|
---|
2323 | // spin on this bit waiting for the lock to be granted.
|
---|
2324 | //
|
---|
2325 | // The owner bit is set when the processor owns the respective lock.
|
---|
2326 | //
|
---|
2327 | // The next field of the spin lock queue structure is used to line the
|
---|
2328 | // queued lock structures together in fifo order. It also can set set and
|
---|
2329 | // cleared noninterlocked.
|
---|
2330 | //
|
---|
2331 |
|
---|
2332 | #define LOCK_QUEUE_WAIT 1
|
---|
2333 | #define LOCK_QUEUE_OWNER 2
|
---|
2334 |
|
---|
2335 | typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
|
---|
2336 | LockQueueDispatcherLock,
|
---|
2337 | LockQueueUnusedSpare1,
|
---|
2338 | LockQueuePfnLock,
|
---|
2339 | LockQueueSystemSpaceLock,
|
---|
2340 | LockQueueVacbLock,
|
---|
2341 | LockQueueMasterLock,
|
---|
2342 | LockQueueNonPagedPoolLock,
|
---|
2343 | LockQueueIoCancelLock,
|
---|
2344 | LockQueueWorkQueueLock,
|
---|
2345 | LockQueueIoVpbLock,
|
---|
2346 | LockQueueIoDatabaseLock,
|
---|
2347 | LockQueueIoCompletionLock,
|
---|
2348 | LockQueueNtfsStructLock,
|
---|
2349 | LockQueueAfdWorkQueueLock,
|
---|
2350 | LockQueueBcbLock,
|
---|
2351 | LockQueueMmNonPagedPoolLock,
|
---|
2352 | LockQueueMaximumLock
|
---|
2353 | } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
|
---|
2354 |
|
---|
2355 | typedef struct _KSPIN_LOCK_QUEUE {
|
---|
2356 | struct _KSPIN_LOCK_QUEUE * volatile Next;
|
---|
2357 | PKSPIN_LOCK volatile Lock;
|
---|
2358 | } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
|
---|
2359 |
|
---|
2360 | typedef struct _KLOCK_QUEUE_HANDLE {
|
---|
2361 | KSPIN_LOCK_QUEUE LockQueue;
|
---|
2362 | KIRQL OldIrql;
|
---|
2363 | } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
|
---|
2364 |
|
---|
2365 |
|
---|
2366 | //
|
---|
2367 | // Interrupt routine (first level dispatch)
|
---|
2368 | //
|
---|
2369 |
|
---|
2370 | typedef
|
---|
2371 | VOID
|
---|
2372 | (*PKINTERRUPT_ROUTINE) (
|
---|
2373 | VOID
|
---|
2374 | );
|
---|
2375 |
|
---|
2376 | //
|
---|
2377 | // Profile source types
|
---|
2378 | //
|
---|
2379 | typedef enum _KPROFILE_SOURCE {
|
---|
2380 | ProfileTime,
|
---|
2381 | ProfileAlignmentFixup,
|
---|
2382 | ProfileTotalIssues,
|
---|
2383 | ProfilePipelineDry,
|
---|
2384 | ProfileLoadInstructions,
|
---|
2385 | ProfilePipelineFrozen,
|
---|
2386 | ProfileBranchInstructions,
|
---|
2387 | ProfileTotalNonissues,
|
---|
2388 | ProfileDcacheMisses,
|
---|
2389 | ProfileIcacheMisses,
|
---|
2390 | ProfileCacheMisses,
|
---|
2391 | ProfileBranchMispredictions,
|
---|
2392 | ProfileStoreInstructions,
|
---|
2393 | ProfileFpInstructions,
|
---|
2394 | ProfileIntegerInstructions,
|
---|
2395 | Profile2Issue,
|
---|
2396 | Profile3Issue,
|
---|
2397 | Profile4Issue,
|
---|
2398 | ProfileSpecialInstructions,
|
---|
2399 | ProfileTotalCycles,
|
---|
2400 | ProfileIcacheIssues,
|
---|
2401 | ProfileDcacheAccesses,
|
---|
2402 | ProfileMemoryBarrierCycles,
|
---|
2403 | ProfileLoadLinkedIssues,
|
---|
2404 | ProfileMaximum
|
---|
2405 | } KPROFILE_SOURCE;
|
---|
2406 |
|
---|
2407 | //
|
---|
2408 | // for move macros
|
---|
2409 | //
|
---|
2410 | #ifdef _MAC
|
---|
2411 | #ifndef _INC_STRING
|
---|
2412 | #include <string.h>
|
---|
2413 | #endif /* _INC_STRING */
|
---|
2414 | #else
|
---|
2415 | #include <string.h>
|
---|
2416 | #endif // _MAC
|
---|
2417 |
|
---|
2418 |
|
---|
2419 | #ifndef _SLIST_HEADER_
|
---|
2420 | #define _SLIST_HEADER_
|
---|
2421 |
|
---|
2422 | #if defined(_WIN64)
|
---|
2423 |
|
---|
2424 | //
|
---|
2425 | // The type SINGLE_LIST_ENTRY is not suitable for use with SLISTs. For
|
---|
2426 | // WIN64, an entry on an SLIST is required to be 16-byte aligned, while a
|
---|
2427 | // SINGLE_LIST_ENTRY structure has only 8 byte alignment.
|
---|
2428 | //
|
---|
2429 | // Therefore, all SLIST code should use the SLIST_ENTRY type instead of the
|
---|
2430 | // SINGLE_LIST_ENTRY type.
|
---|
2431 | //
|
---|
2432 |
|
---|
2433 | #pragma warning(push)
|
---|
2434 | #pragma warning(disable:4324) // structure padded due to align()
|
---|
2435 | typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
|
---|
2436 | typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
|
---|
2437 | PSLIST_ENTRY Next;
|
---|
2438 | } SLIST_ENTRY;
|
---|
2439 | #pragma warning(pop)
|
---|
2440 |
|
---|
2441 | #else
|
---|
2442 |
|
---|
2443 | #define SLIST_ENTRY SINGLE_LIST_ENTRY
|
---|
2444 | #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
|
---|
2445 | #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
|
---|
2446 |
|
---|
2447 | #endif
|
---|
2448 |
|
---|
2449 | #if defined(_WIN64)
|
---|
2450 |
|
---|
2451 | typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER {
|
---|
2452 | ULONGLONG Alignment;
|
---|
2453 | ULONGLONG Region;
|
---|
2454 | } SLIST_HEADER;
|
---|
2455 |
|
---|
2456 | typedef struct _SLIST_HEADER *PSLIST_HEADER;
|
---|
2457 |
|
---|
2458 | #else
|
---|
2459 |
|
---|
2460 | typedef union _SLIST_HEADER {
|
---|
2461 | ULONGLONG Alignment;
|
---|
2462 | struct {
|
---|
2463 | SLIST_ENTRY Next;
|
---|
2464 | USHORT Depth;
|
---|
2465 | USHORT Sequence;
|
---|
2466 | };
|
---|
2467 | } SLIST_HEADER, *PSLIST_HEADER;
|
---|
2468 |
|
---|
2469 | #endif
|
---|
2470 |
|
---|
2471 | #endif
|
---|
2472 |
|
---|
2473 | //
|
---|
2474 | // If debugging support enabled, define an ASSERT macro that works. Otherwise
|
---|
2475 | // define the ASSERT macro to expand to an empty expression.
|
---|
2476 | //
|
---|
2477 | // The ASSERT macro has been updated to be an expression instead of a statement.
|
---|
2478 | //
|
---|
2479 |
|
---|
2480 | NTSYSAPI
|
---|
2481 | VOID
|
---|
2482 | NTAPI
|
---|
2483 | RtlAssert(
|
---|
2484 | PVOID FailedAssertion,
|
---|
2485 | PVOID FileName,
|
---|
2486 | ULONG LineNumber,
|
---|
2487 | PCHAR Message
|
---|
2488 | );
|
---|
2489 |
|
---|
2490 | #if DBG
|
---|
2491 |
|
---|
2492 | #define ASSERT( exp ) \
|
---|
2493 | ((!(exp)) ? \
|
---|
2494 | (RtlAssert( #exp, __FILE__, __LINE__, NULL ),FALSE) : \
|
---|
2495 | TRUE)
|
---|
2496 |
|
---|
2497 | #define ASSERTMSG( msg, exp ) \
|
---|
2498 | ((!(exp)) ? \
|
---|
2499 | (RtlAssert( #exp, __FILE__, __LINE__, msg ),FALSE) : \
|
---|
2500 | TRUE)
|
---|
2501 |
|
---|
2502 | #define RTL_SOFT_ASSERT(_exp) \
|
---|
2503 | ((!(_exp)) ? \
|
---|
2504 | (DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #_exp),FALSE) : \
|
---|
2505 | TRUE)
|
---|
2506 |
|
---|
2507 | #define RTL_SOFT_ASSERTMSG(_msg, _exp) \
|
---|
2508 | ((!(_exp)) ? \
|
---|
2509 | (DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #_exp, (_msg)),FALSE) : \
|
---|
2510 | TRUE)
|
---|
2511 |
|
---|
2512 | #define RTL_VERIFY ASSERT
|
---|
2513 | #define RTL_VERIFYMSG ASSERTMSG
|
---|
2514 |
|
---|
2515 | #define RTL_SOFT_VERIFY RTL_SOFT_ASSERT
|
---|
2516 | #define RTL_SOFT_VERIFYMSG RTL_SOFT_ASSERTMSG
|
---|
2517 |
|
---|
2518 | #else
|
---|
2519 | #define ASSERT( exp ) ((void) 0)
|
---|
2520 | #define ASSERTMSG( msg, exp ) ((void) 0)
|
---|
2521 |
|
---|
2522 | #define RTL_SOFT_ASSERT(_exp) ((void) 0)
|
---|
2523 | #define RTL_SOFT_ASSERTMSG(_msg, _exp) ((void) 0)
|
---|
2524 |
|
---|
2525 | #define RTL_VERIFY( exp ) ((exp) ? TRUE : FALSE)
|
---|
2526 | #define RTL_VERIFYMSG( msg, exp ) ((exp) ? TRUE : FALSE)
|
---|
2527 |
|
---|
2528 | #define RTL_SOFT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
|
---|
2529 | #define RTL_SOFT_VERIFYMSG(msg, _exp) ((_exp) ? TRUE : FALSE)
|
---|
2530 |
|
---|
2531 | #endif // DBG
|
---|
2532 |
|
---|
2533 | //
|
---|
2534 | // Doubly-linked list manipulation routines.
|
---|
2535 | //
|
---|
2536 |
|
---|
2537 |
|
---|
2538 | //
|
---|
2539 | // VOID
|
---|
2540 | // InitializeListHead32(
|
---|
2541 | // PLIST_ENTRY32 ListHead
|
---|
2542 | // );
|
---|
2543 | //
|
---|
2544 |
|
---|
2545 | #define InitializeListHead32(ListHead) (\
|
---|
2546 | (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
|
---|
2547 |
|
---|
2548 | #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
|
---|
2549 |
|
---|
2550 |
|
---|
2551 | VOID
|
---|
2552 | FORCEINLINE
|
---|
2553 | InitializeListHead(
|
---|
2554 | IN PLIST_ENTRY ListHead
|
---|
2555 | )
|
---|
2556 | {
|
---|
2557 | ListHead->Flink = ListHead->Blink = ListHead;
|
---|
2558 | }
|
---|
2559 |
|
---|
2560 | //
|
---|
2561 | // BOOLEAN
|
---|
2562 | // IsListEmpty(
|
---|
2563 | // PLIST_ENTRY ListHead
|
---|
2564 | // );
|
---|
2565 | //
|
---|
2566 |
|
---|
2567 | #define IsListEmpty(ListHead) \
|
---|
2568 | ((ListHead)->Flink == (ListHead))
|
---|
2569 |
|
---|
2570 |
|
---|
2571 |
|
---|
2572 | BOOLEAN
|
---|
2573 | FORCEINLINE
|
---|
2574 | RemoveEntryList(
|
---|
2575 | IN PLIST_ENTRY Entry
|
---|
2576 | )
|
---|
2577 | {
|
---|
2578 | PLIST_ENTRY Blink;
|
---|
2579 | PLIST_ENTRY Flink;
|
---|
2580 |
|
---|
2581 | Flink = Entry->Flink;
|
---|
2582 | Blink = Entry->Blink;
|
---|
2583 | Blink->Flink = Flink;
|
---|
2584 | Flink->Blink = Blink;
|
---|
2585 | return (BOOLEAN)(Flink == Blink);
|
---|
2586 | }
|
---|
2587 |
|
---|
2588 | PLIST_ENTRY
|
---|
2589 | FORCEINLINE
|
---|
2590 | RemoveHeadList(
|
---|
2591 | IN PLIST_ENTRY ListHead
|
---|
2592 | )
|
---|
2593 | {
|
---|
2594 | PLIST_ENTRY Flink;
|
---|
2595 | PLIST_ENTRY Entry;
|
---|
2596 |
|
---|
2597 | Entry = ListHead->Flink;
|
---|
2598 | Flink = Entry->Flink;
|
---|
2599 | ListHead->Flink = Flink;
|
---|
2600 | Flink->Blink = ListHead;
|
---|
2601 | return Entry;
|
---|
2602 | }
|
---|
2603 |
|
---|
2604 |
|
---|
2605 |
|
---|
2606 | PLIST_ENTRY
|
---|
2607 | FORCEINLINE
|
---|
2608 | RemoveTailList(
|
---|
2609 | IN PLIST_ENTRY ListHead
|
---|
2610 | )
|
---|
2611 | {
|
---|
2612 | PLIST_ENTRY Blink;
|
---|
2613 | PLIST_ENTRY Entry;
|
---|
2614 |
|
---|
2615 | Entry = ListHead->Blink;
|
---|
2616 | Blink = Entry->Blink;
|
---|
2617 | ListHead->Blink = Blink;
|
---|
2618 | Blink->Flink = ListHead;
|
---|
2619 | return Entry;
|
---|
2620 | }
|
---|
2621 |
|
---|
2622 |
|
---|
2623 | VOID
|
---|
2624 | FORCEINLINE
|
---|
2625 | InsertTailList(
|
---|
2626 | IN PLIST_ENTRY ListHead,
|
---|
2627 | IN PLIST_ENTRY Entry
|
---|
2628 | )
|
---|
2629 | {
|
---|
2630 | PLIST_ENTRY Blink;
|
---|
2631 |
|
---|
2632 | Blink = ListHead->Blink;
|
---|
2633 | Entry->Flink = ListHead;
|
---|
2634 | Entry->Blink = Blink;
|
---|
2635 | Blink->Flink = Entry;
|
---|
2636 | ListHead->Blink = Entry;
|
---|
2637 | }
|
---|
2638 |
|
---|
2639 |
|
---|
2640 | VOID
|
---|
2641 | FORCEINLINE
|
---|
2642 | InsertHeadList(
|
---|
2643 | IN PLIST_ENTRY ListHead,
|
---|
2644 | IN PLIST_ENTRY Entry
|
---|
2645 | )
|
---|
2646 | {
|
---|
2647 | PLIST_ENTRY Flink;
|
---|
2648 |
|
---|
2649 | Flink = ListHead->Flink;
|
---|
2650 | Entry->Flink = Flink;
|
---|
2651 | Entry->Blink = ListHead;
|
---|
2652 | Flink->Blink = Entry;
|
---|
2653 | ListHead->Flink = Entry;
|
---|
2654 | }
|
---|
2655 |
|
---|
2656 |
|
---|
2657 | //
|
---|
2658 | //
|
---|
2659 | // PSINGLE_LIST_ENTRY
|
---|
2660 | // PopEntryList(
|
---|
2661 | // PSINGLE_LIST_ENTRY ListHead
|
---|
2662 | // );
|
---|
2663 | //
|
---|
2664 |
|
---|
2665 | #define PopEntryList(ListHead) \
|
---|
2666 | (ListHead)->Next;\
|
---|
2667 | {\
|
---|
2668 | PSINGLE_LIST_ENTRY FirstEntry;\
|
---|
2669 | FirstEntry = (ListHead)->Next;\
|
---|
2670 | if (FirstEntry != NULL) { \
|
---|
2671 | (ListHead)->Next = FirstEntry->Next;\
|
---|
2672 | } \
|
---|
2673 | }
|
---|
2674 |
|
---|
2675 |
|
---|
2676 | //
|
---|
2677 | // VOID
|
---|
2678 | // PushEntryList(
|
---|
2679 | // PSINGLE_LIST_ENTRY ListHead,
|
---|
2680 | // PSINGLE_LIST_ENTRY Entry
|
---|
2681 | // );
|
---|
2682 | //
|
---|
2683 |
|
---|
2684 | #define PushEntryList(ListHead,Entry) \
|
---|
2685 | (Entry)->Next = (ListHead)->Next; \
|
---|
2686 | (ListHead)->Next = (Entry)
|
---|
2687 |
|
---|
2688 | #endif // !MIDL_PASS
|
---|
2689 |
|
---|
2690 |
|
---|
2691 |
|
---|
2692 |
|
---|
2693 |
|
---|
2694 | #if defined (_MSC_VER) && ( _MSC_VER >= 900 )
|
---|
2695 |
|
---|
2696 | PVOID
|
---|
2697 | _ReturnAddress (
|
---|
2698 | VOID
|
---|
2699 | );
|
---|
2700 |
|
---|
2701 | #pragma intrinsic(_ReturnAddress)
|
---|
2702 |
|
---|
2703 | #endif
|
---|
2704 |
|
---|
2705 | #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
|
---|
2706 |
|
---|
2707 | #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
|
---|
2708 | *CallersAddress = (PVOID)_ReturnAddress(); \
|
---|
2709 | *CallersCaller = NULL;
|
---|
2710 |
|
---|
2711 | #else
|
---|
2712 |
|
---|
2713 | NTSYSAPI
|
---|
2714 | VOID
|
---|
2715 | NTAPI
|
---|
2716 | RtlGetCallersAddress(
|
---|
2717 | OUT PVOID *CallersAddress,
|
---|
2718 | OUT PVOID *CallersCaller
|
---|
2719 | );
|
---|
2720 |
|
---|
2721 | #endif
|
---|
2722 |
|
---|
2723 | NTSYSAPI
|
---|
2724 | ULONG
|
---|
2725 | NTAPI
|
---|
2726 | RtlWalkFrameChain (
|
---|
2727 | OUT PVOID *Callers,
|
---|
2728 | IN ULONG Count,
|
---|
2729 | IN ULONG Flags
|
---|
2730 | );
|
---|
2731 |
|
---|
2732 | //
|
---|
2733 | // Subroutines for dealing with the Registry
|
---|
2734 | //
|
---|
2735 |
|
---|
2736 | typedef NTSTATUS (NTAPI * PRTL_QUERY_REGISTRY_ROUTINE)(
|
---|
2737 | IN PWSTR ValueName,
|
---|
2738 | IN ULONG ValueType,
|
---|
2739 | IN PVOID ValueData,
|
---|
2740 | IN ULONG ValueLength,
|
---|
2741 | IN PVOID Context,
|
---|
2742 | IN PVOID EntryContext
|
---|
2743 | );
|
---|
2744 |
|
---|
2745 | typedef struct _RTL_QUERY_REGISTRY_TABLE {
|
---|
2746 | PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
|
---|
2747 | ULONG Flags;
|
---|
2748 | PWSTR Name;
|
---|
2749 | PVOID EntryContext;
|
---|
2750 | ULONG DefaultType;
|
---|
2751 | PVOID DefaultData;
|
---|
2752 | ULONG DefaultLength;
|
---|
2753 |
|
---|
2754 | } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
|
---|
2755 |
|
---|
2756 |
|
---|
2757 | //
|
---|
2758 | // The following flags specify how the Name field of a RTL_QUERY_REGISTRY_TABLE
|
---|
2759 | // entry is interpreted. A NULL name indicates the end of the table.
|
---|
2760 | //
|
---|
2761 |
|
---|
2762 | #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001 // Name is a subkey and remainder of
|
---|
2763 | // table or until next subkey are value
|
---|
2764 | // names for that subkey to look at.
|
---|
2765 |
|
---|
2766 | #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002 // Reset current key to original key for
|
---|
2767 | // this and all following table entries.
|
---|
2768 |
|
---|
2769 | #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004 // Fail if no match found for this table
|
---|
2770 | // entry.
|
---|
2771 |
|
---|
2772 | #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008 // Used to mark a table entry that has no
|
---|
2773 | // value name, just wants a call out, not
|
---|
2774 | // an enumeration of all values.
|
---|
2775 |
|
---|
2776 | #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010 // Used to suppress the expansion of
|
---|
2777 | // REG_MULTI_SZ into multiple callouts or
|
---|
2778 | // to prevent the expansion of environment
|
---|
2779 | // variable values in REG_EXPAND_SZ
|
---|
2780 |
|
---|
2781 | #define RTL_QUERY_REGISTRY_DIRECT 0x00000020 // QueryRoutine field ignored. EntryContext
|
---|
2782 | // field points to location to store value.
|
---|
2783 | // For null terminated strings, EntryContext
|
---|
2784 | // points to UNICODE_STRING structure that
|
---|
2785 | // that describes maximum size of buffer.
|
---|
2786 | // If .Buffer field is NULL then a buffer is
|
---|
2787 | // allocated.
|
---|
2788 | //
|
---|
2789 |
|
---|
2790 | #define RTL_QUERY_REGISTRY_DELETE 0x00000040 // Used to delete value keys after they
|
---|
2791 | // are queried.
|
---|
2792 |
|
---|
2793 | NTSYSAPI
|
---|
2794 | NTSTATUS
|
---|
2795 | NTAPI
|
---|
2796 | RtlQueryRegistryValues(
|
---|
2797 | IN ULONG RelativeTo,
|
---|
2798 | IN PCWSTR Path,
|
---|
2799 | IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
|
---|
2800 | IN PVOID Context,
|
---|
2801 | IN PVOID Environment OPTIONAL
|
---|
2802 | );
|
---|
2803 |
|
---|
2804 | NTSYSAPI
|
---|
2805 | NTSTATUS
|
---|
2806 | NTAPI
|
---|
2807 | RtlWriteRegistryValue(
|
---|
2808 | IN ULONG RelativeTo,
|
---|
2809 | IN PCWSTR Path,
|
---|
2810 | IN PCWSTR ValueName,
|
---|
2811 | IN ULONG ValueType,
|
---|
2812 | IN PVOID ValueData,
|
---|
2813 | IN ULONG ValueLength
|
---|
2814 | );
|
---|
2815 |
|
---|
2816 | NTSYSAPI
|
---|
2817 | NTSTATUS
|
---|
2818 | NTAPI
|
---|
2819 | RtlDeleteRegistryValue(
|
---|
2820 | IN ULONG RelativeTo,
|
---|
2821 | IN PCWSTR Path,
|
---|
2822 | IN PCWSTR ValueName
|
---|
2823 | );
|
---|
2824 |
|
---|
2825 |
|
---|
2826 |
|
---|
2827 | NTSYSAPI
|
---|
2828 | NTSTATUS
|
---|
2829 | NTAPI
|
---|
2830 | RtlCreateRegistryKey(
|
---|
2831 | IN ULONG RelativeTo,
|
---|
2832 | IN PWSTR Path
|
---|
2833 | );
|
---|
2834 |
|
---|
2835 | NTSYSAPI
|
---|
2836 | NTSTATUS
|
---|
2837 | NTAPI
|
---|
2838 | RtlCheckRegistryKey(
|
---|
2839 | IN ULONG RelativeTo,
|
---|
2840 | IN PWSTR Path
|
---|
2841 | );
|
---|
2842 |
|
---|
2843 |
|
---|
2844 | //
|
---|
2845 | // The following values for the RelativeTo parameter determine what the
|
---|
2846 | // Path parameter to RtlQueryRegistryValues is relative to.
|
---|
2847 | //
|
---|
2848 |
|
---|
2849 | #define RTL_REGISTRY_ABSOLUTE 0 // Path is a full path
|
---|
2850 | #define RTL_REGISTRY_SERVICES 1 // \Registry\Machine\System\CurrentControlSet\Services
|
---|
2851 | #define RTL_REGISTRY_CONTROL 2 // \Registry\Machine\System\CurrentControlSet\Control
|
---|
2852 | #define RTL_REGISTRY_WINDOWS_NT 3 // \Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion
|
---|
2853 | #define RTL_REGISTRY_DEVICEMAP 4 // \Registry\Machine\Hardware\DeviceMap
|
---|
2854 | #define RTL_REGISTRY_USER 5 // \Registry\User\CurrentUser
|
---|
2855 | #define RTL_REGISTRY_MAXIMUM 6
|
---|
2856 | #define RTL_REGISTRY_HANDLE 0x40000000 // Low order bits are registry handle
|
---|
2857 | #define RTL_REGISTRY_OPTIONAL 0x80000000 // Indicates the key node is optional
|
---|
2858 |
|
---|
2859 | NTSYSAPI
|
---|
2860 | NTSTATUS
|
---|
2861 | NTAPI
|
---|
2862 | RtlCharToInteger (
|
---|
2863 | PCSZ String,
|
---|
2864 | ULONG Base,
|
---|
2865 | PULONG Value
|
---|
2866 | );
|
---|
2867 |
|
---|
2868 | NTSYSAPI
|
---|
2869 | NTSTATUS
|
---|
2870 | NTAPI
|
---|
2871 | RtlIntegerToUnicodeString (
|
---|
2872 | ULONG Value,
|
---|
2873 | ULONG Base,
|
---|
2874 | PUNICODE_STRING String
|
---|
2875 | );
|
---|
2876 |
|
---|
2877 | NTSYSAPI
|
---|
2878 | NTSTATUS
|
---|
2879 | NTAPI
|
---|
2880 | RtlInt64ToUnicodeString (
|
---|
2881 | IN ULONGLONG Value,
|
---|
2882 | IN ULONG Base OPTIONAL,
|
---|
2883 | IN OUT PUNICODE_STRING String
|
---|
2884 | );
|
---|
2885 |
|
---|
2886 | #ifdef _WIN64
|
---|
2887 | #define RtlIntPtrToUnicodeString(Value, Base, String) RtlInt64ToUnicodeString(Value, Base, String)
|
---|
2888 | #else
|
---|
2889 | #define RtlIntPtrToUnicodeString(Value, Base, String) RtlIntegerToUnicodeString(Value, Base, String)
|
---|
2890 | #endif
|
---|
2891 |
|
---|
2892 | NTSYSAPI
|
---|
2893 | NTSTATUS
|
---|
2894 | NTAPI
|
---|
2895 | RtlUnicodeStringToInteger (
|
---|
2896 | PCUNICODE_STRING String,
|
---|
2897 | ULONG Base,
|
---|
2898 | PULONG Value
|
---|
2899 | );
|
---|
2900 |
|
---|
2901 | |
---|
2902 |
|
---|
2903 | //
|
---|
2904 | // String manipulation routines
|
---|
2905 | //
|
---|
2906 |
|
---|
2907 | #ifdef _NTSYSTEM_
|
---|
2908 |
|
---|
2909 | #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
|
---|
2910 | #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
|
---|
2911 |
|
---|
2912 | #else
|
---|
2913 |
|
---|
2914 | #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
|
---|
2915 | #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
|
---|
2916 |
|
---|
2917 | #endif // _NTSYSTEM_
|
---|
2918 |
|
---|
2919 | extern BOOLEAN NLS_MB_CODE_PAGE_TAG; // TRUE -> Multibyte CP, FALSE -> Singlebyte
|
---|
2920 | extern BOOLEAN NLS_MB_OEM_CODE_PAGE_TAG; // TRUE -> Multibyte CP, FALSE -> Singlebyte
|
---|
2921 |
|
---|
2922 | NTSYSAPI
|
---|
2923 | VOID
|
---|
2924 | NTAPI
|
---|
2925 | RtlInitString(
|
---|
2926 | PSTRING DestinationString,
|
---|
2927 | PCSZ SourceString
|
---|
2928 | );
|
---|
2929 |
|
---|
2930 | NTSYSAPI
|
---|
2931 | VOID
|
---|
2932 | NTAPI
|
---|
2933 | RtlInitAnsiString(
|
---|
2934 | PANSI_STRING DestinationString,
|
---|
2935 | PCSZ SourceString
|
---|
2936 | );
|
---|
2937 |
|
---|
2938 | NTSYSAPI
|
---|
2939 | VOID
|
---|
2940 | NTAPI
|
---|
2941 | RtlInitUnicodeString(
|
---|
2942 | PUNICODE_STRING DestinationString,
|
---|
2943 | PCWSTR SourceString
|
---|
2944 | );
|
---|
2945 |
|
---|
2946 | #define RtlInitEmptyUnicodeString(_ucStr,_buf,_bufSize) \
|
---|
2947 | ((_ucStr)->Buffer = (_buf), \
|
---|
2948 | (_ucStr)->Length = 0, \
|
---|
2949 | (_ucStr)->MaximumLength = (USHORT)(_bufSize))
|
---|
2950 |
|
---|
2951 |
|
---|
2952 | NTSYSAPI
|
---|
2953 | VOID
|
---|
2954 | NTAPI
|
---|
2955 | RtlCopyString(
|
---|
2956 | PSTRING DestinationString,
|
---|
2957 | const STRING * SourceString
|
---|
2958 | );
|
---|
2959 |
|
---|
2960 | NTSYSAPI
|
---|
2961 | CHAR
|
---|
2962 | NTAPI
|
---|
2963 | RtlUpperChar (
|
---|
2964 | CHAR Character
|
---|
2965 | );
|
---|
2966 |
|
---|
2967 | NTSYSAPI
|
---|
2968 | LONG
|
---|
2969 | NTAPI
|
---|
2970 | RtlCompareString(
|
---|
2971 | const STRING * String1,
|
---|
2972 | const STRING * String2,
|
---|
2973 | BOOLEAN CaseInSensitive
|
---|
2974 | );
|
---|
2975 |
|
---|
2976 | NTSYSAPI
|
---|
2977 | BOOLEAN
|
---|
2978 | NTAPI
|
---|
2979 | RtlEqualString(
|
---|
2980 | const STRING * String1,
|
---|
2981 | const STRING * String2,
|
---|
2982 | BOOLEAN CaseInSensitive
|
---|
2983 | );
|
---|
2984 |
|
---|
2985 |
|
---|
2986 | NTSYSAPI
|
---|
2987 | VOID
|
---|
2988 | NTAPI
|
---|
2989 | RtlUpperString(
|
---|
2990 | PSTRING DestinationString,
|
---|
2991 | const STRING * SourceString
|
---|
2992 | );
|
---|
2993 |
|
---|
2994 | //
|
---|
2995 | // NLS String functions
|
---|
2996 | //
|
---|
2997 |
|
---|
2998 | NTSYSAPI
|
---|
2999 | NTSTATUS
|
---|
3000 | NTAPI
|
---|
3001 | RtlAnsiStringToUnicodeString(
|
---|
3002 | PUNICODE_STRING DestinationString,
|
---|
3003 | PCANSI_STRING SourceString,
|
---|
3004 | BOOLEAN AllocateDestinationString
|
---|
3005 | );
|
---|
3006 |
|
---|
3007 |
|
---|
3008 | NTSYSAPI
|
---|
3009 | NTSTATUS
|
---|
3010 | NTAPI
|
---|
3011 | RtlUnicodeStringToAnsiString(
|
---|
3012 | PANSI_STRING DestinationString,
|
---|
3013 | PCUNICODE_STRING SourceString,
|
---|
3014 | BOOLEAN AllocateDestinationString
|
---|
3015 | );
|
---|
3016 |
|
---|
3017 |
|
---|
3018 | NTSYSAPI
|
---|
3019 | LONG
|
---|
3020 | NTAPI
|
---|
3021 | RtlCompareUnicodeString(
|
---|
3022 | PCUNICODE_STRING String1,
|
---|
3023 | PCUNICODE_STRING String2,
|
---|
3024 | BOOLEAN CaseInSensitive
|
---|
3025 | );
|
---|
3026 |
|
---|
3027 | NTSYSAPI
|
---|
3028 | BOOLEAN
|
---|
3029 | NTAPI
|
---|
3030 | RtlEqualUnicodeString(
|
---|
3031 | PCUNICODE_STRING String1,
|
---|
3032 | PCUNICODE_STRING String2,
|
---|
3033 | BOOLEAN CaseInSensitive
|
---|
3034 | );
|
---|
3035 |
|
---|
3036 | #define HASH_STRING_ALGORITHM_DEFAULT (0)
|
---|
3037 | #define HASH_STRING_ALGORITHM_X65599 (1)
|
---|
3038 | #define HASH_STRING_ALGORITHM_INVALID (0xffffffff)
|
---|
3039 |
|
---|
3040 | NTSYSAPI
|
---|
3041 | NTSTATUS
|
---|
3042 | NTAPI
|
---|
3043 | RtlHashUnicodeString(
|
---|
3044 | IN const UNICODE_STRING *String,
|
---|
3045 | IN BOOLEAN CaseInSensitive,
|
---|
3046 | IN ULONG HashAlgorithm,
|
---|
3047 | OUT PULONG HashValue
|
---|
3048 | );
|
---|
3049 |
|
---|
3050 |
|
---|
3051 | NTSYSAPI
|
---|
3052 | BOOLEAN
|
---|
3053 | NTAPI
|
---|
3054 | RtlPrefixUnicodeString(
|
---|
3055 | IN PCUNICODE_STRING String1,
|
---|
3056 | IN PCUNICODE_STRING String2,
|
---|
3057 | IN BOOLEAN CaseInSensitive
|
---|
3058 | );
|
---|
3059 |
|
---|
3060 | NTSYSAPI
|
---|
3061 | NTSTATUS
|
---|
3062 | NTAPI
|
---|
3063 | RtlUpcaseUnicodeString(
|
---|
3064 | PUNICODE_STRING DestinationString,
|
---|
3065 | PCUNICODE_STRING SourceString,
|
---|
3066 | BOOLEAN AllocateDestinationString
|
---|
3067 | );
|
---|
3068 |
|
---|
3069 |
|
---|
3070 | NTSYSAPI
|
---|
3071 | VOID
|
---|
3072 | NTAPI
|
---|
3073 | RtlCopyUnicodeString(
|
---|
3074 | PUNICODE_STRING DestinationString,
|
---|
3075 | PCUNICODE_STRING SourceString
|
---|
3076 | );
|
---|
3077 |
|
---|
3078 | NTSYSAPI
|
---|
3079 | NTSTATUS
|
---|
3080 | NTAPI
|
---|
3081 | RtlAppendUnicodeStringToString (
|
---|
3082 | PUNICODE_STRING Destination,
|
---|
3083 | PCUNICODE_STRING Source
|
---|
3084 | );
|
---|
3085 |
|
---|
3086 | NTSYSAPI
|
---|
3087 | NTSTATUS
|
---|
3088 | NTAPI
|
---|
3089 | RtlAppendUnicodeToString (
|
---|
3090 | PUNICODE_STRING Destination,
|
---|
3091 | PCWSTR Source
|
---|
3092 | );
|
---|
3093 |
|
---|
3094 |
|
---|
3095 |
|
---|
3096 | NTSYSAPI
|
---|
3097 | WCHAR
|
---|
3098 | NTAPI
|
---|
3099 | RtlUpcaseUnicodeChar(
|
---|
3100 | WCHAR SourceCharacter
|
---|
3101 | );
|
---|
3102 |
|
---|
3103 | NTSYSAPI
|
---|
3104 | WCHAR
|
---|
3105 | NTAPI
|
---|
3106 | RtlDowncaseUnicodeChar(
|
---|
3107 | WCHAR SourceCharacter
|
---|
3108 | );
|
---|
3109 |
|
---|
3110 |
|
---|
3111 |
|
---|
3112 | NTSYSAPI
|
---|
3113 | VOID
|
---|
3114 | NTAPI
|
---|
3115 | RtlFreeUnicodeString(
|
---|
3116 | PUNICODE_STRING UnicodeString
|
---|
3117 | );
|
---|
3118 |
|
---|
3119 | NTSYSAPI
|
---|
3120 | VOID
|
---|
3121 | NTAPI
|
---|
3122 | RtlFreeAnsiString(
|
---|
3123 | PANSI_STRING AnsiString
|
---|
3124 | );
|
---|
3125 |
|
---|
3126 |
|
---|
3127 | NTSYSAPI
|
---|
3128 | ULONG
|
---|
3129 | NTAPI
|
---|
3130 | RtlxAnsiStringToUnicodeSize(
|
---|
3131 | PCANSI_STRING AnsiString
|
---|
3132 | );
|
---|
3133 |
|
---|
3134 | //
|
---|
3135 | // NTSYSAPI
|
---|
3136 | // ULONG
|
---|
3137 | // NTAPI
|
---|
3138 | // RtlAnsiStringToUnicodeSize(
|
---|
3139 | // PANSI_STRING AnsiString
|
---|
3140 | // );
|
---|
3141 | //
|
---|
3142 |
|
---|
3143 | #define RtlAnsiStringToUnicodeSize(STRING) ( \
|
---|
3144 | NLS_MB_CODE_PAGE_TAG ? \
|
---|
3145 | RtlxAnsiStringToUnicodeSize(STRING) : \
|
---|
3146 | ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
|
---|
3147 | )
|
---|
3148 |
|
---|
3149 |
|
---|
3150 |
|
---|
3151 |
|
---|
3152 | #include <guiddef.h>
|
---|
3153 |
|
---|
3154 |
|
---|
3155 |
|
---|
3156 | #ifndef DEFINE_GUIDEX
|
---|
3157 | #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
|
---|
3158 | #endif // !defined(DEFINE_GUIDEX)
|
---|
3159 |
|
---|
3160 | #ifndef STATICGUIDOF
|
---|
3161 | #define STATICGUIDOF(guid) STATIC_##guid
|
---|
3162 | #endif // !defined(STATICGUIDOF)
|
---|
3163 |
|
---|
3164 | #ifndef __IID_ALIGNED__
|
---|
3165 | #define __IID_ALIGNED__
|
---|
3166 | #ifdef __cplusplus
|
---|
3167 | inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
|
---|
3168 | {
|
---|
3169 | return ((*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)));
|
---|
3170 | }
|
---|
3171 | #else // !__cplusplus
|
---|
3172 | #define IsEqualGUIDAligned(guid1, guid2) \
|
---|
3173 | ((*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)))
|
---|
3174 | #endif // !__cplusplus
|
---|
3175 | #endif // !__IID_ALIGNED__
|
---|
3176 |
|
---|
3177 | NTSYSAPI
|
---|
3178 | NTSTATUS
|
---|
3179 | NTAPI
|
---|
3180 | RtlStringFromGUID(
|
---|
3181 | IN REFGUID Guid,
|
---|
3182 | OUT PUNICODE_STRING GuidString
|
---|
3183 | );
|
---|
3184 |
|
---|
3185 | NTSYSAPI
|
---|
3186 | NTSTATUS
|
---|
3187 | NTAPI
|
---|
3188 | RtlGUIDFromString(
|
---|
3189 | IN PUNICODE_STRING GuidString,
|
---|
3190 | OUT GUID* Guid
|
---|
3191 | );
|
---|
3192 |
|
---|
3193 | //
|
---|
3194 | // Fast primitives to compare, move, and zero memory
|
---|
3195 | //
|
---|
3196 |
|
---|
3197 |
|
---|
3198 |
|
---|
3199 | NTSYSAPI
|
---|
3200 | SIZE_T
|
---|
3201 | NTAPI
|
---|
3202 | RtlCompareMemory (
|
---|
3203 | const VOID *Source1,
|
---|
3204 | const VOID *Source2,
|
---|
3205 | SIZE_T Length
|
---|
3206 | );
|
---|
3207 |
|
---|
3208 | #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
|
---|
3209 |
|
---|
3210 | #if defined(_M_AMD64)
|
---|
3211 |
|
---|
3212 | NTSYSAPI
|
---|
3213 | VOID
|
---|
3214 | NTAPI
|
---|
3215 | RtlCopyMemory (
|
---|
3216 | VOID UNALIGNED *Destination,
|
---|
3217 | CONST VOID UNALIGNED *Source,
|
---|
3218 | SIZE_T Length
|
---|
3219 | );
|
---|
3220 |
|
---|
3221 | NTSYSAPI
|
---|
3222 | VOID
|
---|
3223 | NTAPI
|
---|
3224 | RtlMoveMemory (
|
---|
3225 | VOID UNALIGNED *Destination,
|
---|
3226 | CONST VOID UNALIGNED *Source,
|
---|
3227 | SIZE_T Length
|
---|
3228 | );
|
---|
3229 |
|
---|
3230 | NTSYSAPI
|
---|
3231 | VOID
|
---|
3232 | NTAPI
|
---|
3233 | RtlFillMemory (
|
---|
3234 | VOID UNALIGNED *Destination,
|
---|
3235 | SIZE_T Length,
|
---|
3236 | IN UCHAR Fill
|
---|
3237 | );
|
---|
3238 |
|
---|
3239 | NTSYSAPI
|
---|
3240 | VOID
|
---|
3241 | NTAPI
|
---|
3242 | RtlZeroMemory (
|
---|
3243 | VOID UNALIGNED *Destination,
|
---|
3244 | SIZE_T Length
|
---|
3245 | );
|
---|
3246 |
|
---|
3247 | #else
|
---|
3248 |
|
---|
3249 | #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
|
---|
3250 | #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
|
---|
3251 | #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
|
---|
3252 | #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
|
---|
3253 |
|
---|
3254 | #endif
|
---|
3255 |
|
---|
3256 | #if !defined(MIDL_PASS)
|
---|
3257 | FORCEINLINE
|
---|
3258 | PVOID
|
---|
3259 | RtlSecureZeroMemory(
|
---|
3260 | IN PVOID ptr,
|
---|
3261 | IN SIZE_T cnt
|
---|
3262 | )
|
---|
3263 | {
|
---|
3264 | volatile char *vptr = (volatile char *)ptr;
|
---|
3265 | while (cnt) {
|
---|
3266 | *vptr = 0;
|
---|
3267 | vptr++;
|
---|
3268 | cnt--;
|
---|
3269 | }
|
---|
3270 | return ptr;
|
---|
3271 | }
|
---|
3272 | #endif
|
---|
3273 |
|
---|
3274 |
|
---|
3275 |
|
---|
3276 | #define RtlCopyBytes RtlCopyMemory
|
---|
3277 | #define RtlZeroBytes RtlZeroMemory
|
---|
3278 | #define RtlFillBytes RtlFillMemory
|
---|
3279 |
|
---|
3280 | #if defined(_M_AMD64)
|
---|
3281 |
|
---|
3282 | NTSYSAPI
|
---|
3283 | VOID
|
---|
3284 | NTAPI
|
---|
3285 | RtlCopyMemoryNonTemporal (
|
---|
3286 | VOID UNALIGNED *Destination,
|
---|
3287 | CONST VOID UNALIGNED *Source,
|
---|
3288 | SIZE_T Length
|
---|
3289 | );
|
---|
3290 |
|
---|
3291 | #else
|
---|
3292 |
|
---|
3293 | #define RtlCopyMemoryNonTemporal RtlCopyMemory
|
---|
3294 |
|
---|
3295 | #endif
|
---|
3296 |
|
---|
3297 | NTSYSAPI
|
---|
3298 | VOID
|
---|
3299 | FASTCALL
|
---|
3300 | RtlPrefetchMemoryNonTemporal(
|
---|
3301 | IN PVOID Source,
|
---|
3302 | IN SIZE_T Length
|
---|
3303 | );
|
---|
3304 |
|
---|
3305 | //
|
---|
3306 | // Define kernel debugger print prototypes and macros.
|
---|
3307 | //
|
---|
3308 | // N.B. The following function cannot be directly imported because there are
|
---|
3309 | // a few places in the source tree where this function is redefined.
|
---|
3310 | //
|
---|
3311 |
|
---|
3312 | VOID
|
---|
3313 | NTAPI
|
---|
3314 | DbgBreakPoint(
|
---|
3315 | VOID
|
---|
3316 | );
|
---|
3317 |
|
---|
3318 |
|
---|
3319 |
|
---|
3320 | NTSYSAPI
|
---|
3321 | VOID
|
---|
3322 | NTAPI
|
---|
3323 | DbgBreakPointWithStatus(
|
---|
3324 | IN ULONG Status
|
---|
3325 | );
|
---|
3326 |
|
---|
3327 |
|
---|
3328 |
|
---|
3329 | #define DBG_STATUS_CONTROL_C 1
|
---|
3330 | #define DBG_STATUS_SYSRQ 2
|
---|
3331 | #define DBG_STATUS_BUGCHECK_FIRST 3
|
---|
3332 | #define DBG_STATUS_BUGCHECK_SECOND 4
|
---|
3333 | #define DBG_STATUS_FATAL 5
|
---|
3334 | #define DBG_STATUS_DEBUG_CONTROL 6
|
---|
3335 | #define DBG_STATUS_WORKER 7
|
---|
3336 |
|
---|
3337 | #if DBG
|
---|
3338 |
|
---|
3339 | #define KdPrint(_x_) DbgPrint _x_
|
---|
3340 |
|
---|
3341 | #define KdPrintEx(_x_) DbgPrintEx _x_
|
---|
3342 | #define vKdPrintEx(_x_) vDbgPrintEx _x_
|
---|
3343 | #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_
|
---|
3344 |
|
---|
3345 | #define KdBreakPoint() DbgBreakPoint()
|
---|
3346 |
|
---|
3347 |
|
---|
3348 |
|
---|
3349 | #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s)
|
---|
3350 |
|
---|
3351 |
|
---|
3352 |
|
---|
3353 | #else
|
---|
3354 |
|
---|
3355 | #define KdPrint(_x_)
|
---|
3356 |
|
---|
3357 | #define KdPrintEx(_x_)
|
---|
3358 | #define vKdPrintEx(_x_)
|
---|
3359 | #define vKdPrintExWithPrefix(_x_)
|
---|
3360 |
|
---|
3361 | #define KdBreakPoint()
|
---|
3362 |
|
---|
3363 |
|
---|
3364 |
|
---|
3365 | #define KdBreakPointWithStatus(s)
|
---|
3366 |
|
---|
3367 |
|
---|
3368 |
|
---|
3369 | #endif
|
---|
3370 |
|
---|
3371 | #ifndef _DBGNT_
|
---|
3372 |
|
---|
3373 | ULONG
|
---|
3374 | __cdecl
|
---|
3375 | DbgPrint(
|
---|
3376 | PCH Format,
|
---|
3377 | ...
|
---|
3378 | );
|
---|
3379 |
|
---|
3380 |
|
---|
3381 |
|
---|
3382 | ULONG
|
---|
3383 | __cdecl
|
---|
3384 | DbgPrintEx(
|
---|
3385 | IN ULONG ComponentId,
|
---|
3386 | IN ULONG Level,
|
---|
3387 | IN PCH Format,
|
---|
3388 | ...
|
---|
3389 | );
|
---|
3390 |
|
---|
3391 | #ifdef _VA_LIST_DEFINED
|
---|
3392 |
|
---|
3393 | ULONG
|
---|
3394 | vDbgPrintEx(
|
---|
3395 | IN ULONG ComponentId,
|
---|
3396 | IN ULONG Level,
|
---|
3397 | IN PCH Format,
|
---|
3398 | va_list arglist
|
---|
3399 | );
|
---|
3400 |
|
---|
3401 | ULONG
|
---|
3402 | vDbgPrintExWithPrefix(
|
---|
3403 | IN PCH Prefix,
|
---|
3404 | IN ULONG ComponentId,
|
---|
3405 | IN ULONG Level,
|
---|
3406 | IN PCH Format,
|
---|
3407 | va_list arglist
|
---|
3408 | );
|
---|
3409 |
|
---|
3410 | #endif
|
---|
3411 |
|
---|
3412 | ULONG
|
---|
3413 | __cdecl
|
---|
3414 | DbgPrintReturnControlC(
|
---|
3415 | PCH Format,
|
---|
3416 | ...
|
---|
3417 | );
|
---|
3418 |
|
---|
3419 | NTSYSAPI
|
---|
3420 | NTSTATUS
|
---|
3421 | DbgQueryDebugFilterState(
|
---|
3422 | IN ULONG ComponentId,
|
---|
3423 | IN ULONG Level
|
---|
3424 | );
|
---|
3425 |
|
---|
3426 | NTSYSAPI
|
---|
3427 | NTSTATUS
|
---|
3428 | DbgSetDebugFilterState(
|
---|
3429 | IN ULONG ComponentId,
|
---|
3430 | IN ULONG Level,
|
---|
3431 | IN BOOLEAN State
|
---|
3432 | );
|
---|
3433 |
|
---|
3434 |
|
---|
3435 |
|
---|
3436 | #endif // _DBGNT_
|
---|
3437 |
|
---|
3438 | //
|
---|
3439 | // Large integer arithmetic routines.
|
---|
3440 | //
|
---|
3441 |
|
---|
3442 | //
|
---|
3443 | // Large integer add - 64-bits + 64-bits -> 64-bits
|
---|
3444 | //
|
---|
3445 |
|
---|
3446 | #if !defined(MIDL_PASS)
|
---|
3447 |
|
---|
3448 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3449 | __inline
|
---|
3450 | LARGE_INTEGER
|
---|
3451 | NTAPI
|
---|
3452 | RtlLargeIntegerAdd (
|
---|
3453 | LARGE_INTEGER Addend1,
|
---|
3454 | LARGE_INTEGER Addend2
|
---|
3455 | )
|
---|
3456 | {
|
---|
3457 | LARGE_INTEGER Sum;
|
---|
3458 |
|
---|
3459 | Sum.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
|
---|
3460 | return Sum;
|
---|
3461 | }
|
---|
3462 |
|
---|
3463 | //
|
---|
3464 | // Enlarged integer multiply - 32-bits * 32-bits -> 64-bits
|
---|
3465 | //
|
---|
3466 |
|
---|
3467 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3468 | __inline
|
---|
3469 | LARGE_INTEGER
|
---|
3470 | NTAPI
|
---|
3471 | RtlEnlargedIntegerMultiply (
|
---|
3472 | LONG Multiplicand,
|
---|
3473 | LONG Multiplier
|
---|
3474 | )
|
---|
3475 | {
|
---|
3476 | LARGE_INTEGER Product;
|
---|
3477 |
|
---|
3478 | Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
|
---|
3479 | return Product;
|
---|
3480 | }
|
---|
3481 |
|
---|
3482 | //
|
---|
3483 | // Unsigned enlarged integer multiply - 32-bits * 32-bits -> 64-bits
|
---|
3484 | //
|
---|
3485 |
|
---|
3486 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3487 | __inline
|
---|
3488 | LARGE_INTEGER
|
---|
3489 | NTAPI
|
---|
3490 | RtlEnlargedUnsignedMultiply (
|
---|
3491 | ULONG Multiplicand,
|
---|
3492 | ULONG Multiplier
|
---|
3493 | )
|
---|
3494 | {
|
---|
3495 | LARGE_INTEGER Product;
|
---|
3496 |
|
---|
3497 | Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
|
---|
3498 | return Product;
|
---|
3499 | }
|
---|
3500 |
|
---|
3501 | //
|
---|
3502 | // Enlarged integer divide - 64-bits / 32-bits > 32-bits
|
---|
3503 | //
|
---|
3504 |
|
---|
3505 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3506 | __inline
|
---|
3507 | ULONG
|
---|
3508 | NTAPI
|
---|
3509 | RtlEnlargedUnsignedDivide (
|
---|
3510 | IN ULARGE_INTEGER Dividend,
|
---|
3511 | IN ULONG Divisor,
|
---|
3512 | IN PULONG Remainder OPTIONAL
|
---|
3513 | )
|
---|
3514 | {
|
---|
3515 | ULONG Quotient;
|
---|
3516 |
|
---|
3517 | Quotient = (ULONG)(Dividend.QuadPart / Divisor);
|
---|
3518 | if (ARGUMENT_PRESENT(Remainder)) {
|
---|
3519 | *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
|
---|
3520 | }
|
---|
3521 |
|
---|
3522 | return Quotient;
|
---|
3523 | }
|
---|
3524 |
|
---|
3525 | //
|
---|
3526 | // Large integer negation - -(64-bits)
|
---|
3527 | //
|
---|
3528 |
|
---|
3529 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3530 | __inline
|
---|
3531 | LARGE_INTEGER
|
---|
3532 | NTAPI
|
---|
3533 | RtlLargeIntegerNegate (
|
---|
3534 | LARGE_INTEGER Subtrahend
|
---|
3535 | )
|
---|
3536 | {
|
---|
3537 | LARGE_INTEGER Difference;
|
---|
3538 |
|
---|
3539 | Difference.QuadPart = -Subtrahend.QuadPart;
|
---|
3540 | return Difference;
|
---|
3541 | }
|
---|
3542 |
|
---|
3543 | //
|
---|
3544 | // Large integer subtract - 64-bits - 64-bits -> 64-bits.
|
---|
3545 | //
|
---|
3546 |
|
---|
3547 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3548 | __inline
|
---|
3549 | LARGE_INTEGER
|
---|
3550 | NTAPI
|
---|
3551 | RtlLargeIntegerSubtract (
|
---|
3552 | LARGE_INTEGER Minuend,
|
---|
3553 | LARGE_INTEGER Subtrahend
|
---|
3554 | )
|
---|
3555 | {
|
---|
3556 | LARGE_INTEGER Difference;
|
---|
3557 |
|
---|
3558 | Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart;
|
---|
3559 | return Difference;
|
---|
3560 | }
|
---|
3561 |
|
---|
3562 | //
|
---|
3563 | // Extended large integer magic divide - 64-bits / 32-bits -> 64-bits
|
---|
3564 | //
|
---|
3565 |
|
---|
3566 | #if defined(_AMD64_)
|
---|
3567 |
|
---|
3568 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3569 | __inline
|
---|
3570 | LARGE_INTEGER
|
---|
3571 | NTAPI
|
---|
3572 | RtlExtendedMagicDivide (
|
---|
3573 | LARGE_INTEGER Dividend,
|
---|
3574 | LARGE_INTEGER MagicDivisor,
|
---|
3575 | CCHAR ShiftCount
|
---|
3576 | )
|
---|
3577 |
|
---|
3578 | {
|
---|
3579 |
|
---|
3580 | LARGE_INTEGER Quotient;
|
---|
3581 |
|
---|
3582 | if (Dividend.QuadPart >= 0) {
|
---|
3583 | Quotient.QuadPart = UnsignedMultiplyHigh(Dividend.QuadPart,
|
---|
3584 | (ULONG64)MagicDivisor.QuadPart);
|
---|
3585 |
|
---|
3586 | } else {
|
---|
3587 | Quotient.QuadPart = UnsignedMultiplyHigh(-Dividend.QuadPart,
|
---|
3588 | (ULONG64)MagicDivisor.QuadPart);
|
---|
3589 | }
|
---|
3590 |
|
---|
3591 | Quotient.QuadPart = (ULONG64)Quotient.QuadPart >> ShiftCount;
|
---|
3592 | if (Dividend.QuadPart < 0) {
|
---|
3593 | Quotient.QuadPart = - Quotient.QuadPart;
|
---|
3594 | }
|
---|
3595 |
|
---|
3596 | return Quotient;
|
---|
3597 | }
|
---|
3598 |
|
---|
3599 | #endif // defined(_AMD64_)
|
---|
3600 |
|
---|
3601 | #if defined(_X86_) || defined(_IA64_)
|
---|
3602 |
|
---|
3603 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3604 | NTSYSAPI
|
---|
3605 | LARGE_INTEGER
|
---|
3606 | NTAPI
|
---|
3607 | RtlExtendedMagicDivide (
|
---|
3608 | LARGE_INTEGER Dividend,
|
---|
3609 | LARGE_INTEGER MagicDivisor,
|
---|
3610 | CCHAR ShiftCount
|
---|
3611 | );
|
---|
3612 |
|
---|
3613 | #endif // defined(_X86_) || defined(_IA64_)
|
---|
3614 |
|
---|
3615 | #if defined(_AMD64_) || defined(_IA64_)
|
---|
3616 |
|
---|
3617 | //
|
---|
3618 | // Large Integer divide - 64-bits / 32-bits -> 64-bits
|
---|
3619 | //
|
---|
3620 |
|
---|
3621 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3622 | __inline
|
---|
3623 | LARGE_INTEGER
|
---|
3624 | NTAPI
|
---|
3625 | RtlExtendedLargeIntegerDivide (
|
---|
3626 | LARGE_INTEGER Dividend,
|
---|
3627 | ULONG Divisor,
|
---|
3628 | PULONG Remainder OPTIONAL
|
---|
3629 | )
|
---|
3630 | {
|
---|
3631 | LARGE_INTEGER Quotient;
|
---|
3632 |
|
---|
3633 | Quotient.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
|
---|
3634 | if (ARGUMENT_PRESENT(Remainder)) {
|
---|
3635 | *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
|
---|
3636 | }
|
---|
3637 |
|
---|
3638 | return Quotient;
|
---|
3639 | }
|
---|
3640 |
|
---|
3641 |
|
---|
3642 | //
|
---|
3643 | // Large Integer divide - 64-bits / 64-bits -> 64-bits
|
---|
3644 | //
|
---|
3645 |
|
---|
3646 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3647 | __inline
|
---|
3648 | LARGE_INTEGER
|
---|
3649 | NTAPI
|
---|
3650 | RtlLargeIntegerDivide (
|
---|
3651 | LARGE_INTEGER Dividend,
|
---|
3652 | LARGE_INTEGER Divisor,
|
---|
3653 | PLARGE_INTEGER Remainder OPTIONAL
|
---|
3654 | )
|
---|
3655 | {
|
---|
3656 | LARGE_INTEGER Quotient;
|
---|
3657 |
|
---|
3658 | Quotient.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
|
---|
3659 | if (ARGUMENT_PRESENT(Remainder)) {
|
---|
3660 | Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
|
---|
3661 | }
|
---|
3662 |
|
---|
3663 | return Quotient;
|
---|
3664 | }
|
---|
3665 |
|
---|
3666 |
|
---|
3667 | //
|
---|
3668 | // Extended integer multiply - 32-bits * 64-bits -> 64-bits
|
---|
3669 | //
|
---|
3670 |
|
---|
3671 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3672 | __inline
|
---|
3673 | LARGE_INTEGER
|
---|
3674 | NTAPI
|
---|
3675 | RtlExtendedIntegerMultiply (
|
---|
3676 | LARGE_INTEGER Multiplicand,
|
---|
3677 | LONG Multiplier
|
---|
3678 | )
|
---|
3679 | {
|
---|
3680 | LARGE_INTEGER Product;
|
---|
3681 |
|
---|
3682 | Product.QuadPart = Multiplicand.QuadPart * Multiplier;
|
---|
3683 | return Product;
|
---|
3684 | }
|
---|
3685 |
|
---|
3686 | #else
|
---|
3687 |
|
---|
3688 | //
|
---|
3689 | // Large Integer divide - 64-bits / 32-bits -> 64-bits
|
---|
3690 | //
|
---|
3691 |
|
---|
3692 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3693 | NTSYSAPI
|
---|
3694 | LARGE_INTEGER
|
---|
3695 | NTAPI
|
---|
3696 | RtlExtendedLargeIntegerDivide (
|
---|
3697 | LARGE_INTEGER Dividend,
|
---|
3698 | ULONG Divisor,
|
---|
3699 | PULONG Remainder
|
---|
3700 | );
|
---|
3701 |
|
---|
3702 |
|
---|
3703 | //
|
---|
3704 | // Large Integer divide - 64-bits / 64-bits -> 64-bits
|
---|
3705 | //
|
---|
3706 |
|
---|
3707 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3708 | NTSYSAPI
|
---|
3709 | LARGE_INTEGER
|
---|
3710 | NTAPI
|
---|
3711 | RtlLargeIntegerDivide (
|
---|
3712 | LARGE_INTEGER Dividend,
|
---|
3713 | LARGE_INTEGER Divisor,
|
---|
3714 | PLARGE_INTEGER Remainder
|
---|
3715 | );
|
---|
3716 |
|
---|
3717 |
|
---|
3718 | //
|
---|
3719 | // Extended integer multiply - 32-bits * 64-bits -> 64-bits
|
---|
3720 | //
|
---|
3721 |
|
---|
3722 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3723 | NTSYSAPI
|
---|
3724 | LARGE_INTEGER
|
---|
3725 | NTAPI
|
---|
3726 | RtlExtendedIntegerMultiply (
|
---|
3727 | LARGE_INTEGER Multiplicand,
|
---|
3728 | LONG Multiplier
|
---|
3729 | );
|
---|
3730 |
|
---|
3731 | #endif // defined(_AMD64_) || defined(_IA64_)
|
---|
3732 |
|
---|
3733 | //
|
---|
3734 | // Large integer and - 64-bite & 64-bits -> 64-bits.
|
---|
3735 | //
|
---|
3736 |
|
---|
3737 | #if PRAGMA_DEPRECATED_DDK
|
---|
3738 | #pragma deprecated(RtlLargeIntegerAnd) // Use native __int64 math
|
---|
3739 | #endif
|
---|
3740 | #define RtlLargeIntegerAnd(Result, Source, Mask) \
|
---|
3741 | Result.QuadPart = Source.QuadPart & Mask.QuadPart
|
---|
3742 |
|
---|
3743 | //
|
---|
3744 | // Convert signed integer to large integer.
|
---|
3745 | //
|
---|
3746 |
|
---|
3747 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3748 | __inline
|
---|
3749 | LARGE_INTEGER
|
---|
3750 | NTAPI
|
---|
3751 | RtlConvertLongToLargeInteger (
|
---|
3752 | LONG SignedInteger
|
---|
3753 | )
|
---|
3754 | {
|
---|
3755 | LARGE_INTEGER Result;
|
---|
3756 |
|
---|
3757 | Result.QuadPart = SignedInteger;
|
---|
3758 | return Result;
|
---|
3759 | }
|
---|
3760 |
|
---|
3761 | //
|
---|
3762 | // Convert unsigned integer to large integer.
|
---|
3763 | //
|
---|
3764 |
|
---|
3765 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3766 | __inline
|
---|
3767 | LARGE_INTEGER
|
---|
3768 | NTAPI
|
---|
3769 | RtlConvertUlongToLargeInteger (
|
---|
3770 | ULONG UnsignedInteger
|
---|
3771 | )
|
---|
3772 | {
|
---|
3773 | LARGE_INTEGER Result;
|
---|
3774 |
|
---|
3775 | Result.QuadPart = UnsignedInteger;
|
---|
3776 | return Result;
|
---|
3777 | }
|
---|
3778 |
|
---|
3779 | //
|
---|
3780 | // Large integer shift routines.
|
---|
3781 | //
|
---|
3782 |
|
---|
3783 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3784 | __inline
|
---|
3785 | LARGE_INTEGER
|
---|
3786 | NTAPI
|
---|
3787 | RtlLargeIntegerShiftLeft (
|
---|
3788 | LARGE_INTEGER LargeInteger,
|
---|
3789 | CCHAR ShiftCount
|
---|
3790 | )
|
---|
3791 | {
|
---|
3792 | LARGE_INTEGER Result;
|
---|
3793 |
|
---|
3794 | Result.QuadPart = LargeInteger.QuadPart << ShiftCount;
|
---|
3795 | return Result;
|
---|
3796 | }
|
---|
3797 |
|
---|
3798 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3799 | __inline
|
---|
3800 | LARGE_INTEGER
|
---|
3801 | NTAPI
|
---|
3802 | RtlLargeIntegerShiftRight (
|
---|
3803 | LARGE_INTEGER LargeInteger,
|
---|
3804 | CCHAR ShiftCount
|
---|
3805 | )
|
---|
3806 | {
|
---|
3807 | LARGE_INTEGER Result;
|
---|
3808 |
|
---|
3809 | Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount;
|
---|
3810 | return Result;
|
---|
3811 | }
|
---|
3812 |
|
---|
3813 | DECLSPEC_DEPRECATED_DDK // Use native __int64 math
|
---|
3814 | __inline
|
---|
3815 | LARGE_INTEGER
|
---|
3816 | NTAPI
|
---|
3817 | RtlLargeIntegerArithmeticShift (
|
---|
3818 | LARGE_INTEGER LargeInteger,
|
---|
3819 | CCHAR ShiftCount
|
---|
3820 | )
|
---|
3821 | {
|
---|
3822 | LARGE_INTEGER Result;
|
---|
3823 |
|
---|
3824 | Result.QuadPart = LargeInteger.QuadPart >> ShiftCount;
|
---|
3825 | return Result;
|
---|
3826 | }
|
---|
3827 |
|
---|
3828 |
|
---|
3829 | //
|
---|
3830 | // Large integer comparison routines.
|
---|
3831 | //
|
---|
3832 |
|
---|
3833 | #if PRAGMA_DEPRECATED_DDK
|
---|
3834 | #pragma deprecated(RtlLargeIntegerGreaterThan) // Use native __int64 math
|
---|
3835 | #pragma deprecated(RtlLargeIntegerGreaterThanOrEqualTo) // Use native __int64 math
|
---|
3836 | #pragma deprecated(RtlLargeIntegerEqualTo) // Use native __int64 math
|
---|
3837 | #pragma deprecated(RtlLargeIntegerNotEqualTo) // Use native __int64 math
|
---|
3838 | #pragma deprecated(RtlLargeIntegerLessThan) // Use native __int64 math
|
---|
3839 | #pragma deprecated(RtlLargeIntegerLessThanOrEqualTo) // Use native __int64 math
|
---|
3840 | #pragma deprecated(RtlLargeIntegerGreaterThanZero) // Use native __int64 math
|
---|
3841 | #pragma deprecated(RtlLargeIntegerGreaterOrEqualToZero) // Use native __int64 math
|
---|
3842 | #pragma deprecated(RtlLargeIntegerEqualToZero) // Use native __int64 math
|
---|
3843 | #pragma deprecated(RtlLargeIntegerNotEqualToZero) // Use native __int64 math
|
---|
3844 | #pragma deprecated(RtlLargeIntegerLessThanZero) // Use native __int64 math
|
---|
3845 | #pragma deprecated(RtlLargeIntegerLessOrEqualToZero) // Use native __int64 math
|
---|
3846 | #endif
|
---|
3847 |
|
---|
3848 | #define RtlLargeIntegerGreaterThan(X,Y) ( \
|
---|
3849 | (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
|
---|
3850 | ((X).HighPart > (Y).HighPart) \
|
---|
3851 | )
|
---|
3852 |
|
---|
3853 | #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
|
---|
3854 | (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
|
---|
3855 | ((X).HighPart > (Y).HighPart) \
|
---|
3856 | )
|
---|
3857 |
|
---|
3858 | #define RtlLargeIntegerEqualTo(X,Y) ( \
|
---|
3859 | !(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
|
---|
3860 | )
|
---|
3861 |
|
---|
3862 | #define RtlLargeIntegerNotEqualTo(X,Y) ( \
|
---|
3863 | (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
|
---|
3864 | )
|
---|
3865 |
|
---|
3866 | #define RtlLargeIntegerLessThan(X,Y) ( \
|
---|
3867 | (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
|
---|
3868 | ((X).HighPart < (Y).HighPart) \
|
---|
3869 | )
|
---|
3870 |
|
---|
3871 | #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
|
---|
3872 | (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
|
---|
3873 | ((X).HighPart < (Y).HighPart) \
|
---|
3874 | )
|
---|
3875 |
|
---|
3876 | #define RtlLargeIntegerGreaterThanZero(X) ( \
|
---|
3877 | (((X).HighPart == 0) && ((X).LowPart > 0)) || \
|
---|
3878 | ((X).HighPart > 0 ) \
|
---|
3879 | )
|
---|
3880 |
|
---|
3881 | #define RtlLargeIntegerGreaterOrEqualToZero(X) ( \
|
---|
3882 | (X).HighPart >= 0 \
|
---|
3883 | )
|
---|
3884 |
|
---|
3885 | #define RtlLargeIntegerEqualToZero(X) ( \
|
---|
3886 | !((X).LowPart | (X).HighPart) \
|
---|
3887 | )
|
---|
3888 |
|
---|
3889 | #define RtlLargeIntegerNotEqualToZero(X) ( \
|
---|
3890 | ((X).LowPart | (X).HighPart) \
|
---|
3891 | )
|
---|
3892 |
|
---|
3893 | #define RtlLargeIntegerLessThanZero(X) ( \
|
---|
3894 | ((X).HighPart < 0) \
|
---|
3895 | )
|
---|
3896 |
|
---|
3897 | #define RtlLargeIntegerLessOrEqualToZero(X) ( \
|
---|
3898 | ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) \
|
---|
3899 | )
|
---|
3900 |
|
---|
3901 | #endif // !defined(MIDL_PASS)
|
---|
3902 | |
---|
3903 |
|
---|
3904 | //
|
---|
3905 | // Time conversion routines
|
---|
3906 | //
|
---|
3907 |
|
---|
3908 | typedef struct _TIME_FIELDS {
|
---|
3909 | CSHORT Year; // range [1601...]
|
---|
3910 | CSHORT Month; // range [1..12]
|
---|
3911 | CSHORT Day; // range [1..31]
|
---|
3912 | CSHORT Hour; // range [0..23]
|
---|
3913 | CSHORT Minute; // range [0..59]
|
---|
3914 | CSHORT Second; // range [0..59]
|
---|
3915 | CSHORT Milliseconds;// range [0..999]
|
---|
3916 | CSHORT Weekday; // range [0..6] == [Sunday..Saturday]
|
---|
3917 | } TIME_FIELDS;
|
---|
3918 | typedef TIME_FIELDS *PTIME_FIELDS;
|
---|
3919 |
|
---|
3920 |
|
---|
3921 | NTSYSAPI
|
---|
3922 | VOID
|
---|
3923 | NTAPI
|
---|
3924 | RtlTimeToTimeFields (
|
---|
3925 | PLARGE_INTEGER Time,
|
---|
3926 | PTIME_FIELDS TimeFields
|
---|
3927 | );
|
---|
3928 |
|
---|
3929 | //
|
---|
3930 | // A time field record (Weekday ignored) -> 64 bit Time value
|
---|
3931 | //
|
---|
3932 |
|
---|
3933 | NTSYSAPI
|
---|
3934 | BOOLEAN
|
---|
3935 | NTAPI
|
---|
3936 | RtlTimeFieldsToTime (
|
---|
3937 | PTIME_FIELDS TimeFields,
|
---|
3938 | PLARGE_INTEGER Time
|
---|
3939 | );
|
---|
3940 |
|
---|
3941 | //
|
---|
3942 | // The following macros store and retrieve USHORTS and ULONGS from potentially
|
---|
3943 | // unaligned addresses, avoiding alignment faults. they should probably be
|
---|
3944 | // rewritten in assembler
|
---|
3945 | //
|
---|
3946 |
|
---|
3947 | #define SHORT_SIZE (sizeof(USHORT))
|
---|
3948 | #define SHORT_MASK (SHORT_SIZE - 1)
|
---|
3949 | #define LONG_SIZE (sizeof(LONG))
|
---|
3950 | #define LONGLONG_SIZE (sizeof(LONGLONG))
|
---|
3951 | #define LONG_MASK (LONG_SIZE - 1)
|
---|
3952 | #define LONGLONG_MASK (LONGLONG_SIZE - 1)
|
---|
3953 | #define LOWBYTE_MASK 0x00FF
|
---|
3954 |
|
---|
3955 | #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
|
---|
3956 | #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
|
---|
3957 | #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
|
---|
3958 | #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
|
---|
3959 |
|
---|
3960 | //
|
---|
3961 | // if MIPS Big Endian, order of bytes is reversed.
|
---|
3962 | //
|
---|
3963 |
|
---|
3964 | #define SHORT_LEAST_SIGNIFICANT_BIT 0
|
---|
3965 | #define SHORT_MOST_SIGNIFICANT_BIT 1
|
---|
3966 |
|
---|
3967 | #define LONG_LEAST_SIGNIFICANT_BIT 0
|
---|
3968 | #define LONG_3RD_MOST_SIGNIFICANT_BIT 1
|
---|
3969 | #define LONG_2ND_MOST_SIGNIFICANT_BIT 2
|
---|
3970 | #define LONG_MOST_SIGNIFICANT_BIT 3
|
---|
3971 |
|
---|
3972 | //++
|
---|
3973 | //
|
---|
3974 | // VOID
|
---|
3975 | // RtlStoreUshort (
|
---|
3976 | // PUSHORT ADDRESS
|
---|
3977 | // USHORT VALUE
|
---|
3978 | // )
|
---|
3979 | //
|
---|
3980 | // Routine Description:
|
---|
3981 | //
|
---|
3982 | // This macro stores a USHORT value in at a particular address, avoiding
|
---|
3983 | // alignment faults.
|
---|
3984 | //
|
---|
3985 | // Arguments:
|
---|
3986 | //
|
---|
3987 | // ADDRESS - where to store USHORT value
|
---|
3988 | // VALUE - USHORT to store
|
---|
3989 | //
|
---|
3990 | // Return Value:
|
---|
3991 | //
|
---|
3992 | // none.
|
---|
3993 | //
|
---|
3994 | //--
|
---|
3995 |
|
---|
3996 | #define RtlStoreUshort(ADDRESS,VALUE) \
|
---|
3997 | if ((ULONG_PTR)(ADDRESS) & SHORT_MASK) { \
|
---|
3998 | ((PUCHAR) (ADDRESS))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(VALUE)); \
|
---|
3999 | ((PUCHAR) (ADDRESS))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(VALUE)); \
|
---|
4000 | } \
|
---|
4001 | else { \
|
---|
4002 | *((PUSHORT) (ADDRESS)) = (USHORT) VALUE; \
|
---|
4003 | }
|
---|
4004 |
|
---|
4005 |
|
---|
4006 | //++
|
---|
4007 | //
|
---|
4008 | // VOID
|
---|
4009 | // RtlStoreUlong (
|
---|
4010 | // PULONG ADDRESS
|
---|
4011 | // ULONG VALUE
|
---|
4012 | // )
|
---|
4013 | //
|
---|
4014 | // Routine Description:
|
---|
4015 | //
|
---|
4016 | // This macro stores a ULONG value in at a particular address, avoiding
|
---|
4017 | // alignment faults.
|
---|
4018 | //
|
---|
4019 | // Arguments:
|
---|
4020 | //
|
---|
4021 | // ADDRESS - where to store ULONG value
|
---|
4022 | // VALUE - ULONG to store
|
---|
4023 | //
|
---|
4024 | // Return Value:
|
---|
4025 | //
|
---|
4026 | // none.
|
---|
4027 | //
|
---|
4028 | // Note:
|
---|
4029 | // Depending on the machine, we might want to call storeushort in the
|
---|
4030 | // unaligned case.
|
---|
4031 | //
|
---|
4032 | //--
|
---|
4033 |
|
---|
4034 | #define RtlStoreUlong(ADDRESS,VALUE) \
|
---|
4035 | if ((ULONG_PTR)(ADDRESS) & LONG_MASK) { \
|
---|
4036 | ((PUCHAR) (ADDRESS))[LONG_LEAST_SIGNIFICANT_BIT ] = (UCHAR)(FIRSTBYTE(VALUE)); \
|
---|
4037 | ((PUCHAR) (ADDRESS))[LONG_3RD_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(VALUE)); \
|
---|
4038 | ((PUCHAR) (ADDRESS))[LONG_2ND_MOST_SIGNIFICANT_BIT ] = (UCHAR)(THIRDBYTE(VALUE)); \
|
---|
4039 | ((PUCHAR) (ADDRESS))[LONG_MOST_SIGNIFICANT_BIT ] = (UCHAR)(FOURTHBYTE(VALUE)); \
|
---|
4040 | } \
|
---|
4041 | else { \
|
---|
4042 | *((PULONG) (ADDRESS)) = (ULONG) (VALUE); \
|
---|
4043 | }
|
---|
4044 |
|
---|
4045 | //++
|
---|
4046 | //
|
---|
4047 | // VOID
|
---|
4048 | // RtlStoreUlonglong (
|
---|
4049 | // PULONGLONG ADDRESS
|
---|
4050 | // ULONG VALUE
|
---|
4051 | // )
|
---|
4052 | //
|
---|
4053 | // Routine Description:
|
---|
4054 | //
|
---|
4055 | // This macro stores a ULONGLONG value in at a particular address, avoiding
|
---|
4056 | // alignment faults.
|
---|
4057 | //
|
---|
4058 | // Arguments:
|
---|
4059 | //
|
---|
4060 | // ADDRESS - where to store ULONGLONG value
|
---|
4061 | // VALUE - ULONGLONG to store
|
---|
4062 | //
|
---|
4063 | // Return Value:
|
---|
4064 | //
|
---|
4065 | // none.
|
---|
4066 | //
|
---|
4067 | //--
|
---|
4068 |
|
---|
4069 | #define RtlStoreUlonglong(ADDRESS,VALUE) \
|
---|
4070 | if ((ULONG_PTR)(ADDRESS) & LONGLONG_MASK) { \
|
---|
4071 | RtlStoreUlong((ULONG_PTR)(ADDRESS), \
|
---|
4072 | (ULONGLONG)(VALUE) & 0xFFFFFFFF); \
|
---|
4073 | RtlStoreUlong((ULONG_PTR)(ADDRESS)+sizeof(ULONG), \
|
---|
4074 | (ULONGLONG)(VALUE) >> 32); \
|
---|
4075 | } else { \
|
---|
4076 | *((PULONGLONG)(ADDRESS)) = (ULONGLONG)(VALUE); \
|
---|
4077 | }
|
---|
4078 |
|
---|
4079 | //++
|
---|
4080 | //
|
---|
4081 | // VOID
|
---|
4082 | // RtlStoreUlongPtr (
|
---|
4083 | // PULONG_PTR ADDRESS
|
---|
4084 | // ULONG_PTR VALUE
|
---|
4085 | // )
|
---|
4086 | //
|
---|
4087 | // Routine Description:
|
---|
4088 | //
|
---|
4089 | // This macro stores a ULONG_PTR value in at a particular address, avoiding
|
---|
4090 | // alignment faults.
|
---|
4091 | //
|
---|
4092 | // Arguments:
|
---|
4093 | //
|
---|
4094 | // ADDRESS - where to store ULONG_PTR value
|
---|
4095 | // VALUE - ULONG_PTR to store
|
---|
4096 | //
|
---|
4097 | // Return Value:
|
---|
4098 | //
|
---|
4099 | // none.
|
---|
4100 | //
|
---|
4101 | //--
|
---|
4102 |
|
---|
4103 | #ifdef _WIN64
|
---|
4104 |
|
---|
4105 | #define RtlStoreUlongPtr(ADDRESS,VALUE) \
|
---|
4106 | RtlStoreUlonglong(ADDRESS,VALUE)
|
---|
4107 |
|
---|
4108 | #else
|
---|
4109 |
|
---|
4110 | #define RtlStoreUlongPtr(ADDRESS,VALUE) \
|
---|
4111 | RtlStoreUlong(ADDRESS,VALUE)
|
---|
4112 |
|
---|
4113 | #endif
|
---|
4114 |
|
---|
4115 | //++
|
---|
4116 | //
|
---|
4117 | // VOID
|
---|
4118 | // RtlRetrieveUshort (
|
---|
4119 | // PUSHORT DESTINATION_ADDRESS
|
---|
4120 | // PUSHORT SOURCE_ADDRESS
|
---|
4121 | // )
|
---|
4122 | //
|
---|
4123 | // Routine Description:
|
---|
4124 | //
|
---|
4125 | // This macro retrieves a USHORT value from the SOURCE address, avoiding
|
---|
4126 | // alignment faults. The DESTINATION address is assumed to be aligned.
|
---|
4127 | //
|
---|
4128 | // Arguments:
|
---|
4129 | //
|
---|
4130 | // DESTINATION_ADDRESS - where to store USHORT value
|
---|
4131 | // SOURCE_ADDRESS - where to retrieve USHORT value from
|
---|
4132 | //
|
---|
4133 | // Return Value:
|
---|
4134 | //
|
---|
4135 | // none.
|
---|
4136 | //
|
---|
4137 | //--
|
---|
4138 |
|
---|
4139 | #define RtlRetrieveUshort(DEST_ADDRESS,SRC_ADDRESS) \
|
---|
4140 | if ((ULONG_PTR)SRC_ADDRESS & SHORT_MASK) { \
|
---|
4141 | ((PUCHAR) DEST_ADDRESS)[0] = ((PUCHAR) SRC_ADDRESS)[0]; \
|
---|
4142 | ((PUCHAR) DEST_ADDRESS)[1] = ((PUCHAR) SRC_ADDRESS)[1]; \
|
---|
4143 | } \
|
---|
4144 | else { \
|
---|
4145 | *((PUSHORT) DEST_ADDRESS) = *((PUSHORT) SRC_ADDRESS); \
|
---|
4146 | } \
|
---|
4147 |
|
---|
4148 | //++
|
---|
4149 | //
|
---|
4150 | // VOID
|
---|
4151 | // RtlRetrieveUlong (
|
---|
4152 | // PULONG DESTINATION_ADDRESS
|
---|
4153 | // PULONG SOURCE_ADDRESS
|
---|
4154 | // )
|
---|
4155 | //
|
---|
4156 | // Routine Description:
|
---|
4157 | //
|
---|
4158 | // This macro retrieves a ULONG value from the SOURCE address, avoiding
|
---|
4159 | // alignment faults. The DESTINATION address is assumed to be aligned.
|
---|
4160 | //
|
---|
4161 | // Arguments:
|
---|
4162 | //
|
---|
4163 | // DESTINATION_ADDRESS - where to store ULONG value
|
---|
4164 | // SOURCE_ADDRESS - where to retrieve ULONG value from
|
---|
4165 | //
|
---|
4166 | // Return Value:
|
---|
4167 | //
|
---|
4168 | // none.
|
---|
4169 | //
|
---|
4170 | // Note:
|
---|
4171 | // Depending on the machine, we might want to call retrieveushort in the
|
---|
4172 | // unaligned case.
|
---|
4173 | //
|
---|
4174 | //--
|
---|
4175 |
|
---|
4176 | #define RtlRetrieveUlong(DEST_ADDRESS,SRC_ADDRESS) \
|
---|
4177 | if ((ULONG_PTR)SRC_ADDRESS & LONG_MASK) { \
|
---|
4178 | ((PUCHAR) DEST_ADDRESS)[0] = ((PUCHAR) SRC_ADDRESS)[0]; \
|
---|
4179 | ((PUCHAR) DEST_ADDRESS)[1] = ((PUCHAR) SRC_ADDRESS)[1]; \
|
---|
4180 | ((PUCHAR) DEST_ADDRESS)[2] = ((PUCHAR) SRC_ADDRESS)[2]; \
|
---|
4181 | ((PUCHAR) DEST_ADDRESS)[3] = ((PUCHAR) SRC_ADDRESS)[3]; \
|
---|
4182 | } \
|
---|
4183 | else { \
|
---|
4184 | *((PULONG) DEST_ADDRESS) = *((PULONG) SRC_ADDRESS); \
|
---|
4185 | }
|
---|
4186 | //
|
---|
4187 | // BitMap routines. The following structure, routines, and macros are
|
---|
4188 | // for manipulating bitmaps. The user is responsible for allocating a bitmap
|
---|
4189 | // structure (which is really a header) and a buffer (which must be longword
|
---|
4190 | // aligned and multiple longwords in size).
|
---|
4191 | //
|
---|
4192 |
|
---|
4193 | typedef struct _RTL_BITMAP {
|
---|
4194 | ULONG SizeOfBitMap; // Number of bits in bit map
|
---|
4195 | PULONG Buffer; // Pointer to the bit map itself
|
---|
4196 | } RTL_BITMAP;
|
---|
4197 | typedef RTL_BITMAP *PRTL_BITMAP;
|
---|
4198 |
|
---|
4199 | //
|
---|
4200 | // The following routine initializes a new bitmap. It does not alter the
|
---|
4201 | // data currently in the bitmap. This routine must be called before
|
---|
4202 | // any other bitmap routine/macro.
|
---|
4203 | //
|
---|
4204 |
|
---|
4205 | NTSYSAPI
|
---|
4206 | VOID
|
---|
4207 | NTAPI
|
---|
4208 | RtlInitializeBitMap (
|
---|
4209 | PRTL_BITMAP BitMapHeader,
|
---|
4210 | PULONG BitMapBuffer,
|
---|
4211 | ULONG SizeOfBitMap
|
---|
4212 | );
|
---|
4213 |
|
---|
4214 | //
|
---|
4215 | // The following three routines clear, set, and test the state of a
|
---|
4216 | // single bit in a bitmap.
|
---|
4217 | //
|
---|
4218 |
|
---|
4219 | NTSYSAPI
|
---|
4220 | VOID
|
---|
4221 | NTAPI
|
---|
4222 | RtlClearBit (
|
---|
4223 | PRTL_BITMAP BitMapHeader,
|
---|
4224 | ULONG BitNumber
|
---|
4225 | );
|
---|
4226 |
|
---|
4227 | NTSYSAPI
|
---|
4228 | VOID
|
---|
4229 | NTAPI
|
---|
4230 | RtlSetBit (
|
---|
4231 | PRTL_BITMAP BitMapHeader,
|
---|
4232 | ULONG BitNumber
|
---|
4233 | );
|
---|
4234 |
|
---|
4235 | NTSYSAPI
|
---|
4236 | BOOLEAN
|
---|
4237 | NTAPI
|
---|
4238 | RtlTestBit (
|
---|
4239 | PRTL_BITMAP BitMapHeader,
|
---|
4240 | ULONG BitNumber
|
---|
4241 | );
|
---|
4242 |
|
---|
4243 | //
|
---|
4244 | // The following two routines either clear or set all of the bits
|
---|
4245 | // in a bitmap.
|
---|
4246 | //
|
---|
4247 |
|
---|
4248 | NTSYSAPI
|
---|
4249 | VOID
|
---|
4250 | NTAPI
|
---|
4251 | RtlClearAllBits (
|
---|
4252 | PRTL_BITMAP BitMapHeader
|
---|
4253 | );
|
---|
4254 |
|
---|
4255 | NTSYSAPI
|
---|
4256 | VOID
|
---|
4257 | NTAPI
|
---|
4258 | RtlSetAllBits (
|
---|
4259 | PRTL_BITMAP BitMapHeader
|
---|
4260 | );
|
---|
4261 |
|
---|
4262 | //
|
---|
4263 | // The following two routines locate a contiguous region of either
|
---|
4264 | // clear or set bits within the bitmap. The region will be at least
|
---|
4265 | // as large as the number specified, and the search of the bitmap will
|
---|
4266 | // begin at the specified hint index (which is a bit index within the
|
---|
4267 | // bitmap, zero based). The return value is the bit index of the located
|
---|
4268 | // region (zero based) or -1 (i.e., 0xffffffff) if such a region cannot
|
---|
4269 | // be located
|
---|
4270 | //
|
---|
4271 |
|
---|
4272 | NTSYSAPI
|
---|
4273 | ULONG
|
---|
4274 | NTAPI
|
---|
4275 | RtlFindClearBits (
|
---|
4276 | PRTL_BITMAP BitMapHeader,
|
---|
4277 | ULONG NumberToFind,
|
---|
4278 | ULONG HintIndex
|
---|
4279 | );
|
---|
4280 |
|
---|
4281 | NTSYSAPI
|
---|
4282 | ULONG
|
---|
4283 | NTAPI
|
---|
4284 | RtlFindSetBits (
|
---|
4285 | PRTL_BITMAP BitMapHeader,
|
---|
4286 | ULONG NumberToFind,
|
---|
4287 | ULONG HintIndex
|
---|
4288 | );
|
---|
4289 |
|
---|
4290 | //
|
---|
4291 | // The following two routines locate a contiguous region of either
|
---|
4292 | // clear or set bits within the bitmap and either set or clear the bits
|
---|
4293 | // within the located region. The region will be as large as the number
|
---|
4294 | // specified, and the search for the region will begin at the specified
|
---|
4295 | // hint index (which is a bit index within the bitmap, zero based). The
|
---|
4296 | // return value is the bit index of the located region (zero based) or
|
---|
4297 | // -1 (i.e., 0xffffffff) if such a region cannot be located. If a region
|
---|
4298 | // cannot be located then the setting/clearing of the bitmap is not performed.
|
---|
4299 | //
|
---|
4300 |
|
---|
4301 | NTSYSAPI
|
---|
4302 | ULONG
|
---|
4303 | NTAPI
|
---|
4304 | RtlFindClearBitsAndSet (
|
---|
4305 | PRTL_BITMAP BitMapHeader,
|
---|
4306 | ULONG NumberToFind,
|
---|
4307 | ULONG HintIndex
|
---|
4308 | );
|
---|
4309 |
|
---|
4310 | NTSYSAPI
|
---|
4311 | ULONG
|
---|
4312 | NTAPI
|
---|
4313 | RtlFindSetBitsAndClear (
|
---|
4314 | PRTL_BITMAP BitMapHeader,
|
---|
4315 | ULONG NumberToFind,
|
---|
4316 | ULONG HintIndex
|
---|
4317 | );
|
---|
4318 |
|
---|
4319 | //
|
---|
4320 | // The following two routines clear or set bits within a specified region
|
---|
4321 | // of the bitmap. The starting index is zero based.
|
---|
4322 | //
|
---|
4323 |
|
---|
4324 | NTSYSAPI
|
---|
4325 | VOID
|
---|
4326 | NTAPI
|
---|
4327 | RtlClearBits (
|
---|
4328 | PRTL_BITMAP BitMapHeader,
|
---|
4329 | ULONG StartingIndex,
|
---|
4330 | ULONG NumberToClear
|
---|
4331 | );
|
---|
4332 |
|
---|
4333 | NTSYSAPI
|
---|
4334 | VOID
|
---|
4335 | NTAPI
|
---|
4336 | RtlSetBits (
|
---|
4337 | PRTL_BITMAP BitMapHeader,
|
---|
4338 | ULONG StartingIndex,
|
---|
4339 | ULONG NumberToSet
|
---|
4340 | );
|
---|
4341 |
|
---|
4342 | //
|
---|
4343 | // The following routine locates a set of contiguous regions of clear
|
---|
4344 | // bits within the bitmap. The caller specifies whether to return the
|
---|
4345 | // longest runs or just the first found lcoated. The following structure is
|
---|
4346 | // used to denote a contiguous run of bits. The two routines return an array
|
---|
4347 | // of this structure, one for each run located.
|
---|
4348 | //
|
---|
4349 |
|
---|
4350 | typedef struct _RTL_BITMAP_RUN {
|
---|
4351 |
|
---|
4352 | ULONG StartingIndex;
|
---|
4353 | ULONG NumberOfBits;
|
---|
4354 |
|
---|
4355 | } RTL_BITMAP_RUN;
|
---|
4356 | typedef RTL_BITMAP_RUN *PRTL_BITMAP_RUN;
|
---|
4357 |
|
---|
4358 | NTSYSAPI
|
---|
4359 | ULONG
|
---|
4360 | NTAPI
|
---|
4361 | RtlFindClearRuns (
|
---|
4362 | PRTL_BITMAP BitMapHeader,
|
---|
4363 | PRTL_BITMAP_RUN RunArray,
|
---|
4364 | ULONG SizeOfRunArray,
|
---|
4365 | BOOLEAN LocateLongestRuns
|
---|
4366 | );
|
---|
4367 |
|
---|
4368 | //
|
---|
4369 | // The following routine locates the longest contiguous region of
|
---|
4370 | // clear bits within the bitmap. The returned starting index value
|
---|
4371 | // denotes the first contiguous region located satisfying our requirements
|
---|
4372 | // The return value is the length (in bits) of the longest region found.
|
---|
4373 | //
|
---|
4374 |
|
---|
4375 | NTSYSAPI
|
---|
4376 | ULONG
|
---|
4377 | NTAPI
|
---|
4378 | RtlFindLongestRunClear (
|
---|
4379 | PRTL_BITMAP BitMapHeader,
|
---|
4380 | PULONG StartingIndex
|
---|
4381 | );
|
---|
4382 |
|
---|
4383 | //
|
---|
4384 | // The following routine locates the first contiguous region of
|
---|
4385 | // clear bits within the bitmap. The returned starting index value
|
---|
4386 | // denotes the first contiguous region located satisfying our requirements
|
---|
4387 | // The return value is the length (in bits) of the region found.
|
---|
4388 | //
|
---|
4389 |
|
---|
4390 | NTSYSAPI
|
---|
4391 | ULONG
|
---|
4392 | NTAPI
|
---|
4393 | RtlFindFirstRunClear (
|
---|
4394 | PRTL_BITMAP BitMapHeader,
|
---|
4395 | PULONG StartingIndex
|
---|
4396 | );
|
---|
4397 |
|
---|
4398 | //
|
---|
4399 | // The following macro returns the value of the bit stored within the
|
---|
4400 | // bitmap at the specified location. If the bit is set a value of 1 is
|
---|
4401 | // returned otherwise a value of 0 is returned.
|
---|
4402 | //
|
---|
4403 | // ULONG
|
---|
4404 | // RtlCheckBit (
|
---|
4405 | // PRTL_BITMAP BitMapHeader,
|
---|
4406 | // ULONG BitPosition
|
---|
4407 | // );
|
---|
4408 | //
|
---|
4409 | //
|
---|
4410 | // To implement CheckBit the macro retrieves the longword containing the
|
---|
4411 | // bit in question, shifts the longword to get the bit in question into the
|
---|
4412 | // low order bit position and masks out all other bits.
|
---|
4413 | //
|
---|
4414 |
|
---|
4415 | #define RtlCheckBit(BMH,BP) ((((BMH)->Buffer[(BP) / 32]) >> ((BP) % 32)) & 0x1)
|
---|
4416 |
|
---|
4417 | //
|
---|
4418 | // The following two procedures return to the caller the total number of
|
---|
4419 | // clear or set bits within the specified bitmap.
|
---|
4420 | //
|
---|
4421 |
|
---|
4422 | NTSYSAPI
|
---|
4423 | ULONG
|
---|
4424 | NTAPI
|
---|
4425 | RtlNumberOfClearBits (
|
---|
4426 | PRTL_BITMAP BitMapHeader
|
---|
4427 | );
|
---|
4428 |
|
---|
4429 | NTSYSAPI
|
---|
4430 | ULONG
|
---|
4431 | NTAPI
|
---|
4432 | RtlNumberOfSetBits (
|
---|
4433 | PRTL_BITMAP BitMapHeader
|
---|
4434 | );
|
---|
4435 |
|
---|
4436 | //
|
---|
4437 | // The following two procedures return to the caller a boolean value
|
---|
4438 | // indicating if the specified range of bits are all clear or set.
|
---|
4439 | //
|
---|
4440 |
|
---|
4441 | NTSYSAPI
|
---|
4442 | BOOLEAN
|
---|
4443 | NTAPI
|
---|
4444 | RtlAreBitsClear (
|
---|
4445 | PRTL_BITMAP BitMapHeader,
|
---|
4446 | ULONG StartingIndex,
|
---|
4447 | ULONG Length
|
---|
4448 | );
|
---|
4449 |
|
---|
4450 | NTSYSAPI
|
---|
4451 | BOOLEAN
|
---|
4452 | NTAPI
|
---|
4453 | RtlAreBitsSet (
|
---|
4454 | PRTL_BITMAP BitMapHeader,
|
---|
4455 | ULONG StartingIndex,
|
---|
4456 | ULONG Length
|
---|
4457 | );
|
---|
4458 |
|
---|
4459 | NTSYSAPI
|
---|
4460 | ULONG
|
---|
4461 | NTAPI
|
---|
4462 | RtlFindNextForwardRunClear (
|
---|
4463 | IN PRTL_BITMAP BitMapHeader,
|
---|
4464 | IN ULONG FromIndex,
|
---|
4465 | IN PULONG StartingRunIndex
|
---|
4466 | );
|
---|
4467 |
|
---|
4468 | NTSYSAPI
|
---|
4469 | ULONG
|
---|
4470 | NTAPI
|
---|
4471 | RtlFindLastBackwardRunClear (
|
---|
4472 | IN PRTL_BITMAP BitMapHeader,
|
---|
4473 | IN ULONG FromIndex,
|
---|
4474 | IN PULONG StartingRunIndex
|
---|
4475 | );
|
---|
4476 |
|
---|
4477 | //
|
---|
4478 | // The following two procedures return to the caller a value indicating
|
---|
4479 | // the position within a ULONGLONG of the most or least significant non-zero
|
---|
4480 | // bit. A value of zero results in a return value of -1.
|
---|
4481 | //
|
---|
4482 |
|
---|
4483 | NTSYSAPI
|
---|
4484 | CCHAR
|
---|
4485 | NTAPI
|
---|
4486 | RtlFindLeastSignificantBit (
|
---|
4487 | IN ULONGLONG Set
|
---|
4488 | );
|
---|
4489 |
|
---|
4490 | NTSYSAPI
|
---|
4491 | CCHAR
|
---|
4492 | NTAPI
|
---|
4493 | RtlFindMostSignificantBit (
|
---|
4494 | IN ULONGLONG Set
|
---|
4495 | );
|
---|
4496 |
|
---|
4497 |
|
---|
4498 | //
|
---|
4499 | // BOOLEAN
|
---|
4500 | // RtlEqualLuid(
|
---|
4501 | // PLUID L1,
|
---|
4502 | // PLUID L2
|
---|
4503 | // );
|
---|
4504 |
|
---|
4505 | #define RtlEqualLuid(L1, L2) (((L1)->LowPart == (L2)->LowPart) && \
|
---|
4506 | ((L1)->HighPart == (L2)->HighPart))
|
---|
4507 |
|
---|
4508 | //
|
---|
4509 | // BOOLEAN
|
---|
4510 | // RtlIsZeroLuid(
|
---|
4511 | // PLUID L1
|
---|
4512 | // );
|
---|
4513 | //
|
---|
4514 | #define RtlIsZeroLuid(L1) ((BOOLEAN) (((L1)->LowPart | (L1)->HighPart) == 0))
|
---|
4515 |
|
---|
4516 |
|
---|
4517 | #if !defined(MIDL_PASS)
|
---|
4518 |
|
---|
4519 | FORCEINLINE LUID
|
---|
4520 | NTAPI
|
---|
4521 | RtlConvertLongToLuid(
|
---|
4522 | LONG Long
|
---|
4523 | )
|
---|
4524 | {
|
---|
4525 | LUID TempLuid;
|
---|
4526 | LARGE_INTEGER TempLi;
|
---|
4527 |
|
---|
4528 | TempLi.QuadPart = Long;
|
---|
4529 | TempLuid.LowPart = TempLi.LowPart;
|
---|
4530 | TempLuid.HighPart = TempLi.HighPart;
|
---|
4531 | return(TempLuid);
|
---|
4532 | }
|
---|
4533 |
|
---|
4534 | FORCEINLINE
|
---|
4535 | LUID
|
---|
4536 | NTAPI
|
---|
4537 | RtlConvertUlongToLuid(
|
---|
4538 | ULONG Ulong
|
---|
4539 | )
|
---|
4540 | {
|
---|
4541 | LUID TempLuid;
|
---|
4542 |
|
---|
4543 | TempLuid.LowPart = Ulong;
|
---|
4544 | TempLuid.HighPart = 0;
|
---|
4545 | return(TempLuid);
|
---|
4546 | }
|
---|
4547 | #endif
|
---|
4548 |
|
---|
4549 |
|
---|
4550 | NTSYSAPI
|
---|
4551 | VOID
|
---|
4552 | NTAPI
|
---|
4553 | RtlMapGenericMask(
|
---|
4554 | PACCESS_MASK AccessMask,
|
---|
4555 | PGENERIC_MAPPING GenericMapping
|
---|
4556 | );
|
---|
4557 | //
|
---|
4558 | // SecurityDescriptor RTL routine definitions
|
---|
4559 | //
|
---|
4560 |
|
---|
4561 | NTSYSAPI
|
---|
4562 | NTSTATUS
|
---|
4563 | NTAPI
|
---|
4564 | RtlCreateSecurityDescriptor (
|
---|
4565 | PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
4566 | ULONG Revision
|
---|
4567 | );
|
---|
4568 |
|
---|
4569 |
|
---|
4570 | NTSYSAPI
|
---|
4571 | BOOLEAN
|
---|
4572 | NTAPI
|
---|
4573 | RtlValidSecurityDescriptor (
|
---|
4574 | PSECURITY_DESCRIPTOR SecurityDescriptor
|
---|
4575 | );
|
---|
4576 |
|
---|
4577 |
|
---|
4578 | NTSYSAPI
|
---|
4579 | ULONG
|
---|
4580 | NTAPI
|
---|
4581 | RtlLengthSecurityDescriptor (
|
---|
4582 | PSECURITY_DESCRIPTOR SecurityDescriptor
|
---|
4583 | );
|
---|
4584 |
|
---|
4585 | NTSYSAPI
|
---|
4586 | BOOLEAN
|
---|
4587 | NTAPI
|
---|
4588 | RtlValidRelativeSecurityDescriptor (
|
---|
4589 | IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
|
---|
4590 | IN ULONG SecurityDescriptorLength,
|
---|
4591 | IN SECURITY_INFORMATION RequiredInformation
|
---|
4592 | );
|
---|
4593 |
|
---|
4594 |
|
---|
4595 | NTSYSAPI
|
---|
4596 | NTSTATUS
|
---|
4597 | NTAPI
|
---|
4598 | RtlSetDaclSecurityDescriptor (
|
---|
4599 | PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
4600 | BOOLEAN DaclPresent,
|
---|
4601 | PACL Dacl,
|
---|
4602 | BOOLEAN DaclDefaulted
|
---|
4603 | );
|
---|
4604 |
|
---|
4605 |
|
---|
4606 | //
|
---|
4607 | // Range list package
|
---|
4608 | //
|
---|
4609 |
|
---|
4610 | typedef struct _RTL_RANGE {
|
---|
4611 |
|
---|
4612 | //
|
---|
4613 | // The start of the range
|
---|
4614 | //
|
---|
4615 | ULONGLONG Start; // Read only
|
---|
4616 |
|
---|
4617 | //
|
---|
4618 | // The end of the range
|
---|
4619 | //
|
---|
4620 | ULONGLONG End; // Read only
|
---|
4621 |
|
---|
4622 | //
|
---|
4623 | // Data the user passed in when they created the range
|
---|
4624 | //
|
---|
4625 | PVOID UserData; // Read/Write
|
---|
4626 |
|
---|
4627 | //
|
---|
4628 | // The owner of the range
|
---|
4629 | //
|
---|
4630 | PVOID Owner; // Read/Write
|
---|
4631 |
|
---|
4632 | //
|
---|
4633 | // User defined flags the user specified when they created the range
|
---|
4634 | //
|
---|
4635 | UCHAR Attributes; // Read/Write
|
---|
4636 |
|
---|
4637 | //
|
---|
4638 | // Flags (RTL_RANGE_*)
|
---|
4639 | //
|
---|
4640 | UCHAR Flags; // Read only
|
---|
4641 |
|
---|
4642 | } RTL_RANGE, *PRTL_RANGE;
|
---|
4643 |
|
---|
4644 |
|
---|
4645 | #define RTL_RANGE_SHARED 0x01
|
---|
4646 | #define RTL_RANGE_CONFLICT 0x02
|
---|
4647 |
|
---|
4648 | typedef struct _RTL_RANGE_LIST {
|
---|
4649 |
|
---|
4650 | //
|
---|
4651 | // The list of ranges
|
---|
4652 | //
|
---|
4653 | LIST_ENTRY ListHead;
|
---|
4654 |
|
---|
4655 | //
|
---|
4656 | // These always come in useful
|
---|
4657 | //
|
---|
4658 | ULONG Flags; // use RANGE_LIST_FLAG_*
|
---|
4659 |
|
---|
4660 | //
|
---|
4661 | // The number of entries in the list
|
---|
4662 | //
|
---|
4663 | ULONG Count;
|
---|
4664 |
|
---|
4665 | //
|
---|
4666 | // Every time an add/delete operation is performed on the list this is
|
---|
4667 | // incremented. It is checked during iteration to ensure that the list
|
---|
4668 | // hasn't changed between GetFirst/GetNext or GetNext/GetNext calls
|
---|
4669 | //
|
---|
4670 | ULONG Stamp;
|
---|
4671 |
|
---|
4672 | } RTL_RANGE_LIST, *PRTL_RANGE_LIST;
|
---|
4673 |
|
---|
4674 | typedef struct _RANGE_LIST_ITERATOR {
|
---|
4675 |
|
---|
4676 | PLIST_ENTRY RangeListHead;
|
---|
4677 | PLIST_ENTRY MergedHead;
|
---|
4678 | PVOID Current;
|
---|
4679 | ULONG Stamp;
|
---|
4680 |
|
---|
4681 | } RTL_RANGE_LIST_ITERATOR, *PRTL_RANGE_LIST_ITERATOR;
|
---|
4682 |
|
---|
4683 |
|
---|
4684 | NTSYSAPI
|
---|
4685 | VOID
|
---|
4686 | NTAPI
|
---|
4687 | RtlInitializeRangeList(
|
---|
4688 | IN OUT PRTL_RANGE_LIST RangeList
|
---|
4689 | );
|
---|
4690 |
|
---|
4691 | NTSYSAPI
|
---|
4692 | VOID
|
---|
4693 | NTAPI
|
---|
4694 | RtlFreeRangeList(
|
---|
4695 | IN PRTL_RANGE_LIST RangeList
|
---|
4696 | );
|
---|
4697 |
|
---|
4698 | NTSYSAPI
|
---|
4699 | NTSTATUS
|
---|
4700 | NTAPI
|
---|
4701 | RtlCopyRangeList(
|
---|
4702 | OUT PRTL_RANGE_LIST CopyRangeList,
|
---|
4703 | IN PRTL_RANGE_LIST RangeList
|
---|
4704 | );
|
---|
4705 |
|
---|
4706 | #define RTL_RANGE_LIST_ADD_IF_CONFLICT 0x00000001
|
---|
4707 | #define RTL_RANGE_LIST_ADD_SHARED 0x00000002
|
---|
4708 |
|
---|
4709 | NTSYSAPI
|
---|
4710 | NTSTATUS
|
---|
4711 | NTAPI
|
---|
4712 | RtlAddRange(
|
---|
4713 | IN OUT PRTL_RANGE_LIST RangeList,
|
---|
4714 | IN ULONGLONG Start,
|
---|
4715 | IN ULONGLONG End,
|
---|
4716 | IN UCHAR Attributes,
|
---|
4717 | IN ULONG Flags,
|
---|
4718 | IN PVOID UserData, OPTIONAL
|
---|
4719 | IN PVOID Owner OPTIONAL
|
---|
4720 | );
|
---|
4721 |
|
---|
4722 | NTSYSAPI
|
---|
4723 | NTSTATUS
|
---|
4724 | NTAPI
|
---|
4725 | RtlDeleteRange(
|
---|
4726 | IN OUT PRTL_RANGE_LIST RangeList,
|
---|
4727 | IN ULONGLONG Start,
|
---|
4728 | IN ULONGLONG End,
|
---|
4729 | IN PVOID Owner
|
---|
4730 | );
|
---|
4731 |
|
---|
4732 | NTSYSAPI
|
---|
4733 | NTSTATUS
|
---|
4734 | NTAPI
|
---|
4735 | RtlDeleteOwnersRanges(
|
---|
4736 | IN OUT PRTL_RANGE_LIST RangeList,
|
---|
4737 | IN PVOID Owner
|
---|
4738 | );
|
---|
4739 |
|
---|
4740 | #define RTL_RANGE_LIST_SHARED_OK 0x00000001
|
---|
4741 | #define RTL_RANGE_LIST_NULL_CONFLICT_OK 0x00000002
|
---|
4742 |
|
---|
4743 | typedef
|
---|
4744 | BOOLEAN
|
---|
4745 | (*PRTL_CONFLICT_RANGE_CALLBACK) (
|
---|
4746 | IN PVOID Context,
|
---|
4747 | IN PRTL_RANGE Range
|
---|
4748 | );
|
---|
4749 |
|
---|
4750 | NTSYSAPI
|
---|
4751 | NTSTATUS
|
---|
4752 | NTAPI
|
---|
4753 | RtlFindRange(
|
---|
4754 | IN PRTL_RANGE_LIST RangeList,
|
---|
4755 | IN ULONGLONG Minimum,
|
---|
4756 | IN ULONGLONG Maximum,
|
---|
4757 | IN ULONG Length,
|
---|
4758 | IN ULONG Alignment,
|
---|
4759 | IN ULONG Flags,
|
---|
4760 | IN UCHAR AttributeAvailableMask,
|
---|
4761 | IN PVOID Context OPTIONAL,
|
---|
4762 | IN PRTL_CONFLICT_RANGE_CALLBACK Callback OPTIONAL,
|
---|
4763 | OUT PULONGLONG Start
|
---|
4764 | );
|
---|
4765 |
|
---|
4766 | NTSYSAPI
|
---|
4767 | NTSTATUS
|
---|
4768 | NTAPI
|
---|
4769 | RtlIsRangeAvailable(
|
---|
4770 | IN PRTL_RANGE_LIST RangeList,
|
---|
4771 | IN ULONGLONG Start,
|
---|
4772 | IN ULONGLONG End,
|
---|
4773 | IN ULONG Flags,
|
---|
4774 | IN UCHAR AttributeAvailableMask,
|
---|
4775 | IN PVOID Context OPTIONAL,
|
---|
4776 | IN PRTL_CONFLICT_RANGE_CALLBACK Callback OPTIONAL,
|
---|
4777 | OUT PBOOLEAN Available
|
---|
4778 | );
|
---|
4779 |
|
---|
4780 | #define FOR_ALL_RANGES(RangeList, Iterator, Current) \
|
---|
4781 | for (RtlGetFirstRange((RangeList), (Iterator), &(Current)); \
|
---|
4782 | (Current) != NULL; \
|
---|
4783 | RtlGetNextRange((Iterator), &(Current), TRUE) \
|
---|
4784 | )
|
---|
4785 |
|
---|
4786 | #define FOR_ALL_RANGES_BACKWARDS(RangeList, Iterator, Current) \
|
---|
4787 | for (RtlGetLastRange((RangeList), (Iterator), &(Current)); \
|
---|
4788 | (Current) != NULL; \
|
---|
4789 | RtlGetNextRange((Iterator), &(Current), FALSE) \
|
---|
4790 | )
|
---|
4791 |
|
---|
4792 | NTSYSAPI
|
---|
4793 | NTSTATUS
|
---|
4794 | NTAPI
|
---|
4795 | RtlGetFirstRange(
|
---|
4796 | IN PRTL_RANGE_LIST RangeList,
|
---|
4797 | OUT PRTL_RANGE_LIST_ITERATOR Iterator,
|
---|
4798 | OUT PRTL_RANGE *Range
|
---|
4799 | );
|
---|
4800 |
|
---|
4801 | NTSYSAPI
|
---|
4802 | NTSTATUS
|
---|
4803 | NTAPI
|
---|
4804 | RtlGetLastRange(
|
---|
4805 | IN PRTL_RANGE_LIST RangeList,
|
---|
4806 | OUT PRTL_RANGE_LIST_ITERATOR Iterator,
|
---|
4807 | OUT PRTL_RANGE *Range
|
---|
4808 | );
|
---|
4809 |
|
---|
4810 | NTSYSAPI
|
---|
4811 | NTSTATUS
|
---|
4812 | NTAPI
|
---|
4813 | RtlGetNextRange(
|
---|
4814 | IN OUT PRTL_RANGE_LIST_ITERATOR Iterator,
|
---|
4815 | OUT PRTL_RANGE *Range,
|
---|
4816 | IN BOOLEAN MoveForwards
|
---|
4817 | );
|
---|
4818 |
|
---|
4819 | #define RTL_RANGE_LIST_MERGE_IF_CONFLICT RTL_RANGE_LIST_ADD_IF_CONFLICT
|
---|
4820 |
|
---|
4821 | NTSYSAPI
|
---|
4822 | NTSTATUS
|
---|
4823 | NTAPI
|
---|
4824 | RtlMergeRangeLists(
|
---|
4825 | OUT PRTL_RANGE_LIST MergedRangeList,
|
---|
4826 | IN PRTL_RANGE_LIST RangeList1,
|
---|
4827 | IN PRTL_RANGE_LIST RangeList2,
|
---|
4828 | IN ULONG Flags
|
---|
4829 | );
|
---|
4830 |
|
---|
4831 | NTSYSAPI
|
---|
4832 | NTSTATUS
|
---|
4833 | NTAPI
|
---|
4834 | RtlInvertRangeList(
|
---|
4835 | OUT PRTL_RANGE_LIST InvertedRangeList,
|
---|
4836 | IN PRTL_RANGE_LIST RangeList
|
---|
4837 | );
|
---|
4838 |
|
---|
4839 |
|
---|
4840 |
|
---|
4841 |
|
---|
4842 |
|
---|
4843 | //
|
---|
4844 | // Byte swap routines. These are used to convert from little-endian to
|
---|
4845 | // big-endian and vice-versa.
|
---|
4846 | //
|
---|
4847 |
|
---|
4848 | #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
|
---|
4849 | #ifdef __cplusplus
|
---|
4850 | extern "C" {
|
---|
4851 | #endif
|
---|
4852 | unsigned short __cdecl _byteswap_ushort(unsigned short);
|
---|
4853 | unsigned long __cdecl _byteswap_ulong (unsigned long);
|
---|
4854 | unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
|
---|
4855 | #ifdef __cplusplus
|
---|
4856 | }
|
---|
4857 | #endif
|
---|
4858 | #pragma intrinsic(_byteswap_ushort)
|
---|
4859 | #pragma intrinsic(_byteswap_ulong)
|
---|
4860 | #pragma intrinsic(_byteswap_uint64)
|
---|
4861 |
|
---|
4862 | #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
|
---|
4863 | #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
|
---|
4864 | #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
|
---|
4865 | #else
|
---|
4866 | USHORT
|
---|
4867 | FASTCALL
|
---|
4868 | RtlUshortByteSwap(
|
---|
4869 | IN USHORT Source
|
---|
4870 | );
|
---|
4871 |
|
---|
4872 | ULONG
|
---|
4873 | FASTCALL
|
---|
4874 | RtlUlongByteSwap(
|
---|
4875 | IN ULONG Source
|
---|
4876 | );
|
---|
4877 |
|
---|
4878 | ULONGLONG
|
---|
4879 | FASTCALL
|
---|
4880 | RtlUlonglongByteSwap(
|
---|
4881 | IN ULONGLONG Source
|
---|
4882 | );
|
---|
4883 | #endif
|
---|
4884 |
|
---|
4885 |
|
---|
4886 |
|
---|
4887 |
|
---|
4888 |
|
---|
4889 | //
|
---|
4890 | // Routine for converting from a volume device object to a DOS name.
|
---|
4891 | //
|
---|
4892 |
|
---|
4893 | NTSYSAPI
|
---|
4894 | NTSTATUS
|
---|
4895 | NTAPI
|
---|
4896 | RtlVolumeDeviceToDosName(
|
---|
4897 | IN PVOID VolumeDeviceObject,
|
---|
4898 | OUT PUNICODE_STRING DosName
|
---|
4899 | );
|
---|
4900 |
|
---|
4901 | typedef struct _OSVERSIONINFOA {
|
---|
4902 | ULONG dwOSVersionInfoSize;
|
---|
4903 | ULONG dwMajorVersion;
|
---|
4904 | ULONG dwMinorVersion;
|
---|
4905 | ULONG dwBuildNumber;
|
---|
4906 | ULONG dwPlatformId;
|
---|
4907 | CHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
|
---|
4908 | } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
|
---|
4909 |
|
---|
4910 | typedef struct _OSVERSIONINFOW {
|
---|
4911 | ULONG dwOSVersionInfoSize;
|
---|
4912 | ULONG dwMajorVersion;
|
---|
4913 | ULONG dwMinorVersion;
|
---|
4914 | ULONG dwBuildNumber;
|
---|
4915 | ULONG dwPlatformId;
|
---|
4916 | WCHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
|
---|
4917 | } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
|
---|
4918 | #ifdef UNICODE
|
---|
4919 | typedef OSVERSIONINFOW OSVERSIONINFO;
|
---|
4920 | typedef POSVERSIONINFOW POSVERSIONINFO;
|
---|
4921 | typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
|
---|
4922 | #else
|
---|
4923 | typedef OSVERSIONINFOA OSVERSIONINFO;
|
---|
4924 | typedef POSVERSIONINFOA POSVERSIONINFO;
|
---|
4925 | typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
|
---|
4926 | #endif // UNICODE
|
---|
4927 |
|
---|
4928 | typedef struct _OSVERSIONINFOEXA {
|
---|
4929 | ULONG dwOSVersionInfoSize;
|
---|
4930 | ULONG dwMajorVersion;
|
---|
4931 | ULONG dwMinorVersion;
|
---|
4932 | ULONG dwBuildNumber;
|
---|
4933 | ULONG dwPlatformId;
|
---|
4934 | CHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
|
---|
4935 | USHORT wServicePackMajor;
|
---|
4936 | USHORT wServicePackMinor;
|
---|
4937 | USHORT wSuiteMask;
|
---|
4938 | UCHAR wProductType;
|
---|
4939 | UCHAR wReserved;
|
---|
4940 | } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
|
---|
4941 | typedef struct _OSVERSIONINFOEXW {
|
---|
4942 | ULONG dwOSVersionInfoSize;
|
---|
4943 | ULONG dwMajorVersion;
|
---|
4944 | ULONG dwMinorVersion;
|
---|
4945 | ULONG dwBuildNumber;
|
---|
4946 | ULONG dwPlatformId;
|
---|
4947 | WCHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
|
---|
4948 | USHORT wServicePackMajor;
|
---|
4949 | USHORT wServicePackMinor;
|
---|
4950 | USHORT wSuiteMask;
|
---|
4951 | UCHAR wProductType;
|
---|
4952 | UCHAR wReserved;
|
---|
4953 | } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
|
---|
4954 | #ifdef UNICODE
|
---|
4955 | typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
|
---|
4956 | typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
|
---|
4957 | typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
|
---|
4958 | #else
|
---|
4959 | typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
|
---|
4960 | typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
|
---|
4961 | typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
|
---|
4962 | #endif // UNICODE
|
---|
4963 |
|
---|
4964 | //
|
---|
4965 | // RtlVerifyVersionInfo() conditions
|
---|
4966 | //
|
---|
4967 |
|
---|
4968 | #define VER_EQUAL 1
|
---|
4969 | #define VER_GREATER 2
|
---|
4970 | #define VER_GREATER_EQUAL 3
|
---|
4971 | #define VER_LESS 4
|
---|
4972 | #define VER_LESS_EQUAL 5
|
---|
4973 | #define VER_AND 6
|
---|
4974 | #define VER_OR 7
|
---|
4975 |
|
---|
4976 | #define VER_CONDITION_MASK 7
|
---|
4977 | #define VER_NUM_BITS_PER_CONDITION_MASK 3
|
---|
4978 |
|
---|
4979 | //
|
---|
4980 | // RtlVerifyVersionInfo() type mask bits
|
---|
4981 | //
|
---|
4982 |
|
---|
4983 | #define VER_MINORVERSION 0x0000001
|
---|
4984 | #define VER_MAJORVERSION 0x0000002
|
---|
4985 | #define VER_BUILDNUMBER 0x0000004
|
---|
4986 | #define VER_PLATFORMID 0x0000008
|
---|
4987 | #define VER_SERVICEPACKMINOR 0x0000010
|
---|
4988 | #define VER_SERVICEPACKMAJOR 0x0000020
|
---|
4989 | #define VER_SUITENAME 0x0000040
|
---|
4990 | #define VER_PRODUCT_TYPE 0x0000080
|
---|
4991 |
|
---|
4992 | //
|
---|
4993 | // RtlVerifyVersionInfo() os product type values
|
---|
4994 | //
|
---|
4995 |
|
---|
4996 | #define VER_NT_WORKSTATION 0x0000001
|
---|
4997 | #define VER_NT_DOMAIN_CONTROLLER 0x0000002
|
---|
4998 | #define VER_NT_SERVER 0x0000003
|
---|
4999 |
|
---|
5000 | //
|
---|
5001 | // dwPlatformId defines:
|
---|
5002 | //
|
---|
5003 |
|
---|
5004 | #define VER_PLATFORM_WIN32s 0
|
---|
5005 | #define VER_PLATFORM_WIN32_WINDOWS 1
|
---|
5006 | #define VER_PLATFORM_WIN32_NT 2
|
---|
5007 |
|
---|
5008 |
|
---|
5009 | //
|
---|
5010 | //
|
---|
5011 | // VerifyVersionInfo() macro to set the condition mask
|
---|
5012 | //
|
---|
5013 | // For documentation sakes here's the old version of the macro that got
|
---|
5014 | // changed to call an API
|
---|
5015 | // #define VER_SET_CONDITION(_m_,_t_,_c_) _m_=(_m_|(_c_<<(1<<_t_)))
|
---|
5016 | //
|
---|
5017 |
|
---|
5018 | #define VER_SET_CONDITION(_m_,_t_,_c_) \
|
---|
5019 | ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
|
---|
5020 |
|
---|
5021 | ULONGLONG
|
---|
5022 | NTAPI
|
---|
5023 | VerSetConditionMask(
|
---|
5024 | IN ULONGLONG ConditionMask,
|
---|
5025 | IN ULONG TypeMask,
|
---|
5026 | IN UCHAR Condition
|
---|
5027 | );
|
---|
5028 | //
|
---|
5029 |
|
---|
5030 | //
|
---|
5031 |
|
---|
5032 | NTSYSAPI
|
---|
5033 | NTSTATUS
|
---|
5034 | RtlGetVersion(
|
---|
5035 | OUT PRTL_OSVERSIONINFOW lpVersionInformation
|
---|
5036 | );
|
---|
5037 |
|
---|
5038 | NTSYSAPI
|
---|
5039 | NTSTATUS
|
---|
5040 | RtlVerifyVersionInfo(
|
---|
5041 | IN PRTL_OSVERSIONINFOEXW VersionInfo,
|
---|
5042 | IN ULONG TypeMask,
|
---|
5043 | IN ULONGLONG ConditionMask
|
---|
5044 | );
|
---|
5045 |
|
---|
5046 | //
|
---|
5047 | //
|
---|
5048 | // Interlocked bit manipulation interfaces
|
---|
5049 | //
|
---|
5050 |
|
---|
5051 | #define RtlInterlockedSetBits(Flags, Flag) \
|
---|
5052 | InterlockedOr((PLONG)(Flags), Flag)
|
---|
5053 |
|
---|
5054 | #define RtlInterlockedAndBits(Flags, Flag) \
|
---|
5055 | InterlockedAnd((PLONG)(Flags), Flag)
|
---|
5056 |
|
---|
5057 | #define RtlInterlockedClearBits(Flags, Flag) \
|
---|
5058 | RtlInterlockedAndBits(Flags, ~(Flag))
|
---|
5059 |
|
---|
5060 | #define RtlInterlockedXorBits(Flags, Flag) \
|
---|
5061 | InterlockedXor(Flags, Flag)
|
---|
5062 |
|
---|
5063 | #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
|
---|
5064 | (VOID) RtlInterlockedSetBits(Flags, Flag)
|
---|
5065 |
|
---|
5066 | #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
|
---|
5067 | (VOID) RtlInterlockedAndBits(Flags, Flag)
|
---|
5068 |
|
---|
5069 | #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
|
---|
5070 | RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
|
---|
5071 |
|
---|
5072 | //
|
---|
5073 | // Component name filter id enumeration and levels.
|
---|
5074 | //
|
---|
5075 |
|
---|
5076 | #define DPFLTR_ERROR_LEVEL 0
|
---|
5077 | #define DPFLTR_WARNING_LEVEL 1
|
---|
5078 | #define DPFLTR_TRACE_LEVEL 2
|
---|
5079 | #define DPFLTR_INFO_LEVEL 3
|
---|
5080 | #define DPFLTR_MASK 0x80000000
|
---|
5081 |
|
---|
5082 | typedef enum _DPFLTR_TYPE {
|
---|
5083 | DPFLTR_SYSTEM_ID = 0,
|
---|
5084 | DPFLTR_SMSS_ID = 1,
|
---|
5085 | DPFLTR_SETUP_ID = 2,
|
---|
5086 | DPFLTR_NTFS_ID = 3,
|
---|
5087 | DPFLTR_FSTUB_ID = 4,
|
---|
5088 | DPFLTR_CRASHDUMP_ID = 5,
|
---|
5089 | DPFLTR_CDAUDIO_ID = 6,
|
---|
5090 | DPFLTR_CDROM_ID = 7,
|
---|
5091 | DPFLTR_CLASSPNP_ID = 8,
|
---|
5092 | DPFLTR_DISK_ID = 9,
|
---|
5093 | DPFLTR_REDBOOK_ID = 10,
|
---|
5094 | DPFLTR_STORPROP_ID = 11,
|
---|
5095 | DPFLTR_SCSIPORT_ID = 12,
|
---|
5096 | DPFLTR_SCSIMINIPORT_ID = 13,
|
---|
5097 | DPFLTR_CONFIG_ID = 14,
|
---|
5098 | DPFLTR_I8042PRT_ID = 15,
|
---|
5099 | DPFLTR_SERMOUSE_ID = 16,
|
---|
5100 | DPFLTR_LSERMOUS_ID = 17,
|
---|
5101 | DPFLTR_KBDHID_ID = 18,
|
---|
5102 | DPFLTR_MOUHID_ID = 19,
|
---|
5103 | DPFLTR_KBDCLASS_ID = 20,
|
---|
5104 | DPFLTR_MOUCLASS_ID = 21,
|
---|
5105 | DPFLTR_TWOTRACK_ID = 22,
|
---|
5106 | DPFLTR_WMILIB_ID = 23,
|
---|
5107 | DPFLTR_ACPI_ID = 24,
|
---|
5108 | DPFLTR_AMLI_ID = 25,
|
---|
5109 | DPFLTR_HALIA64_ID = 26,
|
---|
5110 | DPFLTR_VIDEO_ID = 27,
|
---|
5111 | DPFLTR_SVCHOST_ID = 28,
|
---|
5112 | DPFLTR_VIDEOPRT_ID = 29,
|
---|
5113 | DPFLTR_TCPIP_ID = 30,
|
---|
5114 | DPFLTR_DMSYNTH_ID = 31,
|
---|
5115 | DPFLTR_NTOSPNP_ID = 32,
|
---|
5116 | DPFLTR_FASTFAT_ID = 33,
|
---|
5117 | DPFLTR_SAMSS_ID = 34,
|
---|
5118 | DPFLTR_PNPMGR_ID = 35,
|
---|
5119 | DPFLTR_NETAPI_ID = 36,
|
---|
5120 | DPFLTR_SCSERVER_ID = 37,
|
---|
5121 | DPFLTR_SCCLIENT_ID = 38,
|
---|
5122 | DPFLTR_SERIAL_ID = 39,
|
---|
5123 | DPFLTR_SERENUM_ID = 40,
|
---|
5124 | DPFLTR_UHCD_ID = 41,
|
---|
5125 | DPFLTR_RPCPROXY_ID = 42,
|
---|
5126 | DPFLTR_AUTOCHK_ID = 43,
|
---|
5127 | DPFLTR_DCOMSS_ID = 44,
|
---|
5128 | DPFLTR_UNIMODEM_ID = 45,
|
---|
5129 | DPFLTR_SIS_ID = 46,
|
---|
5130 | DPFLTR_FLTMGR_ID = 47,
|
---|
5131 | DPFLTR_WMICORE_ID = 48,
|
---|
5132 | DPFLTR_BURNENG_ID = 49,
|
---|
5133 | DPFLTR_IMAPI_ID = 50,
|
---|
5134 | DPFLTR_SXS_ID = 51,
|
---|
5135 | DPFLTR_FUSION_ID = 52,
|
---|
5136 | DPFLTR_IDLETASK_ID = 53,
|
---|
5137 | DPFLTR_SOFTPCI_ID = 54,
|
---|
5138 | DPFLTR_TAPE_ID = 55,
|
---|
5139 | DPFLTR_MCHGR_ID = 56,
|
---|
5140 | DPFLTR_IDEP_ID = 57,
|
---|
5141 | DPFLTR_PCIIDE_ID = 58,
|
---|
5142 | DPFLTR_FLOPPY_ID = 59,
|
---|
5143 | DPFLTR_FDC_ID = 60,
|
---|
5144 | DPFLTR_TERMSRV_ID = 61,
|
---|
5145 | DPFLTR_W32TIME_ID = 62,
|
---|
5146 | DPFLTR_PREFETCHER_ID = 63,
|
---|
5147 | DPFLTR_RSFILTER_ID = 64,
|
---|
5148 | DPFLTR_FCPORT_ID = 65,
|
---|
5149 | DPFLTR_PCI_ID = 66,
|
---|
5150 | DPFLTR_DMIO_ID = 67,
|
---|
5151 | DPFLTR_DMCONFIG_ID = 68,
|
---|
5152 | DPFLTR_DMADMIN_ID = 69,
|
---|
5153 | DPFLTR_WSOCKTRANSPORT_ID = 70,
|
---|
5154 | DPFLTR_VSS_ID = 71,
|
---|
5155 | DPFLTR_PNPMEM_ID = 72,
|
---|
5156 | DPFLTR_PROCESSOR_ID = 73,
|
---|
5157 | DPFLTR_DMSERVER_ID = 74,
|
---|
5158 | DPFLTR_SR_ID = 75,
|
---|
5159 | DPFLTR_INFINIBAND_ID = 76,
|
---|
5160 | DPFLTR_IHVDRIVER_ID = 77,
|
---|
5161 | DPFLTR_IHVVIDEO_ID = 78,
|
---|
5162 | DPFLTR_IHVAUDIO_ID = 79,
|
---|
5163 | DPFLTR_IHVNETWORK_ID = 80,
|
---|
5164 | DPFLTR_IHVSTREAMING_ID = 81,
|
---|
5165 | DPFLTR_IHVBUS_ID = 82,
|
---|
5166 | DPFLTR_HPS_ID = 83,
|
---|
5167 | DPFLTR_RTLTHREADPOOL_ID = 84,
|
---|
5168 | DPFLTR_LDR_ID = 85,
|
---|
5169 | DPFLTR_TCPIP6_ID = 86,
|
---|
5170 | DPFLTR_ISAPNP_ID = 87,
|
---|
5171 | DPFLTR_SHPC_ID = 88,
|
---|
5172 | DPFLTR_STORPORT_ID = 89,
|
---|
5173 | DPFLTR_STORMINIPORT_ID = 90,
|
---|
5174 | DPFLTR_PRINTSPOOLER_ID = 91,
|
---|
5175 | DPFLTR_VSSDYNDISK_ID = 92,
|
---|
5176 | DPFLTR_VERIFIER_ID = 93,
|
---|
5177 | DPFLTR_VDS_ID = 94,
|
---|
5178 | DPFLTR_VDSBAS_ID = 95,
|
---|
5179 | DPFLTR_VDSDYNDR_ID = 96,
|
---|
5180 | DPFLTR_VDSUTIL_ID = 97,
|
---|
5181 | DPFLTR_DFRGIFC_ID = 98,
|
---|
5182 | DPFLTR_ENDOFTABLE_ID
|
---|
5183 | } DPFLTR_TYPE;
|
---|
5184 |
|
---|
5185 | //
|
---|
5186 | // Define the various device type values. Note that values used by Microsoft
|
---|
5187 | // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
|
---|
5188 | // by customers.
|
---|
5189 | //
|
---|
5190 |
|
---|
5191 | #define DEVICE_TYPE ULONG
|
---|
5192 |
|
---|
5193 | #define FILE_DEVICE_BEEP 0x00000001
|
---|
5194 | #define FILE_DEVICE_CD_ROM 0x00000002
|
---|
5195 | #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
|
---|
5196 | #define FILE_DEVICE_CONTROLLER 0x00000004
|
---|
5197 | #define FILE_DEVICE_DATALINK 0x00000005
|
---|
5198 | #define FILE_DEVICE_DFS 0x00000006
|
---|
5199 | #define FILE_DEVICE_DISK 0x00000007
|
---|
5200 | #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
|
---|
5201 | #define FILE_DEVICE_FILE_SYSTEM 0x00000009
|
---|
5202 | #define FILE_DEVICE_INPORT_PORT 0x0000000a
|
---|
5203 | #define FILE_DEVICE_KEYBOARD 0x0000000b
|
---|
5204 | #define FILE_DEVICE_MAILSLOT 0x0000000c
|
---|
5205 | #define FILE_DEVICE_MIDI_IN 0x0000000d
|
---|
5206 | #define FILE_DEVICE_MIDI_OUT 0x0000000e
|
---|
5207 | #define FILE_DEVICE_MOUSE 0x0000000f
|
---|
5208 | #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
|
---|
5209 | #define FILE_DEVICE_NAMED_PIPE 0x00000011
|
---|
5210 | #define FILE_DEVICE_NETWORK 0x00000012
|
---|
5211 | #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
|
---|
5212 | #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
|
---|
5213 | #define FILE_DEVICE_NULL 0x00000015
|
---|
5214 | #define FILE_DEVICE_PARALLEL_PORT 0x00000016
|
---|
5215 | #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
|
---|
5216 | #define FILE_DEVICE_PRINTER 0x00000018
|
---|
5217 | #define FILE_DEVICE_SCANNER 0x00000019
|
---|
5218 | #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
|
---|
5219 | #define FILE_DEVICE_SERIAL_PORT 0x0000001b
|
---|
5220 | #define FILE_DEVICE_SCREEN 0x0000001c
|
---|
5221 | #define FILE_DEVICE_SOUND 0x0000001d
|
---|
5222 | #define FILE_DEVICE_STREAMS 0x0000001e
|
---|
5223 | #define FILE_DEVICE_TAPE 0x0000001f
|
---|
5224 | #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
|
---|
5225 | #define FILE_DEVICE_TRANSPORT 0x00000021
|
---|
5226 | #define FILE_DEVICE_UNKNOWN 0x00000022
|
---|
5227 | #define FILE_DEVICE_VIDEO 0x00000023
|
---|
5228 | #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
|
---|
5229 | #define FILE_DEVICE_WAVE_IN 0x00000025
|
---|
5230 | #define FILE_DEVICE_WAVE_OUT 0x00000026
|
---|
5231 | #define FILE_DEVICE_8042_PORT 0x00000027
|
---|
5232 | #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
|
---|
5233 | #define FILE_DEVICE_BATTERY 0x00000029
|
---|
5234 | #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
|
---|
5235 | #define FILE_DEVICE_MODEM 0x0000002b
|
---|
5236 | #define FILE_DEVICE_VDM 0x0000002c
|
---|
5237 | #define FILE_DEVICE_MASS_STORAGE 0x0000002d
|
---|
5238 | #define FILE_DEVICE_SMB 0x0000002e
|
---|
5239 | #define FILE_DEVICE_KS 0x0000002f
|
---|
5240 | #define FILE_DEVICE_CHANGER 0x00000030
|
---|
5241 | #define FILE_DEVICE_SMARTCARD 0x00000031
|
---|
5242 | #define FILE_DEVICE_ACPI 0x00000032
|
---|
5243 | #define FILE_DEVICE_DVD 0x00000033
|
---|
5244 | #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
|
---|
5245 | #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
|
---|
5246 | #define FILE_DEVICE_DFS_VOLUME 0x00000036
|
---|
5247 | #define FILE_DEVICE_SERENUM 0x00000037
|
---|
5248 | #define FILE_DEVICE_TERMSRV 0x00000038
|
---|
5249 | #define FILE_DEVICE_KSEC 0x00000039
|
---|
5250 | #define FILE_DEVICE_FIPS 0x0000003A
|
---|
5251 | #define FILE_DEVICE_INFINIBAND 0x0000003B
|
---|
5252 |
|
---|
5253 | //
|
---|
5254 | // Macro definition for defining IOCTL and FSCTL function control codes. Note
|
---|
5255 | // that function codes 0-2047 are reserved for Microsoft Corporation, and
|
---|
5256 | // 2048-4095 are reserved for customers.
|
---|
5257 | //
|
---|
5258 |
|
---|
5259 | #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
|
---|
5260 | ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
|
---|
5261 | )
|
---|
5262 |
|
---|
5263 | //
|
---|
5264 | // Macro to extract device type out of the device io control code
|
---|
5265 | //
|
---|
5266 | #define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0xffff0000)) >> 16)
|
---|
5267 |
|
---|
5268 | //
|
---|
5269 | // Define the method codes for how buffers are passed for I/O and FS controls
|
---|
5270 | //
|
---|
5271 |
|
---|
5272 | #define METHOD_BUFFERED 0
|
---|
5273 | #define METHOD_IN_DIRECT 1
|
---|
5274 | #define METHOD_OUT_DIRECT 2
|
---|
5275 | #define METHOD_NEITHER 3
|
---|
5276 |
|
---|
5277 | //
|
---|
5278 | // Define some easier to comprehend aliases:
|
---|
5279 | // METHOD_DIRECT_TO_HARDWARE (writes, aka METHOD_IN_DIRECT)
|
---|
5280 | // METHOD_DIRECT_FROM_HARDWARE (reads, aka METHOD_OUT_DIRECT)
|
---|
5281 | //
|
---|
5282 |
|
---|
5283 | #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT
|
---|
5284 | #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT
|
---|
5285 |
|
---|
5286 | //
|
---|
5287 | // Define the access check value for any access
|
---|
5288 | //
|
---|
5289 | //
|
---|
5290 | // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
|
---|
5291 | // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
|
---|
5292 | // constants *MUST* always be in sync.
|
---|
5293 | //
|
---|
5294 | //
|
---|
5295 | // FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS.
|
---|
5296 | // The file systems, however, may add additional access checks for I/O and FS controls
|
---|
5297 | // that use this value.
|
---|
5298 | //
|
---|
5299 |
|
---|
5300 |
|
---|
5301 | #define FILE_ANY_ACCESS 0
|
---|
5302 | #define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS)
|
---|
5303 | #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
|
---|
5304 | #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
|
---|
5305 |
|
---|
5306 |
|
---|
5307 |
|
---|
5308 | //
|
---|
5309 | // Define access rights to files and directories
|
---|
5310 | //
|
---|
5311 |
|
---|
5312 | //
|
---|
5313 | // The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
|
---|
5314 | // devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
|
---|
5315 | // constants *MUST* always be in sync.
|
---|
5316 | // The values are redefined in devioctl.h because they must be available to
|
---|
5317 | // both DOS and NT.
|
---|
5318 | //
|
---|
5319 |
|
---|
5320 | #define FILE_READ_DATA ( 0x0001 ) // file & pipe
|
---|
5321 | #define FILE_LIST_DIRECTORY ( 0x0001 ) // directory
|
---|
5322 |
|
---|
5323 | #define FILE_WRITE_DATA ( 0x0002 ) // file & pipe
|
---|
5324 | #define FILE_ADD_FILE ( 0x0002 ) // directory
|
---|
5325 |
|
---|
5326 | #define FILE_APPEND_DATA ( 0x0004 ) // file
|
---|
5327 | #define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory
|
---|
5328 | #define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe
|
---|
5329 |
|
---|
5330 |
|
---|
5331 | #define FILE_READ_EA ( 0x0008 ) // file & directory
|
---|
5332 |
|
---|
5333 | #define FILE_WRITE_EA ( 0x0010 ) // file & directory
|
---|
5334 |
|
---|
5335 | #define FILE_EXECUTE ( 0x0020 ) // file
|
---|
5336 | #define FILE_TRAVERSE ( 0x0020 ) // directory
|
---|
5337 |
|
---|
5338 | #define FILE_DELETE_CHILD ( 0x0040 ) // directory
|
---|
5339 |
|
---|
5340 | #define FILE_READ_ATTRIBUTES ( 0x0080 ) // all
|
---|
5341 |
|
---|
5342 | #define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all
|
---|
5343 |
|
---|
5344 | #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
|
---|
5345 |
|
---|
5346 | #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
|
---|
5347 | FILE_READ_DATA |\
|
---|
5348 | FILE_READ_ATTRIBUTES |\
|
---|
5349 | FILE_READ_EA |\
|
---|
5350 | SYNCHRONIZE)
|
---|
5351 |
|
---|
5352 |
|
---|
5353 | #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
|
---|
5354 | FILE_WRITE_DATA |\
|
---|
5355 | FILE_WRITE_ATTRIBUTES |\
|
---|
5356 | FILE_WRITE_EA |\
|
---|
5357 | FILE_APPEND_DATA |\
|
---|
5358 | SYNCHRONIZE)
|
---|
5359 |
|
---|
5360 |
|
---|
5361 | #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
|
---|
5362 | FILE_READ_ATTRIBUTES |\
|
---|
5363 | FILE_EXECUTE |\
|
---|
5364 | SYNCHRONIZE)
|
---|
5365 |
|
---|
5366 |
|
---|
5367 |
|
---|
5368 |
|
---|
5369 | //
|
---|
5370 | // Define share access rights to files and directories
|
---|
5371 | //
|
---|
5372 |
|
---|
5373 | #define FILE_SHARE_READ 0x00000001
|
---|
5374 | #define FILE_SHARE_WRITE 0x00000002
|
---|
5375 | #define FILE_SHARE_DELETE 0x00000004
|
---|
5376 | #define FILE_SHARE_VALID_FLAGS 0x00000007
|
---|
5377 |
|
---|
5378 | //
|
---|
5379 | // Define the file attributes values
|
---|
5380 | //
|
---|
5381 | // Note: 0x00000008 is reserved for use for the old DOS VOLID (volume ID)
|
---|
5382 | // and is therefore not considered valid in NT.
|
---|
5383 | //
|
---|
5384 | // Note: 0x00000010 is reserved for use for the old DOS SUBDIRECTORY flag
|
---|
5385 | // and is therefore not considered valid in NT. This flag has
|
---|
5386 | // been disassociated with file attributes since the other flags are
|
---|
5387 | // protected with READ_ and WRITE_ATTRIBUTES access to the file.
|
---|
5388 | //
|
---|
5389 | // Note: Note also that the order of these flags is set to allow both the
|
---|
5390 | // FAT and the Pinball File Systems to directly set the attributes
|
---|
5391 | // flags in attributes words without having to pick each flag out
|
---|
5392 | // individually. The order of these flags should not be changed!
|
---|
5393 | //
|
---|
5394 |
|
---|
5395 | #define FILE_ATTRIBUTE_READONLY 0x00000001
|
---|
5396 | #define FILE_ATTRIBUTE_HIDDEN 0x00000002
|
---|
5397 | #define FILE_ATTRIBUTE_SYSTEM 0x00000004
|
---|
5398 | //OLD DOS VOLID 0x00000008
|
---|
5399 |
|
---|
5400 | #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
|
---|
5401 | #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
|
---|
5402 | #define FILE_ATTRIBUTE_DEVICE 0x00000040
|
---|
5403 | #define FILE_ATTRIBUTE_NORMAL 0x00000080
|
---|
5404 |
|
---|
5405 | #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
|
---|
5406 | #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
|
---|
5407 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
|
---|
5408 | #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
|
---|
5409 |
|
---|
5410 | #define FILE_ATTRIBUTE_OFFLINE 0x00001000
|
---|
5411 | #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
|
---|
5412 | #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
|
---|
5413 |
|
---|
5414 | #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
|
---|
5415 | #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
|
---|
5416 |
|
---|
5417 | //
|
---|
5418 | // Define the create disposition values
|
---|
5419 | //
|
---|
5420 |
|
---|
5421 | #define FILE_SUPERSEDE 0x00000000
|
---|
5422 | #define FILE_OPEN 0x00000001
|
---|
5423 | #define FILE_CREATE 0x00000002
|
---|
5424 | #define FILE_OPEN_IF 0x00000003
|
---|
5425 | #define FILE_OVERWRITE 0x00000004
|
---|
5426 | #define FILE_OVERWRITE_IF 0x00000005
|
---|
5427 | #define FILE_MAXIMUM_DISPOSITION 0x00000005
|
---|
5428 |
|
---|
5429 | //
|
---|
5430 | // Define the create/open option flags
|
---|
5431 | //
|
---|
5432 |
|
---|
5433 | #define FILE_DIRECTORY_FILE 0x00000001
|
---|
5434 | #define FILE_WRITE_THROUGH 0x00000002
|
---|
5435 | #define FILE_SEQUENTIAL_ONLY 0x00000004
|
---|
5436 | #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
|
---|
5437 |
|
---|
5438 | #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
|
---|
5439 | #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
|
---|
5440 | #define FILE_NON_DIRECTORY_FILE 0x00000040
|
---|
5441 | #define FILE_CREATE_TREE_CONNECTION 0x00000080
|
---|
5442 |
|
---|
5443 | #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
|
---|
5444 | #define FILE_NO_EA_KNOWLEDGE 0x00000200
|
---|
5445 | #define FILE_OPEN_FOR_RECOVERY 0x00000400
|
---|
5446 | #define FILE_RANDOM_ACCESS 0x00000800
|
---|
5447 |
|
---|
5448 | #define FILE_DELETE_ON_CLOSE 0x00001000
|
---|
5449 | #define FILE_OPEN_BY_FILE_ID 0x00002000
|
---|
5450 | #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
|
---|
5451 | #define FILE_NO_COMPRESSION 0x00008000
|
---|
5452 |
|
---|
5453 | #define FILE_RESERVE_OPFILTER 0x00100000
|
---|
5454 | #define FILE_OPEN_REPARSE_POINT 0x00200000
|
---|
5455 | #define FILE_OPEN_NO_RECALL 0x00400000
|
---|
5456 | #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
|
---|
5457 |
|
---|
5458 | #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
|
---|
5459 | #define FILE_STRUCTURED_STORAGE 0x00000441
|
---|
5460 |
|
---|
5461 | #define FILE_VALID_OPTION_FLAGS 0x00ffffff
|
---|
5462 | #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
|
---|
5463 | #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
|
---|
5464 | #define FILE_VALID_SET_FLAGS 0x00000036
|
---|
5465 |
|
---|
5466 | //
|
---|
5467 | // Define the I/O status information return values for NtCreateFile/NtOpenFile
|
---|
5468 | //
|
---|
5469 |
|
---|
5470 | #define FILE_SUPERSEDED 0x00000000
|
---|
5471 | #define FILE_OPENED 0x00000001
|
---|
5472 | #define FILE_CREATED 0x00000002
|
---|
5473 | #define FILE_OVERWRITTEN 0x00000003
|
---|
5474 | #define FILE_EXISTS 0x00000004
|
---|
5475 | #define FILE_DOES_NOT_EXIST 0x00000005
|
---|
5476 |
|
---|
5477 | //
|
---|
5478 | // Define special ByteOffset parameters for read and write operations
|
---|
5479 | //
|
---|
5480 |
|
---|
5481 | #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
|
---|
5482 | #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
|
---|
5483 |
|
---|
5484 | //
|
---|
5485 | // Define alignment requirement values
|
---|
5486 | //
|
---|
5487 |
|
---|
5488 | #define FILE_BYTE_ALIGNMENT 0x00000000
|
---|
5489 | #define FILE_WORD_ALIGNMENT 0x00000001
|
---|
5490 | #define FILE_LONG_ALIGNMENT 0x00000003
|
---|
5491 | #define FILE_QUAD_ALIGNMENT 0x00000007
|
---|
5492 | #define FILE_OCTA_ALIGNMENT 0x0000000f
|
---|
5493 | #define FILE_32_BYTE_ALIGNMENT 0x0000001f
|
---|
5494 | #define FILE_64_BYTE_ALIGNMENT 0x0000003f
|
---|
5495 | #define FILE_128_BYTE_ALIGNMENT 0x0000007f
|
---|
5496 | #define FILE_256_BYTE_ALIGNMENT 0x000000ff
|
---|
5497 | #define FILE_512_BYTE_ALIGNMENT 0x000001ff
|
---|
5498 |
|
---|
5499 | //
|
---|
5500 | // Define the maximum length of a filename string
|
---|
5501 | //
|
---|
5502 |
|
---|
5503 | #define MAXIMUM_FILENAME_LENGTH 256
|
---|
5504 |
|
---|
5505 | //
|
---|
5506 | // Define the various device characteristics flags
|
---|
5507 | //
|
---|
5508 |
|
---|
5509 | #define FILE_REMOVABLE_MEDIA 0x00000001
|
---|
5510 | #define FILE_READ_ONLY_DEVICE 0x00000002
|
---|
5511 | #define FILE_FLOPPY_DISKETTE 0x00000004
|
---|
5512 | #define FILE_WRITE_ONCE_MEDIA 0x00000008
|
---|
5513 | #define FILE_REMOTE_DEVICE 0x00000010
|
---|
5514 | #define FILE_DEVICE_IS_MOUNTED 0x00000020
|
---|
5515 | #define FILE_VIRTUAL_VOLUME 0x00000040
|
---|
5516 | #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
|
---|
5517 | #define FILE_DEVICE_SECURE_OPEN 0x00000100
|
---|
5518 | #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800
|
---|
5519 |
|
---|
5520 |
|
---|
5521 |
|
---|
5522 | //
|
---|
5523 | // The FILE_EXPECT flags will only exist for WinXP. After that they will be
|
---|
5524 | // ignored and an IRP will be sent in their place.
|
---|
5525 | //
|
---|
5526 | #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
|
---|
5527 | #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
|
---|
5528 | #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
|
---|
5529 |
|
---|
5530 | //
|
---|
5531 | // flags specified here will be propagated up and down a device stack
|
---|
5532 | // after FDO and all filter devices are added, but before the device
|
---|
5533 | // stack is started
|
---|
5534 | //
|
---|
5535 |
|
---|
5536 | #define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \
|
---|
5537 | FILE_READ_ONLY_DEVICE | \
|
---|
5538 | FILE_FLOPPY_DISKETTE | \
|
---|
5539 | FILE_WRITE_ONCE_MEDIA | \
|
---|
5540 | FILE_DEVICE_SECURE_OPEN )
|
---|
5541 |
|
---|
5542 | //
|
---|
5543 | // Define the base asynchronous I/O argument types
|
---|
5544 | //
|
---|
5545 |
|
---|
5546 | typedef struct _IO_STATUS_BLOCK {
|
---|
5547 | union {
|
---|
5548 | NTSTATUS Status;
|
---|
5549 | PVOID Pointer;
|
---|
5550 | };
|
---|
5551 |
|
---|
5552 | ULONG_PTR Information;
|
---|
5553 | } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
|
---|
5554 |
|
---|
5555 | #if defined(_WIN64)
|
---|
5556 | typedef struct _IO_STATUS_BLOCK32 {
|
---|
5557 | NTSTATUS Status;
|
---|
5558 | ULONG Information;
|
---|
5559 | } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
|
---|
5560 | #endif
|
---|
5561 |
|
---|
5562 |
|
---|
5563 | //
|
---|
5564 | // Define an Asynchronous Procedure Call from I/O viewpoint
|
---|
5565 | //
|
---|
5566 |
|
---|
5567 | typedef
|
---|
5568 | VOID
|
---|
5569 | (NTAPI *PIO_APC_ROUTINE) (
|
---|
5570 | IN PVOID ApcContext,
|
---|
5571 | IN PIO_STATUS_BLOCK IoStatusBlock,
|
---|
5572 | IN ULONG Reserved
|
---|
5573 | );
|
---|
5574 | #define PIO_APC_ROUTINE_DEFINED
|
---|
5575 |
|
---|
5576 | //
|
---|
5577 | // Define the file information class values
|
---|
5578 | //
|
---|
5579 | // WARNING: The order of the following values are assumed by the I/O system.
|
---|
5580 | // Any changes made here should be reflected there as well.
|
---|
5581 | //
|
---|
5582 |
|
---|
5583 | typedef enum _FILE_INFORMATION_CLASS {
|
---|
5584 |
|
---|
5585 | FileDirectoryInformation = 1,
|
---|
5586 | FileFullDirectoryInformation, // 2
|
---|
5587 | FileBothDirectoryInformation, // 3
|
---|
5588 | FileBasicInformation, // 4 wdm
|
---|
5589 | FileStandardInformation, // 5 wdm
|
---|
5590 | FileInternalInformation, // 6
|
---|
5591 | FileEaInformation, // 7
|
---|
5592 | FileAccessInformation, // 8
|
---|
5593 | FileNameInformation, // 9
|
---|
5594 | FileRenameInformation, // 10
|
---|
5595 | FileLinkInformation, // 11
|
---|
5596 | FileNamesInformation, // 12
|
---|
5597 | FileDispositionInformation, // 13
|
---|
5598 | FilePositionInformation, // 14 wdm
|
---|
5599 | FileFullEaInformation, // 15
|
---|
5600 | FileModeInformation, // 16
|
---|
5601 | FileAlignmentInformation, // 17
|
---|
5602 | FileAllInformation, // 18
|
---|
5603 | FileAllocationInformation, // 19
|
---|
5604 | FileEndOfFileInformation, // 20 wdm
|
---|
5605 | FileAlternateNameInformation, // 21
|
---|
5606 | FileStreamInformation, // 22
|
---|
5607 | FilePipeInformation, // 23
|
---|
5608 | FilePipeLocalInformation, // 24
|
---|
5609 | FilePipeRemoteInformation, // 25
|
---|
5610 | FileMailslotQueryInformation, // 26
|
---|
5611 | FileMailslotSetInformation, // 27
|
---|
5612 | FileCompressionInformation, // 28
|
---|
5613 | FileObjectIdInformation, // 29
|
---|
5614 | FileCompletionInformation, // 30
|
---|
5615 | FileMoveClusterInformation, // 31
|
---|
5616 | FileQuotaInformation, // 32
|
---|
5617 | FileReparsePointInformation, // 33
|
---|
5618 | FileNetworkOpenInformation, // 34
|
---|
5619 | FileAttributeTagInformation, // 35
|
---|
5620 | FileTrackingInformation, // 36
|
---|
5621 | FileIdBothDirectoryInformation, // 37
|
---|
5622 | FileIdFullDirectoryInformation, // 38
|
---|
5623 | FileValidDataLengthInformation, // 39
|
---|
5624 | FileShortNameInformation, // 40
|
---|
5625 | FileMaximumInformation
|
---|
5626 |
|
---|
5627 | } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
|
---|
5628 |
|
---|
5629 | //
|
---|
5630 | // Define the various structures which are returned on query operations
|
---|
5631 | //
|
---|
5632 |
|
---|
5633 | typedef struct _FILE_BASIC_INFORMATION {
|
---|
5634 | LARGE_INTEGER CreationTime;
|
---|
5635 | LARGE_INTEGER LastAccessTime;
|
---|
5636 | LARGE_INTEGER LastWriteTime;
|
---|
5637 | LARGE_INTEGER ChangeTime;
|
---|
5638 | ULONG FileAttributes;
|
---|
5639 | } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
|
---|
5640 |
|
---|
5641 | typedef struct _FILE_STANDARD_INFORMATION {
|
---|
5642 | LARGE_INTEGER AllocationSize;
|
---|
5643 | LARGE_INTEGER EndOfFile;
|
---|
5644 | ULONG NumberOfLinks;
|
---|
5645 | BOOLEAN DeletePending;
|
---|
5646 | BOOLEAN Directory;
|
---|
5647 | } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
|
---|
5648 |
|
---|
5649 | typedef struct _FILE_POSITION_INFORMATION {
|
---|
5650 | LARGE_INTEGER CurrentByteOffset;
|
---|
5651 | } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
|
---|
5652 |
|
---|
5653 | typedef struct _FILE_ALIGNMENT_INFORMATION {
|
---|
5654 | ULONG AlignmentRequirement;
|
---|
5655 | } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
|
---|
5656 |
|
---|
5657 | typedef struct _FILE_NAME_INFORMATION {
|
---|
5658 | ULONG FileNameLength;
|
---|
5659 | WCHAR FileName[1];
|
---|
5660 | } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
|
---|
5661 |
|
---|
5662 | typedef struct _FILE_NETWORK_OPEN_INFORMATION {
|
---|
5663 | LARGE_INTEGER CreationTime;
|
---|
5664 | LARGE_INTEGER LastAccessTime;
|
---|
5665 | LARGE_INTEGER LastWriteTime;
|
---|
5666 | LARGE_INTEGER ChangeTime;
|
---|
5667 | LARGE_INTEGER AllocationSize;
|
---|
5668 | LARGE_INTEGER EndOfFile;
|
---|
5669 | ULONG FileAttributes;
|
---|
5670 | } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
|
---|
5671 |
|
---|
5672 | typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
|
---|
5673 | ULONG FileAttributes;
|
---|
5674 | ULONG ReparseTag;
|
---|
5675 | } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
|
---|
5676 |
|
---|
5677 | typedef struct _FILE_DISPOSITION_INFORMATION {
|
---|
5678 | BOOLEAN DeleteFile;
|
---|
5679 | } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
|
---|
5680 |
|
---|
5681 | typedef struct _FILE_END_OF_FILE_INFORMATION {
|
---|
5682 | LARGE_INTEGER EndOfFile;
|
---|
5683 | } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
|
---|
5684 |
|
---|
5685 | typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
|
---|
5686 | LARGE_INTEGER ValidDataLength;
|
---|
5687 | } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
|
---|
5688 |
|
---|
5689 | typedef struct _FILE_FULL_EA_INFORMATION {
|
---|
5690 | ULONG NextEntryOffset;
|
---|
5691 | UCHAR Flags;
|
---|
5692 | UCHAR EaNameLength;
|
---|
5693 | USHORT EaValueLength;
|
---|
5694 | CHAR EaName[1];
|
---|
5695 | } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
|
---|
5696 |
|
---|
5697 | //
|
---|
5698 | // Define the file system information class values
|
---|
5699 | //
|
---|
5700 | // WARNING: The order of the following values are assumed by the I/O system.
|
---|
5701 | // Any changes made here should be reflected there as well.
|
---|
5702 |
|
---|
5703 | typedef enum _FSINFOCLASS {
|
---|
5704 | FileFsVolumeInformation = 1,
|
---|
5705 | FileFsLabelInformation, // 2
|
---|
5706 | FileFsSizeInformation, // 3
|
---|
5707 | FileFsDeviceInformation, // 4
|
---|
5708 | FileFsAttributeInformation, // 5
|
---|
5709 | FileFsControlInformation, // 6
|
---|
5710 | FileFsFullSizeInformation, // 7
|
---|
5711 | FileFsObjectIdInformation, // 8
|
---|
5712 | FileFsDriverPathInformation, // 9
|
---|
5713 | FileFsMaximumInformation
|
---|
5714 | } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
|
---|
5715 |
|
---|
5716 | typedef struct _FILE_FS_DEVICE_INFORMATION {
|
---|
5717 | DEVICE_TYPE DeviceType;
|
---|
5718 | ULONG Characteristics;
|
---|
5719 | } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
|
---|
5720 |
|
---|
5721 |
|
---|
5722 | //
|
---|
5723 | // Define segment buffer structure for scatter/gather read/write.
|
---|
5724 | //
|
---|
5725 |
|
---|
5726 | typedef union _FILE_SEGMENT_ELEMENT {
|
---|
5727 | PVOID64 Buffer;
|
---|
5728 | ULONGLONG Alignment;
|
---|
5729 | }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
|
---|
5730 |
|
---|
5731 | //
|
---|
5732 | // Define the I/O bus interface types.
|
---|
5733 | //
|
---|
5734 |
|
---|
5735 | typedef enum _INTERFACE_TYPE {
|
---|
5736 | InterfaceTypeUndefined = -1,
|
---|
5737 | Internal,
|
---|
5738 | Isa,
|
---|
5739 | Eisa,
|
---|
5740 | MicroChannel,
|
---|
5741 | TurboChannel,
|
---|
5742 | PCIBus,
|
---|
5743 | VMEBus,
|
---|
5744 | NuBus,
|
---|
5745 | PCMCIABus,
|
---|
5746 | CBus,
|
---|
5747 | MPIBus,
|
---|
5748 | MPSABus,
|
---|
5749 | ProcessorInternal,
|
---|
5750 | InternalPowerBus,
|
---|
5751 | PNPISABus,
|
---|
5752 | PNPBus,
|
---|
5753 | MaximumInterfaceType
|
---|
5754 | }INTERFACE_TYPE, *PINTERFACE_TYPE;
|
---|
5755 |
|
---|
5756 | //
|
---|
5757 | // Define the DMA transfer widths.
|
---|
5758 | //
|
---|
5759 |
|
---|
5760 | typedef enum _DMA_WIDTH {
|
---|
5761 | Width8Bits,
|
---|
5762 | Width16Bits,
|
---|
5763 | Width32Bits,
|
---|
5764 | MaximumDmaWidth
|
---|
5765 | }DMA_WIDTH, *PDMA_WIDTH;
|
---|
5766 |
|
---|
5767 | //
|
---|
5768 | // Define DMA transfer speeds.
|
---|
5769 | //
|
---|
5770 |
|
---|
5771 | typedef enum _DMA_SPEED {
|
---|
5772 | Compatible,
|
---|
5773 | TypeA,
|
---|
5774 | TypeB,
|
---|
5775 | TypeC,
|
---|
5776 | TypeF,
|
---|
5777 | MaximumDmaSpeed
|
---|
5778 | }DMA_SPEED, *PDMA_SPEED;
|
---|
5779 |
|
---|
5780 | //
|
---|
5781 | // Define Interface reference/dereference routines for
|
---|
5782 | // Interfaces exported by IRP_MN_QUERY_INTERFACE
|
---|
5783 | //
|
---|
5784 |
|
---|
5785 | typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context);
|
---|
5786 | typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context);
|
---|
5787 |
|
---|
5788 |
|
---|
5789 |
|
---|
5790 | //
|
---|
5791 | // Define types of bus information.
|
---|
5792 | //
|
---|
5793 |
|
---|
5794 | typedef enum _BUS_DATA_TYPE {
|
---|
5795 | ConfigurationSpaceUndefined = -1,
|
---|
5796 | Cmos,
|
---|
5797 | EisaConfiguration,
|
---|
5798 | Pos,
|
---|
5799 | CbusConfiguration,
|
---|
5800 | PCIConfiguration,
|
---|
5801 | VMEConfiguration,
|
---|
5802 | NuBusConfiguration,
|
---|
5803 | PCMCIAConfiguration,
|
---|
5804 | MPIConfiguration,
|
---|
5805 | MPSAConfiguration,
|
---|
5806 | PNPISAConfiguration,
|
---|
5807 | SgiInternalConfiguration,
|
---|
5808 | MaximumBusDataType
|
---|
5809 | } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
|
---|
5810 |
|
---|
5811 | //
|
---|
5812 | // Define I/O Driver error log packet structure. This structure is filled in
|
---|
5813 | // by the driver.
|
---|
5814 | //
|
---|
5815 |
|
---|
5816 | typedef struct _IO_ERROR_LOG_PACKET {
|
---|
5817 | UCHAR MajorFunctionCode;
|
---|
5818 | UCHAR RetryCount;
|
---|
5819 | USHORT DumpDataSize;
|
---|
5820 | USHORT NumberOfStrings;
|
---|
5821 | USHORT StringOffset;
|
---|
5822 | USHORT EventCategory;
|
---|
5823 | NTSTATUS ErrorCode;
|
---|
5824 | ULONG UniqueErrorValue;
|
---|
5825 | NTSTATUS FinalStatus;
|
---|
5826 | ULONG SequenceNumber;
|
---|
5827 | ULONG IoControlCode;
|
---|
5828 | LARGE_INTEGER DeviceOffset;
|
---|
5829 | ULONG DumpData[1];
|
---|
5830 | }IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
|
---|
5831 |
|
---|
5832 | //
|
---|
5833 | // Define the I/O error log message. This message is sent by the error log
|
---|
5834 | // thread over the lpc port.
|
---|
5835 | //
|
---|
5836 |
|
---|
5837 | typedef struct _IO_ERROR_LOG_MESSAGE {
|
---|
5838 | USHORT Type;
|
---|
5839 | USHORT Size;
|
---|
5840 | USHORT DriverNameLength;
|
---|
5841 | LARGE_INTEGER TimeStamp;
|
---|
5842 | ULONG DriverNameOffset;
|
---|
5843 | IO_ERROR_LOG_PACKET EntryData;
|
---|
5844 | }IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
|
---|
5845 |
|
---|
5846 | //
|
---|
5847 | // Define the maximum message size that will be sent over the LPC to the
|
---|
5848 | // application reading the error log entries.
|
---|
5849 | //
|
---|
5850 |
|
---|
5851 | //
|
---|
5852 | // Regardless of LPC size restrictions, ERROR_LOG_MAXIMUM_SIZE must remain
|
---|
5853 | // a value that can fit in a UCHAR.
|
---|
5854 | //
|
---|
5855 |
|
---|
5856 | #define ERROR_LOG_LIMIT_SIZE (256-16)
|
---|
5857 |
|
---|
5858 | //
|
---|
5859 | // This limit, exclusive of IO_ERROR_LOG_MESSAGE_HEADER_LENGTH, also applies
|
---|
5860 | // to IO_ERROR_LOG_MESSAGE_LENGTH
|
---|
5861 | //
|
---|
5862 |
|
---|
5863 | #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
|
---|
5864 | sizeof(IO_ERROR_LOG_PACKET) + \
|
---|
5865 | (sizeof(WCHAR) * 40))
|
---|
5866 |
|
---|
5867 | #define ERROR_LOG_MESSAGE_LIMIT_SIZE \
|
---|
5868 | (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
|
---|
5869 |
|
---|
5870 | //
|
---|
5871 | // IO_ERROR_LOG_MESSAGE_LENGTH is
|
---|
5872 | // min(PORT_MAXIMUM_MESSAGE_LENGTH, ERROR_LOG_MESSAGE_LIMIT_SIZE)
|
---|
5873 | //
|
---|
5874 |
|
---|
5875 | #define IO_ERROR_LOG_MESSAGE_LENGTH \
|
---|
5876 | ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \
|
---|
5877 | ERROR_LOG_MESSAGE_LIMIT_SIZE : \
|
---|
5878 | PORT_MAXIMUM_MESSAGE_LENGTH)
|
---|
5879 |
|
---|
5880 | //
|
---|
5881 | // Define the maximum packet size a driver can allocate.
|
---|
5882 | //
|
---|
5883 |
|
---|
5884 | #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
|
---|
5885 | IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
|
---|
5886 |
|
---|
5887 | #ifdef _WIN64
|
---|
5888 | #define PORT_MAXIMUM_MESSAGE_LENGTH 512
|
---|
5889 | #else
|
---|
5890 | #define PORT_MAXIMUM_MESSAGE_LENGTH 256
|
---|
5891 | #endif
|
---|
5892 | //
|
---|
5893 | // Registry Specific Access Rights.
|
---|
5894 | //
|
---|
5895 |
|
---|
5896 | #define KEY_QUERY_VALUE (0x0001)
|
---|
5897 | #define KEY_SET_VALUE (0x0002)
|
---|
5898 | #define KEY_CREATE_SUB_KEY (0x0004)
|
---|
5899 | #define KEY_ENUMERATE_SUB_KEYS (0x0008)
|
---|
5900 | #define KEY_NOTIFY (0x0010)
|
---|
5901 | #define KEY_CREATE_LINK (0x0020)
|
---|
5902 | #define KEY_WOW64_32KEY (0x0200)
|
---|
5903 | #define KEY_WOW64_64KEY (0x0100)
|
---|
5904 | #define KEY_WOW64_RES (0x0300)
|
---|
5905 |
|
---|
5906 | #define KEY_READ ((STANDARD_RIGHTS_READ |\
|
---|
5907 | KEY_QUERY_VALUE |\
|
---|
5908 | KEY_ENUMERATE_SUB_KEYS |\
|
---|
5909 | KEY_NOTIFY) \
|
---|
5910 | & \
|
---|
5911 | (~SYNCHRONIZE))
|
---|
5912 |
|
---|
5913 |
|
---|
5914 | #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
|
---|
5915 | KEY_SET_VALUE |\
|
---|
5916 | KEY_CREATE_SUB_KEY) \
|
---|
5917 | & \
|
---|
5918 | (~SYNCHRONIZE))
|
---|
5919 |
|
---|
5920 | #define KEY_EXECUTE ((KEY_READ) \
|
---|
5921 | & \
|
---|
5922 | (~SYNCHRONIZE))
|
---|
5923 |
|
---|
5924 | #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
|
---|
5925 | KEY_QUERY_VALUE |\
|
---|
5926 | KEY_SET_VALUE |\
|
---|
5927 | KEY_CREATE_SUB_KEY |\
|
---|
5928 | KEY_ENUMERATE_SUB_KEYS |\
|
---|
5929 | KEY_NOTIFY |\
|
---|
5930 | KEY_CREATE_LINK) \
|
---|
5931 | & \
|
---|
5932 | (~SYNCHRONIZE))
|
---|
5933 |
|
---|
5934 | //
|
---|
5935 | // Open/Create Options
|
---|
5936 | //
|
---|
5937 |
|
---|
5938 | #define REG_OPTION_RESERVED (0x00000000L) // Parameter is reserved
|
---|
5939 |
|
---|
5940 | #define REG_OPTION_NON_VOLATILE (0x00000000L) // Key is preserved
|
---|
5941 | // when system is rebooted
|
---|
5942 |
|
---|
5943 | #define REG_OPTION_VOLATILE (0x00000001L) // Key is not preserved
|
---|
5944 | // when system is rebooted
|
---|
5945 |
|
---|
5946 | #define REG_OPTION_CREATE_LINK (0x00000002L) // Created key is a
|
---|
5947 | // symbolic link
|
---|
5948 |
|
---|
5949 | #define REG_OPTION_BACKUP_RESTORE (0x00000004L) // open for backup or restore
|
---|
5950 | // special access rules
|
---|
5951 | // privilege required
|
---|
5952 |
|
---|
5953 | #define REG_OPTION_OPEN_LINK (0x00000008L) // Open symbolic link
|
---|
5954 |
|
---|
5955 | #define REG_LEGAL_OPTION \
|
---|
5956 | (REG_OPTION_RESERVED |\
|
---|
5957 | REG_OPTION_NON_VOLATILE |\
|
---|
5958 | REG_OPTION_VOLATILE |\
|
---|
5959 | REG_OPTION_CREATE_LINK |\
|
---|
5960 | REG_OPTION_BACKUP_RESTORE |\
|
---|
5961 | REG_OPTION_OPEN_LINK)
|
---|
5962 |
|
---|
5963 | //
|
---|
5964 | // Key creation/open disposition
|
---|
5965 | //
|
---|
5966 |
|
---|
5967 | #define REG_CREATED_NEW_KEY (0x00000001L) // New Registry Key created
|
---|
5968 | #define REG_OPENED_EXISTING_KEY (0x00000002L) // Existing Key opened
|
---|
5969 |
|
---|
5970 | //
|
---|
5971 | // hive format to be used by Reg(Nt)SaveKeyEx
|
---|
5972 | //
|
---|
5973 | #define REG_STANDARD_FORMAT 1
|
---|
5974 | #define REG_LATEST_FORMAT 2
|
---|
5975 | #define REG_NO_COMPRESSION 4
|
---|
5976 |
|
---|
5977 | //
|
---|
5978 | // Key restore flags
|
---|
5979 | //
|
---|
5980 |
|
---|
5981 | #define REG_WHOLE_HIVE_VOLATILE (0x00000001L) // Restore whole hive volatile
|
---|
5982 | #define REG_REFRESH_HIVE (0x00000002L) // Unwind changes to last flush
|
---|
5983 | #define REG_NO_LAZY_FLUSH (0x00000004L) // Never lazy flush this hive
|
---|
5984 | #define REG_FORCE_RESTORE (0x00000008L) // Force the restore process even when we have open handles on subkeys
|
---|
5985 |
|
---|
5986 | //
|
---|
5987 | // Unload Flags
|
---|
5988 | //
|
---|
5989 | #define REG_FORCE_UNLOAD 1
|
---|
5990 |
|
---|
5991 | //
|
---|
5992 | // Key query structures
|
---|
5993 | //
|
---|
5994 |
|
---|
5995 | typedef struct _KEY_BASIC_INFORMATION {
|
---|
5996 | LARGE_INTEGER LastWriteTime;
|
---|
5997 | ULONG TitleIndex;
|
---|
5998 | ULONG NameLength;
|
---|
5999 | WCHAR Name[1]; // Variable length string
|
---|
6000 | } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
|
---|
6001 |
|
---|
6002 | typedef struct _KEY_NODE_INFORMATION {
|
---|
6003 | LARGE_INTEGER LastWriteTime;
|
---|
6004 | ULONG TitleIndex;
|
---|
6005 | ULONG ClassOffset;
|
---|
6006 | ULONG ClassLength;
|
---|
6007 | ULONG NameLength;
|
---|
6008 | WCHAR Name[1]; // Variable length string
|
---|
6009 | // Class[1]; // Variable length string not declared
|
---|
6010 | } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
|
---|
6011 |
|
---|
6012 | typedef struct _KEY_FULL_INFORMATION {
|
---|
6013 | LARGE_INTEGER LastWriteTime;
|
---|
6014 | ULONG TitleIndex;
|
---|
6015 | ULONG ClassOffset;
|
---|
6016 | ULONG ClassLength;
|
---|
6017 | ULONG SubKeys;
|
---|
6018 | ULONG MaxNameLen;
|
---|
6019 | ULONG MaxClassLen;
|
---|
6020 | ULONG Values;
|
---|
6021 | ULONG MaxValueNameLen;
|
---|
6022 | ULONG MaxValueDataLen;
|
---|
6023 | WCHAR Class[1]; // Variable length
|
---|
6024 | } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
|
---|
6025 |
|
---|
6026 |
|
---|
6027 | typedef struct _KEY_NAME_INFORMATION {
|
---|
6028 | ULONG NameLength;
|
---|
6029 | WCHAR Name[1]; // Variable length string
|
---|
6030 | } KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
|
---|
6031 |
|
---|
6032 | typedef struct _KEY_CACHED_INFORMATION {
|
---|
6033 | LARGE_INTEGER LastWriteTime;
|
---|
6034 | ULONG TitleIndex;
|
---|
6035 | ULONG SubKeys;
|
---|
6036 | ULONG MaxNameLen;
|
---|
6037 | ULONG Values;
|
---|
6038 | ULONG MaxValueNameLen;
|
---|
6039 | ULONG MaxValueDataLen;
|
---|
6040 | ULONG NameLength;
|
---|
6041 | WCHAR Name[1]; // Variable length string
|
---|
6042 | } KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
|
---|
6043 |
|
---|
6044 | typedef struct _KEY_FLAGS_INFORMATION {
|
---|
6045 | ULONG UserFlags;
|
---|
6046 | } KEY_FLAGS_INFORMATION, *PKEY_FLAGS_INFORMATION;
|
---|
6047 |
|
---|
6048 |
|
---|
6049 | typedef enum _KEY_INFORMATION_CLASS {
|
---|
6050 | KeyBasicInformation,
|
---|
6051 | KeyNodeInformation,
|
---|
6052 | KeyFullInformation
|
---|
6053 |
|
---|
6054 | ,
|
---|
6055 | KeyNameInformation,
|
---|
6056 | KeyCachedInformation,
|
---|
6057 | KeyFlagsInformation,
|
---|
6058 | MaxKeyInfoClass // MaxKeyInfoClass should always be the last enum
|
---|
6059 |
|
---|
6060 | } KEY_INFORMATION_CLASS;
|
---|
6061 |
|
---|
6062 | typedef struct _KEY_WRITE_TIME_INFORMATION {
|
---|
6063 | LARGE_INTEGER LastWriteTime;
|
---|
6064 | } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
|
---|
6065 |
|
---|
6066 | typedef struct _KEY_USER_FLAGS_INFORMATION {
|
---|
6067 | ULONG UserFlags;
|
---|
6068 | } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
|
---|
6069 |
|
---|
6070 | typedef enum _KEY_SET_INFORMATION_CLASS {
|
---|
6071 | KeyWriteTimeInformation,
|
---|
6072 | KeyUserFlagsInformation,
|
---|
6073 | MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum
|
---|
6074 | } KEY_SET_INFORMATION_CLASS;
|
---|
6075 |
|
---|
6076 | //
|
---|
6077 | // Value entry query structures
|
---|
6078 | //
|
---|
6079 |
|
---|
6080 | typedef struct _KEY_VALUE_BASIC_INFORMATION {
|
---|
6081 | ULONG TitleIndex;
|
---|
6082 | ULONG Type;
|
---|
6083 | ULONG NameLength;
|
---|
6084 | WCHAR Name[1]; // Variable size
|
---|
6085 | } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
|
---|
6086 |
|
---|
6087 | typedef struct _KEY_VALUE_FULL_INFORMATION {
|
---|
6088 | ULONG TitleIndex;
|
---|
6089 | ULONG Type;
|
---|
6090 | ULONG DataOffset;
|
---|
6091 | ULONG DataLength;
|
---|
6092 | ULONG NameLength;
|
---|
6093 | WCHAR Name[1]; // Variable size
|
---|
6094 | // Data[1]; // Variable size data not declared
|
---|
6095 | } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
|
---|
6096 |
|
---|
6097 | typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
|
---|
6098 | ULONG TitleIndex;
|
---|
6099 | ULONG Type;
|
---|
6100 | ULONG DataLength;
|
---|
6101 | UCHAR Data[1]; // Variable size
|
---|
6102 | } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
|
---|
6103 |
|
---|
6104 | typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
|
---|
6105 | ULONG Type;
|
---|
6106 | ULONG DataLength;
|
---|
6107 | UCHAR Data[1]; // Variable size
|
---|
6108 | } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
|
---|
6109 |
|
---|
6110 | typedef struct _KEY_VALUE_ENTRY {
|
---|
6111 | PUNICODE_STRING ValueName;
|
---|
6112 | ULONG DataLength;
|
---|
6113 | ULONG DataOffset;
|
---|
6114 | ULONG Type;
|
---|
6115 | } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
|
---|
6116 |
|
---|
6117 | typedef enum _KEY_VALUE_INFORMATION_CLASS {
|
---|
6118 | KeyValueBasicInformation,
|
---|
6119 | KeyValueFullInformation,
|
---|
6120 | KeyValuePartialInformation,
|
---|
6121 | KeyValueFullInformationAlign64,
|
---|
6122 | KeyValuePartialInformationAlign64,
|
---|
6123 | MaxKeyValueInfoClass // MaxKeyValueInfoClass should always be the last enum
|
---|
6124 | } KEY_VALUE_INFORMATION_CLASS;
|
---|
6125 |
|
---|
6126 |
|
---|
6127 |
|
---|
6128 | #define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\')
|
---|
6129 |
|
---|
6130 | //
|
---|
6131 | // Object Manager Object Type Specific Access Rights.
|
---|
6132 | //
|
---|
6133 |
|
---|
6134 | #define OBJECT_TYPE_CREATE (0x0001)
|
---|
6135 |
|
---|
6136 | #define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
|
---|
6137 |
|
---|
6138 | //
|
---|
6139 | // Object Manager Directory Specific Access Rights.
|
---|
6140 | //
|
---|
6141 |
|
---|
6142 | #define DIRECTORY_QUERY (0x0001)
|
---|
6143 | #define DIRECTORY_TRAVERSE (0x0002)
|
---|
6144 | #define DIRECTORY_CREATE_OBJECT (0x0004)
|
---|
6145 | #define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
|
---|
6146 |
|
---|
6147 | #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
|
---|
6148 |
|
---|
6149 | //
|
---|
6150 | // Object Manager Symbolic Link Specific Access Rights.
|
---|
6151 | //
|
---|
6152 |
|
---|
6153 | #define SYMBOLIC_LINK_QUERY (0x0001)
|
---|
6154 |
|
---|
6155 | #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
|
---|
6156 |
|
---|
6157 | typedef struct _OBJECT_NAME_INFORMATION {
|
---|
6158 | UNICODE_STRING Name;
|
---|
6159 | } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
|
---|
6160 | #define DUPLICATE_CLOSE_SOURCE 0x00000001
|
---|
6161 | #define DUPLICATE_SAME_ACCESS 0x00000002
|
---|
6162 | #define DUPLICATE_SAME_ATTRIBUTES 0x00000004
|
---|
6163 |
|
---|
6164 | //
|
---|
6165 | // Section Information Structures.
|
---|
6166 | //
|
---|
6167 |
|
---|
6168 | typedef enum _SECTION_INHERIT {
|
---|
6169 | ViewShare = 1,
|
---|
6170 | ViewUnmap = 2
|
---|
6171 | } SECTION_INHERIT;
|
---|
6172 |
|
---|
6173 | //
|
---|
6174 | // Section Access Rights.
|
---|
6175 | //
|
---|
6176 |
|
---|
6177 |
|
---|
6178 | #define SECTION_QUERY 0x0001
|
---|
6179 | #define SECTION_MAP_WRITE 0x0002
|
---|
6180 | #define SECTION_MAP_READ 0x0004
|
---|
6181 | #define SECTION_MAP_EXECUTE 0x0008
|
---|
6182 | #define SECTION_EXTEND_SIZE 0x0010
|
---|
6183 |
|
---|
6184 | #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
|
---|
6185 | SECTION_MAP_WRITE | \
|
---|
6186 | SECTION_MAP_READ | \
|
---|
6187 | SECTION_MAP_EXECUTE | \
|
---|
6188 | SECTION_EXTEND_SIZE)
|
---|
6189 |
|
---|
6190 |
|
---|
6191 | #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
|
---|
6192 |
|
---|
6193 | #define PAGE_NOACCESS 0x01
|
---|
6194 | #define PAGE_READONLY 0x02
|
---|
6195 | #define PAGE_READWRITE 0x04
|
---|
6196 | #define PAGE_WRITECOPY 0x08
|
---|
6197 | #define PAGE_EXECUTE 0x10
|
---|
6198 | #define PAGE_EXECUTE_READ 0x20
|
---|
6199 | #define PAGE_EXECUTE_READWRITE 0x40
|
---|
6200 | #define PAGE_EXECUTE_WRITECOPY 0x80
|
---|
6201 | #define PAGE_GUARD 0x100
|
---|
6202 | #define PAGE_NOCACHE 0x200
|
---|
6203 | #define PAGE_WRITECOMBINE 0x400
|
---|
6204 |
|
---|
6205 | #define MEM_COMMIT 0x1000
|
---|
6206 | #define MEM_RESERVE 0x2000
|
---|
6207 | #define MEM_DECOMMIT 0x4000
|
---|
6208 | #define MEM_RELEASE 0x8000
|
---|
6209 | #define MEM_FREE 0x10000
|
---|
6210 | #define MEM_PRIVATE 0x20000
|
---|
6211 | #define MEM_MAPPED 0x40000
|
---|
6212 | #define MEM_RESET 0x80000
|
---|
6213 | #define MEM_TOP_DOWN 0x100000
|
---|
6214 | #define MEM_LARGE_PAGES 0x20000000
|
---|
6215 | #define MEM_4MB_PAGES 0x80000000
|
---|
6216 | #define SEC_RESERVE 0x4000000
|
---|
6217 | #define PROCESS_DUP_HANDLE (0x0040)
|
---|
6218 | #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
|
---|
6219 | 0xFFF)
|
---|
6220 |
|
---|
6221 |
|
---|
6222 | #if defined(_WIN64)
|
---|
6223 |
|
---|
6224 | #define MAXIMUM_PROCESSORS 64
|
---|
6225 |
|
---|
6226 | #else
|
---|
6227 |
|
---|
6228 | #define MAXIMUM_PROCESSORS 32
|
---|
6229 |
|
---|
6230 | #endif
|
---|
6231 |
|
---|
6232 |
|
---|
6233 |
|
---|
6234 |
|
---|
6235 |
|
---|
6236 | //
|
---|
6237 | // Thread Specific Access Rights
|
---|
6238 | //
|
---|
6239 |
|
---|
6240 | #define THREAD_TERMINATE (0x0001)
|
---|
6241 | #define THREAD_SET_INFORMATION (0x0020)
|
---|
6242 |
|
---|
6243 | #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
|
---|
6244 | 0x3FF)
|
---|
6245 |
|
---|
6246 | //
|
---|
6247 | // ClientId
|
---|
6248 | //
|
---|
6249 |
|
---|
6250 | typedef struct _CLIENT_ID {
|
---|
6251 | HANDLE UniqueProcess;
|
---|
6252 | HANDLE UniqueThread;
|
---|
6253 | } CLIENT_ID;
|
---|
6254 | typedef CLIENT_ID *PCLIENT_ID;
|
---|
6255 |
|
---|
6256 | //
|
---|
6257 | // Thread Environment Block (and portable part of Thread Information Block)
|
---|
6258 | //
|
---|
6259 |
|
---|
6260 | //
|
---|
6261 | // NT_TIB - Thread Information Block - Portable part.
|
---|
6262 | //
|
---|
6263 | // This is the subsystem portable part of the Thread Information Block.
|
---|
6264 | // It appears as the first part of the TEB for all threads which have
|
---|
6265 | // a user mode component.
|
---|
6266 | //
|
---|
6267 | //
|
---|
6268 |
|
---|
6269 |
|
---|
6270 |
|
---|
6271 | typedef struct _NT_TIB {
|
---|
6272 | struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
|
---|
6273 | PVOID StackBase;
|
---|
6274 | PVOID StackLimit;
|
---|
6275 | PVOID SubSystemTib;
|
---|
6276 | union {
|
---|
6277 | PVOID FiberData;
|
---|
6278 | ULONG Version;
|
---|
6279 | };
|
---|
6280 | PVOID ArbitraryUserPointer;
|
---|
6281 | struct _NT_TIB *Self;
|
---|
6282 | } NT_TIB;
|
---|
6283 | typedef NT_TIB *PNT_TIB;
|
---|
6284 |
|
---|
6285 | //
|
---|
6286 | // 32 and 64 bit specific version for wow64 and the debugger
|
---|
6287 | //
|
---|
6288 | typedef struct _NT_TIB32 {
|
---|
6289 | ULONG ExceptionList;
|
---|
6290 | ULONG StackBase;
|
---|
6291 | ULONG StackLimit;
|
---|
6292 | ULONG SubSystemTib;
|
---|
6293 | union {
|
---|
6294 | ULONG FiberData;
|
---|
6295 | ULONG Version;
|
---|
6296 | };
|
---|
6297 | ULONG ArbitraryUserPointer;
|
---|
6298 | ULONG Self;
|
---|
6299 | } NT_TIB32, *PNT_TIB32;
|
---|
6300 |
|
---|
6301 | typedef struct _NT_TIB64 {
|
---|
6302 | ULONG64 ExceptionList;
|
---|
6303 | ULONG64 StackBase;
|
---|
6304 | ULONG64 StackLimit;
|
---|
6305 | ULONG64 SubSystemTib;
|
---|
6306 | union {
|
---|
6307 | ULONG64 FiberData;
|
---|
6308 | ULONG Version;
|
---|
6309 | };
|
---|
6310 | ULONG64 ArbitraryUserPointer;
|
---|
6311 | ULONG64 Self;
|
---|
6312 | } NT_TIB64, *PNT_TIB64;
|
---|
6313 |
|
---|
6314 | //
|
---|
6315 | // Process Information Classes
|
---|
6316 | //
|
---|
6317 |
|
---|
6318 | typedef enum _PROCESSINFOCLASS {
|
---|
6319 | ProcessBasicInformation,
|
---|
6320 | ProcessQuotaLimits,
|
---|
6321 | ProcessIoCounters,
|
---|
6322 | ProcessVmCounters,
|
---|
6323 | ProcessTimes,
|
---|
6324 | ProcessBasePriority,
|
---|
6325 | ProcessRaisePriority,
|
---|
6326 | ProcessDebugPort,
|
---|
6327 | ProcessExceptionPort,
|
---|
6328 | ProcessAccessToken,
|
---|
6329 | ProcessLdtInformation,
|
---|
6330 | ProcessLdtSize,
|
---|
6331 | ProcessDefaultHardErrorMode,
|
---|
6332 | ProcessIoPortHandlers, // Note: this is kernel mode only
|
---|
6333 | ProcessPooledUsageAndLimits,
|
---|
6334 | ProcessWorkingSetWatch,
|
---|
6335 | ProcessUserModeIOPL,
|
---|
6336 | ProcessEnableAlignmentFaultFixup,
|
---|
6337 | ProcessPriorityClass,
|
---|
6338 | ProcessWx86Information,
|
---|
6339 | ProcessHandleCount,
|
---|
6340 | ProcessAffinityMask,
|
---|
6341 | ProcessPriorityBoost,
|
---|
6342 | ProcessDeviceMap,
|
---|
6343 | ProcessSessionInformation,
|
---|
6344 | ProcessForegroundInformation,
|
---|
6345 | ProcessWow64Information,
|
---|
6346 | ProcessImageFileName,
|
---|
6347 | ProcessLUIDDeviceMapsEnabled,
|
---|
6348 | ProcessBreakOnTermination,
|
---|
6349 | ProcessDebugObjectHandle,
|
---|
6350 | ProcessDebugFlags,
|
---|
6351 | ProcessHandleTracing,
|
---|
6352 | MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum
|
---|
6353 | } PROCESSINFOCLASS;
|
---|
6354 |
|
---|
6355 | //
|
---|
6356 | // Thread Information Classes
|
---|
6357 | //
|
---|
6358 |
|
---|
6359 | typedef enum _THREADINFOCLASS {
|
---|
6360 | ThreadBasicInformation,
|
---|
6361 | ThreadTimes,
|
---|
6362 | ThreadPriority,
|
---|
6363 | ThreadBasePriority,
|
---|
6364 | ThreadAffinityMask,
|
---|
6365 | ThreadImpersonationToken,
|
---|
6366 | ThreadDescriptorTableEntry,
|
---|
6367 | ThreadEnableAlignmentFaultFixup,
|
---|
6368 | ThreadEventPair_Reusable,
|
---|
6369 | ThreadQuerySetWin32StartAddress,
|
---|
6370 | ThreadZeroTlsCell,
|
---|
6371 | ThreadPerformanceCount,
|
---|
6372 | ThreadAmILastThread,
|
---|
6373 | ThreadIdealProcessor,
|
---|
6374 | ThreadPriorityBoost,
|
---|
6375 | ThreadSetTlsArrayAddress,
|
---|
6376 | ThreadIsIoPending,
|
---|
6377 | ThreadHideFromDebugger,
|
---|
6378 | ThreadBreakOnTermination,
|
---|
6379 | MaxThreadInfoClass
|
---|
6380 | } THREADINFOCLASS;
|
---|
6381 | //
|
---|
6382 | // Process Information Structures
|
---|
6383 | //
|
---|
6384 |
|
---|
6385 | //
|
---|
6386 | // PageFaultHistory Information
|
---|
6387 | // NtQueryInformationProcess using ProcessWorkingSetWatch
|
---|
6388 | //
|
---|
6389 | typedef struct _PROCESS_WS_WATCH_INFORMATION {
|
---|
6390 | PVOID FaultingPc;
|
---|
6391 | PVOID FaultingVa;
|
---|
6392 | } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
|
---|
6393 |
|
---|
6394 | //
|
---|
6395 | // Basic Process Information
|
---|
6396 | // NtQueryInformationProcess using ProcessBasicInfo
|
---|
6397 | //
|
---|
6398 |
|
---|
6399 | typedef struct _PROCESS_BASIC_INFORMATION {
|
---|
6400 | NTSTATUS ExitStatus;
|
---|
6401 | PPEB PebBaseAddress;
|
---|
6402 | ULONG_PTR AffinityMask;
|
---|
6403 | KPRIORITY BasePriority;
|
---|
6404 | ULONG_PTR UniqueProcessId;
|
---|
6405 | ULONG_PTR InheritedFromUniqueProcessId;
|
---|
6406 | } PROCESS_BASIC_INFORMATION;
|
---|
6407 | typedef PROCESS_BASIC_INFORMATION *PPROCESS_BASIC_INFORMATION;
|
---|
6408 |
|
---|
6409 |
|
---|
6410 |
|
---|
6411 | //
|
---|
6412 | // Process Device Map information
|
---|
6413 | // NtQueryInformationProcess using ProcessDeviceMap
|
---|
6414 | // NtSetInformationProcess using ProcessDeviceMap
|
---|
6415 | //
|
---|
6416 |
|
---|
6417 | typedef struct _PROCESS_DEVICEMAP_INFORMATION {
|
---|
6418 | union {
|
---|
6419 | struct {
|
---|
6420 | HANDLE DirectoryHandle;
|
---|
6421 | } Set;
|
---|
6422 | struct {
|
---|
6423 | ULONG DriveMap;
|
---|
6424 | UCHAR DriveType[ 32 ];
|
---|
6425 | } Query;
|
---|
6426 | };
|
---|
6427 | } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
|
---|
6428 |
|
---|
6429 | typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
|
---|
6430 | union {
|
---|
6431 | struct {
|
---|
6432 | HANDLE DirectoryHandle;
|
---|
6433 | } Set;
|
---|
6434 | struct {
|
---|
6435 | ULONG DriveMap;
|
---|
6436 | UCHAR DriveType[ 32 ];
|
---|
6437 | } Query;
|
---|
6438 | };
|
---|
6439 | ULONG Flags; // specifies that the query type
|
---|
6440 | } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
|
---|
6441 |
|
---|
6442 | //
|
---|
6443 | // PROCESS_DEVICEMAP_INFORMATION_EX flags
|
---|
6444 | //
|
---|
6445 | #define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
|
---|
6446 |
|
---|
6447 | //
|
---|
6448 | // Multi-User Session specific Process Information
|
---|
6449 | // NtQueryInformationProcess using ProcessSessionInformation
|
---|
6450 | //
|
---|
6451 |
|
---|
6452 | typedef struct _PROCESS_SESSION_INFORMATION {
|
---|
6453 | ULONG SessionId;
|
---|
6454 | } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
|
---|
6455 |
|
---|
6456 |
|
---|
6457 | typedef struct _PROCESS_HANDLE_TRACING_ENABLE {
|
---|
6458 | ULONG Flags;
|
---|
6459 | } PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE;
|
---|
6460 |
|
---|
6461 | typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX {
|
---|
6462 | ULONG Flags;
|
---|
6463 | ULONG TotalSlots;
|
---|
6464 | } PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX;
|
---|
6465 |
|
---|
6466 |
|
---|
6467 | #define PROCESS_HANDLE_TRACING_MAX_STACKS 16
|
---|
6468 |
|
---|
6469 | typedef struct _PROCESS_HANDLE_TRACING_ENTRY {
|
---|
6470 | HANDLE Handle;
|
---|
6471 | CLIENT_ID ClientId;
|
---|
6472 | ULONG Type;
|
---|
6473 | PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS];
|
---|
6474 | } PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY;
|
---|
6475 |
|
---|
6476 | typedef struct _PROCESS_HANDLE_TRACING_QUERY {
|
---|
6477 | HANDLE Handle;
|
---|
6478 | ULONG TotalTraces;
|
---|
6479 | PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1];
|
---|
6480 | } PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY;
|
---|
6481 |
|
---|
6482 | //
|
---|
6483 | // Process Quotas
|
---|
6484 | // NtQueryInformationProcess using ProcessQuotaLimits
|
---|
6485 | // NtQueryInformationProcess using ProcessPooledQuotaLimits
|
---|
6486 | // NtSetInformationProcess using ProcessQuotaLimits
|
---|
6487 | //
|
---|
6488 |
|
---|
6489 |
|
---|
6490 |
|
---|
6491 | typedef struct _QUOTA_LIMITS {
|
---|
6492 | SIZE_T PagedPoolLimit;
|
---|
6493 | SIZE_T NonPagedPoolLimit;
|
---|
6494 | SIZE_T MinimumWorkingSetSize;
|
---|
6495 | SIZE_T MaximumWorkingSetSize;
|
---|
6496 | SIZE_T PagefileLimit;
|
---|
6497 | LARGE_INTEGER TimeLimit;
|
---|
6498 | } QUOTA_LIMITS, *PQUOTA_LIMITS;
|
---|
6499 |
|
---|
6500 | #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
|
---|
6501 | #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
|
---|
6502 | #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
|
---|
6503 | #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
|
---|
6504 |
|
---|
6505 | typedef struct _QUOTA_LIMITS_EX {
|
---|
6506 | SIZE_T PagedPoolLimit;
|
---|
6507 | SIZE_T NonPagedPoolLimit;
|
---|
6508 | SIZE_T MinimumWorkingSetSize;
|
---|
6509 | SIZE_T MaximumWorkingSetSize;
|
---|
6510 | SIZE_T PagefileLimit;
|
---|
6511 | LARGE_INTEGER TimeLimit;
|
---|
6512 | SIZE_T Reserved1;
|
---|
6513 | SIZE_T Reserved2;
|
---|
6514 | SIZE_T Reserved3;
|
---|
6515 | SIZE_T Reserved4;
|
---|
6516 | ULONG Flags;
|
---|
6517 | ULONG Reserved5;
|
---|
6518 | } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
|
---|
6519 |
|
---|
6520 |
|
---|
6521 |
|
---|
6522 | //
|
---|
6523 | // Process I/O Counters
|
---|
6524 | // NtQueryInformationProcess using ProcessIoCounters
|
---|
6525 | //
|
---|
6526 |
|
---|
6527 |
|
---|
6528 | typedef struct _IO_COUNTERS {
|
---|
6529 | ULONGLONG ReadOperationCount;
|
---|
6530 | ULONGLONG WriteOperationCount;
|
---|
6531 | ULONGLONG OtherOperationCount;
|
---|
6532 | ULONGLONG ReadTransferCount;
|
---|
6533 | ULONGLONG WriteTransferCount;
|
---|
6534 | ULONGLONG OtherTransferCount;
|
---|
6535 | } IO_COUNTERS;
|
---|
6536 | typedef IO_COUNTERS *PIO_COUNTERS;
|
---|
6537 |
|
---|
6538 |
|
---|
6539 |
|
---|
6540 | //
|
---|
6541 | // Process Virtual Memory Counters
|
---|
6542 | // NtQueryInformationProcess using ProcessVmCounters
|
---|
6543 | //
|
---|
6544 |
|
---|
6545 | typedef struct _VM_COUNTERS {
|
---|
6546 | SIZE_T PeakVirtualSize;
|
---|
6547 | SIZE_T VirtualSize;
|
---|
6548 | ULONG PageFaultCount;
|
---|
6549 | SIZE_T PeakWorkingSetSize;
|
---|
6550 | SIZE_T WorkingSetSize;
|
---|
6551 | SIZE_T QuotaPeakPagedPoolUsage;
|
---|
6552 | SIZE_T QuotaPagedPoolUsage;
|
---|
6553 | SIZE_T QuotaPeakNonPagedPoolUsage;
|
---|
6554 | SIZE_T QuotaNonPagedPoolUsage;
|
---|
6555 | SIZE_T PagefileUsage;
|
---|
6556 | SIZE_T PeakPagefileUsage;
|
---|
6557 | } VM_COUNTERS;
|
---|
6558 | typedef VM_COUNTERS *PVM_COUNTERS;
|
---|
6559 |
|
---|
6560 | typedef struct _VM_COUNTERS_EX {
|
---|
6561 | SIZE_T PeakVirtualSize;
|
---|
6562 | SIZE_T VirtualSize;
|
---|
6563 | ULONG PageFaultCount;
|
---|
6564 | SIZE_T PeakWorkingSetSize;
|
---|
6565 | SIZE_T WorkingSetSize;
|
---|
6566 | SIZE_T QuotaPeakPagedPoolUsage;
|
---|
6567 | SIZE_T QuotaPagedPoolUsage;
|
---|
6568 | SIZE_T QuotaPeakNonPagedPoolUsage;
|
---|
6569 | SIZE_T QuotaNonPagedPoolUsage;
|
---|
6570 | SIZE_T PagefileUsage;
|
---|
6571 | SIZE_T PeakPagefileUsage;
|
---|
6572 | SIZE_T PrivateUsage;
|
---|
6573 | } VM_COUNTERS_EX;
|
---|
6574 | typedef VM_COUNTERS_EX *PVM_COUNTERS_EX;
|
---|
6575 |
|
---|
6576 | //
|
---|
6577 | // Process Pooled Quota Usage and Limits
|
---|
6578 | // NtQueryInformationProcess using ProcessPooledUsageAndLimits
|
---|
6579 | //
|
---|
6580 |
|
---|
6581 | typedef struct _POOLED_USAGE_AND_LIMITS {
|
---|
6582 | SIZE_T PeakPagedPoolUsage;
|
---|
6583 | SIZE_T PagedPoolUsage;
|
---|
6584 | SIZE_T PagedPoolLimit;
|
---|
6585 | SIZE_T PeakNonPagedPoolUsage;
|
---|
6586 | SIZE_T NonPagedPoolUsage;
|
---|
6587 | SIZE_T NonPagedPoolLimit;
|
---|
6588 | SIZE_T PeakPagefileUsage;
|
---|
6589 | SIZE_T PagefileUsage;
|
---|
6590 | SIZE_T PagefileLimit;
|
---|
6591 | } POOLED_USAGE_AND_LIMITS;
|
---|
6592 | typedef POOLED_USAGE_AND_LIMITS *PPOOLED_USAGE_AND_LIMITS;
|
---|
6593 |
|
---|
6594 | //
|
---|
6595 | // Process Security Context Information
|
---|
6596 | // NtSetInformationProcess using ProcessAccessToken
|
---|
6597 | // PROCESS_SET_ACCESS_TOKEN access to the process is needed
|
---|
6598 | // to use this info level.
|
---|
6599 | //
|
---|
6600 |
|
---|
6601 | typedef struct _PROCESS_ACCESS_TOKEN {
|
---|
6602 |
|
---|
6603 | //
|
---|
6604 | // Handle to Primary token to assign to the process.
|
---|
6605 | // TOKEN_ASSIGN_PRIMARY access to this token is needed.
|
---|
6606 | //
|
---|
6607 |
|
---|
6608 | HANDLE Token;
|
---|
6609 |
|
---|
6610 | //
|
---|
6611 | // Handle to the initial thread of the process.
|
---|
6612 | // A process's access token can only be changed if the process has
|
---|
6613 | // no threads or one thread. If the process has no threads, this
|
---|
6614 | // field must be set to NULL. Otherwise, it must contain a handle
|
---|
6615 | // open to the process's only thread. THREAD_QUERY_INFORMATION access
|
---|
6616 | // is needed via this handle.
|
---|
6617 |
|
---|
6618 | HANDLE Thread;
|
---|
6619 |
|
---|
6620 | } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
|
---|
6621 |
|
---|
6622 | //
|
---|
6623 | // Process/Thread System and User Time
|
---|
6624 | // NtQueryInformationProcess using ProcessTimes
|
---|
6625 | // NtQueryInformationThread using ThreadTimes
|
---|
6626 | //
|
---|
6627 |
|
---|
6628 | typedef struct _KERNEL_USER_TIMES {
|
---|
6629 | LARGE_INTEGER CreateTime;
|
---|
6630 | LARGE_INTEGER ExitTime;
|
---|
6631 | LARGE_INTEGER KernelTime;
|
---|
6632 | LARGE_INTEGER UserTime;
|
---|
6633 | } KERNEL_USER_TIMES;
|
---|
6634 | typedef KERNEL_USER_TIMES *PKERNEL_USER_TIMES;
|
---|
6635 | NTSYSCALLAPI
|
---|
6636 | NTSTATUS
|
---|
6637 | NTAPI
|
---|
6638 | NtOpenProcess (
|
---|
6639 | OUT PHANDLE ProcessHandle,
|
---|
6640 | IN ACCESS_MASK DesiredAccess,
|
---|
6641 | IN POBJECT_ATTRIBUTES ObjectAttributes,
|
---|
6642 | IN PCLIENT_ID ClientId OPTIONAL
|
---|
6643 | );
|
---|
6644 | #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 )
|
---|
6645 | #define ZwCurrentProcess() NtCurrentProcess()
|
---|
6646 | NTSYSCALLAPI
|
---|
6647 | NTSTATUS
|
---|
6648 | NTAPI
|
---|
6649 | NtQueryInformationProcess(
|
---|
6650 | IN HANDLE ProcessHandle,
|
---|
6651 | IN PROCESSINFOCLASS ProcessInformationClass,
|
---|
6652 | OUT PVOID ProcessInformation,
|
---|
6653 | IN ULONG ProcessInformationLength,
|
---|
6654 | OUT PULONG ReturnLength OPTIONAL
|
---|
6655 | );
|
---|
6656 | #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
|
---|
6657 | #define ZwCurrentThread() NtCurrentThread()
|
---|
6658 |
|
---|
6659 | #ifndef _PO_DDK_
|
---|
6660 | #define _PO_DDK_
|
---|
6661 |
|
---|
6662 |
|
---|
6663 |
|
---|
6664 | typedef enum _SYSTEM_POWER_STATE {
|
---|
6665 | PowerSystemUnspecified = 0,
|
---|
6666 | PowerSystemWorking = 1,
|
---|
6667 | PowerSystemSleeping1 = 2,
|
---|
6668 | PowerSystemSleeping2 = 3,
|
---|
6669 | PowerSystemSleeping3 = 4,
|
---|
6670 | PowerSystemHibernate = 5,
|
---|
6671 | PowerSystemShutdown = 6,
|
---|
6672 | PowerSystemMaximum = 7
|
---|
6673 | } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
|
---|
6674 |
|
---|
6675 | #define POWER_SYSTEM_MAXIMUM 7
|
---|
6676 |
|
---|
6677 | typedef enum {
|
---|
6678 | PowerActionNone = 0,
|
---|
6679 | PowerActionReserved,
|
---|
6680 | PowerActionSleep,
|
---|
6681 | PowerActionHibernate,
|
---|
6682 | PowerActionShutdown,
|
---|
6683 | PowerActionShutdownReset,
|
---|
6684 | PowerActionShutdownOff,
|
---|
6685 | PowerActionWarmEject
|
---|
6686 | } POWER_ACTION, *PPOWER_ACTION;
|
---|
6687 |
|
---|
6688 | typedef enum _DEVICE_POWER_STATE {
|
---|
6689 | PowerDeviceUnspecified = 0,
|
---|
6690 | PowerDeviceD0,
|
---|
6691 | PowerDeviceD1,
|
---|
6692 | PowerDeviceD2,
|
---|
6693 | PowerDeviceD3,
|
---|
6694 | PowerDeviceMaximum
|
---|
6695 | } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
|
---|
6696 |
|
---|
6697 |
|
---|
6698 |
|
---|
6699 | typedef union _POWER_STATE {
|
---|
6700 | SYSTEM_POWER_STATE SystemState;
|
---|
6701 | DEVICE_POWER_STATE DeviceState;
|
---|
6702 | } POWER_STATE, *PPOWER_STATE;
|
---|
6703 |
|
---|
6704 | typedef enum _POWER_STATE_TYPE {
|
---|
6705 | SystemPowerState = 0,
|
---|
6706 | DevicePowerState
|
---|
6707 | } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
|
---|
6708 |
|
---|
6709 | //
|
---|
6710 | // Generic power related IOCTLs
|
---|
6711 | //
|
---|
6712 |
|
---|
6713 | #define IOCTL_QUERY_DEVICE_POWER_STATE \
|
---|
6714 | CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
|
---|
6715 |
|
---|
6716 | #define IOCTL_SET_DEVICE_WAKE \
|
---|
6717 | CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
---|
6718 |
|
---|
6719 | #define IOCTL_CANCEL_DEVICE_WAKE \
|
---|
6720 | CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
---|
6721 |
|
---|
6722 |
|
---|
6723 | //
|
---|
6724 | // Defines for W32 interfaces
|
---|
6725 | //
|
---|
6726 |
|
---|
6727 |
|
---|
6728 |
|
---|
6729 | #define ES_SYSTEM_REQUIRED ((ULONG)0x00000001)
|
---|
6730 | #define ES_DISPLAY_REQUIRED ((ULONG)0x00000002)
|
---|
6731 | #define ES_USER_PRESENT ((ULONG)0x00000004)
|
---|
6732 | #define ES_CONTINUOUS ((ULONG)0x80000000)
|
---|
6733 |
|
---|
6734 | typedef ULONG EXECUTION_STATE;
|
---|
6735 |
|
---|
6736 | typedef enum {
|
---|
6737 | LT_DONT_CARE,
|
---|
6738 | LT_LOWEST_LATENCY
|
---|
6739 | } LATENCY_TIME;
|
---|
6740 |
|
---|
6741 |
|
---|
6742 | typedef enum {
|
---|
6743 | SystemPowerPolicyAc,
|
---|
6744 | SystemPowerPolicyDc,
|
---|
6745 | VerifySystemPolicyAc,
|
---|
6746 | VerifySystemPolicyDc,
|
---|
6747 | SystemPowerCapabilities,
|
---|
6748 | SystemBatteryState,
|
---|
6749 | SystemPowerStateHandler,
|
---|
6750 | ProcessorStateHandler,
|
---|
6751 | SystemPowerPolicyCurrent,
|
---|
6752 | AdministratorPowerPolicy,
|
---|
6753 | SystemReserveHiberFile,
|
---|
6754 | ProcessorInformation,
|
---|
6755 | SystemPowerInformation,
|
---|
6756 | ProcessorStateHandler2,
|
---|
6757 | LastWakeTime, // Compare with KeQueryInterruptTime()
|
---|
6758 | LastSleepTime, // Compare with KeQueryInterruptTime()
|
---|
6759 | SystemExecutionState,
|
---|
6760 | SystemPowerStateNotifyHandler,
|
---|
6761 | ProcessorPowerPolicyAc,
|
---|
6762 | ProcessorPowerPolicyDc,
|
---|
6763 | VerifyProcessorPowerPolicyAc,
|
---|
6764 | VerifyProcessorPowerPolicyDc,
|
---|
6765 | ProcessorPowerPolicyCurrent,
|
---|
6766 | SystemPowerStateLogging,
|
---|
6767 | SystemPowerLoggingEntry
|
---|
6768 | } POWER_INFORMATION_LEVEL;
|
---|
6769 |
|
---|
6770 |
|
---|
6771 |
|
---|
6772 | //
|
---|
6773 | // System power manager capabilities
|
---|
6774 | //
|
---|
6775 |
|
---|
6776 | typedef struct {
|
---|
6777 | ULONG Granularity;
|
---|
6778 | ULONG Capacity;
|
---|
6779 | } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
|
---|
6780 |
|
---|
6781 |
|
---|
6782 |
|
---|
6783 |
|
---|
6784 | #endif // !_PO_DDK_
|
---|
6785 |
|
---|
6786 |
|
---|
6787 | #if defined(_X86_)
|
---|
6788 |
|
---|
6789 | //
|
---|
6790 | // Types to use to contain PFNs and their counts.
|
---|
6791 | //
|
---|
6792 |
|
---|
6793 | typedef ULONG PFN_COUNT;
|
---|
6794 |
|
---|
6795 | typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
|
---|
6796 | typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
|
---|
6797 |
|
---|
6798 | //
|
---|
6799 | // Define maximum size of flush multiple TB request.
|
---|
6800 | //
|
---|
6801 |
|
---|
6802 | #define FLUSH_MULTIPLE_MAXIMUM 32
|
---|
6803 |
|
---|
6804 | //
|
---|
6805 | // Indicate that the i386 compiler supports the pragma textout construct.
|
---|
6806 | //
|
---|
6807 |
|
---|
6808 | #define ALLOC_PRAGMA 1
|
---|
6809 | //
|
---|
6810 | // Indicate that the i386 compiler supports the DATA_SEG("INIT") and
|
---|
6811 | // DATA_SEG("PAGE") pragmas
|
---|
6812 | //
|
---|
6813 |
|
---|
6814 | #define ALLOC_DATA_PRAGMA 1
|
---|
6815 |
|
---|
6816 | #define NORMAL_DISPATCH_LENGTH 106
|
---|
6817 | #define DISPATCH_LENGTH NORMAL_DISPATCH_LENGTH
|
---|
6818 | //
|
---|
6819 | // Interrupt Request Level definitions
|
---|
6820 | //
|
---|
6821 |
|
---|
6822 | #define PASSIVE_LEVEL 0 // Passive release level
|
---|
6823 | #define LOW_LEVEL 0 // Lowest interrupt level
|
---|
6824 | #define APC_LEVEL 1 // APC interrupt level
|
---|
6825 | #define DISPATCH_LEVEL 2 // Dispatcher level
|
---|
6826 |
|
---|
6827 | #define PROFILE_LEVEL 27 // timer used for profiling.
|
---|
6828 | #define CLOCK1_LEVEL 28 // Interval clock 1 level - Not used on x86
|
---|
6829 | #define CLOCK2_LEVEL 28 // Interval clock 2 level
|
---|
6830 | #define IPI_LEVEL 29 // Interprocessor interrupt level
|
---|
6831 | #define POWER_LEVEL 30 // Power failure level
|
---|
6832 | #define HIGH_LEVEL 31 // Highest interrupt level
|
---|
6833 |
|
---|
6834 | #define SYNCH_LEVEL (IPI_LEVEL-2)
|
---|
6835 |
|
---|
6836 | //
|
---|
6837 | // I/O space read and write macros.
|
---|
6838 | //
|
---|
6839 | // These have to be actual functions on the 386, because we need
|
---|
6840 | // to use assembler, but cannot return a value if we inline it.
|
---|
6841 | //
|
---|
6842 | // The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space.
|
---|
6843 | // (Use x86 move instructions, with LOCK prefix to force correct behavior
|
---|
6844 | // w.r.t. caches and write buffers.)
|
---|
6845 | //
|
---|
6846 | // The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space.
|
---|
6847 | // (Use x86 in/out instructions.)
|
---|
6848 | //
|
---|
6849 |
|
---|
6850 | NTKERNELAPI
|
---|
6851 | UCHAR
|
---|
6852 | NTAPI
|
---|
6853 | READ_REGISTER_UCHAR(
|
---|
6854 | PUCHAR Register
|
---|
6855 | );
|
---|
6856 |
|
---|
6857 | NTKERNELAPI
|
---|
6858 | USHORT
|
---|
6859 | NTAPI
|
---|
6860 | READ_REGISTER_USHORT(
|
---|
6861 | PUSHORT Register
|
---|
6862 | );
|
---|
6863 |
|
---|
6864 | NTKERNELAPI
|
---|
6865 | ULONG
|
---|
6866 | NTAPI
|
---|
6867 | READ_REGISTER_ULONG(
|
---|
6868 | PULONG Register
|
---|
6869 | );
|
---|
6870 |
|
---|
6871 | NTKERNELAPI
|
---|
6872 | VOID
|
---|
6873 | NTAPI
|
---|
6874 | READ_REGISTER_BUFFER_UCHAR(
|
---|
6875 | PUCHAR Register,
|
---|
6876 | PUCHAR Buffer,
|
---|
6877 | ULONG Count
|
---|
6878 | );
|
---|
6879 |
|
---|
6880 | NTKERNELAPI
|
---|
6881 | VOID
|
---|
6882 | NTAPI
|
---|
6883 | READ_REGISTER_BUFFER_USHORT(
|
---|
6884 | PUSHORT Register,
|
---|
6885 | PUSHORT Buffer,
|
---|
6886 | ULONG Count
|
---|
6887 | );
|
---|
6888 |
|
---|
6889 | NTKERNELAPI
|
---|
6890 | VOID
|
---|
6891 | NTAPI
|
---|
6892 | READ_REGISTER_BUFFER_ULONG(
|
---|
6893 | PULONG Register,
|
---|
6894 | PULONG Buffer,
|
---|
6895 | ULONG Count
|
---|
6896 | );
|
---|
6897 |
|
---|
6898 |
|
---|
6899 | NTKERNELAPI
|
---|
6900 | VOID
|
---|
6901 | NTAPI
|
---|
6902 | WRITE_REGISTER_UCHAR(
|
---|
6903 | PUCHAR Register,
|
---|
6904 | UCHAR Value
|
---|
6905 | );
|
---|
6906 |
|
---|
6907 | NTKERNELAPI
|
---|
6908 | VOID
|
---|
6909 | NTAPI
|
---|
6910 | WRITE_REGISTER_USHORT(
|
---|
6911 | PUSHORT Register,
|
---|
6912 | USHORT Value
|
---|
6913 | );
|
---|
6914 |
|
---|
6915 | NTKERNELAPI
|
---|
6916 | VOID
|
---|
6917 | NTAPI
|
---|
6918 | WRITE_REGISTER_ULONG(
|
---|
6919 | PULONG Register,
|
---|
6920 | ULONG Value
|
---|
6921 | );
|
---|
6922 |
|
---|
6923 | NTKERNELAPI
|
---|
6924 | VOID
|
---|
6925 | NTAPI
|
---|
6926 | WRITE_REGISTER_BUFFER_UCHAR(
|
---|
6927 | PUCHAR Register,
|
---|
6928 | PUCHAR Buffer,
|
---|
6929 | ULONG Count
|
---|
6930 | );
|
---|
6931 |
|
---|
6932 | NTKERNELAPI
|
---|
6933 | VOID
|
---|
6934 | NTAPI
|
---|
6935 | WRITE_REGISTER_BUFFER_USHORT(
|
---|
6936 | PUSHORT Register,
|
---|
6937 | PUSHORT Buffer,
|
---|
6938 | ULONG Count
|
---|
6939 | );
|
---|
6940 |
|
---|
6941 | NTKERNELAPI
|
---|
6942 | VOID
|
---|
6943 | NTAPI
|
---|
6944 | WRITE_REGISTER_BUFFER_ULONG(
|
---|
6945 | PULONG Register,
|
---|
6946 | PULONG Buffer,
|
---|
6947 | ULONG Count
|
---|
6948 | );
|
---|
6949 |
|
---|
6950 | NTHALAPI
|
---|
6951 | UCHAR
|
---|
6952 | NTAPI
|
---|
6953 | READ_PORT_UCHAR(
|
---|
6954 | PUCHAR Port
|
---|
6955 | );
|
---|
6956 |
|
---|
6957 | NTHALAPI
|
---|
6958 | USHORT
|
---|
6959 | NTAPI
|
---|
6960 | READ_PORT_USHORT(
|
---|
6961 | PUSHORT Port
|
---|
6962 | );
|
---|
6963 |
|
---|
6964 | NTHALAPI
|
---|
6965 | ULONG
|
---|
6966 | NTAPI
|
---|
6967 | READ_PORT_ULONG(
|
---|
6968 | PULONG Port
|
---|
6969 | );
|
---|
6970 |
|
---|
6971 | NTHALAPI
|
---|
6972 | VOID
|
---|
6973 | NTAPI
|
---|
6974 | READ_PORT_BUFFER_UCHAR(
|
---|
6975 | PUCHAR Port,
|
---|
6976 | PUCHAR Buffer,
|
---|
6977 | ULONG Count
|
---|
6978 | );
|
---|
6979 |
|
---|
6980 | NTHALAPI
|
---|
6981 | VOID
|
---|
6982 | NTAPI
|
---|
6983 | READ_PORT_BUFFER_USHORT(
|
---|
6984 | PUSHORT Port,
|
---|
6985 | PUSHORT Buffer,
|
---|
6986 | ULONG Count
|
---|
6987 | );
|
---|
6988 |
|
---|
6989 | NTHALAPI
|
---|
6990 | VOID
|
---|
6991 | NTAPI
|
---|
6992 | READ_PORT_BUFFER_ULONG(
|
---|
6993 | PULONG Port,
|
---|
6994 | PULONG Buffer,
|
---|
6995 | ULONG Count
|
---|
6996 | );
|
---|
6997 |
|
---|
6998 | NTHALAPI
|
---|
6999 | VOID
|
---|
7000 | NTAPI
|
---|
7001 | WRITE_PORT_UCHAR(
|
---|
7002 | PUCHAR Port,
|
---|
7003 | UCHAR Value
|
---|
7004 | );
|
---|
7005 |
|
---|
7006 | NTHALAPI
|
---|
7007 | VOID
|
---|
7008 | NTAPI
|
---|
7009 | WRITE_PORT_USHORT(
|
---|
7010 | PUSHORT Port,
|
---|
7011 | USHORT Value
|
---|
7012 | );
|
---|
7013 |
|
---|
7014 | NTHALAPI
|
---|
7015 | VOID
|
---|
7016 | NTAPI
|
---|
7017 | WRITE_PORT_ULONG(
|
---|
7018 | PULONG Port,
|
---|
7019 | ULONG Value
|
---|
7020 | );
|
---|
7021 |
|
---|
7022 | NTHALAPI
|
---|
7023 | VOID
|
---|
7024 | NTAPI
|
---|
7025 | WRITE_PORT_BUFFER_UCHAR(
|
---|
7026 | PUCHAR Port,
|
---|
7027 | PUCHAR Buffer,
|
---|
7028 | ULONG Count
|
---|
7029 | );
|
---|
7030 |
|
---|
7031 | NTHALAPI
|
---|
7032 | VOID
|
---|
7033 | NTAPI
|
---|
7034 | WRITE_PORT_BUFFER_USHORT(
|
---|
7035 | PUSHORT Port,
|
---|
7036 | PUSHORT Buffer,
|
---|
7037 | ULONG Count
|
---|
7038 | );
|
---|
7039 |
|
---|
7040 | NTHALAPI
|
---|
7041 | VOID
|
---|
7042 | NTAPI
|
---|
7043 | WRITE_PORT_BUFFER_ULONG(
|
---|
7044 | PULONG Port,
|
---|
7045 | PULONG Buffer,
|
---|
7046 | ULONG Count
|
---|
7047 | );
|
---|
7048 |
|
---|
7049 |
|
---|
7050 | //
|
---|
7051 | // Get data cache fill size.
|
---|
7052 | //
|
---|
7053 |
|
---|
7054 | #if PRAGMA_DEPRECATED_DDK
|
---|
7055 | #pragma deprecated(KeGetDcacheFillSize) // Use GetDmaAlignment
|
---|
7056 | #endif
|
---|
7057 |
|
---|
7058 | #define KeGetDcacheFillSize() 1L
|
---|
7059 |
|
---|
7060 |
|
---|
7061 | #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
|
---|
7062 |
|
---|
7063 |
|
---|
7064 | #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
|
---|
7065 | #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
|
---|
7066 | #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
|
---|
7067 | #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
|
---|
7068 |
|
---|
7069 |
|
---|
7070 | #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
|
---|
7071 |
|
---|
7072 |
|
---|
7073 |
|
---|
7074 | #define KeQueryTickCount(CurrentCount ) { \
|
---|
7075 | volatile PKSYSTEM_TIME _TickCount = *((PKSYSTEM_TIME *)(&KeTickCount)); \
|
---|
7076 | while (TRUE) { \
|
---|
7077 | (CurrentCount)->HighPart = _TickCount->High1Time; \
|
---|
7078 | (CurrentCount)->LowPart = _TickCount->LowPart; \
|
---|
7079 | if ((CurrentCount)->HighPart == _TickCount->High2Time) break; \
|
---|
7080 | _asm { rep nop } \
|
---|
7081 | } \
|
---|
7082 | }
|
---|
7083 |
|
---|
7084 |
|
---|
7085 |
|
---|
7086 | #else
|
---|
7087 |
|
---|
7088 |
|
---|
7089 | VOID
|
---|
7090 | NTAPI
|
---|
7091 | KeQueryTickCount (
|
---|
7092 | OUT PLARGE_INTEGER CurrentCount
|
---|
7093 | );
|
---|
7094 |
|
---|
7095 | #endif // defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
|
---|
7096 |
|
---|
7097 |
|
---|
7098 | //
|
---|
7099 | // Processor Control Region Structure Definition
|
---|
7100 | //
|
---|
7101 |
|
---|
7102 | #define PCR_MINOR_VERSION 1
|
---|
7103 | #define PCR_MAJOR_VERSION 1
|
---|
7104 |
|
---|
7105 | typedef struct _KPCR {
|
---|
7106 |
|
---|
7107 | //
|
---|
7108 | // Start of the architecturally defined section of the PCR. This section
|
---|
7109 | // may be directly addressed by vendor/platform specific HAL code and will
|
---|
7110 | // not change from version to version of NT.
|
---|
7111 | //
|
---|
7112 | // Certain fields in the TIB are not used in kernel mode. These include the
|
---|
7113 | // stack limit, subsystem TIB, fiber data, arbitrary user pointer, and the
|
---|
7114 | // self address of then PCR itself (another field has been added for that
|
---|
7115 | // purpose). Therefore, these fields are overlaid with other data to get
|
---|
7116 | // better cache locality.
|
---|
7117 | //
|
---|
7118 |
|
---|
7119 | union {
|
---|
7120 | NT_TIB NtTib;
|
---|
7121 | struct {
|
---|
7122 | struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
|
---|
7123 | PVOID Used_StackBase;
|
---|
7124 | PVOID PerfGlobalGroupMask;
|
---|
7125 | PVOID TssCopy;
|
---|
7126 | ULONG ContextSwitches;
|
---|
7127 | KAFFINITY SetMemberCopy;
|
---|
7128 | PVOID Used_Self;
|
---|
7129 | };
|
---|
7130 | };
|
---|
7131 |
|
---|
7132 | struct _KPCR *SelfPcr; // flat address of this PCR
|
---|
7133 | struct _KPRCB *Prcb; // pointer to Prcb
|
---|
7134 | KIRQL Irql; // do not use 3 bytes after this as
|
---|
7135 | // HALs assume they are zero.
|
---|
7136 | ULONG IRR;
|
---|
7137 | ULONG IrrActive;
|
---|
7138 | ULONG IDR;
|
---|
7139 | PVOID KdVersionBlock;
|
---|
7140 |
|
---|
7141 | struct _KIDTENTRY *IDT;
|
---|
7142 | struct _KGDTENTRY *GDT;
|
---|
7143 | struct _KTSS *TSS;
|
---|
7144 | USHORT MajorVersion;
|
---|
7145 | USHORT MinorVersion;
|
---|
7146 | KAFFINITY SetMember;
|
---|
7147 | ULONG StallScaleFactor;
|
---|
7148 | UCHAR SpareUnused;
|
---|
7149 | UCHAR Number;
|
---|
7150 |
|
---|
7151 |
|
---|
7152 | } KPCR, *PKPCR;
|
---|
7153 |
|
---|
7154 | //
|
---|
7155 | // The non-volatile 387 state
|
---|
7156 | //
|
---|
7157 |
|
---|
7158 | typedef struct _KFLOATING_SAVE {
|
---|
7159 | ULONG ControlWord;
|
---|
7160 | ULONG StatusWord;
|
---|
7161 | ULONG ErrorOffset;
|
---|
7162 | ULONG ErrorSelector;
|
---|
7163 | ULONG DataOffset; // Not used in wdm
|
---|
7164 | ULONG DataSelector;
|
---|
7165 | ULONG Cr0NpxState;
|
---|
7166 | ULONG Spare1; // Not used in wdm
|
---|
7167 | } KFLOATING_SAVE, *PKFLOATING_SAVE;
|
---|
7168 |
|
---|
7169 | //
|
---|
7170 | // i386 Specific portions of mm component
|
---|
7171 | //
|
---|
7172 |
|
---|
7173 | //
|
---|
7174 | // Define the page size for the Intel 386 as 4096 (0x1000).
|
---|
7175 | //
|
---|
7176 |
|
---|
7177 | #define PAGE_SIZE 0x1000
|
---|
7178 |
|
---|
7179 | //
|
---|
7180 | // Define the number of trailing zeroes in a page aligned virtual address.
|
---|
7181 | // This is used as the shift count when shifting virtual addresses to
|
---|
7182 | // virtual page numbers.
|
---|
7183 | //
|
---|
7184 |
|
---|
7185 | #define PAGE_SHIFT 12L
|
---|
7186 |
|
---|
7187 |
|
---|
7188 | //
|
---|
7189 | // Define the number of bits to shift to right justify the Page Directory Index
|
---|
7190 | // field of a PTE.
|
---|
7191 | //
|
---|
7192 |
|
---|
7193 | #define PDI_SHIFT_X86 22
|
---|
7194 | #define PDI_SHIFT_X86PAE 21
|
---|
7195 |
|
---|
7196 | #if !defined (_X86PAE_)
|
---|
7197 | #define PDI_SHIFT PDI_SHIFT_X86
|
---|
7198 | #else
|
---|
7199 | #define PDI_SHIFT PDI_SHIFT_X86PAE
|
---|
7200 | #define PPI_SHIFT 30
|
---|
7201 | #endif
|
---|
7202 |
|
---|
7203 | //
|
---|
7204 | // Define the number of bits to shift to right justify the Page Table Index
|
---|
7205 | // field of a PTE.
|
---|
7206 | //
|
---|
7207 |
|
---|
7208 | #define PTI_SHIFT 12
|
---|
7209 |
|
---|
7210 | //
|
---|
7211 | // Define the highest user address and user probe address.
|
---|
7212 | //
|
---|
7213 |
|
---|
7214 |
|
---|
7215 | extern PVOID *MmHighestUserAddress;
|
---|
7216 | extern PVOID *MmSystemRangeStart;
|
---|
7217 | extern ULONG *MmUserProbeAddress;
|
---|
7218 |
|
---|
7219 | #define MM_HIGHEST_USER_ADDRESS *MmHighestUserAddress
|
---|
7220 | #define MM_SYSTEM_RANGE_START *MmSystemRangeStart
|
---|
7221 | #define MM_USER_PROBE_ADDRESS *MmUserProbeAddress
|
---|
7222 |
|
---|
7223 | //
|
---|
7224 | // The lowest user address reserves the low 64k.
|
---|
7225 | //
|
---|
7226 |
|
---|
7227 | #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
|
---|
7228 |
|
---|
7229 | //
|
---|
7230 | // The lowest address for system space.
|
---|
7231 | //
|
---|
7232 |
|
---|
7233 | #if !defined (_X86PAE_)
|
---|
7234 | #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
|
---|
7235 | #else
|
---|
7236 | #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
|
---|
7237 | #endif
|
---|
7238 |
|
---|
7239 |
|
---|
7240 |
|
---|
7241 | #define MmGetProcedureAddress(Address) (Address)
|
---|
7242 | #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
|
---|
7243 |
|
---|
7244 | #define KIP0PCRADDRESS 0xffdff000
|
---|
7245 |
|
---|
7246 | #define KI_USER_SHARED_DATA 0xffdf0000
|
---|
7247 | #define SharedUserData ((KUSER_SHARED_DATA * const) KI_USER_SHARED_DATA)
|
---|
7248 |
|
---|
7249 | //
|
---|
7250 | // Result type definition for i386. (Machine specific enumerate type
|
---|
7251 | // which is return type for portable exinterlockedincrement/decrement
|
---|
7252 | // procedures.) In general, you should use the enumerated type defined
|
---|
7253 | // in ex.h instead of directly referencing these constants.
|
---|
7254 | //
|
---|
7255 |
|
---|
7256 | // Flags loaded into AH by LAHF instruction
|
---|
7257 |
|
---|
7258 | #define EFLAG_SIGN 0x8000
|
---|
7259 | #define EFLAG_ZERO 0x4000
|
---|
7260 | #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
|
---|
7261 |
|
---|
7262 | #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
|
---|
7263 | #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
|
---|
7264 | #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
|
---|
7265 |
|
---|
7266 | //
|
---|
7267 | // Convert various portable ExInterlock APIs into their architectural
|
---|
7268 | // equivalents.
|
---|
7269 | //
|
---|
7270 |
|
---|
7271 | #if PRAGMA_DEPRECATED_DDK
|
---|
7272 | #pragma deprecated(ExInterlockedIncrementLong) // Use InterlockedIncrement
|
---|
7273 | #pragma deprecated(ExInterlockedDecrementLong) // Use InterlockedDecrement
|
---|
7274 | #pragma deprecated(ExInterlockedExchangeUlong) // Use InterlockedExchange
|
---|
7275 | #endif
|
---|
7276 |
|
---|
7277 | #define ExInterlockedIncrementLong(Addend,Lock) \
|
---|
7278 | Exfi386InterlockedIncrementLong(Addend)
|
---|
7279 |
|
---|
7280 | #define ExInterlockedDecrementLong(Addend,Lock) \
|
---|
7281 | Exfi386InterlockedDecrementLong(Addend)
|
---|
7282 |
|
---|
7283 | #define ExInterlockedExchangeUlong(Target,Value,Lock) \
|
---|
7284 | Exfi386InterlockedExchangeUlong(Target,Value)
|
---|
7285 |
|
---|
7286 |
|
---|
7287 |
|
---|
7288 | #define ExInterlockedAddUlong ExfInterlockedAddUlong
|
---|
7289 | #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList
|
---|
7290 | #define ExInterlockedInsertTailList ExfInterlockedInsertTailList
|
---|
7291 | #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList
|
---|
7292 | #define ExInterlockedPopEntryList ExfInterlockedPopEntryList
|
---|
7293 | #define ExInterlockedPushEntryList ExfInterlockedPushEntryList
|
---|
7294 |
|
---|
7295 |
|
---|
7296 |
|
---|
7297 | //
|
---|
7298 | // Prototypes for architectural specific versions of Exi386 Api
|
---|
7299 | //
|
---|
7300 |
|
---|
7301 | //
|
---|
7302 | // Interlocked result type is portable, but its values are machine specific.
|
---|
7303 | // Constants for value are in i386.h, mips.h, etc.
|
---|
7304 | //
|
---|
7305 |
|
---|
7306 | typedef enum _INTERLOCKED_RESULT {
|
---|
7307 | ResultNegative = RESULT_NEGATIVE,
|
---|
7308 | ResultZero = RESULT_ZERO,
|
---|
7309 | ResultPositive = RESULT_POSITIVE
|
---|
7310 | } INTERLOCKED_RESULT;
|
---|
7311 |
|
---|
7312 | NTKERNELAPI
|
---|
7313 | INTERLOCKED_RESULT
|
---|
7314 | FASTCALL
|
---|
7315 | Exfi386InterlockedIncrementLong (
|
---|
7316 | IN PLONG Addend
|
---|
7317 | );
|
---|
7318 |
|
---|
7319 | NTKERNELAPI
|
---|
7320 | INTERLOCKED_RESULT
|
---|
7321 | FASTCALL
|
---|
7322 | Exfi386InterlockedDecrementLong (
|
---|
7323 | IN PLONG Addend
|
---|
7324 | );
|
---|
7325 |
|
---|
7326 | NTKERNELAPI
|
---|
7327 | ULONG
|
---|
7328 | FASTCALL
|
---|
7329 | Exfi386InterlockedExchangeUlong (
|
---|
7330 | IN PULONG Target,
|
---|
7331 | IN ULONG Value
|
---|
7332 | );
|
---|
7333 |
|
---|
7334 | #if !defined(_WINBASE_) && !defined(NONTOSPINTERLOCK)
|
---|
7335 | #if !defined(MIDL_PASS) // wdm
|
---|
7336 | #if defined(NO_INTERLOCKED_INTRINSICS) || defined(_CROSS_PLATFORM_)
|
---|
7337 |
|
---|
7338 |
|
---|
7339 | NTKERNELAPI
|
---|
7340 | LONG
|
---|
7341 | FASTCALL
|
---|
7342 | InterlockedIncrement(
|
---|
7343 | IN LONG volatile *Addend
|
---|
7344 | );
|
---|
7345 |
|
---|
7346 | NTKERNELAPI
|
---|
7347 | LONG
|
---|
7348 | FASTCALL
|
---|
7349 | InterlockedDecrement(
|
---|
7350 | IN LONG volatile *Addend
|
---|
7351 | );
|
---|
7352 |
|
---|
7353 | NTKERNELAPI
|
---|
7354 | LONG
|
---|
7355 | FASTCALL
|
---|
7356 | InterlockedExchange(
|
---|
7357 | IN OUT LONG volatile *Target,
|
---|
7358 | IN LONG Value
|
---|
7359 | );
|
---|
7360 |
|
---|
7361 | #define InterlockedExchangePointer(Target, Value) \
|
---|
7362 | (PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value))
|
---|
7363 |
|
---|
7364 | LONG
|
---|
7365 | FASTCALL
|
---|
7366 | InterlockedExchangeAdd(
|
---|
7367 | IN OUT LONG volatile *Addend,
|
---|
7368 | IN LONG Increment
|
---|
7369 | );
|
---|
7370 |
|
---|
7371 | NTKERNELAPI
|
---|
7372 | LONG
|
---|
7373 | FASTCALL
|
---|
7374 | InterlockedCompareExchange(
|
---|
7375 | IN OUT LONG volatile *Destination,
|
---|
7376 | IN LONG ExChange,
|
---|
7377 | IN LONG Comperand
|
---|
7378 | );
|
---|
7379 |
|
---|
7380 | #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
|
---|
7381 | (PVOID)InterlockedCompareExchange((PLONG)Destination, (LONG)ExChange, (LONG)Comperand)
|
---|
7382 |
|
---|
7383 | #define InterlockedCompareExchange64(Destination, ExChange, Comperand) \
|
---|
7384 | ExfInterlockedCompareExchange64(Destination, &(ExChange), &(Comperand))
|
---|
7385 |
|
---|
7386 | NTKERNELAPI
|
---|
7387 | LONGLONG
|
---|
7388 | FASTCALL
|
---|
7389 | ExfInterlockedCompareExchange64(
|
---|
7390 | IN OUT LONGLONG volatile *Destination,
|
---|
7391 | IN PLONGLONG ExChange,
|
---|
7392 | IN PLONGLONG Comperand
|
---|
7393 | );
|
---|
7394 |
|
---|
7395 |
|
---|
7396 |
|
---|
7397 | #else // NO_INTERLOCKED_INTRINSICS || _CROSS_PLATFORM_
|
---|
7398 |
|
---|
7399 | #define InterlockedExchangePointer(Target, Value) \
|
---|
7400 | (PVOID)InterlockedExchange((PLONG)Target, (LONG)Value)
|
---|
7401 |
|
---|
7402 |
|
---|
7403 | #if (_MSC_FULL_VER > 13009037)
|
---|
7404 | LONG
|
---|
7405 | __cdecl
|
---|
7406 | _InterlockedExchange(
|
---|
7407 | IN OUT LONG volatile *Target,
|
---|
7408 | IN LONG Value
|
---|
7409 | );
|
---|
7410 |
|
---|
7411 | #pragma intrinsic (_InterlockedExchange)
|
---|
7412 | #define InterlockedExchange _InterlockedExchange
|
---|
7413 | #else
|
---|
7414 | FORCEINLINE
|
---|
7415 | LONG
|
---|
7416 | FASTCALL
|
---|
7417 | InterlockedExchange(
|
---|
7418 | IN OUT LONG volatile *Target,
|
---|
7419 | IN LONG Value
|
---|
7420 | )
|
---|
7421 | {
|
---|
7422 | __asm {
|
---|
7423 | mov eax, Value
|
---|
7424 | mov ecx, Target
|
---|
7425 | xchg [ecx], eax
|
---|
7426 | }
|
---|
7427 | }
|
---|
7428 | #endif
|
---|
7429 |
|
---|
7430 | #if (_MSC_FULL_VER > 13009037)
|
---|
7431 | LONG
|
---|
7432 | __cdecl
|
---|
7433 | _InterlockedIncrement(
|
---|
7434 | IN LONG volatile *Addend
|
---|
7435 | );
|
---|
7436 |
|
---|
7437 | #pragma intrinsic (_InterlockedIncrement)
|
---|
7438 | #define InterlockedIncrement _InterlockedIncrement
|
---|
7439 | #else
|
---|
7440 | #define InterlockedIncrement(Addend) (InterlockedExchangeAdd (Addend, 1)+1)
|
---|
7441 | #endif
|
---|
7442 |
|
---|
7443 | #if (_MSC_FULL_VER > 13009037)
|
---|
7444 | LONG
|
---|
7445 | __cdecl
|
---|
7446 | _InterlockedDecrement(
|
---|
7447 | IN LONG volatile *Addend
|
---|
7448 | );
|
---|
7449 |
|
---|
7450 | #pragma intrinsic (_InterlockedDecrement)
|
---|
7451 | #define InterlockedDecrement _InterlockedDecrement
|
---|
7452 | #else
|
---|
7453 | #define InterlockedDecrement(Addend) (InterlockedExchangeAdd (Addend, -1)-1)
|
---|
7454 | #endif
|
---|
7455 |
|
---|
7456 | #if (_MSC_FULL_VER > 13009037)
|
---|
7457 | LONG
|
---|
7458 | __cdecl
|
---|
7459 | _InterlockedExchangeAdd(
|
---|
7460 | IN OUT LONG volatile *Addend,
|
---|
7461 | IN LONG Increment
|
---|
7462 | );
|
---|
7463 |
|
---|
7464 | #pragma intrinsic (_InterlockedExchangeAdd)
|
---|
7465 | #define InterlockedExchangeAdd _InterlockedExchangeAdd
|
---|
7466 | #else
|
---|
7467 |
|
---|
7468 | FORCEINLINE
|
---|
7469 | LONG
|
---|
7470 | FASTCALL
|
---|
7471 | InterlockedExchangeAdd(
|
---|
7472 | IN OUT LONG volatile *Addend,
|
---|
7473 | IN LONG Increment
|
---|
7474 | )
|
---|
7475 | {
|
---|
7476 | __asm {
|
---|
7477 | mov eax, Increment
|
---|
7478 | mov ecx, Addend
|
---|
7479 | lock xadd [ecx], eax
|
---|
7480 | }
|
---|
7481 | }
|
---|
7482 |
|
---|
7483 | #endif
|
---|
7484 |
|
---|
7485 | #if (_MSC_FULL_VER > 13009037)
|
---|
7486 | LONG
|
---|
7487 | __cdecl
|
---|
7488 | _InterlockedCompareExchange (
|
---|
7489 | IN OUT LONG volatile *Destination,
|
---|
7490 | IN LONG ExChange,
|
---|
7491 | IN LONG Comperand
|
---|
7492 | );
|
---|
7493 |
|
---|
7494 | #pragma intrinsic (_InterlockedCompareExchange)
|
---|
7495 | #define InterlockedCompareExchange (LONG)_InterlockedCompareExchange
|
---|
7496 | #else
|
---|
7497 | FORCEINLINE
|
---|
7498 | LONG
|
---|
7499 | FASTCALL
|
---|
7500 | InterlockedCompareExchange(
|
---|
7501 | IN OUT LONG volatile *Destination,
|
---|
7502 | IN LONG Exchange,
|
---|
7503 | IN LONG Comperand
|
---|
7504 | )
|
---|
7505 | {
|
---|
7506 | __asm {
|
---|
7507 | mov eax, Comperand
|
---|
7508 | mov ecx, Destination
|
---|
7509 | mov edx, Exchange
|
---|
7510 | lock cmpxchg [ecx], edx
|
---|
7511 | }
|
---|
7512 | }
|
---|
7513 | #endif
|
---|
7514 |
|
---|
7515 | #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
|
---|
7516 | (PVOID)InterlockedCompareExchange((PLONG)Destination, (LONG)ExChange, (LONG)Comperand)
|
---|
7517 |
|
---|
7518 | #define InterlockedCompareExchange64(Destination, ExChange, Comperand) \
|
---|
7519 | ExfInterlockedCompareExchange64(Destination, &(ExChange), &(Comperand))
|
---|
7520 |
|
---|
7521 | NTKERNELAPI
|
---|
7522 | LONGLONG
|
---|
7523 | FASTCALL
|
---|
7524 | ExfInterlockedCompareExchange64(
|
---|
7525 | IN OUT LONGLONG volatile *Destination,
|
---|
7526 | IN PLONGLONG ExChange,
|
---|
7527 | IN PLONGLONG Comperand
|
---|
7528 | );
|
---|
7529 |
|
---|
7530 | #endif // INTERLOCKED_INTRINSICS || _CROSS_PLATFORM_
|
---|
7531 |
|
---|
7532 | #endif // MIDL_PASS
|
---|
7533 |
|
---|
7534 | #define InterlockedIncrementAcquire InterlockedIncrement
|
---|
7535 | #define InterlockedIncrementRelease InterlockedIncrement
|
---|
7536 | #define InterlockedDecrementAcquire InterlockedDecrement
|
---|
7537 | #define InterlockedDecrementRelease InterlockedDecrement
|
---|
7538 | #define InterlockedExchangeAcquire64 InterlockedExchange64
|
---|
7539 | #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
|
---|
7540 | #define InterlockedCompareExchangeRelease InterlockedCompareExchange
|
---|
7541 | #define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
|
---|
7542 | #define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
|
---|
7543 |
|
---|
7544 | #endif // __WINBASE__ && !NONTOSPINTERLOCK
|
---|
7545 |
|
---|
7546 | //
|
---|
7547 | // Turn these intrinsics off until the compiler can handle them
|
---|
7548 | //
|
---|
7549 | #if (_MSC_FULL_VER > 13009037)
|
---|
7550 |
|
---|
7551 | LONG
|
---|
7552 | _InterlockedOr (
|
---|
7553 | IN OUT LONG volatile *Target,
|
---|
7554 | IN LONG Set
|
---|
7555 | );
|
---|
7556 |
|
---|
7557 | #pragma intrinsic (_InterlockedOr)
|
---|
7558 |
|
---|
7559 | #define InterlockedOr _InterlockedOr
|
---|
7560 |
|
---|
7561 | LONG
|
---|
7562 | _InterlockedAnd (
|
---|
7563 | IN OUT LONG volatile *Target,
|
---|
7564 | IN LONG Set
|
---|
7565 | );
|
---|
7566 |
|
---|
7567 | #pragma intrinsic (_InterlockedAnd)
|
---|
7568 |
|
---|
7569 | #define InterlockedAnd _InterlockedAnd
|
---|
7570 |
|
---|
7571 | LONG
|
---|
7572 | _InterlockedXor (
|
---|
7573 | IN OUT LONG volatile *Target,
|
---|
7574 | IN LONG Set
|
---|
7575 | );
|
---|
7576 |
|
---|
7577 | #pragma intrinsic (_InterlockedXor)
|
---|
7578 |
|
---|
7579 | #define InterlockedXor _InterlockedXor
|
---|
7580 |
|
---|
7581 | #else // compiler version
|
---|
7582 |
|
---|
7583 | FORCEINLINE
|
---|
7584 | LONG
|
---|
7585 | InterlockedAnd (
|
---|
7586 | IN OUT LONG volatile *Target,
|
---|
7587 | LONG Set
|
---|
7588 | )
|
---|
7589 | {
|
---|
7590 | LONG i;
|
---|
7591 | LONG j;
|
---|
7592 |
|
---|
7593 | j = *Target;
|
---|
7594 | do {
|
---|
7595 | i = j;
|
---|
7596 | j = InterlockedCompareExchange(Target,
|
---|
7597 | i & Set,
|
---|
7598 | i);
|
---|
7599 |
|
---|
7600 | } while (i != j);
|
---|
7601 |
|
---|
7602 | return j;
|
---|
7603 | }
|
---|
7604 |
|
---|
7605 | FORCEINLINE
|
---|
7606 | LONG
|
---|
7607 | InterlockedOr (
|
---|
7608 | IN OUT LONG volatile *Target,
|
---|
7609 | IN LONG Set
|
---|
7610 | )
|
---|
7611 | {
|
---|
7612 | LONG i;
|
---|
7613 | LONG j;
|
---|
7614 |
|
---|
7615 | j = *Target;
|
---|
7616 | do {
|
---|
7617 | i = j;
|
---|
7618 | j = InterlockedCompareExchange(Target,
|
---|
7619 | i | Set,
|
---|
7620 | i);
|
---|
7621 |
|
---|
7622 | } while (i != j);
|
---|
7623 |
|
---|
7624 | return j;
|
---|
7625 | }
|
---|
7626 |
|
---|
7627 | #endif // compiler version
|
---|
7628 |
|
---|
7629 |
|
---|
7630 |
|
---|
7631 | #if !defined(MIDL_PASS) && defined(_M_IX86)
|
---|
7632 |
|
---|
7633 | //
|
---|
7634 | // i386 function definitions
|
---|
7635 | //
|
---|
7636 |
|
---|
7637 |
|
---|
7638 |
|
---|
7639 | #if _MSC_VER >= 1200
|
---|
7640 | #pragma warning(push)
|
---|
7641 | #endif
|
---|
7642 | #pragma warning(disable:4035) // re-enable below
|
---|
7643 |
|
---|
7644 | #define _PCR fs:[0]
|
---|
7645 |
|
---|
7646 | //
|
---|
7647 | // Get current IRQL.
|
---|
7648 | //
|
---|
7649 | // On x86 this function resides in the HAL
|
---|
7650 | //
|
---|
7651 |
|
---|
7652 |
|
---|
7653 | NTHALAPI
|
---|
7654 | KIRQL
|
---|
7655 | NTAPI
|
---|
7656 | KeGetCurrentIrql();
|
---|
7657 |
|
---|
7658 |
|
---|
7659 |
|
---|
7660 | //
|
---|
7661 | // Get the current processor number
|
---|
7662 | //
|
---|
7663 |
|
---|
7664 | FORCEINLINE
|
---|
7665 | ULONG
|
---|
7666 | NTAPI
|
---|
7667 | KeGetCurrentProcessorNumber(VOID)
|
---|
7668 | {
|
---|
7669 | #if (_MSC_FULL_VER >= 13012035)
|
---|
7670 | return (ULONG) __readfsbyte (FIELD_OFFSET (KPCR, Number));
|
---|
7671 | #else
|
---|
7672 | __asm { movzx eax, _PCR KPCR.Number }
|
---|
7673 | #endif
|
---|
7674 | }
|
---|
7675 |
|
---|
7676 |
|
---|
7677 | #if _MSC_VER >= 1200
|
---|
7678 | #pragma warning(pop)
|
---|
7679 | #else
|
---|
7680 | #pragma warning(default:4035)
|
---|
7681 | #endif
|
---|
7682 |
|
---|
7683 |
|
---|
7684 | #endif // !defined(MIDL_PASS) && defined(_M_IX86)
|
---|
7685 |
|
---|
7686 |
|
---|
7687 | //++
|
---|
7688 | //
|
---|
7689 | // VOID
|
---|
7690 | // KeMemoryBarrier (
|
---|
7691 | // VOID
|
---|
7692 | // )
|
---|
7693 | //
|
---|
7694 | // VOID
|
---|
7695 | // KeMemoryBarrierWithoutFence (
|
---|
7696 | // VOID
|
---|
7697 | // )
|
---|
7698 | //
|
---|
7699 | //
|
---|
7700 | // Routine Description:
|
---|
7701 | //
|
---|
7702 | // These functions order memory accesses as seen by other processors.
|
---|
7703 | //
|
---|
7704 | // Arguments:
|
---|
7705 | //
|
---|
7706 | // None.
|
---|
7707 | //
|
---|
7708 | // Return Value:
|
---|
7709 | //
|
---|
7710 | // None.
|
---|
7711 | //
|
---|
7712 | //--
|
---|
7713 |
|
---|
7714 | #ifdef __cplusplus
|
---|
7715 | extern "C" {
|
---|
7716 | #endif
|
---|
7717 |
|
---|
7718 | VOID
|
---|
7719 | _ReadWriteBarrier(
|
---|
7720 | VOID
|
---|
7721 | );
|
---|
7722 |
|
---|
7723 | #ifdef __cplusplus
|
---|
7724 | }
|
---|
7725 | #endif
|
---|
7726 |
|
---|
7727 | #pragma intrinsic (_ReadWriteBarrier)
|
---|
7728 |
|
---|
7729 |
|
---|
7730 | FORCEINLINE
|
---|
7731 | VOID
|
---|
7732 | KeMemoryBarrier (
|
---|
7733 | VOID
|
---|
7734 | )
|
---|
7735 | {
|
---|
7736 | LONG Barrier;
|
---|
7737 | __asm {
|
---|
7738 | xchg Barrier, eax
|
---|
7739 | }
|
---|
7740 | }
|
---|
7741 |
|
---|
7742 | #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
|
---|
7743 |
|
---|
7744 |
|
---|
7745 | NTKERNELAPI
|
---|
7746 | NTSTATUS
|
---|
7747 | NTAPI
|
---|
7748 | KeSaveFloatingPointState (
|
---|
7749 | OUT PKFLOATING_SAVE FloatSave
|
---|
7750 | );
|
---|
7751 |
|
---|
7752 | NTKERNELAPI
|
---|
7753 | NTSTATUS
|
---|
7754 | NTAPI
|
---|
7755 | KeRestoreFloatingPointState (
|
---|
7756 | IN PKFLOATING_SAVE FloatSave
|
---|
7757 | );
|
---|
7758 |
|
---|
7759 |
|
---|
7760 | #endif // defined(_X86_)
|
---|
7761 |
|
---|
7762 |
|
---|
7763 | // Use the following for kernel mode runtime checks of X86 system architecture
|
---|
7764 |
|
---|
7765 | #ifdef _X86_
|
---|
7766 |
|
---|
7767 | #ifdef IsNEC_98
|
---|
7768 | #undef IsNEC_98
|
---|
7769 | #endif
|
---|
7770 |
|
---|
7771 | #ifdef IsNotNEC_98
|
---|
7772 | #undef IsNotNEC_98
|
---|
7773 | #endif
|
---|
7774 |
|
---|
7775 | #ifdef SetNEC_98
|
---|
7776 | #undef SetNEC_98
|
---|
7777 | #endif
|
---|
7778 |
|
---|
7779 | #ifdef SetNotNEC_98
|
---|
7780 | #undef SetNotNEC_98
|
---|
7781 | #endif
|
---|
7782 |
|
---|
7783 | #define IsNEC_98 (SharedUserData->AlternativeArchitecture == NEC98x86)
|
---|
7784 | #define IsNotNEC_98 (SharedUserData->AlternativeArchitecture != NEC98x86)
|
---|
7785 | #define SetNEC_98 SharedUserData->AlternativeArchitecture = NEC98x86
|
---|
7786 | #define SetNotNEC_98 SharedUserData->AlternativeArchitecture = StandardDesign
|
---|
7787 |
|
---|
7788 | #endif
|
---|
7789 |
|
---|
7790 |
|
---|
7791 | #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
---|
7792 |
|
---|
7793 | //
|
---|
7794 | // Define intrinsic function to do in's and out's.
|
---|
7795 | //
|
---|
7796 |
|
---|
7797 | #ifdef __cplusplus
|
---|
7798 | extern "C" {
|
---|
7799 | #endif
|
---|
7800 |
|
---|
7801 | UCHAR
|
---|
7802 | __inbyte (
|
---|
7803 | IN USHORT Port
|
---|
7804 | );
|
---|
7805 |
|
---|
7806 | USHORT
|
---|
7807 | __inword (
|
---|
7808 | IN USHORT Port
|
---|
7809 | );
|
---|
7810 |
|
---|
7811 | ULONG
|
---|
7812 | __indword (
|
---|
7813 | IN USHORT Port
|
---|
7814 | );
|
---|
7815 |
|
---|
7816 | VOID
|
---|
7817 | __outbyte (
|
---|
7818 | IN USHORT Port,
|
---|
7819 | IN UCHAR Data
|
---|
7820 | );
|
---|
7821 |
|
---|
7822 | VOID
|
---|
7823 | __outword (
|
---|
7824 | IN USHORT Port,
|
---|
7825 | IN USHORT Data
|
---|
7826 | );
|
---|
7827 |
|
---|
7828 | VOID
|
---|
7829 | __outdword (
|
---|
7830 | IN USHORT Port,
|
---|
7831 | IN ULONG Data
|
---|
7832 | );
|
---|
7833 |
|
---|
7834 | VOID
|
---|
7835 | __inbytestring (
|
---|
7836 | IN USHORT Port,
|
---|
7837 | IN PUCHAR Buffer,
|
---|
7838 | IN ULONG Count
|
---|
7839 | );
|
---|
7840 |
|
---|
7841 | VOID
|
---|
7842 | __inwordstring (
|
---|
7843 | IN USHORT Port,
|
---|
7844 | IN PUSHORT Buffer,
|
---|
7845 | IN ULONG Count
|
---|
7846 | );
|
---|
7847 |
|
---|
7848 | VOID
|
---|
7849 | __indwordstring (
|
---|
7850 | IN USHORT Port,
|
---|
7851 | IN PULONG Buffer,
|
---|
7852 | IN ULONG Count
|
---|
7853 | );
|
---|
7854 |
|
---|
7855 | VOID
|
---|
7856 | __outbytestring (
|
---|
7857 | IN USHORT Port,
|
---|
7858 | IN PUCHAR Buffer,
|
---|
7859 | IN ULONG Count
|
---|
7860 | );
|
---|
7861 |
|
---|
7862 | VOID
|
---|
7863 | __outwordstring (
|
---|
7864 | IN USHORT Port,
|
---|
7865 | IN PUSHORT Buffer,
|
---|
7866 | IN ULONG Count
|
---|
7867 | );
|
---|
7868 |
|
---|
7869 | VOID
|
---|
7870 | __outdwordstring (
|
---|
7871 | IN USHORT Port,
|
---|
7872 | IN PULONG Buffer,
|
---|
7873 | IN ULONG Count
|
---|
7874 | );
|
---|
7875 |
|
---|
7876 | #ifdef __cplusplus
|
---|
7877 | }
|
---|
7878 | #endif
|
---|
7879 |
|
---|
7880 | #pragma intrinsic(__inbyte)
|
---|
7881 | #pragma intrinsic(__inword)
|
---|
7882 | #pragma intrinsic(__indword)
|
---|
7883 | #pragma intrinsic(__outbyte)
|
---|
7884 | #pragma intrinsic(__outword)
|
---|
7885 | #pragma intrinsic(__outdword)
|
---|
7886 | #pragma intrinsic(__inbytestring)
|
---|
7887 | #pragma intrinsic(__inwordstring)
|
---|
7888 | #pragma intrinsic(__indwordstring)
|
---|
7889 | #pragma intrinsic(__outbytestring)
|
---|
7890 | #pragma intrinsic(__outwordstring)
|
---|
7891 | #pragma intrinsic(__outdwordstring)
|
---|
7892 |
|
---|
7893 | //
|
---|
7894 | // Interlocked intrinsic functions.
|
---|
7895 | //
|
---|
7896 |
|
---|
7897 | #define InterlockedAnd _InterlockedAnd
|
---|
7898 | #define InterlockedOr _InterlockedOr
|
---|
7899 | #define InterlockedXor _InterlockedXor
|
---|
7900 | #define InterlockedIncrement _InterlockedIncrement
|
---|
7901 | #define InterlockedIncrementAcquire InterlockedIncrement
|
---|
7902 | #define InterlockedIncrementRelease InterlockedIncrement
|
---|
7903 | #define InterlockedDecrement _InterlockedDecrement
|
---|
7904 | #define InterlockedDecrementAcquire InterlockedDecrement
|
---|
7905 | #define InterlockedDecrementRelease InterlockedDecrement
|
---|
7906 | #define InterlockedAdd _InterlockedAdd
|
---|
7907 | #define InterlockedExchange _InterlockedExchange
|
---|
7908 | #define InterlockedExchangeAdd _InterlockedExchangeAdd
|
---|
7909 | #define InterlockedCompareExchange _InterlockedCompareExchange
|
---|
7910 | #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
|
---|
7911 | #define InterlockedCompareExchangeRelease InterlockedCompareExchange
|
---|
7912 |
|
---|
7913 | #define InterlockedAnd64 _InterlockedAnd64
|
---|
7914 | #define InterlockedOr64 _InterlockedOr64
|
---|
7915 | #define InterlockedXor64 _InterlockedXor64
|
---|
7916 | #define InterlockedIncrement64 _InterlockedIncrement64
|
---|
7917 | #define InterlockedDecrement64 _InterlockedDecrement64
|
---|
7918 | #define InterlockedAdd64 _InterlockedAdd64
|
---|
7919 | #define InterlockedExchange64 _InterlockedExchange64
|
---|
7920 | #define InterlockedExchangeAcquire64 InterlockedExchange64
|
---|
7921 | #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
|
---|
7922 | #define InterlockedCompareExchange64 _InterlockedCompareExchange64
|
---|
7923 | #define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
|
---|
7924 | #define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
|
---|
7925 |
|
---|
7926 | #define InterlockedExchangePointer _InterlockedExchangePointer
|
---|
7927 | #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
|
---|
7928 |
|
---|
7929 | #ifdef __cplusplus
|
---|
7930 | extern "C" {
|
---|
7931 | #endif
|
---|
7932 |
|
---|
7933 | LONG
|
---|
7934 | InterlockedAnd (
|
---|
7935 | IN OUT LONG volatile *Destination,
|
---|
7936 | IN LONG Value
|
---|
7937 | );
|
---|
7938 |
|
---|
7939 | LONG
|
---|
7940 | InterlockedOr (
|
---|
7941 | IN OUT LONG volatile *Destination,
|
---|
7942 | IN LONG Value
|
---|
7943 | );
|
---|
7944 |
|
---|
7945 | LONG
|
---|
7946 | InterlockedXor (
|
---|
7947 | IN OUT LONG volatile *Destination,
|
---|
7948 | IN LONG Value
|
---|
7949 | );
|
---|
7950 |
|
---|
7951 | LONG64
|
---|
7952 | InterlockedAnd64 (
|
---|
7953 | IN OUT LONG64 volatile *Destination,
|
---|
7954 | IN LONG64 Value
|
---|
7955 | );
|
---|
7956 |
|
---|
7957 | LONG64
|
---|
7958 | InterlockedOr64 (
|
---|
7959 | IN OUT LONG64 volatile *Destination,
|
---|
7960 | IN LONG64 Value
|
---|
7961 | );
|
---|
7962 |
|
---|
7963 | LONG64
|
---|
7964 | InterlockedXor64 (
|
---|
7965 | IN OUT LONG64 volatile *Destination,
|
---|
7966 | IN LONG64 Value
|
---|
7967 | );
|
---|
7968 |
|
---|
7969 | LONG
|
---|
7970 | InterlockedIncrement(
|
---|
7971 | IN OUT LONG volatile *Addend
|
---|
7972 | );
|
---|
7973 |
|
---|
7974 | LONG
|
---|
7975 | InterlockedDecrement(
|
---|
7976 | IN OUT LONG volatile *Addend
|
---|
7977 | );
|
---|
7978 |
|
---|
7979 | LONG
|
---|
7980 | InterlockedExchange(
|
---|
7981 | IN OUT LONG volatile *Target,
|
---|
7982 | IN LONG Value
|
---|
7983 | );
|
---|
7984 |
|
---|
7985 | LONG
|
---|
7986 | InterlockedExchangeAdd(
|
---|
7987 | IN OUT LONG volatile *Addend,
|
---|
7988 | IN LONG Value
|
---|
7989 | );
|
---|
7990 |
|
---|
7991 | #if !defined(_X86AMD64_)
|
---|
7992 |
|
---|
7993 | __forceinline
|
---|
7994 | LONG
|
---|
7995 | InterlockedAdd(
|
---|
7996 | IN OUT LONG volatile *Addend,
|
---|
7997 | IN LONG Value
|
---|
7998 | )
|
---|
7999 |
|
---|
8000 | {
|
---|
8001 | return InterlockedExchangeAdd(Addend, Value) + Value;
|
---|
8002 | }
|
---|
8003 |
|
---|
8004 | #endif
|
---|
8005 |
|
---|
8006 | LONG
|
---|
8007 | InterlockedCompareExchange (
|
---|
8008 | IN OUT LONG volatile *Destination,
|
---|
8009 | IN LONG ExChange,
|
---|
8010 | IN LONG Comperand
|
---|
8011 | );
|
---|
8012 |
|
---|
8013 | LONG64
|
---|
8014 | InterlockedIncrement64(
|
---|
8015 | IN OUT LONG64 volatile *Addend
|
---|
8016 | );
|
---|
8017 |
|
---|
8018 | LONG64
|
---|
8019 | InterlockedDecrement64(
|
---|
8020 | IN OUT LONG64 volatile *Addend
|
---|
8021 | );
|
---|
8022 |
|
---|
8023 | LONG64
|
---|
8024 | InterlockedExchange64(
|
---|
8025 | IN OUT LONG64 volatile *Target,
|
---|
8026 | IN LONG64 Value
|
---|
8027 | );
|
---|
8028 |
|
---|
8029 | LONG64
|
---|
8030 | InterlockedExchangeAdd64(
|
---|
8031 | IN OUT LONG64 volatile *Addend,
|
---|
8032 | IN LONG64 Value
|
---|
8033 | );
|
---|
8034 |
|
---|
8035 | #if !defined(_X86AMD64_)
|
---|
8036 |
|
---|
8037 | __forceinline
|
---|
8038 | LONG64
|
---|
8039 | InterlockedAdd64(
|
---|
8040 | IN OUT LONG64 volatile *Addend,
|
---|
8041 | IN LONG64 Value
|
---|
8042 | )
|
---|
8043 |
|
---|
8044 | {
|
---|
8045 | return InterlockedExchangeAdd64(Addend, Value) + Value;
|
---|
8046 | }
|
---|
8047 |
|
---|
8048 | #endif
|
---|
8049 |
|
---|
8050 | LONG64
|
---|
8051 | InterlockedCompareExchange64 (
|
---|
8052 | IN OUT LONG64 volatile *Destination,
|
---|
8053 | IN LONG64 ExChange,
|
---|
8054 | IN LONG64 Comperand
|
---|
8055 | );
|
---|
8056 |
|
---|
8057 | PVOID
|
---|
8058 | InterlockedCompareExchangePointer (
|
---|
8059 | IN OUT PVOID volatile *Destination,
|
---|
8060 | IN PVOID Exchange,
|
---|
8061 | IN PVOID Comperand
|
---|
8062 | );
|
---|
8063 |
|
---|
8064 | PVOID
|
---|
8065 | InterlockedExchangePointer(
|
---|
8066 | IN OUT PVOID volatile *Target,
|
---|
8067 | IN PVOID Value
|
---|
8068 | );
|
---|
8069 |
|
---|
8070 | #pragma intrinsic(_InterlockedAnd)
|
---|
8071 | #pragma intrinsic(_InterlockedOr)
|
---|
8072 | #pragma intrinsic(_InterlockedXor)
|
---|
8073 | #pragma intrinsic(_InterlockedIncrement)
|
---|
8074 | #pragma intrinsic(_InterlockedDecrement)
|
---|
8075 | #pragma intrinsic(_InterlockedExchange)
|
---|
8076 | #pragma intrinsic(_InterlockedExchangeAdd)
|
---|
8077 | #pragma intrinsic(_InterlockedCompareExchange)
|
---|
8078 | #pragma intrinsic(_InterlockedAnd64)
|
---|
8079 | #pragma intrinsic(_InterlockedOr64)
|
---|
8080 | #pragma intrinsic(_InterlockedXor64)
|
---|
8081 | #pragma intrinsic(_InterlockedIncrement64)
|
---|
8082 | #pragma intrinsic(_InterlockedDecrement64)
|
---|
8083 | #pragma intrinsic(_InterlockedExchange64)
|
---|
8084 | #pragma intrinsic(_InterlockedExchangeAdd64)
|
---|
8085 | #pragma intrinsic(_InterlockedCompareExchange64)
|
---|
8086 | #pragma intrinsic(_InterlockedExchangePointer)
|
---|
8087 | #pragma intrinsic(_InterlockedCompareExchangePointer)
|
---|
8088 |
|
---|
8089 | #ifdef __cplusplus
|
---|
8090 | }
|
---|
8091 | #endif
|
---|
8092 |
|
---|
8093 | #endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
---|
8094 |
|
---|
8095 | #if defined(_AMD64_)
|
---|
8096 |
|
---|
8097 | //
|
---|
8098 | // Types to use to contain PFNs and their counts.
|
---|
8099 | //
|
---|
8100 |
|
---|
8101 | typedef ULONG PFN_COUNT;
|
---|
8102 |
|
---|
8103 | typedef LONG64 SPFN_NUMBER, *PSPFN_NUMBER;
|
---|
8104 | typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
|
---|
8105 |
|
---|
8106 | //
|
---|
8107 | // Define maximum size of flush multiple TB request.
|
---|
8108 | //
|
---|
8109 |
|
---|
8110 | #define FLUSH_MULTIPLE_MAXIMUM 32
|
---|
8111 |
|
---|
8112 | //
|
---|
8113 | // Indicate that the AMD64 compiler supports the allocate pragmas.
|
---|
8114 | //
|
---|
8115 |
|
---|
8116 | #define ALLOC_PRAGMA 1
|
---|
8117 | #define ALLOC_DATA_PRAGMA 1
|
---|
8118 |
|
---|
8119 | #define NORMAL_DISPATCH_LENGTH 106
|
---|
8120 | #define DISPATCH_LENGTH NORMAL_DISPATCH_LENGTH
|
---|
8121 |
|
---|
8122 | //
|
---|
8123 | // Interrupt Request Level definitions
|
---|
8124 | //
|
---|
8125 |
|
---|
8126 | #define PASSIVE_LEVEL 0 // Passive release level
|
---|
8127 | #define LOW_LEVEL 0 // Lowest interrupt level
|
---|
8128 | #define APC_LEVEL 1 // APC interrupt level
|
---|
8129 | #define DISPATCH_LEVEL 2 // Dispatcher level
|
---|
8130 |
|
---|
8131 | #define CLOCK_LEVEL 13 // Interval clock level
|
---|
8132 | #define IPI_LEVEL 14 // Interprocessor interrupt level
|
---|
8133 | #define POWER_LEVEL 14 // Power failure level
|
---|
8134 | #define PROFILE_LEVEL 15 // timer used for profiling.
|
---|
8135 | #define HIGH_LEVEL 15 // Highest interrupt level
|
---|
8136 |
|
---|
8137 | #define SYNCH_LEVEL (IPI_LEVEL-2)
|
---|
8138 |
|
---|
8139 | //
|
---|
8140 | // I/O space read and write macros.
|
---|
8141 | //
|
---|
8142 | // The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space.
|
---|
8143 | //
|
---|
8144 | // The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space.
|
---|
8145 | //
|
---|
8146 |
|
---|
8147 | __forceinline
|
---|
8148 | UCHAR
|
---|
8149 | READ_REGISTER_UCHAR (
|
---|
8150 | volatile UCHAR *Register
|
---|
8151 | )
|
---|
8152 | {
|
---|
8153 | return *Register;
|
---|
8154 | }
|
---|
8155 |
|
---|
8156 | __forceinline
|
---|
8157 | USHORT
|
---|
8158 | READ_REGISTER_USHORT (
|
---|
8159 | volatile USHORT *Register
|
---|
8160 | )
|
---|
8161 | {
|
---|
8162 | return *Register;
|
---|
8163 | }
|
---|
8164 |
|
---|
8165 | __forceinline
|
---|
8166 | ULONG
|
---|
8167 | READ_REGISTER_ULONG (
|
---|
8168 | volatile ULONG *Register
|
---|
8169 | )
|
---|
8170 | {
|
---|
8171 | return *Register;
|
---|
8172 | }
|
---|
8173 |
|
---|
8174 | __forceinline
|
---|
8175 | VOID
|
---|
8176 | READ_REGISTER_BUFFER_UCHAR (
|
---|
8177 | PUCHAR Register,
|
---|
8178 | PUCHAR Buffer,
|
---|
8179 | ULONG Count
|
---|
8180 | )
|
---|
8181 | {
|
---|
8182 | __movsb(Buffer, Register, Count);
|
---|
8183 | return;
|
---|
8184 | }
|
---|
8185 |
|
---|
8186 | __forceinline
|
---|
8187 | VOID
|
---|
8188 | READ_REGISTER_BUFFER_USHORT (
|
---|
8189 | PUSHORT Register,
|
---|
8190 | PUSHORT Buffer,
|
---|
8191 | ULONG Count
|
---|
8192 | )
|
---|
8193 | {
|
---|
8194 | __movsw(Buffer, Register, Count);
|
---|
8195 | return;
|
---|
8196 | }
|
---|
8197 |
|
---|
8198 | __forceinline
|
---|
8199 | VOID
|
---|
8200 | READ_REGISTER_BUFFER_ULONG (
|
---|
8201 | PULONG Register,
|
---|
8202 | PULONG Buffer,
|
---|
8203 | ULONG Count
|
---|
8204 | )
|
---|
8205 | {
|
---|
8206 | __movsd(Buffer, Register, Count);
|
---|
8207 | return;
|
---|
8208 | }
|
---|
8209 |
|
---|
8210 | __forceinline
|
---|
8211 | VOID
|
---|
8212 | WRITE_REGISTER_UCHAR (
|
---|
8213 | PUCHAR Register,
|
---|
8214 | UCHAR Value
|
---|
8215 | )
|
---|
8216 | {
|
---|
8217 |
|
---|
8218 | *Register = Value;
|
---|
8219 | StoreFence();
|
---|
8220 | return;
|
---|
8221 | }
|
---|
8222 |
|
---|
8223 | __forceinline
|
---|
8224 | VOID
|
---|
8225 | WRITE_REGISTER_USHORT (
|
---|
8226 | PUSHORT Register,
|
---|
8227 | USHORT Value
|
---|
8228 | )
|
---|
8229 | {
|
---|
8230 |
|
---|
8231 | *Register = Value;
|
---|
8232 | StoreFence();
|
---|
8233 | return;
|
---|
8234 | }
|
---|
8235 |
|
---|
8236 | __forceinline
|
---|
8237 | VOID
|
---|
8238 | WRITE_REGISTER_ULONG (
|
---|
8239 | PULONG Register,
|
---|
8240 | ULONG Value
|
---|
8241 | )
|
---|
8242 | {
|
---|
8243 |
|
---|
8244 | *Register = Value;
|
---|
8245 | StoreFence();
|
---|
8246 | return;
|
---|
8247 | }
|
---|
8248 |
|
---|
8249 | __forceinline
|
---|
8250 | VOID
|
---|
8251 | WRITE_REGISTER_BUFFER_UCHAR (
|
---|
8252 | PUCHAR Register,
|
---|
8253 | PUCHAR Buffer,
|
---|
8254 | ULONG Count
|
---|
8255 | )
|
---|
8256 | {
|
---|
8257 |
|
---|
8258 | __movsb(Register, Buffer, Count);
|
---|
8259 | StoreFence();
|
---|
8260 | return;
|
---|
8261 | }
|
---|
8262 |
|
---|
8263 | __forceinline
|
---|
8264 | VOID
|
---|
8265 | WRITE_REGISTER_BUFFER_USHORT (
|
---|
8266 | PUSHORT Register,
|
---|
8267 | PUSHORT Buffer,
|
---|
8268 | ULONG Count
|
---|
8269 | )
|
---|
8270 | {
|
---|
8271 |
|
---|
8272 | __movsw(Register, Buffer, Count);
|
---|
8273 | StoreFence();
|
---|
8274 | return;
|
---|
8275 | }
|
---|
8276 |
|
---|
8277 | __forceinline
|
---|
8278 | VOID
|
---|
8279 | WRITE_REGISTER_BUFFER_ULONG (
|
---|
8280 | PULONG Register,
|
---|
8281 | PULONG Buffer,
|
---|
8282 | ULONG Count
|
---|
8283 | )
|
---|
8284 | {
|
---|
8285 |
|
---|
8286 | __movsd(Register, Buffer, Count);
|
---|
8287 | StoreFence();
|
---|
8288 | return;
|
---|
8289 | }
|
---|
8290 |
|
---|
8291 | __forceinline
|
---|
8292 | UCHAR
|
---|
8293 | READ_PORT_UCHAR (
|
---|
8294 | PUCHAR Port
|
---|
8295 | )
|
---|
8296 |
|
---|
8297 | {
|
---|
8298 | return __inbyte((USHORT)((ULONG64)Port));
|
---|
8299 | }
|
---|
8300 |
|
---|
8301 | __forceinline
|
---|
8302 | USHORT
|
---|
8303 | READ_PORT_USHORT (
|
---|
8304 | PUSHORT Port
|
---|
8305 | )
|
---|
8306 |
|
---|
8307 | {
|
---|
8308 | return __inword((USHORT)((ULONG64)Port));
|
---|
8309 | }
|
---|
8310 |
|
---|
8311 | __forceinline
|
---|
8312 | ULONG
|
---|
8313 | READ_PORT_ULONG (
|
---|
8314 | PULONG Port
|
---|
8315 | )
|
---|
8316 |
|
---|
8317 | {
|
---|
8318 | return __indword((USHORT)((ULONG64)Port));
|
---|
8319 | }
|
---|
8320 |
|
---|
8321 |
|
---|
8322 | __forceinline
|
---|
8323 | VOID
|
---|
8324 | READ_PORT_BUFFER_UCHAR (
|
---|
8325 | PUCHAR Port,
|
---|
8326 | PUCHAR Buffer,
|
---|
8327 | ULONG Count
|
---|
8328 | )
|
---|
8329 |
|
---|
8330 | {
|
---|
8331 | __inbytestring((USHORT)((ULONG64)Port), Buffer, Count);
|
---|
8332 | return;
|
---|
8333 | }
|
---|
8334 |
|
---|
8335 | __forceinline
|
---|
8336 | VOID
|
---|
8337 | READ_PORT_BUFFER_USHORT (
|
---|
8338 | PUSHORT Port,
|
---|
8339 | PUSHORT Buffer,
|
---|
8340 | ULONG Count
|
---|
8341 | )
|
---|
8342 |
|
---|
8343 | {
|
---|
8344 | __inwordstring((USHORT)((ULONG64)Port), Buffer, Count);
|
---|
8345 | return;
|
---|
8346 | }
|
---|
8347 |
|
---|
8348 | __forceinline
|
---|
8349 | VOID
|
---|
8350 | READ_PORT_BUFFER_ULONG (
|
---|
8351 | PULONG Port,
|
---|
8352 | PULONG Buffer,
|
---|
8353 | ULONG Count
|
---|
8354 | )
|
---|
8355 |
|
---|
8356 | {
|
---|
8357 | __indwordstring((USHORT)((ULONG64)Port), Buffer, Count);
|
---|
8358 | return;
|
---|
8359 | }
|
---|
8360 |
|
---|
8361 | __forceinline
|
---|
8362 | VOID
|
---|
8363 | WRITE_PORT_UCHAR (
|
---|
8364 | PUCHAR Port,
|
---|
8365 | UCHAR Value
|
---|
8366 | )
|
---|
8367 |
|
---|
8368 | {
|
---|
8369 | __outbyte((USHORT)((ULONG64)Port), Value);
|
---|
8370 | return;
|
---|
8371 | }
|
---|
8372 |
|
---|
8373 | __forceinline
|
---|
8374 | VOID
|
---|
8375 | WRITE_PORT_USHORT (
|
---|
8376 | PUSHORT Port,
|
---|
8377 | USHORT Value
|
---|
8378 | )
|
---|
8379 |
|
---|
8380 | {
|
---|
8381 | __outword((USHORT)((ULONG64)Port), Value);
|
---|
8382 | return;
|
---|
8383 | }
|
---|
8384 |
|
---|
8385 | __forceinline
|
---|
8386 | VOID
|
---|
8387 | WRITE_PORT_ULONG (
|
---|
8388 | PULONG Port,
|
---|
8389 | ULONG Value
|
---|
8390 | )
|
---|
8391 |
|
---|
8392 | {
|
---|
8393 | __outdword((USHORT)((ULONG64)Port), Value);
|
---|
8394 | return;
|
---|
8395 | }
|
---|
8396 |
|
---|
8397 | __forceinline
|
---|
8398 | VOID
|
---|
8399 | WRITE_PORT_BUFFER_UCHAR (
|
---|
8400 | PUCHAR Port,
|
---|
8401 | PUCHAR Buffer,
|
---|
8402 | ULONG Count
|
---|
8403 | )
|
---|
8404 |
|
---|
8405 | {
|
---|
8406 | __outbytestring((USHORT)((ULONG64)Port), Buffer, Count);
|
---|
8407 | return;
|
---|
8408 | }
|
---|
8409 |
|
---|
8410 | __forceinline
|
---|
8411 | VOID
|
---|
8412 | WRITE_PORT_BUFFER_USHORT (
|
---|
8413 | PUSHORT Port,
|
---|
8414 | PUSHORT Buffer,
|
---|
8415 | ULONG Count
|
---|
8416 | )
|
---|
8417 |
|
---|
8418 | {
|
---|
8419 | __outwordstring((USHORT)((ULONG64)Port), Buffer, Count);
|
---|
8420 | return;
|
---|
8421 | }
|
---|
8422 |
|
---|
8423 | __forceinline
|
---|
8424 | VOID
|
---|
8425 | WRITE_PORT_BUFFER_ULONG (
|
---|
8426 | PULONG Port,
|
---|
8427 | PULONG Buffer,
|
---|
8428 | ULONG Count
|
---|
8429 | )
|
---|
8430 |
|
---|
8431 | {
|
---|
8432 | __outdwordstring((USHORT)((ULONG64)Port), Buffer, Count);
|
---|
8433 | return;
|
---|
8434 | }
|
---|
8435 |
|
---|
8436 |
|
---|
8437 | //
|
---|
8438 | // Get data cache fill size.
|
---|
8439 | //
|
---|
8440 |
|
---|
8441 | #if PRAGMA_DEPRECATED_DDK
|
---|
8442 | #pragma deprecated(KeGetDcacheFillSize) // Use GetDmaAlignment
|
---|
8443 | #endif
|
---|
8444 |
|
---|
8445 | #define KeGetDcacheFillSize() 1L
|
---|
8446 |
|
---|
8447 |
|
---|
8448 | #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
|
---|
8449 |
|
---|
8450 |
|
---|
8451 | #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
|
---|
8452 | #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
|
---|
8453 | #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
|
---|
8454 | #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
|
---|
8455 |
|
---|
8456 |
|
---|
8457 | #define KI_USER_SHARED_DATA 0xFFFFF78000000000UI64
|
---|
8458 |
|
---|
8459 | #define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
|
---|
8460 |
|
---|
8461 | #define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8)
|
---|
8462 | #define SharedSystemTime (KI_USER_SHARED_DATA + 0x14)
|
---|
8463 | #define SharedTickCount (KI_USER_SHARED_DATA + 0x320)
|
---|
8464 |
|
---|
8465 | #define KeQueryInterruptTime() *((volatile ULONG64 *)(SharedInterruptTime))
|
---|
8466 |
|
---|
8467 | #define KeQuerySystemTime(CurrentCount) \
|
---|
8468 | *((PULONG64)(CurrentCount)) = *((volatile ULONG64 *)(SharedSystemTime))
|
---|
8469 |
|
---|
8470 | #define KeQueryTickCount(CurrentCount) \
|
---|
8471 | *((PULONG64)(CurrentCount)) = *((volatile ULONG64 *)(SharedTickCount))
|
---|
8472 |
|
---|
8473 |
|
---|
8474 | //
|
---|
8475 | // Processor Control Region Structure Definition
|
---|
8476 | //
|
---|
8477 |
|
---|
8478 | #define PCR_MINOR_VERSION 1
|
---|
8479 | #define PCR_MAJOR_VERSION 1
|
---|
8480 |
|
---|
8481 | typedef struct _KPCR {
|
---|
8482 |
|
---|
8483 | //
|
---|
8484 | // Start of the architecturally defined section of the PCR. This section
|
---|
8485 | // may be directly addressed by vendor/platform specific HAL code and will
|
---|
8486 | // not change from version to version of NT.
|
---|
8487 | //
|
---|
8488 | // Certain fields in the TIB are not used in kernel mode. These include the
|
---|
8489 | // exception list, stack base, stack limit, subsystem TIB, fiber data, and
|
---|
8490 | // the arbitrary user pointer. Therefore, these fields are overlaid with
|
---|
8491 | // other data to get better cache locality.
|
---|
8492 |
|
---|
8493 | union {
|
---|
8494 | NT_TIB NtTib;
|
---|
8495 | struct {
|
---|
8496 | union _KGDTENTRY64 *GdtBase;
|
---|
8497 | struct _KTSS64 *TssBase;
|
---|
8498 | PVOID PerfGlobalGroupMask;
|
---|
8499 | struct _KPCR *Self;
|
---|
8500 | ULONG ContextSwitches;
|
---|
8501 | ULONG NotUsed;
|
---|
8502 | KAFFINITY SetMember;
|
---|
8503 | PVOID Used_Self;
|
---|
8504 | };
|
---|
8505 | };
|
---|
8506 |
|
---|
8507 | struct _KPRCB *CurrentPrcb;
|
---|
8508 | ULONG64 SavedRcx;
|
---|
8509 | ULONG64 SavedR11;
|
---|
8510 | KIRQL Irql;
|
---|
8511 | UCHAR SecondLevelCacheAssociativity;
|
---|
8512 | UCHAR Number;
|
---|
8513 | UCHAR Fill0;
|
---|
8514 | ULONG Irr;
|
---|
8515 | ULONG IrrActive;
|
---|
8516 | ULONG Idr;
|
---|
8517 | USHORT MajorVersion;
|
---|
8518 | USHORT MinorVersion;
|
---|
8519 | ULONG StallScaleFactor;
|
---|
8520 | union _KIDTENTRY64 *IdtBase;
|
---|
8521 | PVOID Unused1;
|
---|
8522 | PVOID Unused2;
|
---|
8523 |
|
---|
8524 |
|
---|
8525 | } KPCR, *PKPCR;
|
---|
8526 |
|
---|
8527 | //
|
---|
8528 | // Exception frame
|
---|
8529 | //
|
---|
8530 | // This frame is established when handling an exception. It provides a place
|
---|
8531 | // to save all nonvolatile registers. The volatile registers will already
|
---|
8532 | // have been saved in a trap frame.
|
---|
8533 | //
|
---|
8534 | // N.B. The exception frame has a built in exception record capable of
|
---|
8535 | // storing information for four parameter values. This exception
|
---|
8536 | // record is used exclusively within the trap handling code.
|
---|
8537 | //
|
---|
8538 |
|
---|
8539 | #define EXCEPTION_AREA_SIZE 64
|
---|
8540 |
|
---|
8541 | typedef struct _KEXCEPTION_FRAME {
|
---|
8542 |
|
---|
8543 | //
|
---|
8544 | // Home address for the parameter registers.
|
---|
8545 | //
|
---|
8546 |
|
---|
8547 | ULONG64 P1Home;
|
---|
8548 | ULONG64 P2Home;
|
---|
8549 | ULONG64 P3Home;
|
---|
8550 | ULONG64 P4Home;
|
---|
8551 | ULONG64 P5;
|
---|
8552 |
|
---|
8553 | //
|
---|
8554 | // Kernel callout initial stack value.
|
---|
8555 | //
|
---|
8556 |
|
---|
8557 | ULONG64 InitialStack;
|
---|
8558 |
|
---|
8559 | //
|
---|
8560 | // Saved nonvolatile floating registers.
|
---|
8561 | //
|
---|
8562 |
|
---|
8563 | M128 Xmm6;
|
---|
8564 | M128 Xmm7;
|
---|
8565 | M128 Xmm8;
|
---|
8566 | M128 Xmm9;
|
---|
8567 | M128 Xmm10;
|
---|
8568 | M128 Xmm11;
|
---|
8569 | M128 Xmm12;
|
---|
8570 | M128 Xmm13;
|
---|
8571 | M128 Xmm14;
|
---|
8572 | M128 Xmm15;
|
---|
8573 |
|
---|
8574 | //
|
---|
8575 | // Kernel callout frame variables.
|
---|
8576 | //
|
---|
8577 |
|
---|
8578 | ULONG64 TrapFrame;
|
---|
8579 | ULONG64 CallbackStack;
|
---|
8580 | ULONG64 OutputBuffer;
|
---|
8581 | ULONG64 OutputLength;
|
---|
8582 |
|
---|
8583 | //
|
---|
8584 | // Exception record for exceptions.
|
---|
8585 | //
|
---|
8586 |
|
---|
8587 | UCHAR ExceptionRecord[EXCEPTION_AREA_SIZE];
|
---|
8588 |
|
---|
8589 | //
|
---|
8590 | // Saved nonvolatile register - not always saved.
|
---|
8591 | //
|
---|
8592 |
|
---|
8593 | ULONG64 Fill1;
|
---|
8594 | ULONG64 Rbp;
|
---|
8595 |
|
---|
8596 | //
|
---|
8597 | // Saved nonvolatile registers.
|
---|
8598 | //
|
---|
8599 |
|
---|
8600 | ULONG64 Rbx;
|
---|
8601 | ULONG64 Rdi;
|
---|
8602 | ULONG64 Rsi;
|
---|
8603 | ULONG64 R12;
|
---|
8604 | ULONG64 R13;
|
---|
8605 | ULONG64 R14;
|
---|
8606 | ULONG64 R15;
|
---|
8607 |
|
---|
8608 | //
|
---|
8609 | // EFLAGS and return address.
|
---|
8610 | //
|
---|
8611 |
|
---|
8612 | ULONG64 Return;
|
---|
8613 | } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
|
---|
8614 |
|
---|
8615 | //
|
---|
8616 | // Trap frame
|
---|
8617 | //
|
---|
8618 | // This frame is established when handling a trap. It provides a place to
|
---|
8619 | // save all volatile registers. The nonvolatile registers are saved in an
|
---|
8620 | // exception frame or through the normal C calling conventions for saved
|
---|
8621 | // registers.
|
---|
8622 | //
|
---|
8623 |
|
---|
8624 | typedef struct _KTRAP_FRAME {
|
---|
8625 |
|
---|
8626 | //
|
---|
8627 | // Home address for the parameter registers.
|
---|
8628 | //
|
---|
8629 |
|
---|
8630 | ULONG64 P1Home;
|
---|
8631 | ULONG64 P2Home;
|
---|
8632 | ULONG64 P3Home;
|
---|
8633 | ULONG64 P4Home;
|
---|
8634 | ULONG64 P5;
|
---|
8635 |
|
---|
8636 | //
|
---|
8637 | // Previous processor mode (system services only) and previous IRQL
|
---|
8638 | // (interrupts only).
|
---|
8639 | //
|
---|
8640 |
|
---|
8641 | KPROCESSOR_MODE PreviousMode;
|
---|
8642 | KIRQL PreviousIrql;
|
---|
8643 |
|
---|
8644 | //
|
---|
8645 | // Page fault load/store indicator.
|
---|
8646 | //
|
---|
8647 |
|
---|
8648 | UCHAR FaultIndicator;
|
---|
8649 | UCHAR Fill0;
|
---|
8650 |
|
---|
8651 | //
|
---|
8652 | // Floating point state.
|
---|
8653 | //
|
---|
8654 |
|
---|
8655 | ULONG MxCsr;
|
---|
8656 |
|
---|
8657 | //
|
---|
8658 | // Volatile registers.
|
---|
8659 | //
|
---|
8660 | // N.B. These registers are only saved on exceptions and interrupts. They
|
---|
8661 | // are not saved for system calls.
|
---|
8662 | //
|
---|
8663 |
|
---|
8664 | ULONG64 Rax;
|
---|
8665 | ULONG64 Rcx;
|
---|
8666 | ULONG64 Rdx;
|
---|
8667 | ULONG64 R8;
|
---|
8668 | ULONG64 R9;
|
---|
8669 | ULONG64 R10;
|
---|
8670 | ULONG64 R11;
|
---|
8671 | ULONG64 Spare0;
|
---|
8672 |
|
---|
8673 | //
|
---|
8674 | // Volatile floating registers.
|
---|
8675 | //
|
---|
8676 | // N.B. These registers are only saved on exceptions and interrupts. They
|
---|
8677 | // are not saved for system calls.
|
---|
8678 | //
|
---|
8679 |
|
---|
8680 | M128 Xmm0;
|
---|
8681 | M128 Xmm1;
|
---|
8682 | M128 Xmm2;
|
---|
8683 | M128 Xmm3;
|
---|
8684 | M128 Xmm4;
|
---|
8685 | M128 Xmm5;
|
---|
8686 |
|
---|
8687 | //
|
---|
8688 | // Page fault address.
|
---|
8689 | //
|
---|
8690 |
|
---|
8691 | ULONG64 FaultAddress;
|
---|
8692 |
|
---|
8693 | //
|
---|
8694 | // Debug registers.
|
---|
8695 | //
|
---|
8696 |
|
---|
8697 | ULONG64 Dr0;
|
---|
8698 | ULONG64 Dr1;
|
---|
8699 | ULONG64 Dr2;
|
---|
8700 | ULONG64 Dr3;
|
---|
8701 | ULONG64 Dr6;
|
---|
8702 | ULONG64 Dr7;
|
---|
8703 |
|
---|
8704 | //
|
---|
8705 | // Special debug registers.
|
---|
8706 | //
|
---|
8707 |
|
---|
8708 | ULONG64 DebugControl;
|
---|
8709 | ULONG64 LastBranchToRip;
|
---|
8710 | ULONG64 LastBranchFromRip;
|
---|
8711 | ULONG64 LastExceptionToRip;
|
---|
8712 | ULONG64 LastExceptionFromRip;
|
---|
8713 |
|
---|
8714 | //
|
---|
8715 | // Segment registers
|
---|
8716 | //
|
---|
8717 |
|
---|
8718 | USHORT SegDs;
|
---|
8719 | USHORT SegEs;
|
---|
8720 | USHORT SegFs;
|
---|
8721 | USHORT SegGs;
|
---|
8722 |
|
---|
8723 | //
|
---|
8724 | // Previous trap frame address.
|
---|
8725 | //
|
---|
8726 |
|
---|
8727 | ULONG64 TrapFrame;
|
---|
8728 |
|
---|
8729 | //
|
---|
8730 | // Saved nonvolatile registers RBX, RDI and RSI. These registers are only
|
---|
8731 | // saved in system service trap frames.
|
---|
8732 | //
|
---|
8733 |
|
---|
8734 | ULONG64 Rbx;
|
---|
8735 | ULONG64 Rdi;
|
---|
8736 | ULONG64 Rsi;
|
---|
8737 |
|
---|
8738 | //
|
---|
8739 | // Saved nonvolatile register RBP. This register is used as a frame
|
---|
8740 | // pointer during trap processing and is saved in all trap frames.
|
---|
8741 | //
|
---|
8742 |
|
---|
8743 | ULONG64 Rbp;
|
---|
8744 |
|
---|
8745 | //
|
---|
8746 | // Information pushed by hardware.
|
---|
8747 | //
|
---|
8748 | // N.B. The error code is not always pushed by hardware. For those cases
|
---|
8749 | // where it is not pushed by hardware a dummy error code is allocated
|
---|
8750 | // on the stack.
|
---|
8751 | //
|
---|
8752 |
|
---|
8753 | ULONG64 ErrorCode;
|
---|
8754 | ULONG64 Rip;
|
---|
8755 | USHORT SegCs;
|
---|
8756 | USHORT Fill1[3];
|
---|
8757 | ULONG EFlags;
|
---|
8758 | ULONG Fill2;
|
---|
8759 | ULONG64 Rsp;
|
---|
8760 | USHORT SegSs;
|
---|
8761 | USHORT Fill3[3];
|
---|
8762 | } KTRAP_FRAME, *PKTRAP_FRAME;
|
---|
8763 |
|
---|
8764 | //
|
---|
8765 | // The nonvolatile floating state
|
---|
8766 | //
|
---|
8767 |
|
---|
8768 | typedef struct _KFLOATING_SAVE {
|
---|
8769 | ULONG MxCsr;
|
---|
8770 | } KFLOATING_SAVE, *PKFLOATING_SAVE;
|
---|
8771 |
|
---|
8772 | //
|
---|
8773 | // AMD64 Specific portions of mm component.
|
---|
8774 | //
|
---|
8775 | // Define the page size for the AMD64 as 4096 (0x1000).
|
---|
8776 | //
|
---|
8777 |
|
---|
8778 | #define PAGE_SIZE 0x1000
|
---|
8779 |
|
---|
8780 | //
|
---|
8781 | // Define the number of trailing zeroes in a page aligned virtual address.
|
---|
8782 | // This is used as the shift count when shifting virtual addresses to
|
---|
8783 | // virtual page numbers.
|
---|
8784 | //
|
---|
8785 |
|
---|
8786 | #define PAGE_SHIFT 12L
|
---|
8787 |
|
---|
8788 |
|
---|
8789 |
|
---|
8790 | #define PXE_BASE 0xFFFFF6FB7DBED000UI64
|
---|
8791 | #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68UI64
|
---|
8792 | #define PPE_BASE 0xFFFFF6FB7DA00000UI64
|
---|
8793 | #define PDE_BASE 0xFFFFF6FB40000000UI64
|
---|
8794 | #define PTE_BASE 0xFFFFF68000000000UI64
|
---|
8795 |
|
---|
8796 | #define PXE_TOP 0xFFFFF6FB7DBEDFFFUI64
|
---|
8797 | #define PPE_TOP 0xFFFFF6FB7DBFFFFFUI64
|
---|
8798 | #define PDE_TOP 0xFFFFF6FB7FFFFFFFUI64
|
---|
8799 | #define PTE_TOP 0xFFFFF6FFFFFFFFFFUI64
|
---|
8800 |
|
---|
8801 | #define PDE_KTBASE_AMD64 PPE_BASE
|
---|
8802 |
|
---|
8803 | #define PTI_SHIFT 12
|
---|
8804 | #define PDI_SHIFT 21
|
---|
8805 | #define PPI_SHIFT 30
|
---|
8806 | #define PXI_SHIFT 39
|
---|
8807 |
|
---|
8808 | #define PTE_PER_PAGE 512
|
---|
8809 | #define PDE_PER_PAGE 512
|
---|
8810 | #define PPE_PER_PAGE 512
|
---|
8811 | #define PXE_PER_PAGE 512
|
---|
8812 |
|
---|
8813 | #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
|
---|
8814 | #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
|
---|
8815 | #define PPI_MASK (PPE_PER_PAGE - 1)
|
---|
8816 | #define PXI_MASK (PXE_PER_PAGE - 1)
|
---|
8817 |
|
---|
8818 | //
|
---|
8819 | // Define the highest user address and user probe address.
|
---|
8820 | //
|
---|
8821 |
|
---|
8822 |
|
---|
8823 | extern PVOID *MmHighestUserAddress;
|
---|
8824 | extern PVOID *MmSystemRangeStart;
|
---|
8825 | extern ULONG64 *MmUserProbeAddress;
|
---|
8826 |
|
---|
8827 | #define MM_HIGHEST_USER_ADDRESS *MmHighestUserAddress
|
---|
8828 | #define MM_SYSTEM_RANGE_START *MmSystemRangeStart
|
---|
8829 | #define MM_USER_PROBE_ADDRESS *MmUserProbeAddress
|
---|
8830 |
|
---|
8831 | //
|
---|
8832 | // The lowest user address reserves the low 64k.
|
---|
8833 | //
|
---|
8834 |
|
---|
8835 | #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
|
---|
8836 |
|
---|
8837 | //
|
---|
8838 | // The lowest address for system space.
|
---|
8839 | //
|
---|
8840 |
|
---|
8841 | #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000
|
---|
8842 |
|
---|
8843 |
|
---|
8844 |
|
---|
8845 | #define MmGetProcedureAddress(Address) (Address)
|
---|
8846 | #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
|
---|
8847 |
|
---|
8848 |
|
---|
8849 | //
|
---|
8850 | // Intrinsic functions
|
---|
8851 | //
|
---|
8852 |
|
---|
8853 |
|
---|
8854 |
|
---|
8855 | #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
---|
8856 |
|
---|
8857 |
|
---|
8858 |
|
---|
8859 | //
|
---|
8860 | // The following routines are provided for backward compatibility with old
|
---|
8861 | // code. They are no longer the preferred way to accomplish these functions.
|
---|
8862 | //
|
---|
8863 |
|
---|
8864 | #if PRAGMA_DEPRECATED_DDK
|
---|
8865 | #pragma deprecated(ExInterlockedIncrementLong) // Use InterlockedIncrement
|
---|
8866 | #pragma deprecated(ExInterlockedDecrementLong) // Use InterlockedDecrement
|
---|
8867 | #pragma deprecated(ExInterlockedExchangeUlong) // Use InterlockedExchange
|
---|
8868 | #endif
|
---|
8869 |
|
---|
8870 | #define RESULT_ZERO 0
|
---|
8871 | #define RESULT_NEGATIVE 1
|
---|
8872 | #define RESULT_POSITIVE 2
|
---|
8873 |
|
---|
8874 | typedef enum _INTERLOCKED_RESULT {
|
---|
8875 | ResultNegative = RESULT_NEGATIVE,
|
---|
8876 | ResultZero = RESULT_ZERO,
|
---|
8877 | ResultPositive = RESULT_POSITIVE
|
---|
8878 | } INTERLOCKED_RESULT;
|
---|
8879 |
|
---|
8880 | #define ExInterlockedDecrementLong(Addend, Lock) \
|
---|
8881 | _ExInterlockedDecrementLong(Addend)
|
---|
8882 |
|
---|
8883 | __forceinline
|
---|
8884 | LONG
|
---|
8885 | _ExInterlockedDecrementLong (
|
---|
8886 | IN OUT PLONG Addend
|
---|
8887 | )
|
---|
8888 |
|
---|
8889 | {
|
---|
8890 |
|
---|
8891 | LONG Result;
|
---|
8892 |
|
---|
8893 | Result = InterlockedDecrement(Addend);
|
---|
8894 | if (Result < 0) {
|
---|
8895 | return ResultNegative;
|
---|
8896 |
|
---|
8897 | } else if (Result > 0) {
|
---|
8898 | return ResultPositive;
|
---|
8899 |
|
---|
8900 | } else {
|
---|
8901 | return ResultZero;
|
---|
8902 | }
|
---|
8903 | }
|
---|
8904 |
|
---|
8905 | #define ExInterlockedIncrementLong(Addend, Lock) \
|
---|
8906 | _ExInterlockedIncrementLong(Addend)
|
---|
8907 |
|
---|
8908 | __forceinline
|
---|
8909 | LONG
|
---|
8910 | _ExInterlockedIncrementLong (
|
---|
8911 | IN OUT PLONG Addend
|
---|
8912 | )
|
---|
8913 |
|
---|
8914 | {
|
---|
8915 |
|
---|
8916 | LONG Result;
|
---|
8917 |
|
---|
8918 | Result = InterlockedIncrement(Addend);
|
---|
8919 | if (Result < 0) {
|
---|
8920 | return ResultNegative;
|
---|
8921 |
|
---|
8922 | } else if (Result > 0) {
|
---|
8923 | return ResultPositive;
|
---|
8924 |
|
---|
8925 | } else {
|
---|
8926 | return ResultZero;
|
---|
8927 | }
|
---|
8928 | }
|
---|
8929 |
|
---|
8930 | #define ExInterlockedExchangeUlong(Target, Value, Lock) \
|
---|
8931 | _ExInterlockedExchangeUlong(Target, Value)
|
---|
8932 |
|
---|
8933 | __forceinline
|
---|
8934 | _ExInterlockedExchangeUlong (
|
---|
8935 | IN OUT PULONG Target,
|
---|
8936 | IN ULONG Value
|
---|
8937 | )
|
---|
8938 |
|
---|
8939 | {
|
---|
8940 |
|
---|
8941 | return (ULONG)InterlockedExchange((PLONG)Target, (LONG)Value);
|
---|
8942 | }
|
---|
8943 |
|
---|
8944 |
|
---|
8945 |
|
---|
8946 | #endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
---|
8947 |
|
---|
8948 |
|
---|
8949 | #if !defined(MIDL_PASS) && defined(_M_AMD64)
|
---|
8950 |
|
---|
8951 | //
|
---|
8952 | // AMD646 function prototype definitions
|
---|
8953 | //
|
---|
8954 |
|
---|
8955 |
|
---|
8956 |
|
---|
8957 |
|
---|
8958 | //
|
---|
8959 | // Get the current processor number
|
---|
8960 | //
|
---|
8961 |
|
---|
8962 | __forceinline
|
---|
8963 | ULONG
|
---|
8964 | KeGetCurrentProcessorNumber (
|
---|
8965 | VOID
|
---|
8966 | )
|
---|
8967 |
|
---|
8968 | {
|
---|
8969 |
|
---|
8970 | return (ULONG)__readgsbyte(FIELD_OFFSET(KPCR, Number));
|
---|
8971 | }
|
---|
8972 |
|
---|
8973 |
|
---|
8974 |
|
---|
8975 |
|
---|
8976 | #endif // !defined(MIDL_PASS) && defined(_M_AMD64)
|
---|
8977 |
|
---|
8978 |
|
---|
8979 | //++
|
---|
8980 | //
|
---|
8981 | //
|
---|
8982 | // VOID
|
---|
8983 | // KeMemoryBarrier (
|
---|
8984 | // VOID
|
---|
8985 | // )
|
---|
8986 | //
|
---|
8987 | // VOID
|
---|
8988 | // KeMemoryBarrierWithoutFence (
|
---|
8989 | // VOID
|
---|
8990 | // )
|
---|
8991 | //
|
---|
8992 | //
|
---|
8993 | // Routine Description:
|
---|
8994 | //
|
---|
8995 | // These functions order memory accesses as seen by other processors.
|
---|
8996 | //
|
---|
8997 | // Arguments:
|
---|
8998 | //
|
---|
8999 | // None.
|
---|
9000 | //
|
---|
9001 | // Return Value:
|
---|
9002 | //
|
---|
9003 | // None.
|
---|
9004 | //
|
---|
9005 | //--
|
---|
9006 |
|
---|
9007 | #if !defined(_CROSS_PLATFORM_)
|
---|
9008 |
|
---|
9009 | #ifdef __cplusplus
|
---|
9010 | extern "C" {
|
---|
9011 | #endif
|
---|
9012 |
|
---|
9013 | VOID
|
---|
9014 | _ReadWriteBarrier (
|
---|
9015 | VOID
|
---|
9016 | );
|
---|
9017 |
|
---|
9018 | #pragma intrinsic(_ReadWriteBarrier)
|
---|
9019 |
|
---|
9020 | #ifdef __cplusplus
|
---|
9021 | }
|
---|
9022 | #endif
|
---|
9023 |
|
---|
9024 | #define KeMemoryBarrier() _ReadWriteBarrier()
|
---|
9025 | #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
|
---|
9026 |
|
---|
9027 | #else
|
---|
9028 |
|
---|
9029 | #define KeMemoryBarrier()
|
---|
9030 | #define KeMemoryBarrierWithoutFence()
|
---|
9031 |
|
---|
9032 | #endif
|
---|
9033 |
|
---|
9034 |
|
---|
9035 | NTKERNELAPI
|
---|
9036 | NTSTATUS
|
---|
9037 | KeSaveFloatingPointState (
|
---|
9038 | OUT PKFLOATING_SAVE SaveArea
|
---|
9039 | );
|
---|
9040 |
|
---|
9041 | NTKERNELAPI
|
---|
9042 | NTSTATUS
|
---|
9043 | KeRestoreFloatingPointState (
|
---|
9044 | IN PKFLOATING_SAVE SaveArea
|
---|
9045 | );
|
---|
9046 |
|
---|
9047 |
|
---|
9048 | #endif // defined(_AMD64_)
|
---|
9049 |
|
---|
9050 |
|
---|
9051 |
|
---|
9052 | #if defined(_AMD64_)
|
---|
9053 |
|
---|
9054 | NTKERNELAPI
|
---|
9055 | KIRQL
|
---|
9056 | KeGetCurrentIrql (
|
---|
9057 | VOID
|
---|
9058 | );
|
---|
9059 |
|
---|
9060 | NTKERNELAPI
|
---|
9061 | VOID
|
---|
9062 | KeLowerIrql (
|
---|
9063 | IN KIRQL NewIrql
|
---|
9064 | );
|
---|
9065 |
|
---|
9066 | #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
|
---|
9067 |
|
---|
9068 | NTKERNELAPI
|
---|
9069 | KIRQL
|
---|
9070 | KfRaiseIrql (
|
---|
9071 | IN KIRQL NewIrql
|
---|
9072 | );
|
---|
9073 |
|
---|
9074 |
|
---|
9075 |
|
---|
9076 | NTKERNELAPI
|
---|
9077 | KIRQL
|
---|
9078 | KeRaiseIrqlToDpcLevel (
|
---|
9079 | VOID
|
---|
9080 | );
|
---|
9081 |
|
---|
9082 | NTKERNELAPI
|
---|
9083 | KIRQL
|
---|
9084 | KeRaiseIrqlToSynchLevel (
|
---|
9085 | VOID
|
---|
9086 | );
|
---|
9087 |
|
---|
9088 |
|
---|
9089 |
|
---|
9090 | #endif // defined(_AMD64_)
|
---|
9091 |
|
---|
9092 |
|
---|
9093 | #if defined(_IA64_)
|
---|
9094 |
|
---|
9095 | //
|
---|
9096 | // Types to use to contain PFNs and their counts.
|
---|
9097 | //
|
---|
9098 |
|
---|
9099 | typedef ULONG PFN_COUNT;
|
---|
9100 |
|
---|
9101 | typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
|
---|
9102 | typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
|
---|
9103 |
|
---|
9104 | //
|
---|
9105 | // Indicate that the IA64 compiler supports the pragma textout construct.
|
---|
9106 | //
|
---|
9107 |
|
---|
9108 | #define ALLOC_PRAGMA 1
|
---|
9109 |
|
---|
9110 | //
|
---|
9111 | // Define intrinsic calls and their prototypes
|
---|
9112 | //
|
---|
9113 |
|
---|
9114 | #include "ia64reg.h"
|
---|
9115 |
|
---|
9116 |
|
---|
9117 | #ifdef __cplusplus
|
---|
9118 | extern "C" {
|
---|
9119 | #endif
|
---|
9120 |
|
---|
9121 | unsigned __int64 __getReg (int);
|
---|
9122 | void __setReg (int, unsigned __int64);
|
---|
9123 | void __isrlz (void);
|
---|
9124 | void __dsrlz (void);
|
---|
9125 | void __fwb (void);
|
---|
9126 | void __mf (void);
|
---|
9127 | void __mfa (void);
|
---|
9128 | void __synci (void);
|
---|
9129 | __int64 __thash (__int64);
|
---|
9130 | __int64 __ttag (__int64);
|
---|
9131 | void __ptcl (__int64, __int64);
|
---|
9132 | void __ptcg (__int64, __int64);
|
---|
9133 | void __ptcga (__int64, __int64);
|
---|
9134 | void __ptri (__int64, __int64);
|
---|
9135 | void __ptrd (__int64, __int64);
|
---|
9136 | void __invalat (void);
|
---|
9137 | void __break (int);
|
---|
9138 | void __fc (__int64);
|
---|
9139 | void __fci (__int64);
|
---|
9140 | void __sum (int);
|
---|
9141 | void __rsm (int);
|
---|
9142 | void _ReleaseSpinLock( unsigned __int64 *);
|
---|
9143 | void __yield();
|
---|
9144 | void __lfetch(int, void const *);
|
---|
9145 | void __lfetchfault(int, void const *);
|
---|
9146 |
|
---|
9147 | #ifdef _M_IA64
|
---|
9148 | #pragma intrinsic (__getReg)
|
---|
9149 | #pragma intrinsic (__setReg)
|
---|
9150 | #pragma intrinsic (__isrlz)
|
---|
9151 | #pragma intrinsic (__dsrlz)
|
---|
9152 | #pragma intrinsic (__fwb)
|
---|
9153 | #pragma intrinsic (__mf)
|
---|
9154 | #pragma intrinsic (__mfa)
|
---|
9155 | #pragma intrinsic (__synci)
|
---|
9156 | #pragma intrinsic (__thash)
|
---|
9157 | #pragma intrinsic (__ttag)
|
---|
9158 | #pragma intrinsic (__ptcl)
|
---|
9159 | #pragma intrinsic (__ptcg)
|
---|
9160 | #pragma intrinsic (__ptcga)
|
---|
9161 | #pragma intrinsic (__ptri)
|
---|
9162 | #pragma intrinsic (__ptrd)
|
---|
9163 | #pragma intrinsic (__invalat)
|
---|
9164 | #pragma intrinsic (__break)
|
---|
9165 | #pragma intrinsic (__fc)
|
---|
9166 | #pragma intrinsic (__fci)
|
---|
9167 | #pragma intrinsic (__sum)
|
---|
9168 | #pragma intrinsic (__rsm)
|
---|
9169 | #pragma intrinsic (_ReleaseSpinLock)
|
---|
9170 | #pragma intrinsic (__yield)
|
---|
9171 | #pragma intrinsic (__lfetch)
|
---|
9172 | #pragma intrinsic (__lfetchfault)
|
---|
9173 | #endif // _M_IA64
|
---|
9174 |
|
---|
9175 | #ifdef __cplusplus
|
---|
9176 | }
|
---|
9177 | #endif
|
---|
9178 |
|
---|
9179 |
|
---|
9180 |
|
---|
9181 |
|
---|
9182 | //
|
---|
9183 | // Define length of interrupt vector table.
|
---|
9184 | //
|
---|
9185 |
|
---|
9186 | #define MAXIMUM_VECTOR 256
|
---|
9187 |
|
---|
9188 |
|
---|
9189 |
|
---|
9190 |
|
---|
9191 | //
|
---|
9192 | // IA64 specific interlocked operation result values.
|
---|
9193 | //
|
---|
9194 |
|
---|
9195 | #define RESULT_ZERO 0
|
---|
9196 | #define RESULT_NEGATIVE 1
|
---|
9197 | #define RESULT_POSITIVE 2
|
---|
9198 |
|
---|
9199 | //
|
---|
9200 | // Interlocked result type is portable, but its values are machine specific.
|
---|
9201 | // Constants for values are in i386.h, mips.h, etc.
|
---|
9202 | //
|
---|
9203 |
|
---|
9204 | typedef enum _INTERLOCKED_RESULT {
|
---|
9205 | ResultNegative = RESULT_NEGATIVE,
|
---|
9206 | ResultZero = RESULT_ZERO,
|
---|
9207 | ResultPositive = RESULT_POSITIVE
|
---|
9208 | } INTERLOCKED_RESULT;
|
---|
9209 |
|
---|
9210 | //
|
---|
9211 | // Convert portable interlock interfaces to architecture specific interfaces.
|
---|
9212 | //
|
---|
9213 |
|
---|
9214 | #if PRAGMA_DEPRECATED_DDK
|
---|
9215 | #pragma deprecated(ExInterlockedIncrementLong) // Use InterlockedIncrement
|
---|
9216 | #pragma deprecated(ExInterlockedDecrementLong) // Use InterlockedDecrement
|
---|
9217 | #pragma deprecated(ExInterlockedExchangeUlong) // Use InterlockedExchange
|
---|
9218 | #endif
|
---|
9219 |
|
---|
9220 | #define ExInterlockedIncrementLong(Addend, Lock) \
|
---|
9221 | ExIa64InterlockedIncrementLong(Addend)
|
---|
9222 |
|
---|
9223 | #define ExInterlockedDecrementLong(Addend, Lock) \
|
---|
9224 | ExIa64InterlockedDecrementLong(Addend)
|
---|
9225 |
|
---|
9226 | #define ExInterlockedExchangeUlong(Target, Value, Lock) \
|
---|
9227 | ExIa64InterlockedExchangeUlong(Target, Value)
|
---|
9228 |
|
---|
9229 | NTKERNELAPI
|
---|
9230 | INTERLOCKED_RESULT
|
---|
9231 | ExIa64InterlockedIncrementLong (
|
---|
9232 | IN PLONG Addend
|
---|
9233 | );
|
---|
9234 |
|
---|
9235 | NTKERNELAPI
|
---|
9236 | INTERLOCKED_RESULT
|
---|
9237 | ExIa64InterlockedDecrementLong (
|
---|
9238 | IN PLONG Addend
|
---|
9239 | );
|
---|
9240 |
|
---|
9241 | NTKERNELAPI
|
---|
9242 | ULONG
|
---|
9243 | ExIa64InterlockedExchangeUlong (
|
---|
9244 | IN PULONG Target,
|
---|
9245 | IN ULONG Value
|
---|
9246 | );
|
---|
9247 | |
---|
9248 |
|
---|
9249 |
|
---|
9250 |
|
---|
9251 | //
|
---|
9252 | // IA64 Interrupt Definitions.
|
---|
9253 | //
|
---|
9254 | //
|
---|
9255 | // Define length of interrupt object dispatch code in longwords.
|
---|
9256 | //
|
---|
9257 |
|
---|
9258 | #define DISPATCH_LENGTH 2*2 // Length of dispatch code template in 32-bit words
|
---|
9259 |
|
---|
9260 | // Begin of a block of definitions that must be synchronized with kxia64.h.
|
---|
9261 | //
|
---|
9262 |
|
---|
9263 | //
|
---|
9264 | // Define Interrupt Request Levels.
|
---|
9265 | //
|
---|
9266 |
|
---|
9267 | #define PASSIVE_LEVEL 0 // Passive release level
|
---|
9268 | #define LOW_LEVEL 0 // Lowest interrupt level
|
---|
9269 | #define APC_LEVEL 1 // APC interrupt level
|
---|
9270 | #define DISPATCH_LEVEL 2 // Dispatcher level
|
---|
9271 | #define CMC_LEVEL 3 // Correctable machine check level
|
---|
9272 | #define DEVICE_LEVEL_BASE 4 // 4 - 11 - Device IRQLs
|
---|
9273 | #define PC_LEVEL 12 // Performance Counter IRQL
|
---|
9274 | #define IPI_LEVEL 14 // IPI IRQL
|
---|
9275 | #define CLOCK_LEVEL 13 // Clock Timer IRQL
|
---|
9276 | #define POWER_LEVEL 15 // Power failure level
|
---|
9277 | #define PROFILE_LEVEL 15 // Profiling level
|
---|
9278 | #define HIGH_LEVEL 15 // Highest interrupt level
|
---|
9279 |
|
---|
9280 |
|
---|
9281 | #if defined(_M_IA64) && !defined(RC_INVOKED)
|
---|
9282 |
|
---|
9283 | #define InterlockedAdd _InterlockedAdd
|
---|
9284 | #define InterlockedIncrement _InterlockedIncrement
|
---|
9285 | #define InterlockedIncrementAcquire _InterlockedIncrement_acq
|
---|
9286 | #define InterlockedIncrementRelease _InterlockedIncrement_rel
|
---|
9287 | #define InterlockedDecrement _InterlockedDecrement
|
---|
9288 | #define InterlockedDecrementAcquire _InterlockedDecrement_acq
|
---|
9289 | #define InterlockedDecrementRelease _InterlockedDecrement_rel
|
---|
9290 | #define InterlockedExchange _InterlockedExchange
|
---|
9291 | #define InterlockedExchangeAdd _InterlockedExchangeAdd
|
---|
9292 |
|
---|
9293 | #define InterlockedAdd64 _InterlockedAdd64
|
---|
9294 | #define InterlockedIncrement64 _InterlockedIncrement64
|
---|
9295 | #define InterlockedDecrement64 _InterlockedDecrement64
|
---|
9296 | #define InterlockedExchange64 _InterlockedExchange64
|
---|
9297 | #define InterlockedExchangeAcquire64 _InterlockedExchange64_acq
|
---|
9298 | #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
|
---|
9299 | #define InterlockedCompareExchange64 _InterlockedCompareExchange64
|
---|
9300 | #define InterlockedCompareExchangeAcquire64 _InterlockedCompareExchange64_acq
|
---|
9301 | #define InterlockedCompareExchangeRelease64 _InterlockedCompareExchange64_rel
|
---|
9302 |
|
---|
9303 | #define InterlockedCompareExchange _InterlockedCompareExchange
|
---|
9304 | #define InterlockedCompareExchangeAcquire _InterlockedCompareExchange_acq
|
---|
9305 | #define InterlockedCompareExchangeRelease _InterlockedCompareExchange_rel
|
---|
9306 | #define InterlockedExchangePointer _InterlockedExchangePointer
|
---|
9307 | #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
|
---|
9308 |
|
---|
9309 | #ifdef __cplusplus
|
---|
9310 | extern "C" {
|
---|
9311 | #endif
|
---|
9312 |
|
---|
9313 | LONG
|
---|
9314 | __cdecl
|
---|
9315 | InterlockedAdd (
|
---|
9316 | LONG volatile *Addend,
|
---|
9317 | LONG Value
|
---|
9318 | );
|
---|
9319 |
|
---|
9320 | LONGLONG
|
---|
9321 | __cdecl
|
---|
9322 | InterlockedAdd64 (
|
---|
9323 | LONGLONG volatile *Addend,
|
---|
9324 | LONGLONG Value
|
---|
9325 | );
|
---|
9326 |
|
---|
9327 | LONG
|
---|
9328 | __cdecl
|
---|
9329 | InterlockedIncrement(
|
---|
9330 | IN OUT LONG volatile *Addend
|
---|
9331 | );
|
---|
9332 |
|
---|
9333 | LONG
|
---|
9334 | __cdecl
|
---|
9335 | InterlockedDecrement(
|
---|
9336 | IN OUT LONG volatile *Addend
|
---|
9337 | );
|
---|
9338 |
|
---|
9339 | LONG
|
---|
9340 | __cdecl
|
---|
9341 | InterlockedIncrementAcquire(
|
---|
9342 | IN OUT LONG volatile *Addend
|
---|
9343 | );
|
---|
9344 |
|
---|
9345 | LONG
|
---|
9346 | __cdecl
|
---|
9347 | InterlockedDecrementAcquire(
|
---|
9348 | IN OUT LONG volatile *Addend
|
---|
9349 | );
|
---|
9350 |
|
---|
9351 | LONG
|
---|
9352 | __cdecl
|
---|
9353 | InterlockedIncrementRelease(
|
---|
9354 | IN OUT LONG volatile *Addend
|
---|
9355 | );
|
---|
9356 |
|
---|
9357 | LONG
|
---|
9358 | __cdecl
|
---|
9359 | InterlockedDecrementRelease(
|
---|
9360 | IN OUT LONG volatile *Addend
|
---|
9361 | );
|
---|
9362 |
|
---|
9363 | LONG
|
---|
9364 | __cdecl
|
---|
9365 | InterlockedExchange(
|
---|
9366 | IN OUT LONG volatile *Target,
|
---|
9367 | IN LONG Value
|
---|
9368 | );
|
---|
9369 |
|
---|
9370 | LONG
|
---|
9371 | __cdecl
|
---|
9372 | InterlockedExchangeAdd(
|
---|
9373 | IN OUT LONG volatile *Addend,
|
---|
9374 | IN LONG Value
|
---|
9375 | );
|
---|
9376 |
|
---|
9377 | LONG
|
---|
9378 | __cdecl
|
---|
9379 | InterlockedCompareExchange (
|
---|
9380 | IN OUT LONG volatile *Destination,
|
---|
9381 | IN LONG ExChange,
|
---|
9382 | IN LONG Comperand
|
---|
9383 | );
|
---|
9384 |
|
---|
9385 |
|
---|
9386 | LONG
|
---|
9387 | __cdecl
|
---|
9388 | InterlockedCompareExchangeRelease (
|
---|
9389 | IN OUT LONG volatile *Destination,
|
---|
9390 | IN LONG ExChange,
|
---|
9391 | IN LONG Comperand
|
---|
9392 | );
|
---|
9393 |
|
---|
9394 |
|
---|
9395 | LONG
|
---|
9396 | __cdecl
|
---|
9397 | InterlockedCompareExchangeAcquire (
|
---|
9398 | IN OUT LONG volatile *Destination,
|
---|
9399 | IN LONG ExChange,
|
---|
9400 | IN LONG Comperand
|
---|
9401 | );
|
---|
9402 |
|
---|
9403 |
|
---|
9404 | LONGLONG
|
---|
9405 | __cdecl
|
---|
9406 | InterlockedIncrement64(
|
---|
9407 | IN OUT LONGLONG volatile *Addend
|
---|
9408 | );
|
---|
9409 |
|
---|
9410 | LONGLONG
|
---|
9411 | __cdecl
|
---|
9412 | InterlockedDecrement64(
|
---|
9413 | IN OUT LONGLONG volatile *Addend
|
---|
9414 | );
|
---|
9415 |
|
---|
9416 | LONGLONG
|
---|
9417 | __cdecl
|
---|
9418 | InterlockedExchange64(
|
---|
9419 | IN OUT LONGLONG volatile *Target,
|
---|
9420 | IN LONGLONG Value
|
---|
9421 | );
|
---|
9422 |
|
---|
9423 | LONGLONG
|
---|
9424 | __cdecl
|
---|
9425 | InterlockedExchangeAcquire64(
|
---|
9426 | IN OUT LONGLONG volatile *Target,
|
---|
9427 | IN LONGLONG Value
|
---|
9428 | );
|
---|
9429 |
|
---|
9430 | LONGLONG
|
---|
9431 | __cdecl
|
---|
9432 | InterlockedExchangeAdd64(
|
---|
9433 | IN OUT LONGLONG volatile *Addend,
|
---|
9434 | IN LONGLONG Value
|
---|
9435 | );
|
---|
9436 |
|
---|
9437 | LONGLONG
|
---|
9438 | __cdecl
|
---|
9439 | InterlockedCompareExchange64 (
|
---|
9440 | IN OUT LONGLONG volatile *Destination,
|
---|
9441 | IN LONGLONG ExChange,
|
---|
9442 | IN LONGLONG Comperand
|
---|
9443 | );
|
---|
9444 |
|
---|
9445 | LONGLONG
|
---|
9446 | __cdecl
|
---|
9447 | InterlockedCompareExchangeAcquire64 (
|
---|
9448 | IN OUT LONGLONG volatile *Destination,
|
---|
9449 | IN LONGLONG ExChange,
|
---|
9450 | IN LONGLONG Comperand
|
---|
9451 | );
|
---|
9452 |
|
---|
9453 | LONGLONG
|
---|
9454 | __cdecl
|
---|
9455 | InterlockedCompareExchangeRelease64 (
|
---|
9456 | IN OUT LONGLONG volatile *Destination,
|
---|
9457 | IN LONGLONG ExChange,
|
---|
9458 | IN LONGLONG Comperand
|
---|
9459 | );
|
---|
9460 |
|
---|
9461 | PVOID
|
---|
9462 | __cdecl
|
---|
9463 | InterlockedCompareExchangePointer (
|
---|
9464 | IN OUT PVOID volatile *Destination,
|
---|
9465 | IN PVOID Exchange,
|
---|
9466 | IN PVOID Comperand
|
---|
9467 | );
|
---|
9468 |
|
---|
9469 | PVOID
|
---|
9470 | __cdecl
|
---|
9471 | InterlockedExchangePointer(
|
---|
9472 | IN OUT PVOID volatile *Target,
|
---|
9473 | IN PVOID Value
|
---|
9474 | );
|
---|
9475 |
|
---|
9476 | #if !defined (InterlockedAnd64)
|
---|
9477 |
|
---|
9478 | #define InterlockedAnd64 InterlockedAnd64_Inline
|
---|
9479 |
|
---|
9480 | LONGLONG
|
---|
9481 | FORCEINLINE
|
---|
9482 | InterlockedAnd64_Inline (
|
---|
9483 | IN OUT LONGLONG volatile *Destination,
|
---|
9484 | IN LONGLONG Value
|
---|
9485 | )
|
---|
9486 | {
|
---|
9487 | LONGLONG Old;
|
---|
9488 |
|
---|
9489 | do {
|
---|
9490 | Old = *Destination;
|
---|
9491 | } while (InterlockedCompareExchange64(Destination,
|
---|
9492 | Old & Value,
|
---|
9493 | Old) != Old);
|
---|
9494 |
|
---|
9495 | return Old;
|
---|
9496 | }
|
---|
9497 |
|
---|
9498 | #endif
|
---|
9499 |
|
---|
9500 | #if !defined (InterlockedOr64)
|
---|
9501 |
|
---|
9502 | #define InterlockedOr64 InterlockedOr64_Inline
|
---|
9503 |
|
---|
9504 | LONGLONG
|
---|
9505 | FORCEINLINE
|
---|
9506 | InterlockedOr64_Inline (
|
---|
9507 | IN OUT LONGLONG volatile *Destination,
|
---|
9508 | IN LONGLONG Value
|
---|
9509 | )
|
---|
9510 | {
|
---|
9511 | LONGLONG Old;
|
---|
9512 |
|
---|
9513 | do {
|
---|
9514 | Old = *Destination;
|
---|
9515 | } while (InterlockedCompareExchange64(Destination,
|
---|
9516 | Old | Value,
|
---|
9517 | Old) != Old);
|
---|
9518 |
|
---|
9519 | return Old;
|
---|
9520 | }
|
---|
9521 |
|
---|
9522 | #endif
|
---|
9523 |
|
---|
9524 |
|
---|
9525 | #if !defined (InterlockedXor64)
|
---|
9526 |
|
---|
9527 | #define InterlockedXor64 InterlockedXor64_Inline
|
---|
9528 |
|
---|
9529 | LONGLONG
|
---|
9530 | FORCEINLINE
|
---|
9531 | InterlockedXor64_Inline (
|
---|
9532 | IN OUT LONGLONG volatile *Destination,
|
---|
9533 | IN LONGLONG Value
|
---|
9534 | )
|
---|
9535 | {
|
---|
9536 | LONGLONG Old;
|
---|
9537 |
|
---|
9538 | do {
|
---|
9539 | Old = *Destination;
|
---|
9540 | } while (InterlockedCompareExchange64(Destination,
|
---|
9541 | Old ^ Value,
|
---|
9542 | Old) != Old);
|
---|
9543 |
|
---|
9544 | return Old;
|
---|
9545 | }
|
---|
9546 |
|
---|
9547 | #endif
|
---|
9548 |
|
---|
9549 |
|
---|
9550 | #pragma intrinsic(_InterlockedAdd)
|
---|
9551 | #pragma intrinsic(_InterlockedIncrement)
|
---|
9552 | #pragma intrinsic(_InterlockedIncrement_acq)
|
---|
9553 | #pragma intrinsic(_InterlockedIncrement_rel)
|
---|
9554 | #pragma intrinsic(_InterlockedDecrement)
|
---|
9555 | #pragma intrinsic(_InterlockedDecrement_acq)
|
---|
9556 | #pragma intrinsic(_InterlockedDecrement_rel)
|
---|
9557 | #pragma intrinsic(_InterlockedExchange)
|
---|
9558 | #pragma intrinsic(_InterlockedCompareExchange)
|
---|
9559 | #pragma intrinsic(_InterlockedCompareExchange_acq)
|
---|
9560 | #pragma intrinsic(_InterlockedCompareExchange_rel)
|
---|
9561 | #pragma intrinsic(_InterlockedExchangeAdd)
|
---|
9562 | #pragma intrinsic(_InterlockedAdd64)
|
---|
9563 | #pragma intrinsic(_InterlockedIncrement64)
|
---|
9564 | #pragma intrinsic(_InterlockedDecrement64)
|
---|
9565 | #pragma intrinsic(_InterlockedExchange64)
|
---|
9566 | #pragma intrinsic(_InterlockedExchange64_acq)
|
---|
9567 | #pragma intrinsic(_InterlockedCompareExchange64)
|
---|
9568 | #pragma intrinsic(_InterlockedCompareExchange64_acq)
|
---|
9569 | #pragma intrinsic(_InterlockedCompareExchange64_rel)
|
---|
9570 | #pragma intrinsic(_InterlockedExchangeAdd64)
|
---|
9571 | #pragma intrinsic(_InterlockedExchangePointer)
|
---|
9572 | #pragma intrinsic(_InterlockedCompareExchangePointer)
|
---|
9573 |
|
---|
9574 | #ifdef __cplusplus
|
---|
9575 | }
|
---|
9576 | #endif
|
---|
9577 |
|
---|
9578 | #endif // defined(_M_IA64) && !defined(RC_INVOKED)
|
---|
9579 |
|
---|
9580 |
|
---|
9581 |
|
---|
9582 | __forceinline
|
---|
9583 | LONG
|
---|
9584 | InterlockedAnd (
|
---|
9585 | IN OUT LONG volatile *Target,
|
---|
9586 | LONG Set
|
---|
9587 | )
|
---|
9588 | {
|
---|
9589 | LONG i;
|
---|
9590 | LONG j;
|
---|
9591 |
|
---|
9592 | j = *Target;
|
---|
9593 | do {
|
---|
9594 | i = j;
|
---|
9595 | j = InterlockedCompareExchange(Target,
|
---|
9596 | i & Set,
|
---|
9597 | i);
|
---|
9598 |
|
---|
9599 | } while (i != j);
|
---|
9600 |
|
---|
9601 | return j;
|
---|
9602 | }
|
---|
9603 |
|
---|
9604 | __forceinline
|
---|
9605 | LONG
|
---|
9606 | InterlockedOr (
|
---|
9607 | IN OUT LONG volatile *Target,
|
---|
9608 | IN LONG Set
|
---|
9609 | )
|
---|
9610 | {
|
---|
9611 | LONG i;
|
---|
9612 | LONG j;
|
---|
9613 |
|
---|
9614 | j = *Target;
|
---|
9615 | do {
|
---|
9616 | i = j;
|
---|
9617 | j = InterlockedCompareExchange(Target,
|
---|
9618 | i | Set,
|
---|
9619 | i);
|
---|
9620 |
|
---|
9621 | } while (i != j);
|
---|
9622 |
|
---|
9623 | return j;
|
---|
9624 | }
|
---|
9625 |
|
---|
9626 | __forceinline
|
---|
9627 | LONG
|
---|
9628 | InterlockedXor (
|
---|
9629 | IN OUT LONG volatile *Target,
|
---|
9630 | IN LONG Set
|
---|
9631 | )
|
---|
9632 | {
|
---|
9633 | LONG i;
|
---|
9634 | LONG j;
|
---|
9635 |
|
---|
9636 | j = *Target;
|
---|
9637 | do {
|
---|
9638 | i = j;
|
---|
9639 | j = InterlockedCompareExchange(Target,
|
---|
9640 | i ^ Set,
|
---|
9641 | i);
|
---|
9642 |
|
---|
9643 | } while (i != j);
|
---|
9644 |
|
---|
9645 | return j;
|
---|
9646 | }
|
---|
9647 |
|
---|
9648 |
|
---|
9649 |
|
---|
9650 | #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000))
|
---|
9651 | #define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
|
---|
9652 |
|
---|
9653 |
|
---|
9654 |
|
---|
9655 | //
|
---|
9656 | // Get address of processor control region.
|
---|
9657 | //
|
---|
9658 |
|
---|
9659 | #define KeGetPcr() PCR
|
---|
9660 |
|
---|
9661 | //
|
---|
9662 | // Get address of current kernel thread object.
|
---|
9663 | //
|
---|
9664 |
|
---|
9665 | #if defined(_M_IA64)
|
---|
9666 | #define KeGetCurrentThread() PCR->CurrentThread
|
---|
9667 | #endif
|
---|
9668 |
|
---|
9669 | //
|
---|
9670 | // Get current processor number.
|
---|
9671 | //
|
---|
9672 |
|
---|
9673 | #define KeGetCurrentProcessorNumber() ((ULONG)(PCR->Number))
|
---|
9674 |
|
---|
9675 | //
|
---|
9676 | // Get data cache fill size.
|
---|
9677 | //
|
---|
9678 |
|
---|
9679 | #if PRAGMA_DEPRECATED_DDK
|
---|
9680 | #pragma deprecated(KeGetDcacheFillSize) // Use GetDmaAlignment
|
---|
9681 | #endif
|
---|
9682 |
|
---|
9683 | #define KeGetDcacheFillSize() PCR->DcacheFillSize
|
---|
9684 |
|
---|
9685 |
|
---|
9686 | #define KeSaveFloatingPointState(a) STATUS_SUCCESS
|
---|
9687 | #define KeRestoreFloatingPointState(a) STATUS_SUCCESS
|
---|
9688 |
|
---|
9689 |
|
---|
9690 |
|
---|
9691 | //
|
---|
9692 | //
|
---|
9693 | // VOID
|
---|
9694 | // KeMemoryBarrierWithoutFence (
|
---|
9695 | // VOID
|
---|
9696 | // )
|
---|
9697 | //
|
---|
9698 | //
|
---|
9699 | // Routine Description:
|
---|
9700 | //
|
---|
9701 | // This function cases ordering of memory accesses generated by the compiler.
|
---|
9702 | //
|
---|
9703 | //
|
---|
9704 | // Arguments:
|
---|
9705 | //
|
---|
9706 | // None.
|
---|
9707 | //
|
---|
9708 | // Return Value:
|
---|
9709 | //
|
---|
9710 | // None.
|
---|
9711 | //--
|
---|
9712 |
|
---|
9713 | #ifdef __cplusplus
|
---|
9714 | extern "C" {
|
---|
9715 | #endif
|
---|
9716 |
|
---|
9717 | VOID
|
---|
9718 | _ReadWriteBarrier (
|
---|
9719 | VOID
|
---|
9720 | );
|
---|
9721 |
|
---|
9722 | #ifdef __cplusplus
|
---|
9723 | }
|
---|
9724 | #endif
|
---|
9725 |
|
---|
9726 | #pragma intrinsic(_ReadWriteBarrier)
|
---|
9727 |
|
---|
9728 | #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
|
---|
9729 |
|
---|
9730 | //++
|
---|
9731 | //
|
---|
9732 | //
|
---|
9733 | // VOID
|
---|
9734 | // KeMemoryBarrier (
|
---|
9735 | // VOID
|
---|
9736 | // )
|
---|
9737 | //
|
---|
9738 | //
|
---|
9739 | // Routine Description:
|
---|
9740 | //
|
---|
9741 | // This function cases ordering of memory accesses as generated by the compiler and
|
---|
9742 | // as seen by other processors.
|
---|
9743 | //
|
---|
9744 | //
|
---|
9745 | // Arguments:
|
---|
9746 | //
|
---|
9747 | // None.
|
---|
9748 | //
|
---|
9749 | // Return Value:
|
---|
9750 | //
|
---|
9751 | // None.
|
---|
9752 | //--
|
---|
9753 |
|
---|
9754 | #define KE_MEMORY_BARRIER_REQUIRED
|
---|
9755 |
|
---|
9756 | #define KeMemoryBarrier() {_ReadWriteBarrier();__mf ();_ReadWriteBarrier();}
|
---|
9757 |
|
---|
9758 | //
|
---|
9759 | // Define the page size
|
---|
9760 | //
|
---|
9761 |
|
---|
9762 | #define PAGE_SIZE 0x2000
|
---|
9763 |
|
---|
9764 | //
|
---|
9765 | // Define the number of trailing zeroes in a page aligned virtual address.
|
---|
9766 | // This is used as the shift count when shifting virtual addresses to
|
---|
9767 | // virtual page numbers.
|
---|
9768 | //
|
---|
9769 |
|
---|
9770 | #define PAGE_SHIFT 13L
|
---|
9771 |
|
---|
9772 | //
|
---|
9773 | // Cache and write buffer flush functions.
|
---|
9774 | //
|
---|
9775 |
|
---|
9776 | NTKERNELAPI
|
---|
9777 | VOID
|
---|
9778 | KeFlushIoBuffers (
|
---|
9779 | IN PMDL Mdl,
|
---|
9780 | IN BOOLEAN ReadOperation,
|
---|
9781 | IN BOOLEAN DmaOperation
|
---|
9782 | );
|
---|
9783 |
|
---|
9784 |
|
---|
9785 | //
|
---|
9786 | // Kernel breakin breakpoint
|
---|
9787 | //
|
---|
9788 |
|
---|
9789 | VOID
|
---|
9790 | KeBreakinBreakpoint (
|
---|
9791 | VOID
|
---|
9792 | );
|
---|
9793 |
|
---|
9794 |
|
---|
9795 | #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
|
---|
9796 | #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
|
---|
9797 | #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
|
---|
9798 | #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
|
---|
9799 |
|
---|
9800 |
|
---|
9801 | #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
|
---|
9802 |
|
---|
9803 |
|
---|
9804 |
|
---|
9805 | #define KeQueryTickCount(CurrentCount ) \
|
---|
9806 | *(PULONGLONG)(CurrentCount) = **((volatile ULONGLONG **)(&KeTickCount));
|
---|
9807 |
|
---|
9808 |
|
---|
9809 |
|
---|
9810 | #else
|
---|
9811 |
|
---|
9812 |
|
---|
9813 | NTKERNELAPI
|
---|
9814 | VOID
|
---|
9815 | KeQueryTickCount (
|
---|
9816 | OUT PLARGE_INTEGER CurrentCount
|
---|
9817 | );
|
---|
9818 |
|
---|
9819 | #endif // defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
|
---|
9820 |
|
---|
9821 | //
|
---|
9822 | // I/O space read and write macros.
|
---|
9823 | //
|
---|
9824 |
|
---|
9825 | NTHALAPI
|
---|
9826 | UCHAR
|
---|
9827 | READ_PORT_UCHAR (
|
---|
9828 | PUCHAR RegisterAddress
|
---|
9829 | );
|
---|
9830 |
|
---|
9831 | NTHALAPI
|
---|
9832 | USHORT
|
---|
9833 | READ_PORT_USHORT (
|
---|
9834 | PUSHORT RegisterAddress
|
---|
9835 | );
|
---|
9836 |
|
---|
9837 | NTHALAPI
|
---|
9838 | ULONG
|
---|
9839 | READ_PORT_ULONG (
|
---|
9840 | PULONG RegisterAddress
|
---|
9841 | );
|
---|
9842 |
|
---|
9843 | NTHALAPI
|
---|
9844 | VOID
|
---|
9845 | READ_PORT_BUFFER_UCHAR (
|
---|
9846 | PUCHAR portAddress,
|
---|
9847 | PUCHAR readBuffer,
|
---|
9848 | ULONG readCount
|
---|
9849 | );
|
---|
9850 |
|
---|
9851 | NTHALAPI
|
---|
9852 | VOID
|
---|
9853 | READ_PORT_BUFFER_USHORT (
|
---|
9854 | PUSHORT portAddress,
|
---|
9855 | PUSHORT readBuffer,
|
---|
9856 | ULONG readCount
|
---|
9857 | );
|
---|
9858 |
|
---|
9859 | NTHALAPI
|
---|
9860 | VOID
|
---|
9861 | READ_PORT_BUFFER_ULONG (
|
---|
9862 | PULONG portAddress,
|
---|
9863 | PULONG readBuffer,
|
---|
9864 | ULONG readCount
|
---|
9865 | );
|
---|
9866 |
|
---|
9867 | NTHALAPI
|
---|
9868 | VOID
|
---|
9869 | WRITE_PORT_UCHAR (
|
---|
9870 | PUCHAR portAddress,
|
---|
9871 | UCHAR Data
|
---|
9872 | );
|
---|
9873 |
|
---|
9874 | NTHALAPI
|
---|
9875 | VOID
|
---|
9876 | WRITE_PORT_USHORT (
|
---|
9877 | PUSHORT portAddress,
|
---|
9878 | USHORT Data
|
---|
9879 | );
|
---|
9880 |
|
---|
9881 | NTHALAPI
|
---|
9882 | VOID
|
---|
9883 | WRITE_PORT_ULONG (
|
---|
9884 | PULONG portAddress,
|
---|
9885 | ULONG Data
|
---|
9886 | );
|
---|
9887 |
|
---|
9888 | NTHALAPI
|
---|
9889 | VOID
|
---|
9890 | WRITE_PORT_BUFFER_UCHAR (
|
---|
9891 | PUCHAR portAddress,
|
---|
9892 | PUCHAR writeBuffer,
|
---|
9893 | ULONG writeCount
|
---|
9894 | );
|
---|
9895 |
|
---|
9896 | NTHALAPI
|
---|
9897 | VOID
|
---|
9898 | WRITE_PORT_BUFFER_USHORT (
|
---|
9899 | PUSHORT portAddress,
|
---|
9900 | PUSHORT writeBuffer,
|
---|
9901 | ULONG writeCount
|
---|
9902 | );
|
---|
9903 |
|
---|
9904 | NTHALAPI
|
---|
9905 | VOID
|
---|
9906 | WRITE_PORT_BUFFER_ULONG (
|
---|
9907 | PULONG portAddress,
|
---|
9908 | PULONG writeBuffer,
|
---|
9909 | ULONG writeCount
|
---|
9910 | );
|
---|
9911 |
|
---|
9912 |
|
---|
9913 | #define READ_REGISTER_UCHAR(x) \
|
---|
9914 | (__mf(), *(volatile UCHAR * const)(x))
|
---|
9915 |
|
---|
9916 | #define READ_REGISTER_USHORT(x) \
|
---|
9917 | (__mf(), *(volatile USHORT * const)(x))
|
---|
9918 |
|
---|
9919 | #define READ_REGISTER_ULONG(x) \
|
---|
9920 | (__mf(), *(volatile ULONG * const)(x))
|
---|
9921 |
|
---|
9922 | #define READ_REGISTER_BUFFER_UCHAR(x, y, z) { \
|
---|
9923 | PUCHAR registerBuffer = x; \
|
---|
9924 | PUCHAR readBuffer = y; \
|
---|
9925 | ULONG readCount; \
|
---|
9926 | __mf(); \
|
---|
9927 | for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
|
---|
9928 | *readBuffer = *(volatile UCHAR * const)(registerBuffer); \
|
---|
9929 | } \
|
---|
9930 | }
|
---|
9931 |
|
---|
9932 | #define READ_REGISTER_BUFFER_USHORT(x, y, z) { \
|
---|
9933 | PUSHORT registerBuffer = x; \
|
---|
9934 | PUSHORT readBuffer = y; \
|
---|
9935 | ULONG readCount; \
|
---|
9936 | __mf(); \
|
---|
9937 | for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
|
---|
9938 | *readBuffer = *(volatile USHORT * const)(registerBuffer); \
|
---|
9939 | } \
|
---|
9940 | }
|
---|
9941 |
|
---|
9942 | #define READ_REGISTER_BUFFER_ULONG(x, y, z) { \
|
---|
9943 | PULONG registerBuffer = x; \
|
---|
9944 | PULONG readBuffer = y; \
|
---|
9945 | ULONG readCount; \
|
---|
9946 | __mf(); \
|
---|
9947 | for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
|
---|
9948 | *readBuffer = *(volatile ULONG * const)(registerBuffer); \
|
---|
9949 | } \
|
---|
9950 | }
|
---|
9951 |
|
---|
9952 | #define WRITE_REGISTER_UCHAR(x, y) { \
|
---|
9953 | *(volatile UCHAR * const)(x) = y; \
|
---|
9954 | KeFlushWriteBuffer(); \
|
---|
9955 | }
|
---|
9956 |
|
---|
9957 | #define WRITE_REGISTER_USHORT(x, y) { \
|
---|
9958 | *(volatile USHORT * const)(x) = y; \
|
---|
9959 | KeFlushWriteBuffer(); \
|
---|
9960 | }
|
---|
9961 |
|
---|
9962 | #define WRITE_REGISTER_ULONG(x, y) { \
|
---|
9963 | *(volatile ULONG * const)(x) = y; \
|
---|
9964 | KeFlushWriteBuffer(); \
|
---|
9965 | }
|
---|
9966 |
|
---|
9967 | #define WRITE_REGISTER_BUFFER_UCHAR(x, y, z) { \
|
---|
9968 | PUCHAR registerBuffer = x; \
|
---|
9969 | PUCHAR writeBuffer = y; \
|
---|
9970 | ULONG writeCount; \
|
---|
9971 | for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
|
---|
9972 | *(volatile UCHAR * const)(registerBuffer) = *writeBuffer; \
|
---|
9973 | } \
|
---|
9974 | KeFlushWriteBuffer(); \
|
---|
9975 | }
|
---|
9976 |
|
---|
9977 | #define WRITE_REGISTER_BUFFER_USHORT(x, y, z) { \
|
---|
9978 | PUSHORT registerBuffer = x; \
|
---|
9979 | PUSHORT writeBuffer = y; \
|
---|
9980 | ULONG writeCount; \
|
---|
9981 | for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
|
---|
9982 | *(volatile USHORT * const)(registerBuffer) = *writeBuffer; \
|
---|
9983 | } \
|
---|
9984 | KeFlushWriteBuffer(); \
|
---|
9985 | }
|
---|
9986 |
|
---|
9987 | #define WRITE_REGISTER_BUFFER_ULONG(x, y, z) { \
|
---|
9988 | PULONG registerBuffer = x; \
|
---|
9989 | PULONG writeBuffer = y; \
|
---|
9990 | ULONG writeCount; \
|
---|
9991 | for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
|
---|
9992 | *(volatile ULONG * const)(registerBuffer) = *writeBuffer; \
|
---|
9993 | } \
|
---|
9994 | KeFlushWriteBuffer(); \
|
---|
9995 | }
|
---|
9996 |
|
---|
9997 | //
|
---|
9998 | // Non-volatile floating point state
|
---|
9999 | //
|
---|
10000 |
|
---|
10001 | typedef struct _KFLOATING_SAVE {
|
---|
10002 | ULONG Reserved;
|
---|
10003 | } KFLOATING_SAVE, *PKFLOATING_SAVE;
|
---|
10004 |
|
---|
10005 |
|
---|
10006 | //
|
---|
10007 | // Define Processor Control Region Structure.
|
---|
10008 | //
|
---|
10009 |
|
---|
10010 | #define PCR_MINOR_VERSION 1
|
---|
10011 | #define PCR_MAJOR_VERSION 1
|
---|
10012 |
|
---|
10013 | typedef struct _KPCR {
|
---|
10014 |
|
---|
10015 | //
|
---|
10016 | // Major and minor version numbers of the PCR.
|
---|
10017 | //
|
---|
10018 | ULONG MinorVersion;
|
---|
10019 | ULONG MajorVersion;
|
---|
10020 |
|
---|
10021 | //
|
---|
10022 | // Start of the architecturally defined section of the PCR. This section
|
---|
10023 | // may be directly addressed by vendor/platform specific HAL code and will
|
---|
10024 | // not change from version to version of NT.
|
---|
10025 | //
|
---|
10026 |
|
---|
10027 | //
|
---|
10028 | // First and second level cache parameters.
|
---|
10029 | //
|
---|
10030 |
|
---|
10031 | ULONG FirstLevelDcacheSize;
|
---|
10032 | ULONG FirstLevelDcacheFillSize;
|
---|
10033 | ULONG FirstLevelIcacheSize;
|
---|
10034 | ULONG FirstLevelIcacheFillSize;
|
---|
10035 | ULONG SecondLevelDcacheSize;
|
---|
10036 | ULONG SecondLevelDcacheFillSize;
|
---|
10037 | ULONG SecondLevelIcacheSize;
|
---|
10038 | ULONG SecondLevelIcacheFillSize;
|
---|
10039 |
|
---|
10040 | //
|
---|
10041 | // Data cache alignment and fill size used for cache flushing and alignment.
|
---|
10042 | // These fields are set to the larger of the first and second level data
|
---|
10043 | // cache fill sizes.
|
---|
10044 | //
|
---|
10045 |
|
---|
10046 | ULONG DcacheAlignment;
|
---|
10047 | ULONG DcacheFillSize;
|
---|
10048 |
|
---|
10049 | //
|
---|
10050 | // Instruction cache alignment and fill size used for cache flushing and
|
---|
10051 | // alignment. These fields are set to the larger of the first and second
|
---|
10052 | // level data cache fill sizes.
|
---|
10053 | //
|
---|
10054 |
|
---|
10055 | ULONG IcacheAlignment;
|
---|
10056 | ULONG IcacheFillSize;
|
---|
10057 |
|
---|
10058 | //
|
---|
10059 | // Processor identification from PrId register.
|
---|
10060 | //
|
---|
10061 |
|
---|
10062 | ULONG ProcessorId;
|
---|
10063 |
|
---|
10064 | //
|
---|
10065 | // Profiling data.
|
---|
10066 | //
|
---|
10067 |
|
---|
10068 | ULONG ProfileInterval;
|
---|
10069 | ULONG ProfileCount;
|
---|
10070 |
|
---|
10071 | //
|
---|
10072 | // Stall execution count and scale factor.
|
---|
10073 | //
|
---|
10074 |
|
---|
10075 | ULONG StallExecutionCount;
|
---|
10076 | ULONG StallScaleFactor;
|
---|
10077 |
|
---|
10078 | ULONG InterruptionCount;
|
---|
10079 |
|
---|
10080 | //
|
---|
10081 | // Space reserved for the system.
|
---|
10082 | //
|
---|
10083 |
|
---|
10084 | ULONGLONG SystemReserved[6];
|
---|
10085 |
|
---|
10086 | //
|
---|
10087 | // Space reserved for the HAL
|
---|
10088 | //
|
---|
10089 |
|
---|
10090 | ULONGLONG HalReserved[64];
|
---|
10091 |
|
---|
10092 | //
|
---|
10093 | // IRQL mapping tables.
|
---|
10094 | //
|
---|
10095 |
|
---|
10096 | UCHAR IrqlMask[64];
|
---|
10097 | UCHAR IrqlTable[64];
|
---|
10098 |
|
---|
10099 | //
|
---|
10100 | // External Interrupt vectors.
|
---|
10101 | //
|
---|
10102 |
|
---|
10103 | PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR];
|
---|
10104 |
|
---|
10105 | //
|
---|
10106 | // Reserved interrupt vector mask.
|
---|
10107 | //
|
---|
10108 |
|
---|
10109 | ULONG ReservedVectors;
|
---|
10110 |
|
---|
10111 | //
|
---|
10112 | // Processor affinity mask.
|
---|
10113 | //
|
---|
10114 |
|
---|
10115 | KAFFINITY SetMember;
|
---|
10116 |
|
---|
10117 | //
|
---|
10118 | // Complement of the processor affinity mask.
|
---|
10119 | //
|
---|
10120 |
|
---|
10121 | KAFFINITY NotMember;
|
---|
10122 |
|
---|
10123 | //
|
---|
10124 | // Pointer to processor control block.
|
---|
10125 | //
|
---|
10126 |
|
---|
10127 | struct _KPRCB *Prcb;
|
---|
10128 |
|
---|
10129 | //
|
---|
10130 | // Shadow copy of Prcb->CurrentThread for fast access
|
---|
10131 | //
|
---|
10132 |
|
---|
10133 | struct _KTHREAD *CurrentThread;
|
---|
10134 |
|
---|
10135 | //
|
---|
10136 | // Processor number.
|
---|
10137 | //
|
---|
10138 |
|
---|
10139 | CCHAR Number; // Processor Number
|
---|
10140 |
|
---|
10141 |
|
---|
10142 | } KPCR, *PKPCR;
|
---|
10143 |
|
---|
10144 |
|
---|
10145 |
|
---|
10146 | NTKERNELAPI
|
---|
10147 | KIRQL
|
---|
10148 | KeGetCurrentIrql();
|
---|
10149 |
|
---|
10150 | NTKERNELAPI
|
---|
10151 | VOID
|
---|
10152 | KeLowerIrql (
|
---|
10153 | IN KIRQL NewIrql
|
---|
10154 | );
|
---|
10155 |
|
---|
10156 | NTKERNELAPI
|
---|
10157 | VOID
|
---|
10158 | KeRaiseIrql (
|
---|
10159 | IN KIRQL NewIrql,
|
---|
10160 | OUT PKIRQL OldIrql
|
---|
10161 | );
|
---|
10162 |
|
---|
10163 |
|
---|
10164 |
|
---|
10165 | NTKERNELAPI
|
---|
10166 | KIRQL
|
---|
10167 | KeRaiseIrqlToDpcLevel (
|
---|
10168 | VOID
|
---|
10169 | );
|
---|
10170 |
|
---|
10171 | NTKERNELAPI
|
---|
10172 | KIRQL
|
---|
10173 | KeRaiseIrqlToSynchLevel (
|
---|
10174 | VOID
|
---|
10175 | );
|
---|
10176 |
|
---|
10177 |
|
---|
10178 | //
|
---|
10179 | // The highest user address reserves 64K bytes for a guard page. This
|
---|
10180 | // the probing of address from kernel mode to only have to check the
|
---|
10181 | // starting address for structures of 64k bytes or less.
|
---|
10182 | //
|
---|
10183 |
|
---|
10184 | extern NTKERNELAPI PVOID MmHighestUserAddress;
|
---|
10185 | extern NTKERNELAPI PVOID MmSystemRangeStart;
|
---|
10186 | extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
|
---|
10187 |
|
---|
10188 |
|
---|
10189 | #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
|
---|
10190 | #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
|
---|
10191 | #define MM_SYSTEM_RANGE_START MmSystemRangeStart
|
---|
10192 |
|
---|
10193 | //
|
---|
10194 | // The lowest user address reserves the low 64k.
|
---|
10195 | //
|
---|
10196 |
|
---|
10197 | #define MM_LOWEST_USER_ADDRESS (PVOID)((ULONG_PTR)(UADDRESS_BASE+0x00010000))
|
---|
10198 |
|
---|
10199 |
|
---|
10200 |
|
---|
10201 | #define MmGetProcedureAddress(Address) (Address)
|
---|
10202 | #define MmLockPagableCodeSection(PLabelAddress) \
|
---|
10203 | MmLockPagableDataSection((PVOID)(*((PULONGLONG)PLabelAddress)))
|
---|
10204 |
|
---|
10205 | #define VRN_MASK 0xE000000000000000UI64 // Virtual Region Number mask
|
---|
10206 |
|
---|
10207 | //
|
---|
10208 | // The lowest address for system space.
|
---|
10209 | //
|
---|
10210 |
|
---|
10211 | #define MM_LOWEST_SYSTEM_ADDRESS ((PVOID)((ULONG_PTR)(KADDRESS_BASE + 0xC0C00000)))
|
---|
10212 | #endif // defined(_IA64_)
|
---|
10213 | //
|
---|
10214 | // Event Specific Access Rights.
|
---|
10215 | //
|
---|
10216 |
|
---|
10217 | #define EVENT_QUERY_STATE 0x0001
|
---|
10218 | #define EVENT_MODIFY_STATE 0x0002
|
---|
10219 | #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
|
---|
10220 |
|
---|
10221 | //
|
---|
10222 | // Semaphore Specific Access Rights.
|
---|
10223 | //
|
---|
10224 |
|
---|
10225 | #define SEMAPHORE_QUERY_STATE 0x0001
|
---|
10226 | #define SEMAPHORE_MODIFY_STATE 0x0002
|
---|
10227 |
|
---|
10228 | #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
|
---|
10229 |
|
---|
10230 | //
|
---|
10231 | // Timer APC routine definition.
|
---|
10232 | //
|
---|
10233 |
|
---|
10234 | typedef
|
---|
10235 | VOID
|
---|
10236 | (*PTIMER_APC_ROUTINE) (
|
---|
10237 | IN PVOID TimerContext,
|
---|
10238 | IN ULONG TimerLowValue,
|
---|
10239 | IN LONG TimerHighValue
|
---|
10240 | );
|
---|
10241 |
|
---|
10242 |
|
---|
10243 | //
|
---|
10244 | // Driver Verifier Definitions
|
---|
10245 | //
|
---|
10246 |
|
---|
10247 | typedef ULONG_PTR (*PDRIVER_VERIFIER_THUNK_ROUTINE) (
|
---|
10248 | IN PVOID Context
|
---|
10249 | );
|
---|
10250 |
|
---|
10251 | //
|
---|
10252 | // This structure is passed in by drivers that want to thunk callers of
|
---|
10253 | // their exports.
|
---|
10254 | //
|
---|
10255 |
|
---|
10256 | typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
|
---|
10257 | PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
|
---|
10258 | PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
|
---|
10259 | } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
|
---|
10260 |
|
---|
10261 | //
|
---|
10262 | // Driver Verifier flags.
|
---|
10263 | //
|
---|
10264 |
|
---|
10265 | #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
|
---|
10266 | #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
|
---|
10267 | #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
|
---|
10268 | #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
|
---|
10269 | #define DRIVER_VERIFIER_IO_CHECKING 0x0010
|
---|
10270 |
|
---|
10271 |
|
---|
10272 | //
|
---|
10273 | // Defined processor features
|
---|
10274 | //
|
---|
10275 |
|
---|
10276 | #define PF_FLOATING_POINT_PRECISION_ERRATA 0
|
---|
10277 | #define PF_FLOATING_POINT_EMULATED 1
|
---|
10278 | #define PF_COMPARE_EXCHANGE_DOUBLE 2
|
---|
10279 | #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
|
---|
10280 | #define PF_PPC_MOVEMEM_64BIT_OK 4
|
---|
10281 | #define PF_ALPHA_BYTE_INSTRUCTIONS 5
|
---|
10282 | #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
|
---|
10283 | #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
|
---|
10284 | #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
|
---|
10285 | #define PF_PAE_ENABLED 9
|
---|
10286 | #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
|
---|
10287 |
|
---|
10288 | typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
|
---|
10289 | StandardDesign, // None == 0 == standard design
|
---|
10290 | NEC98x86, // NEC PC98xx series on X86
|
---|
10291 | EndAlternatives // past end of known alternatives
|
---|
10292 | } ALTERNATIVE_ARCHITECTURE_TYPE;
|
---|
10293 |
|
---|
10294 | // correctly define these run-time definitions for non X86 machines
|
---|
10295 |
|
---|
10296 | #ifndef _X86_
|
---|
10297 |
|
---|
10298 | #ifndef IsNEC_98
|
---|
10299 | #define IsNEC_98 (FALSE)
|
---|
10300 | #endif
|
---|
10301 |
|
---|
10302 | #ifndef IsNotNEC_98
|
---|
10303 | #define IsNotNEC_98 (TRUE)
|
---|
10304 | #endif
|
---|
10305 |
|
---|
10306 | #ifndef SetNEC_98
|
---|
10307 | #define SetNEC_98
|
---|
10308 | #endif
|
---|
10309 |
|
---|
10310 | #ifndef SetNotNEC_98
|
---|
10311 | #define SetNotNEC_98
|
---|
10312 | #endif
|
---|
10313 |
|
---|
10314 | #endif
|
---|
10315 |
|
---|
10316 | #define PROCESSOR_FEATURE_MAX 64
|
---|
10317 |
|
---|
10318 |
|
---|
10319 |
|
---|
10320 | #if defined(REMOTE_BOOT)
|
---|
10321 | //
|
---|
10322 | // Defined system flags.
|
---|
10323 | //
|
---|
10324 |
|
---|
10325 | /* the following two lines should be tagged with "winnt" when REMOTE_BOOT is on. */
|
---|
10326 | #define SYSTEM_FLAG_REMOTE_BOOT_CLIENT 0x00000001
|
---|
10327 | #define SYSTEM_FLAG_DISKLESS_CLIENT 0x00000002
|
---|
10328 | #endif // defined(REMOTE_BOOT)
|
---|
10329 |
|
---|
10330 | //
|
---|
10331 | // Define data shared between kernel and user mode.
|
---|
10332 | //
|
---|
10333 | // N.B. User mode has read only access to this data
|
---|
10334 | //
|
---|
10335 | #ifdef _MAC
|
---|
10336 | #pragma warning( disable : 4121)
|
---|
10337 | #endif
|
---|
10338 |
|
---|
10339 | //
|
---|
10340 | // WARNING: This structure must have exactly the same layout for 32- and
|
---|
10341 | // 64-bit systems. The layout of this structure cannot change and new
|
---|
10342 | // fields can only be added to the end of the structure. Deprecated
|
---|
10343 | // fields cannot be deleted. Platform specific fields are included on
|
---|
10344 | // all systems.
|
---|
10345 | //
|
---|
10346 | // Layout exactness is required for Wow64 support of 32bit applications
|
---|
10347 | // on Win64 systems.
|
---|
10348 | //
|
---|
10349 | // The layout itself cannot change since this structure has been exported
|
---|
10350 | // in ntddk, ntifs.h, and nthal.h for some time.
|
---|
10351 | //
|
---|
10352 |
|
---|
10353 | typedef struct _KUSER_SHARED_DATA {
|
---|
10354 |
|
---|
10355 | //
|
---|
10356 | // Current low 32-bit of tick count and tick count multiplier.
|
---|
10357 | //
|
---|
10358 | // N.B. The tick count is updated each time the clock ticks.
|
---|
10359 | //
|
---|
10360 |
|
---|
10361 | ULONG TickCountLowDeprecated;
|
---|
10362 | ULONG TickCountMultiplier;
|
---|
10363 |
|
---|
10364 | //
|
---|
10365 | // Current 64-bit interrupt time in 100ns units.
|
---|
10366 | //
|
---|
10367 |
|
---|
10368 | volatile KSYSTEM_TIME InterruptTime;
|
---|
10369 |
|
---|
10370 | //
|
---|
10371 | // Current 64-bit system time in 100ns units.
|
---|
10372 | //
|
---|
10373 |
|
---|
10374 | volatile KSYSTEM_TIME SystemTime;
|
---|
10375 |
|
---|
10376 | //
|
---|
10377 | // Current 64-bit time zone bias.
|
---|
10378 | //
|
---|
10379 |
|
---|
10380 | volatile KSYSTEM_TIME TimeZoneBias;
|
---|
10381 |
|
---|
10382 | //
|
---|
10383 | // Support image magic number range for the host system.
|
---|
10384 | //
|
---|
10385 | // N.B. This is an inclusive range.
|
---|
10386 | //
|
---|
10387 |
|
---|
10388 | USHORT ImageNumberLow;
|
---|
10389 | USHORT ImageNumberHigh;
|
---|
10390 |
|
---|
10391 | //
|
---|
10392 | // Copy of system root in Unicode
|
---|
10393 | //
|
---|
10394 |
|
---|
10395 | WCHAR NtSystemRoot[ 260 ];
|
---|
10396 |
|
---|
10397 | //
|
---|
10398 | // Maximum stack trace depth if tracing enabled.
|
---|
10399 | //
|
---|
10400 |
|
---|
10401 | ULONG MaxStackTraceDepth;
|
---|
10402 |
|
---|
10403 | //
|
---|
10404 | // Crypto Exponent
|
---|
10405 | //
|
---|
10406 |
|
---|
10407 | ULONG CryptoExponent;
|
---|
10408 |
|
---|
10409 | //
|
---|
10410 | // TimeZoneId
|
---|
10411 | //
|
---|
10412 |
|
---|
10413 | ULONG TimeZoneId;
|
---|
10414 |
|
---|
10415 | ULONG LargePageMinimum;
|
---|
10416 | ULONG Reserved2[ 7 ];
|
---|
10417 |
|
---|
10418 | //
|
---|
10419 | // product type
|
---|
10420 | //
|
---|
10421 |
|
---|
10422 | NT_PRODUCT_TYPE NtProductType;
|
---|
10423 | BOOLEAN ProductTypeIsValid;
|
---|
10424 |
|
---|
10425 | //
|
---|
10426 | // NT Version. Note that each process sees a version from its PEB, but
|
---|
10427 | // if the process is running with an altered view of the system version,
|
---|
10428 | // the following two fields are used to correctly identify the version
|
---|
10429 | //
|
---|
10430 |
|
---|
10431 | ULONG NtMajorVersion;
|
---|
10432 | ULONG NtMinorVersion;
|
---|
10433 |
|
---|
10434 | //
|
---|
10435 | // Processor Feature Bits
|
---|
10436 | //
|
---|
10437 |
|
---|
10438 | BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
|
---|
10439 |
|
---|
10440 | //
|
---|
10441 | // Reserved fields - do not use
|
---|
10442 | //
|
---|
10443 | ULONG Reserved1;
|
---|
10444 | ULONG Reserved3;
|
---|
10445 |
|
---|
10446 | //
|
---|
10447 | // Time slippage while in debugger
|
---|
10448 | //
|
---|
10449 |
|
---|
10450 | volatile ULONG TimeSlip;
|
---|
10451 |
|
---|
10452 | //
|
---|
10453 | // Alternative system architecture. Example: NEC PC98xx on x86
|
---|
10454 | //
|
---|
10455 |
|
---|
10456 | ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
|
---|
10457 |
|
---|
10458 | //
|
---|
10459 | // If the system is an evaluation unit, the following field contains the
|
---|
10460 | // date and time that the evaluation unit expires. A value of 0 indicates
|
---|
10461 | // that there is no expiration. A non-zero value is the UTC absolute time
|
---|
10462 | // that the system expires.
|
---|
10463 | //
|
---|
10464 |
|
---|
10465 | LARGE_INTEGER SystemExpirationDate;
|
---|
10466 |
|
---|
10467 | //
|
---|
10468 | // Suite Support
|
---|
10469 | //
|
---|
10470 |
|
---|
10471 | ULONG SuiteMask;
|
---|
10472 |
|
---|
10473 | //
|
---|
10474 | // TRUE if a kernel debugger is connected/enabled
|
---|
10475 | //
|
---|
10476 |
|
---|
10477 | BOOLEAN KdDebuggerEnabled;
|
---|
10478 |
|
---|
10479 |
|
---|
10480 | //
|
---|
10481 | // Current console session Id. Always zero on non-TS systems
|
---|
10482 | //
|
---|
10483 | volatile ULONG ActiveConsoleId;
|
---|
10484 |
|
---|
10485 | //
|
---|
10486 | // Force-dismounts cause handles to become invalid. Rather than
|
---|
10487 | // always probe handles, we maintain a serial number of
|
---|
10488 | // dismounts that clients can use to see if they need to probe
|
---|
10489 | // handles.
|
---|
10490 | //
|
---|
10491 |
|
---|
10492 | volatile ULONG DismountCount;
|
---|
10493 |
|
---|
10494 | //
|
---|
10495 | // This field indicates the status of the 64-bit COM+ package on the system.
|
---|
10496 | // It indicates whether the Intermediate Language (IL) COM+ images need to
|
---|
10497 | // use the 64-bit COM+ runtime or the 32-bit COM+ runtime.
|
---|
10498 | //
|
---|
10499 |
|
---|
10500 | ULONG ComPlusPackage;
|
---|
10501 |
|
---|
10502 | //
|
---|
10503 | // Time in tick count for system-wide last user input across all
|
---|
10504 | // terminal sessions. For MP performance, it is not updated all
|
---|
10505 | // the time (e.g. once a minute per session). It is used for idle
|
---|
10506 | // detection.
|
---|
10507 | //
|
---|
10508 |
|
---|
10509 | ULONG LastSystemRITEventTickCount;
|
---|
10510 |
|
---|
10511 | //
|
---|
10512 | // Number of physical pages in the system. This can dynamically
|
---|
10513 | // change as physical memory can be added or removed from a running
|
---|
10514 | // system.
|
---|
10515 | //
|
---|
10516 |
|
---|
10517 | ULONG NumberOfPhysicalPages;
|
---|
10518 |
|
---|
10519 | //
|
---|
10520 | // True if the system was booted in safe boot mode.
|
---|
10521 | //
|
---|
10522 |
|
---|
10523 | BOOLEAN SafeBootMode;
|
---|
10524 |
|
---|
10525 | //
|
---|
10526 | // The following field is used for Heap and CritSec Tracing
|
---|
10527 | // The last bit is set for Critical Sec Collision tracing and
|
---|
10528 | // second Last bit is for Heap Tracing
|
---|
10529 | // Also the first 16 bits are used as counter.
|
---|
10530 | //
|
---|
10531 |
|
---|
10532 | ULONG TraceLogging;
|
---|
10533 |
|
---|
10534 | //
|
---|
10535 | // Depending on the processor, the code for fast system call
|
---|
10536 | // will differ, the following buffer is filled with the appropriate
|
---|
10537 | // code sequence and user mode code will branch through it.
|
---|
10538 | //
|
---|
10539 | // (32 bytes, using ULONGLONG for alignment).
|
---|
10540 | //
|
---|
10541 | // N.B. The following two fields are only used on 32-bit systems.
|
---|
10542 | //
|
---|
10543 |
|
---|
10544 | ULONGLONG Fill0; // alignment
|
---|
10545 | ULONGLONG SystemCall[4];
|
---|
10546 |
|
---|
10547 | //
|
---|
10548 | // The 64-bit tick count.
|
---|
10549 | //
|
---|
10550 |
|
---|
10551 | union {
|
---|
10552 | volatile KSYSTEM_TIME TickCount;
|
---|
10553 | volatile ULONG64 TickCountQuad;
|
---|
10554 | };
|
---|
10555 |
|
---|
10556 | } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
|
---|
10557 |
|
---|
10558 | #ifdef _MAC
|
---|
10559 | #pragma warning( default : 4121 )
|
---|
10560 | #endif
|
---|
10561 |
|
---|
10562 |
|
---|
10563 | //
|
---|
10564 | // Predefined Value Types.
|
---|
10565 | //
|
---|
10566 |
|
---|
10567 | #define REG_NONE ( 0 ) // No value type
|
---|
10568 | #define REG_SZ ( 1 ) // Unicode nul terminated string
|
---|
10569 | #define REG_EXPAND_SZ ( 2 ) // Unicode nul terminated string
|
---|
10570 | // (with environment variable references)
|
---|
10571 | #define REG_BINARY ( 3 ) // Free form binary
|
---|
10572 | #define REG_DWORD ( 4 ) // 32-bit number
|
---|
10573 | #define REG_DWORD_LITTLE_ENDIAN ( 4 ) // 32-bit number (same as REG_DWORD)
|
---|
10574 | #define REG_DWORD_BIG_ENDIAN ( 5 ) // 32-bit number
|
---|
10575 | #define REG_LINK ( 6 ) // Symbolic Link (unicode)
|
---|
10576 | #define REG_MULTI_SZ ( 7 ) // Multiple Unicode strings
|
---|
10577 | #define REG_RESOURCE_LIST ( 8 ) // Resource list in the resource map
|
---|
10578 | #define REG_FULL_RESOURCE_DESCRIPTOR ( 9 ) // Resource list in the hardware description
|
---|
10579 | #define REG_RESOURCE_REQUIREMENTS_LIST ( 10 )
|
---|
10580 | #define REG_QWORD ( 11 ) // 64-bit number
|
---|
10581 | #define REG_QWORD_LITTLE_ENDIAN ( 11 ) // 64-bit number (same as REG_QWORD)
|
---|
10582 |
|
---|
10583 | //
|
---|
10584 | // Service Types (Bit Mask)
|
---|
10585 | //
|
---|
10586 | #define SERVICE_KERNEL_DRIVER 0x00000001
|
---|
10587 | #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
|
---|
10588 | #define SERVICE_ADAPTER 0x00000004
|
---|
10589 | #define SERVICE_RECOGNIZER_DRIVER 0x00000008
|
---|
10590 |
|
---|
10591 | #define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \
|
---|
10592 | SERVICE_FILE_SYSTEM_DRIVER | \
|
---|
10593 | SERVICE_RECOGNIZER_DRIVER)
|
---|
10594 |
|
---|
10595 | #define SERVICE_WIN32_OWN_PROCESS 0x00000010
|
---|
10596 | #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
|
---|
10597 | #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \
|
---|
10598 | SERVICE_WIN32_SHARE_PROCESS)
|
---|
10599 |
|
---|
10600 | #define SERVICE_INTERACTIVE_PROCESS 0x00000100
|
---|
10601 |
|
---|
10602 | #define SERVICE_TYPE_ALL (SERVICE_WIN32 | \
|
---|
10603 | SERVICE_ADAPTER | \
|
---|
10604 | SERVICE_DRIVER | \
|
---|
10605 | SERVICE_INTERACTIVE_PROCESS)
|
---|
10606 |
|
---|
10607 | //
|
---|
10608 | // Start Type
|
---|
10609 | //
|
---|
10610 |
|
---|
10611 | #define SERVICE_BOOT_START 0x00000000
|
---|
10612 | #define SERVICE_SYSTEM_START 0x00000001
|
---|
10613 | #define SERVICE_AUTO_START 0x00000002
|
---|
10614 | #define SERVICE_DEMAND_START 0x00000003
|
---|
10615 | #define SERVICE_DISABLED 0x00000004
|
---|
10616 |
|
---|
10617 | //
|
---|
10618 | // Error control type
|
---|
10619 | //
|
---|
10620 | #define SERVICE_ERROR_IGNORE 0x00000000
|
---|
10621 | #define SERVICE_ERROR_NORMAL 0x00000001
|
---|
10622 | #define SERVICE_ERROR_SEVERE 0x00000002
|
---|
10623 | #define SERVICE_ERROR_CRITICAL 0x00000003
|
---|
10624 |
|
---|
10625 | //
|
---|
10626 | //
|
---|
10627 | // Define the registry driver node enumerations
|
---|
10628 | //
|
---|
10629 |
|
---|
10630 | typedef enum _CM_SERVICE_NODE_TYPE {
|
---|
10631 | DriverType = SERVICE_KERNEL_DRIVER,
|
---|
10632 | FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
|
---|
10633 | Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
|
---|
10634 | Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
|
---|
10635 | AdapterType = SERVICE_ADAPTER,
|
---|
10636 | RecognizerType = SERVICE_RECOGNIZER_DRIVER
|
---|
10637 | } SERVICE_NODE_TYPE;
|
---|
10638 |
|
---|
10639 | typedef enum _CM_SERVICE_LOAD_TYPE {
|
---|
10640 | BootLoad = SERVICE_BOOT_START,
|
---|
10641 | SystemLoad = SERVICE_SYSTEM_START,
|
---|
10642 | AutoLoad = SERVICE_AUTO_START,
|
---|
10643 | DemandLoad = SERVICE_DEMAND_START,
|
---|
10644 | DisableLoad = SERVICE_DISABLED
|
---|
10645 | } SERVICE_LOAD_TYPE;
|
---|
10646 |
|
---|
10647 | typedef enum _CM_ERROR_CONTROL_TYPE {
|
---|
10648 | IgnoreError = SERVICE_ERROR_IGNORE,
|
---|
10649 | NormalError = SERVICE_ERROR_NORMAL,
|
---|
10650 | SevereError = SERVICE_ERROR_SEVERE,
|
---|
10651 | CriticalError = SERVICE_ERROR_CRITICAL
|
---|
10652 | } SERVICE_ERROR_TYPE;
|
---|
10653 |
|
---|
10654 |
|
---|
10655 |
|
---|
10656 | //
|
---|
10657 | // Resource List definitions
|
---|
10658 | //
|
---|
10659 |
|
---|
10660 |
|
---|
10661 |
|
---|
10662 | //
|
---|
10663 | // Defines the Type in the RESOURCE_DESCRIPTOR
|
---|
10664 | //
|
---|
10665 | // NOTE: For all CM_RESOURCE_TYPE values, there must be a
|
---|
10666 | // corresponding ResType value in the 32-bit ConfigMgr headerfile
|
---|
10667 | // (cfgmgr32.h). Values in the range [0x6,0x80) use the same values
|
---|
10668 | // as their ConfigMgr counterparts. CM_RESOURCE_TYPE values with
|
---|
10669 | // the high bit set (i.e., in the range [0x80,0xFF]), are
|
---|
10670 | // non-arbitrated resources. These correspond to the same values
|
---|
10671 | // in cfgmgr32.h that have their high bit set (however, since
|
---|
10672 | // cfgmgr32.h uses 16 bits for ResType values, these values are in
|
---|
10673 | // the range [0x8000,0x807F). Note that ConfigMgr ResType values
|
---|
10674 | // cannot be in the range [0x8080,0xFFFF), because they would not
|
---|
10675 | // be able to map into CM_RESOURCE_TYPE values. (0xFFFF itself is
|
---|
10676 | // a special value, because it maps to CmResourceTypeDeviceSpecific.)
|
---|
10677 | //
|
---|
10678 |
|
---|
10679 | typedef int CM_RESOURCE_TYPE;
|
---|
10680 |
|
---|
10681 | // CmResourceTypeNull is reserved
|
---|
10682 |
|
---|
10683 | #define CmResourceTypeNull 0 // ResType_All or ResType_None (0x0000)
|
---|
10684 | #define CmResourceTypePort 1 // ResType_IO (0x0002)
|
---|
10685 | #define CmResourceTypeInterrupt 2 // ResType_IRQ (0x0004)
|
---|
10686 | #define CmResourceTypeMemory 3 // ResType_Mem (0x0001)
|
---|
10687 | #define CmResourceTypeDma 4 // ResType_DMA (0x0003)
|
---|
10688 | #define CmResourceTypeDeviceSpecific 5 // ResType_ClassSpecific (0xFFFF)
|
---|
10689 | #define CmResourceTypeBusNumber 6 // ResType_BusNumber (0x0006)
|
---|
10690 |
|
---|
10691 | #define CmResourceTypeMaximum 7
|
---|
10692 |
|
---|
10693 | #define CmResourceTypeNonArbitrated 128 // Not arbitrated if 0x80 bit set
|
---|
10694 | #define CmResourceTypeConfigData 128 // ResType_Reserved (0x8000)
|
---|
10695 | #define CmResourceTypeDevicePrivate 129 // ResType_DevicePrivate (0x8001)
|
---|
10696 | #define CmResourceTypePcCardConfig 130 // ResType_PcCardConfig (0x8002)
|
---|
10697 | #define CmResourceTypeMfCardConfig 131 // ResType_MfCardConfig (0x8003)
|
---|
10698 |
|
---|
10699 | //
|
---|
10700 | // Defines the ShareDisposition in the RESOURCE_DESCRIPTOR
|
---|
10701 | //
|
---|
10702 |
|
---|
10703 | typedef enum _CM_SHARE_DISPOSITION {
|
---|
10704 | CmResourceShareUndetermined = 0, // Reserved
|
---|
10705 | CmResourceShareDeviceExclusive,
|
---|
10706 | CmResourceShareDriverExclusive,
|
---|
10707 | CmResourceShareShared
|
---|
10708 | } CM_SHARE_DISPOSITION;
|
---|
10709 |
|
---|
10710 | //
|
---|
10711 | // Define the bit masks for Flags when type is CmResourceTypeInterrupt
|
---|
10712 | //
|
---|
10713 |
|
---|
10714 | #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
|
---|
10715 | #define CM_RESOURCE_INTERRUPT_LATCHED 1
|
---|
10716 |
|
---|
10717 | //
|
---|
10718 | // Define the bit masks for Flags when type is CmResourceTypeMemory
|
---|
10719 | //
|
---|
10720 |
|
---|
10721 | #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
|
---|
10722 | #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
|
---|
10723 | #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
|
---|
10724 | #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
|
---|
10725 |
|
---|
10726 | #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
|
---|
10727 | #define CM_RESOURCE_MEMORY_24 0x0010
|
---|
10728 | #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
|
---|
10729 |
|
---|
10730 | //
|
---|
10731 | // Define the bit masks for Flags when type is CmResourceTypePort
|
---|
10732 | //
|
---|
10733 |
|
---|
10734 | #define CM_RESOURCE_PORT_MEMORY 0x0000
|
---|
10735 | #define CM_RESOURCE_PORT_IO 0x0001
|
---|
10736 | #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
|
---|
10737 | #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
|
---|
10738 | #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
|
---|
10739 | #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
|
---|
10740 | #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
|
---|
10741 | #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
|
---|
10742 |
|
---|
10743 | //
|
---|
10744 | // Define the bit masks for Flags when type is CmResourceTypeDma
|
---|
10745 | //
|
---|
10746 |
|
---|
10747 | #define CM_RESOURCE_DMA_8 0x0000
|
---|
10748 | #define CM_RESOURCE_DMA_16 0x0001
|
---|
10749 | #define CM_RESOURCE_DMA_32 0x0002
|
---|
10750 | #define CM_RESOURCE_DMA_8_AND_16 0x0004
|
---|
10751 | #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
|
---|
10752 | #define CM_RESOURCE_DMA_TYPE_A 0x0010
|
---|
10753 | #define CM_RESOURCE_DMA_TYPE_B 0x0020
|
---|
10754 | #define CM_RESOURCE_DMA_TYPE_F 0x0040
|
---|
10755 |
|
---|
10756 |
|
---|
10757 |
|
---|
10758 | //
|
---|
10759 | // This structure defines one type of resource used by a driver.
|
---|
10760 | //
|
---|
10761 | // There can only be *1* DeviceSpecificData block. It must be located at
|
---|
10762 | // the end of all resource descriptors in a full descriptor block.
|
---|
10763 | //
|
---|
10764 |
|
---|
10765 | //
|
---|
10766 | // Make sure alignment is made properly by compiler; otherwise move
|
---|
10767 | // flags back to the top of the structure (common to all members of the
|
---|
10768 | // union).
|
---|
10769 | //
|
---|
10770 |
|
---|
10771 |
|
---|
10772 | #include "pshpack4.h"
|
---|
10773 | typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
|
---|
10774 | UCHAR Type;
|
---|
10775 | UCHAR ShareDisposition;
|
---|
10776 | USHORT Flags;
|
---|
10777 | union {
|
---|
10778 |
|
---|
10779 | //
|
---|
10780 | // Range of resources, inclusive. These are physical, bus relative.
|
---|
10781 | // It is known that Port and Memory below have the exact same layout
|
---|
10782 | // as Generic.
|
---|
10783 | //
|
---|
10784 |
|
---|
10785 | struct {
|
---|
10786 | PHYSICAL_ADDRESS Start;
|
---|
10787 | ULONG Length;
|
---|
10788 | } Generic;
|
---|
10789 |
|
---|
10790 | //
|
---|
10791 |
|
---|
10792 | // Range of port numbers, inclusive. These are physical, bus
|
---|
10793 | // relative. The value should be the same as the one passed to
|
---|
10794 | // HalTranslateBusAddress().
|
---|
10795 |
|
---|
10796 | //
|
---|
10797 |
|
---|
10798 | struct {
|
---|
10799 | PHYSICAL_ADDRESS Start;
|
---|
10800 | ULONG Length;
|
---|
10801 | } Port;
|
---|
10802 |
|
---|
10803 | //
|
---|
10804 |
|
---|
10805 | // IRQL and vector. Should be same values as were passed to
|
---|
10806 | // HalGetInterruptVector().
|
---|
10807 |
|
---|
10808 | //
|
---|
10809 |
|
---|
10810 | struct {
|
---|
10811 | ULONG Level;
|
---|
10812 | ULONG Vector;
|
---|
10813 | KAFFINITY Affinity;
|
---|
10814 | } Interrupt;
|
---|
10815 |
|
---|
10816 | //
|
---|
10817 | // Range of memory addresses, inclusive. These are physical, bus
|
---|
10818 | // relative. The value should be the same as the one passed to
|
---|
10819 | // HalTranslateBusAddress().
|
---|
10820 | //
|
---|
10821 |
|
---|
10822 | struct {
|
---|
10823 | PHYSICAL_ADDRESS Start; // 64 bit physical addresses.
|
---|
10824 | ULONG Length;
|
---|
10825 | } Memory;
|
---|
10826 |
|
---|
10827 | //
|
---|
10828 | // Physical DMA channel.
|
---|
10829 | //
|
---|
10830 |
|
---|
10831 | struct {
|
---|
10832 | ULONG Channel;
|
---|
10833 | ULONG Port;
|
---|
10834 | ULONG Reserved1;
|
---|
10835 | } Dma;
|
---|
10836 |
|
---|
10837 | //
|
---|
10838 | // Device driver private data, usually used to help it figure
|
---|
10839 | // what the resource assignments decisions that were made.
|
---|
10840 | //
|
---|
10841 |
|
---|
10842 | struct {
|
---|
10843 | ULONG Data[3];
|
---|
10844 | } DevicePrivate;
|
---|
10845 |
|
---|
10846 | //
|
---|
10847 | // Bus Number information.
|
---|
10848 | //
|
---|
10849 |
|
---|
10850 | struct {
|
---|
10851 | ULONG Start;
|
---|
10852 | ULONG Length;
|
---|
10853 | ULONG Reserved;
|
---|
10854 | } BusNumber;
|
---|
10855 |
|
---|
10856 | //
|
---|
10857 | // Device Specific information defined by the driver.
|
---|
10858 | // The DataSize field indicates the size of the data in bytes. The
|
---|
10859 | // data is located immediately after the DeviceSpecificData field in
|
---|
10860 | // the structure.
|
---|
10861 | //
|
---|
10862 |
|
---|
10863 | struct {
|
---|
10864 | ULONG DataSize;
|
---|
10865 | ULONG Reserved1;
|
---|
10866 | ULONG Reserved2;
|
---|
10867 | } DeviceSpecificData;
|
---|
10868 | } u;
|
---|
10869 | } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
|
---|
10870 | #include "poppack.h"
|
---|
10871 |
|
---|
10872 | //
|
---|
10873 | // A Partial Resource List is what can be found in the ARC firmware
|
---|
10874 | // or will be generated by ntdetect.com.
|
---|
10875 | // The configuration manager will transform this structure into a Full
|
---|
10876 | // resource descriptor when it is about to store it in the registry.
|
---|
10877 | //
|
---|
10878 | // Note: There must a be a convention to the order of fields of same type,
|
---|
10879 | // (defined on a device by device basis) so that the fields can make sense
|
---|
10880 | // to a driver (i.e. when multiple memory ranges are necessary).
|
---|
10881 | //
|
---|
10882 |
|
---|
10883 | typedef struct _CM_PARTIAL_RESOURCE_LIST {
|
---|
10884 | USHORT Version;
|
---|
10885 | USHORT Revision;
|
---|
10886 | ULONG Count;
|
---|
10887 | CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
|
---|
10888 | } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
|
---|
10889 |
|
---|
10890 | //
|
---|
10891 | // A Full Resource Descriptor is what can be found in the registry.
|
---|
10892 | // This is what will be returned to a driver when it queries the registry
|
---|
10893 | // to get device information; it will be stored under a key in the hardware
|
---|
10894 | // description tree.
|
---|
10895 | //
|
---|
10896 |
|
---|
10897 | // Note: The BusNumber and Type are redundant information, but we will keep
|
---|
10898 | // it since it allows the driver _not_ to append it when it is creating
|
---|
10899 | // a resource list which could possibly span multiple buses.
|
---|
10900 | //
|
---|
10901 |
|
---|
10902 | // Note: There must a be a convention to the order of fields of same type,
|
---|
10903 | // (defined on a device by device basis) so that the fields can make sense
|
---|
10904 | // to a driver (i.e. when multiple memory ranges are necessary).
|
---|
10905 | //
|
---|
10906 |
|
---|
10907 | typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
|
---|
10908 | INTERFACE_TYPE InterfaceType; // unused for WDM
|
---|
10909 | ULONG BusNumber; // unused for WDM
|
---|
10910 | CM_PARTIAL_RESOURCE_LIST PartialResourceList;
|
---|
10911 | } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
|
---|
10912 |
|
---|
10913 | //
|
---|
10914 | // The Resource list is what will be stored by the drivers into the
|
---|
10915 | // resource map via the IO API.
|
---|
10916 | //
|
---|
10917 |
|
---|
10918 | typedef struct _CM_RESOURCE_LIST {
|
---|
10919 | ULONG Count;
|
---|
10920 | CM_FULL_RESOURCE_DESCRIPTOR List[1];
|
---|
10921 | } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
|
---|
10922 |
|
---|
10923 |
|
---|
10924 | //
|
---|
10925 | // Define the structures used to interpret configuration data of
|
---|
10926 | // \\Registry\machine\hardware\description tree.
|
---|
10927 | // Basically, these structures are used to interpret component
|
---|
10928 | // specific data.
|
---|
10929 | //
|
---|
10930 |
|
---|
10931 | //
|
---|
10932 | // Define DEVICE_FLAGS
|
---|
10933 | //
|
---|
10934 |
|
---|
10935 | typedef struct _DEVICE_FLAGS {
|
---|
10936 | ULONG Failed : 1;
|
---|
10937 | ULONG ReadOnly : 1;
|
---|
10938 | ULONG Removable : 1;
|
---|
10939 | ULONG ConsoleIn : 1;
|
---|
10940 | ULONG ConsoleOut : 1;
|
---|
10941 | ULONG Input : 1;
|
---|
10942 | ULONG Output : 1;
|
---|
10943 | } DEVICE_FLAGS, *PDEVICE_FLAGS;
|
---|
10944 |
|
---|
10945 | //
|
---|
10946 | // Define Component Information structure
|
---|
10947 | //
|
---|
10948 |
|
---|
10949 | typedef struct _CM_COMPONENT_INFORMATION {
|
---|
10950 | DEVICE_FLAGS Flags;
|
---|
10951 | ULONG Version;
|
---|
10952 | ULONG Key;
|
---|
10953 | KAFFINITY AffinityMask;
|
---|
10954 | } CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
|
---|
10955 |
|
---|
10956 | //
|
---|
10957 | // The following structures are used to interpret x86
|
---|
10958 | // DeviceSpecificData of CM_PARTIAL_RESOURCE_DESCRIPTOR.
|
---|
10959 | // (Most of the structures are defined by BIOS. They are
|
---|
10960 | // not aligned on word (or dword) boundary.
|
---|
10961 | //
|
---|
10962 |
|
---|
10963 | //
|
---|
10964 | // Define the Rom Block structure
|
---|
10965 | //
|
---|
10966 |
|
---|
10967 | typedef struct _CM_ROM_BLOCK {
|
---|
10968 | ULONG Address;
|
---|
10969 | ULONG Size;
|
---|
10970 | } CM_ROM_BLOCK, *PCM_ROM_BLOCK;
|
---|
10971 |
|
---|
10972 |
|
---|
10973 |
|
---|
10974 | #include "pshpack1.h"
|
---|
10975 |
|
---|
10976 |
|
---|
10977 |
|
---|
10978 | //
|
---|
10979 | // Define INT13 driver parameter block
|
---|
10980 | //
|
---|
10981 |
|
---|
10982 | typedef struct _CM_INT13_DRIVE_PARAMETER {
|
---|
10983 | USHORT DriveSelect;
|
---|
10984 | ULONG MaxCylinders;
|
---|
10985 | USHORT SectorsPerTrack;
|
---|
10986 | USHORT MaxHeads;
|
---|
10987 | USHORT NumberDrives;
|
---|
10988 | } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
|
---|
10989 |
|
---|
10990 |
|
---|
10991 |
|
---|
10992 | //
|
---|
10993 | // Define Mca POS data block for slot
|
---|
10994 | //
|
---|
10995 |
|
---|
10996 | typedef struct _CM_MCA_POS_DATA {
|
---|
10997 | USHORT AdapterId;
|
---|
10998 | UCHAR PosData1;
|
---|
10999 | UCHAR PosData2;
|
---|
11000 | UCHAR PosData3;
|
---|
11001 | UCHAR PosData4;
|
---|
11002 | } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
|
---|
11003 |
|
---|
11004 | //
|
---|
11005 | // Memory configuration of eisa data block structure
|
---|
11006 | //
|
---|
11007 |
|
---|
11008 | typedef struct _EISA_MEMORY_TYPE {
|
---|
11009 | UCHAR ReadWrite: 1;
|
---|
11010 | UCHAR Cached : 1;
|
---|
11011 | UCHAR Reserved0 :1;
|
---|
11012 | UCHAR Type:2;
|
---|
11013 | UCHAR Shared:1;
|
---|
11014 | UCHAR Reserved1 :1;
|
---|
11015 | UCHAR MoreEntries : 1;
|
---|
11016 | } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
|
---|
11017 |
|
---|
11018 | typedef struct _EISA_MEMORY_CONFIGURATION {
|
---|
11019 | EISA_MEMORY_TYPE ConfigurationByte;
|
---|
11020 | UCHAR DataSize;
|
---|
11021 | USHORT AddressLowWord;
|
---|
11022 | UCHAR AddressHighByte;
|
---|
11023 | USHORT MemorySize;
|
---|
11024 | } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
|
---|
11025 |
|
---|
11026 |
|
---|
11027 | //
|
---|
11028 | // Interrupt configuration of eisa data block structure
|
---|
11029 | //
|
---|
11030 |
|
---|
11031 | typedef struct _EISA_IRQ_DESCRIPTOR {
|
---|
11032 | UCHAR Interrupt : 4;
|
---|
11033 | UCHAR Reserved :1;
|
---|
11034 | UCHAR LevelTriggered :1;
|
---|
11035 | UCHAR Shared : 1;
|
---|
11036 | UCHAR MoreEntries : 1;
|
---|
11037 | } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
|
---|
11038 |
|
---|
11039 | typedef struct _EISA_IRQ_CONFIGURATION {
|
---|
11040 | EISA_IRQ_DESCRIPTOR ConfigurationByte;
|
---|
11041 | UCHAR Reserved;
|
---|
11042 | } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
|
---|
11043 |
|
---|
11044 |
|
---|
11045 | //
|
---|
11046 | // DMA description of eisa data block structure
|
---|
11047 | //
|
---|
11048 |
|
---|
11049 | typedef struct _DMA_CONFIGURATION_BYTE0 {
|
---|
11050 | UCHAR Channel : 3;
|
---|
11051 | UCHAR Reserved : 3;
|
---|
11052 | UCHAR Shared :1;
|
---|
11053 | UCHAR MoreEntries :1;
|
---|
11054 | } DMA_CONFIGURATION_BYTE0;
|
---|
11055 |
|
---|
11056 | typedef struct _DMA_CONFIGURATION_BYTE1 {
|
---|
11057 | UCHAR Reserved0 : 2;
|
---|
11058 | UCHAR TransferSize : 2;
|
---|
11059 | UCHAR Timing : 2;
|
---|
11060 | UCHAR Reserved1 : 2;
|
---|
11061 | } DMA_CONFIGURATION_BYTE1;
|
---|
11062 |
|
---|
11063 | typedef struct _EISA_DMA_CONFIGURATION {
|
---|
11064 | DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
|
---|
11065 | DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
|
---|
11066 | } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
|
---|
11067 |
|
---|
11068 |
|
---|
11069 | //
|
---|
11070 | // Port description of eisa data block structure
|
---|
11071 | //
|
---|
11072 |
|
---|
11073 | typedef struct _EISA_PORT_DESCRIPTOR {
|
---|
11074 | UCHAR NumberPorts : 5;
|
---|
11075 | UCHAR Reserved :1;
|
---|
11076 | UCHAR Shared :1;
|
---|
11077 | UCHAR MoreEntries : 1;
|
---|
11078 | } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
|
---|
11079 |
|
---|
11080 | typedef struct _EISA_PORT_CONFIGURATION {
|
---|
11081 | EISA_PORT_DESCRIPTOR Configuration;
|
---|
11082 | USHORT PortAddress;
|
---|
11083 | } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
|
---|
11084 |
|
---|
11085 |
|
---|
11086 | //
|
---|
11087 | // Eisa slot information definition
|
---|
11088 | // N.B. This structure is different from the one defined
|
---|
11089 | // in ARC eisa addendum.
|
---|
11090 | //
|
---|
11091 |
|
---|
11092 | typedef struct _CM_EISA_SLOT_INFORMATION {
|
---|
11093 | UCHAR ReturnCode;
|
---|
11094 | UCHAR ReturnFlags;
|
---|
11095 | UCHAR MajorRevision;
|
---|
11096 | UCHAR MinorRevision;
|
---|
11097 | USHORT Checksum;
|
---|
11098 | UCHAR NumberFunctions;
|
---|
11099 | UCHAR FunctionInformation;
|
---|
11100 | ULONG CompressedId;
|
---|
11101 | } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
|
---|
11102 |
|
---|
11103 |
|
---|
11104 | //
|
---|
11105 | // Eisa function information definition
|
---|
11106 | //
|
---|
11107 |
|
---|
11108 | typedef struct _CM_EISA_FUNCTION_INFORMATION {
|
---|
11109 | ULONG CompressedId;
|
---|
11110 | UCHAR IdSlotFlags1;
|
---|
11111 | UCHAR IdSlotFlags2;
|
---|
11112 | UCHAR MinorRevision;
|
---|
11113 | UCHAR MajorRevision;
|
---|
11114 | UCHAR Selections[26];
|
---|
11115 | UCHAR FunctionFlags;
|
---|
11116 | UCHAR TypeString[80];
|
---|
11117 | EISA_MEMORY_CONFIGURATION EisaMemory[9];
|
---|
11118 | EISA_IRQ_CONFIGURATION EisaIrq[7];
|
---|
11119 | EISA_DMA_CONFIGURATION EisaDma[4];
|
---|
11120 | EISA_PORT_CONFIGURATION EisaPort[20];
|
---|
11121 | UCHAR InitializationData[60];
|
---|
11122 | } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
|
---|
11123 |
|
---|
11124 | //
|
---|
11125 | // The following defines the way pnp bios information is stored in
|
---|
11126 | // the registry \\HKEY_LOCAL_MACHINE\HARDWARE\Description\System\MultifunctionAdapter\x
|
---|
11127 | // key, where x is an integer number indicating adapter instance. The
|
---|
11128 | // "Identifier" of the key must equal to "PNP BIOS" and the
|
---|
11129 | // "ConfigurationData" is organized as follow:
|
---|
11130 | //
|
---|
11131 | // CM_PNP_BIOS_INSTALLATION_CHECK +
|
---|
11132 | // CM_PNP_BIOS_DEVICE_NODE for device 1 +
|
---|
11133 | // CM_PNP_BIOS_DEVICE_NODE for device 2 +
|
---|
11134 | // ...
|
---|
11135 | // CM_PNP_BIOS_DEVICE_NODE for device n
|
---|
11136 | //
|
---|
11137 |
|
---|
11138 | //
|
---|
11139 | // Pnp BIOS device node structure
|
---|
11140 | //
|
---|
11141 |
|
---|
11142 | typedef struct _CM_PNP_BIOS_DEVICE_NODE {
|
---|
11143 | USHORT Size;
|
---|
11144 | UCHAR Node;
|
---|
11145 | ULONG ProductId;
|
---|
11146 | UCHAR DeviceType[3];
|
---|
11147 | USHORT DeviceAttributes;
|
---|
11148 | // followed by AllocatedResourceBlock, PossibleResourceBlock
|
---|
11149 | // and CompatibleDeviceId
|
---|
11150 | } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
|
---|
11151 |
|
---|
11152 | //
|
---|
11153 | // Pnp BIOS Installation check
|
---|
11154 | //
|
---|
11155 |
|
---|
11156 | typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
|
---|
11157 | UCHAR Signature[4]; // $PnP (ascii)
|
---|
11158 | UCHAR Revision;
|
---|
11159 | UCHAR Length;
|
---|
11160 | USHORT ControlField;
|
---|
11161 | UCHAR Checksum;
|
---|
11162 | ULONG EventFlagAddress; // Physical address
|
---|
11163 | USHORT RealModeEntryOffset;
|
---|
11164 | USHORT RealModeEntrySegment;
|
---|
11165 | USHORT ProtectedModeEntryOffset;
|
---|
11166 | ULONG ProtectedModeCodeBaseAddress;
|
---|
11167 | ULONG OemDeviceId;
|
---|
11168 | USHORT RealModeDataBaseAddress;
|
---|
11169 | ULONG ProtectedModeDataBaseAddress;
|
---|
11170 | } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
|
---|
11171 |
|
---|
11172 | #include "poppack.h"
|
---|
11173 |
|
---|
11174 | //
|
---|
11175 | // Masks for EISA function information
|
---|
11176 | //
|
---|
11177 |
|
---|
11178 | #define EISA_FUNCTION_ENABLED 0x80
|
---|
11179 | #define EISA_FREE_FORM_DATA 0x40
|
---|
11180 | #define EISA_HAS_PORT_INIT_ENTRY 0x20
|
---|
11181 | #define EISA_HAS_PORT_RANGE 0x10
|
---|
11182 | #define EISA_HAS_DMA_ENTRY 0x08
|
---|
11183 | #define EISA_HAS_IRQ_ENTRY 0x04
|
---|
11184 | #define EISA_HAS_MEMORY_ENTRY 0x02
|
---|
11185 | #define EISA_HAS_TYPE_ENTRY 0x01
|
---|
11186 | #define EISA_HAS_INFORMATION EISA_HAS_PORT_RANGE + \
|
---|
11187 | EISA_HAS_DMA_ENTRY + \
|
---|
11188 | EISA_HAS_IRQ_ENTRY + \
|
---|
11189 | EISA_HAS_MEMORY_ENTRY + \
|
---|
11190 | EISA_HAS_TYPE_ENTRY
|
---|
11191 |
|
---|
11192 | //
|
---|
11193 | // Masks for EISA memory configuration
|
---|
11194 | //
|
---|
11195 |
|
---|
11196 | #define EISA_MORE_ENTRIES 0x80
|
---|
11197 | #define EISA_SYSTEM_MEMORY 0x00
|
---|
11198 | #define EISA_MEMORY_TYPE_RAM 0x01
|
---|
11199 |
|
---|
11200 | //
|
---|
11201 | // Returned error code for EISA bios call
|
---|
11202 | //
|
---|
11203 |
|
---|
11204 | #define EISA_INVALID_SLOT 0x80
|
---|
11205 | #define EISA_INVALID_FUNCTION 0x81
|
---|
11206 | #define EISA_INVALID_CONFIGURATION 0x82
|
---|
11207 | #define EISA_EMPTY_SLOT 0x83
|
---|
11208 | #define EISA_INVALID_BIOS_CALL 0x86
|
---|
11209 |
|
---|
11210 |
|
---|
11211 |
|
---|
11212 | //
|
---|
11213 | // The following structures are used to interpret mips
|
---|
11214 | // DeviceSpecificData of CM_PARTIAL_RESOURCE_DESCRIPTOR.
|
---|
11215 | //
|
---|
11216 |
|
---|
11217 | //
|
---|
11218 | // Device data records for adapters.
|
---|
11219 | //
|
---|
11220 |
|
---|
11221 | //
|
---|
11222 | // The device data record for the Emulex SCSI controller.
|
---|
11223 | //
|
---|
11224 |
|
---|
11225 | typedef struct _CM_SCSI_DEVICE_DATA {
|
---|
11226 | USHORT Version;
|
---|
11227 | USHORT Revision;
|
---|
11228 | UCHAR HostIdentifier;
|
---|
11229 | } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
|
---|
11230 |
|
---|
11231 | //
|
---|
11232 | // Device data records for controllers.
|
---|
11233 | //
|
---|
11234 |
|
---|
11235 | //
|
---|
11236 | // The device data record for the Video controller.
|
---|
11237 | //
|
---|
11238 |
|
---|
11239 | typedef struct _CM_VIDEO_DEVICE_DATA {
|
---|
11240 | USHORT Version;
|
---|
11241 | USHORT Revision;
|
---|
11242 | ULONG VideoClock;
|
---|
11243 | } CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA;
|
---|
11244 |
|
---|
11245 | //
|
---|
11246 | // The device data record for the SONIC network controller.
|
---|
11247 | //
|
---|
11248 |
|
---|
11249 | typedef struct _CM_SONIC_DEVICE_DATA {
|
---|
11250 | USHORT Version;
|
---|
11251 | USHORT Revision;
|
---|
11252 | USHORT DataConfigurationRegister;
|
---|
11253 | UCHAR EthernetAddress[8];
|
---|
11254 | } CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA;
|
---|
11255 |
|
---|
11256 | //
|
---|
11257 | // The device data record for the serial controller.
|
---|
11258 | //
|
---|
11259 |
|
---|
11260 | typedef struct _CM_SERIAL_DEVICE_DATA {
|
---|
11261 | USHORT Version;
|
---|
11262 | USHORT Revision;
|
---|
11263 | ULONG BaudClock;
|
---|
11264 | } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
|
---|
11265 |
|
---|
11266 | //
|
---|
11267 | // Device data records for peripherals.
|
---|
11268 | //
|
---|
11269 |
|
---|
11270 | //
|
---|
11271 | // The device data record for the Monitor peripheral.
|
---|
11272 | //
|
---|
11273 |
|
---|
11274 | typedef struct _CM_MONITOR_DEVICE_DATA {
|
---|
11275 | USHORT Version;
|
---|
11276 | USHORT Revision;
|
---|
11277 | USHORT HorizontalScreenSize;
|
---|
11278 | USHORT VerticalScreenSize;
|
---|
11279 | USHORT HorizontalResolution;
|
---|
11280 | USHORT VerticalResolution;
|
---|
11281 | USHORT HorizontalDisplayTimeLow;
|
---|
11282 | USHORT HorizontalDisplayTime;
|
---|
11283 | USHORT HorizontalDisplayTimeHigh;
|
---|
11284 | USHORT HorizontalBackPorchLow;
|
---|
11285 | USHORT HorizontalBackPorch;
|
---|
11286 | USHORT HorizontalBackPorchHigh;
|
---|
11287 | USHORT HorizontalFrontPorchLow;
|
---|
11288 | USHORT HorizontalFrontPorch;
|
---|
11289 | USHORT HorizontalFrontPorchHigh;
|
---|
11290 | USHORT HorizontalSyncLow;
|
---|
11291 | USHORT HorizontalSync;
|
---|
11292 | USHORT HorizontalSyncHigh;
|
---|
11293 | USHORT VerticalBackPorchLow;
|
---|
11294 | USHORT VerticalBackPorch;
|
---|
11295 | USHORT VerticalBackPorchHigh;
|
---|
11296 | USHORT VerticalFrontPorchLow;
|
---|
11297 | USHORT VerticalFrontPorch;
|
---|
11298 | USHORT VerticalFrontPorchHigh;
|
---|
11299 | USHORT VerticalSyncLow;
|
---|
11300 | USHORT VerticalSync;
|
---|
11301 | USHORT VerticalSyncHigh;
|
---|
11302 | } CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA;
|
---|
11303 |
|
---|
11304 | //
|
---|
11305 | // The device data record for the Floppy peripheral.
|
---|
11306 | //
|
---|
11307 |
|
---|
11308 | typedef struct _CM_FLOPPY_DEVICE_DATA {
|
---|
11309 | USHORT Version;
|
---|
11310 | USHORT Revision;
|
---|
11311 | CHAR Size[8];
|
---|
11312 | ULONG MaxDensity;
|
---|
11313 | ULONG MountDensity;
|
---|
11314 | //
|
---|
11315 | // New data fields for version >= 2.0
|
---|
11316 | //
|
---|
11317 | UCHAR StepRateHeadUnloadTime;
|
---|
11318 | UCHAR HeadLoadTime;
|
---|
11319 | UCHAR MotorOffTime;
|
---|
11320 | UCHAR SectorLengthCode;
|
---|
11321 | UCHAR SectorPerTrack;
|
---|
11322 | UCHAR ReadWriteGapLength;
|
---|
11323 | UCHAR DataTransferLength;
|
---|
11324 | UCHAR FormatGapLength;
|
---|
11325 | UCHAR FormatFillCharacter;
|
---|
11326 | UCHAR HeadSettleTime;
|
---|
11327 | UCHAR MotorSettleTime;
|
---|
11328 | UCHAR MaximumTrackValue;
|
---|
11329 | UCHAR DataTransferRate;
|
---|
11330 | } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
|
---|
11331 |
|
---|
11332 | //
|
---|
11333 | // The device data record for the Keyboard peripheral.
|
---|
11334 | // The KeyboardFlags is defined (by x86 BIOS INT 16h, function 02) as:
|
---|
11335 | // bit 7 : Insert on
|
---|
11336 | // bit 6 : Caps Lock on
|
---|
11337 | // bit 5 : Num Lock on
|
---|
11338 | // bit 4 : Scroll Lock on
|
---|
11339 | // bit 3 : Alt Key is down
|
---|
11340 | // bit 2 : Ctrl Key is down
|
---|
11341 | // bit 1 : Left shift key is down
|
---|
11342 | // bit 0 : Right shift key is down
|
---|
11343 | //
|
---|
11344 |
|
---|
11345 | typedef struct _CM_KEYBOARD_DEVICE_DATA {
|
---|
11346 | USHORT Version;
|
---|
11347 | USHORT Revision;
|
---|
11348 | UCHAR Type;
|
---|
11349 | UCHAR Subtype;
|
---|
11350 | USHORT KeyboardFlags;
|
---|
11351 | } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
|
---|
11352 |
|
---|
11353 | //
|
---|
11354 | // Declaration of the structure for disk geometries
|
---|
11355 | //
|
---|
11356 |
|
---|
11357 | typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
|
---|
11358 | ULONG BytesPerSector;
|
---|
11359 | ULONG NumberOfCylinders;
|
---|
11360 | ULONG SectorsPerTrack;
|
---|
11361 | ULONG NumberOfHeads;
|
---|
11362 | } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
|
---|
11363 |
|
---|
11364 |
|
---|
11365 | //
|
---|
11366 | // Declaration of the structure for the PcCard ISA IRQ map
|
---|
11367 | //
|
---|
11368 |
|
---|
11369 | typedef struct _CM_PCCARD_DEVICE_DATA {
|
---|
11370 | UCHAR Flags;
|
---|
11371 | UCHAR ErrorCode;
|
---|
11372 | USHORT Reserved;
|
---|
11373 | ULONG BusData;
|
---|
11374 | ULONG DeviceId;
|
---|
11375 | ULONG LegacyBaseAddress;
|
---|
11376 | UCHAR IRQMap[16];
|
---|
11377 | } CM_PCCARD_DEVICE_DATA, *PCM_PCCARD_DEVICE_DATA;
|
---|
11378 |
|
---|
11379 | // Definitions for Flags
|
---|
11380 |
|
---|
11381 | #define PCCARD_MAP_ERROR 0x01
|
---|
11382 | #define PCCARD_DEVICE_PCI 0x10
|
---|
11383 |
|
---|
11384 | #define PCCARD_SCAN_DISABLED 0x01
|
---|
11385 | #define PCCARD_MAP_ZERO 0x02
|
---|
11386 | #define PCCARD_NO_TIMER 0x03
|
---|
11387 | #define PCCARD_NO_PIC 0x04
|
---|
11388 | #define PCCARD_NO_LEGACY_BASE 0x05
|
---|
11389 | #define PCCARD_DUP_LEGACY_BASE 0x06
|
---|
11390 | #define PCCARD_NO_CONTROLLERS 0x07
|
---|
11391 |
|
---|
11392 |
|
---|
11393 |
|
---|
11394 |
|
---|
11395 | //
|
---|
11396 | // Defines Resource Options
|
---|
11397 | //
|
---|
11398 |
|
---|
11399 | #define IO_RESOURCE_PREFERRED 0x01
|
---|
11400 | #define IO_RESOURCE_DEFAULT 0x02
|
---|
11401 | #define IO_RESOURCE_ALTERNATIVE 0x08
|
---|
11402 |
|
---|
11403 |
|
---|
11404 | //
|
---|
11405 | // This structure defines one type of resource requested by the driver
|
---|
11406 | //
|
---|
11407 |
|
---|
11408 | typedef struct _IO_RESOURCE_DESCRIPTOR {
|
---|
11409 | UCHAR Option;
|
---|
11410 | UCHAR Type; // use CM_RESOURCE_TYPE
|
---|
11411 | UCHAR ShareDisposition; // use CM_SHARE_DISPOSITION
|
---|
11412 | UCHAR Spare1;
|
---|
11413 | USHORT Flags; // use CM resource flag defines
|
---|
11414 | USHORT Spare2; // align
|
---|
11415 |
|
---|
11416 | union {
|
---|
11417 | struct {
|
---|
11418 | ULONG Length;
|
---|
11419 | ULONG Alignment;
|
---|
11420 | PHYSICAL_ADDRESS MinimumAddress;
|
---|
11421 | PHYSICAL_ADDRESS MaximumAddress;
|
---|
11422 | } Port;
|
---|
11423 |
|
---|
11424 | struct {
|
---|
11425 | ULONG Length;
|
---|
11426 | ULONG Alignment;
|
---|
11427 | PHYSICAL_ADDRESS MinimumAddress;
|
---|
11428 | PHYSICAL_ADDRESS MaximumAddress;
|
---|
11429 | } Memory;
|
---|
11430 |
|
---|
11431 | struct {
|
---|
11432 | ULONG MinimumVector;
|
---|
11433 | ULONG MaximumVector;
|
---|
11434 | } Interrupt;
|
---|
11435 |
|
---|
11436 | struct {
|
---|
11437 | ULONG MinimumChannel;
|
---|
11438 | ULONG MaximumChannel;
|
---|
11439 | } Dma;
|
---|
11440 |
|
---|
11441 | struct {
|
---|
11442 | ULONG Length;
|
---|
11443 | ULONG Alignment;
|
---|
11444 | PHYSICAL_ADDRESS MinimumAddress;
|
---|
11445 | PHYSICAL_ADDRESS MaximumAddress;
|
---|
11446 | } Generic;
|
---|
11447 |
|
---|
11448 | struct {
|
---|
11449 | ULONG Data[3];
|
---|
11450 | } DevicePrivate;
|
---|
11451 |
|
---|
11452 | //
|
---|
11453 | // Bus Number information.
|
---|
11454 | //
|
---|
11455 |
|
---|
11456 | struct {
|
---|
11457 | ULONG Length;
|
---|
11458 | ULONG MinBusNumber;
|
---|
11459 | ULONG MaxBusNumber;
|
---|
11460 | ULONG Reserved;
|
---|
11461 | } BusNumber;
|
---|
11462 |
|
---|
11463 | struct {
|
---|
11464 | ULONG Priority; // use LCPRI_Xxx values in cfg.h
|
---|
11465 | ULONG Reserved1;
|
---|
11466 | ULONG Reserved2;
|
---|
11467 | } ConfigData;
|
---|
11468 |
|
---|
11469 | } u;
|
---|
11470 |
|
---|
11471 | } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
|
---|
11472 |
|
---|
11473 |
|
---|
11474 |
|
---|
11475 |
|
---|
11476 | typedef struct _IO_RESOURCE_LIST {
|
---|
11477 | USHORT Version;
|
---|
11478 | USHORT Revision;
|
---|
11479 |
|
---|
11480 | ULONG Count;
|
---|
11481 | IO_RESOURCE_DESCRIPTOR Descriptors[1];
|
---|
11482 | } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
|
---|
11483 |
|
---|
11484 |
|
---|
11485 | typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
|
---|
11486 | ULONG ListSize;
|
---|
11487 | INTERFACE_TYPE InterfaceType; // unused for WDM
|
---|
11488 | ULONG BusNumber; // unused for WDM
|
---|
11489 | ULONG SlotNumber;
|
---|
11490 | ULONG Reserved[3];
|
---|
11491 | ULONG AlternativeLists;
|
---|
11492 | IO_RESOURCE_LIST List[1];
|
---|
11493 | } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
|
---|
11494 |
|
---|
11495 | //
|
---|
11496 | // Exception flag definitions.
|
---|
11497 | //
|
---|
11498 |
|
---|
11499 |
|
---|
11500 | #define EXCEPTION_NONCONTINUABLE 0x1 // Noncontinuable exception
|
---|
11501 |
|
---|
11502 |
|
---|
11503 | //
|
---|
11504 | // Define maximum number of exception parameters.
|
---|
11505 | //
|
---|
11506 |
|
---|
11507 |
|
---|
11508 | #define EXCEPTION_MAXIMUM_PARAMETERS 15 // maximum number of exception parameters
|
---|
11509 |
|
---|
11510 | //
|
---|
11511 | // Exception record definition.
|
---|
11512 | //
|
---|
11513 |
|
---|
11514 | typedef struct _EXCEPTION_RECORD {
|
---|
11515 | NTSTATUS ExceptionCode;
|
---|
11516 | ULONG ExceptionFlags;
|
---|
11517 | struct _EXCEPTION_RECORD *ExceptionRecord;
|
---|
11518 | PVOID ExceptionAddress;
|
---|
11519 | ULONG NumberParameters;
|
---|
11520 | ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
|
---|
11521 | } EXCEPTION_RECORD;
|
---|
11522 |
|
---|
11523 | typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
|
---|
11524 |
|
---|
11525 | typedef struct _EXCEPTION_RECORD32 {
|
---|
11526 | NTSTATUS ExceptionCode;
|
---|
11527 | ULONG ExceptionFlags;
|
---|
11528 | ULONG ExceptionRecord;
|
---|
11529 | ULONG ExceptionAddress;
|
---|
11530 | ULONG NumberParameters;
|
---|
11531 | ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
|
---|
11532 | } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
|
---|
11533 |
|
---|
11534 | typedef struct _EXCEPTION_RECORD64 {
|
---|
11535 | NTSTATUS ExceptionCode;
|
---|
11536 | ULONG ExceptionFlags;
|
---|
11537 | ULONG64 ExceptionRecord;
|
---|
11538 | ULONG64 ExceptionAddress;
|
---|
11539 | ULONG NumberParameters;
|
---|
11540 | ULONG __unusedAlignment;
|
---|
11541 | ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
|
---|
11542 | } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
|
---|
11543 |
|
---|
11544 | //
|
---|
11545 | // Typedef for pointer returned by exception_info()
|
---|
11546 | //
|
---|
11547 |
|
---|
11548 | typedef struct _EXCEPTION_POINTERS {
|
---|
11549 | PEXCEPTION_RECORD ExceptionRecord;
|
---|
11550 | PCONTEXT ContextRecord;
|
---|
11551 | } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
|
---|
11552 |
|
---|
11553 |
|
---|
11554 | //
|
---|
11555 | // Define configuration routine types.
|
---|
11556 | //
|
---|
11557 | // Configuration information.
|
---|
11558 | //
|
---|
11559 |
|
---|
11560 | typedef enum _CONFIGURATION_TYPE {
|
---|
11561 | ArcSystem,
|
---|
11562 | CentralProcessor,
|
---|
11563 | FloatingPointProcessor,
|
---|
11564 | PrimaryIcache,
|
---|
11565 | PrimaryDcache,
|
---|
11566 | SecondaryIcache,
|
---|
11567 | SecondaryDcache,
|
---|
11568 | SecondaryCache,
|
---|
11569 | EisaAdapter,
|
---|
11570 | TcAdapter,
|
---|
11571 | ScsiAdapter,
|
---|
11572 | DtiAdapter,
|
---|
11573 | MultiFunctionAdapter,
|
---|
11574 | DiskController,
|
---|
11575 | TapeController,
|
---|
11576 | CdromController,
|
---|
11577 | WormController,
|
---|
11578 | SerialController,
|
---|
11579 | NetworkController,
|
---|
11580 | DisplayController,
|
---|
11581 | ParallelController,
|
---|
11582 | PointerController,
|
---|
11583 | KeyboardController,
|
---|
11584 | AudioController,
|
---|
11585 | OtherController,
|
---|
11586 | DiskPeripheral,
|
---|
11587 | FloppyDiskPeripheral,
|
---|
11588 | TapePeripheral,
|
---|
11589 | ModemPeripheral,
|
---|
11590 | MonitorPeripheral,
|
---|
11591 | PrinterPeripheral,
|
---|
11592 | PointerPeripheral,
|
---|
11593 | KeyboardPeripheral,
|
---|
11594 | TerminalPeripheral,
|
---|
11595 | OtherPeripheral,
|
---|
11596 | LinePeripheral,
|
---|
11597 | NetworkPeripheral,
|
---|
11598 | SystemMemory,
|
---|
11599 | DockingInformation,
|
---|
11600 | RealModeIrqRoutingTable,
|
---|
11601 | RealModePCIEnumeration,
|
---|
11602 | MaximumType
|
---|
11603 | } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
|
---|
11604 |
|
---|
11605 |
|
---|
11606 | #define THREAD_WAIT_OBJECTS 3 // Builtin usable wait blocks
|
---|
11607 |
|
---|
11608 | //
|
---|
11609 |
|
---|
11610 | #if defined(_X86_)
|
---|
11611 |
|
---|
11612 | #define PAUSE_PROCESSOR _asm { rep nop }
|
---|
11613 |
|
---|
11614 | #else
|
---|
11615 |
|
---|
11616 | #define PAUSE_PROCESSOR
|
---|
11617 |
|
---|
11618 | #endif
|
---|
11619 |
|
---|
11620 |
|
---|
11621 | //
|
---|
11622 | // Interrupt modes.
|
---|
11623 | //
|
---|
11624 |
|
---|
11625 | typedef enum _KINTERRUPT_MODE {
|
---|
11626 | LevelSensitive,
|
---|
11627 | Latched
|
---|
11628 | } KINTERRUPT_MODE;
|
---|
11629 |
|
---|
11630 | //
|
---|
11631 | // Wait reasons
|
---|
11632 | //
|
---|
11633 |
|
---|
11634 | typedef enum _KWAIT_REASON {
|
---|
11635 | Executive,
|
---|
11636 | FreePage,
|
---|
11637 | PageIn,
|
---|
11638 | PoolAllocation,
|
---|
11639 | DelayExecution,
|
---|
11640 | Suspended,
|
---|
11641 | UserRequest,
|
---|
11642 | WrExecutive,
|
---|
11643 | WrFreePage,
|
---|
11644 | WrPageIn,
|
---|
11645 | WrPoolAllocation,
|
---|
11646 | WrDelayExecution,
|
---|
11647 | WrSuspended,
|
---|
11648 | WrUserRequest,
|
---|
11649 | WrEventPair,
|
---|
11650 | WrQueue,
|
---|
11651 | WrLpcReceive,
|
---|
11652 | WrLpcReply,
|
---|
11653 | WrVirtualMemory,
|
---|
11654 | WrPageOut,
|
---|
11655 | WrRendezvous,
|
---|
11656 | Spare2,
|
---|
11657 | Spare3,
|
---|
11658 | Spare4,
|
---|
11659 | Spare5,
|
---|
11660 | Spare6,
|
---|
11661 | WrKernel,
|
---|
11662 | WrResource,
|
---|
11663 | WrPushLock,
|
---|
11664 | WrMutex,
|
---|
11665 | WrQuantumEnd,
|
---|
11666 | WrDispatchInt,
|
---|
11667 | WrPreempted,
|
---|
11668 | WrYieldExecution,
|
---|
11669 | MaximumWaitReason
|
---|
11670 | } KWAIT_REASON;
|
---|
11671 |
|
---|
11672 |
|
---|
11673 | typedef struct _KWAIT_BLOCK {
|
---|
11674 | LIST_ENTRY WaitListEntry;
|
---|
11675 | struct _KTHREAD *RESTRICTED_POINTER Thread;
|
---|
11676 | PVOID Object;
|
---|
11677 | struct _KWAIT_BLOCK *RESTRICTED_POINTER NextWaitBlock;
|
---|
11678 | USHORT WaitKey;
|
---|
11679 | USHORT WaitType;
|
---|
11680 | } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
|
---|
11681 |
|
---|
11682 | //
|
---|
11683 | // Thread start function
|
---|
11684 | //
|
---|
11685 |
|
---|
11686 | typedef
|
---|
11687 | VOID
|
---|
11688 | (*PKSTART_ROUTINE) (
|
---|
11689 | IN PVOID StartContext
|
---|
11690 | );
|
---|
11691 |
|
---|
11692 | //
|
---|
11693 | // Kernel object structure definitions
|
---|
11694 | //
|
---|
11695 |
|
---|
11696 | //
|
---|
11697 | // Device Queue object and entry
|
---|
11698 | //
|
---|
11699 |
|
---|
11700 | typedef struct _KDEVICE_QUEUE {
|
---|
11701 | CSHORT Type;
|
---|
11702 | CSHORT Size;
|
---|
11703 | LIST_ENTRY DeviceListHead;
|
---|
11704 | KSPIN_LOCK Lock;
|
---|
11705 | BOOLEAN Busy;
|
---|
11706 | } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
|
---|
11707 |
|
---|
11708 | typedef struct _KDEVICE_QUEUE_ENTRY {
|
---|
11709 | LIST_ENTRY DeviceListEntry;
|
---|
11710 | ULONG SortKey;
|
---|
11711 | BOOLEAN Inserted;
|
---|
11712 | } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
|
---|
11713 |
|
---|
11714 | //
|
---|
11715 | // Define the interrupt service function type and the empty struct
|
---|
11716 | // type.
|
---|
11717 | //
|
---|
11718 |
|
---|
11719 | typedef
|
---|
11720 | BOOLEAN
|
---|
11721 | (*PKSERVICE_ROUTINE) (
|
---|
11722 | IN struct _KINTERRUPT *Interrupt,
|
---|
11723 | IN PVOID ServiceContext
|
---|
11724 | );
|
---|
11725 |
|
---|
11726 | //
|
---|
11727 | // Mutant object
|
---|
11728 | //
|
---|
11729 |
|
---|
11730 | typedef struct _KMUTANT {
|
---|
11731 | DISPATCHER_HEADER Header;
|
---|
11732 | LIST_ENTRY MutantListEntry;
|
---|
11733 | struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
|
---|
11734 | BOOLEAN Abandoned;
|
---|
11735 | UCHAR ApcDisable;
|
---|
11736 | } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
|
---|
11737 |
|
---|
11738 | //
|
---|
11739 | //
|
---|
11740 | // Semaphore object
|
---|
11741 | //
|
---|
11742 |
|
---|
11743 | typedef struct _KSEMAPHORE {
|
---|
11744 | DISPATCHER_HEADER Header;
|
---|
11745 | LONG Limit;
|
---|
11746 | } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
|
---|
11747 |
|
---|
11748 | //
|
---|
11749 | // DPC object
|
---|
11750 | //
|
---|
11751 |
|
---|
11752 | NTKERNELAPI
|
---|
11753 | VOID
|
---|
11754 | KeInitializeDpc (
|
---|
11755 | IN PRKDPC Dpc,
|
---|
11756 | IN PKDEFERRED_ROUTINE DeferredRoutine,
|
---|
11757 | IN PVOID DeferredContext
|
---|
11758 | );
|
---|
11759 |
|
---|
11760 |
|
---|
11761 | NTKERNELAPI
|
---|
11762 | BOOLEAN
|
---|
11763 | KeInsertQueueDpc (
|
---|
11764 | IN PRKDPC Dpc,
|
---|
11765 | IN PVOID SystemArgument1,
|
---|
11766 | IN PVOID SystemArgument2
|
---|
11767 | );
|
---|
11768 |
|
---|
11769 | NTKERNELAPI
|
---|
11770 | BOOLEAN
|
---|
11771 | KeRemoveQueueDpc (
|
---|
11772 | IN PRKDPC Dpc
|
---|
11773 | );
|
---|
11774 |
|
---|
11775 |
|
---|
11776 |
|
---|
11777 | NTKERNELAPI
|
---|
11778 | VOID
|
---|
11779 | KeSetImportanceDpc (
|
---|
11780 | IN PRKDPC Dpc,
|
---|
11781 | IN KDPC_IMPORTANCE Importance
|
---|
11782 | );
|
---|
11783 |
|
---|
11784 | NTKERNELAPI
|
---|
11785 | VOID
|
---|
11786 | KeSetTargetProcessorDpc (
|
---|
11787 | IN PRKDPC Dpc,
|
---|
11788 | IN CCHAR Number
|
---|
11789 | );
|
---|
11790 |
|
---|
11791 |
|
---|
11792 |
|
---|
11793 | NTKERNELAPI
|
---|
11794 | VOID
|
---|
11795 | KeFlushQueuedDpcs (
|
---|
11796 | VOID
|
---|
11797 | );
|
---|
11798 |
|
---|
11799 | //
|
---|
11800 | // Device queue object
|
---|
11801 | //
|
---|
11802 |
|
---|
11803 | NTKERNELAPI
|
---|
11804 | VOID
|
---|
11805 | KeInitializeDeviceQueue (
|
---|
11806 | IN PKDEVICE_QUEUE DeviceQueue
|
---|
11807 | );
|
---|
11808 |
|
---|
11809 | NTKERNELAPI
|
---|
11810 | BOOLEAN
|
---|
11811 | KeInsertDeviceQueue (
|
---|
11812 | IN PKDEVICE_QUEUE DeviceQueue,
|
---|
11813 | IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
|
---|
11814 | );
|
---|
11815 |
|
---|
11816 | NTKERNELAPI
|
---|
11817 | BOOLEAN
|
---|
11818 | KeInsertByKeyDeviceQueue (
|
---|
11819 | IN PKDEVICE_QUEUE DeviceQueue,
|
---|
11820 | IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
|
---|
11821 | IN ULONG SortKey
|
---|
11822 | );
|
---|
11823 |
|
---|
11824 | NTKERNELAPI
|
---|
11825 | PKDEVICE_QUEUE_ENTRY
|
---|
11826 | KeRemoveDeviceQueue (
|
---|
11827 | IN PKDEVICE_QUEUE DeviceQueue
|
---|
11828 | );
|
---|
11829 |
|
---|
11830 | NTKERNELAPI
|
---|
11831 | PKDEVICE_QUEUE_ENTRY
|
---|
11832 | KeRemoveByKeyDeviceQueue (
|
---|
11833 | IN PKDEVICE_QUEUE DeviceQueue,
|
---|
11834 | IN ULONG SortKey
|
---|
11835 | );
|
---|
11836 |
|
---|
11837 | NTKERNELAPI
|
---|
11838 | PKDEVICE_QUEUE_ENTRY
|
---|
11839 | KeRemoveByKeyDeviceQueueIfBusy (
|
---|
11840 | IN PKDEVICE_QUEUE DeviceQueue,
|
---|
11841 | IN ULONG SortKey
|
---|
11842 | );
|
---|
11843 |
|
---|
11844 | NTKERNELAPI
|
---|
11845 | BOOLEAN
|
---|
11846 | KeRemoveEntryDeviceQueue (
|
---|
11847 | IN PKDEVICE_QUEUE DeviceQueue,
|
---|
11848 | IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
|
---|
11849 | );
|
---|
11850 |
|
---|
11851 |
|
---|
11852 | NTKERNELAPI
|
---|
11853 | BOOLEAN
|
---|
11854 | KeSynchronizeExecution (
|
---|
11855 | IN PKINTERRUPT Interrupt,
|
---|
11856 | IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
|
---|
11857 | IN PVOID SynchronizeContext
|
---|
11858 | );
|
---|
11859 |
|
---|
11860 | NTKERNELAPI
|
---|
11861 | KIRQL
|
---|
11862 | KeAcquireInterruptSpinLock (
|
---|
11863 | IN PKINTERRUPT Interrupt
|
---|
11864 | );
|
---|
11865 |
|
---|
11866 | NTKERNELAPI
|
---|
11867 | VOID
|
---|
11868 | KeReleaseInterruptSpinLock (
|
---|
11869 | IN PKINTERRUPT Interrupt,
|
---|
11870 | IN KIRQL OldIrql
|
---|
11871 | );
|
---|
11872 |
|
---|
11873 | //
|
---|
11874 | // Kernel dispatcher object functions
|
---|
11875 | //
|
---|
11876 | // Event Object
|
---|
11877 | //
|
---|
11878 |
|
---|
11879 |
|
---|
11880 | NTKERNELAPI
|
---|
11881 | VOID
|
---|
11882 | KeInitializeEvent (
|
---|
11883 | IN PRKEVENT Event,
|
---|
11884 | IN EVENT_TYPE Type,
|
---|
11885 | IN BOOLEAN State
|
---|
11886 | );
|
---|
11887 |
|
---|
11888 | NTKERNELAPI
|
---|
11889 | VOID
|
---|
11890 | KeClearEvent (
|
---|
11891 | IN PRKEVENT Event
|
---|
11892 | );
|
---|
11893 |
|
---|
11894 |
|
---|
11895 | NTKERNELAPI
|
---|
11896 | LONG
|
---|
11897 | KePulseEvent (
|
---|
11898 | IN PRKEVENT Event,
|
---|
11899 | IN KPRIORITY Increment,
|
---|
11900 | IN BOOLEAN Wait
|
---|
11901 | );
|
---|
11902 |
|
---|
11903 |
|
---|
11904 | NTKERNELAPI
|
---|
11905 | LONG
|
---|
11906 | KeReadStateEvent (
|
---|
11907 | IN PRKEVENT Event
|
---|
11908 | );
|
---|
11909 |
|
---|
11910 | NTKERNELAPI
|
---|
11911 | LONG
|
---|
11912 | KeResetEvent (
|
---|
11913 | IN PRKEVENT Event
|
---|
11914 | );
|
---|
11915 |
|
---|
11916 | NTKERNELAPI
|
---|
11917 | LONG
|
---|
11918 | KeSetEvent (
|
---|
11919 | IN PRKEVENT Event,
|
---|
11920 | IN KPRIORITY Increment,
|
---|
11921 | IN BOOLEAN Wait
|
---|
11922 | );
|
---|
11923 |
|
---|
11924 | //
|
---|
11925 | // Mutex object
|
---|
11926 | //
|
---|
11927 |
|
---|
11928 | NTKERNELAPI
|
---|
11929 | VOID
|
---|
11930 | KeInitializeMutex (
|
---|
11931 | IN PRKMUTEX Mutex,
|
---|
11932 | IN ULONG Level
|
---|
11933 | );
|
---|
11934 |
|
---|
11935 | NTKERNELAPI
|
---|
11936 | LONG
|
---|
11937 | KeReadStateMutex (
|
---|
11938 | IN PRKMUTEX Mutex
|
---|
11939 | );
|
---|
11940 |
|
---|
11941 | NTKERNELAPI
|
---|
11942 | LONG
|
---|
11943 | KeReleaseMutex (
|
---|
11944 | IN PRKMUTEX Mutex,
|
---|
11945 | IN BOOLEAN Wait
|
---|
11946 | );
|
---|
11947 |
|
---|
11948 | //
|
---|
11949 | // Semaphore object
|
---|
11950 | //
|
---|
11951 |
|
---|
11952 | NTKERNELAPI
|
---|
11953 | VOID
|
---|
11954 | KeInitializeSemaphore (
|
---|
11955 | IN PRKSEMAPHORE Semaphore,
|
---|
11956 | IN LONG Count,
|
---|
11957 | IN LONG Limit
|
---|
11958 | );
|
---|
11959 |
|
---|
11960 | NTKERNELAPI
|
---|
11961 | LONG
|
---|
11962 | KeReadStateSemaphore (
|
---|
11963 | IN PRKSEMAPHORE Semaphore
|
---|
11964 | );
|
---|
11965 |
|
---|
11966 | NTKERNELAPI
|
---|
11967 | LONG
|
---|
11968 | KeReleaseSemaphore (
|
---|
11969 | IN PRKSEMAPHORE Semaphore,
|
---|
11970 | IN KPRIORITY Increment,
|
---|
11971 | IN LONG Adjustment,
|
---|
11972 | IN BOOLEAN Wait
|
---|
11973 | );
|
---|
11974 |
|
---|
11975 | NTKERNELAPI
|
---|
11976 | NTSTATUS
|
---|
11977 | KeDelayExecutionThread (
|
---|
11978 | IN KPROCESSOR_MODE WaitMode,
|
---|
11979 | IN BOOLEAN Alertable,
|
---|
11980 | IN PLARGE_INTEGER Interval
|
---|
11981 | );
|
---|
11982 |
|
---|
11983 | NTKERNELAPI
|
---|
11984 | KPRIORITY
|
---|
11985 | KeQueryPriorityThread (
|
---|
11986 | IN PKTHREAD Thread
|
---|
11987 | );
|
---|
11988 |
|
---|
11989 | NTKERNELAPI
|
---|
11990 | ULONG
|
---|
11991 | KeQueryRuntimeThread (
|
---|
11992 | IN PKTHREAD Thread,
|
---|
11993 | OUT PULONG UserTime
|
---|
11994 | );
|
---|
11995 |
|
---|
11996 | NTKERNELAPI
|
---|
11997 | LONG
|
---|
11998 | KeSetBasePriorityThread (
|
---|
11999 | IN PKTHREAD Thread,
|
---|
12000 | IN LONG Increment
|
---|
12001 | );
|
---|
12002 |
|
---|
12003 | NTKERNELAPI
|
---|
12004 | KPRIORITY
|
---|
12005 | KeSetPriorityThread (
|
---|
12006 | IN PKTHREAD Thread,
|
---|
12007 | IN KPRIORITY Priority
|
---|
12008 | );
|
---|
12009 |
|
---|
12010 |
|
---|
12011 | #if ((defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) ||defined(_NTHAL_)) && !defined(_NTSYSTEM_DRIVER_) || defined(_NTOSP_))
|
---|
12012 |
|
---|
12013 |
|
---|
12014 |
|
---|
12015 | NTKERNELAPI
|
---|
12016 | VOID
|
---|
12017 | KeEnterCriticalRegion (
|
---|
12018 | VOID
|
---|
12019 | );
|
---|
12020 |
|
---|
12021 | NTKERNELAPI
|
---|
12022 | VOID
|
---|
12023 | KeLeaveCriticalRegion (
|
---|
12024 | VOID
|
---|
12025 | );
|
---|
12026 |
|
---|
12027 | NTKERNELAPI
|
---|
12028 | BOOLEAN
|
---|
12029 | KeAreApcsDisabled (
|
---|
12030 | VOID
|
---|
12031 | );
|
---|
12032 |
|
---|
12033 |
|
---|
12034 |
|
---|
12035 | #endif
|
---|
12036 |
|
---|
12037 |
|
---|
12038 |
|
---|
12039 | //
|
---|
12040 | // Timer object
|
---|
12041 | //
|
---|
12042 |
|
---|
12043 | NTKERNELAPI
|
---|
12044 | VOID
|
---|
12045 | KeInitializeTimer (
|
---|
12046 | IN PKTIMER Timer
|
---|
12047 | );
|
---|
12048 |
|
---|
12049 | NTKERNELAPI
|
---|
12050 | VOID
|
---|
12051 | KeInitializeTimerEx (
|
---|
12052 | IN PKTIMER Timer,
|
---|
12053 | IN TIMER_TYPE Type
|
---|
12054 | );
|
---|
12055 |
|
---|
12056 | NTKERNELAPI
|
---|
12057 | BOOLEAN
|
---|
12058 | KeCancelTimer (
|
---|
12059 | IN PKTIMER
|
---|
12060 | );
|
---|
12061 |
|
---|
12062 | NTKERNELAPI
|
---|
12063 | BOOLEAN
|
---|
12064 | KeReadStateTimer (
|
---|
12065 | PKTIMER Timer
|
---|
12066 | );
|
---|
12067 |
|
---|
12068 | NTKERNELAPI
|
---|
12069 | BOOLEAN
|
---|
12070 | KeSetTimer (
|
---|
12071 | IN PKTIMER Timer,
|
---|
12072 | IN LARGE_INTEGER DueTime,
|
---|
12073 | IN PKDPC Dpc OPTIONAL
|
---|
12074 | );
|
---|
12075 |
|
---|
12076 | NTKERNELAPI
|
---|
12077 | BOOLEAN
|
---|
12078 | KeSetTimerEx (
|
---|
12079 | IN PKTIMER Timer,
|
---|
12080 | IN LARGE_INTEGER DueTime,
|
---|
12081 | IN LONG Period OPTIONAL,
|
---|
12082 | IN PKDPC Dpc OPTIONAL
|
---|
12083 | );
|
---|
12084 |
|
---|
12085 |
|
---|
12086 | #define KeWaitForMutexObject KeWaitForSingleObject
|
---|
12087 |
|
---|
12088 | NTKERNELAPI
|
---|
12089 | NTSTATUS
|
---|
12090 | KeWaitForMultipleObjects (
|
---|
12091 | IN ULONG Count,
|
---|
12092 | IN PVOID Object[],
|
---|
12093 | IN WAIT_TYPE WaitType,
|
---|
12094 | IN KWAIT_REASON WaitReason,
|
---|
12095 | IN KPROCESSOR_MODE WaitMode,
|
---|
12096 | IN BOOLEAN Alertable,
|
---|
12097 | IN PLARGE_INTEGER Timeout OPTIONAL,
|
---|
12098 | IN PKWAIT_BLOCK WaitBlockArray OPTIONAL
|
---|
12099 | );
|
---|
12100 |
|
---|
12101 | NTKERNELAPI
|
---|
12102 | NTSTATUS
|
---|
12103 | KeWaitForSingleObject (
|
---|
12104 | IN PVOID Object,
|
---|
12105 | IN KWAIT_REASON WaitReason,
|
---|
12106 | IN KPROCESSOR_MODE WaitMode,
|
---|
12107 | IN BOOLEAN Alertable,
|
---|
12108 | IN PLARGE_INTEGER Timeout OPTIONAL
|
---|
12109 | );
|
---|
12110 |
|
---|
12111 | //
|
---|
12112 | // Define interprocess interrupt generic call types.
|
---|
12113 | //
|
---|
12114 |
|
---|
12115 | typedef
|
---|
12116 | ULONG_PTR
|
---|
12117 | (*PKIPI_BROADCAST_WORKER)(
|
---|
12118 | IN ULONG_PTR Argument
|
---|
12119 | );
|
---|
12120 |
|
---|
12121 | ULONG_PTR
|
---|
12122 | KeIpiGenericCall (
|
---|
12123 | IN PKIPI_BROADCAST_WORKER BroadcastFunction,
|
---|
12124 | IN ULONG_PTR Context
|
---|
12125 | );
|
---|
12126 |
|
---|
12127 |
|
---|
12128 | //
|
---|
12129 | // On X86 the following routines are defined in the HAL and imported by
|
---|
12130 | // all other modules.
|
---|
12131 | //
|
---|
12132 |
|
---|
12133 | #if defined(_X86_) && !defined(_NTHAL_)
|
---|
12134 |
|
---|
12135 | #define _DECL_HAL_KE_IMPORT __declspec(dllimport)
|
---|
12136 |
|
---|
12137 | #else
|
---|
12138 |
|
---|
12139 | #define _DECL_HAL_KE_IMPORT
|
---|
12140 |
|
---|
12141 | #endif
|
---|
12142 |
|
---|
12143 | //
|
---|
12144 | // spin lock functions
|
---|
12145 | //
|
---|
12146 |
|
---|
12147 | #if defined(_X86_) && (defined(_WDMDDK_) || defined(WIN9X_COMPAT_SPINLOCK))
|
---|
12148 |
|
---|
12149 | NTKERNELAPI
|
---|
12150 | VOID
|
---|
12151 | NTAPI
|
---|
12152 | KeInitializeSpinLock (
|
---|
12153 | IN PKSPIN_LOCK SpinLock
|
---|
12154 | );
|
---|
12155 |
|
---|
12156 | #else
|
---|
12157 |
|
---|
12158 | __inline
|
---|
12159 | VOID
|
---|
12160 | NTAPI
|
---|
12161 | KeInitializeSpinLock (
|
---|
12162 | IN PKSPIN_LOCK SpinLock
|
---|
12163 | )
|
---|
12164 | {
|
---|
12165 | *SpinLock = 0;
|
---|
12166 | }
|
---|
12167 |
|
---|
12168 | #endif
|
---|
12169 |
|
---|
12170 | #if defined(_X86_)
|
---|
12171 |
|
---|
12172 | NTKERNELAPI
|
---|
12173 | VOID
|
---|
12174 | FASTCALL
|
---|
12175 | KefAcquireSpinLockAtDpcLevel (
|
---|
12176 | IN PKSPIN_LOCK SpinLock
|
---|
12177 | );
|
---|
12178 |
|
---|
12179 | NTKERNELAPI
|
---|
12180 | VOID
|
---|
12181 | FASTCALL
|
---|
12182 | KefReleaseSpinLockFromDpcLevel (
|
---|
12183 | IN PKSPIN_LOCK SpinLock
|
---|
12184 | );
|
---|
12185 |
|
---|
12186 | #define KeAcquireSpinLockAtDpcLevel(a) KefAcquireSpinLockAtDpcLevel(a)
|
---|
12187 | #define KeReleaseSpinLockFromDpcLevel(a) KefReleaseSpinLockFromDpcLevel(a)
|
---|
12188 |
|
---|
12189 | _DECL_HAL_KE_IMPORT
|
---|
12190 | KIRQL
|
---|
12191 | FASTCALL
|
---|
12192 | KfAcquireSpinLock (
|
---|
12193 | IN PKSPIN_LOCK SpinLock
|
---|
12194 | );
|
---|
12195 |
|
---|
12196 | _DECL_HAL_KE_IMPORT
|
---|
12197 | VOID
|
---|
12198 | FASTCALL
|
---|
12199 | KfReleaseSpinLock (
|
---|
12200 | IN PKSPIN_LOCK SpinLock,
|
---|
12201 | IN KIRQL NewIrql
|
---|
12202 | );
|
---|
12203 |
|
---|
12204 |
|
---|
12205 | #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
|
---|
12206 | #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
|
---|
12207 |
|
---|
12208 | NTKERNELAPI
|
---|
12209 | BOOLEAN
|
---|
12210 | FASTCALL
|
---|
12211 | KeTestSpinLock (
|
---|
12212 | IN PKSPIN_LOCK SpinLock
|
---|
12213 | );
|
---|
12214 |
|
---|
12215 | NTKERNELAPI
|
---|
12216 | BOOLEAN
|
---|
12217 | FASTCALL
|
---|
12218 | KeTryToAcquireSpinLockAtDpcLevel (
|
---|
12219 | IN PKSPIN_LOCK SpinLock
|
---|
12220 | );
|
---|
12221 |
|
---|
12222 | #else
|
---|
12223 |
|
---|
12224 | //
|
---|
12225 | // These functions are imported for IA64, ntddk, ntifs, nthal, ntosp, and wdm.
|
---|
12226 | // They can be inlined for the system on AMD64.
|
---|
12227 | //
|
---|
12228 |
|
---|
12229 | #define KeAcquireSpinLock(SpinLock, OldIrql) \
|
---|
12230 | *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
|
---|
12231 |
|
---|
12232 | #if defined(_IA64_) || defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_) || defined(_WDMDDK_)
|
---|
12233 |
|
---|
12234 |
|
---|
12235 | NTKERNELAPI
|
---|
12236 | VOID
|
---|
12237 | KeAcquireSpinLockAtDpcLevel (
|
---|
12238 | IN PKSPIN_LOCK SpinLock
|
---|
12239 | );
|
---|
12240 |
|
---|
12241 | NTKERNELAPI
|
---|
12242 | KIRQL
|
---|
12243 | KeAcquireSpinLockRaiseToDpc (
|
---|
12244 | IN PKSPIN_LOCK SpinLock
|
---|
12245 | );
|
---|
12246 |
|
---|
12247 | NTKERNELAPI
|
---|
12248 | VOID
|
---|
12249 | KeReleaseSpinLock (
|
---|
12250 | IN PKSPIN_LOCK SpinLock,
|
---|
12251 | IN KIRQL NewIrql
|
---|
12252 | );
|
---|
12253 |
|
---|
12254 | NTKERNELAPI
|
---|
12255 | VOID
|
---|
12256 | KeReleaseSpinLockFromDpcLevel (
|
---|
12257 | IN PKSPIN_LOCK SpinLock
|
---|
12258 | );
|
---|
12259 |
|
---|
12260 | NTKERNELAPI
|
---|
12261 | BOOLEAN
|
---|
12262 | FASTCALL
|
---|
12263 | KeTestSpinLock (
|
---|
12264 | IN PKSPIN_LOCK SpinLock
|
---|
12265 | );
|
---|
12266 |
|
---|
12267 | NTKERNELAPI
|
---|
12268 | BOOLEAN
|
---|
12269 | FASTCALL
|
---|
12270 | KeTryToAcquireSpinLockAtDpcLevel (
|
---|
12271 | IN PKSPIN_LOCK SpinLock
|
---|
12272 | );
|
---|
12273 |
|
---|
12274 | #else
|
---|
12275 |
|
---|
12276 | #if defined(_AMD64_)
|
---|
12277 |
|
---|
12278 | //
|
---|
12279 | // The system version of these functions are defined in amd64.h for AMD64.
|
---|
12280 | //
|
---|
12281 |
|
---|
12282 | #endif
|
---|
12283 |
|
---|
12284 | #endif
|
---|
12285 |
|
---|
12286 | #endif
|
---|
12287 |
|
---|
12288 |
|
---|
12289 | #if defined(_X86_)
|
---|
12290 |
|
---|
12291 | _DECL_HAL_KE_IMPORT
|
---|
12292 | VOID
|
---|
12293 | FASTCALL
|
---|
12294 | KfLowerIrql (
|
---|
12295 | IN KIRQL NewIrql
|
---|
12296 | );
|
---|
12297 |
|
---|
12298 | _DECL_HAL_KE_IMPORT
|
---|
12299 | KIRQL
|
---|
12300 | FASTCALL
|
---|
12301 | KfRaiseIrql (
|
---|
12302 | IN KIRQL NewIrql
|
---|
12303 | );
|
---|
12304 |
|
---|
12305 |
|
---|
12306 |
|
---|
12307 | _DECL_HAL_KE_IMPORT
|
---|
12308 | KIRQL
|
---|
12309 | KeRaiseIrqlToDpcLevel(
|
---|
12310 | VOID
|
---|
12311 | );
|
---|
12312 |
|
---|
12313 |
|
---|
12314 | #define KeLowerIrql(a) KfLowerIrql(a)
|
---|
12315 | #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
|
---|
12316 |
|
---|
12317 |
|
---|
12318 |
|
---|
12319 |
|
---|
12320 |
|
---|
12321 | #elif defined(_IA64_)
|
---|
12322 |
|
---|
12323 | //
|
---|
12324 | // These function are defined in IA64.h for the IA64 platform.
|
---|
12325 | //
|
---|
12326 |
|
---|
12327 |
|
---|
12328 | #elif defined(_AMD64_)
|
---|
12329 |
|
---|
12330 | //
|
---|
12331 | // These function are defined in amd64.h for the AMD64 platform.
|
---|
12332 | //
|
---|
12333 |
|
---|
12334 | #else
|
---|
12335 |
|
---|
12336 | #error "no target architecture"
|
---|
12337 |
|
---|
12338 | #endif
|
---|
12339 |
|
---|
12340 | //
|
---|
12341 | // Queued spin lock functions for "in stack" lock handles.
|
---|
12342 | //
|
---|
12343 | // The following three functions RAISE and LOWER IRQL when a queued
|
---|
12344 | // in stack spin lock is acquired or released using these routines.
|
---|
12345 | //
|
---|
12346 |
|
---|
12347 | _DECL_HAL_KE_IMPORT
|
---|
12348 | VOID
|
---|
12349 | FASTCALL
|
---|
12350 | KeAcquireInStackQueuedSpinLock (
|
---|
12351 | IN PKSPIN_LOCK SpinLock,
|
---|
12352 | IN PKLOCK_QUEUE_HANDLE LockHandle
|
---|
12353 | );
|
---|
12354 |
|
---|
12355 |
|
---|
12356 | _DECL_HAL_KE_IMPORT
|
---|
12357 | VOID
|
---|
12358 | FASTCALL
|
---|
12359 | KeReleaseInStackQueuedSpinLock (
|
---|
12360 | IN PKLOCK_QUEUE_HANDLE LockHandle
|
---|
12361 | );
|
---|
12362 |
|
---|
12363 | //
|
---|
12364 | // The following two functions do NOT raise or lower IRQL when a queued
|
---|
12365 | // in stack spin lock is acquired or released using these functions.
|
---|
12366 | //
|
---|
12367 |
|
---|
12368 | NTKERNELAPI
|
---|
12369 | VOID
|
---|
12370 | FASTCALL
|
---|
12371 | KeAcquireInStackQueuedSpinLockAtDpcLevel (
|
---|
12372 | IN PKSPIN_LOCK SpinLock,
|
---|
12373 | IN PKLOCK_QUEUE_HANDLE LockHandle
|
---|
12374 | );
|
---|
12375 |
|
---|
12376 | NTKERNELAPI
|
---|
12377 | VOID
|
---|
12378 | FASTCALL
|
---|
12379 | KeReleaseInStackQueuedSpinLockFromDpcLevel (
|
---|
12380 | IN PKLOCK_QUEUE_HANDLE LockHandle
|
---|
12381 | );
|
---|
12382 |
|
---|
12383 | //
|
---|
12384 | // Miscellaneous kernel functions
|
---|
12385 | //
|
---|
12386 |
|
---|
12387 | typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
|
---|
12388 | BufferEmpty,
|
---|
12389 | BufferInserted,
|
---|
12390 | BufferStarted,
|
---|
12391 | BufferFinished,
|
---|
12392 | BufferIncomplete
|
---|
12393 | } KBUGCHECK_BUFFER_DUMP_STATE;
|
---|
12394 |
|
---|
12395 | typedef
|
---|
12396 | VOID
|
---|
12397 | (*PKBUGCHECK_CALLBACK_ROUTINE) (
|
---|
12398 | IN PVOID Buffer,
|
---|
12399 | IN ULONG Length
|
---|
12400 | );
|
---|
12401 |
|
---|
12402 | typedef struct _KBUGCHECK_CALLBACK_RECORD {
|
---|
12403 | LIST_ENTRY Entry;
|
---|
12404 | PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
|
---|
12405 | PVOID Buffer;
|
---|
12406 | ULONG Length;
|
---|
12407 | PUCHAR Component;
|
---|
12408 | ULONG_PTR Checksum;
|
---|
12409 | UCHAR State;
|
---|
12410 | } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
|
---|
12411 |
|
---|
12412 | #define KeInitializeCallbackRecord(CallbackRecord) \
|
---|
12413 | (CallbackRecord)->State = BufferEmpty
|
---|
12414 |
|
---|
12415 | NTKERNELAPI
|
---|
12416 | BOOLEAN
|
---|
12417 | KeDeregisterBugCheckCallback (
|
---|
12418 | IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord
|
---|
12419 | );
|
---|
12420 |
|
---|
12421 | NTKERNELAPI
|
---|
12422 | BOOLEAN
|
---|
12423 | KeRegisterBugCheckCallback (
|
---|
12424 | IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
|
---|
12425 | IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
|
---|
12426 | IN PVOID Buffer,
|
---|
12427 | IN ULONG Length,
|
---|
12428 | IN PUCHAR Component
|
---|
12429 | );
|
---|
12430 |
|
---|
12431 | typedef enum _KBUGCHECK_CALLBACK_REASON {
|
---|
12432 | KbCallbackInvalid,
|
---|
12433 | KbCallbackReserved1,
|
---|
12434 | KbCallbackSecondaryDumpData,
|
---|
12435 | KbCallbackDumpIo,
|
---|
12436 | } KBUGCHECK_CALLBACK_REASON;
|
---|
12437 |
|
---|
12438 | typedef
|
---|
12439 | VOID
|
---|
12440 | (*PKBUGCHECK_REASON_CALLBACK_ROUTINE) (
|
---|
12441 | IN KBUGCHECK_CALLBACK_REASON Reason,
|
---|
12442 | IN struct _KBUGCHECK_REASON_CALLBACK_RECORD* Record,
|
---|
12443 | IN OUT PVOID ReasonSpecificData,
|
---|
12444 | IN ULONG ReasonSpecificDataLength
|
---|
12445 | );
|
---|
12446 |
|
---|
12447 | typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
|
---|
12448 | LIST_ENTRY Entry;
|
---|
12449 | PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
|
---|
12450 | PUCHAR Component;
|
---|
12451 | ULONG_PTR Checksum;
|
---|
12452 | KBUGCHECK_CALLBACK_REASON Reason;
|
---|
12453 | UCHAR State;
|
---|
12454 | } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
|
---|
12455 |
|
---|
12456 | typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
|
---|
12457 | IN PVOID InBuffer;
|
---|
12458 | IN ULONG InBufferLength;
|
---|
12459 | IN ULONG MaximumAllowed;
|
---|
12460 | OUT GUID Guid;
|
---|
12461 | OUT PVOID OutBuffer;
|
---|
12462 | OUT ULONG OutBufferLength;
|
---|
12463 | } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
|
---|
12464 |
|
---|
12465 | typedef enum _KBUGCHECK_DUMP_IO_TYPE
|
---|
12466 | {
|
---|
12467 | KbDumpIoInvalid,
|
---|
12468 | KbDumpIoHeader,
|
---|
12469 | KbDumpIoBody,
|
---|
12470 | KbDumpIoSecondaryData,
|
---|
12471 | KbDumpIoComplete
|
---|
12472 | } KBUGCHECK_DUMP_IO_TYPE;
|
---|
12473 |
|
---|
12474 | typedef struct _KBUGCHECK_DUMP_IO {
|
---|
12475 | IN ULONG64 Offset;
|
---|
12476 | IN PVOID Buffer;
|
---|
12477 | IN ULONG BufferLength;
|
---|
12478 | IN KBUGCHECK_DUMP_IO_TYPE Type;
|
---|
12479 | } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
|
---|
12480 |
|
---|
12481 | NTKERNELAPI
|
---|
12482 | BOOLEAN
|
---|
12483 | KeDeregisterBugCheckReasonCallback (
|
---|
12484 | IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
|
---|
12485 | );
|
---|
12486 |
|
---|
12487 | NTKERNELAPI
|
---|
12488 | BOOLEAN
|
---|
12489 | KeRegisterBugCheckReasonCallback (
|
---|
12490 | IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
|
---|
12491 | IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
|
---|
12492 | IN KBUGCHECK_CALLBACK_REASON Reason,
|
---|
12493 | IN PUCHAR Component
|
---|
12494 | );
|
---|
12495 |
|
---|
12496 | typedef
|
---|
12497 | BOOLEAN
|
---|
12498 | (*PNMI_CALLBACK)(
|
---|
12499 | IN PVOID Context,
|
---|
12500 | IN BOOLEAN Handled
|
---|
12501 | );
|
---|
12502 |
|
---|
12503 | NTKERNELAPI
|
---|
12504 | PVOID
|
---|
12505 | KeRegisterNmiCallback(
|
---|
12506 | PNMI_CALLBACK CallbackRoutine,
|
---|
12507 | PVOID Context
|
---|
12508 | );
|
---|
12509 |
|
---|
12510 | NTSTATUS
|
---|
12511 | KeDeregisterNmiCallback(
|
---|
12512 | PVOID Handle
|
---|
12513 | );
|
---|
12514 |
|
---|
12515 |
|
---|
12516 |
|
---|
12517 | NTKERNELAPI
|
---|
12518 | DECLSPEC_NORETURN
|
---|
12519 | VOID
|
---|
12520 | NTAPI
|
---|
12521 | KeBugCheck (
|
---|
12522 | IN ULONG BugCheckCode
|
---|
12523 | );
|
---|
12524 |
|
---|
12525 |
|
---|
12526 | NTKERNELAPI
|
---|
12527 | DECLSPEC_NORETURN
|
---|
12528 | VOID
|
---|
12529 | KeBugCheckEx(
|
---|
12530 | IN ULONG BugCheckCode,
|
---|
12531 | IN ULONG_PTR BugCheckParameter1,
|
---|
12532 | IN ULONG_PTR BugCheckParameter2,
|
---|
12533 | IN ULONG_PTR BugCheckParameter3,
|
---|
12534 | IN ULONG_PTR BugCheckParameter4
|
---|
12535 | );
|
---|
12536 |
|
---|
12537 |
|
---|
12538 | #if defined(_AMD64_) || defined(_X86_)
|
---|
12539 |
|
---|
12540 | NTKERNELAPI
|
---|
12541 | BOOLEAN
|
---|
12542 | KeInvalidateAllCaches (
|
---|
12543 | VOID
|
---|
12544 | );
|
---|
12545 |
|
---|
12546 | #endif
|
---|
12547 |
|
---|
12548 |
|
---|
12549 | #if !defined(_AMD64_)
|
---|
12550 |
|
---|
12551 | NTKERNELAPI
|
---|
12552 | ULONGLONG
|
---|
12553 | KeQueryInterruptTime (
|
---|
12554 | VOID
|
---|
12555 | );
|
---|
12556 |
|
---|
12557 | NTKERNELAPI
|
---|
12558 | VOID
|
---|
12559 | KeQuerySystemTime (
|
---|
12560 | OUT PLARGE_INTEGER CurrentTime
|
---|
12561 | );
|
---|
12562 |
|
---|
12563 | #endif
|
---|
12564 |
|
---|
12565 | NTKERNELAPI
|
---|
12566 | ULONG
|
---|
12567 | KeQueryTimeIncrement (
|
---|
12568 | VOID
|
---|
12569 | );
|
---|
12570 |
|
---|
12571 | NTKERNELAPI
|
---|
12572 | ULONG
|
---|
12573 | KeGetRecommendedSharedDataAlignment (
|
---|
12574 | VOID
|
---|
12575 | );
|
---|
12576 |
|
---|
12577 |
|
---|
12578 |
|
---|
12579 | NTKERNELAPI
|
---|
12580 | KAFFINITY
|
---|
12581 | KeQueryActiveProcessors (
|
---|
12582 | VOID
|
---|
12583 | );
|
---|
12584 |
|
---|
12585 |
|
---|
12586 | #if defined(_IA64_)
|
---|
12587 |
|
---|
12588 | extern volatile LARGE_INTEGER KeTickCount;
|
---|
12589 |
|
---|
12590 | #elif defined(_X86_)
|
---|
12591 |
|
---|
12592 | extern volatile KSYSTEM_TIME KeTickCount;
|
---|
12593 |
|
---|
12594 | #endif
|
---|
12595 |
|
---|
12596 |
|
---|
12597 | typedef enum _MEMORY_CACHING_TYPE_ORIG {
|
---|
12598 | MmFrameBufferCached = 2
|
---|
12599 | } MEMORY_CACHING_TYPE_ORIG;
|
---|
12600 |
|
---|
12601 | typedef enum _MEMORY_CACHING_TYPE {
|
---|
12602 | MmNonCached = FALSE,
|
---|
12603 | MmCached = TRUE,
|
---|
12604 | MmWriteCombined = MmFrameBufferCached,
|
---|
12605 | MmHardwareCoherentCached,
|
---|
12606 | MmNonCachedUnordered, // IA64
|
---|
12607 | MmUSWCCached,
|
---|
12608 | MmMaximumCacheType
|
---|
12609 | } MEMORY_CACHING_TYPE;
|
---|
12610 |
|
---|
12611 | //
|
---|
12612 | // Define external data.
|
---|
12613 | // because of indirection for all drivers external to ntoskrnl these are actually ptrs
|
---|
12614 | //
|
---|
12615 |
|
---|
12616 | #if defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
|
---|
12617 |
|
---|
12618 | extern PBOOLEAN KdDebuggerNotPresent;
|
---|
12619 | extern PBOOLEAN KdDebuggerEnabled;
|
---|
12620 | #define KD_DEBUGGER_ENABLED *KdDebuggerEnabled
|
---|
12621 | #define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent
|
---|
12622 |
|
---|
12623 | #else
|
---|
12624 |
|
---|
12625 | extern BOOLEAN KdDebuggerNotPresent;
|
---|
12626 | extern BOOLEAN KdDebuggerEnabled;
|
---|
12627 | #define KD_DEBUGGER_ENABLED KdDebuggerEnabled
|
---|
12628 | #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
|
---|
12629 |
|
---|
12630 | #endif
|
---|
12631 |
|
---|
12632 |
|
---|
12633 |
|
---|
12634 |
|
---|
12635 | NTSTATUS
|
---|
12636 | KdDisableDebugger(
|
---|
12637 | VOID
|
---|
12638 | );
|
---|
12639 |
|
---|
12640 | NTSTATUS
|
---|
12641 | KdEnableDebugger(
|
---|
12642 | VOID
|
---|
12643 | );
|
---|
12644 |
|
---|
12645 | //
|
---|
12646 | // KdRefreshDebuggerPresent attempts to communicate with
|
---|
12647 | // the debugger host machine to refresh the state of
|
---|
12648 | // KdDebuggerNotPresent. It returns the state of
|
---|
12649 | // KdDebuggerNotPresent while the kd locks are held.
|
---|
12650 | // KdDebuggerNotPresent may immediately change state
|
---|
12651 | // after the kd locks are released so it may not
|
---|
12652 | // match the return value.
|
---|
12653 | //
|
---|
12654 |
|
---|
12655 | BOOLEAN
|
---|
12656 | KdRefreshDebuggerNotPresent(
|
---|
12657 | VOID
|
---|
12658 | );
|
---|
12659 |
|
---|
12660 | //
|
---|
12661 | // Pool Allocation routines (in pool.c)
|
---|
12662 | //
|
---|
12663 |
|
---|
12664 | typedef enum _POOL_TYPE {
|
---|
12665 | NonPagedPool,
|
---|
12666 | PagedPool,
|
---|
12667 | NonPagedPoolMustSucceed,
|
---|
12668 | DontUseThisType,
|
---|
12669 | NonPagedPoolCacheAligned,
|
---|
12670 | PagedPoolCacheAligned,
|
---|
12671 | NonPagedPoolCacheAlignedMustS,
|
---|
12672 | MaxPoolType
|
---|
12673 |
|
---|
12674 |
|
---|
12675 | ,
|
---|
12676 | //
|
---|
12677 | // Note these per session types are carefully chosen so that the appropriate
|
---|
12678 | // masking still applies as well as MaxPoolType above.
|
---|
12679 | //
|
---|
12680 |
|
---|
12681 | NonPagedPoolSession = 32,
|
---|
12682 | PagedPoolSession = NonPagedPoolSession + 1,
|
---|
12683 | NonPagedPoolMustSucceedSession = PagedPoolSession + 1,
|
---|
12684 | DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1,
|
---|
12685 | NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1,
|
---|
12686 | PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1,
|
---|
12687 | NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1,
|
---|
12688 |
|
---|
12689 |
|
---|
12690 |
|
---|
12691 | } POOL_TYPE;
|
---|
12692 |
|
---|
12693 | #define POOL_COLD_ALLOCATION 256 // Note this cannot encode into the header.
|
---|
12694 |
|
---|
12695 |
|
---|
12696 | DECLSPEC_DEPRECATED_DDK // Use ExAllocatePoolWithTag
|
---|
12697 | NTKERNELAPI
|
---|
12698 | PVOID
|
---|
12699 | ExAllocatePool(
|
---|
12700 | IN POOL_TYPE PoolType,
|
---|
12701 | IN SIZE_T NumberOfBytes
|
---|
12702 | );
|
---|
12703 |
|
---|
12704 | DECLSPEC_DEPRECATED_DDK // Use ExAllocatePoolWithQuotaTag
|
---|
12705 | NTKERNELAPI
|
---|
12706 | PVOID
|
---|
12707 | ExAllocatePoolWithQuota(
|
---|
12708 | IN POOL_TYPE PoolType,
|
---|
12709 | IN SIZE_T NumberOfBytes
|
---|
12710 | );
|
---|
12711 |
|
---|
12712 | NTKERNELAPI
|
---|
12713 | PVOID
|
---|
12714 | NTAPI
|
---|
12715 | ExAllocatePoolWithTag(
|
---|
12716 | IN POOL_TYPE PoolType,
|
---|
12717 | IN SIZE_T NumberOfBytes,
|
---|
12718 | IN ULONG Tag
|
---|
12719 | );
|
---|
12720 |
|
---|
12721 | //
|
---|
12722 | // _EX_POOL_PRIORITY_ provides a method for the system to handle requests
|
---|
12723 | // intelligently in low resource conditions.
|
---|
12724 | //
|
---|
12725 | // LowPoolPriority should be used when it is acceptable to the driver for the
|
---|
12726 | // mapping request to fail if the system is low on resources. An example of
|
---|
12727 | // this could be for a non-critical network connection where the driver can
|
---|
12728 | // handle the failure case when system resources are close to being depleted.
|
---|
12729 | //
|
---|
12730 | // NormalPoolPriority should be used when it is acceptable to the driver for the
|
---|
12731 | // mapping request to fail if the system is very low on resources. An example
|
---|
12732 | // of this could be for a non-critical local filesystem request.
|
---|
12733 | //
|
---|
12734 | // HighPoolPriority should be used when it is unacceptable to the driver for the
|
---|
12735 | // mapping request to fail unless the system is completely out of resources.
|
---|
12736 | // An example of this would be the paging file path in a driver.
|
---|
12737 | //
|
---|
12738 | // SpecialPool can be specified to bound the allocation at a page end (or
|
---|
12739 | // beginning). This should only be done on systems being debugged as the
|
---|
12740 | // memory cost is expensive.
|
---|
12741 | //
|
---|
12742 | // N.B. These values are very carefully chosen so that the pool allocation
|
---|
12743 | // code can quickly crack the priority request.
|
---|
12744 | //
|
---|
12745 |
|
---|
12746 | typedef enum _EX_POOL_PRIORITY {
|
---|
12747 | LowPoolPriority,
|
---|
12748 | LowPoolPrioritySpecialPoolOverrun = 8,
|
---|
12749 | LowPoolPrioritySpecialPoolUnderrun = 9,
|
---|
12750 | NormalPoolPriority = 16,
|
---|
12751 | NormalPoolPrioritySpecialPoolOverrun = 24,
|
---|
12752 | NormalPoolPrioritySpecialPoolUnderrun = 25,
|
---|
12753 | HighPoolPriority = 32,
|
---|
12754 | HighPoolPrioritySpecialPoolOverrun = 40,
|
---|
12755 | HighPoolPrioritySpecialPoolUnderrun = 41
|
---|
12756 |
|
---|
12757 | } EX_POOL_PRIORITY;
|
---|
12758 |
|
---|
12759 | NTKERNELAPI
|
---|
12760 | PVOID
|
---|
12761 | NTAPI
|
---|
12762 | ExAllocatePoolWithTagPriority(
|
---|
12763 | IN POOL_TYPE PoolType,
|
---|
12764 | IN SIZE_T NumberOfBytes,
|
---|
12765 | IN ULONG Tag,
|
---|
12766 | IN EX_POOL_PRIORITY Priority
|
---|
12767 | );
|
---|
12768 |
|
---|
12769 | #ifndef POOL_TAGGING
|
---|
12770 | #define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
|
---|
12771 | #endif //POOL_TAGGING
|
---|
12772 |
|
---|
12773 | NTKERNELAPI
|
---|
12774 | PVOID
|
---|
12775 | ExAllocatePoolWithQuotaTag(
|
---|
12776 | IN POOL_TYPE PoolType,
|
---|
12777 | IN SIZE_T NumberOfBytes,
|
---|
12778 | IN ULONG Tag
|
---|
12779 | );
|
---|
12780 |
|
---|
12781 | #ifndef POOL_TAGGING
|
---|
12782 | #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
|
---|
12783 | #endif //POOL_TAGGING
|
---|
12784 |
|
---|
12785 | NTKERNELAPI
|
---|
12786 | VOID
|
---|
12787 | NTAPI
|
---|
12788 | ExFreePool(
|
---|
12789 | IN PVOID P
|
---|
12790 | );
|
---|
12791 |
|
---|
12792 |
|
---|
12793 | #if defined(POOL_TAGGING)
|
---|
12794 | #define ExFreePool(a) ExFreePoolWithTag(a,0)
|
---|
12795 | #endif
|
---|
12796 |
|
---|
12797 | //
|
---|
12798 | // If high order bit in Pool tag is set, then must use ExFreePoolWithTag to free
|
---|
12799 | //
|
---|
12800 |
|
---|
12801 | #define PROTECTED_POOL 0x80000000
|
---|
12802 |
|
---|
12803 |
|
---|
12804 | NTKERNELAPI
|
---|
12805 | VOID
|
---|
12806 | ExFreePoolWithTag(
|
---|
12807 | IN PVOID P,
|
---|
12808 | IN ULONG Tag
|
---|
12809 | );
|
---|
12810 |
|
---|
12811 | //
|
---|
12812 | // Routines to support fast mutexes.
|
---|
12813 | //
|
---|
12814 |
|
---|
12815 | typedef struct _FAST_MUTEX {
|
---|
12816 | LONG Count;
|
---|
12817 | PKTHREAD Owner;
|
---|
12818 | ULONG Contention;
|
---|
12819 | KEVENT Event;
|
---|
12820 | ULONG OldIrql;
|
---|
12821 | } FAST_MUTEX, *PFAST_MUTEX;
|
---|
12822 |
|
---|
12823 | #define ExInitializeFastMutex(_FastMutex) \
|
---|
12824 | (_FastMutex)->Count = 1; \
|
---|
12825 | (_FastMutex)->Owner = NULL; \
|
---|
12826 | (_FastMutex)->Contention = 0; \
|
---|
12827 | KeInitializeEvent(&(_FastMutex)->Event, \
|
---|
12828 | SynchronizationEvent, \
|
---|
12829 | FALSE);
|
---|
12830 |
|
---|
12831 |
|
---|
12832 | NTKERNELAPI
|
---|
12833 | VOID
|
---|
12834 | FASTCALL
|
---|
12835 | ExAcquireFastMutexUnsafe (
|
---|
12836 | IN PFAST_MUTEX FastMutex
|
---|
12837 | );
|
---|
12838 |
|
---|
12839 | NTKERNELAPI
|
---|
12840 | VOID
|
---|
12841 | FASTCALL
|
---|
12842 | ExReleaseFastMutexUnsafe (
|
---|
12843 | IN PFAST_MUTEX FastMutex
|
---|
12844 | );
|
---|
12845 |
|
---|
12846 |
|
---|
12847 | #if defined(_IA64_) || defined(_AMD64_)
|
---|
12848 |
|
---|
12849 | NTKERNELAPI
|
---|
12850 | VOID
|
---|
12851 | FASTCALL
|
---|
12852 | ExAcquireFastMutex (
|
---|
12853 | IN PFAST_MUTEX FastMutex
|
---|
12854 | );
|
---|
12855 |
|
---|
12856 | NTKERNELAPI
|
---|
12857 | VOID
|
---|
12858 | FASTCALL
|
---|
12859 | ExReleaseFastMutex (
|
---|
12860 | IN PFAST_MUTEX FastMutex
|
---|
12861 | );
|
---|
12862 |
|
---|
12863 | NTKERNELAPI
|
---|
12864 | BOOLEAN
|
---|
12865 | FASTCALL
|
---|
12866 | ExTryToAcquireFastMutex (
|
---|
12867 | IN PFAST_MUTEX FastMutex
|
---|
12868 | );
|
---|
12869 |
|
---|
12870 | #elif defined(_X86_)
|
---|
12871 |
|
---|
12872 | NTHALAPI
|
---|
12873 | VOID
|
---|
12874 | FASTCALL
|
---|
12875 | ExAcquireFastMutex (
|
---|
12876 | IN PFAST_MUTEX FastMutex
|
---|
12877 | );
|
---|
12878 |
|
---|
12879 | NTHALAPI
|
---|
12880 | VOID
|
---|
12881 | FASTCALL
|
---|
12882 | ExReleaseFastMutex (
|
---|
12883 | IN PFAST_MUTEX FastMutex
|
---|
12884 | );
|
---|
12885 |
|
---|
12886 | NTHALAPI
|
---|
12887 | BOOLEAN
|
---|
12888 | FASTCALL
|
---|
12889 | ExTryToAcquireFastMutex (
|
---|
12890 | IN PFAST_MUTEX FastMutex
|
---|
12891 | );
|
---|
12892 |
|
---|
12893 | #else
|
---|
12894 |
|
---|
12895 | #error "Target architecture not defined"
|
---|
12896 |
|
---|
12897 | #endif
|
---|
12898 |
|
---|
12899 | //
|
---|
12900 |
|
---|
12901 | #if defined(_WIN64)
|
---|
12902 |
|
---|
12903 | #define ExInterlockedAddLargeStatistic(Addend, Increment) \
|
---|
12904 | (VOID) InterlockedAdd64(&(Addend)->QuadPart, Increment)
|
---|
12905 |
|
---|
12906 | #else
|
---|
12907 |
|
---|
12908 | #ifdef __cplusplus
|
---|
12909 | extern "C" {
|
---|
12910 | #endif
|
---|
12911 |
|
---|
12912 | LONG
|
---|
12913 | _InterlockedAddLargeStatistic (
|
---|
12914 | IN PLONGLONG Addend,
|
---|
12915 | IN ULONG Increment
|
---|
12916 | );
|
---|
12917 |
|
---|
12918 | #ifdef __cplusplus
|
---|
12919 | }
|
---|
12920 | #endif
|
---|
12921 |
|
---|
12922 | #pragma intrinsic (_InterlockedAddLargeStatistic)
|
---|
12923 |
|
---|
12924 | #define ExInterlockedAddLargeStatistic(Addend,Increment) \
|
---|
12925 | (VOID) _InterlockedAddLargeStatistic ((PLONGLONG)&(Addend)->QuadPart, Increment)
|
---|
12926 |
|
---|
12927 | #endif
|
---|
12928 |
|
---|
12929 |
|
---|
12930 |
|
---|
12931 | NTKERNELAPI
|
---|
12932 | LARGE_INTEGER
|
---|
12933 | ExInterlockedAddLargeInteger (
|
---|
12934 | IN PLARGE_INTEGER Addend,
|
---|
12935 | IN LARGE_INTEGER Increment,
|
---|
12936 | IN PKSPIN_LOCK Lock
|
---|
12937 | );
|
---|
12938 |
|
---|
12939 |
|
---|
12940 | NTKERNELAPI
|
---|
12941 | ULONG
|
---|
12942 | FASTCALL
|
---|
12943 | ExInterlockedAddUlong (
|
---|
12944 | IN PULONG Addend,
|
---|
12945 | IN ULONG Increment,
|
---|
12946 | IN PKSPIN_LOCK Lock
|
---|
12947 | );
|
---|
12948 |
|
---|
12949 |
|
---|
12950 | #if defined(_AMD64_) || defined(_AXP64_) || defined(_IA64_)
|
---|
12951 |
|
---|
12952 | #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
|
---|
12953 | InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
|
---|
12954 |
|
---|
12955 | #elif defined(_ALPHA_)
|
---|
12956 |
|
---|
12957 | #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
|
---|
12958 | ExpInterlockedCompareExchange64(Destination, Exchange, Comperand)
|
---|
12959 |
|
---|
12960 | #else
|
---|
12961 |
|
---|
12962 | #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
|
---|
12963 | ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
|
---|
12964 |
|
---|
12965 | #endif
|
---|
12966 |
|
---|
12967 | NTKERNELAPI
|
---|
12968 | PLIST_ENTRY
|
---|
12969 | FASTCALL
|
---|
12970 | ExInterlockedInsertHeadList (
|
---|
12971 | IN PLIST_ENTRY ListHead,
|
---|
12972 | IN PLIST_ENTRY ListEntry,
|
---|
12973 | IN PKSPIN_LOCK Lock
|
---|
12974 | );
|
---|
12975 |
|
---|
12976 | NTKERNELAPI
|
---|
12977 | PLIST_ENTRY
|
---|
12978 | FASTCALL
|
---|
12979 | ExInterlockedInsertTailList (
|
---|
12980 | IN PLIST_ENTRY ListHead,
|
---|
12981 | IN PLIST_ENTRY ListEntry,
|
---|
12982 | IN PKSPIN_LOCK Lock
|
---|
12983 | );
|
---|
12984 |
|
---|
12985 | NTKERNELAPI
|
---|
12986 | PLIST_ENTRY
|
---|
12987 | FASTCALL
|
---|
12988 | ExInterlockedRemoveHeadList (
|
---|
12989 | IN PLIST_ENTRY ListHead,
|
---|
12990 | IN PKSPIN_LOCK Lock
|
---|
12991 | );
|
---|
12992 |
|
---|
12993 | NTKERNELAPI
|
---|
12994 | PSINGLE_LIST_ENTRY
|
---|
12995 | FASTCALL
|
---|
12996 | ExInterlockedPopEntryList (
|
---|
12997 | IN PSINGLE_LIST_ENTRY ListHead,
|
---|
12998 | IN PKSPIN_LOCK Lock
|
---|
12999 | );
|
---|
13000 |
|
---|
13001 | NTKERNELAPI
|
---|
13002 | PSINGLE_LIST_ENTRY
|
---|
13003 | FASTCALL
|
---|
13004 | ExInterlockedPushEntryList (
|
---|
13005 | IN PSINGLE_LIST_ENTRY ListHead,
|
---|
13006 | IN PSINGLE_LIST_ENTRY ListEntry,
|
---|
13007 | IN PKSPIN_LOCK Lock
|
---|
13008 | );
|
---|
13009 |
|
---|
13010 | //
|
---|
13011 | // Define interlocked sequenced listhead functions.
|
---|
13012 | //
|
---|
13013 | // A sequenced interlocked list is a singly linked list with a header that
|
---|
13014 | // contains the current depth and a sequence number. Each time an entry is
|
---|
13015 | // inserted or removed from the list the depth is updated and the sequence
|
---|
13016 | // number is incremented. This enables AMD64, IA64, and Pentium and later
|
---|
13017 | // machines to insert and remove from the list without the use of spinlocks.
|
---|
13018 | //
|
---|
13019 |
|
---|
13020 | #if !defined(_WINBASE_)
|
---|
13021 |
|
---|
13022 | /*++
|
---|
13023 |
|
---|
13024 | Routine Description:
|
---|
13025 |
|
---|
13026 | This function initializes a sequenced singly linked listhead.
|
---|
13027 |
|
---|
13028 | Arguments:
|
---|
13029 |
|
---|
13030 | SListHead - Supplies a pointer to a sequenced singly linked listhead.
|
---|
13031 |
|
---|
13032 | Return Value:
|
---|
13033 |
|
---|
13034 | None.
|
---|
13035 |
|
---|
13036 | --*/
|
---|
13037 |
|
---|
13038 | #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
|
---|
13039 |
|
---|
13040 | NTKERNELAPI
|
---|
13041 | VOID
|
---|
13042 | InitializeSListHead (
|
---|
13043 | IN PSLIST_HEADER SListHead
|
---|
13044 | );
|
---|
13045 |
|
---|
13046 | #else
|
---|
13047 |
|
---|
13048 | __inline
|
---|
13049 | VOID
|
---|
13050 | InitializeSListHead (
|
---|
13051 | IN PSLIST_HEADER SListHead
|
---|
13052 | )
|
---|
13053 |
|
---|
13054 | {
|
---|
13055 |
|
---|
13056 | #ifdef _WIN64
|
---|
13057 |
|
---|
13058 | //
|
---|
13059 | // Slist headers must be 16 byte aligned.
|
---|
13060 | //
|
---|
13061 |
|
---|
13062 | if ((ULONG_PTR) SListHead & 0x0f) {
|
---|
13063 |
|
---|
13064 | DbgPrint( "InitializeSListHead unaligned Slist header. Address = %p, Caller = %p\n", SListHead, _ReturnAddress());
|
---|
13065 | RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
|
---|
13066 | }
|
---|
13067 |
|
---|
13068 | #endif
|
---|
13069 |
|
---|
13070 | SListHead->Alignment = 0;
|
---|
13071 |
|
---|
13072 | //
|
---|
13073 | // For IA-64 we save the region number of the elements of the list in a
|
---|
13074 | // separate field. This imposes the requirement that all elements stored
|
---|
13075 | // in the list are from the same region.
|
---|
13076 |
|
---|
13077 | #if defined(_IA64_)
|
---|
13078 |
|
---|
13079 | SListHead->Region = (ULONG_PTR)SListHead & VRN_MASK;
|
---|
13080 |
|
---|
13081 | #elif defined(_AMD64_)
|
---|
13082 |
|
---|
13083 | SListHead->Region = 0;
|
---|
13084 |
|
---|
13085 | #endif
|
---|
13086 |
|
---|
13087 | return;
|
---|
13088 | }
|
---|
13089 |
|
---|
13090 | #endif
|
---|
13091 |
|
---|
13092 | #endif // !defined(_WINBASE_)
|
---|
13093 |
|
---|
13094 | #define ExInitializeSListHead InitializeSListHead
|
---|
13095 |
|
---|
13096 | PSLIST_ENTRY
|
---|
13097 | FirstEntrySList (
|
---|
13098 | IN const SLIST_HEADER *SListHead
|
---|
13099 | );
|
---|
13100 |
|
---|
13101 | /*++
|
---|
13102 |
|
---|
13103 | Routine Description:
|
---|
13104 |
|
---|
13105 | This function queries the current number of entries contained in a
|
---|
13106 | sequenced single linked list.
|
---|
13107 |
|
---|
13108 | Arguments:
|
---|
13109 |
|
---|
13110 | SListHead - Supplies a pointer to the sequenced listhead which is
|
---|
13111 | be queried.
|
---|
13112 |
|
---|
13113 | Return Value:
|
---|
13114 |
|
---|
13115 | The current number of entries in the sequenced singly linked list is
|
---|
13116 | returned as the function value.
|
---|
13117 |
|
---|
13118 | --*/
|
---|
13119 |
|
---|
13120 | #if defined(_WIN64)
|
---|
13121 |
|
---|
13122 | #if (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
|
---|
13123 |
|
---|
13124 | NTKERNELAPI
|
---|
13125 | USHORT
|
---|
13126 | ExQueryDepthSList (
|
---|
13127 | IN PSLIST_HEADER SListHead
|
---|
13128 | );
|
---|
13129 |
|
---|
13130 | #else
|
---|
13131 |
|
---|
13132 | __inline
|
---|
13133 | USHORT
|
---|
13134 | ExQueryDepthSList (
|
---|
13135 | IN PSLIST_HEADER SListHead
|
---|
13136 | )
|
---|
13137 |
|
---|
13138 | {
|
---|
13139 |
|
---|
13140 | return (USHORT)(SListHead->Alignment & 0xffff);
|
---|
13141 | }
|
---|
13142 |
|
---|
13143 | #endif
|
---|
13144 |
|
---|
13145 | #else
|
---|
13146 |
|
---|
13147 | #define ExQueryDepthSList(_listhead_) (_listhead_)->Depth
|
---|
13148 |
|
---|
13149 | #endif
|
---|
13150 |
|
---|
13151 | #if defined(_WIN64)
|
---|
13152 |
|
---|
13153 | #define ExInterlockedPopEntrySList(Head, Lock) \
|
---|
13154 | ExpInterlockedPopEntrySList(Head)
|
---|
13155 |
|
---|
13156 | #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
|
---|
13157 | ExpInterlockedPushEntrySList(Head, Entry)
|
---|
13158 |
|
---|
13159 | #define ExInterlockedFlushSList(Head) \
|
---|
13160 | ExpInterlockedFlushSList(Head)
|
---|
13161 |
|
---|
13162 | #if !defined(_WINBASE_)
|
---|
13163 |
|
---|
13164 | #define InterlockedPopEntrySList(Head) \
|
---|
13165 | ExpInterlockedPopEntrySList(Head)
|
---|
13166 |
|
---|
13167 | #define InterlockedPushEntrySList(Head, Entry) \
|
---|
13168 | ExpInterlockedPushEntrySList(Head, Entry)
|
---|
13169 |
|
---|
13170 | #define InterlockedFlushSList(Head) \
|
---|
13171 | ExpInterlockedFlushSList(Head)
|
---|
13172 |
|
---|
13173 | #define QueryDepthSList(Head) \
|
---|
13174 | ExQueryDepthSList(Head)
|
---|
13175 |
|
---|
13176 | #endif // !defined(_WINBASE_)
|
---|
13177 |
|
---|
13178 | NTKERNELAPI
|
---|
13179 | PSLIST_ENTRY
|
---|
13180 | ExpInterlockedPopEntrySList (
|
---|
13181 | IN PSLIST_HEADER ListHead
|
---|
13182 | );
|
---|
13183 |
|
---|
13184 | NTKERNELAPI
|
---|
13185 | PSLIST_ENTRY
|
---|
13186 | ExpInterlockedPushEntrySList (
|
---|
13187 | IN PSLIST_HEADER ListHead,
|
---|
13188 | IN PSLIST_ENTRY ListEntry
|
---|
13189 | );
|
---|
13190 |
|
---|
13191 | NTKERNELAPI
|
---|
13192 | PSLIST_ENTRY
|
---|
13193 | ExpInterlockedFlushSList (
|
---|
13194 | IN PSLIST_HEADER ListHead
|
---|
13195 | );
|
---|
13196 |
|
---|
13197 | #else
|
---|
13198 |
|
---|
13199 | #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
|
---|
13200 |
|
---|
13201 | NTKERNELAPI
|
---|
13202 | PSLIST_ENTRY
|
---|
13203 | FASTCALL
|
---|
13204 | ExInterlockedPopEntrySList (
|
---|
13205 | IN PSLIST_HEADER ListHead,
|
---|
13206 | IN PKSPIN_LOCK Lock
|
---|
13207 | );
|
---|
13208 |
|
---|
13209 | NTKERNELAPI
|
---|
13210 | PSLIST_ENTRY
|
---|
13211 | FASTCALL
|
---|
13212 | ExInterlockedPushEntrySList (
|
---|
13213 | IN PSLIST_HEADER ListHead,
|
---|
13214 | IN PSLIST_ENTRY ListEntry,
|
---|
13215 | IN PKSPIN_LOCK Lock
|
---|
13216 | );
|
---|
13217 |
|
---|
13218 | #else
|
---|
13219 |
|
---|
13220 | #define ExInterlockedPopEntrySList(ListHead, Lock) \
|
---|
13221 | InterlockedPopEntrySList(ListHead)
|
---|
13222 |
|
---|
13223 | #define ExInterlockedPushEntrySList(ListHead, ListEntry, Lock) \
|
---|
13224 | InterlockedPushEntrySList(ListHead, ListEntry)
|
---|
13225 |
|
---|
13226 | #endif
|
---|
13227 |
|
---|
13228 | NTKERNELAPI
|
---|
13229 | PSLIST_ENTRY
|
---|
13230 | FASTCALL
|
---|
13231 | ExInterlockedFlushSList (
|
---|
13232 | IN PSLIST_HEADER ListHead
|
---|
13233 | );
|
---|
13234 |
|
---|
13235 | #if !defined(_WINBASE_)
|
---|
13236 |
|
---|
13237 | NTKERNELAPI
|
---|
13238 | PSLIST_ENTRY
|
---|
13239 | FASTCALL
|
---|
13240 | InterlockedPopEntrySList (
|
---|
13241 | IN PSLIST_HEADER ListHead
|
---|
13242 | );
|
---|
13243 |
|
---|
13244 | NTKERNELAPI
|
---|
13245 | PSLIST_ENTRY
|
---|
13246 | FASTCALL
|
---|
13247 | InterlockedPushEntrySList (
|
---|
13248 | IN PSLIST_HEADER ListHead,
|
---|
13249 | IN PSLIST_ENTRY ListEntry
|
---|
13250 | );
|
---|
13251 |
|
---|
13252 | #define InterlockedFlushSList(Head) \
|
---|
13253 | ExInterlockedFlushSList(Head)
|
---|
13254 |
|
---|
13255 | #define QueryDepthSList(Head) \
|
---|
13256 | ExQueryDepthSList(Head)
|
---|
13257 |
|
---|
13258 | #endif // !defined(_WINBASE_)
|
---|
13259 |
|
---|
13260 | #endif // defined(_WIN64)
|
---|
13261 |
|
---|
13262 |
|
---|
13263 | typedef
|
---|
13264 | PVOID
|
---|
13265 | (*PALLOCATE_FUNCTION) (
|
---|
13266 | IN POOL_TYPE PoolType,
|
---|
13267 | IN SIZE_T NumberOfBytes,
|
---|
13268 | IN ULONG Tag
|
---|
13269 | );
|
---|
13270 |
|
---|
13271 | typedef
|
---|
13272 | VOID
|
---|
13273 | (*PFREE_FUNCTION) (
|
---|
13274 | IN PVOID Buffer
|
---|
13275 | );
|
---|
13276 |
|
---|
13277 | #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
|
---|
13278 |
|
---|
13279 | typedef struct _GENERAL_LOOKASIDE {
|
---|
13280 |
|
---|
13281 | #else
|
---|
13282 |
|
---|
13283 | typedef struct DECLSPEC_CACHEALIGN _GENERAL_LOOKASIDE {
|
---|
13284 |
|
---|
13285 | #endif
|
---|
13286 |
|
---|
13287 | SLIST_HEADER ListHead;
|
---|
13288 | USHORT Depth;
|
---|
13289 | USHORT MaximumDepth;
|
---|
13290 | ULONG TotalAllocates;
|
---|
13291 | union {
|
---|
13292 | ULONG AllocateMisses;
|
---|
13293 | ULONG AllocateHits;
|
---|
13294 | };
|
---|
13295 |
|
---|
13296 | ULONG TotalFrees;
|
---|
13297 | union {
|
---|
13298 | ULONG FreeMisses;
|
---|
13299 | ULONG FreeHits;
|
---|
13300 | };
|
---|
13301 |
|
---|
13302 | POOL_TYPE Type;
|
---|
13303 | ULONG Tag;
|
---|
13304 | ULONG Size;
|
---|
13305 | PALLOCATE_FUNCTION Allocate;
|
---|
13306 | PFREE_FUNCTION Free;
|
---|
13307 | LIST_ENTRY ListEntry;
|
---|
13308 | ULONG LastTotalAllocates;
|
---|
13309 | union {
|
---|
13310 | ULONG LastAllocateMisses;
|
---|
13311 | ULONG LastAllocateHits;
|
---|
13312 | };
|
---|
13313 |
|
---|
13314 | ULONG Future[2];
|
---|
13315 | } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
|
---|
13316 |
|
---|
13317 | #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
|
---|
13318 |
|
---|
13319 | typedef struct _NPAGED_LOOKASIDE_LIST {
|
---|
13320 |
|
---|
13321 | #else
|
---|
13322 |
|
---|
13323 | typedef struct DECLSPEC_CACHEALIGN _NPAGED_LOOKASIDE_LIST {
|
---|
13324 |
|
---|
13325 | #endif
|
---|
13326 |
|
---|
13327 | GENERAL_LOOKASIDE L;
|
---|
13328 |
|
---|
13329 | #if !defined(_AMD64_) && !defined(_IA64_)
|
---|
13330 |
|
---|
13331 | KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
|
---|
13332 |
|
---|
13333 | #endif
|
---|
13334 |
|
---|
13335 | } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
|
---|
13336 |
|
---|
13337 | NTKERNELAPI
|
---|
13338 | VOID
|
---|
13339 | ExInitializeNPagedLookasideList (
|
---|
13340 | IN PNPAGED_LOOKASIDE_LIST Lookaside,
|
---|
13341 | IN PALLOCATE_FUNCTION Allocate,
|
---|
13342 | IN PFREE_FUNCTION Free,
|
---|
13343 | IN ULONG Flags,
|
---|
13344 | IN SIZE_T Size,
|
---|
13345 | IN ULONG Tag,
|
---|
13346 | IN USHORT Depth
|
---|
13347 | );
|
---|
13348 |
|
---|
13349 | NTKERNELAPI
|
---|
13350 | VOID
|
---|
13351 | ExDeleteNPagedLookasideList (
|
---|
13352 | IN PNPAGED_LOOKASIDE_LIST Lookaside
|
---|
13353 | );
|
---|
13354 |
|
---|
13355 | __inline
|
---|
13356 | PVOID
|
---|
13357 | ExAllocateFromNPagedLookasideList(
|
---|
13358 | IN PNPAGED_LOOKASIDE_LIST Lookaside
|
---|
13359 | )
|
---|
13360 |
|
---|
13361 | /*++
|
---|
13362 |
|
---|
13363 | Routine Description:
|
---|
13364 |
|
---|
13365 | This function removes (pops) the first entry from the specified
|
---|
13366 | nonpaged lookaside list.
|
---|
13367 |
|
---|
13368 | Arguments:
|
---|
13369 |
|
---|
13370 | Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
|
---|
13371 |
|
---|
13372 | Return Value:
|
---|
13373 |
|
---|
13374 | If an entry is removed from the specified lookaside list, then the
|
---|
13375 | address of the entry is returned as the function value. Otherwise,
|
---|
13376 | NULL is returned.
|
---|
13377 |
|
---|
13378 | --*/
|
---|
13379 |
|
---|
13380 | {
|
---|
13381 |
|
---|
13382 | PVOID Entry;
|
---|
13383 |
|
---|
13384 | Lookaside->L.TotalAllocates += 1;
|
---|
13385 |
|
---|
13386 | #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
|
---|
13387 |
|
---|
13388 | Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead,
|
---|
13389 | &Lookaside->Lock__ObsoleteButDoNotDelete);
|
---|
13390 |
|
---|
13391 |
|
---|
13392 | #else
|
---|
13393 |
|
---|
13394 | Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
|
---|
13395 |
|
---|
13396 | #endif
|
---|
13397 |
|
---|
13398 | if (Entry == NULL) {
|
---|
13399 | Lookaside->L.AllocateMisses += 1;
|
---|
13400 | Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
|
---|
13401 | Lookaside->L.Size,
|
---|
13402 | Lookaside->L.Tag);
|
---|
13403 | }
|
---|
13404 |
|
---|
13405 | return Entry;
|
---|
13406 | }
|
---|
13407 |
|
---|
13408 | __inline
|
---|
13409 | VOID
|
---|
13410 | ExFreeToNPagedLookasideList(
|
---|
13411 | IN PNPAGED_LOOKASIDE_LIST Lookaside,
|
---|
13412 | IN PVOID Entry
|
---|
13413 | )
|
---|
13414 |
|
---|
13415 | /*++
|
---|
13416 |
|
---|
13417 | Routine Description:
|
---|
13418 |
|
---|
13419 | This function inserts (pushes) the specified entry into the specified
|
---|
13420 | nonpaged lookaside list.
|
---|
13421 |
|
---|
13422 | Arguments:
|
---|
13423 |
|
---|
13424 | Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
|
---|
13425 |
|
---|
13426 | Entry - Supplies a pointer to the entry that is inserted in the
|
---|
13427 | lookaside list.
|
---|
13428 |
|
---|
13429 | Return Value:
|
---|
13430 |
|
---|
13431 | None.
|
---|
13432 |
|
---|
13433 | --*/
|
---|
13434 |
|
---|
13435 | {
|
---|
13436 |
|
---|
13437 | Lookaside->L.TotalFrees += 1;
|
---|
13438 | if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
|
---|
13439 | Lookaside->L.FreeMisses += 1;
|
---|
13440 | (Lookaside->L.Free)(Entry);
|
---|
13441 |
|
---|
13442 | } else {
|
---|
13443 |
|
---|
13444 | #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
|
---|
13445 |
|
---|
13446 | ExInterlockedPushEntrySList(&Lookaside->L.ListHead,
|
---|
13447 | (PSLIST_ENTRY)Entry,
|
---|
13448 | &Lookaside->Lock__ObsoleteButDoNotDelete);
|
---|
13449 |
|
---|
13450 | #else
|
---|
13451 |
|
---|
13452 | InterlockedPushEntrySList(&Lookaside->L.ListHead,
|
---|
13453 | (PSLIST_ENTRY)Entry);
|
---|
13454 |
|
---|
13455 | #endif
|
---|
13456 |
|
---|
13457 | }
|
---|
13458 | return;
|
---|
13459 | }
|
---|
13460 |
|
---|
13461 |
|
---|
13462 |
|
---|
13463 | #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
|
---|
13464 |
|
---|
13465 | typedef struct _PAGED_LOOKASIDE_LIST {
|
---|
13466 |
|
---|
13467 | #else
|
---|
13468 |
|
---|
13469 | typedef struct DECLSPEC_CACHEALIGN _PAGED_LOOKASIDE_LIST {
|
---|
13470 |
|
---|
13471 | #endif
|
---|
13472 |
|
---|
13473 | GENERAL_LOOKASIDE L;
|
---|
13474 |
|
---|
13475 | #if !defined(_AMD64_) && !defined(_IA64_)
|
---|
13476 |
|
---|
13477 | FAST_MUTEX Lock__ObsoleteButDoNotDelete;
|
---|
13478 |
|
---|
13479 | #endif
|
---|
13480 |
|
---|
13481 | } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
|
---|
13482 |
|
---|
13483 |
|
---|
13484 | NTKERNELAPI
|
---|
13485 | VOID
|
---|
13486 | ExInitializePagedLookasideList (
|
---|
13487 | IN PPAGED_LOOKASIDE_LIST Lookaside,
|
---|
13488 | IN PALLOCATE_FUNCTION Allocate,
|
---|
13489 | IN PFREE_FUNCTION Free,
|
---|
13490 | IN ULONG Flags,
|
---|
13491 | IN SIZE_T Size,
|
---|
13492 | IN ULONG Tag,
|
---|
13493 | IN USHORT Depth
|
---|
13494 | );
|
---|
13495 |
|
---|
13496 | NTKERNELAPI
|
---|
13497 | VOID
|
---|
13498 | ExDeletePagedLookasideList (
|
---|
13499 | IN PPAGED_LOOKASIDE_LIST Lookaside
|
---|
13500 | );
|
---|
13501 |
|
---|
13502 | #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
|
---|
13503 |
|
---|
13504 | NTKERNELAPI
|
---|
13505 | PVOID
|
---|
13506 | ExAllocateFromPagedLookasideList(
|
---|
13507 | IN PPAGED_LOOKASIDE_LIST Lookaside
|
---|
13508 | );
|
---|
13509 |
|
---|
13510 | #else
|
---|
13511 |
|
---|
13512 | __inline
|
---|
13513 | PVOID
|
---|
13514 | ExAllocateFromPagedLookasideList(
|
---|
13515 | IN PPAGED_LOOKASIDE_LIST Lookaside
|
---|
13516 | )
|
---|
13517 |
|
---|
13518 | /*++
|
---|
13519 |
|
---|
13520 | Routine Description:
|
---|
13521 |
|
---|
13522 | This function removes (pops) the first entry from the specified
|
---|
13523 | paged lookaside list.
|
---|
13524 |
|
---|
13525 | Arguments:
|
---|
13526 |
|
---|
13527 | Lookaside - Supplies a pointer to a paged lookaside list structure.
|
---|
13528 |
|
---|
13529 | Return Value:
|
---|
13530 |
|
---|
13531 | If an entry is removed from the specified lookaside list, then the
|
---|
13532 | address of the entry is returned as the function value. Otherwise,
|
---|
13533 | NULL is returned.
|
---|
13534 |
|
---|
13535 | --*/
|
---|
13536 |
|
---|
13537 | {
|
---|
13538 |
|
---|
13539 | PVOID Entry;
|
---|
13540 |
|
---|
13541 | Lookaside->L.TotalAllocates += 1;
|
---|
13542 | Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
|
---|
13543 | if (Entry == NULL) {
|
---|
13544 | Lookaside->L.AllocateMisses += 1;
|
---|
13545 | Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
|
---|
13546 | Lookaside->L.Size,
|
---|
13547 | Lookaside->L.Tag);
|
---|
13548 | }
|
---|
13549 |
|
---|
13550 | return Entry;
|
---|
13551 | }
|
---|
13552 |
|
---|
13553 | #endif
|
---|
13554 |
|
---|
13555 | #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
|
---|
13556 |
|
---|
13557 | NTKERNELAPI
|
---|
13558 | VOID
|
---|
13559 | ExFreeToPagedLookasideList(
|
---|
13560 | IN PPAGED_LOOKASIDE_LIST Lookaside,
|
---|
13561 | IN PVOID Entry
|
---|
13562 | );
|
---|
13563 |
|
---|
13564 | #else
|
---|
13565 |
|
---|
13566 | __inline
|
---|
13567 | VOID
|
---|
13568 | ExFreeToPagedLookasideList(
|
---|
13569 | IN PPAGED_LOOKASIDE_LIST Lookaside,
|
---|
13570 | IN PVOID Entry
|
---|
13571 | )
|
---|
13572 |
|
---|
13573 | /*++
|
---|
13574 |
|
---|
13575 | Routine Description:
|
---|
13576 |
|
---|
13577 | This function inserts (pushes) the specified entry into the specified
|
---|
13578 | paged lookaside list.
|
---|
13579 |
|
---|
13580 | Arguments:
|
---|
13581 |
|
---|
13582 | Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
|
---|
13583 |
|
---|
13584 | Entry - Supplies a pointer to the entry that is inserted in the
|
---|
13585 | lookaside list.
|
---|
13586 |
|
---|
13587 | Return Value:
|
---|
13588 |
|
---|
13589 | None.
|
---|
13590 |
|
---|
13591 | --*/
|
---|
13592 |
|
---|
13593 | {
|
---|
13594 |
|
---|
13595 | Lookaside->L.TotalFrees += 1;
|
---|
13596 | if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
|
---|
13597 | Lookaside->L.FreeMisses += 1;
|
---|
13598 | (Lookaside->L.Free)(Entry);
|
---|
13599 |
|
---|
13600 | } else {
|
---|
13601 | InterlockedPushEntrySList(&Lookaside->L.ListHead,
|
---|
13602 | (PSLIST_ENTRY)Entry);
|
---|
13603 | }
|
---|
13604 |
|
---|
13605 | return;
|
---|
13606 | }
|
---|
13607 |
|
---|
13608 | #endif
|
---|
13609 |
|
---|
13610 |
|
---|
13611 | NTKERNELAPI
|
---|
13612 | VOID
|
---|
13613 | NTAPI
|
---|
13614 | ProbeForRead(
|
---|
13615 | IN CONST VOID *Address,
|
---|
13616 | IN SIZE_T Length,
|
---|
13617 | IN ULONG Alignment
|
---|
13618 | );
|
---|
13619 |
|
---|
13620 | //
|
---|
13621 | // Common probe for write functions.
|
---|
13622 | //
|
---|
13623 |
|
---|
13624 | NTKERNELAPI
|
---|
13625 | VOID
|
---|
13626 | NTAPI
|
---|
13627 | ProbeForWrite (
|
---|
13628 | IN PVOID Address,
|
---|
13629 | IN SIZE_T Length,
|
---|
13630 | IN ULONG Alignment
|
---|
13631 | );
|
---|
13632 |
|
---|
13633 | //
|
---|
13634 | // Worker Thread
|
---|
13635 | //
|
---|
13636 |
|
---|
13637 | typedef enum _WORK_QUEUE_TYPE {
|
---|
13638 | CriticalWorkQueue,
|
---|
13639 | DelayedWorkQueue,
|
---|
13640 | HyperCriticalWorkQueue,
|
---|
13641 | MaximumWorkQueue
|
---|
13642 | } WORK_QUEUE_TYPE;
|
---|
13643 |
|
---|
13644 | typedef
|
---|
13645 | VOID
|
---|
13646 | (*PWORKER_THREAD_ROUTINE)(
|
---|
13647 | IN PVOID Parameter
|
---|
13648 | );
|
---|
13649 |
|
---|
13650 | typedef struct _WORK_QUEUE_ITEM {
|
---|
13651 | LIST_ENTRY List;
|
---|
13652 | PWORKER_THREAD_ROUTINE WorkerRoutine;
|
---|
13653 | PVOID Parameter;
|
---|
13654 | } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
|
---|
13655 |
|
---|
13656 | #if PRAGMA_DEPRECATED_DDK
|
---|
13657 | #pragma deprecated(ExInitializeWorkItem) // Use IoAllocateWorkItem
|
---|
13658 | #endif
|
---|
13659 | #define ExInitializeWorkItem(Item, Routine, Context) \
|
---|
13660 | (Item)->WorkerRoutine = (Routine); \
|
---|
13661 | (Item)->Parameter = (Context); \
|
---|
13662 | (Item)->List.Flink = NULL;
|
---|
13663 |
|
---|
13664 | DECLSPEC_DEPRECATED_DDK // Use IoQueueWorkItem
|
---|
13665 | NTKERNELAPI
|
---|
13666 | VOID
|
---|
13667 | ExQueueWorkItem(
|
---|
13668 | IN PWORK_QUEUE_ITEM WorkItem,
|
---|
13669 | IN WORK_QUEUE_TYPE QueueType
|
---|
13670 | );
|
---|
13671 |
|
---|
13672 |
|
---|
13673 | NTKERNELAPI
|
---|
13674 | BOOLEAN
|
---|
13675 | ExIsProcessorFeaturePresent(
|
---|
13676 | ULONG ProcessorFeature
|
---|
13677 | );
|
---|
13678 |
|
---|
13679 | //
|
---|
13680 | // Zone Allocation
|
---|
13681 | //
|
---|
13682 |
|
---|
13683 | typedef struct _ZONE_SEGMENT_HEADER {
|
---|
13684 | SINGLE_LIST_ENTRY SegmentList;
|
---|
13685 | PVOID Reserved;
|
---|
13686 | } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
|
---|
13687 |
|
---|
13688 | typedef struct _ZONE_HEADER {
|
---|
13689 | SINGLE_LIST_ENTRY FreeList;
|
---|
13690 | SINGLE_LIST_ENTRY SegmentList;
|
---|
13691 | ULONG BlockSize;
|
---|
13692 | ULONG TotalSegmentSize;
|
---|
13693 | } ZONE_HEADER, *PZONE_HEADER;
|
---|
13694 |
|
---|
13695 |
|
---|
13696 | DECLSPEC_DEPRECATED_DDK
|
---|
13697 | NTKERNELAPI
|
---|
13698 | NTSTATUS
|
---|
13699 | ExInitializeZone(
|
---|
13700 | IN PZONE_HEADER Zone,
|
---|
13701 | IN ULONG BlockSize,
|
---|
13702 | IN PVOID InitialSegment,
|
---|
13703 | IN ULONG InitialSegmentSize
|
---|
13704 | );
|
---|
13705 |
|
---|
13706 | DECLSPEC_DEPRECATED_DDK
|
---|
13707 | NTKERNELAPI
|
---|
13708 | NTSTATUS
|
---|
13709 | ExExtendZone(
|
---|
13710 | IN PZONE_HEADER Zone,
|
---|
13711 | IN PVOID Segment,
|
---|
13712 | IN ULONG SegmentSize
|
---|
13713 | );
|
---|
13714 |
|
---|
13715 | DECLSPEC_DEPRECATED_DDK
|
---|
13716 | NTKERNELAPI
|
---|
13717 | NTSTATUS
|
---|
13718 | ExInterlockedExtendZone(
|
---|
13719 | IN PZONE_HEADER Zone,
|
---|
13720 | IN PVOID Segment,
|
---|
13721 | IN ULONG SegmentSize,
|
---|
13722 | IN PKSPIN_LOCK Lock
|
---|
13723 | );
|
---|
13724 |
|
---|
13725 | //++
|
---|
13726 | //
|
---|
13727 | // PVOID
|
---|
13728 | // ExAllocateFromZone(
|
---|
13729 | // IN PZONE_HEADER Zone
|
---|
13730 | // )
|
---|
13731 | //
|
---|
13732 | // Routine Description:
|
---|
13733 | //
|
---|
13734 | // This routine removes an entry from the zone and returns a pointer to it.
|
---|
13735 | //
|
---|
13736 | // Arguments:
|
---|
13737 | //
|
---|
13738 | // Zone - Pointer to the zone header controlling the storage from which the
|
---|
13739 | // entry is to be allocated.
|
---|
13740 | //
|
---|
13741 | // Return Value:
|
---|
13742 | //
|
---|
13743 | // The function value is a pointer to the storage allocated from the zone.
|
---|
13744 | //
|
---|
13745 | //--
|
---|
13746 | #if PRAGMA_DEPRECATED_DDK
|
---|
13747 | #pragma deprecated(ExAllocateFromZone)
|
---|
13748 | #endif
|
---|
13749 | #define ExAllocateFromZone(Zone) \
|
---|
13750 | (PVOID)((Zone)->FreeList.Next); \
|
---|
13751 | if ( (Zone)->FreeList.Next ) (Zone)->FreeList.Next = (Zone)->FreeList.Next->Next
|
---|
13752 |
|
---|
13753 |
|
---|
13754 | //++
|
---|
13755 | //
|
---|
13756 | // PVOID
|
---|
13757 | // ExFreeToZone(
|
---|
13758 | // IN PZONE_HEADER Zone,
|
---|
13759 | // IN PVOID Block
|
---|
13760 | // )
|
---|
13761 | //
|
---|
13762 | // Routine Description:
|
---|
13763 | //
|
---|
13764 | // This routine places the specified block of storage back onto the free
|
---|
13765 | // list in the specified zone.
|
---|
13766 | //
|
---|
13767 | // Arguments:
|
---|
13768 | //
|
---|
13769 | // Zone - Pointer to the zone header controlling the storage to which the
|
---|
13770 | // entry is to be inserted.
|
---|
13771 | //
|
---|
13772 | // Block - Pointer to the block of storage to be freed back to the zone.
|
---|
13773 | //
|
---|
13774 | // Return Value:
|
---|
13775 | //
|
---|
13776 | // Pointer to previous block of storage that was at the head of the free
|
---|
13777 | // list. NULL implies the zone went from no available free blocks to
|
---|
13778 | // at least one free block.
|
---|
13779 | //
|
---|
13780 | //--
|
---|
13781 |
|
---|
13782 | #if PRAGMA_DEPRECATED_DDK
|
---|
13783 | #pragma deprecated(ExFreeToZone)
|
---|
13784 | #endif
|
---|
13785 | #define ExFreeToZone(Zone,Block) \
|
---|
13786 | ( ((PSINGLE_LIST_ENTRY)(Block))->Next = (Zone)->FreeList.Next, \
|
---|
13787 | (Zone)->FreeList.Next = ((PSINGLE_LIST_ENTRY)(Block)), \
|
---|
13788 | ((PSINGLE_LIST_ENTRY)(Block))->Next \
|
---|
13789 | )
|
---|
13790 |
|
---|
13791 | //++
|
---|
13792 | //
|
---|
13793 | // BOOLEAN
|
---|
13794 | // ExIsFullZone(
|
---|
13795 | // IN PZONE_HEADER Zone
|
---|
13796 | // )
|
---|
13797 | //
|
---|
13798 | // Routine Description:
|
---|
13799 | //
|
---|
13800 | // This routine determines if the specified zone is full or not. A zone
|
---|
13801 | // is considered full if the free list is empty.
|
---|
13802 | //
|
---|
13803 | // Arguments:
|
---|
13804 | //
|
---|
13805 | // Zone - Pointer to the zone header to be tested.
|
---|
13806 | //
|
---|
13807 | // Return Value:
|
---|
13808 | //
|
---|
13809 | // TRUE if the zone is full and FALSE otherwise.
|
---|
13810 | //
|
---|
13811 | //--
|
---|
13812 |
|
---|
13813 | #if PRAGMA_DEPRECATED_DDK
|
---|
13814 | #pragma deprecated(ExIsFullZone)
|
---|
13815 | #endif
|
---|
13816 | #define ExIsFullZone(Zone) \
|
---|
13817 | ( (Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY)NULL )
|
---|
13818 |
|
---|
13819 | //++
|
---|
13820 | //
|
---|
13821 | // PVOID
|
---|
13822 | // ExInterlockedAllocateFromZone(
|
---|
13823 | // IN PZONE_HEADER Zone,
|
---|
13824 | // IN PKSPIN_LOCK Lock
|
---|
13825 | // )
|
---|
13826 | //
|
---|
13827 | // Routine Description:
|
---|
13828 | //
|
---|
13829 | // This routine removes an entry from the zone and returns a pointer to it.
|
---|
13830 | // The removal is performed with the specified lock owned for the sequence
|
---|
13831 | // to make it MP-safe.
|
---|
13832 | //
|
---|
13833 | // Arguments:
|
---|
13834 | //
|
---|
13835 | // Zone - Pointer to the zone header controlling the storage from which the
|
---|
13836 | // entry is to be allocated.
|
---|
13837 | //
|
---|
13838 | // Lock - Pointer to the spin lock which should be obtained before removing
|
---|
13839 | // the entry from the allocation list. The lock is released before
|
---|
13840 | // returning to the caller.
|
---|
13841 | //
|
---|
13842 | // Return Value:
|
---|
13843 | //
|
---|
13844 | // The function value is a pointer to the storage allocated from the zone.
|
---|
13845 | //
|
---|
13846 | //--
|
---|
13847 |
|
---|
13848 | #if PRAGMA_DEPRECATED_DDK
|
---|
13849 | #pragma deprecated(ExInterlockedAllocateFromZone)
|
---|
13850 | #endif
|
---|
13851 | #define ExInterlockedAllocateFromZone(Zone,Lock) \
|
---|
13852 | (PVOID) ExInterlockedPopEntryList( &(Zone)->FreeList, Lock )
|
---|
13853 |
|
---|
13854 | //++
|
---|
13855 | //
|
---|
13856 | // PVOID
|
---|
13857 | // ExInterlockedFreeToZone(
|
---|
13858 | // IN PZONE_HEADER Zone,
|
---|
13859 | // IN PVOID Block,
|
---|
13860 | // IN PKSPIN_LOCK Lock
|
---|
13861 | // )
|
---|
13862 | //
|
---|
13863 | // Routine Description:
|
---|
13864 | //
|
---|
13865 | // This routine places the specified block of storage back onto the free
|
---|
13866 | // list in the specified zone. The insertion is performed with the lock
|
---|
13867 | // owned for the sequence to make it MP-safe.
|
---|
13868 | //
|
---|
13869 | // Arguments:
|
---|
13870 | //
|
---|
13871 | // Zone - Pointer to the zone header controlling the storage to which the
|
---|
13872 | // entry is to be inserted.
|
---|
13873 | //
|
---|
13874 | // Block - Pointer to the block of storage to be freed back to the zone.
|
---|
13875 | //
|
---|
13876 | // Lock - Pointer to the spin lock which should be obtained before inserting
|
---|
13877 | // the entry onto the free list. The lock is released before returning
|
---|
13878 | // to the caller.
|
---|
13879 | //
|
---|
13880 | // Return Value:
|
---|
13881 | //
|
---|
13882 | // Pointer to previous block of storage that was at the head of the free
|
---|
13883 | // list. NULL implies the zone went from no available free blocks to
|
---|
13884 | // at least one free block.
|
---|
13885 | //
|
---|
13886 | //--
|
---|
13887 |
|
---|
13888 | #if PRAGMA_DEPRECATED_DDK
|
---|
13889 | #pragma deprecated(ExInterlockedFreeToZone)
|
---|
13890 | #endif
|
---|
13891 | #define ExInterlockedFreeToZone(Zone,Block,Lock) \
|
---|
13892 | ExInterlockedPushEntryList( &(Zone)->FreeList, ((PSINGLE_LIST_ENTRY) (Block)), Lock )
|
---|
13893 |
|
---|
13894 |
|
---|
13895 | //++
|
---|
13896 | //
|
---|
13897 | // BOOLEAN
|
---|
13898 | // ExIsObjectInFirstZoneSegment(
|
---|
13899 | // IN PZONE_HEADER Zone,
|
---|
13900 | // IN PVOID Object
|
---|
13901 | // )
|
---|
13902 | //
|
---|
13903 | // Routine Description:
|
---|
13904 | //
|
---|
13905 | // This routine determines if the specified pointer lives in the zone.
|
---|
13906 | //
|
---|
13907 | // Arguments:
|
---|
13908 | //
|
---|
13909 | // Zone - Pointer to the zone header controlling the storage to which the
|
---|
13910 | // object may belong.
|
---|
13911 | //
|
---|
13912 | // Object - Pointer to the object in question.
|
---|
13913 | //
|
---|
13914 | // Return Value:
|
---|
13915 | //
|
---|
13916 | // TRUE if the Object came from the first segment of zone.
|
---|
13917 | //
|
---|
13918 | //--
|
---|
13919 |
|
---|
13920 | #if PRAGMA_DEPRECATED_DDK
|
---|
13921 | #pragma deprecated(ExIsObjectInFirstZoneSegment)
|
---|
13922 | #endif
|
---|
13923 | #define ExIsObjectInFirstZoneSegment(Zone,Object) ((BOOLEAN) \
|
---|
13924 | (((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
|
---|
13925 | ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
|
---|
13926 | (Zone)->TotalSegmentSize)) \
|
---|
13927 | )
|
---|
13928 |
|
---|
13929 | //
|
---|
13930 | // Define executive resource data structures.
|
---|
13931 | //
|
---|
13932 |
|
---|
13933 | typedef ULONG_PTR ERESOURCE_THREAD;
|
---|
13934 | typedef ERESOURCE_THREAD *PERESOURCE_THREAD;
|
---|
13935 |
|
---|
13936 | typedef struct _OWNER_ENTRY {
|
---|
13937 | ERESOURCE_THREAD OwnerThread;
|
---|
13938 | union {
|
---|
13939 | LONG OwnerCount;
|
---|
13940 | ULONG TableSize;
|
---|
13941 | };
|
---|
13942 |
|
---|
13943 | } OWNER_ENTRY, *POWNER_ENTRY;
|
---|
13944 |
|
---|
13945 | typedef struct _ERESOURCE {
|
---|
13946 | LIST_ENTRY SystemResourcesList;
|
---|
13947 | POWNER_ENTRY OwnerTable;
|
---|
13948 | SHORT ActiveCount;
|
---|
13949 | USHORT Flag;
|
---|
13950 | PKSEMAPHORE SharedWaiters;
|
---|
13951 | PKEVENT ExclusiveWaiters;
|
---|
13952 | OWNER_ENTRY OwnerThreads[2];
|
---|
13953 | ULONG ContentionCount;
|
---|
13954 | USHORT NumberOfSharedWaiters;
|
---|
13955 | USHORT NumberOfExclusiveWaiters;
|
---|
13956 | union {
|
---|
13957 | PVOID Address;
|
---|
13958 | ULONG_PTR CreatorBackTraceIndex;
|
---|
13959 | };
|
---|
13960 |
|
---|
13961 | KSPIN_LOCK SpinLock;
|
---|
13962 | } ERESOURCE, *PERESOURCE;
|
---|
13963 | //
|
---|
13964 | // Values for ERESOURCE.Flag
|
---|
13965 | //
|
---|
13966 |
|
---|
13967 | #define ResourceNeverExclusive 0x10
|
---|
13968 | #define ResourceReleaseByOtherThread 0x20
|
---|
13969 | #define ResourceOwnedExclusive 0x80
|
---|
13970 |
|
---|
13971 | #define RESOURCE_HASH_TABLE_SIZE 64
|
---|
13972 |
|
---|
13973 | typedef struct _RESOURCE_HASH_ENTRY {
|
---|
13974 | LIST_ENTRY ListEntry;
|
---|
13975 | PVOID Address;
|
---|
13976 | ULONG ContentionCount;
|
---|
13977 | ULONG Number;
|
---|
13978 | } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY;
|
---|
13979 |
|
---|
13980 | typedef struct _RESOURCE_PERFORMANCE_DATA {
|
---|
13981 | ULONG ActiveResourceCount;
|
---|
13982 | ULONG TotalResourceCount;
|
---|
13983 | ULONG ExclusiveAcquire;
|
---|
13984 | ULONG SharedFirstLevel;
|
---|
13985 | ULONG SharedSecondLevel;
|
---|
13986 | ULONG StarveFirstLevel;
|
---|
13987 | ULONG StarveSecondLevel;
|
---|
13988 | ULONG WaitForExclusive;
|
---|
13989 | ULONG OwnerTableExpands;
|
---|
13990 | ULONG MaximumTableExpand;
|
---|
13991 | LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE];
|
---|
13992 | } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA;
|
---|
13993 |
|
---|
13994 | //
|
---|
13995 | // Define executive resource function prototypes.
|
---|
13996 | //
|
---|
13997 | NTKERNELAPI
|
---|
13998 | NTSTATUS
|
---|
13999 | ExInitializeResourceLite(
|
---|
14000 | IN PERESOURCE Resource
|
---|
14001 | );
|
---|
14002 |
|
---|
14003 | NTKERNELAPI
|
---|
14004 | NTSTATUS
|
---|
14005 | ExReinitializeResourceLite(
|
---|
14006 | IN PERESOURCE Resource
|
---|
14007 | );
|
---|
14008 |
|
---|
14009 | NTKERNELAPI
|
---|
14010 | BOOLEAN
|
---|
14011 | ExAcquireResourceSharedLite(
|
---|
14012 | IN PERESOURCE Resource,
|
---|
14013 | IN BOOLEAN Wait
|
---|
14014 | );
|
---|
14015 |
|
---|
14016 | NTKERNELAPI
|
---|
14017 | BOOLEAN
|
---|
14018 | ExAcquireResourceExclusiveLite(
|
---|
14019 | IN PERESOURCE Resource,
|
---|
14020 | IN BOOLEAN Wait
|
---|
14021 | );
|
---|
14022 |
|
---|
14023 | NTKERNELAPI
|
---|
14024 | BOOLEAN
|
---|
14025 | ExAcquireSharedStarveExclusive(
|
---|
14026 | IN PERESOURCE Resource,
|
---|
14027 | IN BOOLEAN Wait
|
---|
14028 | );
|
---|
14029 |
|
---|
14030 | NTKERNELAPI
|
---|
14031 | BOOLEAN
|
---|
14032 | ExAcquireSharedWaitForExclusive(
|
---|
14033 | IN PERESOURCE Resource,
|
---|
14034 | IN BOOLEAN Wait
|
---|
14035 | );
|
---|
14036 |
|
---|
14037 | NTKERNELAPI
|
---|
14038 | BOOLEAN
|
---|
14039 | ExTryToAcquireResourceExclusiveLite(
|
---|
14040 | IN PERESOURCE Resource
|
---|
14041 | );
|
---|
14042 |
|
---|
14043 | //
|
---|
14044 | // VOID
|
---|
14045 | // ExReleaseResource(
|
---|
14046 | // IN PERESOURCE Resource
|
---|
14047 | // );
|
---|
14048 | //
|
---|
14049 |
|
---|
14050 | #if PRAGMA_DEPRECATED_DDK
|
---|
14051 | #pragma deprecated(ExReleaseResource) // Use ExReleaseResourceLite
|
---|
14052 | #endif
|
---|
14053 | #define ExReleaseResource(R) (ExReleaseResourceLite(R))
|
---|
14054 |
|
---|
14055 | NTKERNELAPI
|
---|
14056 | VOID
|
---|
14057 | FASTCALL
|
---|
14058 | ExReleaseResourceLite(
|
---|
14059 | IN PERESOURCE Resource
|
---|
14060 | );
|
---|
14061 |
|
---|
14062 | NTKERNELAPI
|
---|
14063 | VOID
|
---|
14064 | ExReleaseResourceForThreadLite(
|
---|
14065 | IN PERESOURCE Resource,
|
---|
14066 | IN ERESOURCE_THREAD ResourceThreadId
|
---|
14067 | );
|
---|
14068 |
|
---|
14069 | NTKERNELAPI
|
---|
14070 | VOID
|
---|
14071 | ExSetResourceOwnerPointer(
|
---|
14072 | IN PERESOURCE Resource,
|
---|
14073 | IN PVOID OwnerPointer
|
---|
14074 | );
|
---|
14075 |
|
---|
14076 | NTKERNELAPI
|
---|
14077 | VOID
|
---|
14078 | ExConvertExclusiveToSharedLite(
|
---|
14079 | IN PERESOURCE Resource
|
---|
14080 | );
|
---|
14081 |
|
---|
14082 | NTKERNELAPI
|
---|
14083 | NTSTATUS
|
---|
14084 | ExDeleteResourceLite (
|
---|
14085 | IN PERESOURCE Resource
|
---|
14086 | );
|
---|
14087 |
|
---|
14088 | NTKERNELAPI
|
---|
14089 | ULONG
|
---|
14090 | ExGetExclusiveWaiterCount (
|
---|
14091 | IN PERESOURCE Resource
|
---|
14092 | );
|
---|
14093 |
|
---|
14094 | NTKERNELAPI
|
---|
14095 | ULONG
|
---|
14096 | ExGetSharedWaiterCount (
|
---|
14097 | IN PERESOURCE Resource
|
---|
14098 | );
|
---|
14099 |
|
---|
14100 | //
|
---|
14101 | // ERESOURCE_THREAD
|
---|
14102 | // ExGetCurrentResourceThread(
|
---|
14103 | // );
|
---|
14104 | //
|
---|
14105 |
|
---|
14106 | #define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread())
|
---|
14107 |
|
---|
14108 | NTKERNELAPI
|
---|
14109 | BOOLEAN
|
---|
14110 | ExIsResourceAcquiredExclusiveLite (
|
---|
14111 | IN PERESOURCE Resource
|
---|
14112 | );
|
---|
14113 |
|
---|
14114 | NTKERNELAPI
|
---|
14115 | ULONG
|
---|
14116 | ExIsResourceAcquiredSharedLite (
|
---|
14117 | IN PERESOURCE Resource
|
---|
14118 | );
|
---|
14119 |
|
---|
14120 | //
|
---|
14121 | // An acquired resource is always owned shared, as shared ownership is a subset
|
---|
14122 | // of exclusive ownership.
|
---|
14123 | //
|
---|
14124 | #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite
|
---|
14125 |
|
---|
14126 |
|
---|
14127 | //
|
---|
14128 | // ntddk.h stole the entrypoints we wanted so fix them up here.
|
---|
14129 | //
|
---|
14130 |
|
---|
14131 | #if PRAGMA_DEPRECATED_DDK
|
---|
14132 | #pragma deprecated(ExInitializeResource) // use ExInitializeResourceLite
|
---|
14133 | #pragma deprecated(ExAcquireResourceShared) // use ExAcquireResourceSharedLite
|
---|
14134 | #pragma deprecated(ExAcquireResourceExclusive) // use ExAcquireResourceExclusiveLite
|
---|
14135 | #pragma deprecated(ExReleaseResourceForThread) // use ExReleaseResourceForThreadLite
|
---|
14136 | #pragma deprecated(ExConvertExclusiveToShared) // use ExConvertExclusiveToSharedLite
|
---|
14137 | #pragma deprecated(ExDeleteResource) // use ExDeleteResourceLite
|
---|
14138 | #pragma deprecated(ExIsResourceAcquiredExclusive) // use ExIsResourceAcquiredExclusiveLite
|
---|
14139 | #pragma deprecated(ExIsResourceAcquiredShared) // use ExIsResourceAcquiredSharedLite
|
---|
14140 | #pragma deprecated(ExIsResourceAcquired) // use ExIsResourceAcquiredSharedLite
|
---|
14141 | #endif
|
---|
14142 | #define ExInitializeResource ExInitializeResourceLite
|
---|
14143 | #define ExAcquireResourceShared ExAcquireResourceSharedLite
|
---|
14144 | #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
|
---|
14145 | #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
|
---|
14146 | #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
|
---|
14147 | #define ExDeleteResource ExDeleteResourceLite
|
---|
14148 | #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
|
---|
14149 | #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
|
---|
14150 | #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
|
---|
14151 |
|
---|
14152 | //
|
---|
14153 | // Get previous mode
|
---|
14154 | //
|
---|
14155 |
|
---|
14156 | NTKERNELAPI
|
---|
14157 | KPROCESSOR_MODE
|
---|
14158 | ExGetPreviousMode(
|
---|
14159 | VOID
|
---|
14160 | );
|
---|
14161 | //
|
---|
14162 | // Raise status from kernel mode.
|
---|
14163 | //
|
---|
14164 |
|
---|
14165 | NTKERNELAPI
|
---|
14166 | VOID
|
---|
14167 | NTAPI
|
---|
14168 | ExRaiseStatus (
|
---|
14169 | IN NTSTATUS Status
|
---|
14170 | );
|
---|
14171 |
|
---|
14172 |
|
---|
14173 |
|
---|
14174 | NTKERNELAPI
|
---|
14175 | VOID
|
---|
14176 | ExRaiseDatatypeMisalignment (
|
---|
14177 | VOID
|
---|
14178 | );
|
---|
14179 |
|
---|
14180 | NTKERNELAPI
|
---|
14181 | VOID
|
---|
14182 | ExRaiseAccessViolation (
|
---|
14183 | VOID
|
---|
14184 | );
|
---|
14185 |
|
---|
14186 | //
|
---|
14187 | // Set timer resolution.
|
---|
14188 | //
|
---|
14189 |
|
---|
14190 | NTKERNELAPI
|
---|
14191 | ULONG
|
---|
14192 | ExSetTimerResolution (
|
---|
14193 | IN ULONG DesiredTime,
|
---|
14194 | IN BOOLEAN SetResolution
|
---|
14195 | );
|
---|
14196 |
|
---|
14197 | //
|
---|
14198 | // Subtract time zone bias from system time to get local time.
|
---|
14199 | //
|
---|
14200 |
|
---|
14201 | NTKERNELAPI
|
---|
14202 | VOID
|
---|
14203 | ExSystemTimeToLocalTime (
|
---|
14204 | IN PLARGE_INTEGER SystemTime,
|
---|
14205 | OUT PLARGE_INTEGER LocalTime
|
---|
14206 | );
|
---|
14207 |
|
---|
14208 | //
|
---|
14209 | // Add time zone bias to local time to get system time.
|
---|
14210 | //
|
---|
14211 |
|
---|
14212 | NTKERNELAPI
|
---|
14213 | VOID
|
---|
14214 | ExLocalTimeToSystemTime (
|
---|
14215 | IN PLARGE_INTEGER LocalTime,
|
---|
14216 | OUT PLARGE_INTEGER SystemTime
|
---|
14217 | );
|
---|
14218 |
|
---|
14219 |
|
---|
14220 | //
|
---|
14221 | // Define the type for Callback function.
|
---|
14222 | //
|
---|
14223 |
|
---|
14224 | typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
|
---|
14225 |
|
---|
14226 | typedef VOID (*PCALLBACK_FUNCTION ) (
|
---|
14227 | IN PVOID CallbackContext,
|
---|
14228 | IN PVOID Argument1,
|
---|
14229 | IN PVOID Argument2
|
---|
14230 | );
|
---|
14231 |
|
---|
14232 |
|
---|
14233 | NTKERNELAPI
|
---|
14234 | NTSTATUS
|
---|
14235 | ExCreateCallback (
|
---|
14236 | OUT PCALLBACK_OBJECT *CallbackObject,
|
---|
14237 | IN POBJECT_ATTRIBUTES ObjectAttributes,
|
---|
14238 | IN BOOLEAN Create,
|
---|
14239 | IN BOOLEAN AllowMultipleCallbacks
|
---|
14240 | );
|
---|
14241 |
|
---|
14242 | NTKERNELAPI
|
---|
14243 | PVOID
|
---|
14244 | ExRegisterCallback (
|
---|
14245 | IN PCALLBACK_OBJECT CallbackObject,
|
---|
14246 | IN PCALLBACK_FUNCTION CallbackFunction,
|
---|
14247 | IN PVOID CallbackContext
|
---|
14248 | );
|
---|
14249 |
|
---|
14250 | NTKERNELAPI
|
---|
14251 | VOID
|
---|
14252 | ExUnregisterCallback (
|
---|
14253 | IN PVOID CallbackRegistration
|
---|
14254 | );
|
---|
14255 |
|
---|
14256 | NTKERNELAPI
|
---|
14257 | VOID
|
---|
14258 | ExNotifyCallback (
|
---|
14259 | IN PVOID CallbackObject,
|
---|
14260 | IN PVOID Argument1,
|
---|
14261 | IN PVOID Argument2
|
---|
14262 | );
|
---|
14263 |
|
---|
14264 |
|
---|
14265 |
|
---|
14266 | //
|
---|
14267 | // UUID Generation
|
---|
14268 | //
|
---|
14269 |
|
---|
14270 | typedef GUID UUID;
|
---|
14271 |
|
---|
14272 | NTKERNELAPI
|
---|
14273 | NTSTATUS
|
---|
14274 | ExUuidCreate(
|
---|
14275 | OUT UUID *Uuid
|
---|
14276 | );
|
---|
14277 |
|
---|
14278 | //
|
---|
14279 | // suite support
|
---|
14280 | //
|
---|
14281 |
|
---|
14282 | NTKERNELAPI
|
---|
14283 | BOOLEAN
|
---|
14284 | ExVerifySuite(
|
---|
14285 | SUITE_TYPE SuiteType
|
---|
14286 | );
|
---|
14287 |
|
---|
14288 |
|
---|
14289 | //
|
---|
14290 | // Define a block to hold the actual routine registration.
|
---|
14291 | //
|
---|
14292 | typedef NTSTATUS (*PEX_CALLBACK_FUNCTION ) (
|
---|
14293 | IN PVOID CallbackContext,
|
---|
14294 | IN PVOID Argument1,
|
---|
14295 | IN PVOID Argument2
|
---|
14296 | );
|
---|
14297 |
|
---|
14298 |
|
---|
14299 | //
|
---|
14300 | // Registry kernel mode callbacks
|
---|
14301 | //
|
---|
14302 |
|
---|
14303 | //
|
---|
14304 | // Hook selector
|
---|
14305 | //
|
---|
14306 | typedef enum _REG_NOTIFY_CLASS {
|
---|
14307 | RegNtDeleteKey,
|
---|
14308 | RegNtPreDeleteKey = RegNtDeleteKey,
|
---|
14309 | RegNtSetValueKey,
|
---|
14310 | RegNtPreSetValueKey = RegNtSetValueKey,
|
---|
14311 | RegNtDeleteValueKey,
|
---|
14312 | RegNtPreDeleteValueKey = RegNtDeleteValueKey,
|
---|
14313 | RegNtSetInformationKey,
|
---|
14314 | RegNtPreSetInformationKey = RegNtSetInformationKey,
|
---|
14315 | RegNtRenameKey,
|
---|
14316 | RegNtPreRenameKey = RegNtRenameKey,
|
---|
14317 | RegNtEnumerateKey,
|
---|
14318 | RegNtPreEnumerateKey = RegNtEnumerateKey,
|
---|
14319 | RegNtEnumerateValueKey,
|
---|
14320 | RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
|
---|
14321 | RegNtQueryKey,
|
---|
14322 | RegNtPreQueryKey = RegNtQueryKey,
|
---|
14323 | RegNtQueryValueKey,
|
---|
14324 | RegNtPreQueryValueKey = RegNtQueryValueKey,
|
---|
14325 | RegNtQueryMultipleValueKey,
|
---|
14326 | RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
|
---|
14327 | RegNtPreCreateKey,
|
---|
14328 | RegNtPostCreateKey,
|
---|
14329 | RegNtPreOpenKey,
|
---|
14330 | RegNtPostOpenKey,
|
---|
14331 | RegNtKeyHandleClose,
|
---|
14332 | RegNtPreKeyHandleClose = RegNtKeyHandleClose,
|
---|
14333 | //
|
---|
14334 | // .Net only
|
---|
14335 | //
|
---|
14336 | RegNtPostDeleteKey,
|
---|
14337 | RegNtPostSetValueKey,
|
---|
14338 | RegNtPostDeleteValueKey,
|
---|
14339 | RegNtPostSetInformationKey,
|
---|
14340 | RegNtPostRenameKey,
|
---|
14341 | RegNtPostEnumerateKey,
|
---|
14342 | RegNtPostEnumerateValueKey,
|
---|
14343 | RegNtPostQueryKey,
|
---|
14344 | RegNtPostQueryValueKey,
|
---|
14345 | RegNtPostQueryMultipleValueKey,
|
---|
14346 | RegNtPostKeyHandleClose,
|
---|
14347 | RegNtPreCreateKeyEx,
|
---|
14348 | RegNtPostCreateKeyEx,
|
---|
14349 | RegNtPreOpenKeyEx,
|
---|
14350 | RegNtPostOpenKeyEx
|
---|
14351 | } REG_NOTIFY_CLASS;
|
---|
14352 |
|
---|
14353 | //
|
---|
14354 | // Parameter description for each notify class
|
---|
14355 | //
|
---|
14356 | typedef struct _REG_DELETE_KEY_INFORMATION {
|
---|
14357 | PVOID Object; // IN
|
---|
14358 | } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION;
|
---|
14359 |
|
---|
14360 | typedef struct _REG_SET_VALUE_KEY_INFORMATION {
|
---|
14361 | PVOID Object; // IN
|
---|
14362 | PUNICODE_STRING ValueName; // IN
|
---|
14363 | ULONG TitleIndex; // IN
|
---|
14364 | ULONG Type; // IN
|
---|
14365 | PVOID Data; // IN
|
---|
14366 | ULONG DataSize; // IN
|
---|
14367 | } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
|
---|
14368 |
|
---|
14369 | typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
|
---|
14370 | PVOID Object; // IN
|
---|
14371 | PUNICODE_STRING ValueName; // IN
|
---|
14372 | } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
|
---|
14373 |
|
---|
14374 | typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
|
---|
14375 | PVOID Object; // IN
|
---|
14376 | KEY_SET_INFORMATION_CLASS KeySetInformationClass; // IN
|
---|
14377 | PVOID KeySetInformation; // IN
|
---|
14378 | ULONG KeySetInformationLength;// IN
|
---|
14379 | } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
|
---|
14380 |
|
---|
14381 | typedef struct _REG_ENUMERATE_KEY_INFORMATION {
|
---|
14382 | PVOID Object; // IN
|
---|
14383 | ULONG Index; // IN
|
---|
14384 | KEY_INFORMATION_CLASS KeyInformationClass; // IN
|
---|
14385 | PVOID KeyInformation; // IN
|
---|
14386 | ULONG Length; // IN
|
---|
14387 | PULONG ResultLength; // OUT
|
---|
14388 | } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
|
---|
14389 |
|
---|
14390 | typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
|
---|
14391 | PVOID Object; // IN
|
---|
14392 | ULONG Index; // IN
|
---|
14393 | KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass; // IN
|
---|
14394 | PVOID KeyValueInformation; // IN
|
---|
14395 | ULONG Length; // IN
|
---|
14396 | PULONG ResultLength; // OUT
|
---|
14397 | } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
|
---|
14398 |
|
---|
14399 | typedef struct _REG_QUERY_KEY_INFORMATION {
|
---|
14400 | PVOID Object; // IN
|
---|
14401 | KEY_INFORMATION_CLASS KeyInformationClass; // IN
|
---|
14402 | PVOID KeyInformation; // IN
|
---|
14403 | ULONG Length; // IN
|
---|
14404 | PULONG ResultLength; // OUT
|
---|
14405 | } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
|
---|
14406 |
|
---|
14407 | typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
|
---|
14408 | PVOID Object; // IN
|
---|
14409 | PUNICODE_STRING ValueName; // IN
|
---|
14410 | KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass; // IN
|
---|
14411 | PVOID KeyValueInformation; // IN
|
---|
14412 | ULONG Length; // IN
|
---|
14413 | PULONG ResultLength; // OUT
|
---|
14414 | } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
|
---|
14415 |
|
---|
14416 | typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
|
---|
14417 | PVOID Object; // IN
|
---|
14418 | PKEY_VALUE_ENTRY ValueEntries; // IN
|
---|
14419 | ULONG EntryCount; // IN
|
---|
14420 | PVOID ValueBuffer; // IN
|
---|
14421 | PULONG BufferLength; // IN OUT
|
---|
14422 | PULONG RequiredBufferLength; // OUT
|
---|
14423 | } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
|
---|
14424 |
|
---|
14425 | typedef struct _REG_RENAME_KEY_INFORMATION {
|
---|
14426 | PVOID Object; // IN
|
---|
14427 | PUNICODE_STRING NewName; // IN
|
---|
14428 | } REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION;
|
---|
14429 |
|
---|
14430 |
|
---|
14431 | typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
|
---|
14432 | PVOID Object; // IN
|
---|
14433 | } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
|
---|
14434 |
|
---|
14435 | /* .Net Only */
|
---|
14436 | typedef struct _REG_CREATE_KEY_INFORMATION {
|
---|
14437 | PUNICODE_STRING CompleteName; // IN
|
---|
14438 | PVOID RootObject; // IN
|
---|
14439 | } REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION;
|
---|
14440 |
|
---|
14441 | typedef struct _REG_POST_OPERATION_INFORMATION {
|
---|
14442 | PVOID Object; // IN
|
---|
14443 | NTSTATUS Status; // IN
|
---|
14444 | } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
|
---|
14445 | /* end .Net Only */
|
---|
14446 |
|
---|
14447 | /* XP only */
|
---|
14448 | typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
|
---|
14449 | PUNICODE_STRING CompleteName; // IN
|
---|
14450 | } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;;
|
---|
14451 |
|
---|
14452 | typedef struct _REG_POST_CREATE_KEY_INFORMATION {
|
---|
14453 | PUNICODE_STRING CompleteName; // IN
|
---|
14454 | PVOID Object; // IN
|
---|
14455 | NTSTATUS Status; // IN
|
---|
14456 | } REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
|
---|
14457 | /* end XP only */
|
---|
14458 |
|
---|
14459 |
|
---|
14460 | NTSTATUS
|
---|
14461 | CmRegisterCallback(IN PEX_CALLBACK_FUNCTION Function,
|
---|
14462 | IN PVOID Context,
|
---|
14463 | IN OUT PLARGE_INTEGER Cookie
|
---|
14464 | );
|
---|
14465 | NTSTATUS
|
---|
14466 | CmUnRegisterCallback(IN LARGE_INTEGER Cookie);
|
---|
14467 |
|
---|
14468 | //
|
---|
14469 | // Priority increment definitions. The comment for each definition gives
|
---|
14470 | // the names of the system services that use the definition when satisfying
|
---|
14471 | // a wait.
|
---|
14472 | //
|
---|
14473 |
|
---|
14474 | //
|
---|
14475 | // Priority increment used when satisfying a wait on an executive event
|
---|
14476 | // (NtPulseEvent and NtSetEvent)
|
---|
14477 | //
|
---|
14478 |
|
---|
14479 | #define EVENT_INCREMENT 1
|
---|
14480 |
|
---|
14481 | //
|
---|
14482 | // Priority increment when no I/O has been done. This is used by device
|
---|
14483 | // and file system drivers when completing an IRP (IoCompleteRequest).
|
---|
14484 | //
|
---|
14485 |
|
---|
14486 | #define IO_NO_INCREMENT 0
|
---|
14487 |
|
---|
14488 |
|
---|
14489 | //
|
---|
14490 | // Priority increment for completing CD-ROM I/O. This is used by CD-ROM device
|
---|
14491 | // and file system drivers when completing an IRP (IoCompleteRequest)
|
---|
14492 | //
|
---|
14493 |
|
---|
14494 | #define IO_CD_ROM_INCREMENT 1
|
---|
14495 |
|
---|
14496 | //
|
---|
14497 | // Priority increment for completing disk I/O. This is used by disk device
|
---|
14498 | // and file system drivers when completing an IRP (IoCompleteRequest)
|
---|
14499 | //
|
---|
14500 |
|
---|
14501 | #define IO_DISK_INCREMENT 1
|
---|
14502 |
|
---|
14503 |
|
---|
14504 |
|
---|
14505 | //
|
---|
14506 | // Priority increment for completing keyboard I/O. This is used by keyboard
|
---|
14507 | // device drivers when completing an IRP (IoCompleteRequest)
|
---|
14508 | //
|
---|
14509 |
|
---|
14510 | #define IO_KEYBOARD_INCREMENT 6
|
---|
14511 |
|
---|
14512 |
|
---|
14513 | //
|
---|
14514 | // Priority increment for completing mailslot I/O. This is used by the mail-
|
---|
14515 | // slot file system driver when completing an IRP (IoCompleteRequest).
|
---|
14516 | //
|
---|
14517 |
|
---|
14518 | #define IO_MAILSLOT_INCREMENT 2
|
---|
14519 |
|
---|
14520 |
|
---|
14521 | //
|
---|
14522 | // Priority increment for completing mouse I/O. This is used by mouse device
|
---|
14523 | // drivers when completing an IRP (IoCompleteRequest)
|
---|
14524 | //
|
---|
14525 |
|
---|
14526 | #define IO_MOUSE_INCREMENT 6
|
---|
14527 |
|
---|
14528 |
|
---|
14529 | //
|
---|
14530 | // Priority increment for completing named pipe I/O. This is used by the
|
---|
14531 | // named pipe file system driver when completing an IRP (IoCompleteRequest).
|
---|
14532 | //
|
---|
14533 |
|
---|
14534 | #define IO_NAMED_PIPE_INCREMENT 2
|
---|
14535 |
|
---|
14536 | //
|
---|
14537 | // Priority increment for completing network I/O. This is used by network
|
---|
14538 | // device and network file system drivers when completing an IRP
|
---|
14539 | // (IoCompleteRequest).
|
---|
14540 | //
|
---|
14541 |
|
---|
14542 | #define IO_NETWORK_INCREMENT 2
|
---|
14543 |
|
---|
14544 |
|
---|
14545 | //
|
---|
14546 | // Priority increment for completing parallel I/O. This is used by parallel
|
---|
14547 | // device drivers when completing an IRP (IoCompleteRequest)
|
---|
14548 | //
|
---|
14549 |
|
---|
14550 | #define IO_PARALLEL_INCREMENT 1
|
---|
14551 |
|
---|
14552 | //
|
---|
14553 | // Priority increment for completing serial I/O. This is used by serial device
|
---|
14554 | // drivers when completing an IRP (IoCompleteRequest)
|
---|
14555 | //
|
---|
14556 |
|
---|
14557 | #define IO_SERIAL_INCREMENT 2
|
---|
14558 |
|
---|
14559 | //
|
---|
14560 | // Priority increment for completing sound I/O. This is used by sound device
|
---|
14561 | // drivers when completing an IRP (IoCompleteRequest)
|
---|
14562 | //
|
---|
14563 |
|
---|
14564 | #define IO_SOUND_INCREMENT 8
|
---|
14565 |
|
---|
14566 | //
|
---|
14567 | // Priority increment for completing video I/O. This is used by video device
|
---|
14568 | // drivers when completing an IRP (IoCompleteRequest)
|
---|
14569 | //
|
---|
14570 |
|
---|
14571 | #define IO_VIDEO_INCREMENT 1
|
---|
14572 |
|
---|
14573 | //
|
---|
14574 | // Priority increment used when satisfying a wait on an executive semaphore
|
---|
14575 | // (NtReleaseSemaphore)
|
---|
14576 | //
|
---|
14577 |
|
---|
14578 | #define SEMAPHORE_INCREMENT 1
|
---|
14579 |
|
---|
14580 | //
|
---|
14581 | // Indicates the system may do I/O to physical addresses above 4 GB.
|
---|
14582 | //
|
---|
14583 |
|
---|
14584 | extern PBOOLEAN Mm64BitPhysicalAddress;
|
---|
14585 |
|
---|
14586 |
|
---|
14587 | //
|
---|
14588 | // Define maximum disk transfer size to be used by MM and Cache Manager,
|
---|
14589 | // so that packet-oriented disk drivers can optimize their packet allocation
|
---|
14590 | // to this size.
|
---|
14591 | //
|
---|
14592 |
|
---|
14593 | #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
|
---|
14594 |
|
---|
14595 | //++
|
---|
14596 | //
|
---|
14597 | // ULONG_PTR
|
---|
14598 | // ROUND_TO_PAGES (
|
---|
14599 | // IN ULONG_PTR Size
|
---|
14600 | // )
|
---|
14601 | //
|
---|
14602 | // Routine Description:
|
---|
14603 | //
|
---|
14604 | // The ROUND_TO_PAGES macro takes a size in bytes and rounds it up to a
|
---|
14605 | // multiple of the page size.
|
---|
14606 | //
|
---|
14607 | // NOTE: This macro fails for values 0xFFFFFFFF - (PAGE_SIZE - 1).
|
---|
14608 | //
|
---|
14609 | // Arguments:
|
---|
14610 | //
|
---|
14611 | // Size - Size in bytes to round up to a page multiple.
|
---|
14612 | //
|
---|
14613 | // Return Value:
|
---|
14614 | //
|
---|
14615 | // Returns the size rounded up to a multiple of the page size.
|
---|
14616 | //
|
---|
14617 | //--
|
---|
14618 |
|
---|
14619 | #define ROUND_TO_PAGES(Size) (((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
|
---|
14620 |
|
---|
14621 | //++
|
---|
14622 | //
|
---|
14623 | // ULONG
|
---|
14624 | // BYTES_TO_PAGES (
|
---|
14625 | // IN ULONG Size
|
---|
14626 | // )
|
---|
14627 | //
|
---|
14628 | // Routine Description:
|
---|
14629 | //
|
---|
14630 | // The BYTES_TO_PAGES macro takes the size in bytes and calculates the
|
---|
14631 | // number of pages required to contain the bytes.
|
---|
14632 | //
|
---|
14633 | // Arguments:
|
---|
14634 | //
|
---|
14635 | // Size - Size in bytes.
|
---|
14636 | //
|
---|
14637 | // Return Value:
|
---|
14638 | //
|
---|
14639 | // Returns the number of pages required to contain the specified size.
|
---|
14640 | //
|
---|
14641 | //--
|
---|
14642 |
|
---|
14643 | #define BYTES_TO_PAGES(Size) (((Size) >> PAGE_SHIFT) + \
|
---|
14644 | (((Size) & (PAGE_SIZE - 1)) != 0))
|
---|
14645 |
|
---|
14646 | //++
|
---|
14647 | //
|
---|
14648 | // ULONG
|
---|
14649 | // BYTE_OFFSET (
|
---|
14650 | // IN PVOID Va
|
---|
14651 | // )
|
---|
14652 | //
|
---|
14653 | // Routine Description:
|
---|
14654 | //
|
---|
14655 | // The BYTE_OFFSET macro takes a virtual address and returns the byte offset
|
---|
14656 | // of that address within the page.
|
---|
14657 | //
|
---|
14658 | // Arguments:
|
---|
14659 | //
|
---|
14660 | // Va - Virtual address.
|
---|
14661 | //
|
---|
14662 | // Return Value:
|
---|
14663 | //
|
---|
14664 | // Returns the byte offset portion of the virtual address.
|
---|
14665 | //
|
---|
14666 | //--
|
---|
14667 |
|
---|
14668 | #define BYTE_OFFSET(Va) ((ULONG)((LONG_PTR)(Va) & (PAGE_SIZE - 1)))
|
---|
14669 |
|
---|
14670 | //++
|
---|
14671 | //
|
---|
14672 | // PVOID
|
---|
14673 | // PAGE_ALIGN (
|
---|
14674 | // IN PVOID Va
|
---|
14675 | // )
|
---|
14676 | //
|
---|
14677 | // Routine Description:
|
---|
14678 | //
|
---|
14679 | // The PAGE_ALIGN macro takes a virtual address and returns a page-aligned
|
---|
14680 | // virtual address for that page.
|
---|
14681 | //
|
---|
14682 | // Arguments:
|
---|
14683 | //
|
---|
14684 | // Va - Virtual address.
|
---|
14685 | //
|
---|
14686 | // Return Value:
|
---|
14687 | //
|
---|
14688 | // Returns the page aligned virtual address.
|
---|
14689 | //
|
---|
14690 | //--
|
---|
14691 |
|
---|
14692 | #define PAGE_ALIGN(Va) ((PVOID)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
|
---|
14693 |
|
---|
14694 | //++
|
---|
14695 | //
|
---|
14696 | // ULONG
|
---|
14697 | // ADDRESS_AND_SIZE_TO_SPAN_PAGES (
|
---|
14698 | // IN PVOID Va,
|
---|
14699 | // IN ULONG Size
|
---|
14700 | // )
|
---|
14701 | //
|
---|
14702 | // Routine Description:
|
---|
14703 | //
|
---|
14704 | // The ADDRESS_AND_SIZE_TO_SPAN_PAGES macro takes a virtual address and
|
---|
14705 | // size and returns the number of pages spanned by the size.
|
---|
14706 | //
|
---|
14707 | // Arguments:
|
---|
14708 | //
|
---|
14709 | // Va - Virtual address.
|
---|
14710 | //
|
---|
14711 | // Size - Size in bytes.
|
---|
14712 | //
|
---|
14713 | // Return Value:
|
---|
14714 | //
|
---|
14715 | // Returns the number of pages spanned by the size.
|
---|
14716 | //
|
---|
14717 | //--
|
---|
14718 |
|
---|
14719 | #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) \
|
---|
14720 | ((ULONG)((((ULONG_PTR)(Va) & (PAGE_SIZE -1)) + (Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
|
---|
14721 |
|
---|
14722 | #if PRAGMA_DEPRECATED_DDK
|
---|
14723 | #pragma deprecated(COMPUTE_PAGES_SPANNED) // Use ADDRESS_AND_SIZE_TO_SPAN_PAGES
|
---|
14724 | #endif
|
---|
14725 |
|
---|
14726 | #define COMPUTE_PAGES_SPANNED(Va, Size) ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
|
---|
14727 |
|
---|
14728 |
|
---|
14729 | //++
|
---|
14730 | // PPFN_NUMBER
|
---|
14731 | // MmGetMdlPfnArray (
|
---|
14732 | // IN PMDL Mdl
|
---|
14733 | // )
|
---|
14734 | //
|
---|
14735 | // Routine Description:
|
---|
14736 | //
|
---|
14737 | // The MmGetMdlPfnArray routine returns the virtual address of the
|
---|
14738 | // first element of the array of physical page numbers associated with
|
---|
14739 | // the MDL.
|
---|
14740 | //
|
---|
14741 | // Arguments:
|
---|
14742 | //
|
---|
14743 | // Mdl - Pointer to an MDL.
|
---|
14744 | //
|
---|
14745 | // Return Value:
|
---|
14746 | //
|
---|
14747 | // Returns the virtual address of the first element of the array of
|
---|
14748 | // physical page numbers associated with the MDL.
|
---|
14749 | //
|
---|
14750 | //--
|
---|
14751 |
|
---|
14752 | #define MmGetMdlPfnArray(Mdl) ((PPFN_NUMBER)(Mdl + 1))
|
---|
14753 |
|
---|
14754 | //++
|
---|
14755 | //
|
---|
14756 | // PVOID
|
---|
14757 | // MmGetMdlVirtualAddress (
|
---|
14758 | // IN PMDL Mdl
|
---|
14759 | // )
|
---|
14760 | //
|
---|
14761 | // Routine Description:
|
---|
14762 | //
|
---|
14763 | // The MmGetMdlVirtualAddress returns the virtual address of the buffer
|
---|
14764 | // described by the Mdl.
|
---|
14765 | //
|
---|
14766 | // Arguments:
|
---|
14767 | //
|
---|
14768 | // Mdl - Pointer to an MDL.
|
---|
14769 | //
|
---|
14770 | // Return Value:
|
---|
14771 | //
|
---|
14772 | // Returns the virtual address of the buffer described by the Mdl
|
---|
14773 | //
|
---|
14774 | //--
|
---|
14775 |
|
---|
14776 | #define MmGetMdlVirtualAddress(Mdl) \
|
---|
14777 | ((PVOID) ((PCHAR) ((Mdl)->StartVa) + (Mdl)->ByteOffset))
|
---|
14778 |
|
---|
14779 | //++
|
---|
14780 | //
|
---|
14781 | // ULONG
|
---|
14782 | // MmGetMdlByteCount (
|
---|
14783 | // IN PMDL Mdl
|
---|
14784 | // )
|
---|
14785 | //
|
---|
14786 | // Routine Description:
|
---|
14787 | //
|
---|
14788 | // The MmGetMdlByteCount returns the length in bytes of the buffer
|
---|
14789 | // described by the Mdl.
|
---|
14790 | //
|
---|
14791 | // Arguments:
|
---|
14792 | //
|
---|
14793 | // Mdl - Pointer to an MDL.
|
---|
14794 | //
|
---|
14795 | // Return Value:
|
---|
14796 | //
|
---|
14797 | // Returns the byte count of the buffer described by the Mdl
|
---|
14798 | //
|
---|
14799 | //--
|
---|
14800 |
|
---|
14801 | #define MmGetMdlByteCount(Mdl) ((Mdl)->ByteCount)
|
---|
14802 |
|
---|
14803 | //++
|
---|
14804 | //
|
---|
14805 | // ULONG
|
---|
14806 | // MmGetMdlByteOffset (
|
---|
14807 | // IN PMDL Mdl
|
---|
14808 | // )
|
---|
14809 | //
|
---|
14810 | // Routine Description:
|
---|
14811 | //
|
---|
14812 | // The MmGetMdlByteOffset returns the byte offset within the page
|
---|
14813 | // of the buffer described by the Mdl.
|
---|
14814 | //
|
---|
14815 | // Arguments:
|
---|
14816 | //
|
---|
14817 | // Mdl - Pointer to an MDL.
|
---|
14818 | //
|
---|
14819 | // Return Value:
|
---|
14820 | //
|
---|
14821 | // Returns the byte offset within the page of the buffer described by the Mdl
|
---|
14822 | //
|
---|
14823 | //--
|
---|
14824 |
|
---|
14825 | #define MmGetMdlByteOffset(Mdl) ((Mdl)->ByteOffset)
|
---|
14826 |
|
---|
14827 | //++
|
---|
14828 | //
|
---|
14829 | // PVOID
|
---|
14830 | // MmGetMdlStartVa (
|
---|
14831 | // IN PMDL Mdl
|
---|
14832 | // )
|
---|
14833 | //
|
---|
14834 | // Routine Description:
|
---|
14835 | //
|
---|
14836 | // The MmGetMdlBaseVa returns the virtual address of the buffer
|
---|
14837 | // described by the Mdl rounded down to the nearest page.
|
---|
14838 | //
|
---|
14839 | // Arguments:
|
---|
14840 | //
|
---|
14841 | // Mdl - Pointer to an MDL.
|
---|
14842 | //
|
---|
14843 | // Return Value:
|
---|
14844 | //
|
---|
14845 | // Returns the returns the starting virtual address of the MDL.
|
---|
14846 | //
|
---|
14847 | //
|
---|
14848 | //--
|
---|
14849 |
|
---|
14850 | #define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa)
|
---|
14851 |
|
---|
14852 | typedef enum _MM_SYSTEM_SIZE {
|
---|
14853 | MmSmallSystem,
|
---|
14854 | MmMediumSystem,
|
---|
14855 | MmLargeSystem
|
---|
14856 | } MM_SYSTEMSIZE;
|
---|
14857 |
|
---|
14858 | NTKERNELAPI
|
---|
14859 | MM_SYSTEMSIZE
|
---|
14860 | MmQuerySystemSize (
|
---|
14861 | VOID
|
---|
14862 | );
|
---|
14863 |
|
---|
14864 |
|
---|
14865 |
|
---|
14866 | NTKERNELAPI
|
---|
14867 | BOOLEAN
|
---|
14868 | MmIsThisAnNtAsSystem (
|
---|
14869 | VOID
|
---|
14870 | );
|
---|
14871 |
|
---|
14872 |
|
---|
14873 | NTSTATUS
|
---|
14874 | MmIsVerifierEnabled (
|
---|
14875 | OUT PULONG VerifierFlags
|
---|
14876 | );
|
---|
14877 |
|
---|
14878 | NTSTATUS
|
---|
14879 | MmAddVerifierThunks (
|
---|
14880 | IN PVOID ThunkBuffer,
|
---|
14881 | IN ULONG ThunkBufferSize
|
---|
14882 | );
|
---|
14883 |
|
---|
14884 |
|
---|
14885 | NTKERNELAPI
|
---|
14886 | VOID
|
---|
14887 | MmProbeAndLockProcessPages (
|
---|
14888 | IN OUT PMDL MemoryDescriptorList,
|
---|
14889 | IN PEPROCESS Process,
|
---|
14890 | IN KPROCESSOR_MODE AccessMode,
|
---|
14891 | IN LOCK_OPERATION Operation
|
---|
14892 | );
|
---|
14893 |
|
---|
14894 |
|
---|
14895 |
|
---|
14896 | //
|
---|
14897 | // I/O support routines.
|
---|
14898 | //
|
---|
14899 |
|
---|
14900 | NTKERNELAPI
|
---|
14901 | VOID
|
---|
14902 | MmProbeAndLockPages (
|
---|
14903 | IN OUT PMDL MemoryDescriptorList,
|
---|
14904 | IN KPROCESSOR_MODE AccessMode,
|
---|
14905 | IN LOCK_OPERATION Operation
|
---|
14906 | );
|
---|
14907 |
|
---|
14908 |
|
---|
14909 | NTKERNELAPI
|
---|
14910 | VOID
|
---|
14911 | MmUnlockPages (
|
---|
14912 | IN PMDL MemoryDescriptorList
|
---|
14913 | );
|
---|
14914 |
|
---|
14915 |
|
---|
14916 | NTKERNELAPI
|
---|
14917 | VOID
|
---|
14918 | MmBuildMdlForNonPagedPool (
|
---|
14919 | IN OUT PMDL MemoryDescriptorList
|
---|
14920 | );
|
---|
14921 |
|
---|
14922 | NTKERNELAPI
|
---|
14923 | PVOID
|
---|
14924 | MmMapLockedPages (
|
---|
14925 | IN PMDL MemoryDescriptorList,
|
---|
14926 | IN KPROCESSOR_MODE AccessMode
|
---|
14927 | );
|
---|
14928 |
|
---|
14929 | LOGICAL
|
---|
14930 | MmIsIoSpaceActive (
|
---|
14931 | IN PHYSICAL_ADDRESS StartAddress,
|
---|
14932 | IN SIZE_T NumberOfBytes
|
---|
14933 | );
|
---|
14934 |
|
---|
14935 | NTKERNELAPI
|
---|
14936 | PVOID
|
---|
14937 | MmGetSystemRoutineAddress (
|
---|
14938 | IN PUNICODE_STRING SystemRoutineName
|
---|
14939 | );
|
---|
14940 |
|
---|
14941 | NTKERNELAPI
|
---|
14942 | NTSTATUS
|
---|
14943 | MmAdvanceMdl (
|
---|
14944 | IN PMDL Mdl,
|
---|
14945 | IN ULONG NumberOfBytes
|
---|
14946 | );
|
---|
14947 |
|
---|
14948 |
|
---|
14949 |
|
---|
14950 | NTKERNELAPI
|
---|
14951 | NTSTATUS
|
---|
14952 | MmMapUserAddressesToPage (
|
---|
14953 | IN PVOID BaseAddress,
|
---|
14954 | IN SIZE_T NumberOfBytes,
|
---|
14955 | IN PVOID PageAddress
|
---|
14956 | );
|
---|
14957 |
|
---|
14958 |
|
---|
14959 | NTKERNELAPI
|
---|
14960 | NTSTATUS
|
---|
14961 | MmProtectMdlSystemAddress (
|
---|
14962 | IN PMDL MemoryDescriptorList,
|
---|
14963 | IN ULONG NewProtect
|
---|
14964 | );
|
---|
14965 |
|
---|
14966 | //
|
---|
14967 | // _MM_PAGE_PRIORITY_ provides a method for the system to handle requests
|
---|
14968 | // intelligently in low resource conditions.
|
---|
14969 | //
|
---|
14970 | // LowPagePriority should be used when it is acceptable to the driver for the
|
---|
14971 | // mapping request to fail if the system is low on resources. An example of
|
---|
14972 | // this could be for a non-critical network connection where the driver can
|
---|
14973 | // handle the failure case when system resources are close to being depleted.
|
---|
14974 | //
|
---|
14975 | // NormalPagePriority should be used when it is acceptable to the driver for the
|
---|
14976 | // mapping request to fail if the system is very low on resources. An example
|
---|
14977 | // of this could be for a non-critical local filesystem request.
|
---|
14978 | //
|
---|
14979 | // HighPagePriority should be used when it is unacceptable to the driver for the
|
---|
14980 | // mapping request to fail unless the system is completely out of resources.
|
---|
14981 | // An example of this would be the paging file path in a driver.
|
---|
14982 | //
|
---|
14983 |
|
---|
14984 |
|
---|
14985 |
|
---|
14986 | typedef enum _MM_PAGE_PRIORITY {
|
---|
14987 | LowPagePriority,
|
---|
14988 | NormalPagePriority = 16,
|
---|
14989 | HighPagePriority = 32
|
---|
14990 | } MM_PAGE_PRIORITY;
|
---|
14991 |
|
---|
14992 |
|
---|
14993 |
|
---|
14994 | //
|
---|
14995 | // Note: This function is not available in WDM 1.0
|
---|
14996 | //
|
---|
14997 | NTKERNELAPI
|
---|
14998 | PVOID
|
---|
14999 | MmMapLockedPagesSpecifyCache (
|
---|
15000 | IN PMDL MemoryDescriptorList,
|
---|
15001 | IN KPROCESSOR_MODE AccessMode,
|
---|
15002 | IN MEMORY_CACHING_TYPE CacheType,
|
---|
15003 | IN PVOID BaseAddress,
|
---|
15004 | IN ULONG BugCheckOnFailure,
|
---|
15005 | IN MM_PAGE_PRIORITY Priority
|
---|
15006 | );
|
---|
15007 |
|
---|
15008 | NTKERNELAPI
|
---|
15009 | VOID
|
---|
15010 | MmUnmapLockedPages (
|
---|
15011 | IN PVOID BaseAddress,
|
---|
15012 | IN PMDL MemoryDescriptorList
|
---|
15013 | );
|
---|
15014 |
|
---|
15015 | PVOID
|
---|
15016 | MmAllocateMappingAddress (
|
---|
15017 | IN SIZE_T NumberOfBytes,
|
---|
15018 | IN ULONG PoolTag
|
---|
15019 | );
|
---|
15020 |
|
---|
15021 | VOID
|
---|
15022 | MmFreeMappingAddress (
|
---|
15023 | IN PVOID BaseAddress,
|
---|
15024 | IN ULONG PoolTag
|
---|
15025 | );
|
---|
15026 |
|
---|
15027 | PVOID
|
---|
15028 | MmMapLockedPagesWithReservedMapping (
|
---|
15029 | IN PVOID MappingAddress,
|
---|
15030 | IN ULONG PoolTag,
|
---|
15031 | IN PMDL MemoryDescriptorList,
|
---|
15032 | IN MEMORY_CACHING_TYPE CacheType
|
---|
15033 | );
|
---|
15034 |
|
---|
15035 | VOID
|
---|
15036 | MmUnmapReservedMapping (
|
---|
15037 | IN PVOID BaseAddress,
|
---|
15038 | IN ULONG PoolTag,
|
---|
15039 | IN PMDL MemoryDescriptorList
|
---|
15040 | );
|
---|
15041 |
|
---|
15042 |
|
---|
15043 |
|
---|
15044 | typedef struct _PHYSICAL_MEMORY_RANGE {
|
---|
15045 | PHYSICAL_ADDRESS BaseAddress;
|
---|
15046 | LARGE_INTEGER NumberOfBytes;
|
---|
15047 | } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
|
---|
15048 |
|
---|
15049 | NTKERNELAPI
|
---|
15050 | NTSTATUS
|
---|
15051 | MmAddPhysicalMemory (
|
---|
15052 | IN PPHYSICAL_ADDRESS StartAddress,
|
---|
15053 | IN OUT PLARGE_INTEGER NumberOfBytes
|
---|
15054 | );
|
---|
15055 |
|
---|
15056 |
|
---|
15057 | NTKERNELAPI
|
---|
15058 | NTSTATUS
|
---|
15059 | MmRemovePhysicalMemory (
|
---|
15060 | IN PPHYSICAL_ADDRESS StartAddress,
|
---|
15061 | IN OUT PLARGE_INTEGER NumberOfBytes
|
---|
15062 | );
|
---|
15063 |
|
---|
15064 |
|
---|
15065 | NTKERNELAPI
|
---|
15066 | PPHYSICAL_MEMORY_RANGE
|
---|
15067 | MmGetPhysicalMemoryRanges (
|
---|
15068 | VOID
|
---|
15069 | );
|
---|
15070 |
|
---|
15071 |
|
---|
15072 | NTKERNELAPI
|
---|
15073 | PMDL
|
---|
15074 | MmAllocatePagesForMdl (
|
---|
15075 | IN PHYSICAL_ADDRESS LowAddress,
|
---|
15076 | IN PHYSICAL_ADDRESS HighAddress,
|
---|
15077 | IN PHYSICAL_ADDRESS SkipBytes,
|
---|
15078 | IN SIZE_T TotalBytes
|
---|
15079 | );
|
---|
15080 |
|
---|
15081 | NTKERNELAPI
|
---|
15082 | VOID
|
---|
15083 | MmFreePagesFromMdl (
|
---|
15084 | IN PMDL MemoryDescriptorList
|
---|
15085 | );
|
---|
15086 |
|
---|
15087 | NTKERNELAPI
|
---|
15088 | PVOID
|
---|
15089 | MmMapIoSpace (
|
---|
15090 | IN PHYSICAL_ADDRESS PhysicalAddress,
|
---|
15091 | IN SIZE_T NumberOfBytes,
|
---|
15092 | IN MEMORY_CACHING_TYPE CacheType
|
---|
15093 | );
|
---|
15094 |
|
---|
15095 | NTKERNELAPI
|
---|
15096 | VOID
|
---|
15097 | MmUnmapIoSpace (
|
---|
15098 | IN PVOID BaseAddress,
|
---|
15099 | IN SIZE_T NumberOfBytes
|
---|
15100 | );
|
---|
15101 |
|
---|
15102 |
|
---|
15103 | NTKERNELAPI
|
---|
15104 | PVOID
|
---|
15105 | MmMapVideoDisplay (
|
---|
15106 | IN PHYSICAL_ADDRESS PhysicalAddress,
|
---|
15107 | IN SIZE_T NumberOfBytes,
|
---|
15108 | IN MEMORY_CACHING_TYPE CacheType
|
---|
15109 | );
|
---|
15110 |
|
---|
15111 | NTKERNELAPI
|
---|
15112 | VOID
|
---|
15113 | MmUnmapVideoDisplay (
|
---|
15114 | IN PVOID BaseAddress,
|
---|
15115 | IN SIZE_T NumberOfBytes
|
---|
15116 | );
|
---|
15117 |
|
---|
15118 | NTKERNELAPI
|
---|
15119 | PHYSICAL_ADDRESS
|
---|
15120 | MmGetPhysicalAddress (
|
---|
15121 | IN PVOID BaseAddress
|
---|
15122 | );
|
---|
15123 |
|
---|
15124 | NTKERNELAPI
|
---|
15125 | PVOID
|
---|
15126 | MmGetVirtualForPhysical (
|
---|
15127 | IN PHYSICAL_ADDRESS PhysicalAddress
|
---|
15128 | );
|
---|
15129 |
|
---|
15130 | NTKERNELAPI
|
---|
15131 | PVOID
|
---|
15132 | MmAllocateContiguousMemory (
|
---|
15133 | IN SIZE_T NumberOfBytes,
|
---|
15134 | IN PHYSICAL_ADDRESS HighestAcceptableAddress
|
---|
15135 | );
|
---|
15136 |
|
---|
15137 | NTKERNELAPI
|
---|
15138 | PVOID
|
---|
15139 | MmAllocateContiguousMemorySpecifyCache (
|
---|
15140 | IN SIZE_T NumberOfBytes,
|
---|
15141 | IN PHYSICAL_ADDRESS LowestAcceptableAddress,
|
---|
15142 | IN PHYSICAL_ADDRESS HighestAcceptableAddress,
|
---|
15143 | IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
|
---|
15144 | IN MEMORY_CACHING_TYPE CacheType
|
---|
15145 | );
|
---|
15146 |
|
---|
15147 | NTKERNELAPI
|
---|
15148 | VOID
|
---|
15149 | MmFreeContiguousMemory (
|
---|
15150 | IN PVOID BaseAddress
|
---|
15151 | );
|
---|
15152 |
|
---|
15153 | NTKERNELAPI
|
---|
15154 | VOID
|
---|
15155 | MmFreeContiguousMemorySpecifyCache (
|
---|
15156 | IN PVOID BaseAddress,
|
---|
15157 | IN SIZE_T NumberOfBytes,
|
---|
15158 | IN MEMORY_CACHING_TYPE CacheType
|
---|
15159 | );
|
---|
15160 |
|
---|
15161 |
|
---|
15162 | NTKERNELAPI
|
---|
15163 | PVOID
|
---|
15164 | MmAllocateNonCachedMemory (
|
---|
15165 | IN SIZE_T NumberOfBytes
|
---|
15166 | );
|
---|
15167 |
|
---|
15168 | NTKERNELAPI
|
---|
15169 | VOID
|
---|
15170 | MmFreeNonCachedMemory (
|
---|
15171 | IN PVOID BaseAddress,
|
---|
15172 | IN SIZE_T NumberOfBytes
|
---|
15173 | );
|
---|
15174 |
|
---|
15175 | NTKERNELAPI
|
---|
15176 | BOOLEAN
|
---|
15177 | MmIsAddressValid (
|
---|
15178 | IN PVOID VirtualAddress
|
---|
15179 | );
|
---|
15180 |
|
---|
15181 | DECLSPEC_DEPRECATED_DDK
|
---|
15182 | NTKERNELAPI
|
---|
15183 | BOOLEAN
|
---|
15184 | MmIsNonPagedSystemAddressValid (
|
---|
15185 | IN PVOID VirtualAddress
|
---|
15186 | );
|
---|
15187 |
|
---|
15188 |
|
---|
15189 |
|
---|
15190 | NTKERNELAPI
|
---|
15191 | SIZE_T
|
---|
15192 | MmSizeOfMdl (
|
---|
15193 | IN PVOID Base,
|
---|
15194 | IN SIZE_T Length
|
---|
15195 | );
|
---|
15196 |
|
---|
15197 | DECLSPEC_DEPRECATED_DDK // Use IoAllocateMdl
|
---|
15198 | NTKERNELAPI
|
---|
15199 | PMDL
|
---|
15200 | MmCreateMdl (
|
---|
15201 | IN PMDL MemoryDescriptorList OPTIONAL,
|
---|
15202 | IN PVOID Base,
|
---|
15203 | IN SIZE_T Length
|
---|
15204 | );
|
---|
15205 |
|
---|
15206 | NTKERNELAPI
|
---|
15207 | PVOID
|
---|
15208 | MmLockPagableDataSection (
|
---|
15209 | IN PVOID AddressWithinSection
|
---|
15210 | );
|
---|
15211 |
|
---|
15212 |
|
---|
15213 |
|
---|
15214 | NTKERNELAPI
|
---|
15215 | VOID
|
---|
15216 | MmLockPagableSectionByHandle (
|
---|
15217 | IN PVOID ImageSectionHandle
|
---|
15218 | );
|
---|
15219 |
|
---|
15220 | NTKERNELAPI
|
---|
15221 | VOID
|
---|
15222 | MmResetDriverPaging (
|
---|
15223 | IN PVOID AddressWithinSection
|
---|
15224 | );
|
---|
15225 |
|
---|
15226 |
|
---|
15227 | NTKERNELAPI
|
---|
15228 | PVOID
|
---|
15229 | MmPageEntireDriver (
|
---|
15230 | IN PVOID AddressWithinSection
|
---|
15231 | );
|
---|
15232 |
|
---|
15233 | NTKERNELAPI
|
---|
15234 | VOID
|
---|
15235 | MmUnlockPagableImageSection(
|
---|
15236 | IN PVOID ImageSectionHandle
|
---|
15237 | );
|
---|
15238 |
|
---|
15239 |
|
---|
15240 |
|
---|
15241 |
|
---|
15242 |
|
---|
15243 | //
|
---|
15244 | // Note that even though this function prototype
|
---|
15245 | // says "HANDLE", MmSecureVirtualMemory does NOT return
|
---|
15246 | // anything resembling a Win32-style handle. The return
|
---|
15247 | // value from this function can ONLY be used with MmUnsecureVirtualMemory.
|
---|
15248 | //
|
---|
15249 | NTKERNELAPI
|
---|
15250 | HANDLE
|
---|
15251 | MmSecureVirtualMemory (
|
---|
15252 | IN PVOID Address,
|
---|
15253 | IN SIZE_T Size,
|
---|
15254 | IN ULONG ProbeMode
|
---|
15255 | );
|
---|
15256 |
|
---|
15257 | NTKERNELAPI
|
---|
15258 | VOID
|
---|
15259 | MmUnsecureVirtualMemory (
|
---|
15260 | IN HANDLE SecureHandle
|
---|
15261 | );
|
---|
15262 |
|
---|
15263 |
|
---|
15264 |
|
---|
15265 | NTKERNELAPI
|
---|
15266 | NTSTATUS
|
---|
15267 | MmMapViewInSystemSpace (
|
---|
15268 | IN PVOID Section,
|
---|
15269 | OUT PVOID *MappedBase,
|
---|
15270 | IN PSIZE_T ViewSize
|
---|
15271 | );
|
---|
15272 |
|
---|
15273 | NTKERNELAPI
|
---|
15274 | NTSTATUS
|
---|
15275 | MmUnmapViewInSystemSpace (
|
---|
15276 | IN PVOID MappedBase
|
---|
15277 | );
|
---|
15278 |
|
---|
15279 |
|
---|
15280 | NTKERNELAPI
|
---|
15281 | NTSTATUS
|
---|
15282 | MmMapViewInSessionSpace (
|
---|
15283 | IN PVOID Section,
|
---|
15284 | OUT PVOID *MappedBase,
|
---|
15285 | IN OUT PSIZE_T ViewSize
|
---|
15286 | );
|
---|
15287 |
|
---|
15288 |
|
---|
15289 | NTKERNELAPI
|
---|
15290 | NTSTATUS
|
---|
15291 | MmUnmapViewInSessionSpace (
|
---|
15292 | IN PVOID MappedBase
|
---|
15293 | );
|
---|
15294 |
|
---|
15295 |
|
---|
15296 |
|
---|
15297 |
|
---|
15298 | //++
|
---|
15299 | //
|
---|
15300 | // VOID
|
---|
15301 | // MmInitializeMdl (
|
---|
15302 | // IN PMDL MemoryDescriptorList,
|
---|
15303 | // IN PVOID BaseVa,
|
---|
15304 | // IN SIZE_T Length
|
---|
15305 | // )
|
---|
15306 | //
|
---|
15307 | // Routine Description:
|
---|
15308 | //
|
---|
15309 | // This routine initializes the header of a Memory Descriptor List (MDL).
|
---|
15310 | //
|
---|
15311 | // Arguments:
|
---|
15312 | //
|
---|
15313 | // MemoryDescriptorList - Pointer to the MDL to initialize.
|
---|
15314 | //
|
---|
15315 | // BaseVa - Base virtual address mapped by the MDL.
|
---|
15316 | //
|
---|
15317 | // Length - Length, in bytes, of the buffer mapped by the MDL.
|
---|
15318 | //
|
---|
15319 | // Return Value:
|
---|
15320 | //
|
---|
15321 | // None.
|
---|
15322 | //
|
---|
15323 | //--
|
---|
15324 |
|
---|
15325 | #define MmInitializeMdl(MemoryDescriptorList, BaseVa, Length) { \
|
---|
15326 | (MemoryDescriptorList)->Next = (PMDL) NULL; \
|
---|
15327 | (MemoryDescriptorList)->Size = (CSHORT)(sizeof(MDL) + \
|
---|
15328 | (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa), (Length)))); \
|
---|
15329 | (MemoryDescriptorList)->MdlFlags = 0; \
|
---|
15330 | (MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN((BaseVa)); \
|
---|
15331 | (MemoryDescriptorList)->ByteOffset = BYTE_OFFSET((BaseVa)); \
|
---|
15332 | (MemoryDescriptorList)->ByteCount = (ULONG)(Length); \
|
---|
15333 | }
|
---|
15334 |
|
---|
15335 | //++
|
---|
15336 | //
|
---|
15337 | // PVOID
|
---|
15338 | // MmGetSystemAddressForMdlSafe (
|
---|
15339 | // IN PMDL MDL,
|
---|
15340 | // IN MM_PAGE_PRIORITY PRIORITY
|
---|
15341 | // )
|
---|
15342 | //
|
---|
15343 | // Routine Description:
|
---|
15344 | //
|
---|
15345 | // This routine returns the mapped address of an MDL. If the
|
---|
15346 | // Mdl is not already mapped or a system address, it is mapped.
|
---|
15347 | //
|
---|
15348 | // Arguments:
|
---|
15349 | //
|
---|
15350 | // MemoryDescriptorList - Pointer to the MDL to map.
|
---|
15351 | //
|
---|
15352 | // Priority - Supplies an indication as to how important it is that this
|
---|
15353 | // request succeed under low available PTE conditions.
|
---|
15354 | //
|
---|
15355 | // Return Value:
|
---|
15356 | //
|
---|
15357 | // Returns the base address where the pages are mapped. The base address
|
---|
15358 | // has the same offset as the virtual address in the MDL.
|
---|
15359 | //
|
---|
15360 | // Unlike MmGetSystemAddressForMdl, Safe guarantees that it will always
|
---|
15361 | // return NULL on failure instead of bugchecking the system.
|
---|
15362 | //
|
---|
15363 | // This macro is not usable by WDM 1.0 drivers as 1.0 did not include
|
---|
15364 | // MmMapLockedPagesSpecifyCache. The solution for WDM 1.0 drivers is to
|
---|
15365 | // provide synchronization and set/reset the MDL_MAPPING_CAN_FAIL bit.
|
---|
15366 | //
|
---|
15367 | //--
|
---|
15368 |
|
---|
15369 | #define MmGetSystemAddressForMdlSafe(MDL, PRIORITY) \
|
---|
15370 | (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
|
---|
15371 | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
|
---|
15372 | ((MDL)->MappedSystemVa) : \
|
---|
15373 | (MmMapLockedPagesSpecifyCache((MDL), \
|
---|
15374 | KernelMode, \
|
---|
15375 | MmCached, \
|
---|
15376 | NULL, \
|
---|
15377 | FALSE, \
|
---|
15378 | (PRIORITY))))
|
---|
15379 |
|
---|
15380 | //++
|
---|
15381 | //
|
---|
15382 | // PVOID
|
---|
15383 | // MmGetSystemAddressForMdl (
|
---|
15384 | // IN PMDL MDL
|
---|
15385 | // )
|
---|
15386 | //
|
---|
15387 | // Routine Description:
|
---|
15388 | //
|
---|
15389 | // This routine returns the mapped address of an MDL, if the
|
---|
15390 | // Mdl is not already mapped or a system address, it is mapped.
|
---|
15391 | //
|
---|
15392 | // Arguments:
|
---|
15393 | //
|
---|
15394 | // MemoryDescriptorList - Pointer to the MDL to map.
|
---|
15395 | //
|
---|
15396 | // Return Value:
|
---|
15397 | //
|
---|
15398 | // Returns the base address where the pages are mapped. The base address
|
---|
15399 | // has the same offset as the virtual address in the MDL.
|
---|
15400 | //
|
---|
15401 | //--
|
---|
15402 |
|
---|
15403 | //#define MmGetSystemAddressForMdl(MDL)
|
---|
15404 | // (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA)) ?
|
---|
15405 | // ((MDL)->MappedSystemVa) :
|
---|
15406 | // ((((MDL)->MdlFlags & (MDL_SOURCE_IS_NONPAGED_POOL)) ?
|
---|
15407 | // ((PVOID)((ULONG)(MDL)->StartVa | (MDL)->ByteOffset)) :
|
---|
15408 | // (MmMapLockedPages((MDL),KernelMode)))))
|
---|
15409 |
|
---|
15410 | #if PRAGMA_DEPRECATED_DDK
|
---|
15411 | #pragma deprecated(MmGetSystemAddressForMdl) // Use MmGetSystemAddressForMdlSafe
|
---|
15412 | #endif
|
---|
15413 |
|
---|
15414 | #define MmGetSystemAddressForMdl(MDL) \
|
---|
15415 | (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
|
---|
15416 | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
|
---|
15417 | ((MDL)->MappedSystemVa) : \
|
---|
15418 | (MmMapLockedPages((MDL),KernelMode)))
|
---|
15419 |
|
---|
15420 | //++
|
---|
15421 | //
|
---|
15422 | // VOID
|
---|
15423 | // MmPrepareMdlForReuse (
|
---|
15424 | // IN PMDL MDL
|
---|
15425 | // )
|
---|
15426 | //
|
---|
15427 | // Routine Description:
|
---|
15428 | //
|
---|
15429 | // This routine will take all of the steps necessary to allow an MDL to be
|
---|
15430 | // re-used.
|
---|
15431 | //
|
---|
15432 | // Arguments:
|
---|
15433 | //
|
---|
15434 | // MemoryDescriptorList - Pointer to the MDL that will be re-used.
|
---|
15435 | //
|
---|
15436 | // Return Value:
|
---|
15437 | //
|
---|
15438 | // None.
|
---|
15439 | //
|
---|
15440 | //--
|
---|
15441 |
|
---|
15442 | #define MmPrepareMdlForReuse(MDL) \
|
---|
15443 | if (((MDL)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
|
---|
15444 | ASSERT(((MDL)->MdlFlags & MDL_PARTIAL) != 0); \
|
---|
15445 | MmUnmapLockedPages( (MDL)->MappedSystemVa, (MDL) ); \
|
---|
15446 | } else if (((MDL)->MdlFlags & MDL_PARTIAL) == 0) { \
|
---|
15447 | ASSERT(((MDL)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
|
---|
15448 | }
|
---|
15449 |
|
---|
15450 | typedef NTSTATUS (*PMM_DLL_INITIALIZE)(
|
---|
15451 | IN PUNICODE_STRING RegistryPath
|
---|
15452 | );
|
---|
15453 |
|
---|
15454 | typedef NTSTATUS (*PMM_DLL_UNLOAD)(
|
---|
15455 | VOID
|
---|
15456 | );
|
---|
15457 |
|
---|
15458 |
|
---|
15459 |
|
---|
15460 | NTKERNELAPI
|
---|
15461 | NTSTATUS
|
---|
15462 | MmCreateMirror (
|
---|
15463 | VOID
|
---|
15464 | );
|
---|
15465 |
|
---|
15466 |
|
---|
15467 | //
|
---|
15468 | // Define an empty typedef for the _DRIVER_OBJECT structure so it may be
|
---|
15469 | // referenced by function types before it is actually defined.
|
---|
15470 | //
|
---|
15471 | struct _DRIVER_OBJECT;
|
---|
15472 |
|
---|
15473 | NTKERNELAPI
|
---|
15474 | LOGICAL
|
---|
15475 | MmIsDriverVerifying (
|
---|
15476 | IN struct _DRIVER_OBJECT *DriverObject
|
---|
15477 | );
|
---|
15478 |
|
---|
15479 | //
|
---|
15480 | // Security operation codes
|
---|
15481 | //
|
---|
15482 |
|
---|
15483 | typedef enum _SECURITY_OPERATION_CODE {
|
---|
15484 | SetSecurityDescriptor,
|
---|
15485 | QuerySecurityDescriptor,
|
---|
15486 | DeleteSecurityDescriptor,
|
---|
15487 | AssignSecurityDescriptor
|
---|
15488 | } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
|
---|
15489 |
|
---|
15490 | //
|
---|
15491 | // Data structure used to capture subject security context
|
---|
15492 | // for access validations and auditing.
|
---|
15493 | //
|
---|
15494 | // THE FIELDS OF THIS DATA STRUCTURE SHOULD BE CONSIDERED OPAQUE
|
---|
15495 | // BY ALL EXCEPT THE SECURITY ROUTINES.
|
---|
15496 | //
|
---|
15497 |
|
---|
15498 | typedef struct _SECURITY_SUBJECT_CONTEXT {
|
---|
15499 | PACCESS_TOKEN ClientToken;
|
---|
15500 | SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
|
---|
15501 | PACCESS_TOKEN PrimaryToken;
|
---|
15502 | PVOID ProcessAuditId;
|
---|
15503 | } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
|
---|
15504 |
|
---|
15505 | ///////////////////////////////////////////////////////////////////////////////
|
---|
15506 | // //
|
---|
15507 | // ACCESS_STATE and related structures //
|
---|
15508 | // //
|
---|
15509 | ///////////////////////////////////////////////////////////////////////////////
|
---|
15510 |
|
---|
15511 | //
|
---|
15512 | // Initial Privilege Set - Room for three privileges, which should
|
---|
15513 | // be enough for most applications. This structure exists so that
|
---|
15514 | // it can be embedded in an ACCESS_STATE structure. Use PRIVILEGE_SET
|
---|
15515 | // for all other references to Privilege sets.
|
---|
15516 | //
|
---|
15517 |
|
---|
15518 | #define INITIAL_PRIVILEGE_COUNT 3
|
---|
15519 |
|
---|
15520 | typedef struct _INITIAL_PRIVILEGE_SET {
|
---|
15521 | ULONG PrivilegeCount;
|
---|
15522 | ULONG Control;
|
---|
15523 | LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
|
---|
15524 | } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
|
---|
15525 |
|
---|
15526 |
|
---|
15527 |
|
---|
15528 | //
|
---|
15529 | // Combine the information that describes the state
|
---|
15530 | // of an access-in-progress into a single structure
|
---|
15531 | //
|
---|
15532 |
|
---|
15533 |
|
---|
15534 | typedef struct _ACCESS_STATE {
|
---|
15535 | LUID OperationID;
|
---|
15536 | BOOLEAN SecurityEvaluated;
|
---|
15537 | BOOLEAN GenerateAudit;
|
---|
15538 | BOOLEAN GenerateOnClose;
|
---|
15539 | BOOLEAN PrivilegesAllocated;
|
---|
15540 | ULONG Flags;
|
---|
15541 | ACCESS_MASK RemainingDesiredAccess;
|
---|
15542 | ACCESS_MASK PreviouslyGrantedAccess;
|
---|
15543 | ACCESS_MASK OriginalDesiredAccess;
|
---|
15544 | SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
|
---|
15545 | PSECURITY_DESCRIPTOR SecurityDescriptor;
|
---|
15546 | PVOID AuxData;
|
---|
15547 | union {
|
---|
15548 | INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
|
---|
15549 | PRIVILEGE_SET PrivilegeSet;
|
---|
15550 | } Privileges;
|
---|
15551 |
|
---|
15552 | BOOLEAN AuditPrivileges;
|
---|
15553 | UNICODE_STRING ObjectName;
|
---|
15554 | UNICODE_STRING ObjectTypeName;
|
---|
15555 |
|
---|
15556 | } ACCESS_STATE, *PACCESS_STATE;
|
---|
15557 |
|
---|
15558 |
|
---|
15559 | NTKERNELAPI
|
---|
15560 | NTSTATUS
|
---|
15561 | SeAssignSecurity (
|
---|
15562 | IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
|
---|
15563 | IN PSECURITY_DESCRIPTOR ExplicitDescriptor,
|
---|
15564 | OUT PSECURITY_DESCRIPTOR *NewDescriptor,
|
---|
15565 | IN BOOLEAN IsDirectoryObject,
|
---|
15566 | IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
---|
15567 | IN PGENERIC_MAPPING GenericMapping,
|
---|
15568 | IN POOL_TYPE PoolType
|
---|
15569 | );
|
---|
15570 |
|
---|
15571 | NTKERNELAPI
|
---|
15572 | NTSTATUS
|
---|
15573 | SeAssignSecurityEx (
|
---|
15574 | IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
|
---|
15575 | IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL,
|
---|
15576 | OUT PSECURITY_DESCRIPTOR *NewDescriptor,
|
---|
15577 | IN GUID *ObjectType OPTIONAL,
|
---|
15578 | IN BOOLEAN IsDirectoryObject,
|
---|
15579 | IN ULONG AutoInheritFlags,
|
---|
15580 | IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
---|
15581 | IN PGENERIC_MAPPING GenericMapping,
|
---|
15582 | IN POOL_TYPE PoolType
|
---|
15583 | );
|
---|
15584 |
|
---|
15585 | NTKERNELAPI
|
---|
15586 | NTSTATUS
|
---|
15587 | SeDeassignSecurity (
|
---|
15588 | IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor
|
---|
15589 | );
|
---|
15590 |
|
---|
15591 | NTKERNELAPI
|
---|
15592 | BOOLEAN
|
---|
15593 | SeAccessCheck (
|
---|
15594 | IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
15595 | IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
|
---|
15596 | IN BOOLEAN SubjectContextLocked,
|
---|
15597 | IN ACCESS_MASK DesiredAccess,
|
---|
15598 | IN ACCESS_MASK PreviouslyGrantedAccess,
|
---|
15599 | OUT PPRIVILEGE_SET *Privileges OPTIONAL,
|
---|
15600 | IN PGENERIC_MAPPING GenericMapping,
|
---|
15601 | IN KPROCESSOR_MODE AccessMode,
|
---|
15602 | OUT PACCESS_MASK GrantedAccess,
|
---|
15603 | OUT PNTSTATUS AccessStatus
|
---|
15604 | );
|
---|
15605 |
|
---|
15606 |
|
---|
15607 | #ifdef SE_NTFS_WORLD_CACHE
|
---|
15608 |
|
---|
15609 | VOID
|
---|
15610 | SeGetWorldRights (
|
---|
15611 | IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
15612 | IN PGENERIC_MAPPING GenericMapping,
|
---|
15613 | OUT PACCESS_MASK GrantedAccess
|
---|
15614 | );
|
---|
15615 |
|
---|
15616 | #endif
|
---|
15617 |
|
---|
15618 |
|
---|
15619 | NTKERNELAPI
|
---|
15620 | BOOLEAN
|
---|
15621 | SeValidSecurityDescriptor(
|
---|
15622 | IN ULONG Length,
|
---|
15623 | IN PSECURITY_DESCRIPTOR SecurityDescriptor
|
---|
15624 | );
|
---|
15625 |
|
---|
15626 | NTKERNELAPI
|
---|
15627 | BOOLEAN
|
---|
15628 | SeSinglePrivilegeCheck(
|
---|
15629 | LUID PrivilegeValue,
|
---|
15630 | KPROCESSOR_MODE PreviousMode
|
---|
15631 | );
|
---|
15632 | //
|
---|
15633 | // System Thread and Process Creation and Termination
|
---|
15634 | //
|
---|
15635 |
|
---|
15636 | NTKERNELAPI
|
---|
15637 | NTSTATUS
|
---|
15638 | PsCreateSystemThread(
|
---|
15639 | OUT PHANDLE ThreadHandle,
|
---|
15640 | IN ULONG DesiredAccess,
|
---|
15641 | IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
---|
15642 | IN HANDLE ProcessHandle OPTIONAL,
|
---|
15643 | OUT PCLIENT_ID ClientId OPTIONAL,
|
---|
15644 | IN PKSTART_ROUTINE StartRoutine,
|
---|
15645 | IN PVOID StartContext
|
---|
15646 | );
|
---|
15647 |
|
---|
15648 | NTKERNELAPI
|
---|
15649 | NTSTATUS
|
---|
15650 | PsTerminateSystemThread(
|
---|
15651 | IN NTSTATUS ExitStatus
|
---|
15652 | );
|
---|
15653 |
|
---|
15654 |
|
---|
15655 | typedef
|
---|
15656 | VOID
|
---|
15657 | (*PCREATE_PROCESS_NOTIFY_ROUTINE)(
|
---|
15658 | IN HANDLE ParentId,
|
---|
15659 | IN HANDLE ProcessId,
|
---|
15660 | IN BOOLEAN Create
|
---|
15661 | );
|
---|
15662 |
|
---|
15663 | NTSTATUS
|
---|
15664 | PsSetCreateProcessNotifyRoutine(
|
---|
15665 | IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
---|
15666 | IN BOOLEAN Remove
|
---|
15667 | );
|
---|
15668 |
|
---|
15669 | typedef
|
---|
15670 | VOID
|
---|
15671 | (*PCREATE_THREAD_NOTIFY_ROUTINE)(
|
---|
15672 | IN HANDLE ProcessId,
|
---|
15673 | IN HANDLE ThreadId,
|
---|
15674 | IN BOOLEAN Create
|
---|
15675 | );
|
---|
15676 |
|
---|
15677 | NTSTATUS
|
---|
15678 | PsSetCreateThreadNotifyRoutine(
|
---|
15679 | IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
|
---|
15680 | );
|
---|
15681 |
|
---|
15682 | NTSTATUS
|
---|
15683 | PsRemoveCreateThreadNotifyRoutine (
|
---|
15684 | IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
|
---|
15685 | );
|
---|
15686 |
|
---|
15687 | //
|
---|
15688 | // Structures for Load Image Notify
|
---|
15689 | //
|
---|
15690 |
|
---|
15691 | typedef struct _IMAGE_INFO {
|
---|
15692 | union {
|
---|
15693 | ULONG Properties;
|
---|
15694 | struct {
|
---|
15695 | ULONG ImageAddressingMode : 8; // code addressing mode
|
---|
15696 | ULONG SystemModeImage : 1; // system mode image
|
---|
15697 | ULONG ImageMappedToAllPids : 1; // image mapped into all processes
|
---|
15698 | ULONG Reserved : 22;
|
---|
15699 | };
|
---|
15700 | };
|
---|
15701 | PVOID ImageBase;
|
---|
15702 | ULONG ImageSelector;
|
---|
15703 | SIZE_T ImageSize;
|
---|
15704 | ULONG ImageSectionNumber;
|
---|
15705 | } IMAGE_INFO, *PIMAGE_INFO;
|
---|
15706 |
|
---|
15707 | #define IMAGE_ADDRESSING_MODE_32BIT 3
|
---|
15708 |
|
---|
15709 | typedef
|
---|
15710 | VOID
|
---|
15711 | (*PLOAD_IMAGE_NOTIFY_ROUTINE)(
|
---|
15712 | IN PUNICODE_STRING FullImageName,
|
---|
15713 | IN HANDLE ProcessId, // pid into which image is being mapped
|
---|
15714 | IN PIMAGE_INFO ImageInfo
|
---|
15715 | );
|
---|
15716 |
|
---|
15717 | NTSTATUS
|
---|
15718 | PsSetLoadImageNotifyRoutine(
|
---|
15719 | IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine
|
---|
15720 | );
|
---|
15721 |
|
---|
15722 | NTSTATUS
|
---|
15723 | PsRemoveLoadImageNotifyRoutine(
|
---|
15724 | IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine
|
---|
15725 | );
|
---|
15726 |
|
---|
15727 |
|
---|
15728 |
|
---|
15729 | HANDLE
|
---|
15730 | PsGetCurrentProcessId( VOID );
|
---|
15731 |
|
---|
15732 | HANDLE
|
---|
15733 | PsGetCurrentThreadId( VOID );
|
---|
15734 |
|
---|
15735 |
|
---|
15736 |
|
---|
15737 |
|
---|
15738 | BOOLEAN
|
---|
15739 | PsGetVersion(
|
---|
15740 | PULONG MajorVersion OPTIONAL,
|
---|
15741 | PULONG MinorVersion OPTIONAL,
|
---|
15742 | PULONG BuildNumber OPTIONAL,
|
---|
15743 | PUNICODE_STRING CSDVersion OPTIONAL
|
---|
15744 | );
|
---|
15745 |
|
---|
15746 | //
|
---|
15747 | // Define I/O system data structure type codes. Each major data structure in
|
---|
15748 | // the I/O system has a type code The type field in each structure is at the
|
---|
15749 | // same offset. The following values can be used to determine which type of
|
---|
15750 | // data structure a pointer refers to.
|
---|
15751 | //
|
---|
15752 |
|
---|
15753 | #define IO_TYPE_ADAPTER 0x00000001
|
---|
15754 | #define IO_TYPE_CONTROLLER 0x00000002
|
---|
15755 | #define IO_TYPE_DEVICE 0x00000003
|
---|
15756 | #define IO_TYPE_DRIVER 0x00000004
|
---|
15757 | #define IO_TYPE_FILE 0x00000005
|
---|
15758 | #define IO_TYPE_IRP 0x00000006
|
---|
15759 | #define IO_TYPE_MASTER_ADAPTER 0x00000007
|
---|
15760 | #define IO_TYPE_OPEN_PACKET 0x00000008
|
---|
15761 | #define IO_TYPE_TIMER 0x00000009
|
---|
15762 | #define IO_TYPE_VPB 0x0000000a
|
---|
15763 | #define IO_TYPE_ERROR_LOG 0x0000000b
|
---|
15764 | #define IO_TYPE_ERROR_MESSAGE 0x0000000c
|
---|
15765 | #define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0000000d
|
---|
15766 |
|
---|
15767 |
|
---|
15768 | //
|
---|
15769 | // Define the major function codes for IRPs.
|
---|
15770 | //
|
---|
15771 |
|
---|
15772 |
|
---|
15773 | #define IRP_MJ_CREATE 0x00
|
---|
15774 | #define IRP_MJ_CREATE_NAMED_PIPE 0x01
|
---|
15775 | #define IRP_MJ_CLOSE 0x02
|
---|
15776 | #define IRP_MJ_READ 0x03
|
---|
15777 | #define IRP_MJ_WRITE 0x04
|
---|
15778 | #define IRP_MJ_QUERY_INFORMATION 0x05
|
---|
15779 | #define IRP_MJ_SET_INFORMATION 0x06
|
---|
15780 | #define IRP_MJ_QUERY_EA 0x07
|
---|
15781 | #define IRP_MJ_SET_EA 0x08
|
---|
15782 | #define IRP_MJ_FLUSH_BUFFERS 0x09
|
---|
15783 | #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
|
---|
15784 | #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
|
---|
15785 | #define IRP_MJ_DIRECTORY_CONTROL 0x0c
|
---|
15786 | #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
|
---|
15787 | #define IRP_MJ_DEVICE_CONTROL 0x0e
|
---|
15788 | #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
|
---|
15789 | #define IRP_MJ_SHUTDOWN 0x10
|
---|
15790 | #define IRP_MJ_LOCK_CONTROL 0x11
|
---|
15791 | #define IRP_MJ_CLEANUP 0x12
|
---|
15792 | #define IRP_MJ_CREATE_MAILSLOT 0x13
|
---|
15793 | #define IRP_MJ_QUERY_SECURITY 0x14
|
---|
15794 | #define IRP_MJ_SET_SECURITY 0x15
|
---|
15795 | #define IRP_MJ_POWER 0x16
|
---|
15796 | #define IRP_MJ_SYSTEM_CONTROL 0x17
|
---|
15797 | #define IRP_MJ_DEVICE_CHANGE 0x18
|
---|
15798 | #define IRP_MJ_QUERY_QUOTA 0x19
|
---|
15799 | #define IRP_MJ_SET_QUOTA 0x1a
|
---|
15800 | #define IRP_MJ_PNP 0x1b
|
---|
15801 | #define IRP_MJ_PNP_POWER IRP_MJ_PNP // Obsolete....
|
---|
15802 | #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
|
---|
15803 |
|
---|
15804 | //
|
---|
15805 | // Make the Scsi major code the same as internal device control.
|
---|
15806 | //
|
---|
15807 |
|
---|
15808 | #define IRP_MJ_SCSI IRP_MJ_INTERNAL_DEVICE_CONTROL
|
---|
15809 |
|
---|
15810 | //
|
---|
15811 | // Define the minor function codes for IRPs. The lower 128 codes, from 0x00 to
|
---|
15812 | // 0x7f are reserved to Microsoft. The upper 128 codes, from 0x80 to 0xff, are
|
---|
15813 | // reserved to customers of Microsoft.
|
---|
15814 | //
|
---|
15815 |
|
---|
15816 |
|
---|
15817 | //
|
---|
15818 | // Directory control minor function codes
|
---|
15819 | //
|
---|
15820 |
|
---|
15821 | #define IRP_MN_QUERY_DIRECTORY 0x01
|
---|
15822 | #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
|
---|
15823 |
|
---|
15824 | //
|
---|
15825 | // File system control minor function codes. Note that "user request" is
|
---|
15826 | // assumed to be zero by both the I/O system and file systems. Do not change
|
---|
15827 | // this value.
|
---|
15828 | //
|
---|
15829 |
|
---|
15830 | #define IRP_MN_USER_FS_REQUEST 0x00
|
---|
15831 | #define IRP_MN_MOUNT_VOLUME 0x01
|
---|
15832 | #define IRP_MN_VERIFY_VOLUME 0x02
|
---|
15833 | #define IRP_MN_LOAD_FILE_SYSTEM 0x03
|
---|
15834 | #define IRP_MN_TRACK_LINK 0x04 // To be obsoleted soon
|
---|
15835 | #define IRP_MN_KERNEL_CALL 0x04
|
---|
15836 |
|
---|
15837 | //
|
---|
15838 | // Lock control minor function codes
|
---|
15839 | //
|
---|
15840 |
|
---|
15841 | #define IRP_MN_LOCK 0x01
|
---|
15842 | #define IRP_MN_UNLOCK_SINGLE 0x02
|
---|
15843 | #define IRP_MN_UNLOCK_ALL 0x03
|
---|
15844 | #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
|
---|
15845 |
|
---|
15846 | //
|
---|
15847 | // Read and Write minor function codes for file systems supporting Lan Manager
|
---|
15848 | // software. All of these subfunction codes are invalid if the file has been
|
---|
15849 | // opened with FO_NO_INTERMEDIATE_BUFFERING. They are also invalid in combi-
|
---|
15850 | // nation with synchronous calls (Irp Flag or file open option).
|
---|
15851 | //
|
---|
15852 | // Note that "normal" is assumed to be zero by both the I/O system and file
|
---|
15853 | // systems. Do not change this value.
|
---|
15854 | //
|
---|
15855 |
|
---|
15856 | #define IRP_MN_NORMAL 0x00
|
---|
15857 | #define IRP_MN_DPC 0x01
|
---|
15858 | #define IRP_MN_MDL 0x02
|
---|
15859 | #define IRP_MN_COMPLETE 0x04
|
---|
15860 | #define IRP_MN_COMPRESSED 0x08
|
---|
15861 |
|
---|
15862 | #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
|
---|
15863 | #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
|
---|
15864 | #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
|
---|
15865 |
|
---|
15866 |
|
---|
15867 | //
|
---|
15868 | // Device Control Request minor function codes for SCSI support. Note that
|
---|
15869 | // user requests are assumed to be zero.
|
---|
15870 | //
|
---|
15871 |
|
---|
15872 | #define IRP_MN_SCSI_CLASS 0x01
|
---|
15873 |
|
---|
15874 | //
|
---|
15875 | // PNP minor function codes.
|
---|
15876 | //
|
---|
15877 |
|
---|
15878 | #define IRP_MN_START_DEVICE 0x00
|
---|
15879 | #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
|
---|
15880 | #define IRP_MN_REMOVE_DEVICE 0x02
|
---|
15881 | #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
|
---|
15882 | #define IRP_MN_STOP_DEVICE 0x04
|
---|
15883 | #define IRP_MN_QUERY_STOP_DEVICE 0x05
|
---|
15884 | #define IRP_MN_CANCEL_STOP_DEVICE 0x06
|
---|
15885 |
|
---|
15886 | #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
|
---|
15887 | #define IRP_MN_QUERY_INTERFACE 0x08
|
---|
15888 | #define IRP_MN_QUERY_CAPABILITIES 0x09
|
---|
15889 | #define IRP_MN_QUERY_RESOURCES 0x0A
|
---|
15890 | #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
|
---|
15891 | #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
|
---|
15892 | #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
|
---|
15893 |
|
---|
15894 | #define IRP_MN_READ_CONFIG 0x0F
|
---|
15895 | #define IRP_MN_WRITE_CONFIG 0x10
|
---|
15896 | #define IRP_MN_EJECT 0x11
|
---|
15897 | #define IRP_MN_SET_LOCK 0x12
|
---|
15898 | #define IRP_MN_QUERY_ID 0x13
|
---|
15899 | #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
|
---|
15900 | #define IRP_MN_QUERY_BUS_INFORMATION 0x15
|
---|
15901 | #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
|
---|
15902 | #define IRP_MN_SURPRISE_REMOVAL 0x17
|
---|
15903 |
|
---|
15904 | #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
|
---|
15905 |
|
---|
15906 |
|
---|
15907 | //
|
---|
15908 | // POWER minor function codes
|
---|
15909 | //
|
---|
15910 | #define IRP_MN_WAIT_WAKE 0x00
|
---|
15911 | #define IRP_MN_POWER_SEQUENCE 0x01
|
---|
15912 | #define IRP_MN_SET_POWER 0x02
|
---|
15913 | #define IRP_MN_QUERY_POWER 0x03
|
---|
15914 |
|
---|
15915 |
|
---|
15916 | //
|
---|
15917 | // WMI minor function codes under IRP_MJ_SYSTEM_CONTROL
|
---|
15918 | //
|
---|
15919 |
|
---|
15920 | #define IRP_MN_QUERY_ALL_DATA 0x00
|
---|
15921 | #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
|
---|
15922 | #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
|
---|
15923 | #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
|
---|
15924 | #define IRP_MN_ENABLE_EVENTS 0x04
|
---|
15925 | #define IRP_MN_DISABLE_EVENTS 0x05
|
---|
15926 | #define IRP_MN_ENABLE_COLLECTION 0x06
|
---|
15927 | #define IRP_MN_DISABLE_COLLECTION 0x07
|
---|
15928 | #define IRP_MN_REGINFO 0x08
|
---|
15929 | #define IRP_MN_EXECUTE_METHOD 0x09
|
---|
15930 | // Minor code 0x0a is reserved
|
---|
15931 | #define IRP_MN_REGINFO_EX 0x0b
|
---|
15932 |
|
---|
15933 |
|
---|
15934 |
|
---|
15935 | //
|
---|
15936 | // Define option flags for IoCreateFile. Note that these values must be
|
---|
15937 | // exactly the same as the SL_... flags for a create function. Note also
|
---|
15938 | // that there are flags that may be passed to IoCreateFile that are not
|
---|
15939 | // placed in the stack location for the create IRP. These flags start in
|
---|
15940 | // the next byte.
|
---|
15941 | //
|
---|
15942 |
|
---|
15943 | #define IO_FORCE_ACCESS_CHECK 0x0001
|
---|
15944 | #define IO_NO_PARAMETER_CHECKING 0x0100
|
---|
15945 |
|
---|
15946 | //
|
---|
15947 | // Define Information fields for whether or not a REPARSE or a REMOUNT has
|
---|
15948 | // occurred in the file system.
|
---|
15949 | //
|
---|
15950 |
|
---|
15951 | #define IO_REPARSE 0x0
|
---|
15952 | #define IO_REMOUNT 0x1
|
---|
15953 |
|
---|
15954 | //
|
---|
15955 | // Define callout routine type for use in IoQueryDeviceDescription().
|
---|
15956 | //
|
---|
15957 |
|
---|
15958 | typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(
|
---|
15959 | IN PVOID Context,
|
---|
15960 | IN PUNICODE_STRING PathName,
|
---|
15961 | IN INTERFACE_TYPE BusType,
|
---|
15962 | IN ULONG BusNumber,
|
---|
15963 | IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
|
---|
15964 | IN CONFIGURATION_TYPE ControllerType,
|
---|
15965 | IN ULONG ControllerNumber,
|
---|
15966 | IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
|
---|
15967 | IN CONFIGURATION_TYPE PeripheralType,
|
---|
15968 | IN ULONG PeripheralNumber,
|
---|
15969 | IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
|
---|
15970 | );
|
---|
15971 |
|
---|
15972 |
|
---|
15973 | // Defines the order of the information in the array of
|
---|
15974 | // PKEY_VALUE_FULL_INFORMATION.
|
---|
15975 | //
|
---|
15976 |
|
---|
15977 | typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
|
---|
15978 | IoQueryDeviceIdentifier = 0,
|
---|
15979 | IoQueryDeviceConfigurationData,
|
---|
15980 | IoQueryDeviceComponentInformation,
|
---|
15981 | IoQueryDeviceMaxData
|
---|
15982 | } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
|
---|
15983 |
|
---|
15984 |
|
---|
15985 | //
|
---|
15986 | // Define the objects that can be created by IoCreateFile.
|
---|
15987 | //
|
---|
15988 |
|
---|
15989 | typedef enum _CREATE_FILE_TYPE {
|
---|
15990 | CreateFileTypeNone,
|
---|
15991 | CreateFileTypeNamedPipe,
|
---|
15992 | CreateFileTypeMailslot
|
---|
15993 | } CREATE_FILE_TYPE;
|
---|
15994 |
|
---|
15995 | //
|
---|
15996 | // Define the structures used by the I/O system
|
---|
15997 | //
|
---|
15998 |
|
---|
15999 | //
|
---|
16000 | // Define empty typedefs for the _IRP, _DEVICE_OBJECT, and _DRIVER_OBJECT
|
---|
16001 | // structures so they may be referenced by function types before they are
|
---|
16002 | // actually defined.
|
---|
16003 | //
|
---|
16004 | struct _DEVICE_DESCRIPTION;
|
---|
16005 | struct _DEVICE_OBJECT;
|
---|
16006 | struct _DMA_ADAPTER;
|
---|
16007 | struct _DRIVER_OBJECT;
|
---|
16008 | struct _DRIVE_LAYOUT_INFORMATION;
|
---|
16009 | struct _DISK_PARTITION;
|
---|
16010 | struct _FILE_OBJECT;
|
---|
16011 | struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _IRP;
|
---|
16012 | struct _SCSI_REQUEST_BLOCK;
|
---|
16013 | struct _SCATTER_GATHER_LIST;
|
---|
16014 |
|
---|
16015 | //
|
---|
16016 | // Define the I/O version of a DPC routine.
|
---|
16017 | //
|
---|
16018 |
|
---|
16019 | typedef
|
---|
16020 | VOID
|
---|
16021 | (*PIO_DPC_ROUTINE) (
|
---|
16022 | IN PKDPC Dpc,
|
---|
16023 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
16024 | IN struct _IRP *Irp,
|
---|
16025 | IN PVOID Context
|
---|
16026 | );
|
---|
16027 |
|
---|
16028 | //
|
---|
16029 | // Define driver timer routine type.
|
---|
16030 | //
|
---|
16031 |
|
---|
16032 | typedef
|
---|
16033 | VOID
|
---|
16034 | (*PIO_TIMER_ROUTINE) (
|
---|
16035 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
16036 | IN PVOID Context
|
---|
16037 | );
|
---|
16038 |
|
---|
16039 | //
|
---|
16040 | // Define driver initialization routine type.
|
---|
16041 | //
|
---|
16042 | typedef
|
---|
16043 | NTSTATUS
|
---|
16044 | (*PDRIVER_INITIALIZE) (
|
---|
16045 | IN struct _DRIVER_OBJECT *DriverObject,
|
---|
16046 | IN PUNICODE_STRING RegistryPath
|
---|
16047 | );
|
---|
16048 |
|
---|
16049 |
|
---|
16050 | //
|
---|
16051 | // Define driver reinitialization routine type.
|
---|
16052 | //
|
---|
16053 |
|
---|
16054 | typedef
|
---|
16055 | VOID
|
---|
16056 | (*PDRIVER_REINITIALIZE) (
|
---|
16057 | IN struct _DRIVER_OBJECT *DriverObject,
|
---|
16058 | IN PVOID Context,
|
---|
16059 | IN ULONG Count
|
---|
16060 | );
|
---|
16061 |
|
---|
16062 |
|
---|
16063 | //
|
---|
16064 | // Define driver cancel routine type.
|
---|
16065 | //
|
---|
16066 |
|
---|
16067 | typedef
|
---|
16068 | VOID
|
---|
16069 | (*PDRIVER_CANCEL) (
|
---|
16070 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
16071 | IN struct _IRP *Irp
|
---|
16072 | );
|
---|
16073 |
|
---|
16074 | //
|
---|
16075 | // Define driver dispatch routine type.
|
---|
16076 | //
|
---|
16077 |
|
---|
16078 | typedef
|
---|
16079 | NTSTATUS
|
---|
16080 | (*PDRIVER_DISPATCH) (
|
---|
16081 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
16082 | IN struct _IRP *Irp
|
---|
16083 | );
|
---|
16084 |
|
---|
16085 | //
|
---|
16086 | // Define driver start I/O routine type.
|
---|
16087 | //
|
---|
16088 |
|
---|
16089 | typedef
|
---|
16090 | VOID
|
---|
16091 | (*PDRIVER_STARTIO) (
|
---|
16092 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
16093 | IN struct _IRP *Irp
|
---|
16094 | );
|
---|
16095 |
|
---|
16096 | //
|
---|
16097 | // Define driver unload routine type.
|
---|
16098 | //
|
---|
16099 | typedef
|
---|
16100 | VOID
|
---|
16101 | (*PDRIVER_UNLOAD) (
|
---|
16102 | IN struct _DRIVER_OBJECT *DriverObject
|
---|
16103 | );
|
---|
16104 | //
|
---|
16105 | // Define driver AddDevice routine type.
|
---|
16106 | //
|
---|
16107 |
|
---|
16108 | typedef
|
---|
16109 | NTSTATUS
|
---|
16110 | (*PDRIVER_ADD_DEVICE) (
|
---|
16111 | IN struct _DRIVER_OBJECT *DriverObject,
|
---|
16112 | IN struct _DEVICE_OBJECT *PhysicalDeviceObject
|
---|
16113 | );
|
---|
16114 |
|
---|
16115 |
|
---|
16116 | //
|
---|
16117 | // Define fast I/O procedure prototypes.
|
---|
16118 | //
|
---|
16119 | // Fast I/O read and write procedures.
|
---|
16120 | //
|
---|
16121 |
|
---|
16122 | typedef
|
---|
16123 | BOOLEAN
|
---|
16124 | (*PFAST_IO_CHECK_IF_POSSIBLE) (
|
---|
16125 | IN struct _FILE_OBJECT *FileObject,
|
---|
16126 | IN PLARGE_INTEGER FileOffset,
|
---|
16127 | IN ULONG Length,
|
---|
16128 | IN BOOLEAN Wait,
|
---|
16129 | IN ULONG LockKey,
|
---|
16130 | IN BOOLEAN CheckForReadOperation,
|
---|
16131 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16132 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16133 | );
|
---|
16134 |
|
---|
16135 | typedef
|
---|
16136 | BOOLEAN
|
---|
16137 | (*PFAST_IO_READ) (
|
---|
16138 | IN struct _FILE_OBJECT *FileObject,
|
---|
16139 | IN PLARGE_INTEGER FileOffset,
|
---|
16140 | IN ULONG Length,
|
---|
16141 | IN BOOLEAN Wait,
|
---|
16142 | IN ULONG LockKey,
|
---|
16143 | OUT PVOID Buffer,
|
---|
16144 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16145 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16146 | );
|
---|
16147 |
|
---|
16148 | typedef
|
---|
16149 | BOOLEAN
|
---|
16150 | (*PFAST_IO_WRITE) (
|
---|
16151 | IN struct _FILE_OBJECT *FileObject,
|
---|
16152 | IN PLARGE_INTEGER FileOffset,
|
---|
16153 | IN ULONG Length,
|
---|
16154 | IN BOOLEAN Wait,
|
---|
16155 | IN ULONG LockKey,
|
---|
16156 | IN PVOID Buffer,
|
---|
16157 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16158 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16159 | );
|
---|
16160 |
|
---|
16161 | //
|
---|
16162 | // Fast I/O query basic and standard information procedures.
|
---|
16163 | //
|
---|
16164 |
|
---|
16165 | typedef
|
---|
16166 | BOOLEAN
|
---|
16167 | (*PFAST_IO_QUERY_BASIC_INFO) (
|
---|
16168 | IN struct _FILE_OBJECT *FileObject,
|
---|
16169 | IN BOOLEAN Wait,
|
---|
16170 | OUT PFILE_BASIC_INFORMATION Buffer,
|
---|
16171 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16172 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16173 | );
|
---|
16174 |
|
---|
16175 | typedef
|
---|
16176 | BOOLEAN
|
---|
16177 | (*PFAST_IO_QUERY_STANDARD_INFO) (
|
---|
16178 | IN struct _FILE_OBJECT *FileObject,
|
---|
16179 | IN BOOLEAN Wait,
|
---|
16180 | OUT PFILE_STANDARD_INFORMATION Buffer,
|
---|
16181 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16182 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16183 | );
|
---|
16184 |
|
---|
16185 | //
|
---|
16186 | // Fast I/O lock and unlock procedures.
|
---|
16187 | //
|
---|
16188 |
|
---|
16189 | typedef
|
---|
16190 | BOOLEAN
|
---|
16191 | (*PFAST_IO_LOCK) (
|
---|
16192 | IN struct _FILE_OBJECT *FileObject,
|
---|
16193 | IN PLARGE_INTEGER FileOffset,
|
---|
16194 | IN PLARGE_INTEGER Length,
|
---|
16195 | PEPROCESS ProcessId,
|
---|
16196 | ULONG Key,
|
---|
16197 | BOOLEAN FailImmediately,
|
---|
16198 | BOOLEAN ExclusiveLock,
|
---|
16199 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16200 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16201 | );
|
---|
16202 |
|
---|
16203 | typedef
|
---|
16204 | BOOLEAN
|
---|
16205 | (*PFAST_IO_UNLOCK_SINGLE) (
|
---|
16206 | IN struct _FILE_OBJECT *FileObject,
|
---|
16207 | IN PLARGE_INTEGER FileOffset,
|
---|
16208 | IN PLARGE_INTEGER Length,
|
---|
16209 | PEPROCESS ProcessId,
|
---|
16210 | ULONG Key,
|
---|
16211 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16212 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16213 | );
|
---|
16214 |
|
---|
16215 | typedef
|
---|
16216 | BOOLEAN
|
---|
16217 | (*PFAST_IO_UNLOCK_ALL) (
|
---|
16218 | IN struct _FILE_OBJECT *FileObject,
|
---|
16219 | PEPROCESS ProcessId,
|
---|
16220 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16221 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16222 | );
|
---|
16223 |
|
---|
16224 | typedef
|
---|
16225 | BOOLEAN
|
---|
16226 | (*PFAST_IO_UNLOCK_ALL_BY_KEY) (
|
---|
16227 | IN struct _FILE_OBJECT *FileObject,
|
---|
16228 | PVOID ProcessId,
|
---|
16229 | ULONG Key,
|
---|
16230 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16231 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16232 | );
|
---|
16233 |
|
---|
16234 | //
|
---|
16235 | // Fast I/O device control procedure.
|
---|
16236 | //
|
---|
16237 |
|
---|
16238 | typedef
|
---|
16239 | BOOLEAN
|
---|
16240 | (*PFAST_IO_DEVICE_CONTROL) (
|
---|
16241 | IN struct _FILE_OBJECT *FileObject,
|
---|
16242 | IN BOOLEAN Wait,
|
---|
16243 | IN PVOID InputBuffer OPTIONAL,
|
---|
16244 | IN ULONG InputBufferLength,
|
---|
16245 | OUT PVOID OutputBuffer OPTIONAL,
|
---|
16246 | IN ULONG OutputBufferLength,
|
---|
16247 | IN ULONG IoControlCode,
|
---|
16248 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16249 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16250 | );
|
---|
16251 |
|
---|
16252 | //
|
---|
16253 | // Define callbacks for NtCreateSection to synchronize correctly with
|
---|
16254 | // the file system. It pre-acquires the resources that will be needed
|
---|
16255 | // when calling to query and set file/allocation size in the file system.
|
---|
16256 | //
|
---|
16257 |
|
---|
16258 | typedef
|
---|
16259 | VOID
|
---|
16260 | (*PFAST_IO_ACQUIRE_FILE) (
|
---|
16261 | IN struct _FILE_OBJECT *FileObject
|
---|
16262 | );
|
---|
16263 |
|
---|
16264 | typedef
|
---|
16265 | VOID
|
---|
16266 | (*PFAST_IO_RELEASE_FILE) (
|
---|
16267 | IN struct _FILE_OBJECT *FileObject
|
---|
16268 | );
|
---|
16269 |
|
---|
16270 | //
|
---|
16271 | // Define callback for drivers that have device objects attached to lower-
|
---|
16272 | // level drivers' device objects. This callback is made when the lower-level
|
---|
16273 | // driver is deleting its device object.
|
---|
16274 | //
|
---|
16275 |
|
---|
16276 | typedef
|
---|
16277 | VOID
|
---|
16278 | (*PFAST_IO_DETACH_DEVICE) (
|
---|
16279 | IN struct _DEVICE_OBJECT *SourceDevice,
|
---|
16280 | IN struct _DEVICE_OBJECT *TargetDevice
|
---|
16281 | );
|
---|
16282 |
|
---|
16283 | //
|
---|
16284 | // This structure is used by the server to quickly get the information needed
|
---|
16285 | // to service a server open call. It is takes what would be two fast io calls
|
---|
16286 | // one for basic information and the other for standard information and makes
|
---|
16287 | // it into one call.
|
---|
16288 | //
|
---|
16289 |
|
---|
16290 | typedef
|
---|
16291 | BOOLEAN
|
---|
16292 | (*PFAST_IO_QUERY_NETWORK_OPEN_INFO) (
|
---|
16293 | IN struct _FILE_OBJECT *FileObject,
|
---|
16294 | IN BOOLEAN Wait,
|
---|
16295 | OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
|
---|
16296 | OUT struct _IO_STATUS_BLOCK *IoStatus,
|
---|
16297 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16298 | );
|
---|
16299 |
|
---|
16300 | //
|
---|
16301 | // Define Mdl-based routines for the server to call
|
---|
16302 | //
|
---|
16303 |
|
---|
16304 | typedef
|
---|
16305 | BOOLEAN
|
---|
16306 | (*PFAST_IO_MDL_READ) (
|
---|
16307 | IN struct _FILE_OBJECT *FileObject,
|
---|
16308 | IN PLARGE_INTEGER FileOffset,
|
---|
16309 | IN ULONG Length,
|
---|
16310 | IN ULONG LockKey,
|
---|
16311 | OUT PMDL *MdlChain,
|
---|
16312 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16313 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16314 | );
|
---|
16315 |
|
---|
16316 | typedef
|
---|
16317 | BOOLEAN
|
---|
16318 | (*PFAST_IO_MDL_READ_COMPLETE) (
|
---|
16319 | IN struct _FILE_OBJECT *FileObject,
|
---|
16320 | IN PMDL MdlChain,
|
---|
16321 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16322 | );
|
---|
16323 |
|
---|
16324 | typedef
|
---|
16325 | BOOLEAN
|
---|
16326 | (*PFAST_IO_PREPARE_MDL_WRITE) (
|
---|
16327 | IN struct _FILE_OBJECT *FileObject,
|
---|
16328 | IN PLARGE_INTEGER FileOffset,
|
---|
16329 | IN ULONG Length,
|
---|
16330 | IN ULONG LockKey,
|
---|
16331 | OUT PMDL *MdlChain,
|
---|
16332 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16333 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16334 | );
|
---|
16335 |
|
---|
16336 | typedef
|
---|
16337 | BOOLEAN
|
---|
16338 | (*PFAST_IO_MDL_WRITE_COMPLETE) (
|
---|
16339 | IN struct _FILE_OBJECT *FileObject,
|
---|
16340 | IN PLARGE_INTEGER FileOffset,
|
---|
16341 | IN PMDL MdlChain,
|
---|
16342 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16343 | );
|
---|
16344 |
|
---|
16345 | //
|
---|
16346 | // If this routine is present, it will be called by FsRtl
|
---|
16347 | // to acquire the file for the mapped page writer.
|
---|
16348 | //
|
---|
16349 |
|
---|
16350 | typedef
|
---|
16351 | NTSTATUS
|
---|
16352 | (*PFAST_IO_ACQUIRE_FOR_MOD_WRITE) (
|
---|
16353 | IN struct _FILE_OBJECT *FileObject,
|
---|
16354 | IN PLARGE_INTEGER EndingOffset,
|
---|
16355 | OUT struct _ERESOURCE **ResourceToRelease,
|
---|
16356 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16357 | );
|
---|
16358 |
|
---|
16359 | typedef
|
---|
16360 | NTSTATUS
|
---|
16361 | (*PFAST_IO_RELEASE_FOR_MOD_WRITE) (
|
---|
16362 | IN struct _FILE_OBJECT *FileObject,
|
---|
16363 | IN struct _ERESOURCE *ResourceToRelease,
|
---|
16364 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16365 | );
|
---|
16366 |
|
---|
16367 | //
|
---|
16368 | // If this routine is present, it will be called by FsRtl
|
---|
16369 | // to acquire the file for the mapped page writer.
|
---|
16370 | //
|
---|
16371 |
|
---|
16372 | typedef
|
---|
16373 | NTSTATUS
|
---|
16374 | (*PFAST_IO_ACQUIRE_FOR_CCFLUSH) (
|
---|
16375 | IN struct _FILE_OBJECT *FileObject,
|
---|
16376 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16377 | );
|
---|
16378 |
|
---|
16379 | typedef
|
---|
16380 | NTSTATUS
|
---|
16381 | (*PFAST_IO_RELEASE_FOR_CCFLUSH) (
|
---|
16382 | IN struct _FILE_OBJECT *FileObject,
|
---|
16383 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16384 | );
|
---|
16385 |
|
---|
16386 | typedef
|
---|
16387 | BOOLEAN
|
---|
16388 | (*PFAST_IO_READ_COMPRESSED) (
|
---|
16389 | IN struct _FILE_OBJECT *FileObject,
|
---|
16390 | IN PLARGE_INTEGER FileOffset,
|
---|
16391 | IN ULONG Length,
|
---|
16392 | IN ULONG LockKey,
|
---|
16393 | OUT PVOID Buffer,
|
---|
16394 | OUT PMDL *MdlChain,
|
---|
16395 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16396 | OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
|
---|
16397 | IN ULONG CompressedDataInfoLength,
|
---|
16398 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16399 | );
|
---|
16400 |
|
---|
16401 | typedef
|
---|
16402 | BOOLEAN
|
---|
16403 | (*PFAST_IO_WRITE_COMPRESSED) (
|
---|
16404 | IN struct _FILE_OBJECT *FileObject,
|
---|
16405 | IN PLARGE_INTEGER FileOffset,
|
---|
16406 | IN ULONG Length,
|
---|
16407 | IN ULONG LockKey,
|
---|
16408 | IN PVOID Buffer,
|
---|
16409 | OUT PMDL *MdlChain,
|
---|
16410 | OUT PIO_STATUS_BLOCK IoStatus,
|
---|
16411 | IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
|
---|
16412 | IN ULONG CompressedDataInfoLength,
|
---|
16413 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16414 | );
|
---|
16415 |
|
---|
16416 | typedef
|
---|
16417 | BOOLEAN
|
---|
16418 | (*PFAST_IO_MDL_READ_COMPLETE_COMPRESSED) (
|
---|
16419 | IN struct _FILE_OBJECT *FileObject,
|
---|
16420 | IN PMDL MdlChain,
|
---|
16421 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16422 | );
|
---|
16423 |
|
---|
16424 | typedef
|
---|
16425 | BOOLEAN
|
---|
16426 | (*PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED) (
|
---|
16427 | IN struct _FILE_OBJECT *FileObject,
|
---|
16428 | IN PLARGE_INTEGER FileOffset,
|
---|
16429 | IN PMDL MdlChain,
|
---|
16430 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16431 | );
|
---|
16432 |
|
---|
16433 | typedef
|
---|
16434 | BOOLEAN
|
---|
16435 | (*PFAST_IO_QUERY_OPEN) (
|
---|
16436 | IN struct _IRP *Irp,
|
---|
16437 | OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
|
---|
16438 | IN struct _DEVICE_OBJECT *DeviceObject
|
---|
16439 | );
|
---|
16440 |
|
---|
16441 | //
|
---|
16442 | // Define the structure to describe the Fast I/O dispatch routines. Any
|
---|
16443 | // additions made to this structure MUST be added monotonically to the end
|
---|
16444 | // of the structure, and fields CANNOT be removed from the middle.
|
---|
16445 | //
|
---|
16446 |
|
---|
16447 | typedef struct _FAST_IO_DISPATCH {
|
---|
16448 | ULONG SizeOfFastIoDispatch;
|
---|
16449 | PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
|
---|
16450 | PFAST_IO_READ FastIoRead;
|
---|
16451 | PFAST_IO_WRITE FastIoWrite;
|
---|
16452 | PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
|
---|
16453 | PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
|
---|
16454 | PFAST_IO_LOCK FastIoLock;
|
---|
16455 | PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
|
---|
16456 | PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
|
---|
16457 | PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
|
---|
16458 | PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
|
---|
16459 | PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
|
---|
16460 | PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
|
---|
16461 | PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
|
---|
16462 | PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
|
---|
16463 | PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
|
---|
16464 | PFAST_IO_MDL_READ MdlRead;
|
---|
16465 | PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
|
---|
16466 | PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
|
---|
16467 | PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
|
---|
16468 | PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
|
---|
16469 | PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
|
---|
16470 | PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
|
---|
16471 | PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
|
---|
16472 | PFAST_IO_QUERY_OPEN FastIoQueryOpen;
|
---|
16473 | PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
|
---|
16474 | PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
|
---|
16475 | PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
|
---|
16476 | } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
|
---|
16477 |
|
---|
16478 | //
|
---|
16479 | // Define the actions that a driver execution routine may request of the
|
---|
16480 | // adapter/controller allocation routines upon return.
|
---|
16481 | //
|
---|
16482 |
|
---|
16483 | typedef enum _IO_ALLOCATION_ACTION {
|
---|
16484 | KeepObject = 1,
|
---|
16485 | DeallocateObject,
|
---|
16486 | DeallocateObjectKeepRegisters
|
---|
16487 | } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
|
---|
16488 |
|
---|
16489 | //
|
---|
16490 | // Define device driver adapter/controller execution routine.
|
---|
16491 | //
|
---|
16492 |
|
---|
16493 | typedef
|
---|
16494 | IO_ALLOCATION_ACTION
|
---|
16495 | (*PDRIVER_CONTROL) (
|
---|
16496 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
16497 | IN struct _IRP *Irp,
|
---|
16498 | IN PVOID MapRegisterBase,
|
---|
16499 | IN PVOID Context
|
---|
16500 | );
|
---|
16501 |
|
---|
16502 | //
|
---|
16503 | // Define the I/O system's security context type for use by file system's
|
---|
16504 | // when checking access to volumes, files, and directories.
|
---|
16505 | //
|
---|
16506 |
|
---|
16507 | typedef struct _IO_SECURITY_CONTEXT {
|
---|
16508 | PSECURITY_QUALITY_OF_SERVICE SecurityQos;
|
---|
16509 | PACCESS_STATE AccessState;
|
---|
16510 | ACCESS_MASK DesiredAccess;
|
---|
16511 | ULONG FullCreateOptions;
|
---|
16512 | } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
|
---|
16513 |
|
---|
16514 | //
|
---|
16515 | // Define Volume Parameter Block (VPB) flags.
|
---|
16516 | //
|
---|
16517 |
|
---|
16518 | #define VPB_MOUNTED 0x00000001
|
---|
16519 | #define VPB_LOCKED 0x00000002
|
---|
16520 | #define VPB_PERSISTENT 0x00000004
|
---|
16521 | #define VPB_REMOVE_PENDING 0x00000008
|
---|
16522 | #define VPB_RAW_MOUNT 0x00000010
|
---|
16523 |
|
---|
16524 |
|
---|
16525 | //
|
---|
16526 | // Volume Parameter Block (VPB)
|
---|
16527 | //
|
---|
16528 |
|
---|
16529 | #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) // 32 characters
|
---|
16530 |
|
---|
16531 | typedef struct _VPB {
|
---|
16532 | CSHORT Type;
|
---|
16533 | CSHORT Size;
|
---|
16534 | USHORT Flags;
|
---|
16535 | USHORT VolumeLabelLength; // in bytes
|
---|
16536 | struct _DEVICE_OBJECT *DeviceObject;
|
---|
16537 | struct _DEVICE_OBJECT *RealDevice;
|
---|
16538 | ULONG SerialNumber;
|
---|
16539 | ULONG ReferenceCount;
|
---|
16540 | WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
|
---|
16541 | } VPB, *PVPB;
|
---|
16542 |
|
---|
16543 |
|
---|
16544 | #if defined(_WIN64)
|
---|
16545 |
|
---|
16546 | //
|
---|
16547 | // Use __inline DMA macros (hal.h)
|
---|
16548 | //
|
---|
16549 | #ifndef USE_DMA_MACROS
|
---|
16550 | #define USE_DMA_MACROS
|
---|
16551 | #endif
|
---|
16552 |
|
---|
16553 | //
|
---|
16554 | // Only PnP drivers!
|
---|
16555 | //
|
---|
16556 | #ifndef NO_LEGACY_DRIVERS
|
---|
16557 | #define NO_LEGACY_DRIVERS
|
---|
16558 | #endif
|
---|
16559 |
|
---|
16560 | #endif // _WIN64
|
---|
16561 |
|
---|
16562 |
|
---|
16563 | #if defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_))
|
---|
16564 |
|
---|
16565 |
|
---|
16566 | //
|
---|
16567 | // Define object type specific fields of various objects used by the I/O system
|
---|
16568 | //
|
---|
16569 |
|
---|
16570 | typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
|
---|
16571 |
|
---|
16572 |
|
---|
16573 | #else
|
---|
16574 |
|
---|
16575 | //
|
---|
16576 | // Define object type specific fields of various objects used by the I/O system
|
---|
16577 | //
|
---|
16578 |
|
---|
16579 | typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
|
---|
16580 |
|
---|
16581 | #endif // USE_DMA_MACROS && (_NTDDK_ || _NTDRIVER_ || _NTOSP_)
|
---|
16582 |
|
---|
16583 |
|
---|
16584 | //
|
---|
16585 | // Define Wait Context Block (WCB)
|
---|
16586 | //
|
---|
16587 |
|
---|
16588 | typedef struct _WAIT_CONTEXT_BLOCK {
|
---|
16589 | KDEVICE_QUEUE_ENTRY WaitQueueEntry;
|
---|
16590 | PDRIVER_CONTROL DeviceRoutine;
|
---|
16591 | PVOID DeviceContext;
|
---|
16592 | ULONG NumberOfMapRegisters;
|
---|
16593 | PVOID DeviceObject;
|
---|
16594 | PVOID CurrentIrp;
|
---|
16595 | PKDPC BufferChainingDpc;
|
---|
16596 | } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
|
---|
16597 |
|
---|
16598 |
|
---|
16599 |
|
---|
16600 | typedef struct _CONTROLLER_OBJECT {
|
---|
16601 | CSHORT Type;
|
---|
16602 | CSHORT Size;
|
---|
16603 | PVOID ControllerExtension;
|
---|
16604 | KDEVICE_QUEUE DeviceWaitQueue;
|
---|
16605 |
|
---|
16606 | ULONG Spare1;
|
---|
16607 | LARGE_INTEGER Spare2;
|
---|
16608 |
|
---|
16609 | } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
|
---|
16610 |
|
---|
16611 |
|
---|
16612 | //
|
---|
16613 | // Define Device Object (DO) flags
|
---|
16614 | //
|
---|
16615 | #define DO_VERIFY_VOLUME 0x00000002
|
---|
16616 | #define DO_BUFFERED_IO 0x00000004
|
---|
16617 | #define DO_EXCLUSIVE 0x00000008
|
---|
16618 | #define DO_DIRECT_IO 0x00000010
|
---|
16619 | #define DO_MAP_IO_BUFFER 0x00000020
|
---|
16620 | #define DO_DEVICE_HAS_NAME 0x00000040
|
---|
16621 | #define DO_DEVICE_INITIALIZING 0x00000080
|
---|
16622 | #define DO_SYSTEM_BOOT_PARTITION 0x00000100
|
---|
16623 | #define DO_LONG_TERM_REQUESTS 0x00000200
|
---|
16624 | #define DO_NEVER_LAST_DEVICE 0x00000400
|
---|
16625 | #define DO_SHUTDOWN_REGISTERED 0x00000800
|
---|
16626 | #define DO_BUS_ENUMERATED_DEVICE 0x00001000
|
---|
16627 | #define DO_POWER_PAGABLE 0x00002000
|
---|
16628 | #define DO_POWER_INRUSH 0x00004000
|
---|
16629 | #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
|
---|
16630 | //
|
---|
16631 | // Device Object structure definition
|
---|
16632 | //
|
---|
16633 |
|
---|
16634 | typedef struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _DEVICE_OBJECT {
|
---|
16635 | CSHORT Type;
|
---|
16636 | USHORT Size;
|
---|
16637 | LONG ReferenceCount;
|
---|
16638 | struct _DRIVER_OBJECT *DriverObject;
|
---|
16639 | struct _DEVICE_OBJECT *NextDevice;
|
---|
16640 | struct _DEVICE_OBJECT *AttachedDevice;
|
---|
16641 | struct _IRP *CurrentIrp;
|
---|
16642 | PIO_TIMER Timer;
|
---|
16643 | ULONG Flags; // See above: DO_...
|
---|
16644 | ULONG Characteristics; // See ntioapi: FILE_...
|
---|
16645 | PVPB Vpb;
|
---|
16646 | PVOID DeviceExtension;
|
---|
16647 | DEVICE_TYPE DeviceType;
|
---|
16648 | CCHAR StackSize;
|
---|
16649 | union {
|
---|
16650 | LIST_ENTRY ListEntry;
|
---|
16651 | WAIT_CONTEXT_BLOCK Wcb;
|
---|
16652 | } Queue;
|
---|
16653 | ULONG AlignmentRequirement;
|
---|
16654 | KDEVICE_QUEUE DeviceQueue;
|
---|
16655 | KDPC Dpc;
|
---|
16656 |
|
---|
16657 | //
|
---|
16658 | // The following field is for exclusive use by the filesystem to keep
|
---|
16659 | // track of the number of Fsp threads currently using the device
|
---|
16660 | //
|
---|
16661 |
|
---|
16662 | ULONG ActiveThreadCount;
|
---|
16663 | PSECURITY_DESCRIPTOR SecurityDescriptor;
|
---|
16664 | KEVENT DeviceLock;
|
---|
16665 |
|
---|
16666 | USHORT SectorSize;
|
---|
16667 | USHORT Spare1;
|
---|
16668 |
|
---|
16669 | struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
|
---|
16670 | PVOID Reserved;
|
---|
16671 | } DEVICE_OBJECT;
|
---|
16672 |
|
---|
16673 | typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
|
---|
16674 |
|
---|
16675 |
|
---|
16676 | struct _DEVICE_OBJECT_POWER_EXTENSION;
|
---|
16677 |
|
---|
16678 | typedef struct _DEVOBJ_EXTENSION {
|
---|
16679 |
|
---|
16680 | CSHORT Type;
|
---|
16681 | USHORT Size;
|
---|
16682 |
|
---|
16683 | //
|
---|
16684 | // Public part of the DeviceObjectExtension structure
|
---|
16685 | //
|
---|
16686 |
|
---|
16687 | PDEVICE_OBJECT DeviceObject; // owning device object
|
---|
16688 |
|
---|
16689 |
|
---|
16690 | } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
|
---|
16691 |
|
---|
16692 | //
|
---|
16693 | // Define Driver Object (DRVO) flags
|
---|
16694 | //
|
---|
16695 |
|
---|
16696 | #define DRVO_UNLOAD_INVOKED 0x00000001
|
---|
16697 | #define DRVO_LEGACY_DRIVER 0x00000002
|
---|
16698 | #define DRVO_BUILTIN_DRIVER 0x00000004 // Driver objects for Hal, PnP Mgr
|
---|
16699 |
|
---|
16700 | #define DRVO_REINIT_REGISTERED 0x00000008
|
---|
16701 | #define DRVO_INITIALIZED 0x00000010
|
---|
16702 | #define DRVO_BOOTREINIT_REGISTERED 0x00000020
|
---|
16703 | #define DRVO_LEGACY_RESOURCES 0x00000040
|
---|
16704 |
|
---|
16705 |
|
---|
16706 |
|
---|
16707 | typedef struct _DRIVER_EXTENSION {
|
---|
16708 |
|
---|
16709 | //
|
---|
16710 | // Back pointer to Driver Object
|
---|
16711 | //
|
---|
16712 |
|
---|
16713 | struct _DRIVER_OBJECT *DriverObject;
|
---|
16714 |
|
---|
16715 | //
|
---|
16716 | // The AddDevice entry point is called by the Plug & Play manager
|
---|
16717 | // to inform the driver when a new device instance arrives that this
|
---|
16718 | // driver must control.
|
---|
16719 | //
|
---|
16720 |
|
---|
16721 | PDRIVER_ADD_DEVICE AddDevice;
|
---|
16722 |
|
---|
16723 | //
|
---|
16724 | // The count field is used to count the number of times the driver has
|
---|
16725 | // had its registered reinitialization routine invoked.
|
---|
16726 | //
|
---|
16727 |
|
---|
16728 | ULONG Count;
|
---|
16729 |
|
---|
16730 | //
|
---|
16731 | // The service name field is used by the pnp manager to determine
|
---|
16732 | // where the driver related info is stored in the registry.
|
---|
16733 | //
|
---|
16734 |
|
---|
16735 | UNICODE_STRING ServiceKeyName;
|
---|
16736 |
|
---|
16737 | //
|
---|
16738 | // Note: any new shared fields get added here.
|
---|
16739 | //
|
---|
16740 |
|
---|
16741 |
|
---|
16742 | } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
|
---|
16743 |
|
---|
16744 |
|
---|
16745 | typedef struct _DRIVER_OBJECT {
|
---|
16746 | CSHORT Type;
|
---|
16747 | CSHORT Size;
|
---|
16748 |
|
---|
16749 | //
|
---|
16750 | // The following links all of the devices created by a single driver
|
---|
16751 | // together on a list, and the Flags word provides an extensible flag
|
---|
16752 | // location for driver objects.
|
---|
16753 | //
|
---|
16754 |
|
---|
16755 | PDEVICE_OBJECT DeviceObject;
|
---|
16756 | ULONG Flags;
|
---|
16757 |
|
---|
16758 | //
|
---|
16759 | // The following section describes where the driver is loaded. The count
|
---|
16760 | // field is used to count the number of times the driver has had its
|
---|
16761 | // registered reinitialization routine invoked.
|
---|
16762 | //
|
---|
16763 |
|
---|
16764 | PVOID DriverStart;
|
---|
16765 | ULONG DriverSize;
|
---|
16766 | PVOID DriverSection;
|
---|
16767 | PDRIVER_EXTENSION DriverExtension;
|
---|
16768 |
|
---|
16769 | //
|
---|
16770 | // The driver name field is used by the error log thread
|
---|
16771 | // determine the name of the driver that an I/O request is/was bound.
|
---|
16772 | //
|
---|
16773 |
|
---|
16774 | UNICODE_STRING DriverName;
|
---|
16775 |
|
---|
16776 | //
|
---|
16777 | // The following section is for registry support. This is a pointer
|
---|
16778 | // to the path to the hardware information in the registry
|
---|
16779 | //
|
---|
16780 |
|
---|
16781 | PUNICODE_STRING HardwareDatabase;
|
---|
16782 |
|
---|
16783 | //
|
---|
16784 | // The following section contains the optional pointer to an array of
|
---|
16785 | // alternate entry points to a driver for "fast I/O" support. Fast I/O
|
---|
16786 | // is performed by invoking the driver routine directly with separate
|
---|
16787 | // parameters, rather than using the standard IRP call mechanism. Note
|
---|
16788 | // that these functions may only be used for synchronous I/O, and when
|
---|
16789 | // the file is cached.
|
---|
16790 | //
|
---|
16791 |
|
---|
16792 | PFAST_IO_DISPATCH FastIoDispatch;
|
---|
16793 |
|
---|
16794 | //
|
---|
16795 | // The following section describes the entry points to this particular
|
---|
16796 | // driver. Note that the major function dispatch table must be the last
|
---|
16797 | // field in the object so that it remains extensible.
|
---|
16798 | //
|
---|
16799 |
|
---|
16800 | PDRIVER_INITIALIZE DriverInit;
|
---|
16801 | PDRIVER_STARTIO DriverStartIo;
|
---|
16802 | PDRIVER_UNLOAD DriverUnload;
|
---|
16803 | PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
|
---|
16804 |
|
---|
16805 | } DRIVER_OBJECT;
|
---|
16806 | typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
|
---|
16807 |
|
---|
16808 |
|
---|
16809 |
|
---|
16810 | //
|
---|
16811 | // The following structure is pointed to by the SectionObject pointer field
|
---|
16812 | // of a file object, and is allocated by the various NT file systems.
|
---|
16813 | //
|
---|
16814 |
|
---|
16815 | typedef struct _SECTION_OBJECT_POINTERS {
|
---|
16816 | PVOID DataSectionObject;
|
---|
16817 | PVOID SharedCacheMap;
|
---|
16818 | PVOID ImageSectionObject;
|
---|
16819 | } SECTION_OBJECT_POINTERS;
|
---|
16820 | typedef SECTION_OBJECT_POINTERS *PSECTION_OBJECT_POINTERS;
|
---|
16821 |
|
---|
16822 | //
|
---|
16823 | // Define the format of a completion message.
|
---|
16824 | //
|
---|
16825 |
|
---|
16826 | typedef struct _IO_COMPLETION_CONTEXT {
|
---|
16827 | PVOID Port;
|
---|
16828 | PVOID Key;
|
---|
16829 | } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
|
---|
16830 |
|
---|
16831 | //
|
---|
16832 | // Define File Object (FO) flags
|
---|
16833 | //
|
---|
16834 |
|
---|
16835 | #define FO_FILE_OPEN 0x00000001
|
---|
16836 | #define FO_SYNCHRONOUS_IO 0x00000002
|
---|
16837 | #define FO_ALERTABLE_IO 0x00000004
|
---|
16838 | #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
|
---|
16839 | #define FO_WRITE_THROUGH 0x00000010
|
---|
16840 | #define FO_SEQUENTIAL_ONLY 0x00000020
|
---|
16841 | #define FO_CACHE_SUPPORTED 0x00000040
|
---|
16842 | #define FO_NAMED_PIPE 0x00000080
|
---|
16843 | #define FO_STREAM_FILE 0x00000100
|
---|
16844 | #define FO_MAILSLOT 0x00000200
|
---|
16845 | #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
|
---|
16846 | #define FO_DIRECT_DEVICE_OPEN 0x00000800
|
---|
16847 | #define FO_FILE_MODIFIED 0x00001000
|
---|
16848 | #define FO_FILE_SIZE_CHANGED 0x00002000
|
---|
16849 | #define FO_CLEANUP_COMPLETE 0x00004000
|
---|
16850 | #define FO_TEMPORARY_FILE 0x00008000
|
---|
16851 | #define FO_DELETE_ON_CLOSE 0x00010000
|
---|
16852 | #define FO_OPENED_CASE_SENSITIVE 0x00020000
|
---|
16853 | #define FO_HANDLE_CREATED 0x00040000
|
---|
16854 | #define FO_FILE_FAST_IO_READ 0x00080000
|
---|
16855 | #define FO_RANDOM_ACCESS 0x00100000
|
---|
16856 | #define FO_FILE_OPEN_CANCELLED 0x00200000
|
---|
16857 | #define FO_VOLUME_OPEN 0x00400000
|
---|
16858 | #define FO_FILE_OBJECT_HAS_EXTENSION 0x00800000
|
---|
16859 | #define FO_REMOTE_ORIGIN 0x01000000
|
---|
16860 |
|
---|
16861 | typedef struct _FILE_OBJECT {
|
---|
16862 | CSHORT Type;
|
---|
16863 | CSHORT Size;
|
---|
16864 | PDEVICE_OBJECT DeviceObject;
|
---|
16865 | PVPB Vpb;
|
---|
16866 | PVOID FsContext;
|
---|
16867 | PVOID FsContext2;
|
---|
16868 | PSECTION_OBJECT_POINTERS SectionObjectPointer;
|
---|
16869 | PVOID PrivateCacheMap;
|
---|
16870 | NTSTATUS FinalStatus;
|
---|
16871 | struct _FILE_OBJECT *RelatedFileObject;
|
---|
16872 | BOOLEAN LockOperation;
|
---|
16873 | BOOLEAN DeletePending;
|
---|
16874 | BOOLEAN ReadAccess;
|
---|
16875 | BOOLEAN WriteAccess;
|
---|
16876 | BOOLEAN DeleteAccess;
|
---|
16877 | BOOLEAN SharedRead;
|
---|
16878 | BOOLEAN SharedWrite;
|
---|
16879 | BOOLEAN SharedDelete;
|
---|
16880 | ULONG Flags;
|
---|
16881 | UNICODE_STRING FileName;
|
---|
16882 | LARGE_INTEGER CurrentByteOffset;
|
---|
16883 | ULONG Waiters;
|
---|
16884 | ULONG Busy;
|
---|
16885 | PVOID LastLock;
|
---|
16886 | KEVENT Lock;
|
---|
16887 | KEVENT Event;
|
---|
16888 | PIO_COMPLETION_CONTEXT CompletionContext;
|
---|
16889 | } FILE_OBJECT;
|
---|
16890 | typedef struct _FILE_OBJECT *PFILE_OBJECT;
|
---|
16891 |
|
---|
16892 | //
|
---|
16893 | // Define I/O Request Packet (IRP) flags
|
---|
16894 | //
|
---|
16895 |
|
---|
16896 | #define IRP_NOCACHE 0x00000001
|
---|
16897 | #define IRP_PAGING_IO 0x00000002
|
---|
16898 | #define IRP_MOUNT_COMPLETION 0x00000002
|
---|
16899 | #define IRP_SYNCHRONOUS_API 0x00000004
|
---|
16900 | #define IRP_ASSOCIATED_IRP 0x00000008
|
---|
16901 | #define IRP_BUFFERED_IO 0x00000010
|
---|
16902 | #define IRP_DEALLOCATE_BUFFER 0x00000020
|
---|
16903 | #define IRP_INPUT_OPERATION 0x00000040
|
---|
16904 | #define IRP_SYNCHRONOUS_PAGING_IO 0x00000040
|
---|
16905 | #define IRP_CREATE_OPERATION 0x00000080
|
---|
16906 | #define IRP_READ_OPERATION 0x00000100
|
---|
16907 | #define IRP_WRITE_OPERATION 0x00000200
|
---|
16908 | #define IRP_CLOSE_OPERATION 0x00000400
|
---|
16909 |
|
---|
16910 |
|
---|
16911 | #define IRP_DEFER_IO_COMPLETION 0x00000800
|
---|
16912 | #define IRP_OB_QUERY_NAME 0x00001000
|
---|
16913 | #define IRP_HOLD_DEVICE_QUEUE 0x00002000
|
---|
16914 |
|
---|
16915 |
|
---|
16916 |
|
---|
16917 | //
|
---|
16918 | // Define I/O request packet (IRP) alternate flags for allocation control.
|
---|
16919 | //
|
---|
16920 |
|
---|
16921 | #define IRP_QUOTA_CHARGED 0x01
|
---|
16922 | #define IRP_ALLOCATED_MUST_SUCCEED 0x02
|
---|
16923 | #define IRP_ALLOCATED_FIXED_SIZE 0x04
|
---|
16924 | #define IRP_LOOKASIDE_ALLOCATION 0x08
|
---|
16925 |
|
---|
16926 | //
|
---|
16927 | // I/O Request Packet (IRP) definition
|
---|
16928 | //
|
---|
16929 |
|
---|
16930 | typedef struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _IRP {
|
---|
16931 | CSHORT Type;
|
---|
16932 | USHORT Size;
|
---|
16933 |
|
---|
16934 | //
|
---|
16935 | // Define the common fields used to control the IRP.
|
---|
16936 | //
|
---|
16937 |
|
---|
16938 | //
|
---|
16939 | // Define a pointer to the Memory Descriptor List (MDL) for this I/O
|
---|
16940 | // request. This field is only used if the I/O is "direct I/O".
|
---|
16941 | //
|
---|
16942 |
|
---|
16943 | PMDL MdlAddress;
|
---|
16944 |
|
---|
16945 | //
|
---|
16946 | // Flags word - used to remember various flags.
|
---|
16947 | //
|
---|
16948 |
|
---|
16949 | ULONG Flags;
|
---|
16950 |
|
---|
16951 | //
|
---|
16952 | // The following union is used for one of three purposes:
|
---|
16953 | //
|
---|
16954 | // 1. This IRP is an associated IRP. The field is a pointer to a master
|
---|
16955 | // IRP.
|
---|
16956 | //
|
---|
16957 | // 2. This is the master IRP. The field is the count of the number of
|
---|
16958 | // IRPs which must complete (associated IRPs) before the master can
|
---|
16959 | // complete.
|
---|
16960 | //
|
---|
16961 | // 3. This operation is being buffered and the field is the address of
|
---|
16962 | // the system space buffer.
|
---|
16963 | //
|
---|
16964 |
|
---|
16965 | union {
|
---|
16966 | struct _IRP *MasterIrp;
|
---|
16967 | LONG IrpCount;
|
---|
16968 | PVOID SystemBuffer;
|
---|
16969 | } AssociatedIrp;
|
---|
16970 |
|
---|
16971 | //
|
---|
16972 | // Thread list entry - allows queueing the IRP to the thread pending I/O
|
---|
16973 | // request packet list.
|
---|
16974 | //
|
---|
16975 |
|
---|
16976 | LIST_ENTRY ThreadListEntry;
|
---|
16977 |
|
---|
16978 | //
|
---|
16979 | // I/O status - final status of operation.
|
---|
16980 | //
|
---|
16981 |
|
---|
16982 | IO_STATUS_BLOCK IoStatus;
|
---|
16983 |
|
---|
16984 | //
|
---|
16985 | // Requestor mode - mode of the original requestor of this operation.
|
---|
16986 | //
|
---|
16987 |
|
---|
16988 | KPROCESSOR_MODE RequestorMode;
|
---|
16989 |
|
---|
16990 | //
|
---|
16991 | // Pending returned - TRUE if pending was initially returned as the
|
---|
16992 | // status for this packet.
|
---|
16993 | //
|
---|
16994 |
|
---|
16995 | BOOLEAN PendingReturned;
|
---|
16996 |
|
---|
16997 | //
|
---|
16998 | // Stack state information.
|
---|
16999 | //
|
---|
17000 |
|
---|
17001 | CHAR StackCount;
|
---|
17002 | CHAR CurrentLocation;
|
---|
17003 |
|
---|
17004 | //
|
---|
17005 | // Cancel - packet has been canceled.
|
---|
17006 | //
|
---|
17007 |
|
---|
17008 | BOOLEAN Cancel;
|
---|
17009 |
|
---|
17010 | //
|
---|
17011 | // Cancel Irql - Irql at which the cancel spinlock was acquired.
|
---|
17012 | //
|
---|
17013 |
|
---|
17014 | KIRQL CancelIrql;
|
---|
17015 |
|
---|
17016 | //
|
---|
17017 | // ApcEnvironment - Used to save the APC environment at the time that the
|
---|
17018 | // packet was initialized.
|
---|
17019 | //
|
---|
17020 |
|
---|
17021 | CCHAR ApcEnvironment;
|
---|
17022 |
|
---|
17023 | //
|
---|
17024 | // Allocation control flags.
|
---|
17025 | //
|
---|
17026 |
|
---|
17027 | UCHAR AllocationFlags;
|
---|
17028 |
|
---|
17029 | //
|
---|
17030 | // User parameters.
|
---|
17031 | //
|
---|
17032 |
|
---|
17033 | PIO_STATUS_BLOCK UserIosb;
|
---|
17034 | PKEVENT UserEvent;
|
---|
17035 | union {
|
---|
17036 | struct {
|
---|
17037 | PIO_APC_ROUTINE UserApcRoutine;
|
---|
17038 | PVOID UserApcContext;
|
---|
17039 | } AsynchronousParameters;
|
---|
17040 | LARGE_INTEGER AllocationSize;
|
---|
17041 | } Overlay;
|
---|
17042 |
|
---|
17043 | //
|
---|
17044 | // CancelRoutine - Used to contain the address of a cancel routine supplied
|
---|
17045 | // by a device driver when the IRP is in a cancelable state.
|
---|
17046 | //
|
---|
17047 |
|
---|
17048 | PDRIVER_CANCEL CancelRoutine;
|
---|
17049 |
|
---|
17050 | //
|
---|
17051 | // Note that the UserBuffer parameter is outside of the stack so that I/O
|
---|
17052 | // completion can copy data back into the user's address space without
|
---|
17053 | // having to know exactly which service was being invoked. The length
|
---|
17054 | // of the copy is stored in the second half of the I/O status block. If
|
---|
17055 | // the UserBuffer field is NULL, then no copy is performed.
|
---|
17056 | //
|
---|
17057 |
|
---|
17058 | PVOID UserBuffer;
|
---|
17059 |
|
---|
17060 | //
|
---|
17061 | // Kernel structures
|
---|
17062 | //
|
---|
17063 | // The following section contains kernel structures which the IRP needs
|
---|
17064 | // in order to place various work information in kernel controller system
|
---|
17065 | // queues. Because the size and alignment cannot be controlled, they are
|
---|
17066 | // placed here at the end so they just hang off and do not affect the
|
---|
17067 | // alignment of other fields in the IRP.
|
---|
17068 | //
|
---|
17069 |
|
---|
17070 | union {
|
---|
17071 |
|
---|
17072 | struct {
|
---|
17073 |
|
---|
17074 | union {
|
---|
17075 |
|
---|
17076 | //
|
---|
17077 | // DeviceQueueEntry - The device queue entry field is used to
|
---|
17078 | // queue the IRP to the device driver device queue.
|
---|
17079 | //
|
---|
17080 |
|
---|
17081 | KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
|
---|
17082 |
|
---|
17083 | struct {
|
---|
17084 |
|
---|
17085 | //
|
---|
17086 | // The following are available to the driver to use in
|
---|
17087 | // whatever manner is desired, while the driver owns the
|
---|
17088 | // packet.
|
---|
17089 | //
|
---|
17090 |
|
---|
17091 | PVOID DriverContext[4];
|
---|
17092 |
|
---|
17093 | } ;
|
---|
17094 |
|
---|
17095 | } ;
|
---|
17096 |
|
---|
17097 | //
|
---|
17098 | // Thread - pointer to caller's Thread Control Block.
|
---|
17099 | //
|
---|
17100 |
|
---|
17101 | PETHREAD Thread;
|
---|
17102 |
|
---|
17103 | //
|
---|
17104 | // Auxiliary buffer - pointer to any auxiliary buffer that is
|
---|
17105 | // required to pass information to a driver that is not contained
|
---|
17106 | // in a normal buffer.
|
---|
17107 | //
|
---|
17108 |
|
---|
17109 | PCHAR AuxiliaryBuffer;
|
---|
17110 |
|
---|
17111 | //
|
---|
17112 | // The following unnamed structure must be exactly identical
|
---|
17113 | // to the unnamed structure used in the minipacket header used
|
---|
17114 | // for completion queue entries.
|
---|
17115 | //
|
---|
17116 |
|
---|
17117 | struct {
|
---|
17118 |
|
---|
17119 | //
|
---|
17120 | // List entry - used to queue the packet to completion queue, among
|
---|
17121 | // others.
|
---|
17122 | //
|
---|
17123 |
|
---|
17124 | LIST_ENTRY ListEntry;
|
---|
17125 |
|
---|
17126 | union {
|
---|
17127 |
|
---|
17128 | //
|
---|
17129 | // Current stack location - contains a pointer to the current
|
---|
17130 | // IO_STACK_LOCATION structure in the IRP stack. This field
|
---|
17131 | // should never be directly accessed by drivers. They should
|
---|
17132 | // use the standard functions.
|
---|
17133 | //
|
---|
17134 |
|
---|
17135 | struct _IO_STACK_LOCATION *CurrentStackLocation;
|
---|
17136 |
|
---|
17137 | //
|
---|
17138 | // Minipacket type.
|
---|
17139 | //
|
---|
17140 |
|
---|
17141 | ULONG PacketType;
|
---|
17142 | };
|
---|
17143 | };
|
---|
17144 |
|
---|
17145 | //
|
---|
17146 | // Original file object - pointer to the original file object
|
---|
17147 | // that was used to open the file. This field is owned by the
|
---|
17148 | // I/O system and should not be used by any other drivers.
|
---|
17149 | //
|
---|
17150 |
|
---|
17151 | PFILE_OBJECT OriginalFileObject;
|
---|
17152 |
|
---|
17153 | } Overlay;
|
---|
17154 |
|
---|
17155 | //
|
---|
17156 | // APC - This APC control block is used for the special kernel APC as
|
---|
17157 | // well as for the caller's APC, if one was specified in the original
|
---|
17158 | // argument list. If so, then the APC is reused for the normal APC for
|
---|
17159 | // whatever mode the caller was in and the "special" routine that is
|
---|
17160 | // invoked before the APC gets control simply deallocates the IRP.
|
---|
17161 | //
|
---|
17162 |
|
---|
17163 | KAPC Apc;
|
---|
17164 |
|
---|
17165 | //
|
---|
17166 | // CompletionKey - This is the key that is used to distinguish
|
---|
17167 | // individual I/O operations initiated on a single file handle.
|
---|
17168 | //
|
---|
17169 |
|
---|
17170 | PVOID CompletionKey;
|
---|
17171 |
|
---|
17172 | } Tail;
|
---|
17173 |
|
---|
17174 | } IRP, *PIRP;
|
---|
17175 |
|
---|
17176 | //
|
---|
17177 | // Define completion routine types for use in stack locations in an IRP
|
---|
17178 | //
|
---|
17179 |
|
---|
17180 | typedef
|
---|
17181 | NTSTATUS
|
---|
17182 | (*PIO_COMPLETION_ROUTINE) (
|
---|
17183 | IN PDEVICE_OBJECT DeviceObject,
|
---|
17184 | IN PIRP Irp,
|
---|
17185 | IN PVOID Context
|
---|
17186 | );
|
---|
17187 |
|
---|
17188 | //
|
---|
17189 | // Define stack location control flags
|
---|
17190 | //
|
---|
17191 |
|
---|
17192 | #define SL_PENDING_RETURNED 0x01
|
---|
17193 | #define SL_INVOKE_ON_CANCEL 0x20
|
---|
17194 | #define SL_INVOKE_ON_SUCCESS 0x40
|
---|
17195 | #define SL_INVOKE_ON_ERROR 0x80
|
---|
17196 |
|
---|
17197 | //
|
---|
17198 | // Define flags for various functions
|
---|
17199 | //
|
---|
17200 |
|
---|
17201 | //
|
---|
17202 | // Create / Create Named Pipe
|
---|
17203 | //
|
---|
17204 | // The following flags must exactly match those in the IoCreateFile call's
|
---|
17205 | // options. The case sensitive flag is added in later, by the parse routine,
|
---|
17206 | // and is not an actual option to open. Rather, it is part of the object
|
---|
17207 | // manager's attributes structure.
|
---|
17208 | //
|
---|
17209 |
|
---|
17210 | #define SL_FORCE_ACCESS_CHECK 0x01
|
---|
17211 | #define SL_OPEN_PAGING_FILE 0x02
|
---|
17212 | #define SL_OPEN_TARGET_DIRECTORY 0x04
|
---|
17213 |
|
---|
17214 | #define SL_CASE_SENSITIVE 0x80
|
---|
17215 |
|
---|
17216 | //
|
---|
17217 | // Read / Write
|
---|
17218 | //
|
---|
17219 |
|
---|
17220 | #define SL_KEY_SPECIFIED 0x01
|
---|
17221 | #define SL_OVERRIDE_VERIFY_VOLUME 0x02
|
---|
17222 | #define SL_WRITE_THROUGH 0x04
|
---|
17223 | #define SL_FT_SEQUENTIAL_WRITE 0x08
|
---|
17224 |
|
---|
17225 | //
|
---|
17226 | // Device I/O Control
|
---|
17227 | //
|
---|
17228 | //
|
---|
17229 | // Same SL_OVERRIDE_VERIFY_VOLUME as for read/write above.
|
---|
17230 | //
|
---|
17231 |
|
---|
17232 | #define SL_READ_ACCESS_GRANTED 0x01
|
---|
17233 | #define SL_WRITE_ACCESS_GRANTED 0x04 // Gap for SL_OVERRIDE_VERIFY_VOLUME
|
---|
17234 |
|
---|
17235 | //
|
---|
17236 | // Lock
|
---|
17237 | //
|
---|
17238 |
|
---|
17239 | #define SL_FAIL_IMMEDIATELY 0x01
|
---|
17240 | #define SL_EXCLUSIVE_LOCK 0x02
|
---|
17241 |
|
---|
17242 | //
|
---|
17243 | // QueryDirectory / QueryEa / QueryQuota
|
---|
17244 | //
|
---|
17245 |
|
---|
17246 | #define SL_RESTART_SCAN 0x01
|
---|
17247 | #define SL_RETURN_SINGLE_ENTRY 0x02
|
---|
17248 | #define SL_INDEX_SPECIFIED 0x04
|
---|
17249 |
|
---|
17250 | //
|
---|
17251 | // NotifyDirectory
|
---|
17252 | //
|
---|
17253 |
|
---|
17254 | #define SL_WATCH_TREE 0x01
|
---|
17255 |
|
---|
17256 | //
|
---|
17257 | // FileSystemControl
|
---|
17258 | //
|
---|
17259 | // minor: mount/verify volume
|
---|
17260 | //
|
---|
17261 |
|
---|
17262 | #define SL_ALLOW_RAW_MOUNT 0x01
|
---|
17263 |
|
---|
17264 | //
|
---|
17265 | // Define PNP/POWER types required by IRP_MJ_PNP/IRP_MJ_POWER.
|
---|
17266 | //
|
---|
17267 |
|
---|
17268 | typedef enum _DEVICE_RELATION_TYPE {
|
---|
17269 | BusRelations,
|
---|
17270 | EjectionRelations,
|
---|
17271 | PowerRelations,
|
---|
17272 | RemovalRelations,
|
---|
17273 | TargetDeviceRelation,
|
---|
17274 | SingleBusRelations
|
---|
17275 | } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
|
---|
17276 |
|
---|
17277 | typedef struct _DEVICE_RELATIONS {
|
---|
17278 | ULONG Count;
|
---|
17279 | PDEVICE_OBJECT Objects[1]; // variable length
|
---|
17280 | } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
|
---|
17281 |
|
---|
17282 | typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
|
---|
17283 | DeviceUsageTypeUndefined,
|
---|
17284 | DeviceUsageTypePaging,
|
---|
17285 | DeviceUsageTypeHibernation,
|
---|
17286 | DeviceUsageTypeDumpFile
|
---|
17287 | } DEVICE_USAGE_NOTIFICATION_TYPE;
|
---|
17288 |
|
---|
17289 |
|
---|
17290 |
|
---|
17291 | // workaround overloaded definition (rpc generated headers all define INTERFACE
|
---|
17292 | // to match the class name).
|
---|
17293 | #undef INTERFACE
|
---|
17294 |
|
---|
17295 | typedef struct _INTERFACE {
|
---|
17296 | USHORT Size;
|
---|
17297 | USHORT Version;
|
---|
17298 | PVOID Context;
|
---|
17299 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
17300 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
17301 | // interface specific entries go here
|
---|
17302 | } INTERFACE, *PINTERFACE;
|
---|
17303 |
|
---|
17304 |
|
---|
17305 |
|
---|
17306 | typedef struct _DEVICE_CAPABILITIES {
|
---|
17307 | USHORT Size;
|
---|
17308 | USHORT Version; // the version documented here is version 1
|
---|
17309 | ULONG DeviceD1:1;
|
---|
17310 | ULONG DeviceD2:1;
|
---|
17311 | ULONG LockSupported:1;
|
---|
17312 | ULONG EjectSupported:1; // Ejectable in S0
|
---|
17313 | ULONG Removable:1;
|
---|
17314 | ULONG DockDevice:1;
|
---|
17315 | ULONG UniqueID:1;
|
---|
17316 | ULONG SilentInstall:1;
|
---|
17317 | ULONG RawDeviceOK:1;
|
---|
17318 | ULONG SurpriseRemovalOK:1;
|
---|
17319 | ULONG WakeFromD0:1;
|
---|
17320 | ULONG WakeFromD1:1;
|
---|
17321 | ULONG WakeFromD2:1;
|
---|
17322 | ULONG WakeFromD3:1;
|
---|
17323 | ULONG HardwareDisabled:1;
|
---|
17324 | ULONG NonDynamic:1;
|
---|
17325 | ULONG WarmEjectSupported:1;
|
---|
17326 | ULONG NoDisplayInUI:1;
|
---|
17327 | ULONG Reserved:14;
|
---|
17328 |
|
---|
17329 | ULONG Address;
|
---|
17330 | ULONG UINumber;
|
---|
17331 |
|
---|
17332 | DEVICE_POWER_STATE DeviceState[POWER_SYSTEM_MAXIMUM];
|
---|
17333 | SYSTEM_POWER_STATE SystemWake;
|
---|
17334 | DEVICE_POWER_STATE DeviceWake;
|
---|
17335 | ULONG D1Latency;
|
---|
17336 | ULONG D2Latency;
|
---|
17337 | ULONG D3Latency;
|
---|
17338 | } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
|
---|
17339 |
|
---|
17340 | typedef struct _POWER_SEQUENCE {
|
---|
17341 | ULONG SequenceD1;
|
---|
17342 | ULONG SequenceD2;
|
---|
17343 | ULONG SequenceD3;
|
---|
17344 | } POWER_SEQUENCE, *PPOWER_SEQUENCE;
|
---|
17345 |
|
---|
17346 | typedef enum {
|
---|
17347 | BusQueryDeviceID = 0, // <Enumerator>\<Enumerator-specific device id>
|
---|
17348 | BusQueryHardwareIDs = 1, // Hardware ids
|
---|
17349 | BusQueryCompatibleIDs = 2, // compatible device ids
|
---|
17350 | BusQueryInstanceID = 3, // persistent id for this instance of the device
|
---|
17351 | BusQueryDeviceSerialNumber = 4 // serial number for this device
|
---|
17352 | } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
|
---|
17353 |
|
---|
17354 | typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
|
---|
17355 |
|
---|
17356 | #define PNP_DEVICE_DISABLED 0x00000001
|
---|
17357 | #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
|
---|
17358 | #define PNP_DEVICE_FAILED 0x00000004
|
---|
17359 | #define PNP_DEVICE_REMOVED 0x00000008
|
---|
17360 | #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
|
---|
17361 | #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
|
---|
17362 |
|
---|
17363 | typedef enum {
|
---|
17364 | DeviceTextDescription = 0, // DeviceDesc property
|
---|
17365 | DeviceTextLocationInformation = 1 // DeviceLocation property
|
---|
17366 | } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
|
---|
17367 |
|
---|
17368 | //
|
---|
17369 | // Define I/O Request Packet (IRP) stack locations
|
---|
17370 | //
|
---|
17371 |
|
---|
17372 | #if !defined(_AMD64_) && !defined(_IA64_)
|
---|
17373 | #include "pshpack4.h"
|
---|
17374 | #endif
|
---|
17375 |
|
---|
17376 |
|
---|
17377 |
|
---|
17378 | #if defined(_WIN64)
|
---|
17379 | #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
|
---|
17380 | #else
|
---|
17381 | #define POINTER_ALIGNMENT
|
---|
17382 | #endif
|
---|
17383 |
|
---|
17384 |
|
---|
17385 |
|
---|
17386 | typedef struct _IO_STACK_LOCATION {
|
---|
17387 | UCHAR MajorFunction;
|
---|
17388 | UCHAR MinorFunction;
|
---|
17389 | UCHAR Flags;
|
---|
17390 | UCHAR Control;
|
---|
17391 |
|
---|
17392 | //
|
---|
17393 | // The following user parameters are based on the service that is being
|
---|
17394 | // invoked. Drivers and file systems can determine which set to use based
|
---|
17395 | // on the above major and minor function codes.
|
---|
17396 | //
|
---|
17397 |
|
---|
17398 | union {
|
---|
17399 |
|
---|
17400 | //
|
---|
17401 | // System service parameters for: NtCreateFile
|
---|
17402 | //
|
---|
17403 |
|
---|
17404 | struct {
|
---|
17405 | PIO_SECURITY_CONTEXT SecurityContext;
|
---|
17406 | ULONG Options;
|
---|
17407 | USHORT POINTER_ALIGNMENT FileAttributes;
|
---|
17408 | USHORT ShareAccess;
|
---|
17409 | ULONG POINTER_ALIGNMENT EaLength;
|
---|
17410 | } Create;
|
---|
17411 |
|
---|
17412 |
|
---|
17413 | //
|
---|
17414 | // System service parameters for: NtReadFile
|
---|
17415 | //
|
---|
17416 |
|
---|
17417 | struct {
|
---|
17418 | ULONG Length;
|
---|
17419 | ULONG POINTER_ALIGNMENT Key;
|
---|
17420 | LARGE_INTEGER ByteOffset;
|
---|
17421 | } Read;
|
---|
17422 |
|
---|
17423 | //
|
---|
17424 | // System service parameters for: NtWriteFile
|
---|
17425 | //
|
---|
17426 |
|
---|
17427 | struct {
|
---|
17428 | ULONG Length;
|
---|
17429 | ULONG POINTER_ALIGNMENT Key;
|
---|
17430 | LARGE_INTEGER ByteOffset;
|
---|
17431 | } Write;
|
---|
17432 |
|
---|
17433 |
|
---|
17434 | //
|
---|
17435 | // System service parameters for: NtQueryInformationFile
|
---|
17436 | //
|
---|
17437 |
|
---|
17438 | struct {
|
---|
17439 | ULONG Length;
|
---|
17440 | FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
|
---|
17441 | } QueryFile;
|
---|
17442 |
|
---|
17443 | //
|
---|
17444 | // System service parameters for: NtSetInformationFile
|
---|
17445 | //
|
---|
17446 |
|
---|
17447 | struct {
|
---|
17448 | ULONG Length;
|
---|
17449 | FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
|
---|
17450 | PFILE_OBJECT FileObject;
|
---|
17451 | union {
|
---|
17452 | struct {
|
---|
17453 | BOOLEAN ReplaceIfExists;
|
---|
17454 | BOOLEAN AdvanceOnly;
|
---|
17455 | };
|
---|
17456 | ULONG ClusterCount;
|
---|
17457 | HANDLE DeleteHandle;
|
---|
17458 | };
|
---|
17459 | } SetFile;
|
---|
17460 |
|
---|
17461 |
|
---|
17462 | //
|
---|
17463 | // System service parameters for: NtQueryVolumeInformationFile
|
---|
17464 | //
|
---|
17465 |
|
---|
17466 | struct {
|
---|
17467 | ULONG Length;
|
---|
17468 | FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
|
---|
17469 | } QueryVolume;
|
---|
17470 |
|
---|
17471 |
|
---|
17472 | //
|
---|
17473 | // System service parameters for: NtFlushBuffersFile
|
---|
17474 | //
|
---|
17475 | // No extra user-supplied parameters.
|
---|
17476 | //
|
---|
17477 |
|
---|
17478 |
|
---|
17479 | //
|
---|
17480 | // System service parameters for: NtDeviceIoControlFile
|
---|
17481 | //
|
---|
17482 | // Note that the user's output buffer is stored in the UserBuffer field
|
---|
17483 | // and the user's input buffer is stored in the SystemBuffer field.
|
---|
17484 | //
|
---|
17485 |
|
---|
17486 | struct {
|
---|
17487 | ULONG OutputBufferLength;
|
---|
17488 | ULONG POINTER_ALIGNMENT InputBufferLength;
|
---|
17489 | ULONG POINTER_ALIGNMENT IoControlCode;
|
---|
17490 | PVOID Type3InputBuffer;
|
---|
17491 | } DeviceIoControl;
|
---|
17492 |
|
---|
17493 |
|
---|
17494 | //
|
---|
17495 | // System service parameters for: NtQuerySecurityObject
|
---|
17496 | //
|
---|
17497 |
|
---|
17498 | struct {
|
---|
17499 | SECURITY_INFORMATION SecurityInformation;
|
---|
17500 | ULONG POINTER_ALIGNMENT Length;
|
---|
17501 | } QuerySecurity;
|
---|
17502 |
|
---|
17503 | //
|
---|
17504 | // System service parameters for: NtSetSecurityObject
|
---|
17505 | //
|
---|
17506 |
|
---|
17507 | struct {
|
---|
17508 | SECURITY_INFORMATION SecurityInformation;
|
---|
17509 | PSECURITY_DESCRIPTOR SecurityDescriptor;
|
---|
17510 | } SetSecurity;
|
---|
17511 |
|
---|
17512 |
|
---|
17513 | //
|
---|
17514 | // Non-system service parameters.
|
---|
17515 | //
|
---|
17516 | // Parameters for MountVolume
|
---|
17517 | //
|
---|
17518 |
|
---|
17519 | struct {
|
---|
17520 | PVPB Vpb;
|
---|
17521 | PDEVICE_OBJECT DeviceObject;
|
---|
17522 | } MountVolume;
|
---|
17523 |
|
---|
17524 | //
|
---|
17525 | // Parameters for VerifyVolume
|
---|
17526 | //
|
---|
17527 |
|
---|
17528 | struct {
|
---|
17529 | PVPB Vpb;
|
---|
17530 | PDEVICE_OBJECT DeviceObject;
|
---|
17531 | } VerifyVolume;
|
---|
17532 |
|
---|
17533 | //
|
---|
17534 | // Parameters for Scsi with internal device control.
|
---|
17535 | //
|
---|
17536 |
|
---|
17537 | struct {
|
---|
17538 | struct _SCSI_REQUEST_BLOCK *Srb;
|
---|
17539 | } Scsi;
|
---|
17540 |
|
---|
17541 |
|
---|
17542 | //
|
---|
17543 | // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
|
---|
17544 | //
|
---|
17545 |
|
---|
17546 | struct {
|
---|
17547 | DEVICE_RELATION_TYPE Type;
|
---|
17548 | } QueryDeviceRelations;
|
---|
17549 |
|
---|
17550 | //
|
---|
17551 | // Parameters for IRP_MN_QUERY_INTERFACE
|
---|
17552 | //
|
---|
17553 |
|
---|
17554 | struct {
|
---|
17555 | CONST GUID *InterfaceType;
|
---|
17556 | USHORT Size;
|
---|
17557 | USHORT Version;
|
---|
17558 | PINTERFACE Interface;
|
---|
17559 | PVOID InterfaceSpecificData;
|
---|
17560 | } QueryInterface;
|
---|
17561 |
|
---|
17562 |
|
---|
17563 |
|
---|
17564 | //
|
---|
17565 | // Parameters for IRP_MN_QUERY_CAPABILITIES
|
---|
17566 | //
|
---|
17567 |
|
---|
17568 | struct {
|
---|
17569 | PDEVICE_CAPABILITIES Capabilities;
|
---|
17570 | } DeviceCapabilities;
|
---|
17571 |
|
---|
17572 | //
|
---|
17573 | // Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
|
---|
17574 | //
|
---|
17575 |
|
---|
17576 | struct {
|
---|
17577 | PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
|
---|
17578 | } FilterResourceRequirements;
|
---|
17579 |
|
---|
17580 | //
|
---|
17581 | // Parameters for IRP_MN_READ_CONFIG and IRP_MN_WRITE_CONFIG
|
---|
17582 | //
|
---|
17583 |
|
---|
17584 | struct {
|
---|
17585 | ULONG WhichSpace;
|
---|
17586 | PVOID Buffer;
|
---|
17587 | ULONG Offset;
|
---|
17588 | ULONG POINTER_ALIGNMENT Length;
|
---|
17589 | } ReadWriteConfig;
|
---|
17590 |
|
---|
17591 | //
|
---|
17592 | // Parameters for IRP_MN_SET_LOCK
|
---|
17593 | //
|
---|
17594 |
|
---|
17595 | struct {
|
---|
17596 | BOOLEAN Lock;
|
---|
17597 | } SetLock;
|
---|
17598 |
|
---|
17599 | //
|
---|
17600 | // Parameters for IRP_MN_QUERY_ID
|
---|
17601 | //
|
---|
17602 |
|
---|
17603 | struct {
|
---|
17604 | BUS_QUERY_ID_TYPE IdType;
|
---|
17605 | } QueryId;
|
---|
17606 |
|
---|
17607 | //
|
---|
17608 | // Parameters for IRP_MN_QUERY_DEVICE_TEXT
|
---|
17609 | //
|
---|
17610 |
|
---|
17611 | struct {
|
---|
17612 | DEVICE_TEXT_TYPE DeviceTextType;
|
---|
17613 | LCID POINTER_ALIGNMENT LocaleId;
|
---|
17614 | } QueryDeviceText;
|
---|
17615 |
|
---|
17616 | //
|
---|
17617 | // Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
|
---|
17618 | //
|
---|
17619 |
|
---|
17620 | struct {
|
---|
17621 | BOOLEAN InPath;
|
---|
17622 | BOOLEAN Reserved[3];
|
---|
17623 | DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
|
---|
17624 | } UsageNotification;
|
---|
17625 |
|
---|
17626 | //
|
---|
17627 | // Parameters for IRP_MN_WAIT_WAKE
|
---|
17628 | //
|
---|
17629 |
|
---|
17630 | struct {
|
---|
17631 | SYSTEM_POWER_STATE PowerState;
|
---|
17632 | } WaitWake;
|
---|
17633 |
|
---|
17634 | //
|
---|
17635 | // Parameter for IRP_MN_POWER_SEQUENCE
|
---|
17636 | //
|
---|
17637 |
|
---|
17638 | struct {
|
---|
17639 | PPOWER_SEQUENCE PowerSequence;
|
---|
17640 | } PowerSequence;
|
---|
17641 |
|
---|
17642 | //
|
---|
17643 | // Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
|
---|
17644 | //
|
---|
17645 |
|
---|
17646 | struct {
|
---|
17647 | ULONG SystemContext;
|
---|
17648 | POWER_STATE_TYPE POINTER_ALIGNMENT Type;
|
---|
17649 | POWER_STATE POINTER_ALIGNMENT State;
|
---|
17650 | POWER_ACTION POINTER_ALIGNMENT ShutdownType;
|
---|
17651 | } Power;
|
---|
17652 |
|
---|
17653 | //
|
---|
17654 | // Parameters for StartDevice
|
---|
17655 | //
|
---|
17656 |
|
---|
17657 | struct {
|
---|
17658 | PCM_RESOURCE_LIST AllocatedResources;
|
---|
17659 | PCM_RESOURCE_LIST AllocatedResourcesTranslated;
|
---|
17660 | } StartDevice;
|
---|
17661 |
|
---|
17662 |
|
---|
17663 | //
|
---|
17664 | // Parameters for Cleanup
|
---|
17665 | //
|
---|
17666 | // No extra parameters supplied
|
---|
17667 | //
|
---|
17668 |
|
---|
17669 | //
|
---|
17670 | // WMI Irps
|
---|
17671 | //
|
---|
17672 |
|
---|
17673 | struct {
|
---|
17674 | ULONG_PTR ProviderId;
|
---|
17675 | PVOID DataPath;
|
---|
17676 | ULONG BufferSize;
|
---|
17677 | PVOID Buffer;
|
---|
17678 | } WMI;
|
---|
17679 |
|
---|
17680 | //
|
---|
17681 | // Others - driver-specific
|
---|
17682 | //
|
---|
17683 |
|
---|
17684 | struct {
|
---|
17685 | PVOID Argument1;
|
---|
17686 | PVOID Argument2;
|
---|
17687 | PVOID Argument3;
|
---|
17688 | PVOID Argument4;
|
---|
17689 | } Others;
|
---|
17690 |
|
---|
17691 | } Parameters;
|
---|
17692 |
|
---|
17693 | //
|
---|
17694 | // Save a pointer to this device driver's device object for this request
|
---|
17695 | // so it can be passed to the completion routine if needed.
|
---|
17696 | //
|
---|
17697 |
|
---|
17698 | PDEVICE_OBJECT DeviceObject;
|
---|
17699 |
|
---|
17700 | //
|
---|
17701 | // The following location contains a pointer to the file object for this
|
---|
17702 | //
|
---|
17703 |
|
---|
17704 | PFILE_OBJECT FileObject;
|
---|
17705 |
|
---|
17706 | //
|
---|
17707 | // The following routine is invoked depending on the flags in the above
|
---|
17708 | // flags field.
|
---|
17709 | //
|
---|
17710 |
|
---|
17711 | PIO_COMPLETION_ROUTINE CompletionRoutine;
|
---|
17712 |
|
---|
17713 | //
|
---|
17714 | // The following is used to store the address of the context parameter
|
---|
17715 | // that should be passed to the CompletionRoutine.
|
---|
17716 | //
|
---|
17717 |
|
---|
17718 | PVOID Context;
|
---|
17719 |
|
---|
17720 | } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
|
---|
17721 | #if !defined(_AMD64_) && !defined(_IA64_)
|
---|
17722 | #include "poppack.h"
|
---|
17723 | #endif
|
---|
17724 |
|
---|
17725 | //
|
---|
17726 | // Define the share access structure used by file systems to determine
|
---|
17727 | // whether or not another accessor may open the file.
|
---|
17728 | //
|
---|
17729 |
|
---|
17730 | typedef struct _SHARE_ACCESS {
|
---|
17731 | ULONG OpenCount;
|
---|
17732 | ULONG Readers;
|
---|
17733 | ULONG Writers;
|
---|
17734 | ULONG Deleters;
|
---|
17735 | ULONG SharedRead;
|
---|
17736 | ULONG SharedWrite;
|
---|
17737 | ULONG SharedDelete;
|
---|
17738 | } SHARE_ACCESS, *PSHARE_ACCESS;
|
---|
17739 |
|
---|
17740 |
|
---|
17741 |
|
---|
17742 | //
|
---|
17743 | // The following structure is used by drivers that are initializing to
|
---|
17744 | // determine the number of devices of a particular type that have already
|
---|
17745 | // been initialized. It is also used to track whether or not the AtDisk
|
---|
17746 | // address range has already been claimed. Finally, it is used by the
|
---|
17747 | // NtQuerySystemInformation system service to return device type counts.
|
---|
17748 | //
|
---|
17749 |
|
---|
17750 | typedef struct _CONFIGURATION_INFORMATION {
|
---|
17751 |
|
---|
17752 | //
|
---|
17753 | // This field indicates the total number of disks in the system. This
|
---|
17754 | // number should be used by the driver to determine the name of new
|
---|
17755 | // disks. This field should be updated by the driver as it finds new
|
---|
17756 | // disks.
|
---|
17757 | //
|
---|
17758 |
|
---|
17759 | ULONG DiskCount; // Count of hard disks thus far
|
---|
17760 | ULONG FloppyCount; // Count of floppy disks thus far
|
---|
17761 | ULONG CdRomCount; // Count of CD-ROM drives thus far
|
---|
17762 | ULONG TapeCount; // Count of tape drives thus far
|
---|
17763 | ULONG ScsiPortCount; // Count of SCSI port adapters thus far
|
---|
17764 | ULONG SerialCount; // Count of serial devices thus far
|
---|
17765 | ULONG ParallelCount; // Count of parallel devices thus far
|
---|
17766 |
|
---|
17767 | //
|
---|
17768 | // These next two fields indicate ownership of one of the two IO address
|
---|
17769 | // spaces that are used by WD1003-compatible disk controllers.
|
---|
17770 | //
|
---|
17771 |
|
---|
17772 | BOOLEAN AtDiskPrimaryAddressClaimed; // 0x1F0 - 0x1FF
|
---|
17773 | BOOLEAN AtDiskSecondaryAddressClaimed; // 0x170 - 0x17F
|
---|
17774 |
|
---|
17775 | //
|
---|
17776 | // Indicates the structure version, as anything value belong this will have been added.
|
---|
17777 | // Use the structure size as the version.
|
---|
17778 | //
|
---|
17779 |
|
---|
17780 | ULONG Version;
|
---|
17781 |
|
---|
17782 | //
|
---|
17783 | // Indicates the total number of medium changer devices in the system.
|
---|
17784 | // This field will be updated by the drivers as it determines that
|
---|
17785 | // new devices have been found and will be supported.
|
---|
17786 | //
|
---|
17787 |
|
---|
17788 | ULONG MediumChangerCount;
|
---|
17789 |
|
---|
17790 | } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
|
---|
17791 |
|
---|
17792 | //
|
---|
17793 | // Public I/O routine definitions
|
---|
17794 | //
|
---|
17795 |
|
---|
17796 | NTKERNELAPI
|
---|
17797 | VOID
|
---|
17798 | IoAcquireCancelSpinLock(
|
---|
17799 | OUT PKIRQL Irql
|
---|
17800 | );
|
---|
17801 |
|
---|
17802 |
|
---|
17803 | DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
|
---|
17804 | NTKERNELAPI
|
---|
17805 | NTSTATUS
|
---|
17806 | IoAllocateAdapterChannel(
|
---|
17807 | IN PADAPTER_OBJECT AdapterObject,
|
---|
17808 | IN PDEVICE_OBJECT DeviceObject,
|
---|
17809 | IN ULONG NumberOfMapRegisters,
|
---|
17810 | IN PDRIVER_CONTROL ExecutionRoutine,
|
---|
17811 | IN PVOID Context
|
---|
17812 | );
|
---|
17813 |
|
---|
17814 | NTKERNELAPI
|
---|
17815 | VOID
|
---|
17816 | IoAllocateController(
|
---|
17817 | IN PCONTROLLER_OBJECT ControllerObject,
|
---|
17818 | IN PDEVICE_OBJECT DeviceObject,
|
---|
17819 | IN PDRIVER_CONTROL ExecutionRoutine,
|
---|
17820 | IN PVOID Context
|
---|
17821 | );
|
---|
17822 |
|
---|
17823 |
|
---|
17824 |
|
---|
17825 | NTKERNELAPI
|
---|
17826 | NTSTATUS
|
---|
17827 | IoAllocateDriverObjectExtension(
|
---|
17828 | IN PDRIVER_OBJECT DriverObject,
|
---|
17829 | IN PVOID ClientIdentificationAddress,
|
---|
17830 | IN ULONG DriverObjectExtensionSize,
|
---|
17831 | OUT PVOID *DriverObjectExtension
|
---|
17832 | );
|
---|
17833 |
|
---|
17834 |
|
---|
17835 |
|
---|
17836 | NTKERNELAPI
|
---|
17837 | PVOID
|
---|
17838 | IoAllocateErrorLogEntry(
|
---|
17839 | IN PVOID IoObject,
|
---|
17840 | IN UCHAR EntrySize
|
---|
17841 | );
|
---|
17842 |
|
---|
17843 | NTKERNELAPI
|
---|
17844 | PIRP
|
---|
17845 | IoAllocateIrp(
|
---|
17846 | IN CCHAR StackSize,
|
---|
17847 | IN BOOLEAN ChargeQuota
|
---|
17848 | );
|
---|
17849 |
|
---|
17850 | NTKERNELAPI
|
---|
17851 | PMDL
|
---|
17852 | IoAllocateMdl(
|
---|
17853 | IN PVOID VirtualAddress,
|
---|
17854 | IN ULONG Length,
|
---|
17855 | IN BOOLEAN SecondaryBuffer,
|
---|
17856 | IN BOOLEAN ChargeQuota,
|
---|
17857 | IN OUT PIRP Irp OPTIONAL
|
---|
17858 | );
|
---|
17859 |
|
---|
17860 |
|
---|
17861 | //++
|
---|
17862 | //
|
---|
17863 | // VOID
|
---|
17864 | // IoAssignArcName(
|
---|
17865 | // IN PUNICODE_STRING ArcName,
|
---|
17866 | // IN PUNICODE_STRING DeviceName
|
---|
17867 | // )
|
---|
17868 | //
|
---|
17869 | // Routine Description:
|
---|
17870 | //
|
---|
17871 | // This routine is invoked by drivers of bootable media to create a symbolic
|
---|
17872 | // link between the ARC name of their device and its NT name. This allows
|
---|
17873 | // the system to determine which device in the system was actually booted
|
---|
17874 | // from since the ARC firmware only deals in ARC names, and NT only deals
|
---|
17875 | // in NT names.
|
---|
17876 | //
|
---|
17877 | // Arguments:
|
---|
17878 | //
|
---|
17879 | // ArcName - Supplies the Unicode string representing the ARC name.
|
---|
17880 | //
|
---|
17881 | // DeviceName - Supplies the name to which the ARCname refers.
|
---|
17882 | //
|
---|
17883 | // Return Value:
|
---|
17884 | //
|
---|
17885 | // None.
|
---|
17886 | //
|
---|
17887 | //--
|
---|
17888 |
|
---|
17889 | #define IoAssignArcName( ArcName, DeviceName ) ( \
|
---|
17890 | IoCreateSymbolicLink( (ArcName), (DeviceName) ) )
|
---|
17891 |
|
---|
17892 | DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReprtDetectedDevice
|
---|
17893 | NTKERNELAPI
|
---|
17894 | NTSTATUS
|
---|
17895 | IoAssignResources (
|
---|
17896 | IN PUNICODE_STRING RegistryPath,
|
---|
17897 | IN PUNICODE_STRING DriverClassName OPTIONAL,
|
---|
17898 | IN PDRIVER_OBJECT DriverObject,
|
---|
17899 | IN PDEVICE_OBJECT DeviceObject OPTIONAL,
|
---|
17900 | IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
|
---|
17901 | IN OUT PCM_RESOURCE_LIST *AllocatedResources
|
---|
17902 | );
|
---|
17903 |
|
---|
17904 | typedef enum _IO_PAGING_PRIORITY {
|
---|
17905 | IoPagingPriorityInvalid, // Returned if a non-paging IO IRP is passed.
|
---|
17906 | IoPagingPriorityNormal, // For regular paging IO
|
---|
17907 | IoPagingPriorityHigh, // For high priority paging IO
|
---|
17908 | IoPagingPriorityReserved1, // Reserved for future use.
|
---|
17909 | IoPagingPriorityReserved2 // Reserved for future use.
|
---|
17910 | } IO_PAGING_PRIORITY;
|
---|
17911 |
|
---|
17912 | NTKERNELAPI
|
---|
17913 | NTSTATUS
|
---|
17914 | IoAttachDevice(
|
---|
17915 | IN PDEVICE_OBJECT SourceDevice,
|
---|
17916 | IN PUNICODE_STRING TargetDevice,
|
---|
17917 | OUT PDEVICE_OBJECT *AttachedDevice
|
---|
17918 | );
|
---|
17919 |
|
---|
17920 |
|
---|
17921 |
|
---|
17922 | DECLSPEC_DEPRECATED_DDK // Use IoAttachDeviceToDeviceStack
|
---|
17923 | NTKERNELAPI
|
---|
17924 | NTSTATUS
|
---|
17925 | IoAttachDeviceByPointer(
|
---|
17926 | IN PDEVICE_OBJECT SourceDevice,
|
---|
17927 | IN PDEVICE_OBJECT TargetDevice
|
---|
17928 | );
|
---|
17929 |
|
---|
17930 |
|
---|
17931 |
|
---|
17932 | NTKERNELAPI
|
---|
17933 | PDEVICE_OBJECT
|
---|
17934 | IoAttachDeviceToDeviceStack(
|
---|
17935 | IN PDEVICE_OBJECT SourceDevice,
|
---|
17936 | IN PDEVICE_OBJECT TargetDevice
|
---|
17937 | );
|
---|
17938 |
|
---|
17939 | NTKERNELAPI
|
---|
17940 | PIRP
|
---|
17941 | IoBuildAsynchronousFsdRequest(
|
---|
17942 | IN ULONG MajorFunction,
|
---|
17943 | IN PDEVICE_OBJECT DeviceObject,
|
---|
17944 | IN OUT PVOID Buffer OPTIONAL,
|
---|
17945 | IN ULONG Length OPTIONAL,
|
---|
17946 | IN PLARGE_INTEGER StartingOffset OPTIONAL,
|
---|
17947 | IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL
|
---|
17948 | );
|
---|
17949 |
|
---|
17950 | NTKERNELAPI
|
---|
17951 | PIRP
|
---|
17952 | IoBuildDeviceIoControlRequest(
|
---|
17953 | IN ULONG IoControlCode,
|
---|
17954 | IN PDEVICE_OBJECT DeviceObject,
|
---|
17955 | IN PVOID InputBuffer OPTIONAL,
|
---|
17956 | IN ULONG InputBufferLength,
|
---|
17957 | OUT PVOID OutputBuffer OPTIONAL,
|
---|
17958 | IN ULONG OutputBufferLength,
|
---|
17959 | IN BOOLEAN InternalDeviceIoControl,
|
---|
17960 | IN PKEVENT Event,
|
---|
17961 | OUT PIO_STATUS_BLOCK IoStatusBlock
|
---|
17962 | );
|
---|
17963 |
|
---|
17964 | NTKERNELAPI
|
---|
17965 | VOID
|
---|
17966 | IoBuildPartialMdl(
|
---|
17967 | IN PMDL SourceMdl,
|
---|
17968 | IN OUT PMDL TargetMdl,
|
---|
17969 | IN PVOID VirtualAddress,
|
---|
17970 | IN ULONG Length
|
---|
17971 | );
|
---|
17972 |
|
---|
17973 | typedef struct _BOOTDISK_INFORMATION {
|
---|
17974 | LONGLONG BootPartitionOffset;
|
---|
17975 | LONGLONG SystemPartitionOffset;
|
---|
17976 | ULONG BootDeviceSignature;
|
---|
17977 | ULONG SystemDeviceSignature;
|
---|
17978 | } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
|
---|
17979 |
|
---|
17980 | //
|
---|
17981 | // This structure should follow the previous structure field for field.
|
---|
17982 | //
|
---|
17983 | typedef struct _BOOTDISK_INFORMATION_EX {
|
---|
17984 | LONGLONG BootPartitionOffset;
|
---|
17985 | LONGLONG SystemPartitionOffset;
|
---|
17986 | ULONG BootDeviceSignature;
|
---|
17987 | ULONG SystemDeviceSignature;
|
---|
17988 | GUID BootDeviceGuid;
|
---|
17989 | GUID SystemDeviceGuid;
|
---|
17990 | BOOLEAN BootDeviceIsGpt;
|
---|
17991 | BOOLEAN SystemDeviceIsGpt;
|
---|
17992 | } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
|
---|
17993 |
|
---|
17994 | NTKERNELAPI
|
---|
17995 | NTSTATUS
|
---|
17996 | IoGetBootDiskInformation(
|
---|
17997 | IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
|
---|
17998 | IN ULONG Size
|
---|
17999 | );
|
---|
18000 |
|
---|
18001 |
|
---|
18002 | NTKERNELAPI
|
---|
18003 | PIRP
|
---|
18004 | IoBuildSynchronousFsdRequest(
|
---|
18005 | IN ULONG MajorFunction,
|
---|
18006 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18007 | IN OUT PVOID Buffer OPTIONAL,
|
---|
18008 | IN ULONG Length OPTIONAL,
|
---|
18009 | IN PLARGE_INTEGER StartingOffset OPTIONAL,
|
---|
18010 | IN PKEVENT Event,
|
---|
18011 | OUT PIO_STATUS_BLOCK IoStatusBlock
|
---|
18012 | );
|
---|
18013 |
|
---|
18014 | NTKERNELAPI
|
---|
18015 | NTSTATUS
|
---|
18016 | FASTCALL
|
---|
18017 | IofCallDriver(
|
---|
18018 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18019 | IN OUT PIRP Irp
|
---|
18020 | );
|
---|
18021 |
|
---|
18022 | #define IoCallDriver(a,b) \
|
---|
18023 | IofCallDriver(a,b)
|
---|
18024 |
|
---|
18025 |
|
---|
18026 | NTKERNELAPI
|
---|
18027 | BOOLEAN
|
---|
18028 | IoCancelIrp(
|
---|
18029 | IN PIRP Irp
|
---|
18030 | );
|
---|
18031 |
|
---|
18032 |
|
---|
18033 | NTKERNELAPI
|
---|
18034 | NTSTATUS
|
---|
18035 | IoCheckShareAccess(
|
---|
18036 | IN ACCESS_MASK DesiredAccess,
|
---|
18037 | IN ULONG DesiredShareAccess,
|
---|
18038 | IN OUT PFILE_OBJECT FileObject,
|
---|
18039 | IN OUT PSHARE_ACCESS ShareAccess,
|
---|
18040 | IN BOOLEAN Update
|
---|
18041 | );
|
---|
18042 |
|
---|
18043 | //
|
---|
18044 | // This value should be returned from completion routines to continue
|
---|
18045 | // completing the IRP upwards. Otherwise, STATUS_MORE_PROCESSING_REQUIRED
|
---|
18046 | // should be returned.
|
---|
18047 | //
|
---|
18048 | #define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS
|
---|
18049 |
|
---|
18050 | //
|
---|
18051 | // Completion routines can also use this enumeration in place of status codes.
|
---|
18052 | //
|
---|
18053 | typedef enum _IO_COMPLETION_ROUTINE_RESULT {
|
---|
18054 |
|
---|
18055 | ContinueCompletion = STATUS_CONTINUE_COMPLETION,
|
---|
18056 | StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
|
---|
18057 |
|
---|
18058 | } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
|
---|
18059 |
|
---|
18060 | NTKERNELAPI
|
---|
18061 | VOID
|
---|
18062 | FASTCALL
|
---|
18063 | IofCompleteRequest(
|
---|
18064 | IN PIRP Irp,
|
---|
18065 | IN CCHAR PriorityBoost
|
---|
18066 | );
|
---|
18067 |
|
---|
18068 | #define IoCompleteRequest(a,b) \
|
---|
18069 | IofCompleteRequest(a,b)
|
---|
18070 |
|
---|
18071 |
|
---|
18072 |
|
---|
18073 | NTKERNELAPI
|
---|
18074 | NTSTATUS
|
---|
18075 | IoConnectInterrupt(
|
---|
18076 | OUT PKINTERRUPT *InterruptObject,
|
---|
18077 | IN PKSERVICE_ROUTINE ServiceRoutine,
|
---|
18078 | IN PVOID ServiceContext,
|
---|
18079 | IN PKSPIN_LOCK SpinLock OPTIONAL,
|
---|
18080 | IN ULONG Vector,
|
---|
18081 | IN KIRQL Irql,
|
---|
18082 | IN KIRQL SynchronizeIrql,
|
---|
18083 | IN KINTERRUPT_MODE InterruptMode,
|
---|
18084 | IN BOOLEAN ShareVector,
|
---|
18085 | IN KAFFINITY ProcessorEnableMask,
|
---|
18086 | IN BOOLEAN FloatingSave
|
---|
18087 | );
|
---|
18088 |
|
---|
18089 |
|
---|
18090 |
|
---|
18091 | NTKERNELAPI
|
---|
18092 | PCONTROLLER_OBJECT
|
---|
18093 | IoCreateController(
|
---|
18094 | IN ULONG Size
|
---|
18095 | );
|
---|
18096 |
|
---|
18097 |
|
---|
18098 |
|
---|
18099 | NTKERNELAPI
|
---|
18100 | NTSTATUS
|
---|
18101 | IoCreateDevice(
|
---|
18102 | IN PDRIVER_OBJECT DriverObject,
|
---|
18103 | IN ULONG DeviceExtensionSize,
|
---|
18104 | IN PUNICODE_STRING DeviceName OPTIONAL,
|
---|
18105 | IN DEVICE_TYPE DeviceType,
|
---|
18106 | IN ULONG DeviceCharacteristics,
|
---|
18107 | IN BOOLEAN Exclusive,
|
---|
18108 | OUT PDEVICE_OBJECT *DeviceObject
|
---|
18109 | );
|
---|
18110 |
|
---|
18111 |
|
---|
18112 | #define WDM_MAJORVERSION 0x01
|
---|
18113 | #define WDM_MINORVERSION 0x30
|
---|
18114 |
|
---|
18115 | NTKERNELAPI
|
---|
18116 | BOOLEAN
|
---|
18117 | IoIsWdmVersionAvailable(
|
---|
18118 | IN UCHAR MajorVersion,
|
---|
18119 | IN UCHAR MinorVersion
|
---|
18120 | );
|
---|
18121 |
|
---|
18122 |
|
---|
18123 |
|
---|
18124 | NTKERNELAPI
|
---|
18125 | NTSTATUS
|
---|
18126 | IoCreateFile(
|
---|
18127 | OUT PHANDLE FileHandle,
|
---|
18128 | IN ACCESS_MASK DesiredAccess,
|
---|
18129 | IN POBJECT_ATTRIBUTES ObjectAttributes,
|
---|
18130 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
18131 | IN PLARGE_INTEGER AllocationSize OPTIONAL,
|
---|
18132 | IN ULONG FileAttributes,
|
---|
18133 | IN ULONG ShareAccess,
|
---|
18134 | IN ULONG Disposition,
|
---|
18135 | IN ULONG CreateOptions,
|
---|
18136 | IN PVOID EaBuffer OPTIONAL,
|
---|
18137 | IN ULONG EaLength,
|
---|
18138 | IN CREATE_FILE_TYPE CreateFileType,
|
---|
18139 | IN PVOID ExtraCreateParameters OPTIONAL,
|
---|
18140 | IN ULONG Options
|
---|
18141 | );
|
---|
18142 |
|
---|
18143 |
|
---|
18144 | NTKERNELAPI
|
---|
18145 | PKEVENT
|
---|
18146 | IoCreateNotificationEvent(
|
---|
18147 | IN PUNICODE_STRING EventName,
|
---|
18148 | OUT PHANDLE EventHandle
|
---|
18149 | );
|
---|
18150 |
|
---|
18151 | NTKERNELAPI
|
---|
18152 | NTSTATUS
|
---|
18153 | IoCreateSymbolicLink(
|
---|
18154 | IN PUNICODE_STRING SymbolicLinkName,
|
---|
18155 | IN PUNICODE_STRING DeviceName
|
---|
18156 | );
|
---|
18157 |
|
---|
18158 | NTKERNELAPI
|
---|
18159 | PKEVENT
|
---|
18160 | IoCreateSynchronizationEvent(
|
---|
18161 | IN PUNICODE_STRING EventName,
|
---|
18162 | OUT PHANDLE EventHandle
|
---|
18163 | );
|
---|
18164 |
|
---|
18165 | NTKERNELAPI
|
---|
18166 | NTSTATUS
|
---|
18167 | IoCreateUnprotectedSymbolicLink(
|
---|
18168 | IN PUNICODE_STRING SymbolicLinkName,
|
---|
18169 | IN PUNICODE_STRING DeviceName
|
---|
18170 | );
|
---|
18171 |
|
---|
18172 |
|
---|
18173 |
|
---|
18174 | //++
|
---|
18175 | //
|
---|
18176 | // VOID
|
---|
18177 | // IoDeassignArcName(
|
---|
18178 | // IN PUNICODE_STRING ArcName
|
---|
18179 | // )
|
---|
18180 | //
|
---|
18181 | // Routine Description:
|
---|
18182 | //
|
---|
18183 | // This routine is invoked by drivers to deassign an ARC name that they
|
---|
18184 | // created to a device. This is generally only called if the driver is
|
---|
18185 | // deleting the device object, which means that the driver is probably
|
---|
18186 | // unloading.
|
---|
18187 | //
|
---|
18188 | // Arguments:
|
---|
18189 | //
|
---|
18190 | // ArcName - Supplies the ARC name to be removed.
|
---|
18191 | //
|
---|
18192 | // Return Value:
|
---|
18193 | //
|
---|
18194 | // None.
|
---|
18195 | //
|
---|
18196 | //--
|
---|
18197 |
|
---|
18198 | #define IoDeassignArcName( ArcName ) ( \
|
---|
18199 | IoDeleteSymbolicLink( (ArcName) ) )
|
---|
18200 |
|
---|
18201 |
|
---|
18202 |
|
---|
18203 | NTKERNELAPI
|
---|
18204 | VOID
|
---|
18205 | IoDeleteController(
|
---|
18206 | IN PCONTROLLER_OBJECT ControllerObject
|
---|
18207 | );
|
---|
18208 |
|
---|
18209 |
|
---|
18210 |
|
---|
18211 | NTKERNELAPI
|
---|
18212 | VOID
|
---|
18213 | IoDeleteDevice(
|
---|
18214 | IN PDEVICE_OBJECT DeviceObject
|
---|
18215 | );
|
---|
18216 |
|
---|
18217 | NTKERNELAPI
|
---|
18218 | NTSTATUS
|
---|
18219 | IoDeleteSymbolicLink(
|
---|
18220 | IN PUNICODE_STRING SymbolicLinkName
|
---|
18221 | );
|
---|
18222 |
|
---|
18223 | NTKERNELAPI
|
---|
18224 | VOID
|
---|
18225 | IoDetachDevice(
|
---|
18226 | IN OUT PDEVICE_OBJECT TargetDevice
|
---|
18227 | );
|
---|
18228 |
|
---|
18229 |
|
---|
18230 |
|
---|
18231 | NTKERNELAPI
|
---|
18232 | VOID
|
---|
18233 | IoDisconnectInterrupt(
|
---|
18234 | IN PKINTERRUPT InterruptObject
|
---|
18235 | );
|
---|
18236 |
|
---|
18237 |
|
---|
18238 | NTKERNELAPI
|
---|
18239 | VOID
|
---|
18240 | IoFreeController(
|
---|
18241 | IN PCONTROLLER_OBJECT ControllerObject
|
---|
18242 | );
|
---|
18243 |
|
---|
18244 |
|
---|
18245 |
|
---|
18246 | NTKERNELAPI
|
---|
18247 | VOID
|
---|
18248 | IoFreeIrp(
|
---|
18249 | IN PIRP Irp
|
---|
18250 | );
|
---|
18251 |
|
---|
18252 | NTKERNELAPI
|
---|
18253 | VOID
|
---|
18254 | IoFreeMdl(
|
---|
18255 | IN PMDL Mdl
|
---|
18256 | );
|
---|
18257 |
|
---|
18258 | NTKERNELAPI
|
---|
18259 | PDEVICE_OBJECT
|
---|
18260 | IoGetAttachedDeviceReference(
|
---|
18261 | IN PDEVICE_OBJECT DeviceObject
|
---|
18262 | );
|
---|
18263 |
|
---|
18264 | NTKERNELAPI
|
---|
18265 | PCONFIGURATION_INFORMATION
|
---|
18266 | IoGetConfigurationInformation( VOID );
|
---|
18267 |
|
---|
18268 | //++
|
---|
18269 | //
|
---|
18270 | // PIO_STACK_LOCATION
|
---|
18271 | // IoGetCurrentIrpStackLocation(
|
---|
18272 | // IN PIRP Irp
|
---|
18273 | // )
|
---|
18274 | //
|
---|
18275 | // Routine Description:
|
---|
18276 | //
|
---|
18277 | // This routine is invoked to return a pointer to the current stack location
|
---|
18278 | // in an I/O Request Packet (IRP).
|
---|
18279 | //
|
---|
18280 | // Arguments:
|
---|
18281 | //
|
---|
18282 | // Irp - Pointer to the I/O Request Packet.
|
---|
18283 | //
|
---|
18284 | // Return Value:
|
---|
18285 | //
|
---|
18286 | // The function value is a pointer to the current stack location in the
|
---|
18287 | // packet.
|
---|
18288 | //
|
---|
18289 | //--
|
---|
18290 |
|
---|
18291 | #define IoGetCurrentIrpStackLocation( Irp ) ( (Irp)->Tail.Overlay.CurrentStackLocation )
|
---|
18292 |
|
---|
18293 |
|
---|
18294 |
|
---|
18295 | NTKERNELAPI
|
---|
18296 | PDEVICE_OBJECT
|
---|
18297 | IoGetDeviceToVerify(
|
---|
18298 | IN PETHREAD Thread
|
---|
18299 | );
|
---|
18300 |
|
---|
18301 |
|
---|
18302 |
|
---|
18303 | NTKERNELAPI
|
---|
18304 | PVOID
|
---|
18305 | IoGetDriverObjectExtension(
|
---|
18306 | IN PDRIVER_OBJECT DriverObject,
|
---|
18307 | IN PVOID ClientIdentificationAddress
|
---|
18308 | );
|
---|
18309 |
|
---|
18310 | NTKERNELAPI
|
---|
18311 | PEPROCESS
|
---|
18312 | IoGetCurrentProcess(
|
---|
18313 | VOID
|
---|
18314 | );
|
---|
18315 |
|
---|
18316 |
|
---|
18317 |
|
---|
18318 | NTKERNELAPI
|
---|
18319 | NTSTATUS
|
---|
18320 | IoGetDeviceObjectPointer(
|
---|
18321 | IN PUNICODE_STRING ObjectName,
|
---|
18322 | IN ACCESS_MASK DesiredAccess,
|
---|
18323 | OUT PFILE_OBJECT *FileObject,
|
---|
18324 | OUT PDEVICE_OBJECT *DeviceObject
|
---|
18325 | );
|
---|
18326 |
|
---|
18327 | NTKERNELAPI
|
---|
18328 | struct _DMA_ADAPTER *
|
---|
18329 | IoGetDmaAdapter(
|
---|
18330 | IN PDEVICE_OBJECT PhysicalDeviceObject, OPTIONAL // required for PnP drivers
|
---|
18331 | IN struct _DEVICE_DESCRIPTION *DeviceDescription,
|
---|
18332 | IN OUT PULONG NumberOfMapRegisters
|
---|
18333 | );
|
---|
18334 |
|
---|
18335 | NTKERNELAPI
|
---|
18336 | BOOLEAN
|
---|
18337 | IoForwardIrpSynchronously(
|
---|
18338 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18339 | IN PIRP Irp
|
---|
18340 | );
|
---|
18341 |
|
---|
18342 | #define IoForwardAndCatchIrp IoForwardIrpSynchronously
|
---|
18343 |
|
---|
18344 |
|
---|
18345 |
|
---|
18346 | NTKERNELAPI
|
---|
18347 | PGENERIC_MAPPING
|
---|
18348 | IoGetFileObjectGenericMapping(
|
---|
18349 | VOID
|
---|
18350 | );
|
---|
18351 |
|
---|
18352 |
|
---|
18353 |
|
---|
18354 |
|
---|
18355 |
|
---|
18356 |
|
---|
18357 | //++
|
---|
18358 | //
|
---|
18359 | // ULONG
|
---|
18360 | // IoGetFunctionCodeFromCtlCode(
|
---|
18361 | // IN ULONG ControlCode
|
---|
18362 | // )
|
---|
18363 | //
|
---|
18364 | // Routine Description:
|
---|
18365 | //
|
---|
18366 | // This routine extracts the function code from IOCTL and FSCTL function
|
---|
18367 | // control codes.
|
---|
18368 | // This routine should only be used by kernel mode code.
|
---|
18369 | //
|
---|
18370 | // Arguments:
|
---|
18371 | //
|
---|
18372 | // ControlCode - A function control code (IOCTL or FSCTL) from which the
|
---|
18373 | // function code must be extracted.
|
---|
18374 | //
|
---|
18375 | // Return Value:
|
---|
18376 | //
|
---|
18377 | // The extracted function code.
|
---|
18378 | //
|
---|
18379 | // Note:
|
---|
18380 | //
|
---|
18381 | // The CTL_CODE macro, used to create IOCTL and FSCTL function control
|
---|
18382 | // codes, is defined in ntioapi.h
|
---|
18383 | //
|
---|
18384 | //--
|
---|
18385 |
|
---|
18386 | #define IoGetFunctionCodeFromCtlCode( ControlCode ) (\
|
---|
18387 | ( ControlCode >> 2) & 0x00000FFF )
|
---|
18388 |
|
---|
18389 |
|
---|
18390 |
|
---|
18391 | NTKERNELAPI
|
---|
18392 | PVOID
|
---|
18393 | IoGetInitialStack(
|
---|
18394 | VOID
|
---|
18395 | );
|
---|
18396 |
|
---|
18397 | NTKERNELAPI
|
---|
18398 | VOID
|
---|
18399 | IoGetStackLimits (
|
---|
18400 | OUT PULONG_PTR LowLimit,
|
---|
18401 | OUT PULONG_PTR HighLimit
|
---|
18402 | );
|
---|
18403 |
|
---|
18404 | //
|
---|
18405 | // The following function is used to tell the caller how much stack is available
|
---|
18406 | //
|
---|
18407 |
|
---|
18408 | FORCEINLINE
|
---|
18409 | ULONG_PTR
|
---|
18410 | IoGetRemainingStackSize (
|
---|
18411 | VOID
|
---|
18412 | )
|
---|
18413 | {
|
---|
18414 | ULONG_PTR Top;
|
---|
18415 | ULONG_PTR Bottom;
|
---|
18416 |
|
---|
18417 | IoGetStackLimits( &Bottom, &Top );
|
---|
18418 | return((ULONG_PTR)(&Top) - Bottom );
|
---|
18419 | }
|
---|
18420 |
|
---|
18421 | //++
|
---|
18422 | //
|
---|
18423 | // PIO_STACK_LOCATION
|
---|
18424 | // IoGetNextIrpStackLocation(
|
---|
18425 | // IN PIRP Irp
|
---|
18426 | // )
|
---|
18427 | //
|
---|
18428 | // Routine Description:
|
---|
18429 | //
|
---|
18430 | // This routine is invoked to return a pointer to the next stack location
|
---|
18431 | // in an I/O Request Packet (IRP).
|
---|
18432 | //
|
---|
18433 | // Arguments:
|
---|
18434 | //
|
---|
18435 | // Irp - Pointer to the I/O Request Packet.
|
---|
18436 | //
|
---|
18437 | // Return Value:
|
---|
18438 | //
|
---|
18439 | // The function value is a pointer to the next stack location in the packet.
|
---|
18440 | //
|
---|
18441 | //--
|
---|
18442 |
|
---|
18443 | #define IoGetNextIrpStackLocation( Irp ) (\
|
---|
18444 | (Irp)->Tail.Overlay.CurrentStackLocation - 1 )
|
---|
18445 |
|
---|
18446 | NTKERNELAPI
|
---|
18447 | PDEVICE_OBJECT
|
---|
18448 | IoGetRelatedDeviceObject(
|
---|
18449 | IN PFILE_OBJECT FileObject
|
---|
18450 | );
|
---|
18451 |
|
---|
18452 |
|
---|
18453 | //++
|
---|
18454 | //
|
---|
18455 | // VOID
|
---|
18456 | // IoInitializeDpcRequest(
|
---|
18457 | // IN PDEVICE_OBJECT DeviceObject,
|
---|
18458 | // IN PIO_DPC_ROUTINE DpcRoutine
|
---|
18459 | // )
|
---|
18460 | //
|
---|
18461 | // Routine Description:
|
---|
18462 | //
|
---|
18463 | // This routine is invoked to initialize the DPC in a device object for a
|
---|
18464 | // device driver during its initialization routine. The DPC is used later
|
---|
18465 | // when the driver interrupt service routine requests that a DPC routine
|
---|
18466 | // be queued for later execution.
|
---|
18467 | //
|
---|
18468 | // Arguments:
|
---|
18469 | //
|
---|
18470 | // DeviceObject - Pointer to the device object that the request is for.
|
---|
18471 | //
|
---|
18472 | // DpcRoutine - Address of the driver's DPC routine to be executed when
|
---|
18473 | // the DPC is dequeued for processing.
|
---|
18474 | //
|
---|
18475 | // Return Value:
|
---|
18476 | //
|
---|
18477 | // None.
|
---|
18478 | //
|
---|
18479 | //--
|
---|
18480 |
|
---|
18481 | #define IoInitializeDpcRequest( DeviceObject, DpcRoutine ) (\
|
---|
18482 | KeInitializeDpc( &(DeviceObject)->Dpc, \
|
---|
18483 | (PKDEFERRED_ROUTINE) (DpcRoutine), \
|
---|
18484 | (DeviceObject) ) )
|
---|
18485 |
|
---|
18486 |
|
---|
18487 | NTKERNELAPI
|
---|
18488 | VOID
|
---|
18489 | IoInitializeIrp(
|
---|
18490 | IN OUT PIRP Irp,
|
---|
18491 | IN USHORT PacketSize,
|
---|
18492 | IN CCHAR StackSize
|
---|
18493 | );
|
---|
18494 |
|
---|
18495 | NTKERNELAPI
|
---|
18496 | NTSTATUS
|
---|
18497 | IoInitializeTimer(
|
---|
18498 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18499 | IN PIO_TIMER_ROUTINE TimerRoutine,
|
---|
18500 | IN PVOID Context
|
---|
18501 | );
|
---|
18502 |
|
---|
18503 |
|
---|
18504 | NTKERNELAPI
|
---|
18505 | VOID
|
---|
18506 | IoReuseIrp(
|
---|
18507 | IN OUT PIRP Irp,
|
---|
18508 | IN NTSTATUS Iostatus
|
---|
18509 | );
|
---|
18510 |
|
---|
18511 |
|
---|
18512 |
|
---|
18513 | NTKERNELAPI
|
---|
18514 | VOID
|
---|
18515 | IoCancelFileOpen(
|
---|
18516 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18517 | IN PFILE_OBJECT FileObject
|
---|
18518 | );
|
---|
18519 |
|
---|
18520 | //++
|
---|
18521 | //
|
---|
18522 | // BOOLEAN
|
---|
18523 | // IoIsErrorUserInduced(
|
---|
18524 | // IN NTSTATUS Status
|
---|
18525 | // )
|
---|
18526 | //
|
---|
18527 | // Routine Description:
|
---|
18528 | //
|
---|
18529 | // This routine is invoked to determine if an error was as a
|
---|
18530 | // result of user actions. Typically these error are related
|
---|
18531 | // to removable media and will result in a pop-up.
|
---|
18532 | //
|
---|
18533 | // Arguments:
|
---|
18534 | //
|
---|
18535 | // Status - The status value to check.
|
---|
18536 | //
|
---|
18537 | // Return Value:
|
---|
18538 | // The function value is TRUE if the user induced the error,
|
---|
18539 | // otherwise FALSE is returned.
|
---|
18540 | //
|
---|
18541 | //--
|
---|
18542 | #define IoIsErrorUserInduced( Status ) ((BOOLEAN) \
|
---|
18543 | (((Status) == STATUS_DEVICE_NOT_READY) || \
|
---|
18544 | ((Status) == STATUS_IO_TIMEOUT) || \
|
---|
18545 | ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
|
---|
18546 | ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
|
---|
18547 | ((Status) == STATUS_VERIFY_REQUIRED) || \
|
---|
18548 | ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
|
---|
18549 | ((Status) == STATUS_WRONG_VOLUME)))
|
---|
18550 |
|
---|
18551 |
|
---|
18552 | NTKERNELAPI
|
---|
18553 | PIRP
|
---|
18554 | IoMakeAssociatedIrp(
|
---|
18555 | IN PIRP Irp,
|
---|
18556 | IN CCHAR StackSize
|
---|
18557 | );
|
---|
18558 |
|
---|
18559 |
|
---|
18560 |
|
---|
18561 | //++
|
---|
18562 | //
|
---|
18563 | // VOID
|
---|
18564 | // IoMarkIrpPending(
|
---|
18565 | // IN OUT PIRP Irp
|
---|
18566 | // )
|
---|
18567 | //
|
---|
18568 | // Routine Description:
|
---|
18569 | //
|
---|
18570 | // This routine marks the specified I/O Request Packet (IRP) to indicate
|
---|
18571 | // that an initial status of STATUS_PENDING was returned to the caller.
|
---|
18572 | // This is used so that I/O completion can determine whether or not to
|
---|
18573 | // fully complete the I/O operation requested by the packet.
|
---|
18574 | //
|
---|
18575 | // Arguments:
|
---|
18576 | //
|
---|
18577 | // Irp - Pointer to the I/O Request Packet to be marked pending.
|
---|
18578 | //
|
---|
18579 | // Return Value:
|
---|
18580 | //
|
---|
18581 | // None.
|
---|
18582 | //
|
---|
18583 | //--
|
---|
18584 |
|
---|
18585 | #define IoMarkIrpPending( Irp ) ( \
|
---|
18586 | IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED )
|
---|
18587 |
|
---|
18588 | DECLSPEC_DEPRECATED_DDK // Use IoGetDeviceProperty
|
---|
18589 | NTKERNELAPI
|
---|
18590 | NTSTATUS
|
---|
18591 | IoQueryDeviceDescription(
|
---|
18592 | IN PINTERFACE_TYPE BusType OPTIONAL,
|
---|
18593 | IN PULONG BusNumber OPTIONAL,
|
---|
18594 | IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
|
---|
18595 | IN PULONG ControllerNumber OPTIONAL,
|
---|
18596 | IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
|
---|
18597 | IN PULONG PeripheralNumber OPTIONAL,
|
---|
18598 | IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
|
---|
18599 | IN PVOID Context
|
---|
18600 | );
|
---|
18601 |
|
---|
18602 |
|
---|
18603 | NTKERNELAPI
|
---|
18604 | VOID
|
---|
18605 | IoRaiseHardError(
|
---|
18606 | IN PIRP Irp,
|
---|
18607 | IN PVPB Vpb OPTIONAL,
|
---|
18608 | IN PDEVICE_OBJECT RealDeviceObject
|
---|
18609 | );
|
---|
18610 |
|
---|
18611 | NTKERNELAPI
|
---|
18612 | BOOLEAN
|
---|
18613 | IoRaiseInformationalHardError(
|
---|
18614 | IN NTSTATUS ErrorStatus,
|
---|
18615 | IN PUNICODE_STRING String OPTIONAL,
|
---|
18616 | IN PKTHREAD Thread OPTIONAL
|
---|
18617 | );
|
---|
18618 |
|
---|
18619 | NTKERNELAPI
|
---|
18620 | BOOLEAN
|
---|
18621 | IoSetThreadHardErrorMode(
|
---|
18622 | IN BOOLEAN EnableHardErrors
|
---|
18623 | );
|
---|
18624 |
|
---|
18625 | NTKERNELAPI
|
---|
18626 | VOID
|
---|
18627 | IoRegisterBootDriverReinitialization(
|
---|
18628 | IN PDRIVER_OBJECT DriverObject,
|
---|
18629 | IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
|
---|
18630 | IN PVOID Context
|
---|
18631 | );
|
---|
18632 |
|
---|
18633 | NTKERNELAPI
|
---|
18634 | VOID
|
---|
18635 | IoRegisterDriverReinitialization(
|
---|
18636 | IN PDRIVER_OBJECT DriverObject,
|
---|
18637 | IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
|
---|
18638 | IN PVOID Context
|
---|
18639 | );
|
---|
18640 |
|
---|
18641 |
|
---|
18642 | NTKERNELAPI
|
---|
18643 | NTSTATUS
|
---|
18644 | IoRegisterShutdownNotification(
|
---|
18645 | IN PDEVICE_OBJECT DeviceObject
|
---|
18646 | );
|
---|
18647 |
|
---|
18648 | NTKERNELAPI
|
---|
18649 | NTSTATUS
|
---|
18650 | IoRegisterLastChanceShutdownNotification(
|
---|
18651 | IN PDEVICE_OBJECT DeviceObject
|
---|
18652 | );
|
---|
18653 |
|
---|
18654 |
|
---|
18655 |
|
---|
18656 | NTKERNELAPI
|
---|
18657 | VOID
|
---|
18658 | IoReleaseCancelSpinLock(
|
---|
18659 | IN KIRQL Irql
|
---|
18660 | );
|
---|
18661 |
|
---|
18662 |
|
---|
18663 | NTKERNELAPI
|
---|
18664 | VOID
|
---|
18665 | IoRemoveShareAccess(
|
---|
18666 | IN PFILE_OBJECT FileObject,
|
---|
18667 | IN OUT PSHARE_ACCESS ShareAccess
|
---|
18668 | );
|
---|
18669 |
|
---|
18670 |
|
---|
18671 | DECLSPEC_DEPRECATED_DDK // Use IoReportResourceForDetection
|
---|
18672 | NTKERNELAPI
|
---|
18673 | NTSTATUS
|
---|
18674 | IoReportResourceUsage(
|
---|
18675 | IN PUNICODE_STRING DriverClassName OPTIONAL,
|
---|
18676 | IN PDRIVER_OBJECT DriverObject,
|
---|
18677 | IN PCM_RESOURCE_LIST DriverList OPTIONAL,
|
---|
18678 | IN ULONG DriverListSize OPTIONAL,
|
---|
18679 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18680 | IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
|
---|
18681 | IN ULONG DeviceListSize OPTIONAL,
|
---|
18682 | IN BOOLEAN OverrideConflict,
|
---|
18683 | OUT PBOOLEAN ConflictDetected
|
---|
18684 | );
|
---|
18685 |
|
---|
18686 |
|
---|
18687 |
|
---|
18688 | //++
|
---|
18689 | //
|
---|
18690 | // VOID
|
---|
18691 | // IoRequestDpc(
|
---|
18692 | // IN PDEVICE_OBJECT DeviceObject,
|
---|
18693 | // IN PIRP Irp,
|
---|
18694 | // IN PVOID Context
|
---|
18695 | // )
|
---|
18696 | //
|
---|
18697 | // Routine Description:
|
---|
18698 | //
|
---|
18699 | // This routine is invoked by the device driver's interrupt service routine
|
---|
18700 | // to request that a DPC routine be queued for later execution at a lower
|
---|
18701 | // IRQL.
|
---|
18702 | //
|
---|
18703 | // Arguments:
|
---|
18704 | //
|
---|
18705 | // DeviceObject - Device object for which the request is being processed.
|
---|
18706 | //
|
---|
18707 | // Irp - Pointer to the current I/O Request Packet (IRP) for the specified
|
---|
18708 | // device.
|
---|
18709 | //
|
---|
18710 | // Context - Provides a general context parameter to be passed to the
|
---|
18711 | // DPC routine.
|
---|
18712 | //
|
---|
18713 | // Return Value:
|
---|
18714 | //
|
---|
18715 | // None.
|
---|
18716 | //
|
---|
18717 | //--
|
---|
18718 |
|
---|
18719 | #define IoRequestDpc( DeviceObject, Irp, Context ) ( \
|
---|
18720 | KeInsertQueueDpc( &(DeviceObject)->Dpc, (Irp), (Context) ) )
|
---|
18721 |
|
---|
18722 | //++
|
---|
18723 | //
|
---|
18724 | // PDRIVER_CANCEL
|
---|
18725 | // IoSetCancelRoutine(
|
---|
18726 | // IN PIRP Irp,
|
---|
18727 | // IN PDRIVER_CANCEL CancelRoutine
|
---|
18728 | // )
|
---|
18729 | //
|
---|
18730 | // Routine Description:
|
---|
18731 | //
|
---|
18732 | // This routine is invoked to set the address of a cancel routine which
|
---|
18733 | // is to be invoked when an I/O packet has been canceled.
|
---|
18734 | //
|
---|
18735 | // Arguments:
|
---|
18736 | //
|
---|
18737 | // Irp - Pointer to the I/O Request Packet itself.
|
---|
18738 | //
|
---|
18739 | // CancelRoutine - Address of the cancel routine that is to be invoked
|
---|
18740 | // if the IRP is cancelled.
|
---|
18741 | //
|
---|
18742 | // Return Value:
|
---|
18743 | //
|
---|
18744 | // Previous value of CancelRoutine field in the IRP.
|
---|
18745 | //
|
---|
18746 | //--
|
---|
18747 |
|
---|
18748 | #define IoSetCancelRoutine( Irp, NewCancelRoutine ) ( \
|
---|
18749 | (PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( (PVOID *) &(Irp)->CancelRoutine, (PVOID) (ULONG_PTR)(NewCancelRoutine) ) )
|
---|
18750 |
|
---|
18751 | //++
|
---|
18752 | //
|
---|
18753 | // VOID
|
---|
18754 | // IoSetCompletionRoutine(
|
---|
18755 | // IN PIRP Irp,
|
---|
18756 | // IN PIO_COMPLETION_ROUTINE CompletionRoutine,
|
---|
18757 | // IN PVOID Context,
|
---|
18758 | // IN BOOLEAN InvokeOnSuccess,
|
---|
18759 | // IN BOOLEAN InvokeOnError,
|
---|
18760 | // IN BOOLEAN InvokeOnCancel
|
---|
18761 | // )
|
---|
18762 | //
|
---|
18763 | // Routine Description:
|
---|
18764 | //
|
---|
18765 | // This routine is invoked to set the address of a completion routine which
|
---|
18766 | // is to be invoked when an I/O packet has been completed by a lower-level
|
---|
18767 | // driver.
|
---|
18768 | //
|
---|
18769 | // Arguments:
|
---|
18770 | //
|
---|
18771 | // Irp - Pointer to the I/O Request Packet itself.
|
---|
18772 | //
|
---|
18773 | // CompletionRoutine - Address of the completion routine that is to be
|
---|
18774 | // invoked once the next level driver completes the packet.
|
---|
18775 | //
|
---|
18776 | // Context - Specifies a context parameter to be passed to the completion
|
---|
18777 | // routine.
|
---|
18778 | //
|
---|
18779 | // InvokeOnSuccess - Specifies that the completion routine is invoked when the
|
---|
18780 | // operation is successfully completed.
|
---|
18781 | //
|
---|
18782 | // InvokeOnError - Specifies that the completion routine is invoked when the
|
---|
18783 | // operation completes with an error status.
|
---|
18784 | //
|
---|
18785 | // InvokeOnCancel - Specifies that the completion routine is invoked when the
|
---|
18786 | // operation is being canceled.
|
---|
18787 | //
|
---|
18788 | // Return Value:
|
---|
18789 | //
|
---|
18790 | // None.
|
---|
18791 | //
|
---|
18792 | //--
|
---|
18793 |
|
---|
18794 | #define IoSetCompletionRoutine( Irp, Routine, CompletionContext, Success, Error, Cancel ) { \
|
---|
18795 | PIO_STACK_LOCATION __irpSp; \
|
---|
18796 | ASSERT( (Success) | (Error) | (Cancel) ? (Routine) != NULL : TRUE ); \
|
---|
18797 | __irpSp = IoGetNextIrpStackLocation( (Irp) ); \
|
---|
18798 | __irpSp->CompletionRoutine = (Routine); \
|
---|
18799 | __irpSp->Context = (CompletionContext); \
|
---|
18800 | __irpSp->Control = 0; \
|
---|
18801 | if ((Success)) { __irpSp->Control = SL_INVOKE_ON_SUCCESS; } \
|
---|
18802 | if ((Error)) { __irpSp->Control |= SL_INVOKE_ON_ERROR; } \
|
---|
18803 | if ((Cancel)) { __irpSp->Control |= SL_INVOKE_ON_CANCEL; } }
|
---|
18804 |
|
---|
18805 | NTSTATUS
|
---|
18806 | IoSetCompletionRoutineEx(
|
---|
18807 | IN PDEVICE_OBJECT DeviceObject,
|
---|
18808 | IN PIRP Irp,
|
---|
18809 | IN PIO_COMPLETION_ROUTINE CompletionRoutine,
|
---|
18810 | IN PVOID Context,
|
---|
18811 | IN BOOLEAN InvokeOnSuccess,
|
---|
18812 | IN BOOLEAN InvokeOnError,
|
---|
18813 | IN BOOLEAN InvokeOnCancel
|
---|
18814 | );
|
---|
18815 |
|
---|
18816 |
|
---|
18817 |
|
---|
18818 | NTKERNELAPI
|
---|
18819 | VOID
|
---|
18820 | IoSetHardErrorOrVerifyDevice(
|
---|
18821 | IN PIRP Irp,
|
---|
18822 | IN PDEVICE_OBJECT DeviceObject
|
---|
18823 | );
|
---|
18824 |
|
---|
18825 |
|
---|
18826 | //++
|
---|
18827 | //
|
---|
18828 | // VOID
|
---|
18829 | // IoSetNextIrpStackLocation (
|
---|
18830 | // IN OUT PIRP Irp
|
---|
18831 | // )
|
---|
18832 | //
|
---|
18833 | // Routine Description:
|
---|
18834 | //
|
---|
18835 | // This routine is invoked to set the current IRP stack location to
|
---|
18836 | // the next stack location, i.e. it "pushes" the stack.
|
---|
18837 | //
|
---|
18838 | // Arguments:
|
---|
18839 | //
|
---|
18840 | // Irp - Pointer to the I/O Request Packet (IRP).
|
---|
18841 | //
|
---|
18842 | // Return Value:
|
---|
18843 | //
|
---|
18844 | // None.
|
---|
18845 | //
|
---|
18846 | //--
|
---|
18847 |
|
---|
18848 | #define IoSetNextIrpStackLocation( Irp ) { \
|
---|
18849 | (Irp)->CurrentLocation--; \
|
---|
18850 | (Irp)->Tail.Overlay.CurrentStackLocation--; }
|
---|
18851 |
|
---|
18852 | //++
|
---|
18853 | //
|
---|
18854 | // VOID
|
---|
18855 | // IoCopyCurrentIrpStackLocationToNext(
|
---|
18856 | // IN PIRP Irp
|
---|
18857 | // )
|
---|
18858 | //
|
---|
18859 | // Routine Description:
|
---|
18860 | //
|
---|
18861 | // This routine is invoked to copy the IRP stack arguments and file
|
---|
18862 | // pointer from the current IrpStackLocation to the next
|
---|
18863 | // in an I/O Request Packet (IRP).
|
---|
18864 | //
|
---|
18865 | // If the caller wants to call IoCallDriver with a completion routine
|
---|
18866 | // but does not wish to change the arguments otherwise,
|
---|
18867 | // the caller first calls IoCopyCurrentIrpStackLocationToNext,
|
---|
18868 | // then IoSetCompletionRoutine, then IoCallDriver.
|
---|
18869 | //
|
---|
18870 | // Arguments:
|
---|
18871 | //
|
---|
18872 | // Irp - Pointer to the I/O Request Packet.
|
---|
18873 | //
|
---|
18874 | // Return Value:
|
---|
18875 | //
|
---|
18876 | // None.
|
---|
18877 | //
|
---|
18878 | //--
|
---|
18879 |
|
---|
18880 | #define IoCopyCurrentIrpStackLocationToNext( Irp ) { \
|
---|
18881 | PIO_STACK_LOCATION __irpSp; \
|
---|
18882 | PIO_STACK_LOCATION __nextIrpSp; \
|
---|
18883 | __irpSp = IoGetCurrentIrpStackLocation( (Irp) ); \
|
---|
18884 | __nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); \
|
---|
18885 | RtlCopyMemory( __nextIrpSp, __irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
|
---|
18886 | __nextIrpSp->Control = 0; }
|
---|
18887 |
|
---|
18888 | //++
|
---|
18889 | //
|
---|
18890 | // VOID
|
---|
18891 | // IoSkipCurrentIrpStackLocation (
|
---|
18892 | // IN PIRP Irp
|
---|
18893 | // )
|
---|
18894 | //
|
---|
18895 | // Routine Description:
|
---|
18896 | //
|
---|
18897 | // This routine is invoked to increment the current stack location of
|
---|
18898 | // a given IRP.
|
---|
18899 | //
|
---|
18900 | // If the caller wishes to call the next driver in a stack, and does not
|
---|
18901 | // wish to change the arguments, nor does he wish to set a completion
|
---|
18902 | // routine, then the caller first calls IoSkipCurrentIrpStackLocation
|
---|
18903 | // and the calls IoCallDriver.
|
---|
18904 | //
|
---|
18905 | // Arguments:
|
---|
18906 | //
|
---|
18907 | // Irp - Pointer to the I/O Request Packet.
|
---|
18908 | //
|
---|
18909 | // Return Value:
|
---|
18910 | //
|
---|
18911 | // None
|
---|
18912 | //
|
---|
18913 | //--
|
---|
18914 |
|
---|
18915 | #define IoSkipCurrentIrpStackLocation( Irp ) { \
|
---|
18916 | (Irp)->CurrentLocation++; \
|
---|
18917 | (Irp)->Tail.Overlay.CurrentStackLocation++; }
|
---|
18918 |
|
---|
18919 |
|
---|
18920 | NTKERNELAPI
|
---|
18921 | VOID
|
---|
18922 | IoSetShareAccess(
|
---|
18923 | IN ACCESS_MASK DesiredAccess,
|
---|
18924 | IN ULONG DesiredShareAccess,
|
---|
18925 | IN OUT PFILE_OBJECT FileObject,
|
---|
18926 | OUT PSHARE_ACCESS ShareAccess
|
---|
18927 | );
|
---|
18928 |
|
---|
18929 |
|
---|
18930 |
|
---|
18931 | typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
|
---|
18932 |
|
---|
18933 | typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
|
---|
18934 | BOOLEAN Removed;
|
---|
18935 | BOOLEAN Reserved [3];
|
---|
18936 | LONG IoCount;
|
---|
18937 | KEVENT RemoveEvent;
|
---|
18938 |
|
---|
18939 | } IO_REMOVE_LOCK_COMMON_BLOCK;
|
---|
18940 |
|
---|
18941 | typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
|
---|
18942 | LONG Signature;
|
---|
18943 | ULONG HighWatermark;
|
---|
18944 | LONGLONG MaxLockedTicks;
|
---|
18945 | LONG AllocateTag;
|
---|
18946 | LIST_ENTRY LockList;
|
---|
18947 | KSPIN_LOCK Spin;
|
---|
18948 | LONG LowMemoryCount;
|
---|
18949 | ULONG Reserved1[4];
|
---|
18950 | PVOID Reserved2;
|
---|
18951 | PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
|
---|
18952 | } IO_REMOVE_LOCK_DBG_BLOCK;
|
---|
18953 |
|
---|
18954 | typedef struct _IO_REMOVE_LOCK {
|
---|
18955 | IO_REMOVE_LOCK_COMMON_BLOCK Common;
|
---|
18956 | #if DBG
|
---|
18957 | IO_REMOVE_LOCK_DBG_BLOCK Dbg;
|
---|
18958 | #endif
|
---|
18959 | } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
|
---|
18960 |
|
---|
18961 | #define IoInitializeRemoveLock(Lock, Tag, Maxmin, HighWater) \
|
---|
18962 | IoInitializeRemoveLockEx (Lock, Tag, Maxmin, HighWater, sizeof (IO_REMOVE_LOCK))
|
---|
18963 |
|
---|
18964 | NTSYSAPI
|
---|
18965 | VOID
|
---|
18966 | NTAPI
|
---|
18967 | IoInitializeRemoveLockEx(
|
---|
18968 | IN PIO_REMOVE_LOCK Lock,
|
---|
18969 | IN ULONG AllocateTag, // Used only on checked kernels
|
---|
18970 | IN ULONG MaxLockedMinutes, // Used only on checked kernels
|
---|
18971 | IN ULONG HighWatermark, // Used only on checked kernels
|
---|
18972 | IN ULONG RemlockSize // are we checked or free
|
---|
18973 | );
|
---|
18974 | //
|
---|
18975 | // Initialize a remove lock.
|
---|
18976 | //
|
---|
18977 | // Note: Allocation for remove locks needs to be within the device extension,
|
---|
18978 | // so that the memory for this structure stays allocated until such time as the
|
---|
18979 | // device object itself is deallocated.
|
---|
18980 | //
|
---|
18981 |
|
---|
18982 | #define IoAcquireRemoveLock(RemoveLock, Tag) \
|
---|
18983 | IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
|
---|
18984 |
|
---|
18985 | NTSYSAPI
|
---|
18986 | NTSTATUS
|
---|
18987 | NTAPI
|
---|
18988 | IoAcquireRemoveLockEx (
|
---|
18989 | IN PIO_REMOVE_LOCK RemoveLock,
|
---|
18990 | IN OPTIONAL PVOID Tag, // Optional
|
---|
18991 | IN PCSTR File,
|
---|
18992 | IN ULONG Line,
|
---|
18993 | IN ULONG RemlockSize // are we checked or free
|
---|
18994 | );
|
---|
18995 |
|
---|
18996 | //
|
---|
18997 | // Routine Description:
|
---|
18998 | //
|
---|
18999 | // This routine is called to acquire the remove lock for a device object.
|
---|
19000 | // While the lock is held, the caller can assume that no pending pnp REMOVE
|
---|
19001 | // requests will be completed.
|
---|
19002 | //
|
---|
19003 | // The lock should be acquired immediately upon entering a dispatch routine.
|
---|
19004 | // It should also be acquired before creating any new reference to the
|
---|
19005 | // device object if there's a chance of releasing the reference before the
|
---|
19006 | // new one is done, in addition to references to the driver code itself,
|
---|
19007 | // which is removed from memory when the last device object goes.
|
---|
19008 | //
|
---|
19009 | // Arguments:
|
---|
19010 | //
|
---|
19011 | // RemoveLock - A pointer to an initialized REMOVE_LOCK structure.
|
---|
19012 | //
|
---|
19013 | // Tag - Used for tracking lock allocation and release. The same tag
|
---|
19014 | // specified when acquiring the lock must be used to release the lock.
|
---|
19015 | // Tags are only checked in checked versions of the driver.
|
---|
19016 | //
|
---|
19017 | // File - set to __FILE__ as the location in the code where the lock was taken.
|
---|
19018 | //
|
---|
19019 | // Line - set to __LINE__.
|
---|
19020 | //
|
---|
19021 | // Return Value:
|
---|
19022 | //
|
---|
19023 | // Returns whether or not the remove lock was obtained.
|
---|
19024 | // If successful the caller should continue with work calling
|
---|
19025 | // IoReleaseRemoveLock when finished.
|
---|
19026 | //
|
---|
19027 | // If not successful the lock was not obtained. The caller should abort the
|
---|
19028 | // work but not call IoReleaseRemoveLock.
|
---|
19029 | //
|
---|
19030 |
|
---|
19031 | #define IoReleaseRemoveLock(RemoveLock, Tag) \
|
---|
19032 | IoReleaseRemoveLockEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
|
---|
19033 |
|
---|
19034 | NTSYSAPI
|
---|
19035 | VOID
|
---|
19036 | NTAPI
|
---|
19037 | IoReleaseRemoveLockEx(
|
---|
19038 | IN PIO_REMOVE_LOCK RemoveLock,
|
---|
19039 | IN PVOID Tag, // Optional
|
---|
19040 | IN ULONG RemlockSize // are we checked or free
|
---|
19041 | );
|
---|
19042 | //
|
---|
19043 | //
|
---|
19044 | // Routine Description:
|
---|
19045 | //
|
---|
19046 | // This routine is called to release the remove lock on the device object. It
|
---|
19047 | // must be called when finished using a previously locked reference to the
|
---|
19048 | // device object. If an Tag was specified when acquiring the lock then the
|
---|
19049 | // same Tag must be specified when releasing the lock.
|
---|
19050 | //
|
---|
19051 | // When the lock count reduces to zero, this routine will signal the waiting
|
---|
19052 | // event to release the waiting thread deleting the device object protected
|
---|
19053 | // by this lock.
|
---|
19054 | //
|
---|
19055 | // Arguments:
|
---|
19056 | //
|
---|
19057 | // DeviceObject - the device object to lock
|
---|
19058 | //
|
---|
19059 | // Tag - The TAG (if any) specified when acquiring the lock. This is used
|
---|
19060 | // for lock tracking purposes
|
---|
19061 | //
|
---|
19062 | // Return Value:
|
---|
19063 | //
|
---|
19064 | // none
|
---|
19065 | //
|
---|
19066 |
|
---|
19067 | #define IoReleaseRemoveLockAndWait(RemoveLock, Tag) \
|
---|
19068 | IoReleaseRemoveLockAndWaitEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
|
---|
19069 |
|
---|
19070 | NTSYSAPI
|
---|
19071 | VOID
|
---|
19072 | NTAPI
|
---|
19073 | IoReleaseRemoveLockAndWaitEx(
|
---|
19074 | IN PIO_REMOVE_LOCK RemoveLock,
|
---|
19075 | IN PVOID Tag,
|
---|
19076 | IN ULONG RemlockSize // are we checked or free
|
---|
19077 | );
|
---|
19078 | //
|
---|
19079 | //
|
---|
19080 | // Routine Description:
|
---|
19081 | //
|
---|
19082 | // This routine is called when the client would like to delete the
|
---|
19083 | // remove-locked resource. This routine will block until all the remove
|
---|
19084 | // locks have released.
|
---|
19085 | //
|
---|
19086 | // This routine MUST be called after acquiring the lock.
|
---|
19087 | //
|
---|
19088 | // Arguments:
|
---|
19089 | //
|
---|
19090 | // RemoveLock
|
---|
19091 | //
|
---|
19092 | // Return Value:
|
---|
19093 | //
|
---|
19094 | // none
|
---|
19095 | //
|
---|
19096 |
|
---|
19097 |
|
---|
19098 | //++
|
---|
19099 | //
|
---|
19100 | // USHORT
|
---|
19101 | // IoSizeOfIrp(
|
---|
19102 | // IN CCHAR StackSize
|
---|
19103 | // )
|
---|
19104 | //
|
---|
19105 | // Routine Description:
|
---|
19106 | //
|
---|
19107 | // Determines the size of an IRP given the number of stack locations
|
---|
19108 | // the IRP will have.
|
---|
19109 | //
|
---|
19110 | // Arguments:
|
---|
19111 | //
|
---|
19112 | // StackSize - Number of stack locations for the IRP.
|
---|
19113 | //
|
---|
19114 | // Return Value:
|
---|
19115 | //
|
---|
19116 | // Size in bytes of the IRP.
|
---|
19117 | //
|
---|
19118 | //--
|
---|
19119 |
|
---|
19120 | #define IoSizeOfIrp( StackSize ) \
|
---|
19121 | ((USHORT) (sizeof( IRP ) + ((StackSize) * (sizeof( IO_STACK_LOCATION )))))
|
---|
19122 |
|
---|
19123 |
|
---|
19124 |
|
---|
19125 |
|
---|
19126 | NTKERNELAPI
|
---|
19127 | VOID
|
---|
19128 | IoStartNextPacket(
|
---|
19129 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19130 | IN BOOLEAN Cancelable
|
---|
19131 | );
|
---|
19132 |
|
---|
19133 | NTKERNELAPI
|
---|
19134 | VOID
|
---|
19135 | IoStartNextPacketByKey(
|
---|
19136 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19137 | IN BOOLEAN Cancelable,
|
---|
19138 | IN ULONG Key
|
---|
19139 | );
|
---|
19140 |
|
---|
19141 | NTKERNELAPI
|
---|
19142 | VOID
|
---|
19143 | IoStartPacket(
|
---|
19144 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19145 | IN PIRP Irp,
|
---|
19146 | IN PULONG Key OPTIONAL,
|
---|
19147 | IN PDRIVER_CANCEL CancelFunction OPTIONAL
|
---|
19148 | );
|
---|
19149 |
|
---|
19150 | VOID
|
---|
19151 | IoSetStartIoAttributes(
|
---|
19152 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19153 | IN BOOLEAN DeferredStartIo,
|
---|
19154 | IN BOOLEAN NonCancelable
|
---|
19155 | );
|
---|
19156 |
|
---|
19157 |
|
---|
19158 |
|
---|
19159 | NTKERNELAPI
|
---|
19160 | VOID
|
---|
19161 | IoStartTimer(
|
---|
19162 | IN PDEVICE_OBJECT DeviceObject
|
---|
19163 | );
|
---|
19164 |
|
---|
19165 | NTKERNELAPI
|
---|
19166 | VOID
|
---|
19167 | IoStopTimer(
|
---|
19168 | IN PDEVICE_OBJECT DeviceObject
|
---|
19169 | );
|
---|
19170 |
|
---|
19171 |
|
---|
19172 | NTKERNELAPI
|
---|
19173 | VOID
|
---|
19174 | IoUnregisterShutdownNotification(
|
---|
19175 | IN PDEVICE_OBJECT DeviceObject
|
---|
19176 | );
|
---|
19177 |
|
---|
19178 |
|
---|
19179 |
|
---|
19180 | NTKERNELAPI
|
---|
19181 | VOID
|
---|
19182 | IoUpdateShareAccess(
|
---|
19183 | IN PFILE_OBJECT FileObject,
|
---|
19184 | IN OUT PSHARE_ACCESS ShareAccess
|
---|
19185 | );
|
---|
19186 |
|
---|
19187 | NTKERNELAPI
|
---|
19188 | VOID
|
---|
19189 | IoWriteErrorLogEntry(
|
---|
19190 | IN PVOID ElEntry
|
---|
19191 | );
|
---|
19192 |
|
---|
19193 | typedef struct _IO_WORKITEM *PIO_WORKITEM;
|
---|
19194 |
|
---|
19195 | typedef
|
---|
19196 | VOID
|
---|
19197 | (*PIO_WORKITEM_ROUTINE) (
|
---|
19198 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19199 | IN PVOID Context
|
---|
19200 | );
|
---|
19201 |
|
---|
19202 | PIO_WORKITEM
|
---|
19203 | IoAllocateWorkItem(
|
---|
19204 | PDEVICE_OBJECT DeviceObject
|
---|
19205 | );
|
---|
19206 |
|
---|
19207 | VOID
|
---|
19208 | IoFreeWorkItem(
|
---|
19209 | PIO_WORKITEM IoWorkItem
|
---|
19210 | );
|
---|
19211 |
|
---|
19212 | VOID
|
---|
19213 | IoQueueWorkItem(
|
---|
19214 | IN PIO_WORKITEM IoWorkItem,
|
---|
19215 | IN PIO_WORKITEM_ROUTINE WorkerRoutine,
|
---|
19216 | IN WORK_QUEUE_TYPE QueueType,
|
---|
19217 | IN PVOID Context
|
---|
19218 | );
|
---|
19219 |
|
---|
19220 |
|
---|
19221 | NTKERNELAPI
|
---|
19222 | NTSTATUS
|
---|
19223 | IoWMIRegistrationControl(
|
---|
19224 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19225 | IN ULONG Action
|
---|
19226 | );
|
---|
19227 |
|
---|
19228 | //
|
---|
19229 | // Action code for IoWMIRegistrationControl api
|
---|
19230 | //
|
---|
19231 |
|
---|
19232 | #define WMIREG_ACTION_REGISTER 1
|
---|
19233 | #define WMIREG_ACTION_DEREGISTER 2
|
---|
19234 | #define WMIREG_ACTION_REREGISTER 3
|
---|
19235 | #define WMIREG_ACTION_UPDATE_GUIDS 4
|
---|
19236 | #define WMIREG_ACTION_BLOCK_IRPS 5
|
---|
19237 |
|
---|
19238 | //
|
---|
19239 | // Code passed in IRP_MN_REGINFO WMI irp
|
---|
19240 | //
|
---|
19241 |
|
---|
19242 | #define WMIREGISTER 0
|
---|
19243 | #define WMIUPDATE 1
|
---|
19244 |
|
---|
19245 | NTKERNELAPI
|
---|
19246 | NTSTATUS
|
---|
19247 | IoWMIAllocateInstanceIds(
|
---|
19248 | IN GUID *Guid,
|
---|
19249 | IN ULONG InstanceCount,
|
---|
19250 | OUT ULONG *FirstInstanceId
|
---|
19251 | );
|
---|
19252 |
|
---|
19253 | NTKERNELAPI
|
---|
19254 | NTSTATUS
|
---|
19255 | IoWMISuggestInstanceName(
|
---|
19256 | IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
|
---|
19257 | IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
|
---|
19258 | IN BOOLEAN CombineNames,
|
---|
19259 | OUT PUNICODE_STRING SuggestedInstanceName
|
---|
19260 | );
|
---|
19261 |
|
---|
19262 | NTKERNELAPI
|
---|
19263 | NTSTATUS
|
---|
19264 | IoWMIWriteEvent(
|
---|
19265 | IN PVOID WnodeEventItem
|
---|
19266 | );
|
---|
19267 |
|
---|
19268 | #if defined(_WIN64)
|
---|
19269 | NTKERNELAPI
|
---|
19270 | ULONG IoWMIDeviceObjectToProviderId(
|
---|
19271 | PDEVICE_OBJECT DeviceObject
|
---|
19272 | );
|
---|
19273 | #else
|
---|
19274 | #define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
|
---|
19275 | #endif
|
---|
19276 |
|
---|
19277 | NTKERNELAPI
|
---|
19278 | NTSTATUS IoWMIOpenBlock(
|
---|
19279 | IN GUID *DataBlockGuid,
|
---|
19280 | IN ULONG DesiredAccess,
|
---|
19281 | OUT PVOID *DataBlockObject
|
---|
19282 | );
|
---|
19283 |
|
---|
19284 |
|
---|
19285 | NTKERNELAPI
|
---|
19286 | NTSTATUS IoWMIQueryAllData(
|
---|
19287 | IN PVOID DataBlockObject,
|
---|
19288 | IN OUT ULONG *InOutBufferSize,
|
---|
19289 | OUT /* non paged */ PVOID OutBuffer
|
---|
19290 | );
|
---|
19291 |
|
---|
19292 |
|
---|
19293 | NTKERNELAPI
|
---|
19294 | NTSTATUS
|
---|
19295 | IoWMIQueryAllDataMultiple(
|
---|
19296 | IN PVOID *DataBlockObjectList,
|
---|
19297 | IN ULONG ObjectCount,
|
---|
19298 | IN OUT ULONG *InOutBufferSize,
|
---|
19299 | OUT /* non paged */ PVOID OutBuffer
|
---|
19300 | );
|
---|
19301 |
|
---|
19302 |
|
---|
19303 | NTKERNELAPI
|
---|
19304 | NTSTATUS
|
---|
19305 | IoWMIQuerySingleInstance(
|
---|
19306 | IN PVOID DataBlockObject,
|
---|
19307 | IN PUNICODE_STRING InstanceName,
|
---|
19308 | IN OUT ULONG *InOutBufferSize,
|
---|
19309 | OUT /* non paged */ PVOID OutBuffer
|
---|
19310 | );
|
---|
19311 |
|
---|
19312 | NTKERNELAPI
|
---|
19313 | NTSTATUS
|
---|
19314 | IoWMIQuerySingleInstanceMultiple(
|
---|
19315 | IN PVOID *DataBlockObjectList,
|
---|
19316 | IN PUNICODE_STRING InstanceNames,
|
---|
19317 | IN ULONG ObjectCount,
|
---|
19318 | IN OUT ULONG *InOutBufferSize,
|
---|
19319 | OUT /* non paged */ PVOID OutBuffer
|
---|
19320 | );
|
---|
19321 |
|
---|
19322 | NTKERNELAPI
|
---|
19323 | NTSTATUS
|
---|
19324 | IoWMISetSingleInstance(
|
---|
19325 | IN PVOID DataBlockObject,
|
---|
19326 | IN PUNICODE_STRING InstanceName,
|
---|
19327 | IN ULONG Version,
|
---|
19328 | IN ULONG ValueBufferSize,
|
---|
19329 | IN PVOID ValueBuffer
|
---|
19330 | );
|
---|
19331 |
|
---|
19332 | NTKERNELAPI
|
---|
19333 | NTSTATUS
|
---|
19334 | IoWMISetSingleItem(
|
---|
19335 | IN PVOID DataBlockObject,
|
---|
19336 | IN PUNICODE_STRING InstanceName,
|
---|
19337 | IN ULONG DataItemId,
|
---|
19338 | IN ULONG Version,
|
---|
19339 | IN ULONG ValueBufferSize,
|
---|
19340 | IN PVOID ValueBuffer
|
---|
19341 | );
|
---|
19342 |
|
---|
19343 | NTKERNELAPI
|
---|
19344 | NTSTATUS
|
---|
19345 | IoWMIExecuteMethod(
|
---|
19346 | IN PVOID DataBlockObject,
|
---|
19347 | IN PUNICODE_STRING InstanceName,
|
---|
19348 | IN ULONG MethodId,
|
---|
19349 | IN ULONG InBufferSize,
|
---|
19350 | IN OUT PULONG OutBufferSize,
|
---|
19351 | IN OUT PUCHAR InOutBuffer
|
---|
19352 | );
|
---|
19353 |
|
---|
19354 |
|
---|
19355 |
|
---|
19356 | typedef VOID (*WMI_NOTIFICATION_CALLBACK)(
|
---|
19357 | PVOID Wnode,
|
---|
19358 | PVOID Context
|
---|
19359 | );
|
---|
19360 |
|
---|
19361 | NTKERNELAPI
|
---|
19362 | NTSTATUS
|
---|
19363 | IoWMISetNotificationCallback(
|
---|
19364 | IN PVOID Object,
|
---|
19365 | IN WMI_NOTIFICATION_CALLBACK Callback,
|
---|
19366 | IN PVOID Context
|
---|
19367 | );
|
---|
19368 |
|
---|
19369 | NTKERNELAPI
|
---|
19370 | NTSTATUS
|
---|
19371 | IoWMIHandleToInstanceName(
|
---|
19372 | IN PVOID DataBlockObject,
|
---|
19373 | IN HANDLE FileHandle,
|
---|
19374 | OUT PUNICODE_STRING InstanceName
|
---|
19375 | );
|
---|
19376 |
|
---|
19377 | NTKERNELAPI
|
---|
19378 | NTSTATUS
|
---|
19379 | IoWMIDeviceObjectToInstanceName(
|
---|
19380 | IN PVOID DataBlockObject,
|
---|
19381 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19382 | OUT PUNICODE_STRING InstanceName
|
---|
19383 | );
|
---|
19384 |
|
---|
19385 | #if defined(_WIN64)
|
---|
19386 | BOOLEAN
|
---|
19387 | IoIs32bitProcess(
|
---|
19388 | IN PIRP Irp
|
---|
19389 | );
|
---|
19390 | #endif
|
---|
19391 | NTKERNELAPI
|
---|
19392 | VOID
|
---|
19393 | FASTCALL
|
---|
19394 | HalExamineMBR(
|
---|
19395 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19396 | IN ULONG SectorSize,
|
---|
19397 | IN ULONG MBRTypeIdentifier,
|
---|
19398 | OUT PVOID *Buffer
|
---|
19399 | );
|
---|
19400 |
|
---|
19401 | DECLSPEC_DEPRECATED_DDK // Use IoReadPartitionTableEx
|
---|
19402 | NTKERNELAPI
|
---|
19403 | NTSTATUS
|
---|
19404 | FASTCALL
|
---|
19405 | IoReadPartitionTable(
|
---|
19406 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19407 | IN ULONG SectorSize,
|
---|
19408 | IN BOOLEAN ReturnRecognizedPartitions,
|
---|
19409 | OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer
|
---|
19410 | );
|
---|
19411 |
|
---|
19412 | DECLSPEC_DEPRECATED_DDK // Use IoSetPartitionInformationEx
|
---|
19413 | NTKERNELAPI
|
---|
19414 | NTSTATUS
|
---|
19415 | FASTCALL
|
---|
19416 | IoSetPartitionInformation(
|
---|
19417 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19418 | IN ULONG SectorSize,
|
---|
19419 | IN ULONG PartitionNumber,
|
---|
19420 | IN ULONG PartitionType
|
---|
19421 | );
|
---|
19422 |
|
---|
19423 |
|
---|
19424 | DECLSPEC_DEPRECATED_DDK // Use IoWritePartitionTableEx
|
---|
19425 | NTKERNELAPI
|
---|
19426 | NTSTATUS
|
---|
19427 | FASTCALL
|
---|
19428 | IoWritePartitionTable(
|
---|
19429 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19430 | IN ULONG SectorSize,
|
---|
19431 | IN ULONG SectorsPerTrack,
|
---|
19432 | IN ULONG NumberOfHeads,
|
---|
19433 | IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer
|
---|
19434 | );
|
---|
19435 |
|
---|
19436 | NTKERNELAPI
|
---|
19437 | NTSTATUS
|
---|
19438 | IoCreateDisk(
|
---|
19439 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19440 | IN struct _CREATE_DISK* Disk
|
---|
19441 | );
|
---|
19442 |
|
---|
19443 | NTKERNELAPI
|
---|
19444 | NTSTATUS
|
---|
19445 | IoReadPartitionTableEx(
|
---|
19446 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19447 | IN struct _DRIVE_LAYOUT_INFORMATION_EX** DriveLayout
|
---|
19448 | );
|
---|
19449 |
|
---|
19450 | NTKERNELAPI
|
---|
19451 | NTSTATUS
|
---|
19452 | IoWritePartitionTableEx(
|
---|
19453 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19454 | IN struct _DRIVE_LAYOUT_INFORMATION_EX* DriveLayout
|
---|
19455 | );
|
---|
19456 |
|
---|
19457 | NTKERNELAPI
|
---|
19458 | NTSTATUS
|
---|
19459 | IoSetPartitionInformationEx(
|
---|
19460 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19461 | IN ULONG PartitionNumber,
|
---|
19462 | IN struct _SET_PARTITION_INFORMATION_EX* PartitionInfo
|
---|
19463 | );
|
---|
19464 |
|
---|
19465 | NTKERNELAPI
|
---|
19466 | NTSTATUS
|
---|
19467 | IoUpdateDiskGeometry(
|
---|
19468 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19469 | IN struct _DISK_GEOMETRY_EX* OldDiskGeometry,
|
---|
19470 | IN struct _DISK_GEOMETRY_EX* NewDiskGeometry
|
---|
19471 | );
|
---|
19472 |
|
---|
19473 | NTKERNELAPI
|
---|
19474 | NTSTATUS
|
---|
19475 | IoVerifyPartitionTable(
|
---|
19476 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19477 | IN BOOLEAN FixErrors
|
---|
19478 | );
|
---|
19479 |
|
---|
19480 | typedef struct _DISK_SIGNATURE {
|
---|
19481 | ULONG PartitionStyle;
|
---|
19482 | union {
|
---|
19483 | struct {
|
---|
19484 | ULONG Signature;
|
---|
19485 | ULONG CheckSum;
|
---|
19486 | } Mbr;
|
---|
19487 |
|
---|
19488 | struct {
|
---|
19489 | GUID DiskId;
|
---|
19490 | } Gpt;
|
---|
19491 | };
|
---|
19492 | } DISK_SIGNATURE, *PDISK_SIGNATURE;
|
---|
19493 |
|
---|
19494 | NTKERNELAPI
|
---|
19495 | NTSTATUS
|
---|
19496 | IoReadDiskSignature(
|
---|
19497 | IN PDEVICE_OBJECT DeviceObject,
|
---|
19498 | IN ULONG BytesPerSector,
|
---|
19499 | OUT PDISK_SIGNATURE Signature
|
---|
19500 | );
|
---|
19501 |
|
---|
19502 |
|
---|
19503 |
|
---|
19504 | NTSTATUS
|
---|
19505 | IoVolumeDeviceToDosName(
|
---|
19506 | IN PVOID VolumeDeviceObject,
|
---|
19507 | OUT PUNICODE_STRING DosName
|
---|
19508 | );
|
---|
19509 |
|
---|
19510 | NTSTATUS
|
---|
19511 | IoSetSystemPartition(
|
---|
19512 | PUNICODE_STRING VolumeNameString
|
---|
19513 | );
|
---|
19514 |
|
---|
19515 |
|
---|
19516 | VOID
|
---|
19517 | IoFreeErrorLogEntry(
|
---|
19518 | PVOID ElEntry
|
---|
19519 | );
|
---|
19520 |
|
---|
19521 | // Cancel SAFE API set start
|
---|
19522 | //
|
---|
19523 | // The following APIs are to help ease the pain of writing queue packages that
|
---|
19524 | // handle the cancellation race well. The idea of this set of APIs is to not
|
---|
19525 | // force a single queue data structure but allow the cancel logic to be hidden
|
---|
19526 | // from the drivers. A driver implements a queue and as part of its header
|
---|
19527 | // includes the IO_CSQ structure. In its initialization routine it calls
|
---|
19528 | // IoInitializeCsq. Then in the dispatch routine when the driver wants to
|
---|
19529 | // insert an IRP into the queue it calls IoCsqInsertIrp. When the driver wants
|
---|
19530 | // to remove something from the queue it calls IoCsqRemoveIrp. Note that Insert
|
---|
19531 | // can fail if the IRP was cancelled in the meantime. Remove can also fail if
|
---|
19532 | // the IRP was already cancelled.
|
---|
19533 | //
|
---|
19534 | // There are typically two modes where drivers queue IRPs. These two modes are
|
---|
19535 | // covered by the cancel safe queue API set.
|
---|
19536 | //
|
---|
19537 | // Mode 1:
|
---|
19538 | // One is where the driver queues the IRP and at some later
|
---|
19539 | // point in time dequeues an IRP and issues the IO request.
|
---|
19540 | // For this mode the driver should use IoCsqInsertIrp and IoCsqRemoveNextIrp.
|
---|
19541 | // The driver in this case is expected to pass NULL to the irp context
|
---|
19542 | // parameter in IoInsertIrp.
|
---|
19543 | //
|
---|
19544 | // Mode 2:
|
---|
19545 | // In this the driver queues theIRP, issues the IO request (like issuing a DMA
|
---|
19546 | // request or writing to a register) and when the IO request completes (either
|
---|
19547 | // using a DPC or timer) the driver dequeues the IRP and completes it. For this
|
---|
19548 | // mode the driver should use IoCsqInsertIrp and IoCsqRemoveIrp. In this case
|
---|
19549 | // the driver should allocate an IRP context and pass it in to IoCsqInsertIrp.
|
---|
19550 | // The cancel API code creates an association between the IRP and the context
|
---|
19551 | // and thus ensures that when the time comes to remove the IRP it can ascertain
|
---|
19552 | // correctly.
|
---|
19553 | //
|
---|
19554 | // Note that the cancel API set assumes that the field DriverContext[3] is
|
---|
19555 | // always available for use and that the driver does not use it.
|
---|
19556 | //
|
---|
19557 |
|
---|
19558 |
|
---|
19559 | //
|
---|
19560 | // Bookkeeping structure. This should be opaque to drivers.
|
---|
19561 | // Drivers typically include this as part of their queue headers.
|
---|
19562 | // Given a CSQ pointer the driver should be able to get its
|
---|
19563 | // queue header using CONTAINING_RECORD macro
|
---|
19564 | //
|
---|
19565 |
|
---|
19566 | typedef struct _IO_CSQ IO_CSQ, *PIO_CSQ;
|
---|
19567 |
|
---|
19568 | #define IO_TYPE_CSQ_IRP_CONTEXT 1
|
---|
19569 | #define IO_TYPE_CSQ 2
|
---|
19570 | #define IO_TYPE_CSQ_EX 3
|
---|
19571 |
|
---|
19572 | //
|
---|
19573 | // IRP context structure. This structure is necessary if the driver is using
|
---|
19574 | // the second mode.
|
---|
19575 | //
|
---|
19576 |
|
---|
19577 |
|
---|
19578 | typedef struct _IO_CSQ_IRP_CONTEXT {
|
---|
19579 | ULONG Type;
|
---|
19580 | PIRP Irp;
|
---|
19581 | PIO_CSQ Csq;
|
---|
19582 | } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
|
---|
19583 |
|
---|
19584 | //
|
---|
19585 | // Routines that insert/remove IRP
|
---|
19586 | //
|
---|
19587 |
|
---|
19588 | typedef VOID
|
---|
19589 | (*PIO_CSQ_INSERT_IRP)(
|
---|
19590 | IN struct _IO_CSQ *Csq,
|
---|
19591 | IN PIRP Irp
|
---|
19592 | );
|
---|
19593 |
|
---|
19594 | typedef NTSTATUS
|
---|
19595 | (*PIO_CSQ_INSERT_IRP_EX)(
|
---|
19596 | IN struct _IO_CSQ *Csq,
|
---|
19597 | IN PIRP Irp,
|
---|
19598 | IN OUT PVOID InsertContext
|
---|
19599 | );
|
---|
19600 |
|
---|
19601 | typedef VOID
|
---|
19602 | (*PIO_CSQ_REMOVE_IRP)(
|
---|
19603 | IN PIO_CSQ Csq,
|
---|
19604 | IN PIRP Irp
|
---|
19605 | );
|
---|
19606 |
|
---|
19607 | //
|
---|
19608 | // Retrieves next entry after Irp from the queue.
|
---|
19609 | // Returns NULL if there are no entries in the queue.
|
---|
19610 | // If Irp is NUL, returns the entry in the head of the queue.
|
---|
19611 | // This routine does not remove the IRP from the queue.
|
---|
19612 | //
|
---|
19613 |
|
---|
19614 |
|
---|
19615 | typedef PIRP
|
---|
19616 | (*PIO_CSQ_PEEK_NEXT_IRP)(
|
---|
19617 | IN PIO_CSQ Csq,
|
---|
19618 | IN PIRP Irp,
|
---|
19619 | IN PVOID PeekContext
|
---|
19620 | );
|
---|
19621 |
|
---|
19622 | //
|
---|
19623 | // Lock routine that protects the cancel safe queue.
|
---|
19624 | //
|
---|
19625 |
|
---|
19626 | typedef VOID
|
---|
19627 | (*PIO_CSQ_ACQUIRE_LOCK)(
|
---|
19628 | IN PIO_CSQ Csq,
|
---|
19629 | OUT PKIRQL Irql
|
---|
19630 | );
|
---|
19631 |
|
---|
19632 | typedef VOID
|
---|
19633 | (*PIO_CSQ_RELEASE_LOCK)(
|
---|
19634 | IN PIO_CSQ Csq,
|
---|
19635 | IN KIRQL Irql
|
---|
19636 | );
|
---|
19637 |
|
---|
19638 |
|
---|
19639 | //
|
---|
19640 | // Completes the IRP with STATUS_CANCELLED. IRP is guaranteed to be valid
|
---|
19641 | // In most cases this routine just calls IoCompleteRequest(Irp, STATUS_CANCELLED);
|
---|
19642 | //
|
---|
19643 |
|
---|
19644 | typedef VOID
|
---|
19645 | (*PIO_CSQ_COMPLETE_CANCELED_IRP)(
|
---|
19646 | IN PIO_CSQ Csq,
|
---|
19647 | IN PIRP Irp
|
---|
19648 | );
|
---|
19649 |
|
---|
19650 | //
|
---|
19651 | // Bookkeeping structure. This should be opaque to drivers.
|
---|
19652 | // Drivers typically include this as part of their queue headers.
|
---|
19653 | // Given a CSQ pointer the driver should be able to get its
|
---|
19654 | // queue header using CONTAINING_RECORD macro
|
---|
19655 | //
|
---|
19656 |
|
---|
19657 | typedef struct _IO_CSQ {
|
---|
19658 | ULONG Type;
|
---|
19659 | PIO_CSQ_INSERT_IRP CsqInsertIrp;
|
---|
19660 | PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
|
---|
19661 | PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
|
---|
19662 | PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
|
---|
19663 | PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
|
---|
19664 | PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
|
---|
19665 | PVOID ReservePointer; // Future expansion
|
---|
19666 | } IO_CSQ, *PIO_CSQ;
|
---|
19667 |
|
---|
19668 | //
|
---|
19669 | // Initializes the cancel queue structure.
|
---|
19670 | //
|
---|
19671 |
|
---|
19672 | NTSTATUS
|
---|
19673 | IoCsqInitialize(
|
---|
19674 | IN PIO_CSQ Csq,
|
---|
19675 | IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
|
---|
19676 | IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
|
---|
19677 | IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
|
---|
19678 | IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
|
---|
19679 | IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
|
---|
19680 | IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
|
---|
19681 | );
|
---|
19682 |
|
---|
19683 | NTSTATUS
|
---|
19684 | IoCsqInitializeEx(
|
---|
19685 | IN PIO_CSQ Csq,
|
---|
19686 | IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp,
|
---|
19687 | IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
|
---|
19688 | IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
|
---|
19689 | IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
|
---|
19690 | IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
|
---|
19691 | IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
|
---|
19692 | );
|
---|
19693 |
|
---|
19694 | //
|
---|
19695 | // The caller calls this routine to insert the IRP and return STATUS_PENDING.
|
---|
19696 | //
|
---|
19697 |
|
---|
19698 | VOID
|
---|
19699 | IoCsqInsertIrp(
|
---|
19700 | IN PIO_CSQ Csq,
|
---|
19701 | IN PIRP Irp,
|
---|
19702 | IN PIO_CSQ_IRP_CONTEXT Context
|
---|
19703 | );
|
---|
19704 |
|
---|
19705 |
|
---|
19706 | NTSTATUS
|
---|
19707 | IoCsqInsertIrpEx(
|
---|
19708 | IN PIO_CSQ Csq,
|
---|
19709 | IN PIRP Irp,
|
---|
19710 | IN PIO_CSQ_IRP_CONTEXT Context,
|
---|
19711 | IN PVOID InsertContext
|
---|
19712 | );
|
---|
19713 |
|
---|
19714 | //
|
---|
19715 | // Returns an IRP if one can be found. NULL otherwise.
|
---|
19716 | //
|
---|
19717 |
|
---|
19718 | PIRP
|
---|
19719 | IoCsqRemoveNextIrp(
|
---|
19720 | IN PIO_CSQ Csq,
|
---|
19721 | IN PVOID PeekContext
|
---|
19722 | );
|
---|
19723 |
|
---|
19724 | //
|
---|
19725 | // This routine is called from timeout or DPCs.
|
---|
19726 | // The context is presumably part of the DPC or timer context.
|
---|
19727 | // If successful returns the IRP associated with context.
|
---|
19728 | //
|
---|
19729 |
|
---|
19730 | PIRP
|
---|
19731 | IoCsqRemoveIrp(
|
---|
19732 | IN PIO_CSQ Csq,
|
---|
19733 | IN PIO_CSQ_IRP_CONTEXT Context
|
---|
19734 | );
|
---|
19735 |
|
---|
19736 | // Cancel SAFE API set end
|
---|
19737 |
|
---|
19738 |
|
---|
19739 | NTSTATUS
|
---|
19740 | IoValidateDeviceIoControlAccess(
|
---|
19741 | IN PIRP Irp,
|
---|
19742 | IN ULONG RequiredAccess
|
---|
19743 | );
|
---|
19744 |
|
---|
19745 |
|
---|
19746 |
|
---|
19747 | IO_PAGING_PRIORITY
|
---|
19748 | FASTCALL
|
---|
19749 | IoGetPagingIoPriority(
|
---|
19750 | IN PIRP IRP
|
---|
19751 | );
|
---|
19752 |
|
---|
19753 |
|
---|
19754 | #ifdef RUN_WPP
|
---|
19755 | #include <evntrace.h>
|
---|
19756 | #include <stdarg.h>
|
---|
19757 | #endif // #ifdef RUN_WPP
|
---|
19758 |
|
---|
19759 | #ifdef RUN_WPP
|
---|
19760 |
|
---|
19761 | NTKERNELAPI
|
---|
19762 | NTSTATUS
|
---|
19763 | WmiTraceMessage(
|
---|
19764 | IN TRACEHANDLE LoggerHandle,
|
---|
19765 | IN ULONG MessageFlags,
|
---|
19766 | IN LPGUID MessageGuid,
|
---|
19767 | IN USHORT MessageNumber,
|
---|
19768 | IN ...
|
---|
19769 | );
|
---|
19770 |
|
---|
19771 | NTKERNELAPI
|
---|
19772 | NTSTATUS
|
---|
19773 | WmiTraceMessageVa(
|
---|
19774 | IN TRACEHANDLE LoggerHandle,
|
---|
19775 | IN ULONG MessageFlags,
|
---|
19776 | IN LPGUID MessageGuid,
|
---|
19777 | IN USHORT MessageNumber,
|
---|
19778 | IN va_list MessageArgList
|
---|
19779 | );
|
---|
19780 |
|
---|
19781 |
|
---|
19782 | #endif // #ifdef RUN_WPP
|
---|
19783 |
|
---|
19784 | #ifndef TRACE_INFORMATION_CLASS_DEFINE
|
---|
19785 | typedef enum _TRACE_INFORMATION_CLASS {
|
---|
19786 | TraceIdClass,
|
---|
19787 | TraceHandleClass,
|
---|
19788 | TraceEnableFlagsClass,
|
---|
19789 | TraceEnableLevelClass,
|
---|
19790 | GlobalLoggerHandleClass,
|
---|
19791 | EventLoggerHandleClass,
|
---|
19792 | AllLoggerHandlesClass,
|
---|
19793 | TraceHandleByNameClass
|
---|
19794 | } TRACE_INFORMATION_CLASS;
|
---|
19795 |
|
---|
19796 | NTKERNELAPI
|
---|
19797 | NTSTATUS
|
---|
19798 | WmiQueryTraceInformation(
|
---|
19799 | IN TRACE_INFORMATION_CLASS TraceInformationClass,
|
---|
19800 | OUT PVOID TraceInformation,
|
---|
19801 | IN ULONG TraceInformationLength,
|
---|
19802 | OUT PULONG RequiredLength OPTIONAL,
|
---|
19803 | IN PVOID Buffer OPTIONAL
|
---|
19804 | );
|
---|
19805 | #define TRACE_INFORMATION_CLASS_DEFINE
|
---|
19806 | #endif // TRACE_INFOPRMATION_CLASS_DEFINE
|
---|
19807 |
|
---|
19808 |
|
---|
19809 | //
|
---|
19810 | // Define PnP Device Property for IoGetDeviceProperty
|
---|
19811 | //
|
---|
19812 |
|
---|
19813 | typedef enum {
|
---|
19814 | DevicePropertyDeviceDescription,
|
---|
19815 | DevicePropertyHardwareID,
|
---|
19816 | DevicePropertyCompatibleIDs,
|
---|
19817 | DevicePropertyBootConfiguration,
|
---|
19818 | DevicePropertyBootConfigurationTranslated,
|
---|
19819 | DevicePropertyClassName,
|
---|
19820 | DevicePropertyClassGuid,
|
---|
19821 | DevicePropertyDriverKeyName,
|
---|
19822 | DevicePropertyManufacturer,
|
---|
19823 | DevicePropertyFriendlyName,
|
---|
19824 | DevicePropertyLocationInformation,
|
---|
19825 | DevicePropertyPhysicalDeviceObjectName,
|
---|
19826 | DevicePropertyBusTypeGuid,
|
---|
19827 | DevicePropertyLegacyBusType,
|
---|
19828 | DevicePropertyBusNumber,
|
---|
19829 | DevicePropertyEnumeratorName,
|
---|
19830 | DevicePropertyAddress,
|
---|
19831 | DevicePropertyUINumber,
|
---|
19832 | DevicePropertyInstallState,
|
---|
19833 | DevicePropertyRemovalPolicy
|
---|
19834 | } DEVICE_REGISTRY_PROPERTY;
|
---|
19835 |
|
---|
19836 | typedef BOOLEAN (*PTRANSLATE_BUS_ADDRESS)(
|
---|
19837 | IN PVOID Context,
|
---|
19838 | IN PHYSICAL_ADDRESS BusAddress,
|
---|
19839 | IN ULONG Length,
|
---|
19840 | IN OUT PULONG AddressSpace,
|
---|
19841 | OUT PPHYSICAL_ADDRESS TranslatedAddress
|
---|
19842 | );
|
---|
19843 |
|
---|
19844 | typedef struct _DMA_ADAPTER *(*PGET_DMA_ADAPTER)(
|
---|
19845 | IN PVOID Context,
|
---|
19846 | IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
|
---|
19847 | OUT PULONG NumberOfMapRegisters
|
---|
19848 | );
|
---|
19849 |
|
---|
19850 | typedef ULONG (*PGET_SET_DEVICE_DATA)(
|
---|
19851 | IN PVOID Context,
|
---|
19852 | IN ULONG DataType,
|
---|
19853 | IN PVOID Buffer,
|
---|
19854 | IN ULONG Offset,
|
---|
19855 | IN ULONG Length
|
---|
19856 | );
|
---|
19857 |
|
---|
19858 | typedef enum _DEVICE_INSTALL_STATE {
|
---|
19859 | InstallStateInstalled,
|
---|
19860 | InstallStateNeedsReinstall,
|
---|
19861 | InstallStateFailedInstall,
|
---|
19862 | InstallStateFinishInstall
|
---|
19863 | } DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE;
|
---|
19864 |
|
---|
19865 | //
|
---|
19866 | // Define structure returned in response to IRP_MN_QUERY_BUS_INFORMATION by a
|
---|
19867 | // PDO indicating the type of bus the device exists on.
|
---|
19868 | //
|
---|
19869 |
|
---|
19870 | typedef struct _PNP_BUS_INFORMATION {
|
---|
19871 | GUID BusTypeGuid;
|
---|
19872 | INTERFACE_TYPE LegacyBusType;
|
---|
19873 | ULONG BusNumber;
|
---|
19874 | } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
|
---|
19875 |
|
---|
19876 | //
|
---|
19877 | // Define structure returned in response to IRP_MN_QUERY_LEGACY_BUS_INFORMATION
|
---|
19878 | // by an FDO indicating the type of bus it is. This is normally the same bus
|
---|
19879 | // type as the device's children (i.e., as retrieved from the child PDO's via
|
---|
19880 | // IRP_MN_QUERY_BUS_INFORMATION) except for cases like CardBus, which can
|
---|
19881 | // support both 16-bit (PCMCIABus) and 32-bit (PCIBus) cards.
|
---|
19882 | //
|
---|
19883 |
|
---|
19884 | typedef struct _LEGACY_BUS_INFORMATION {
|
---|
19885 | GUID BusTypeGuid;
|
---|
19886 | INTERFACE_TYPE LegacyBusType;
|
---|
19887 | ULONG BusNumber;
|
---|
19888 | } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
|
---|
19889 |
|
---|
19890 | //
|
---|
19891 | // Defines for IoGetDeviceProperty(DevicePropertyRemovalPolicy).
|
---|
19892 | //
|
---|
19893 | typedef enum _DEVICE_REMOVAL_POLICY {
|
---|
19894 |
|
---|
19895 | RemovalPolicyExpectNoRemoval = 1,
|
---|
19896 | RemovalPolicyExpectOrderlyRemoval = 2,
|
---|
19897 | RemovalPolicyExpectSurpriseRemoval = 3
|
---|
19898 |
|
---|
19899 | } DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY;
|
---|
19900 |
|
---|
19901 |
|
---|
19902 |
|
---|
19903 | typedef struct _BUS_INTERFACE_STANDARD {
|
---|
19904 | //
|
---|
19905 | // generic interface header
|
---|
19906 | //
|
---|
19907 | USHORT Size;
|
---|
19908 | USHORT Version;
|
---|
19909 | PVOID Context;
|
---|
19910 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
19911 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
19912 | //
|
---|
19913 | // standard bus interfaces
|
---|
19914 | //
|
---|
19915 | PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
|
---|
19916 | PGET_DMA_ADAPTER GetDmaAdapter;
|
---|
19917 | PGET_SET_DEVICE_DATA SetBusData;
|
---|
19918 | PGET_SET_DEVICE_DATA GetBusData;
|
---|
19919 |
|
---|
19920 | } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
|
---|
19921 |
|
---|
19922 |
|
---|
19923 | typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD {
|
---|
19924 | //
|
---|
19925 | // generic interface header
|
---|
19926 | //
|
---|
19927 | USHORT Size;
|
---|
19928 | USHORT Version;
|
---|
19929 | PVOID Context;
|
---|
19930 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
19931 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
19932 |
|
---|
19933 | //
|
---|
19934 | // config munging routines
|
---|
19935 | //
|
---|
19936 | PGET_SET_DEVICE_DATA SetBusData;
|
---|
19937 | PGET_SET_DEVICE_DATA GetBusData;
|
---|
19938 | UCHAR CapabilityID; // 2 (AGPv2 host) or new 0xE (AGPv3 bridge)
|
---|
19939 |
|
---|
19940 | } AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD;
|
---|
19941 |
|
---|
19942 |
|
---|
19943 | //
|
---|
19944 | // The following definitions are used in ACPI QueryInterface
|
---|
19945 | //
|
---|
19946 | typedef BOOLEAN (* PGPE_SERVICE_ROUTINE) (
|
---|
19947 | PVOID,
|
---|
19948 | PVOID);
|
---|
19949 |
|
---|
19950 | typedef NTSTATUS (* PGPE_CONNECT_VECTOR) (
|
---|
19951 | PDEVICE_OBJECT,
|
---|
19952 | ULONG,
|
---|
19953 | KINTERRUPT_MODE,
|
---|
19954 | BOOLEAN,
|
---|
19955 | PGPE_SERVICE_ROUTINE,
|
---|
19956 | PVOID,
|
---|
19957 | PVOID);
|
---|
19958 |
|
---|
19959 | typedef NTSTATUS (* PGPE_DISCONNECT_VECTOR) (
|
---|
19960 | PVOID);
|
---|
19961 |
|
---|
19962 | typedef NTSTATUS (* PGPE_ENABLE_EVENT) (
|
---|
19963 | PDEVICE_OBJECT,
|
---|
19964 | PVOID);
|
---|
19965 |
|
---|
19966 | typedef NTSTATUS (* PGPE_DISABLE_EVENT) (
|
---|
19967 | PDEVICE_OBJECT,
|
---|
19968 | PVOID);
|
---|
19969 |
|
---|
19970 | typedef NTSTATUS (* PGPE_CLEAR_STATUS) (
|
---|
19971 | PDEVICE_OBJECT,
|
---|
19972 | PVOID);
|
---|
19973 |
|
---|
19974 | typedef VOID (* PDEVICE_NOTIFY_CALLBACK) (
|
---|
19975 | PVOID,
|
---|
19976 | ULONG);
|
---|
19977 |
|
---|
19978 | typedef NTSTATUS (* PREGISTER_FOR_DEVICE_NOTIFICATIONS) (
|
---|
19979 | PDEVICE_OBJECT,
|
---|
19980 | PDEVICE_NOTIFY_CALLBACK,
|
---|
19981 | PVOID);
|
---|
19982 |
|
---|
19983 | typedef void (* PUNREGISTER_FOR_DEVICE_NOTIFICATIONS) (
|
---|
19984 | PDEVICE_OBJECT,
|
---|
19985 | PDEVICE_NOTIFY_CALLBACK);
|
---|
19986 |
|
---|
19987 | typedef struct _ACPI_INTERFACE_STANDARD {
|
---|
19988 | //
|
---|
19989 | // Generic interface header
|
---|
19990 | //
|
---|
19991 | USHORT Size;
|
---|
19992 | USHORT Version;
|
---|
19993 | PVOID Context;
|
---|
19994 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
19995 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
19996 | //
|
---|
19997 | // ACPI interfaces
|
---|
19998 | //
|
---|
19999 | PGPE_CONNECT_VECTOR GpeConnectVector;
|
---|
20000 | PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
|
---|
20001 | PGPE_ENABLE_EVENT GpeEnableEvent;
|
---|
20002 | PGPE_DISABLE_EVENT GpeDisableEvent;
|
---|
20003 | PGPE_CLEAR_STATUS GpeClearStatus;
|
---|
20004 | PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
|
---|
20005 | PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
|
---|
20006 |
|
---|
20007 | } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
|
---|
20008 |
|
---|
20009 |
|
---|
20010 | NTKERNELAPI
|
---|
20011 | NTSTATUS
|
---|
20012 | IoReportDetectedDevice(
|
---|
20013 | IN PDRIVER_OBJECT DriverObject,
|
---|
20014 | IN INTERFACE_TYPE LegacyBusType,
|
---|
20015 | IN ULONG BusNumber,
|
---|
20016 | IN ULONG SlotNumber,
|
---|
20017 | IN PCM_RESOURCE_LIST ResourceList,
|
---|
20018 | IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
|
---|
20019 | IN BOOLEAN ResourceAssigned,
|
---|
20020 | IN OUT PDEVICE_OBJECT *DeviceObject
|
---|
20021 | );
|
---|
20022 |
|
---|
20023 |
|
---|
20024 |
|
---|
20025 | NTKERNELAPI
|
---|
20026 | VOID
|
---|
20027 | IoInvalidateDeviceRelations(
|
---|
20028 | IN PDEVICE_OBJECT DeviceObject,
|
---|
20029 | IN DEVICE_RELATION_TYPE Type
|
---|
20030 | );
|
---|
20031 |
|
---|
20032 | NTKERNELAPI
|
---|
20033 | VOID
|
---|
20034 | IoRequestDeviceEject(
|
---|
20035 | IN PDEVICE_OBJECT PhysicalDeviceObject
|
---|
20036 | );
|
---|
20037 |
|
---|
20038 | NTKERNELAPI
|
---|
20039 | NTSTATUS
|
---|
20040 | IoGetDeviceProperty(
|
---|
20041 | IN PDEVICE_OBJECT DeviceObject,
|
---|
20042 | IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
|
---|
20043 | IN ULONG BufferLength,
|
---|
20044 | OUT PVOID PropertyBuffer,
|
---|
20045 | OUT PULONG ResultLength
|
---|
20046 | );
|
---|
20047 |
|
---|
20048 | //
|
---|
20049 | // The following definitions are used in IoOpenDeviceRegistryKey
|
---|
20050 | //
|
---|
20051 |
|
---|
20052 | #define PLUGPLAY_REGKEY_DEVICE 1
|
---|
20053 | #define PLUGPLAY_REGKEY_DRIVER 2
|
---|
20054 | #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
|
---|
20055 |
|
---|
20056 | NTKERNELAPI
|
---|
20057 | NTSTATUS
|
---|
20058 | IoOpenDeviceRegistryKey(
|
---|
20059 | IN PDEVICE_OBJECT DeviceObject,
|
---|
20060 | IN ULONG DevInstKeyType,
|
---|
20061 | IN ACCESS_MASK DesiredAccess,
|
---|
20062 | OUT PHANDLE DevInstRegKey
|
---|
20063 | );
|
---|
20064 |
|
---|
20065 | NTKERNELAPI
|
---|
20066 | NTSTATUS
|
---|
20067 | NTAPI
|
---|
20068 | IoRegisterDeviceInterface(
|
---|
20069 | IN PDEVICE_OBJECT PhysicalDeviceObject,
|
---|
20070 | IN CONST GUID *InterfaceClassGuid,
|
---|
20071 | IN PUNICODE_STRING ReferenceString, OPTIONAL
|
---|
20072 | OUT PUNICODE_STRING SymbolicLinkName
|
---|
20073 | );
|
---|
20074 |
|
---|
20075 | NTKERNELAPI
|
---|
20076 | NTSTATUS
|
---|
20077 | IoOpenDeviceInterfaceRegistryKey(
|
---|
20078 | IN PUNICODE_STRING SymbolicLinkName,
|
---|
20079 | IN ACCESS_MASK DesiredAccess,
|
---|
20080 | OUT PHANDLE DeviceInterfaceKey
|
---|
20081 | );
|
---|
20082 |
|
---|
20083 | NTKERNELAPI
|
---|
20084 | NTSTATUS
|
---|
20085 | IoSetDeviceInterfaceState(
|
---|
20086 | IN PUNICODE_STRING SymbolicLinkName,
|
---|
20087 | IN BOOLEAN Enable
|
---|
20088 | );
|
---|
20089 |
|
---|
20090 | NTKERNELAPI
|
---|
20091 | NTSTATUS
|
---|
20092 | NTAPI
|
---|
20093 | IoGetDeviceInterfaces(
|
---|
20094 | IN CONST GUID *InterfaceClassGuid,
|
---|
20095 | IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
|
---|
20096 | IN ULONG Flags,
|
---|
20097 | OUT PWSTR *SymbolicLinkList
|
---|
20098 | );
|
---|
20099 |
|
---|
20100 | #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
|
---|
20101 |
|
---|
20102 | NTKERNELAPI
|
---|
20103 | NTSTATUS
|
---|
20104 | NTAPI
|
---|
20105 | IoGetDeviceInterfaceAlias(
|
---|
20106 | IN PUNICODE_STRING SymbolicLinkName,
|
---|
20107 | IN CONST GUID *AliasInterfaceClassGuid,
|
---|
20108 | OUT PUNICODE_STRING AliasSymbolicLinkName
|
---|
20109 | );
|
---|
20110 |
|
---|
20111 | //
|
---|
20112 | // Define PnP notification event categories
|
---|
20113 | //
|
---|
20114 |
|
---|
20115 | typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
|
---|
20116 | EventCategoryReserved,
|
---|
20117 | EventCategoryHardwareProfileChange,
|
---|
20118 | EventCategoryDeviceInterfaceChange,
|
---|
20119 | EventCategoryTargetDeviceChange
|
---|
20120 | } IO_NOTIFICATION_EVENT_CATEGORY;
|
---|
20121 |
|
---|
20122 | //
|
---|
20123 | // Define flags that modify the behavior of IoRegisterPlugPlayNotification
|
---|
20124 | // for the various event categories...
|
---|
20125 | //
|
---|
20126 |
|
---|
20127 | #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
|
---|
20128 |
|
---|
20129 | typedef
|
---|
20130 | NTSTATUS
|
---|
20131 | (*PDRIVER_NOTIFICATION_CALLBACK_ROUTINE) (
|
---|
20132 | IN PVOID NotificationStructure,
|
---|
20133 | IN PVOID Context
|
---|
20134 | );
|
---|
20135 |
|
---|
20136 |
|
---|
20137 | NTKERNELAPI
|
---|
20138 | NTSTATUS
|
---|
20139 | IoRegisterPlugPlayNotification(
|
---|
20140 | IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
|
---|
20141 | IN ULONG EventCategoryFlags,
|
---|
20142 | IN PVOID EventCategoryData OPTIONAL,
|
---|
20143 | IN PDRIVER_OBJECT DriverObject,
|
---|
20144 | IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
|
---|
20145 | IN PVOID Context,
|
---|
20146 | OUT PVOID *NotificationEntry
|
---|
20147 | );
|
---|
20148 |
|
---|
20149 | NTKERNELAPI
|
---|
20150 | NTSTATUS
|
---|
20151 | IoUnregisterPlugPlayNotification(
|
---|
20152 | IN PVOID NotificationEntry
|
---|
20153 | );
|
---|
20154 |
|
---|
20155 | NTKERNELAPI
|
---|
20156 | NTSTATUS
|
---|
20157 | IoReportTargetDeviceChange(
|
---|
20158 | IN PDEVICE_OBJECT PhysicalDeviceObject,
|
---|
20159 | IN PVOID NotificationStructure // always begins with a PLUGPLAY_NOTIFICATION_HEADER
|
---|
20160 | );
|
---|
20161 |
|
---|
20162 | typedef
|
---|
20163 | VOID
|
---|
20164 | (*PDEVICE_CHANGE_COMPLETE_CALLBACK)(
|
---|
20165 | IN PVOID Context
|
---|
20166 | );
|
---|
20167 |
|
---|
20168 | NTKERNELAPI
|
---|
20169 | VOID
|
---|
20170 | IoInvalidateDeviceState(
|
---|
20171 | IN PDEVICE_OBJECT PhysicalDeviceObject
|
---|
20172 | );
|
---|
20173 |
|
---|
20174 | #define IoAdjustPagingPathCount(_count_,_paging_) { \
|
---|
20175 | if (_paging_) { \
|
---|
20176 | InterlockedIncrement(_count_); \
|
---|
20177 | } else { \
|
---|
20178 | InterlockedDecrement(_count_); \
|
---|
20179 | } \
|
---|
20180 | }
|
---|
20181 |
|
---|
20182 | NTKERNELAPI
|
---|
20183 | NTSTATUS
|
---|
20184 | IoReportTargetDeviceChangeAsynchronous(
|
---|
20185 | IN PDEVICE_OBJECT PhysicalDeviceObject,
|
---|
20186 | IN PVOID NotificationStructure, // always begins with a PLUGPLAY_NOTIFICATION_HEADER
|
---|
20187 | IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback, OPTIONAL
|
---|
20188 | IN PVOID Context OPTIONAL
|
---|
20189 | );
|
---|
20190 |
|
---|
20191 | //
|
---|
20192 | // Device location interface declarations
|
---|
20193 | //
|
---|
20194 | typedef
|
---|
20195 | NTSTATUS
|
---|
20196 | (*PGET_LOCATION_STRING) (
|
---|
20197 | IN PVOID Context,
|
---|
20198 | OUT PWCHAR *LocationStrings
|
---|
20199 | );
|
---|
20200 |
|
---|
20201 | typedef struct _PNP_LOCATION_INTERFACE {
|
---|
20202 | //
|
---|
20203 | // generic interface header
|
---|
20204 | //
|
---|
20205 | USHORT Size;
|
---|
20206 | USHORT Version;
|
---|
20207 | PVOID Context;
|
---|
20208 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
20209 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
20210 |
|
---|
20211 | //
|
---|
20212 | // interface specific entry
|
---|
20213 | //
|
---|
20214 | PGET_LOCATION_STRING GetLocationString;
|
---|
20215 |
|
---|
20216 | } PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE;
|
---|
20217 |
|
---|
20218 | //
|
---|
20219 | // Resource arbiter declarations
|
---|
20220 | //
|
---|
20221 |
|
---|
20222 | typedef enum _ARBITER_ACTION {
|
---|
20223 | ArbiterActionTestAllocation,
|
---|
20224 | ArbiterActionRetestAllocation,
|
---|
20225 | ArbiterActionCommitAllocation,
|
---|
20226 | ArbiterActionRollbackAllocation,
|
---|
20227 | ArbiterActionQueryAllocatedResources,
|
---|
20228 | ArbiterActionWriteReservedResources,
|
---|
20229 | ArbiterActionQueryConflict,
|
---|
20230 | ArbiterActionQueryArbitrate,
|
---|
20231 | ArbiterActionAddReserved,
|
---|
20232 | ArbiterActionBootAllocation
|
---|
20233 | } ARBITER_ACTION, *PARBITER_ACTION;
|
---|
20234 |
|
---|
20235 | typedef struct _ARBITER_CONFLICT_INFO {
|
---|
20236 | //
|
---|
20237 | // The device object owning the device that is causing the conflict
|
---|
20238 | //
|
---|
20239 | PDEVICE_OBJECT OwningObject;
|
---|
20240 |
|
---|
20241 | //
|
---|
20242 | // The start of the conflicting range
|
---|
20243 | //
|
---|
20244 | ULONGLONG Start;
|
---|
20245 |
|
---|
20246 | //
|
---|
20247 | // The end of the conflicting range
|
---|
20248 | //
|
---|
20249 | ULONGLONG End;
|
---|
20250 |
|
---|
20251 | } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
|
---|
20252 |
|
---|
20253 | //
|
---|
20254 | // The parameters for those actions
|
---|
20255 | //
|
---|
20256 |
|
---|
20257 | typedef struct _ARBITER_PARAMETERS {
|
---|
20258 |
|
---|
20259 | union {
|
---|
20260 |
|
---|
20261 | struct {
|
---|
20262 |
|
---|
20263 | //
|
---|
20264 | // Doubly linked list of ARBITER_LIST_ENTRY's
|
---|
20265 | //
|
---|
20266 | IN OUT PLIST_ENTRY ArbitrationList;
|
---|
20267 |
|
---|
20268 | //
|
---|
20269 | // The size of the AllocateFrom array
|
---|
20270 | //
|
---|
20271 | IN ULONG AllocateFromCount;
|
---|
20272 |
|
---|
20273 | //
|
---|
20274 | // Array of resource descriptors describing the resources available
|
---|
20275 | // to the arbiter for it to arbitrate
|
---|
20276 | //
|
---|
20277 | IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
|
---|
20278 |
|
---|
20279 | } TestAllocation;
|
---|
20280 |
|
---|
20281 | struct {
|
---|
20282 |
|
---|
20283 | //
|
---|
20284 | // Doubly linked list of ARBITER_LIST_ENTRY's
|
---|
20285 | //
|
---|
20286 | IN OUT PLIST_ENTRY ArbitrationList;
|
---|
20287 |
|
---|
20288 | //
|
---|
20289 | // The size of the AllocateFrom array
|
---|
20290 | //
|
---|
20291 | IN ULONG AllocateFromCount;
|
---|
20292 |
|
---|
20293 | //
|
---|
20294 | // Array of resource descriptors describing the resources available
|
---|
20295 | // to the arbiter for it to arbitrate
|
---|
20296 | //
|
---|
20297 | IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
|
---|
20298 |
|
---|
20299 | } RetestAllocation;
|
---|
20300 |
|
---|
20301 | struct {
|
---|
20302 |
|
---|
20303 | //
|
---|
20304 | // Doubly linked list of ARBITER_LIST_ENTRY's
|
---|
20305 | //
|
---|
20306 | IN OUT PLIST_ENTRY ArbitrationList;
|
---|
20307 |
|
---|
20308 | } BootAllocation;
|
---|
20309 |
|
---|
20310 | struct {
|
---|
20311 |
|
---|
20312 | //
|
---|
20313 | // The resources that are currently allocated
|
---|
20314 | //
|
---|
20315 | OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
|
---|
20316 |
|
---|
20317 | } QueryAllocatedResources;
|
---|
20318 |
|
---|
20319 | struct {
|
---|
20320 |
|
---|
20321 | //
|
---|
20322 | // This is the device we are trying to find a conflict for
|
---|
20323 | //
|
---|
20324 | IN PDEVICE_OBJECT PhysicalDeviceObject;
|
---|
20325 |
|
---|
20326 | //
|
---|
20327 | // This is the resource to find the conflict for
|
---|
20328 | //
|
---|
20329 | IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
|
---|
20330 |
|
---|
20331 | //
|
---|
20332 | // Number of devices conflicting on the resource
|
---|
20333 | //
|
---|
20334 | OUT PULONG ConflictCount;
|
---|
20335 |
|
---|
20336 | //
|
---|
20337 | // Pointer to array describing the conflicting device objects and ranges
|
---|
20338 | //
|
---|
20339 | OUT PARBITER_CONFLICT_INFO *Conflicts;
|
---|
20340 |
|
---|
20341 | } QueryConflict;
|
---|
20342 |
|
---|
20343 | struct {
|
---|
20344 |
|
---|
20345 | //
|
---|
20346 | // Doubly linked list of ARBITER_LIST_ENTRY's - should have
|
---|
20347 | // only one entry
|
---|
20348 | //
|
---|
20349 | IN PLIST_ENTRY ArbitrationList;
|
---|
20350 |
|
---|
20351 | } QueryArbitrate;
|
---|
20352 |
|
---|
20353 | struct {
|
---|
20354 |
|
---|
20355 | //
|
---|
20356 | // Indicates the device whose resources are to be marked as reserved
|
---|
20357 | //
|
---|
20358 | PDEVICE_OBJECT ReserveDevice;
|
---|
20359 |
|
---|
20360 | } AddReserved;
|
---|
20361 |
|
---|
20362 | } Parameters;
|
---|
20363 |
|
---|
20364 | } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
|
---|
20365 |
|
---|
20366 |
|
---|
20367 |
|
---|
20368 | typedef enum _ARBITER_REQUEST_SOURCE {
|
---|
20369 |
|
---|
20370 | ArbiterRequestUndefined = -1,
|
---|
20371 | ArbiterRequestLegacyReported, // IoReportResourceUsage
|
---|
20372 | ArbiterRequestHalReported, // IoReportHalResourceUsage
|
---|
20373 | ArbiterRequestLegacyAssigned, // IoAssignResources
|
---|
20374 | ArbiterRequestPnpDetected, // IoReportResourceForDetection
|
---|
20375 | ArbiterRequestPnpEnumerated // IRP_MN_QUERY_RESOURCE_REQUIREMENTS
|
---|
20376 |
|
---|
20377 | } ARBITER_REQUEST_SOURCE;
|
---|
20378 |
|
---|
20379 |
|
---|
20380 | typedef enum _ARBITER_RESULT {
|
---|
20381 |
|
---|
20382 | ArbiterResultUndefined = -1,
|
---|
20383 | ArbiterResultSuccess,
|
---|
20384 | ArbiterResultExternalConflict, // This indicates that the request can never be solved for devices in this list
|
---|
20385 | ArbiterResultNullRequest // The request was for length zero and thus no translation should be attempted
|
---|
20386 |
|
---|
20387 | } ARBITER_RESULT;
|
---|
20388 |
|
---|
20389 | //
|
---|
20390 | // ARBITER_FLAG_BOOT_CONFIG - this indicates that the request is for the
|
---|
20391 | // resources assigned by the firmware/BIOS. It should be succeeded even if
|
---|
20392 | // it conflicts with another devices boot config.
|
---|
20393 | //
|
---|
20394 |
|
---|
20395 | #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
|
---|
20396 |
|
---|
20397 |
|
---|
20398 |
|
---|
20399 | NTKERNELAPI
|
---|
20400 | NTSTATUS
|
---|
20401 | IoReportResourceForDetection(
|
---|
20402 | IN PDRIVER_OBJECT DriverObject,
|
---|
20403 | IN PCM_RESOURCE_LIST DriverList OPTIONAL,
|
---|
20404 | IN ULONG DriverListSize OPTIONAL,
|
---|
20405 | IN PDEVICE_OBJECT DeviceObject OPTIONAL,
|
---|
20406 | IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
|
---|
20407 | IN ULONG DeviceListSize OPTIONAL,
|
---|
20408 | OUT PBOOLEAN ConflictDetected
|
---|
20409 | );
|
---|
20410 |
|
---|
20411 |
|
---|
20412 |
|
---|
20413 | typedef struct _ARBITER_LIST_ENTRY {
|
---|
20414 |
|
---|
20415 | //
|
---|
20416 | // This is a doubly linked list of entries for easy sorting
|
---|
20417 | //
|
---|
20418 | LIST_ENTRY ListEntry;
|
---|
20419 |
|
---|
20420 | //
|
---|
20421 | // The number of alternative allocation
|
---|
20422 | //
|
---|
20423 | ULONG AlternativeCount;
|
---|
20424 |
|
---|
20425 | //
|
---|
20426 | // Pointer to an array of resource descriptors for the possible allocations
|
---|
20427 | //
|
---|
20428 | PIO_RESOURCE_DESCRIPTOR Alternatives;
|
---|
20429 |
|
---|
20430 | //
|
---|
20431 | // The device object of the device requesting these resources.
|
---|
20432 | //
|
---|
20433 | PDEVICE_OBJECT PhysicalDeviceObject;
|
---|
20434 |
|
---|
20435 | //
|
---|
20436 | // Indicates where the request came from
|
---|
20437 | //
|
---|
20438 | ARBITER_REQUEST_SOURCE RequestSource;
|
---|
20439 |
|
---|
20440 | //
|
---|
20441 | // Flags these indicate a variety of things (use ARBITER_FLAG_*)
|
---|
20442 | //
|
---|
20443 | ULONG Flags;
|
---|
20444 |
|
---|
20445 | //
|
---|
20446 | // Space to aid the arbiter in processing the list it is initialized to 0 when
|
---|
20447 | // the entry is created. The system will not attempt to interpret it.
|
---|
20448 | //
|
---|
20449 | LONG_PTR WorkSpace;
|
---|
20450 |
|
---|
20451 | //
|
---|
20452 | // Interface Type, Slot Number and Bus Number from Resource Requirements list,
|
---|
20453 | // used only for reverse identification.
|
---|
20454 | //
|
---|
20455 | INTERFACE_TYPE InterfaceType;
|
---|
20456 | ULONG SlotNumber;
|
---|
20457 | ULONG BusNumber;
|
---|
20458 |
|
---|
20459 | //
|
---|
20460 | // A pointer to a descriptor to indicate the resource that was allocated.
|
---|
20461 | // This is allocated by the system and filled in by the arbiter in response to an
|
---|
20462 | // ArbiterActionTestAllocation.
|
---|
20463 | //
|
---|
20464 | PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
|
---|
20465 |
|
---|
20466 | //
|
---|
20467 | // Pointer to the alternative that was chosen from to provide the assignment.
|
---|
20468 | // This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
|
---|
20469 | //
|
---|
20470 | PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
|
---|
20471 |
|
---|
20472 | //
|
---|
20473 | // The result of the operation
|
---|
20474 | // This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
|
---|
20475 | //
|
---|
20476 | ARBITER_RESULT Result;
|
---|
20477 |
|
---|
20478 | } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
|
---|
20479 |
|
---|
20480 | //
|
---|
20481 | // The arbiter's entry point
|
---|
20482 | //
|
---|
20483 |
|
---|
20484 | typedef
|
---|
20485 | NTSTATUS
|
---|
20486 | (*PARBITER_HANDLER) (
|
---|
20487 | IN PVOID Context,
|
---|
20488 | IN ARBITER_ACTION Action,
|
---|
20489 | IN OUT PARBITER_PARAMETERS Parameters
|
---|
20490 | );
|
---|
20491 |
|
---|
20492 | //
|
---|
20493 | // Arbiter interface
|
---|
20494 | //
|
---|
20495 |
|
---|
20496 | #define ARBITER_PARTIAL 0x00000001
|
---|
20497 |
|
---|
20498 |
|
---|
20499 | typedef struct _ARBITER_INTERFACE {
|
---|
20500 |
|
---|
20501 | //
|
---|
20502 | // Generic interface header
|
---|
20503 | //
|
---|
20504 | USHORT Size;
|
---|
20505 | USHORT Version;
|
---|
20506 | PVOID Context;
|
---|
20507 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
20508 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
20509 |
|
---|
20510 | //
|
---|
20511 | // Entry point to the arbiter
|
---|
20512 | //
|
---|
20513 | PARBITER_HANDLER ArbiterHandler;
|
---|
20514 |
|
---|
20515 | //
|
---|
20516 | // Other information about the arbiter, use ARBITER_* flags
|
---|
20517 | //
|
---|
20518 | ULONG Flags;
|
---|
20519 |
|
---|
20520 | } ARBITER_INTERFACE, *PARBITER_INTERFACE;
|
---|
20521 |
|
---|
20522 | //
|
---|
20523 | // The directions translation can take place in
|
---|
20524 | //
|
---|
20525 |
|
---|
20526 | typedef enum _RESOURCE_TRANSLATION_DIRECTION { // ntosp
|
---|
20527 | TranslateChildToParent, // ntosp
|
---|
20528 | TranslateParentToChild // ntosp
|
---|
20529 | } RESOURCE_TRANSLATION_DIRECTION; // ntosp
|
---|
20530 |
|
---|
20531 | //
|
---|
20532 | // Translation functions
|
---|
20533 | //
|
---|
20534 |
|
---|
20535 |
|
---|
20536 | typedef
|
---|
20537 | NTSTATUS
|
---|
20538 | (*PTRANSLATE_RESOURCE_HANDLER)(
|
---|
20539 | IN PVOID Context,
|
---|
20540 | IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
|
---|
20541 | IN RESOURCE_TRANSLATION_DIRECTION Direction,
|
---|
20542 | IN ULONG AlternativesCount, OPTIONAL
|
---|
20543 | IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
|
---|
20544 | IN PDEVICE_OBJECT PhysicalDeviceObject,
|
---|
20545 | OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
|
---|
20546 | );
|
---|
20547 |
|
---|
20548 | typedef
|
---|
20549 | NTSTATUS
|
---|
20550 | (*PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
|
---|
20551 | IN PVOID Context,
|
---|
20552 | IN PIO_RESOURCE_DESCRIPTOR Source,
|
---|
20553 | IN PDEVICE_OBJECT PhysicalDeviceObject,
|
---|
20554 | OUT PULONG TargetCount,
|
---|
20555 | OUT PIO_RESOURCE_DESCRIPTOR *Target
|
---|
20556 | );
|
---|
20557 |
|
---|
20558 | //
|
---|
20559 | // Translator Interface
|
---|
20560 | //
|
---|
20561 |
|
---|
20562 | typedef struct _TRANSLATOR_INTERFACE {
|
---|
20563 | USHORT Size;
|
---|
20564 | USHORT Version;
|
---|
20565 | PVOID Context;
|
---|
20566 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
20567 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
20568 | PTRANSLATE_RESOURCE_HANDLER TranslateResources;
|
---|
20569 | PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
|
---|
20570 | } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
|
---|
20571 |
|
---|
20572 |
|
---|
20573 | //
|
---|
20574 | // Header structure for all Plug&Play notification events...
|
---|
20575 | //
|
---|
20576 |
|
---|
20577 | typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
|
---|
20578 | USHORT Version; // presently at version 1.
|
---|
20579 | USHORT Size; // size (in bytes) of header + event-specific data.
|
---|
20580 | GUID Event;
|
---|
20581 | //
|
---|
20582 | // Event-specific stuff starts here.
|
---|
20583 | //
|
---|
20584 | } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
|
---|
20585 |
|
---|
20586 | //
|
---|
20587 | // Notification structure for all EventCategoryHardwareProfileChange events...
|
---|
20588 | //
|
---|
20589 |
|
---|
20590 | typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
|
---|
20591 | USHORT Version;
|
---|
20592 | USHORT Size;
|
---|
20593 | GUID Event;
|
---|
20594 | //
|
---|
20595 | // (No event-specific data)
|
---|
20596 | //
|
---|
20597 | } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
|
---|
20598 |
|
---|
20599 |
|
---|
20600 | //
|
---|
20601 | // Notification structure for all EventCategoryDeviceInterfaceChange events...
|
---|
20602 | //
|
---|
20603 |
|
---|
20604 | typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
|
---|
20605 | USHORT Version;
|
---|
20606 | USHORT Size;
|
---|
20607 | GUID Event;
|
---|
20608 | //
|
---|
20609 | // Event-specific data
|
---|
20610 | //
|
---|
20611 | GUID InterfaceClassGuid;
|
---|
20612 | PUNICODE_STRING SymbolicLinkName;
|
---|
20613 | } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
|
---|
20614 |
|
---|
20615 |
|
---|
20616 | //
|
---|
20617 | // Notification structures for EventCategoryTargetDeviceChange...
|
---|
20618 | //
|
---|
20619 |
|
---|
20620 | //
|
---|
20621 | // The following structure is used for TargetDeviceQueryRemove,
|
---|
20622 | // TargetDeviceRemoveCancelled, and TargetDeviceRemoveComplete:
|
---|
20623 | //
|
---|
20624 | typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
|
---|
20625 | USHORT Version;
|
---|
20626 | USHORT Size;
|
---|
20627 | GUID Event;
|
---|
20628 | //
|
---|
20629 | // Event-specific data
|
---|
20630 | //
|
---|
20631 | PFILE_OBJECT FileObject;
|
---|
20632 | } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
|
---|
20633 |
|
---|
20634 | //
|
---|
20635 | // The following structure header is used for all other (i.e., 3rd-party)
|
---|
20636 | // target device change events. The structure accommodates both a
|
---|
20637 | // variable-length binary data buffer, and a variable-length unicode text
|
---|
20638 | // buffer. The header must indicate where the text buffer begins, so that
|
---|
20639 | // the data can be delivered in the appropriate format (ANSI or Unicode)
|
---|
20640 | // to user-mode recipients (i.e., that have registered for handle-based
|
---|
20641 | // notification via RegisterDeviceNotification).
|
---|
20642 | //
|
---|
20643 |
|
---|
20644 | typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
|
---|
20645 | USHORT Version;
|
---|
20646 | USHORT Size;
|
---|
20647 | GUID Event;
|
---|
20648 | //
|
---|
20649 | // Event-specific data
|
---|
20650 | //
|
---|
20651 | PFILE_OBJECT FileObject; // This field must be set to NULL by callers of
|
---|
20652 | // IoReportTargetDeviceChange. Clients that
|
---|
20653 | // have registered for target device change
|
---|
20654 | // notification on the affected PDO will be
|
---|
20655 | // called with this field set to the file object
|
---|
20656 | // they specified during registration.
|
---|
20657 | //
|
---|
20658 | LONG NameBufferOffset; // offset (in bytes) from beginning of
|
---|
20659 | // CustomDataBuffer where text begins (-1 if none)
|
---|
20660 | //
|
---|
20661 | UCHAR CustomDataBuffer[1]; // variable-length buffer, containing (optionally)
|
---|
20662 | // a binary data at the start of the buffer,
|
---|
20663 | // followed by an optional unicode text buffer
|
---|
20664 | // (word-aligned).
|
---|
20665 | //
|
---|
20666 | } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
|
---|
20667 |
|
---|
20668 | //
|
---|
20669 | // Define the device description structure.
|
---|
20670 | //
|
---|
20671 |
|
---|
20672 | typedef struct _DEVICE_DESCRIPTION {
|
---|
20673 | ULONG Version;
|
---|
20674 | BOOLEAN Master;
|
---|
20675 | BOOLEAN ScatterGather;
|
---|
20676 | BOOLEAN DemandMode;
|
---|
20677 | BOOLEAN AutoInitialize;
|
---|
20678 | BOOLEAN Dma32BitAddresses;
|
---|
20679 | BOOLEAN IgnoreCount;
|
---|
20680 | BOOLEAN Reserved1; // must be false
|
---|
20681 | BOOLEAN Dma64BitAddresses;
|
---|
20682 | ULONG BusNumber; // unused for WDM
|
---|
20683 | ULONG DmaChannel;
|
---|
20684 | INTERFACE_TYPE InterfaceType;
|
---|
20685 | DMA_WIDTH DmaWidth;
|
---|
20686 | DMA_SPEED DmaSpeed;
|
---|
20687 | ULONG MaximumLength;
|
---|
20688 | ULONG DmaPort;
|
---|
20689 | } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
|
---|
20690 |
|
---|
20691 | //
|
---|
20692 | // Define the supported version numbers for the device description structure.
|
---|
20693 | //
|
---|
20694 |
|
---|
20695 | #define DEVICE_DESCRIPTION_VERSION 0
|
---|
20696 | #define DEVICE_DESCRIPTION_VERSION1 1
|
---|
20697 | #define DEVICE_DESCRIPTION_VERSION2 2
|
---|
20698 |
|
---|
20699 | //
|
---|
20700 | // The following function prototypes are for HAL routines with a prefix of Hal.
|
---|
20701 | //
|
---|
20702 | // General functions.
|
---|
20703 | //
|
---|
20704 |
|
---|
20705 | typedef
|
---|
20706 | BOOLEAN
|
---|
20707 | (*PHAL_RESET_DISPLAY_PARAMETERS) (
|
---|
20708 | IN ULONG Columns,
|
---|
20709 | IN ULONG Rows
|
---|
20710 | );
|
---|
20711 |
|
---|
20712 | DECLSPEC_DEPRECATED_DDK
|
---|
20713 | NTHALAPI
|
---|
20714 | VOID
|
---|
20715 | HalAcquireDisplayOwnership (
|
---|
20716 | IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
|
---|
20717 | );
|
---|
20718 |
|
---|
20719 | #if defined(_IA64_)
|
---|
20720 |
|
---|
20721 | DECLSPEC_DEPRECATED_DDK // Use GetDmaRequirement
|
---|
20722 | NTHALAPI
|
---|
20723 | ULONG
|
---|
20724 | HalGetDmaAlignmentRequirement (
|
---|
20725 | VOID
|
---|
20726 | );
|
---|
20727 |
|
---|
20728 | #endif
|
---|
20729 |
|
---|
20730 | #if defined(_M_IX86) || defined(_M_AMD64)
|
---|
20731 |
|
---|
20732 | #define HalGetDmaAlignmentRequirement() 1L
|
---|
20733 | #endif
|
---|
20734 |
|
---|
20735 | NTHALAPI
|
---|
20736 | VOID
|
---|
20737 | KeFlushWriteBuffer (
|
---|
20738 | VOID
|
---|
20739 | );
|
---|
20740 |
|
---|
20741 | //
|
---|
20742 | // I/O driver configuration functions.
|
---|
20743 | //
|
---|
20744 | #if !defined(NO_LEGACY_DRIVERS)
|
---|
20745 | DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReportDetectedDevice
|
---|
20746 | NTHALAPI
|
---|
20747 | NTSTATUS
|
---|
20748 | HalAssignSlotResources (
|
---|
20749 | IN PUNICODE_STRING RegistryPath,
|
---|
20750 | IN PUNICODE_STRING DriverClassName OPTIONAL,
|
---|
20751 | IN PDRIVER_OBJECT DriverObject,
|
---|
20752 | IN PDEVICE_OBJECT DeviceObject,
|
---|
20753 | IN INTERFACE_TYPE BusType,
|
---|
20754 | IN ULONG BusNumber,
|
---|
20755 | IN ULONG SlotNumber,
|
---|
20756 | IN OUT PCM_RESOURCE_LIST *AllocatedResources
|
---|
20757 | );
|
---|
20758 |
|
---|
20759 | DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReportDetectedDevice
|
---|
20760 | NTHALAPI
|
---|
20761 | ULONG
|
---|
20762 | HalGetInterruptVector(
|
---|
20763 | IN INTERFACE_TYPE InterfaceType,
|
---|
20764 | IN ULONG BusNumber,
|
---|
20765 | IN ULONG BusInterruptLevel,
|
---|
20766 | IN ULONG BusInterruptVector,
|
---|
20767 | OUT PKIRQL Irql,
|
---|
20768 | OUT PKAFFINITY Affinity
|
---|
20769 | );
|
---|
20770 |
|
---|
20771 | DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
|
---|
20772 | NTHALAPI
|
---|
20773 | ULONG
|
---|
20774 | HalSetBusData(
|
---|
20775 | IN BUS_DATA_TYPE BusDataType,
|
---|
20776 | IN ULONG BusNumber,
|
---|
20777 | IN ULONG SlotNumber,
|
---|
20778 | IN PVOID Buffer,
|
---|
20779 | IN ULONG Length
|
---|
20780 | );
|
---|
20781 | #endif // NO_LEGACY_DRIVERS
|
---|
20782 |
|
---|
20783 | DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
|
---|
20784 | NTHALAPI
|
---|
20785 | ULONG
|
---|
20786 | HalSetBusDataByOffset(
|
---|
20787 | IN BUS_DATA_TYPE BusDataType,
|
---|
20788 | IN ULONG BusNumber,
|
---|
20789 | IN ULONG SlotNumber,
|
---|
20790 | IN PVOID Buffer,
|
---|
20791 | IN ULONG Offset,
|
---|
20792 | IN ULONG Length
|
---|
20793 | );
|
---|
20794 |
|
---|
20795 | DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
|
---|
20796 | NTHALAPI
|
---|
20797 | BOOLEAN
|
---|
20798 | HalTranslateBusAddress(
|
---|
20799 | IN INTERFACE_TYPE InterfaceType,
|
---|
20800 | IN ULONG BusNumber,
|
---|
20801 | IN PHYSICAL_ADDRESS BusAddress,
|
---|
20802 | IN OUT PULONG AddressSpace,
|
---|
20803 | OUT PPHYSICAL_ADDRESS TranslatedAddress
|
---|
20804 | );
|
---|
20805 |
|
---|
20806 | //
|
---|
20807 | // Values for AddressSpace parameter of HalTranslateBusAddress
|
---|
20808 | //
|
---|
20809 | // 0x0 - Memory space
|
---|
20810 | // 0x1 - Port space
|
---|
20811 | // 0x2 - 0x1F - Address spaces specific for Alpha
|
---|
20812 | // 0x2 - UserMode view of memory space
|
---|
20813 | // 0x3 - UserMode view of port space
|
---|
20814 | // 0x4 - Dense memory space
|
---|
20815 | // 0x5 - reserved
|
---|
20816 | // 0x6 - UserMode view of dense memory space
|
---|
20817 | // 0x7 - 0x1F - reserved
|
---|
20818 | //
|
---|
20819 |
|
---|
20820 | NTHALAPI
|
---|
20821 | PVOID
|
---|
20822 | HalAllocateCrashDumpRegisters(
|
---|
20823 | IN PADAPTER_OBJECT AdapterObject,
|
---|
20824 | IN OUT PULONG NumberOfMapRegisters
|
---|
20825 | );
|
---|
20826 |
|
---|
20827 | #if !defined(NO_LEGACY_DRIVERS)
|
---|
20828 | DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
|
---|
20829 | NTHALAPI
|
---|
20830 | ULONG
|
---|
20831 | HalGetBusData(
|
---|
20832 | IN BUS_DATA_TYPE BusDataType,
|
---|
20833 | IN ULONG BusNumber,
|
---|
20834 | IN ULONG SlotNumber,
|
---|
20835 | IN PVOID Buffer,
|
---|
20836 | IN ULONG Length
|
---|
20837 | );
|
---|
20838 | #endif // NO_LEGACY_DRIVERS
|
---|
20839 |
|
---|
20840 | DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
|
---|
20841 | NTHALAPI
|
---|
20842 | ULONG
|
---|
20843 | HalGetBusDataByOffset(
|
---|
20844 | IN BUS_DATA_TYPE BusDataType,
|
---|
20845 | IN ULONG BusNumber,
|
---|
20846 | IN ULONG SlotNumber,
|
---|
20847 | IN PVOID Buffer,
|
---|
20848 | IN ULONG Offset,
|
---|
20849 | IN ULONG Length
|
---|
20850 | );
|
---|
20851 |
|
---|
20852 | DECLSPEC_DEPRECATED_DDK // Use IoGetDmaAdapter
|
---|
20853 | NTHALAPI
|
---|
20854 | PADAPTER_OBJECT
|
---|
20855 | HalGetAdapter(
|
---|
20856 | IN PDEVICE_DESCRIPTION DeviceDescription,
|
---|
20857 | IN OUT PULONG NumberOfMapRegisters
|
---|
20858 | );
|
---|
20859 |
|
---|
20860 | //
|
---|
20861 | // System beep functions.
|
---|
20862 | //
|
---|
20863 | #if !defined(NO_LEGACY_DRIVERS)
|
---|
20864 | DECLSPEC_DEPRECATED_DDK
|
---|
20865 | NTHALAPI
|
---|
20866 | BOOLEAN
|
---|
20867 | HalMakeBeep(
|
---|
20868 | IN ULONG Frequency
|
---|
20869 | );
|
---|
20870 | #endif // NO_LEGACY_DRIVERS
|
---|
20871 |
|
---|
20872 | //
|
---|
20873 | // The following function prototypes are for HAL routines with a prefix of Io.
|
---|
20874 | //
|
---|
20875 | // DMA adapter object functions.
|
---|
20876 | //
|
---|
20877 |
|
---|
20878 | //
|
---|
20879 | // Performance counter function.
|
---|
20880 | //
|
---|
20881 |
|
---|
20882 | NTHALAPI
|
---|
20883 | LARGE_INTEGER
|
---|
20884 | KeQueryPerformanceCounter (
|
---|
20885 | OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL
|
---|
20886 | );
|
---|
20887 |
|
---|
20888 |
|
---|
20889 | //
|
---|
20890 | // Stall processor execution function.
|
---|
20891 | //
|
---|
20892 |
|
---|
20893 | NTHALAPI
|
---|
20894 | VOID
|
---|
20895 | KeStallExecutionProcessor (
|
---|
20896 | IN ULONG MicroSeconds
|
---|
20897 | );
|
---|
20898 |
|
---|
20899 |
|
---|
20900 | typedef
|
---|
20901 | VOID
|
---|
20902 | (*PDEVICE_CONTROL_COMPLETION)(
|
---|
20903 | IN struct _DEVICE_CONTROL_CONTEXT *ControlContext
|
---|
20904 | );
|
---|
20905 |
|
---|
20906 | typedef struct _DEVICE_CONTROL_CONTEXT {
|
---|
20907 | NTSTATUS Status;
|
---|
20908 | PDEVICE_HANDLER_OBJECT DeviceHandler;
|
---|
20909 | PDEVICE_OBJECT DeviceObject;
|
---|
20910 | ULONG ControlCode;
|
---|
20911 | PVOID Buffer;
|
---|
20912 | PULONG BufferLength;
|
---|
20913 | PVOID Context;
|
---|
20914 | } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
|
---|
20915 |
|
---|
20916 | typedef
|
---|
20917 | PBUS_HANDLER
|
---|
20918 | (FASTCALL *pHalHandlerForBus) (
|
---|
20919 | IN INTERFACE_TYPE InterfaceType,
|
---|
20920 | IN ULONG BusNumber
|
---|
20921 | );
|
---|
20922 | typedef
|
---|
20923 | VOID
|
---|
20924 | (FASTCALL *pHalReferenceBusHandler) (
|
---|
20925 | IN PBUS_HANDLER BusHandler
|
---|
20926 | );
|
---|
20927 |
|
---|
20928 | //*****************************************************************************
|
---|
20929 | // HAL Function dispatch
|
---|
20930 | //
|
---|
20931 |
|
---|
20932 | typedef enum _HAL_QUERY_INFORMATION_CLASS {
|
---|
20933 | HalInstalledBusInformation,
|
---|
20934 | HalProfileSourceInformation,
|
---|
20935 | HalInformationClassUnused1,
|
---|
20936 | HalPowerInformation,
|
---|
20937 | HalProcessorSpeedInformation,
|
---|
20938 | HalCallbackInformation,
|
---|
20939 | HalMapRegisterInformation,
|
---|
20940 | HalMcaLogInformation, // Machine Check Abort Information
|
---|
20941 | HalFrameBufferCachingInformation,
|
---|
20942 | HalDisplayBiosInformation,
|
---|
20943 | HalProcessorFeatureInformation,
|
---|
20944 | HalNumaTopologyInterface,
|
---|
20945 | HalErrorInformation, // General MCA, CMC, CPE Error Information.
|
---|
20946 | HalCmcLogInformation, // Processor Corrected Machine Check Information
|
---|
20947 | HalCpeLogInformation, // Corrected Platform Error Information
|
---|
20948 | HalQueryMcaInterface,
|
---|
20949 | HalQueryAMLIIllegalIOPortAddresses,
|
---|
20950 | HalQueryMaxHotPlugMemoryAddress,
|
---|
20951 | HalPartitionIpiInterface,
|
---|
20952 | HalPlatformInformation,
|
---|
20953 | HalQueryProfileSourceList
|
---|
20954 | // information levels >= 0x8000000 reserved for OEM use
|
---|
20955 | } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
|
---|
20956 |
|
---|
20957 |
|
---|
20958 | typedef enum _HAL_SET_INFORMATION_CLASS {
|
---|
20959 | HalProfileSourceInterval,
|
---|
20960 | HalProfileSourceInterruptHandler,
|
---|
20961 | HalMcaRegisterDriver, // Registering Machine Check Abort driver
|
---|
20962 | HalKernelErrorHandler,
|
---|
20963 | HalCmcRegisterDriver, // Registering Processor Corrected Machine Check driver
|
---|
20964 | HalCpeRegisterDriver, // Registering Corrected Platform Error driver
|
---|
20965 | HalMcaLog,
|
---|
20966 | HalCmcLog,
|
---|
20967 | HalCpeLog,
|
---|
20968 | HalGenerateCmcInterrupt // Used to test CMC
|
---|
20969 | } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
|
---|
20970 |
|
---|
20971 |
|
---|
20972 | typedef
|
---|
20973 | NTSTATUS
|
---|
20974 | (*pHalQuerySystemInformation)(
|
---|
20975 | IN HAL_QUERY_INFORMATION_CLASS InformationClass,
|
---|
20976 | IN ULONG BufferSize,
|
---|
20977 | IN OUT PVOID Buffer,
|
---|
20978 | OUT PULONG ReturnedLength
|
---|
20979 | );
|
---|
20980 |
|
---|
20981 |
|
---|
20982 | typedef
|
---|
20983 | NTSTATUS
|
---|
20984 | (*pHalSetSystemInformation)(
|
---|
20985 | IN HAL_SET_INFORMATION_CLASS InformationClass,
|
---|
20986 | IN ULONG BufferSize,
|
---|
20987 | IN PVOID Buffer
|
---|
20988 | );
|
---|
20989 |
|
---|
20990 |
|
---|
20991 | typedef
|
---|
20992 | VOID
|
---|
20993 | (FASTCALL *pHalExamineMBR)(
|
---|
20994 | IN PDEVICE_OBJECT DeviceObject,
|
---|
20995 | IN ULONG SectorSize,
|
---|
20996 | IN ULONG MBRTypeIdentifier,
|
---|
20997 | OUT PVOID *Buffer
|
---|
20998 | );
|
---|
20999 |
|
---|
21000 | typedef
|
---|
21001 | VOID
|
---|
21002 | (FASTCALL *pHalIoAssignDriveLetters)(
|
---|
21003 | IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
|
---|
21004 | IN PSTRING NtDeviceName,
|
---|
21005 | OUT PUCHAR NtSystemPath,
|
---|
21006 | OUT PSTRING NtSystemPathString
|
---|
21007 | );
|
---|
21008 |
|
---|
21009 | typedef
|
---|
21010 | NTSTATUS
|
---|
21011 | (FASTCALL *pHalIoReadPartitionTable)(
|
---|
21012 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21013 | IN ULONG SectorSize,
|
---|
21014 | IN BOOLEAN ReturnRecognizedPartitions,
|
---|
21015 | OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer
|
---|
21016 | );
|
---|
21017 |
|
---|
21018 | typedef
|
---|
21019 | NTSTATUS
|
---|
21020 | (FASTCALL *pHalIoSetPartitionInformation)(
|
---|
21021 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21022 | IN ULONG SectorSize,
|
---|
21023 | IN ULONG PartitionNumber,
|
---|
21024 | IN ULONG PartitionType
|
---|
21025 | );
|
---|
21026 |
|
---|
21027 | typedef
|
---|
21028 | NTSTATUS
|
---|
21029 | (FASTCALL *pHalIoWritePartitionTable)(
|
---|
21030 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21031 | IN ULONG SectorSize,
|
---|
21032 | IN ULONG SectorsPerTrack,
|
---|
21033 | IN ULONG NumberOfHeads,
|
---|
21034 | IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer
|
---|
21035 | );
|
---|
21036 |
|
---|
21037 | typedef
|
---|
21038 | NTSTATUS
|
---|
21039 | (*pHalQueryBusSlots)(
|
---|
21040 | IN PBUS_HANDLER BusHandler,
|
---|
21041 | IN ULONG BufferSize,
|
---|
21042 | OUT PULONG SlotNumbers,
|
---|
21043 | OUT PULONG ReturnedLength
|
---|
21044 | );
|
---|
21045 |
|
---|
21046 | typedef
|
---|
21047 | NTSTATUS
|
---|
21048 | (*pHalInitPnpDriver)(
|
---|
21049 | VOID
|
---|
21050 | );
|
---|
21051 |
|
---|
21052 |
|
---|
21053 | typedef struct _PM_DISPATCH_TABLE {
|
---|
21054 | ULONG Signature;
|
---|
21055 | ULONG Version;
|
---|
21056 | PVOID Function[1];
|
---|
21057 | } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
|
---|
21058 |
|
---|
21059 | typedef
|
---|
21060 | NTSTATUS
|
---|
21061 | (*pHalInitPowerManagement)(
|
---|
21062 | IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
|
---|
21063 | OUT PPM_DISPATCH_TABLE *PmHalDispatchTable
|
---|
21064 | );
|
---|
21065 |
|
---|
21066 |
|
---|
21067 | typedef
|
---|
21068 | struct _DMA_ADAPTER *
|
---|
21069 | (*pHalGetDmaAdapter)(
|
---|
21070 | IN PVOID Context,
|
---|
21071 | IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
|
---|
21072 | OUT PULONG NumberOfMapRegisters
|
---|
21073 | );
|
---|
21074 |
|
---|
21075 |
|
---|
21076 | typedef
|
---|
21077 | NTSTATUS
|
---|
21078 | (*pHalGetInterruptTranslator)(
|
---|
21079 | IN INTERFACE_TYPE ParentInterfaceType,
|
---|
21080 | IN ULONG ParentBusNumber,
|
---|
21081 | IN INTERFACE_TYPE BridgeInterfaceType,
|
---|
21082 | IN USHORT Size,
|
---|
21083 | IN USHORT Version,
|
---|
21084 | OUT PTRANSLATOR_INTERFACE Translator,
|
---|
21085 | OUT PULONG BridgeBusNumber
|
---|
21086 | );
|
---|
21087 |
|
---|
21088 |
|
---|
21089 | typedef
|
---|
21090 | BOOLEAN
|
---|
21091 | (*pHalTranslateBusAddress)(
|
---|
21092 | IN INTERFACE_TYPE InterfaceType,
|
---|
21093 | IN ULONG BusNumber,
|
---|
21094 | IN PHYSICAL_ADDRESS BusAddress,
|
---|
21095 | IN OUT PULONG AddressSpace,
|
---|
21096 | OUT PPHYSICAL_ADDRESS TranslatedAddress
|
---|
21097 | );
|
---|
21098 |
|
---|
21099 | typedef
|
---|
21100 | NTSTATUS
|
---|
21101 | (*pHalAssignSlotResources) (
|
---|
21102 | IN PUNICODE_STRING RegistryPath,
|
---|
21103 | IN PUNICODE_STRING DriverClassName OPTIONAL,
|
---|
21104 | IN PDRIVER_OBJECT DriverObject,
|
---|
21105 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21106 | IN INTERFACE_TYPE BusType,
|
---|
21107 | IN ULONG BusNumber,
|
---|
21108 | IN ULONG SlotNumber,
|
---|
21109 | IN OUT PCM_RESOURCE_LIST *AllocatedResources
|
---|
21110 | );
|
---|
21111 |
|
---|
21112 | typedef
|
---|
21113 | VOID
|
---|
21114 | (*pHalHaltSystem) (
|
---|
21115 | VOID
|
---|
21116 | );
|
---|
21117 |
|
---|
21118 | typedef
|
---|
21119 | BOOLEAN
|
---|
21120 | (*pHalResetDisplay) (
|
---|
21121 | VOID
|
---|
21122 | );
|
---|
21123 |
|
---|
21124 |
|
---|
21125 | typedef struct _MAP_REGISTER_ENTRY {
|
---|
21126 | PVOID MapRegister;
|
---|
21127 | BOOLEAN WriteToDevice;
|
---|
21128 | } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
|
---|
21129 |
|
---|
21130 |
|
---|
21131 |
|
---|
21132 | typedef
|
---|
21133 | UCHAR
|
---|
21134 | (*pHalVectorToIDTEntry) (
|
---|
21135 | ULONG Vector
|
---|
21136 | );
|
---|
21137 |
|
---|
21138 | typedef
|
---|
21139 | BOOLEAN
|
---|
21140 | (*pHalFindBusAddressTranslation) (
|
---|
21141 | IN PHYSICAL_ADDRESS BusAddress,
|
---|
21142 | IN OUT PULONG AddressSpace,
|
---|
21143 | OUT PPHYSICAL_ADDRESS TranslatedAddress,
|
---|
21144 | IN OUT PULONG_PTR Context,
|
---|
21145 | IN BOOLEAN NextBus
|
---|
21146 | );
|
---|
21147 |
|
---|
21148 | typedef
|
---|
21149 | NTSTATUS
|
---|
21150 | (*pHalStartMirroring)(
|
---|
21151 | VOID
|
---|
21152 | );
|
---|
21153 |
|
---|
21154 | typedef
|
---|
21155 | NTSTATUS
|
---|
21156 | (*pHalEndMirroring)(
|
---|
21157 | IN ULONG PassNumber
|
---|
21158 | );
|
---|
21159 |
|
---|
21160 | typedef
|
---|
21161 | NTSTATUS
|
---|
21162 | (*pHalMirrorPhysicalMemory)(
|
---|
21163 | IN PHYSICAL_ADDRESS PhysicalAddress,
|
---|
21164 | IN LARGE_INTEGER NumberOfBytes
|
---|
21165 | );
|
---|
21166 |
|
---|
21167 | typedef
|
---|
21168 | NTSTATUS
|
---|
21169 | (*pHalMirrorVerify)(
|
---|
21170 | IN PHYSICAL_ADDRESS PhysicalAddress,
|
---|
21171 | IN LARGE_INTEGER NumberOfBytes
|
---|
21172 | );
|
---|
21173 |
|
---|
21174 | typedef struct {
|
---|
21175 | UCHAR Type; //CmResourceType
|
---|
21176 | BOOLEAN Valid;
|
---|
21177 | UCHAR Reserved[2];
|
---|
21178 | PUCHAR TranslatedAddress;
|
---|
21179 | ULONG Length;
|
---|
21180 | } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
|
---|
21181 |
|
---|
21182 | typedef struct {
|
---|
21183 | PHYSICAL_ADDRESS Start;
|
---|
21184 | PHYSICAL_ADDRESS MaxEnd;
|
---|
21185 | PVOID VirtualAddress;
|
---|
21186 | ULONG Length;
|
---|
21187 | BOOLEAN Cached;
|
---|
21188 | BOOLEAN Aligned;
|
---|
21189 | } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
|
---|
21190 |
|
---|
21191 | typedef struct {
|
---|
21192 | ULONG Bus;
|
---|
21193 | ULONG Slot;
|
---|
21194 | USHORT VendorID;
|
---|
21195 | USHORT DeviceID;
|
---|
21196 | UCHAR BaseClass;
|
---|
21197 | UCHAR SubClass;
|
---|
21198 | UCHAR ProgIf;
|
---|
21199 | BOOLEAN Initialized;
|
---|
21200 | DEBUG_DEVICE_ADDRESS BaseAddress[6];
|
---|
21201 | DEBUG_MEMORY_REQUIREMENTS Memory;
|
---|
21202 | } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
|
---|
21203 |
|
---|
21204 | typedef
|
---|
21205 | NTSTATUS
|
---|
21206 | (*pKdSetupPciDeviceForDebugging)(
|
---|
21207 | IN PVOID LoaderBlock, OPTIONAL
|
---|
21208 | IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
|
---|
21209 | );
|
---|
21210 |
|
---|
21211 | typedef
|
---|
21212 | NTSTATUS
|
---|
21213 | (*pKdReleasePciDeviceForDebugging)(
|
---|
21214 | IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
|
---|
21215 | );
|
---|
21216 |
|
---|
21217 | typedef
|
---|
21218 | PVOID
|
---|
21219 | (*pKdGetAcpiTablePhase0)(
|
---|
21220 | IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
|
---|
21221 | IN ULONG Signature
|
---|
21222 | );
|
---|
21223 |
|
---|
21224 | typedef
|
---|
21225 | VOID
|
---|
21226 | (*pKdCheckPowerButton)(
|
---|
21227 | VOID
|
---|
21228 | );
|
---|
21229 |
|
---|
21230 | typedef
|
---|
21231 | VOID
|
---|
21232 | (*pHalEndOfBoot)(
|
---|
21233 | VOID
|
---|
21234 | );
|
---|
21235 |
|
---|
21236 | typedef
|
---|
21237 | PVOID
|
---|
21238 | (*pKdMapPhysicalMemory64)(
|
---|
21239 | IN PHYSICAL_ADDRESS PhysicalAddress,
|
---|
21240 | IN ULONG NumberPages
|
---|
21241 | );
|
---|
21242 |
|
---|
21243 | typedef
|
---|
21244 | VOID
|
---|
21245 | (*pKdUnmapVirtualAddress)(
|
---|
21246 | IN PVOID VirtualAddress,
|
---|
21247 | IN ULONG NumberPages
|
---|
21248 | );
|
---|
21249 |
|
---|
21250 |
|
---|
21251 | typedef struct {
|
---|
21252 | ULONG Version;
|
---|
21253 | pHalQuerySystemInformation HalQuerySystemInformation;
|
---|
21254 | pHalSetSystemInformation HalSetSystemInformation;
|
---|
21255 | pHalQueryBusSlots HalQueryBusSlots;
|
---|
21256 | ULONG Spare1;
|
---|
21257 | pHalExamineMBR HalExamineMBR;
|
---|
21258 | pHalIoAssignDriveLetters HalIoAssignDriveLetters;
|
---|
21259 | pHalIoReadPartitionTable HalIoReadPartitionTable;
|
---|
21260 | pHalIoSetPartitionInformation HalIoSetPartitionInformation;
|
---|
21261 | pHalIoWritePartitionTable HalIoWritePartitionTable;
|
---|
21262 |
|
---|
21263 | pHalHandlerForBus HalReferenceHandlerForBus;
|
---|
21264 | pHalReferenceBusHandler HalReferenceBusHandler;
|
---|
21265 | pHalReferenceBusHandler HalDereferenceBusHandler;
|
---|
21266 |
|
---|
21267 | pHalInitPnpDriver HalInitPnpDriver;
|
---|
21268 | pHalInitPowerManagement HalInitPowerManagement;
|
---|
21269 |
|
---|
21270 | pHalGetDmaAdapter HalGetDmaAdapter;
|
---|
21271 | pHalGetInterruptTranslator HalGetInterruptTranslator;
|
---|
21272 |
|
---|
21273 | pHalStartMirroring HalStartMirroring;
|
---|
21274 | pHalEndMirroring HalEndMirroring;
|
---|
21275 | pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
|
---|
21276 | pHalEndOfBoot HalEndOfBoot;
|
---|
21277 | pHalMirrorVerify HalMirrorVerify;
|
---|
21278 |
|
---|
21279 | } HAL_DISPATCH, *PHAL_DISPATCH;
|
---|
21280 |
|
---|
21281 | #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)
|
---|
21282 |
|
---|
21283 | extern PHAL_DISPATCH HalDispatchTable;
|
---|
21284 | #define HALDISPATCH HalDispatchTable
|
---|
21285 |
|
---|
21286 | #else
|
---|
21287 |
|
---|
21288 | extern HAL_DISPATCH HalDispatchTable;
|
---|
21289 | #define HALDISPATCH (&HalDispatchTable)
|
---|
21290 |
|
---|
21291 | #endif
|
---|
21292 |
|
---|
21293 | #define HAL_DISPATCH_VERSION 3
|
---|
21294 |
|
---|
21295 | #define HalDispatchTableVersion HALDISPATCH->Version
|
---|
21296 | #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
|
---|
21297 | #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
|
---|
21298 | #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
|
---|
21299 |
|
---|
21300 | #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
|
---|
21301 | #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
|
---|
21302 | #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
|
---|
21303 |
|
---|
21304 | #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
|
---|
21305 | #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
|
---|
21306 |
|
---|
21307 | #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
|
---|
21308 | #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
|
---|
21309 |
|
---|
21310 | #define HalStartMirroring HALDISPATCH->HalStartMirroring
|
---|
21311 | #define HalEndMirroring HALDISPATCH->HalEndMirroring
|
---|
21312 | #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
|
---|
21313 | #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
|
---|
21314 | #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
|
---|
21315 |
|
---|
21316 |
|
---|
21317 | //
|
---|
21318 | // HAL System Information Structures.
|
---|
21319 | //
|
---|
21320 |
|
---|
21321 | // for the information class "HalInstalledBusInformation"
|
---|
21322 | typedef struct _HAL_BUS_INFORMATION{
|
---|
21323 | INTERFACE_TYPE BusType;
|
---|
21324 | BUS_DATA_TYPE ConfigurationType;
|
---|
21325 | ULONG BusNumber;
|
---|
21326 | ULONG Reserved;
|
---|
21327 | } HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION;
|
---|
21328 |
|
---|
21329 | // for the information class "HalProfileSourceInformation"
|
---|
21330 | typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
|
---|
21331 | KPROFILE_SOURCE Source;
|
---|
21332 | BOOLEAN Supported;
|
---|
21333 | ULONG Interval;
|
---|
21334 | } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
|
---|
21335 |
|
---|
21336 | // for the information class "HalProfileSourceInformation"
|
---|
21337 | typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX {
|
---|
21338 | KPROFILE_SOURCE Source;
|
---|
21339 | BOOLEAN Supported;
|
---|
21340 | ULONG_PTR Interval;
|
---|
21341 | ULONG_PTR DefInterval;
|
---|
21342 | ULONG_PTR MaxInterval;
|
---|
21343 | ULONG_PTR MinInterval;
|
---|
21344 | } HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX;
|
---|
21345 |
|
---|
21346 | // for the information class "HalProfileSourceInterval"
|
---|
21347 | typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
|
---|
21348 | KPROFILE_SOURCE Source;
|
---|
21349 | ULONG_PTR Interval;
|
---|
21350 | } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
|
---|
21351 |
|
---|
21352 | // for the information class "HalQueryProfileSourceList"
|
---|
21353 | typedef struct _HAL_PROFILE_SOURCE_LIST {
|
---|
21354 | KPROFILE_SOURCE Source;
|
---|
21355 | PWSTR Description;
|
---|
21356 | } HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST;
|
---|
21357 |
|
---|
21358 | // for the information class "HalDispayBiosInformation"
|
---|
21359 | typedef enum _HAL_DISPLAY_BIOS_INFORMATION {
|
---|
21360 | HalDisplayInt10Bios,
|
---|
21361 | HalDisplayEmulatedBios,
|
---|
21362 | HalDisplayNoBios
|
---|
21363 | } HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION;
|
---|
21364 |
|
---|
21365 | // for the information class "HalPowerInformation"
|
---|
21366 | typedef struct _HAL_POWER_INFORMATION {
|
---|
21367 | ULONG TBD;
|
---|
21368 | } HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION;
|
---|
21369 |
|
---|
21370 | // for the information class "HalProcessorSpeedInformation"
|
---|
21371 | typedef struct _HAL_PROCESSOR_SPEED_INFO {
|
---|
21372 | ULONG ProcessorSpeed;
|
---|
21373 | } HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION;
|
---|
21374 |
|
---|
21375 | // for the information class "HalCallbackInformation"
|
---|
21376 | typedef struct _HAL_CALLBACKS {
|
---|
21377 | PCALLBACK_OBJECT SetSystemInformation;
|
---|
21378 | PCALLBACK_OBJECT BusCheck;
|
---|
21379 | } HAL_CALLBACKS, *PHAL_CALLBACKS;
|
---|
21380 |
|
---|
21381 | // for the information class "HalProcessorFeatureInformation"
|
---|
21382 | typedef struct _HAL_PROCESSOR_FEATURE {
|
---|
21383 | ULONG UsableFeatureBits;
|
---|
21384 | } HAL_PROCESSOR_FEATURE;
|
---|
21385 |
|
---|
21386 | // for the information class "HalNumaTopologyInterface"
|
---|
21387 |
|
---|
21388 | typedef ULONG HALNUMAPAGETONODE;
|
---|
21389 |
|
---|
21390 | typedef
|
---|
21391 | HALNUMAPAGETONODE
|
---|
21392 | (*PHALNUMAPAGETONODE)(
|
---|
21393 | IN ULONG_PTR PhysicalPageNumber
|
---|
21394 | );
|
---|
21395 |
|
---|
21396 | typedef
|
---|
21397 | NTSTATUS
|
---|
21398 | (*PHALNUMAQUERYPROCESSORNODE)(
|
---|
21399 | IN ULONG ProcessorNumber,
|
---|
21400 | OUT PUSHORT Identifier,
|
---|
21401 | OUT PUCHAR Node
|
---|
21402 | );
|
---|
21403 |
|
---|
21404 | typedef struct _HAL_NUMA_TOPOLOGY_INTERFACE {
|
---|
21405 | ULONG NumberOfNodes;
|
---|
21406 | PHALNUMAQUERYPROCESSORNODE QueryProcessorNode;
|
---|
21407 | PHALNUMAPAGETONODE PageToNode;
|
---|
21408 | } HAL_NUMA_TOPOLOGY_INTERFACE;
|
---|
21409 |
|
---|
21410 | typedef
|
---|
21411 | NTSTATUS
|
---|
21412 | (*PHALIOREADWRITEHANDLER)(
|
---|
21413 | IN BOOLEAN fRead,
|
---|
21414 | IN ULONG dwAddr,
|
---|
21415 | IN ULONG dwSize,
|
---|
21416 | IN OUT PULONG pdwData
|
---|
21417 | );
|
---|
21418 |
|
---|
21419 | // for the information class "HalQueryIllegalIOPortAddresses"
|
---|
21420 | typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST
|
---|
21421 | {
|
---|
21422 | ULONG BadAddrBegin;
|
---|
21423 | ULONG BadAddrSize;
|
---|
21424 | ULONG OSVersionTrigger;
|
---|
21425 | PHALIOREADWRITEHANDLER IOHandler;
|
---|
21426 | } HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST;
|
---|
21427 |
|
---|
21428 |
|
---|
21429 |
|
---|
21430 | #if defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
|
---|
21431 |
|
---|
21432 | //
|
---|
21433 | // HalQueryMcaInterface
|
---|
21434 | //
|
---|
21435 |
|
---|
21436 | typedef
|
---|
21437 | VOID
|
---|
21438 | (*PHALMCAINTERFACELOCK)(
|
---|
21439 | VOID
|
---|
21440 | );
|
---|
21441 |
|
---|
21442 | typedef
|
---|
21443 | VOID
|
---|
21444 | (*PHALMCAINTERFACEUNLOCK)(
|
---|
21445 | VOID
|
---|
21446 | );
|
---|
21447 |
|
---|
21448 | typedef
|
---|
21449 | NTSTATUS
|
---|
21450 | (*PHALMCAINTERFACEREADREGISTER)(
|
---|
21451 | IN UCHAR BankNumber,
|
---|
21452 | IN OUT PVOID Exception
|
---|
21453 | );
|
---|
21454 |
|
---|
21455 | typedef struct _HAL_MCA_INTERFACE {
|
---|
21456 | PHALMCAINTERFACELOCK Lock;
|
---|
21457 | PHALMCAINTERFACEUNLOCK Unlock;
|
---|
21458 | PHALMCAINTERFACEREADREGISTER ReadRegister;
|
---|
21459 | } HAL_MCA_INTERFACE;
|
---|
21460 |
|
---|
21461 | #if defined(_AMD64_)
|
---|
21462 |
|
---|
21463 | struct _KTRAP_FRAME;
|
---|
21464 | struct _KEXCEPTION_FRAME;
|
---|
21465 |
|
---|
21466 | typedef
|
---|
21467 | ERROR_SEVERITY
|
---|
21468 | (*PDRIVER_EXCPTN_CALLBACK) (
|
---|
21469 | IN PVOID Context,
|
---|
21470 | IN struct _KTRAP_FRAME *TrapFrame,
|
---|
21471 | IN struct _KEXCEPTION_FRAME *ExceptionFrame,
|
---|
21472 | IN PMCA_EXCEPTION Exception
|
---|
21473 | );
|
---|
21474 |
|
---|
21475 | #endif
|
---|
21476 |
|
---|
21477 | #if defined(_X86_) || defined(_IA64_)
|
---|
21478 |
|
---|
21479 | typedef
|
---|
21480 | #if defined(_IA64_)
|
---|
21481 | ERROR_SEVERITY
|
---|
21482 | #else
|
---|
21483 | VOID
|
---|
21484 | #endif
|
---|
21485 | (*PDRIVER_EXCPTN_CALLBACK) (
|
---|
21486 | IN PVOID Context,
|
---|
21487 | IN PMCA_EXCEPTION BankLog
|
---|
21488 | );
|
---|
21489 |
|
---|
21490 | #endif
|
---|
21491 |
|
---|
21492 | typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK;
|
---|
21493 |
|
---|
21494 | //
|
---|
21495 | // Structure to record the callbacks from driver
|
---|
21496 | //
|
---|
21497 |
|
---|
21498 | typedef struct _MCA_DRIVER_INFO {
|
---|
21499 | PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback;
|
---|
21500 | PKDEFERRED_ROUTINE DpcCallback;
|
---|
21501 | PVOID DeviceContext;
|
---|
21502 | } MCA_DRIVER_INFO, *PMCA_DRIVER_INFO;
|
---|
21503 |
|
---|
21504 |
|
---|
21505 | typedef struct _HAL_ERROR_INFO {
|
---|
21506 | ULONG Version; // Version of this structure
|
---|
21507 | ULONG Reserved; //
|
---|
21508 | ULONG McaMaxSize; // Maximum size of a Machine Check Abort record
|
---|
21509 | ULONG McaPreviousEventsCount; // Flag indicating previous or early-boot MCA event logs.
|
---|
21510 | ULONG McaCorrectedEventsCount; // Number of corrected MCA events since boot. approx.
|
---|
21511 | ULONG McaKernelDeliveryFails; // Number of Kernel callback failures. approx.
|
---|
21512 | ULONG McaDriverDpcQueueFails; // Number of OEM MCA Driver Dpc queueing failures. approx.
|
---|
21513 | ULONG McaReserved;
|
---|
21514 | ULONG CmcMaxSize; // Maximum size of a Corrected Machine Check record
|
---|
21515 | ULONG CmcPollingInterval; // In units of seconds
|
---|
21516 | ULONG CmcInterruptsCount; // Number of CMC interrupts. approx.
|
---|
21517 | ULONG CmcKernelDeliveryFails; // Number of Kernel callback failures. approx.
|
---|
21518 | ULONG CmcDriverDpcQueueFails; // Number of OEM CMC Driver Dpc queueing failures. approx.
|
---|
21519 | ULONG CmcGetStateFails; // Number of failures in getting the log from FW.
|
---|
21520 | ULONG CmcClearStateFails; // Number of failures in clearing the log from FW.
|
---|
21521 | ULONG CmcReserved;
|
---|
21522 | ULONGLONG CmcLogId; // Last seen record identifier.
|
---|
21523 | ULONG CpeMaxSize; // Maximum size of a Corrected Platform Event record
|
---|
21524 | ULONG CpePollingInterval; // In units of seconds
|
---|
21525 | ULONG CpeInterruptsCount; // Number of CPE interrupts. approx.
|
---|
21526 | ULONG CpeKernelDeliveryFails; // Number of Kernel callback failures. approx.
|
---|
21527 | ULONG CpeDriverDpcQueueFails; // Number of OEM CPE Driver Dpc queueing failures. approx.
|
---|
21528 | ULONG CpeGetStateFails; // Number of failures in getting the log from FW.
|
---|
21529 | ULONG CpeClearStateFails; // Number of failures in clearing the log from FW.
|
---|
21530 | ULONG CpeInterruptSources; // Number of SAPIC Platform Interrupt Sources
|
---|
21531 | ULONGLONG CpeLogId; // Last seen record identifier.
|
---|
21532 | ULONGLONG KernelReserved[4];
|
---|
21533 | } HAL_ERROR_INFO, *PHAL_ERROR_INFO;
|
---|
21534 |
|
---|
21535 |
|
---|
21536 | #define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1)
|
---|
21537 | #define HAL_MCE_DISABLED ((ULONG)0)
|
---|
21538 |
|
---|
21539 | //
|
---|
21540 | // Known values for HAL_ERROR_INFO.CmcPollingInterval.
|
---|
21541 | //
|
---|
21542 |
|
---|
21543 | #define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED
|
---|
21544 | #define HAL_CMC_DISABLED HAL_MCE_DISABLED
|
---|
21545 |
|
---|
21546 | //
|
---|
21547 | // Known values for HAL_ERROR_INFO.CpePollingInterval.
|
---|
21548 | //
|
---|
21549 |
|
---|
21550 | #define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED
|
---|
21551 | #define HAL_CPE_DISABLED HAL_MCE_DISABLED
|
---|
21552 |
|
---|
21553 | #define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED
|
---|
21554 | #define HAL_MCA_DISABLED HAL_MCE_DISABLED
|
---|
21555 |
|
---|
21556 |
|
---|
21557 |
|
---|
21558 | //
|
---|
21559 | // Driver Callback type for the information class "HalCmcRegisterDriver"
|
---|
21560 | //
|
---|
21561 |
|
---|
21562 | typedef
|
---|
21563 | VOID
|
---|
21564 | (*PDRIVER_CMC_EXCEPTION_CALLBACK) (
|
---|
21565 | IN PVOID Context,
|
---|
21566 | IN PCMC_EXCEPTION CmcLog
|
---|
21567 | );
|
---|
21568 |
|
---|
21569 | //
|
---|
21570 | // Driver Callback type for the information class "HalCpeRegisterDriver"
|
---|
21571 | //
|
---|
21572 |
|
---|
21573 | typedef
|
---|
21574 | VOID
|
---|
21575 | (*PDRIVER_CPE_EXCEPTION_CALLBACK) (
|
---|
21576 | IN PVOID Context,
|
---|
21577 | IN PCPE_EXCEPTION CmcLog
|
---|
21578 | );
|
---|
21579 |
|
---|
21580 | //
|
---|
21581 | //
|
---|
21582 | // Structure to record the callbacks from driver
|
---|
21583 | //
|
---|
21584 |
|
---|
21585 | typedef struct _CMC_DRIVER_INFO {
|
---|
21586 | PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback;
|
---|
21587 | PKDEFERRED_ROUTINE DpcCallback;
|
---|
21588 | PVOID DeviceContext;
|
---|
21589 | } CMC_DRIVER_INFO, *PCMC_DRIVER_INFO;
|
---|
21590 |
|
---|
21591 | typedef struct _CPE_DRIVER_INFO {
|
---|
21592 | PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback;
|
---|
21593 | PKDEFERRED_ROUTINE DpcCallback;
|
---|
21594 | PVOID DeviceContext;
|
---|
21595 | } CPE_DRIVER_INFO, *PCPE_DRIVER_INFO;
|
---|
21596 |
|
---|
21597 | #endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
|
---|
21598 |
|
---|
21599 | #if defined(_IA64_)
|
---|
21600 |
|
---|
21601 | typedef
|
---|
21602 | NTSTATUS
|
---|
21603 | (*HALSENDCROSSPARTITIONIPI)(
|
---|
21604 | IN USHORT ProcessorID,
|
---|
21605 | IN UCHAR HardwareVector
|
---|
21606 | );
|
---|
21607 |
|
---|
21608 | typedef
|
---|
21609 | NTSTATUS
|
---|
21610 | (*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)(
|
---|
21611 | OUT PULONG Vector,
|
---|
21612 | OUT PKIRQL Irql,
|
---|
21613 | IN OUT PKAFFINITY Affinity,
|
---|
21614 | OUT PUCHAR HardwareVector
|
---|
21615 | );
|
---|
21616 |
|
---|
21617 | typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE {
|
---|
21618 | HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi;
|
---|
21619 | HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector;
|
---|
21620 | } HAL_CROSS_PARTITION_IPI_INTERFACE;
|
---|
21621 |
|
---|
21622 | #endif
|
---|
21623 |
|
---|
21624 | typedef struct _HAL_PLATFORM_INFORMATION {
|
---|
21625 | ULONG PlatformFlags;
|
---|
21626 | } HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION;
|
---|
21627 |
|
---|
21628 | //
|
---|
21629 | // These platform flags are carried over from the IPPT table
|
---|
21630 | // definition if appropriate.
|
---|
21631 | //
|
---|
21632 |
|
---|
21633 | #define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L
|
---|
21634 | #define HAL_PLATFORM_DISABLE_PTCG 0x04L
|
---|
21635 | #define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L
|
---|
21636 | #define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L
|
---|
21637 | #define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L
|
---|
21638 |
|
---|
21639 |
|
---|
21640 |
|
---|
21641 | typedef struct _SCATTER_GATHER_ELEMENT {
|
---|
21642 | PHYSICAL_ADDRESS Address;
|
---|
21643 | ULONG Length;
|
---|
21644 | ULONG_PTR Reserved;
|
---|
21645 | } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
|
---|
21646 |
|
---|
21647 | #if _MSC_VER >= 1200
|
---|
21648 | #pragma warning(push)
|
---|
21649 | #endif
|
---|
21650 | #pragma warning(disable:4200)
|
---|
21651 | typedef struct _SCATTER_GATHER_LIST {
|
---|
21652 | ULONG NumberOfElements;
|
---|
21653 | ULONG_PTR Reserved;
|
---|
21654 | SCATTER_GATHER_ELEMENT Elements[];
|
---|
21655 | } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
|
---|
21656 | #if _MSC_VER >= 1200
|
---|
21657 | #pragma warning(pop)
|
---|
21658 | #else
|
---|
21659 | #pragma warning(default:4200)
|
---|
21660 | #endif
|
---|
21661 |
|
---|
21662 |
|
---|
21663 |
|
---|
21664 | typedef struct _DMA_OPERATIONS *PDMA_OPERATIONS;
|
---|
21665 |
|
---|
21666 | typedef struct _DMA_ADAPTER {
|
---|
21667 | USHORT Version;
|
---|
21668 | USHORT Size;
|
---|
21669 | PDMA_OPERATIONS DmaOperations;
|
---|
21670 | // Private Bus Device Driver data follows,
|
---|
21671 | } DMA_ADAPTER, *PDMA_ADAPTER;
|
---|
21672 |
|
---|
21673 | typedef VOID (*PPUT_DMA_ADAPTER)(
|
---|
21674 | PDMA_ADAPTER DmaAdapter
|
---|
21675 | );
|
---|
21676 |
|
---|
21677 | typedef PVOID (*PALLOCATE_COMMON_BUFFER)(
|
---|
21678 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21679 | IN ULONG Length,
|
---|
21680 | OUT PPHYSICAL_ADDRESS LogicalAddress,
|
---|
21681 | IN BOOLEAN CacheEnabled
|
---|
21682 | );
|
---|
21683 |
|
---|
21684 | typedef VOID (*PFREE_COMMON_BUFFER)(
|
---|
21685 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21686 | IN ULONG Length,
|
---|
21687 | IN PHYSICAL_ADDRESS LogicalAddress,
|
---|
21688 | IN PVOID VirtualAddress,
|
---|
21689 | IN BOOLEAN CacheEnabled
|
---|
21690 | );
|
---|
21691 |
|
---|
21692 | typedef NTSTATUS (*PALLOCATE_ADAPTER_CHANNEL)(
|
---|
21693 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21694 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21695 | IN ULONG NumberOfMapRegisters,
|
---|
21696 | IN PDRIVER_CONTROL ExecutionRoutine,
|
---|
21697 | IN PVOID Context
|
---|
21698 | );
|
---|
21699 |
|
---|
21700 | typedef BOOLEAN (*PFLUSH_ADAPTER_BUFFERS)(
|
---|
21701 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21702 | IN PMDL Mdl,
|
---|
21703 | IN PVOID MapRegisterBase,
|
---|
21704 | IN PVOID CurrentVa,
|
---|
21705 | IN ULONG Length,
|
---|
21706 | IN BOOLEAN WriteToDevice
|
---|
21707 | );
|
---|
21708 |
|
---|
21709 | typedef VOID (*PFREE_ADAPTER_CHANNEL)(
|
---|
21710 | IN PDMA_ADAPTER DmaAdapter
|
---|
21711 | );
|
---|
21712 |
|
---|
21713 | typedef VOID (*PFREE_MAP_REGISTERS)(
|
---|
21714 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21715 | PVOID MapRegisterBase,
|
---|
21716 | ULONG NumberOfMapRegisters
|
---|
21717 | );
|
---|
21718 |
|
---|
21719 | typedef PHYSICAL_ADDRESS (*PMAP_TRANSFER)(
|
---|
21720 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21721 | IN PMDL Mdl,
|
---|
21722 | IN PVOID MapRegisterBase,
|
---|
21723 | IN PVOID CurrentVa,
|
---|
21724 | IN OUT PULONG Length,
|
---|
21725 | IN BOOLEAN WriteToDevice
|
---|
21726 | );
|
---|
21727 |
|
---|
21728 | typedef ULONG (*PGET_DMA_ALIGNMENT)(
|
---|
21729 | IN PDMA_ADAPTER DmaAdapter
|
---|
21730 | );
|
---|
21731 |
|
---|
21732 | typedef ULONG (*PREAD_DMA_COUNTER)(
|
---|
21733 | IN PDMA_ADAPTER DmaAdapter
|
---|
21734 | );
|
---|
21735 |
|
---|
21736 | typedef VOID
|
---|
21737 | (*PDRIVER_LIST_CONTROL)(
|
---|
21738 | IN struct _DEVICE_OBJECT *DeviceObject,
|
---|
21739 | IN struct _IRP *Irp,
|
---|
21740 | IN PSCATTER_GATHER_LIST ScatterGather,
|
---|
21741 | IN PVOID Context
|
---|
21742 | );
|
---|
21743 |
|
---|
21744 | typedef NTSTATUS
|
---|
21745 | (*PGET_SCATTER_GATHER_LIST)(
|
---|
21746 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21747 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21748 | IN PMDL Mdl,
|
---|
21749 | IN PVOID CurrentVa,
|
---|
21750 | IN ULONG Length,
|
---|
21751 | IN PDRIVER_LIST_CONTROL ExecutionRoutine,
|
---|
21752 | IN PVOID Context,
|
---|
21753 | IN BOOLEAN WriteToDevice
|
---|
21754 | );
|
---|
21755 |
|
---|
21756 | typedef VOID
|
---|
21757 | (*PPUT_SCATTER_GATHER_LIST)(
|
---|
21758 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21759 | IN PSCATTER_GATHER_LIST ScatterGather,
|
---|
21760 | IN BOOLEAN WriteToDevice
|
---|
21761 | );
|
---|
21762 |
|
---|
21763 | typedef NTSTATUS
|
---|
21764 | (*PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
|
---|
21765 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21766 | IN OPTIONAL PMDL Mdl,
|
---|
21767 | IN PVOID CurrentVa,
|
---|
21768 | IN ULONG Length,
|
---|
21769 | OUT PULONG ScatterGatherListSize,
|
---|
21770 | OUT OPTIONAL PULONG pNumberOfMapRegisters
|
---|
21771 | );
|
---|
21772 |
|
---|
21773 | typedef NTSTATUS
|
---|
21774 | (*PBUILD_SCATTER_GATHER_LIST)(
|
---|
21775 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21776 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21777 | IN PMDL Mdl,
|
---|
21778 | IN PVOID CurrentVa,
|
---|
21779 | IN ULONG Length,
|
---|
21780 | IN PDRIVER_LIST_CONTROL ExecutionRoutine,
|
---|
21781 | IN PVOID Context,
|
---|
21782 | IN BOOLEAN WriteToDevice,
|
---|
21783 | IN PVOID ScatterGatherBuffer,
|
---|
21784 | IN ULONG ScatterGatherLength
|
---|
21785 | );
|
---|
21786 |
|
---|
21787 | typedef NTSTATUS
|
---|
21788 | (*PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
|
---|
21789 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21790 | IN PSCATTER_GATHER_LIST ScatterGather,
|
---|
21791 | IN PMDL OriginalMdl,
|
---|
21792 | OUT PMDL *TargetMdl
|
---|
21793 | );
|
---|
21794 |
|
---|
21795 | typedef struct _DMA_OPERATIONS {
|
---|
21796 | ULONG Size;
|
---|
21797 | PPUT_DMA_ADAPTER PutDmaAdapter;
|
---|
21798 | PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
|
---|
21799 | PFREE_COMMON_BUFFER FreeCommonBuffer;
|
---|
21800 | PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
|
---|
21801 | PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
|
---|
21802 | PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
|
---|
21803 | PFREE_MAP_REGISTERS FreeMapRegisters;
|
---|
21804 | PMAP_TRANSFER MapTransfer;
|
---|
21805 | PGET_DMA_ALIGNMENT GetDmaAlignment;
|
---|
21806 | PREAD_DMA_COUNTER ReadDmaCounter;
|
---|
21807 | PGET_SCATTER_GATHER_LIST GetScatterGatherList;
|
---|
21808 | PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
|
---|
21809 | PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
|
---|
21810 | PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
|
---|
21811 | PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
|
---|
21812 | } DMA_OPERATIONS;
|
---|
21813 |
|
---|
21814 |
|
---|
21815 |
|
---|
21816 |
|
---|
21817 | #if defined(_WIN64)
|
---|
21818 |
|
---|
21819 | //
|
---|
21820 | // Use __inline DMA macros (hal.h)
|
---|
21821 | //
|
---|
21822 | #ifndef USE_DMA_MACROS
|
---|
21823 | #define USE_DMA_MACROS
|
---|
21824 | #endif
|
---|
21825 |
|
---|
21826 | //
|
---|
21827 | // Only PnP drivers!
|
---|
21828 | //
|
---|
21829 | #ifndef NO_LEGACY_DRIVERS
|
---|
21830 | #define NO_LEGACY_DRIVERS
|
---|
21831 | #endif
|
---|
21832 |
|
---|
21833 | #endif // _WIN64
|
---|
21834 |
|
---|
21835 |
|
---|
21836 | #if defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_))
|
---|
21837 |
|
---|
21838 |
|
---|
21839 |
|
---|
21840 | DECLSPEC_DEPRECATED_DDK // Use AllocateCommonBuffer
|
---|
21841 | FORCEINLINE
|
---|
21842 | PVOID
|
---|
21843 | HalAllocateCommonBuffer(
|
---|
21844 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21845 | IN ULONG Length,
|
---|
21846 | OUT PPHYSICAL_ADDRESS LogicalAddress,
|
---|
21847 | IN BOOLEAN CacheEnabled
|
---|
21848 | ){
|
---|
21849 |
|
---|
21850 | PALLOCATE_COMMON_BUFFER allocateCommonBuffer;
|
---|
21851 | PVOID commonBuffer;
|
---|
21852 |
|
---|
21853 | allocateCommonBuffer = *(DmaAdapter)->DmaOperations->AllocateCommonBuffer;
|
---|
21854 | ASSERT( allocateCommonBuffer != NULL );
|
---|
21855 |
|
---|
21856 | commonBuffer = allocateCommonBuffer( DmaAdapter,
|
---|
21857 | Length,
|
---|
21858 | LogicalAddress,
|
---|
21859 | CacheEnabled );
|
---|
21860 |
|
---|
21861 | return commonBuffer;
|
---|
21862 | }
|
---|
21863 |
|
---|
21864 | DECLSPEC_DEPRECATED_DDK // Use FreeCommonBuffer
|
---|
21865 | FORCEINLINE
|
---|
21866 | VOID
|
---|
21867 | HalFreeCommonBuffer(
|
---|
21868 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21869 | IN ULONG Length,
|
---|
21870 | IN PHYSICAL_ADDRESS LogicalAddress,
|
---|
21871 | IN PVOID VirtualAddress,
|
---|
21872 | IN BOOLEAN CacheEnabled
|
---|
21873 | ){
|
---|
21874 |
|
---|
21875 | PFREE_COMMON_BUFFER freeCommonBuffer;
|
---|
21876 |
|
---|
21877 | freeCommonBuffer = *(DmaAdapter)->DmaOperations->FreeCommonBuffer;
|
---|
21878 | ASSERT( freeCommonBuffer != NULL );
|
---|
21879 |
|
---|
21880 | freeCommonBuffer( DmaAdapter,
|
---|
21881 | Length,
|
---|
21882 | LogicalAddress,
|
---|
21883 | VirtualAddress,
|
---|
21884 | CacheEnabled );
|
---|
21885 | }
|
---|
21886 |
|
---|
21887 | DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
|
---|
21888 | FORCEINLINE
|
---|
21889 | NTSTATUS
|
---|
21890 | IoAllocateAdapterChannel(
|
---|
21891 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21892 | IN PDEVICE_OBJECT DeviceObject,
|
---|
21893 | IN ULONG NumberOfMapRegisters,
|
---|
21894 | IN PDRIVER_CONTROL ExecutionRoutine,
|
---|
21895 | IN PVOID Context
|
---|
21896 | ){
|
---|
21897 |
|
---|
21898 | PALLOCATE_ADAPTER_CHANNEL allocateAdapterChannel;
|
---|
21899 | NTSTATUS status;
|
---|
21900 |
|
---|
21901 | allocateAdapterChannel =
|
---|
21902 | *(DmaAdapter)->DmaOperations->AllocateAdapterChannel;
|
---|
21903 |
|
---|
21904 | ASSERT( allocateAdapterChannel != NULL );
|
---|
21905 |
|
---|
21906 | status = allocateAdapterChannel( DmaAdapter,
|
---|
21907 | DeviceObject,
|
---|
21908 | NumberOfMapRegisters,
|
---|
21909 | ExecutionRoutine,
|
---|
21910 | Context );
|
---|
21911 |
|
---|
21912 | return status;
|
---|
21913 | }
|
---|
21914 |
|
---|
21915 | DECLSPEC_DEPRECATED_DDK // Use FlushAdapterBuffers
|
---|
21916 | FORCEINLINE
|
---|
21917 | BOOLEAN
|
---|
21918 | IoFlushAdapterBuffers(
|
---|
21919 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21920 | IN PMDL Mdl,
|
---|
21921 | IN PVOID MapRegisterBase,
|
---|
21922 | IN PVOID CurrentVa,
|
---|
21923 | IN ULONG Length,
|
---|
21924 | IN BOOLEAN WriteToDevice
|
---|
21925 | ){
|
---|
21926 |
|
---|
21927 | PFLUSH_ADAPTER_BUFFERS flushAdapterBuffers;
|
---|
21928 | BOOLEAN result;
|
---|
21929 |
|
---|
21930 | flushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers;
|
---|
21931 | ASSERT( flushAdapterBuffers != NULL );
|
---|
21932 |
|
---|
21933 | result = flushAdapterBuffers( DmaAdapter,
|
---|
21934 | Mdl,
|
---|
21935 | MapRegisterBase,
|
---|
21936 | CurrentVa,
|
---|
21937 | Length,
|
---|
21938 | WriteToDevice );
|
---|
21939 | return result;
|
---|
21940 | }
|
---|
21941 |
|
---|
21942 | DECLSPEC_DEPRECATED_DDK // Use FreeAdapterChannel
|
---|
21943 | FORCEINLINE
|
---|
21944 | VOID
|
---|
21945 | IoFreeAdapterChannel(
|
---|
21946 | IN PDMA_ADAPTER DmaAdapter
|
---|
21947 | ){
|
---|
21948 |
|
---|
21949 | PFREE_ADAPTER_CHANNEL freeAdapterChannel;
|
---|
21950 |
|
---|
21951 | freeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel;
|
---|
21952 | ASSERT( freeAdapterChannel != NULL );
|
---|
21953 |
|
---|
21954 | freeAdapterChannel( DmaAdapter );
|
---|
21955 | }
|
---|
21956 |
|
---|
21957 | DECLSPEC_DEPRECATED_DDK // Use FreeMapRegisters
|
---|
21958 | FORCEINLINE
|
---|
21959 | VOID
|
---|
21960 | IoFreeMapRegisters(
|
---|
21961 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21962 | IN PVOID MapRegisterBase,
|
---|
21963 | IN ULONG NumberOfMapRegisters
|
---|
21964 | ){
|
---|
21965 |
|
---|
21966 | PFREE_MAP_REGISTERS freeMapRegisters;
|
---|
21967 |
|
---|
21968 | freeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters;
|
---|
21969 | ASSERT( freeMapRegisters != NULL );
|
---|
21970 |
|
---|
21971 | freeMapRegisters( DmaAdapter,
|
---|
21972 | MapRegisterBase,
|
---|
21973 | NumberOfMapRegisters );
|
---|
21974 | }
|
---|
21975 |
|
---|
21976 |
|
---|
21977 | DECLSPEC_DEPRECATED_DDK // Use MapTransfer
|
---|
21978 | FORCEINLINE
|
---|
21979 | PHYSICAL_ADDRESS
|
---|
21980 | IoMapTransfer(
|
---|
21981 | IN PDMA_ADAPTER DmaAdapter,
|
---|
21982 | IN PMDL Mdl,
|
---|
21983 | IN PVOID MapRegisterBase,
|
---|
21984 | IN PVOID CurrentVa,
|
---|
21985 | IN OUT PULONG Length,
|
---|
21986 | IN BOOLEAN WriteToDevice
|
---|
21987 | ){
|
---|
21988 |
|
---|
21989 | PHYSICAL_ADDRESS physicalAddress;
|
---|
21990 | PMAP_TRANSFER mapTransfer;
|
---|
21991 |
|
---|
21992 | mapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer;
|
---|
21993 | ASSERT( mapTransfer != NULL );
|
---|
21994 |
|
---|
21995 | physicalAddress = mapTransfer( DmaAdapter,
|
---|
21996 | Mdl,
|
---|
21997 | MapRegisterBase,
|
---|
21998 | CurrentVa,
|
---|
21999 | Length,
|
---|
22000 | WriteToDevice );
|
---|
22001 |
|
---|
22002 | return physicalAddress;
|
---|
22003 | }
|
---|
22004 |
|
---|
22005 | DECLSPEC_DEPRECATED_DDK // Use GetDmaAlignment
|
---|
22006 | FORCEINLINE
|
---|
22007 | ULONG
|
---|
22008 | HalGetDmaAlignment(
|
---|
22009 | IN PDMA_ADAPTER DmaAdapter
|
---|
22010 | )
|
---|
22011 | {
|
---|
22012 | PGET_DMA_ALIGNMENT getDmaAlignment;
|
---|
22013 | ULONG alignment;
|
---|
22014 |
|
---|
22015 | getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment;
|
---|
22016 | ASSERT( getDmaAlignment != NULL );
|
---|
22017 |
|
---|
22018 | alignment = getDmaAlignment( DmaAdapter );
|
---|
22019 | return alignment;
|
---|
22020 | }
|
---|
22021 |
|
---|
22022 | DECLSPEC_DEPRECATED_DDK // Use ReadDmaCounter
|
---|
22023 | FORCEINLINE
|
---|
22024 | ULONG
|
---|
22025 | HalReadDmaCounter(
|
---|
22026 | IN PDMA_ADAPTER DmaAdapter
|
---|
22027 | )
|
---|
22028 | {
|
---|
22029 | PREAD_DMA_COUNTER readDmaCounter;
|
---|
22030 | ULONG counter;
|
---|
22031 |
|
---|
22032 | readDmaCounter = *(DmaAdapter)->DmaOperations->ReadDmaCounter;
|
---|
22033 | ASSERT( readDmaCounter != NULL );
|
---|
22034 |
|
---|
22035 | counter = readDmaCounter( DmaAdapter );
|
---|
22036 | return counter;
|
---|
22037 | }
|
---|
22038 |
|
---|
22039 |
|
---|
22040 |
|
---|
22041 | #else
|
---|
22042 |
|
---|
22043 | //
|
---|
22044 | // DMA adapter object functions.
|
---|
22045 | //
|
---|
22046 | DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
|
---|
22047 | NTHALAPI
|
---|
22048 | NTSTATUS
|
---|
22049 | HalAllocateAdapterChannel(
|
---|
22050 | IN PADAPTER_OBJECT AdapterObject,
|
---|
22051 | IN PWAIT_CONTEXT_BLOCK Wcb,
|
---|
22052 | IN ULONG NumberOfMapRegisters,
|
---|
22053 | IN PDRIVER_CONTROL ExecutionRoutine
|
---|
22054 | );
|
---|
22055 |
|
---|
22056 | DECLSPEC_DEPRECATED_DDK // Use AllocateCommonBuffer
|
---|
22057 | NTHALAPI
|
---|
22058 | PVOID
|
---|
22059 | HalAllocateCommonBuffer(
|
---|
22060 | IN PADAPTER_OBJECT AdapterObject,
|
---|
22061 | IN ULONG Length,
|
---|
22062 | OUT PPHYSICAL_ADDRESS LogicalAddress,
|
---|
22063 | IN BOOLEAN CacheEnabled
|
---|
22064 | );
|
---|
22065 |
|
---|
22066 | DECLSPEC_DEPRECATED_DDK // Use FreeCommonBuffer
|
---|
22067 | NTHALAPI
|
---|
22068 | VOID
|
---|
22069 | HalFreeCommonBuffer(
|
---|
22070 | IN PADAPTER_OBJECT AdapterObject,
|
---|
22071 | IN ULONG Length,
|
---|
22072 | IN PHYSICAL_ADDRESS LogicalAddress,
|
---|
22073 | IN PVOID VirtualAddress,
|
---|
22074 | IN BOOLEAN CacheEnabled
|
---|
22075 | );
|
---|
22076 |
|
---|
22077 | DECLSPEC_DEPRECATED_DDK // Use ReadDmaCounter
|
---|
22078 | NTHALAPI
|
---|
22079 | ULONG
|
---|
22080 | HalReadDmaCounter(
|
---|
22081 | IN PADAPTER_OBJECT AdapterObject
|
---|
22082 | );
|
---|
22083 |
|
---|
22084 | DECLSPEC_DEPRECATED_DDK // Use FlushAdapterBuffers
|
---|
22085 | NTHALAPI
|
---|
22086 | BOOLEAN
|
---|
22087 | IoFlushAdapterBuffers(
|
---|
22088 | IN PADAPTER_OBJECT AdapterObject,
|
---|
22089 | IN PMDL Mdl,
|
---|
22090 | IN PVOID MapRegisterBase,
|
---|
22091 | IN PVOID CurrentVa,
|
---|
22092 | IN ULONG Length,
|
---|
22093 | IN BOOLEAN WriteToDevice
|
---|
22094 | );
|
---|
22095 |
|
---|
22096 | DECLSPEC_DEPRECATED_DDK // Use FreeAdapterChannel
|
---|
22097 | NTHALAPI
|
---|
22098 | VOID
|
---|
22099 | IoFreeAdapterChannel(
|
---|
22100 | IN PADAPTER_OBJECT AdapterObject
|
---|
22101 | );
|
---|
22102 |
|
---|
22103 | DECLSPEC_DEPRECATED_DDK // Use FreeMapRegisters
|
---|
22104 | NTHALAPI
|
---|
22105 | VOID
|
---|
22106 | IoFreeMapRegisters(
|
---|
22107 | IN PADAPTER_OBJECT AdapterObject,
|
---|
22108 | IN PVOID MapRegisterBase,
|
---|
22109 | IN ULONG NumberOfMapRegisters
|
---|
22110 | );
|
---|
22111 |
|
---|
22112 | DECLSPEC_DEPRECATED_DDK // Use MapTransfer
|
---|
22113 | NTHALAPI
|
---|
22114 | PHYSICAL_ADDRESS
|
---|
22115 | IoMapTransfer(
|
---|
22116 | IN PADAPTER_OBJECT AdapterObject,
|
---|
22117 | IN PMDL Mdl,
|
---|
22118 | IN PVOID MapRegisterBase,
|
---|
22119 | IN PVOID CurrentVa,
|
---|
22120 | IN OUT PULONG Length,
|
---|
22121 | IN BOOLEAN WriteToDevice
|
---|
22122 | );
|
---|
22123 | #endif // USE_DMA_MACROS && (_NTDDK_ || _NTDRIVER_)
|
---|
22124 |
|
---|
22125 | DECLSPEC_DEPRECATED_DDK
|
---|
22126 | NTSTATUS
|
---|
22127 | HalGetScatterGatherList ( // Use GetScatterGatherList
|
---|
22128 | IN PADAPTER_OBJECT DmaAdapter,
|
---|
22129 | IN PDEVICE_OBJECT DeviceObject,
|
---|
22130 | IN PMDL Mdl,
|
---|
22131 | IN PVOID CurrentVa,
|
---|
22132 | IN ULONG Length,
|
---|
22133 | IN PDRIVER_LIST_CONTROL ExecutionRoutine,
|
---|
22134 | IN PVOID Context,
|
---|
22135 | IN BOOLEAN WriteToDevice
|
---|
22136 | );
|
---|
22137 |
|
---|
22138 | DECLSPEC_DEPRECATED_DDK // Use PutScatterGatherList
|
---|
22139 | VOID
|
---|
22140 | HalPutScatterGatherList (
|
---|
22141 | IN PADAPTER_OBJECT DmaAdapter,
|
---|
22142 | IN PSCATTER_GATHER_LIST ScatterGather,
|
---|
22143 | IN BOOLEAN WriteToDevice
|
---|
22144 | );
|
---|
22145 |
|
---|
22146 | DECLSPEC_DEPRECATED_DDK // Use PutDmaAdapter
|
---|
22147 | VOID
|
---|
22148 | HalPutDmaAdapter(
|
---|
22149 | IN PADAPTER_OBJECT DmaAdapter
|
---|
22150 | );
|
---|
22151 |
|
---|
22152 |
|
---|
22153 | NTKERNELAPI
|
---|
22154 | VOID
|
---|
22155 | PoSetSystemState (
|
---|
22156 | IN EXECUTION_STATE Flags
|
---|
22157 | );
|
---|
22158 |
|
---|
22159 |
|
---|
22160 |
|
---|
22161 | NTKERNELAPI
|
---|
22162 | PVOID
|
---|
22163 | PoRegisterSystemState (
|
---|
22164 | IN PVOID StateHandle,
|
---|
22165 | IN EXECUTION_STATE Flags
|
---|
22166 | );
|
---|
22167 |
|
---|
22168 |
|
---|
22169 |
|
---|
22170 | typedef
|
---|
22171 | VOID
|
---|
22172 | (*PREQUEST_POWER_COMPLETE) (
|
---|
22173 | IN PDEVICE_OBJECT DeviceObject,
|
---|
22174 | IN UCHAR MinorFunction,
|
---|
22175 | IN POWER_STATE PowerState,
|
---|
22176 | IN PVOID Context,
|
---|
22177 | IN PIO_STATUS_BLOCK IoStatus
|
---|
22178 | );
|
---|
22179 |
|
---|
22180 | NTKERNELAPI
|
---|
22181 | NTSTATUS
|
---|
22182 | PoRequestPowerIrp (
|
---|
22183 | IN PDEVICE_OBJECT DeviceObject,
|
---|
22184 | IN UCHAR MinorFunction,
|
---|
22185 | IN POWER_STATE PowerState,
|
---|
22186 | IN PREQUEST_POWER_COMPLETE CompletionFunction,
|
---|
22187 | IN PVOID Context,
|
---|
22188 | OUT PIRP *Irp OPTIONAL
|
---|
22189 | );
|
---|
22190 |
|
---|
22191 | NTKERNELAPI
|
---|
22192 | NTSTATUS
|
---|
22193 | PoRequestShutdownEvent (
|
---|
22194 | OUT PVOID *Event
|
---|
22195 | );
|
---|
22196 |
|
---|
22197 | NTKERNELAPI
|
---|
22198 | NTSTATUS
|
---|
22199 | PoRequestShutdownWait (
|
---|
22200 | IN PETHREAD Thread
|
---|
22201 | );
|
---|
22202 |
|
---|
22203 |
|
---|
22204 |
|
---|
22205 | NTKERNELAPI
|
---|
22206 | VOID
|
---|
22207 | PoUnregisterSystemState (
|
---|
22208 | IN PVOID StateHandle
|
---|
22209 | );
|
---|
22210 |
|
---|
22211 |
|
---|
22212 |
|
---|
22213 | NTKERNELAPI
|
---|
22214 | POWER_STATE
|
---|
22215 | PoSetPowerState (
|
---|
22216 | IN PDEVICE_OBJECT DeviceObject,
|
---|
22217 | IN POWER_STATE_TYPE Type,
|
---|
22218 | IN POWER_STATE State
|
---|
22219 | );
|
---|
22220 |
|
---|
22221 | NTKERNELAPI
|
---|
22222 | NTSTATUS
|
---|
22223 | PoCallDriver (
|
---|
22224 | IN PDEVICE_OBJECT DeviceObject,
|
---|
22225 | IN OUT PIRP Irp
|
---|
22226 | );
|
---|
22227 |
|
---|
22228 | NTKERNELAPI
|
---|
22229 | VOID
|
---|
22230 | PoStartNextPowerIrp(
|
---|
22231 | IN PIRP Irp
|
---|
22232 | );
|
---|
22233 |
|
---|
22234 |
|
---|
22235 | NTKERNELAPI
|
---|
22236 | PULONG
|
---|
22237 | PoRegisterDeviceForIdleDetection (
|
---|
22238 | IN PDEVICE_OBJECT DeviceObject,
|
---|
22239 | IN ULONG ConservationIdleTime,
|
---|
22240 | IN ULONG PerformanceIdleTime,
|
---|
22241 | IN DEVICE_POWER_STATE State
|
---|
22242 | );
|
---|
22243 |
|
---|
22244 | #define PoSetDeviceBusy(IdlePointer) \
|
---|
22245 | *IdlePointer = 0
|
---|
22246 |
|
---|
22247 | //
|
---|
22248 | // \Callback\PowerState values
|
---|
22249 | //
|
---|
22250 |
|
---|
22251 | #define PO_CB_SYSTEM_POWER_POLICY 0
|
---|
22252 | #define PO_CB_AC_STATUS 1
|
---|
22253 | #define PO_CB_BUTTON_COLLISION 2
|
---|
22254 | #define PO_CB_SYSTEM_STATE_LOCK 3
|
---|
22255 | #define PO_CB_LID_SWITCH_STATE 4
|
---|
22256 | #define PO_CB_PROCESSOR_POWER_POLICY 5
|
---|
22257 |
|
---|
22258 | //
|
---|
22259 | // Determine if there is a complete device failure on an error.
|
---|
22260 | //
|
---|
22261 |
|
---|
22262 | NTKERNELAPI
|
---|
22263 | BOOLEAN
|
---|
22264 | FsRtlIsTotalDeviceFailure(
|
---|
22265 | IN NTSTATUS Status
|
---|
22266 | );
|
---|
22267 |
|
---|
22268 | //
|
---|
22269 | // Object Manager types
|
---|
22270 | //
|
---|
22271 |
|
---|
22272 | typedef struct _OBJECT_HANDLE_INFORMATION {
|
---|
22273 | ULONG HandleAttributes;
|
---|
22274 | ACCESS_MASK GrantedAccess;
|
---|
22275 | } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
|
---|
22276 |
|
---|
22277 | NTKERNELAPI
|
---|
22278 | NTSTATUS
|
---|
22279 | ObReferenceObjectByHandle(
|
---|
22280 | IN HANDLE Handle,
|
---|
22281 | IN ACCESS_MASK DesiredAccess,
|
---|
22282 | IN POBJECT_TYPE ObjectType OPTIONAL,
|
---|
22283 | IN KPROCESSOR_MODE AccessMode,
|
---|
22284 | OUT PVOID *Object,
|
---|
22285 | OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL
|
---|
22286 | );
|
---|
22287 |
|
---|
22288 | #define ObDereferenceObject(a) \
|
---|
22289 | ObfDereferenceObject(a)
|
---|
22290 |
|
---|
22291 | #define ObReferenceObject(Object) ObfReferenceObject(Object)
|
---|
22292 |
|
---|
22293 | NTKERNELAPI
|
---|
22294 | LONG_PTR
|
---|
22295 | FASTCALL
|
---|
22296 | ObfReferenceObject(
|
---|
22297 | IN PVOID Object
|
---|
22298 | );
|
---|
22299 |
|
---|
22300 | NTKERNELAPI
|
---|
22301 | NTSTATUS
|
---|
22302 | ObReferenceObjectByPointer(
|
---|
22303 | IN PVOID Object,
|
---|
22304 | IN ACCESS_MASK DesiredAccess,
|
---|
22305 | IN POBJECT_TYPE ObjectType,
|
---|
22306 | IN KPROCESSOR_MODE AccessMode
|
---|
22307 | );
|
---|
22308 |
|
---|
22309 | NTKERNELAPI
|
---|
22310 | LONG_PTR
|
---|
22311 | FASTCALL
|
---|
22312 | ObfDereferenceObject(
|
---|
22313 | IN PVOID Object
|
---|
22314 | );
|
---|
22315 |
|
---|
22316 | NTSTATUS
|
---|
22317 | ObGetObjectSecurity(
|
---|
22318 | IN PVOID Object,
|
---|
22319 | OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
|
---|
22320 | OUT PBOOLEAN MemoryAllocated
|
---|
22321 | );
|
---|
22322 |
|
---|
22323 | VOID
|
---|
22324 | ObReleaseObjectSecurity(
|
---|
22325 | IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
22326 | IN BOOLEAN MemoryAllocated
|
---|
22327 | );
|
---|
22328 |
|
---|
22329 | //
|
---|
22330 | // A PCI driver can read the complete 256 bytes of configuration
|
---|
22331 | // information for any PCI device by calling:
|
---|
22332 | //
|
---|
22333 | // ULONG
|
---|
22334 | // HalGetBusData (
|
---|
22335 | // IN BUS_DATA_TYPE PCIConfiguration,
|
---|
22336 | // IN ULONG PciBusNumber,
|
---|
22337 | // IN PCI_SLOT_NUMBER VirtualSlotNumber,
|
---|
22338 | // IN PPCI_COMMON_CONFIG &PCIDeviceConfig,
|
---|
22339 | // IN ULONG sizeof (PCIDeviceConfig)
|
---|
22340 | // );
|
---|
22341 | //
|
---|
22342 | // A return value of 0 means that the specified PCI bus does not exist.
|
---|
22343 | //
|
---|
22344 | // A return value of 2, with a VendorID of PCI_INVALID_VENDORID means
|
---|
22345 | // that the PCI bus does exist, but there is no device at the specified
|
---|
22346 | // VirtualSlotNumber (PCI Device/Function number).
|
---|
22347 | //
|
---|
22348 | //
|
---|
22349 |
|
---|
22350 |
|
---|
22351 |
|
---|
22352 | typedef struct _PCI_SLOT_NUMBER {
|
---|
22353 | union {
|
---|
22354 | struct {
|
---|
22355 | ULONG DeviceNumber:5;
|
---|
22356 | ULONG FunctionNumber:3;
|
---|
22357 | ULONG Reserved:24;
|
---|
22358 | } bits;
|
---|
22359 | ULONG AsULONG;
|
---|
22360 | } u;
|
---|
22361 | } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
|
---|
22362 |
|
---|
22363 |
|
---|
22364 | #define PCI_TYPE0_ADDRESSES 6
|
---|
22365 | #define PCI_TYPE1_ADDRESSES 2
|
---|
22366 | #define PCI_TYPE2_ADDRESSES 5
|
---|
22367 |
|
---|
22368 | typedef struct _PCI_COMMON_CONFIG {
|
---|
22369 | USHORT VendorID; // (ro)
|
---|
22370 | USHORT DeviceID; // (ro)
|
---|
22371 | USHORT Command; // Device control
|
---|
22372 | USHORT Status;
|
---|
22373 | UCHAR RevisionID; // (ro)
|
---|
22374 | UCHAR ProgIf; // (ro)
|
---|
22375 | UCHAR SubClass; // (ro)
|
---|
22376 | UCHAR BaseClass; // (ro)
|
---|
22377 | UCHAR CacheLineSize; // (ro+)
|
---|
22378 | UCHAR LatencyTimer; // (ro+)
|
---|
22379 | UCHAR HeaderType; // (ro)
|
---|
22380 | UCHAR BIST; // Built in self test
|
---|
22381 |
|
---|
22382 | union {
|
---|
22383 | struct _PCI_HEADER_TYPE_0 {
|
---|
22384 | ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
|
---|
22385 | ULONG CIS;
|
---|
22386 | USHORT SubVendorID;
|
---|
22387 | USHORT SubSystemID;
|
---|
22388 | ULONG ROMBaseAddress;
|
---|
22389 | UCHAR CapabilitiesPtr;
|
---|
22390 | UCHAR Reserved1[3];
|
---|
22391 | ULONG Reserved2;
|
---|
22392 | UCHAR InterruptLine; //
|
---|
22393 | UCHAR InterruptPin; // (ro)
|
---|
22394 | UCHAR MinimumGrant; // (ro)
|
---|
22395 | UCHAR MaximumLatency; // (ro)
|
---|
22396 | } type0;
|
---|
22397 |
|
---|
22398 |
|
---|
22399 |
|
---|
22400 | //
|
---|
22401 | // PCI to PCI Bridge
|
---|
22402 | //
|
---|
22403 |
|
---|
22404 | struct _PCI_HEADER_TYPE_1 {
|
---|
22405 | ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
|
---|
22406 | UCHAR PrimaryBus;
|
---|
22407 | UCHAR SecondaryBus;
|
---|
22408 | UCHAR SubordinateBus;
|
---|
22409 | UCHAR SecondaryLatency;
|
---|
22410 | UCHAR IOBase;
|
---|
22411 | UCHAR IOLimit;
|
---|
22412 | USHORT SecondaryStatus;
|
---|
22413 | USHORT MemoryBase;
|
---|
22414 | USHORT MemoryLimit;
|
---|
22415 | USHORT PrefetchBase;
|
---|
22416 | USHORT PrefetchLimit;
|
---|
22417 | ULONG PrefetchBaseUpper32;
|
---|
22418 | ULONG PrefetchLimitUpper32;
|
---|
22419 | USHORT IOBaseUpper16;
|
---|
22420 | USHORT IOLimitUpper16;
|
---|
22421 | UCHAR CapabilitiesPtr;
|
---|
22422 | UCHAR Reserved1[3];
|
---|
22423 | ULONG ROMBaseAddress;
|
---|
22424 | UCHAR InterruptLine;
|
---|
22425 | UCHAR InterruptPin;
|
---|
22426 | USHORT BridgeControl;
|
---|
22427 | } type1;
|
---|
22428 |
|
---|
22429 | //
|
---|
22430 | // PCI to CARDBUS Bridge
|
---|
22431 | //
|
---|
22432 |
|
---|
22433 | struct _PCI_HEADER_TYPE_2 {
|
---|
22434 | ULONG SocketRegistersBaseAddress;
|
---|
22435 | UCHAR CapabilitiesPtr;
|
---|
22436 | UCHAR Reserved;
|
---|
22437 | USHORT SecondaryStatus;
|
---|
22438 | UCHAR PrimaryBus;
|
---|
22439 | UCHAR SecondaryBus;
|
---|
22440 | UCHAR SubordinateBus;
|
---|
22441 | UCHAR SecondaryLatency;
|
---|
22442 | struct {
|
---|
22443 | ULONG Base;
|
---|
22444 | ULONG Limit;
|
---|
22445 | } Range[PCI_TYPE2_ADDRESSES-1];
|
---|
22446 | UCHAR InterruptLine;
|
---|
22447 | UCHAR InterruptPin;
|
---|
22448 | USHORT BridgeControl;
|
---|
22449 | } type2;
|
---|
22450 |
|
---|
22451 |
|
---|
22452 |
|
---|
22453 | } u;
|
---|
22454 |
|
---|
22455 | UCHAR DeviceSpecific[192];
|
---|
22456 |
|
---|
22457 | } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
|
---|
22458 |
|
---|
22459 |
|
---|
22460 | #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
|
---|
22461 |
|
---|
22462 | #define PCI_MAX_DEVICES 32
|
---|
22463 | #define PCI_MAX_FUNCTION 8
|
---|
22464 | #define PCI_MAX_BRIDGE_NUMBER 0xFF
|
---|
22465 |
|
---|
22466 | #define PCI_INVALID_VENDORID 0xFFFF
|
---|
22467 |
|
---|
22468 | //
|
---|
22469 | // Bit encodings for PCI_COMMON_CONFIG.HeaderType
|
---|
22470 | //
|
---|
22471 |
|
---|
22472 | #define PCI_MULTIFUNCTION 0x80
|
---|
22473 | #define PCI_DEVICE_TYPE 0x00
|
---|
22474 | #define PCI_BRIDGE_TYPE 0x01
|
---|
22475 | #define PCI_CARDBUS_BRIDGE_TYPE 0x02
|
---|
22476 |
|
---|
22477 | #define PCI_CONFIGURATION_TYPE(PciData) \
|
---|
22478 | (((PPCI_COMMON_CONFIG)(PciData))->HeaderType & ~PCI_MULTIFUNCTION)
|
---|
22479 |
|
---|
22480 | #define PCI_MULTIFUNCTION_DEVICE(PciData) \
|
---|
22481 | ((((PPCI_COMMON_CONFIG)(PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
|
---|
22482 |
|
---|
22483 | //
|
---|
22484 | // Bit encodings for PCI_COMMON_CONFIG.Command
|
---|
22485 | //
|
---|
22486 |
|
---|
22487 | #define PCI_ENABLE_IO_SPACE 0x0001
|
---|
22488 | #define PCI_ENABLE_MEMORY_SPACE 0x0002
|
---|
22489 | #define PCI_ENABLE_BUS_MASTER 0x0004
|
---|
22490 | #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
|
---|
22491 | #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
|
---|
22492 | #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
|
---|
22493 | #define PCI_ENABLE_PARITY 0x0040 // (ro+)
|
---|
22494 | #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
|
---|
22495 | #define PCI_ENABLE_SERR 0x0100 // (ro+)
|
---|
22496 | #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
|
---|
22497 |
|
---|
22498 | //
|
---|
22499 | // Bit encodings for PCI_COMMON_CONFIG.Status
|
---|
22500 | //
|
---|
22501 |
|
---|
22502 | #define PCI_STATUS_CAPABILITIES_LIST 0x0010 // (ro)
|
---|
22503 | #define PCI_STATUS_66MHZ_CAPABLE 0x0020 // (ro)
|
---|
22504 | #define PCI_STATUS_UDF_SUPPORTED 0x0040 // (ro)
|
---|
22505 | #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
|
---|
22506 | #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
|
---|
22507 | #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
|
---|
22508 | #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
|
---|
22509 | #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
|
---|
22510 | #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
|
---|
22511 | #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
|
---|
22512 | #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
|
---|
22513 |
|
---|
22514 | //
|
---|
22515 | // The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
|
---|
22516 | // routines. The following values are defined-
|
---|
22517 | //
|
---|
22518 |
|
---|
22519 | #define PCI_WHICHSPACE_CONFIG 0x0
|
---|
22520 | #define PCI_WHICHSPACE_ROM 0x52696350
|
---|
22521 |
|
---|
22522 |
|
---|
22523 | //
|
---|
22524 | // PCI Capability IDs
|
---|
22525 | //
|
---|
22526 |
|
---|
22527 | #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
|
---|
22528 | #define PCI_CAPABILITY_ID_AGP 0x02
|
---|
22529 | #define PCI_CAPABILITY_ID_MSI 0x05
|
---|
22530 | #define PCI_CAPABILITY_ID_AGP_TARGET 0x0E
|
---|
22531 |
|
---|
22532 | //
|
---|
22533 | // All PCI Capability structures have the following header.
|
---|
22534 | //
|
---|
22535 | // CapabilityID is used to identify the type of the structure (is
|
---|
22536 | // one of the PCI_CAPABILITY_ID values above.
|
---|
22537 | //
|
---|
22538 | // Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
|
---|
22539 | // next capability structure in the list, or 0x00 if there are no more
|
---|
22540 | // entries.
|
---|
22541 | //
|
---|
22542 | typedef struct _PCI_CAPABILITIES_HEADER {
|
---|
22543 | UCHAR CapabilityID;
|
---|
22544 | UCHAR Next;
|
---|
22545 | } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
|
---|
22546 |
|
---|
22547 | //
|
---|
22548 | // Power Management Capability
|
---|
22549 | //
|
---|
22550 |
|
---|
22551 | typedef struct _PCI_PMC {
|
---|
22552 | UCHAR Version:3;
|
---|
22553 | UCHAR PMEClock:1;
|
---|
22554 | UCHAR Rsvd1:1;
|
---|
22555 | UCHAR DeviceSpecificInitialization:1;
|
---|
22556 | UCHAR Rsvd2:2;
|
---|
22557 | struct _PM_SUPPORT {
|
---|
22558 | UCHAR Rsvd2:1;
|
---|
22559 | UCHAR D1:1;
|
---|
22560 | UCHAR D2:1;
|
---|
22561 | UCHAR PMED0:1;
|
---|
22562 | UCHAR PMED1:1;
|
---|
22563 | UCHAR PMED2:1;
|
---|
22564 | UCHAR PMED3Hot:1;
|
---|
22565 | UCHAR PMED3Cold:1;
|
---|
22566 | } Support;
|
---|
22567 | } PCI_PMC, *PPCI_PMC;
|
---|
22568 |
|
---|
22569 | typedef struct _PCI_PMCSR {
|
---|
22570 | USHORT PowerState:2;
|
---|
22571 | USHORT Rsvd1:6;
|
---|
22572 | USHORT PMEEnable:1;
|
---|
22573 | USHORT DataSelect:4;
|
---|
22574 | USHORT DataScale:2;
|
---|
22575 | USHORT PMEStatus:1;
|
---|
22576 | } PCI_PMCSR, *PPCI_PMCSR;
|
---|
22577 |
|
---|
22578 |
|
---|
22579 | typedef struct _PCI_PMCSR_BSE {
|
---|
22580 | UCHAR Rsvd1:6;
|
---|
22581 | UCHAR D3HotSupportsStopClock:1; // B2_B3#
|
---|
22582 | UCHAR BusPowerClockControlEnabled:1; // BPCC_EN
|
---|
22583 | } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
|
---|
22584 |
|
---|
22585 |
|
---|
22586 | typedef struct _PCI_PM_CAPABILITY {
|
---|
22587 |
|
---|
22588 | PCI_CAPABILITIES_HEADER Header;
|
---|
22589 |
|
---|
22590 | //
|
---|
22591 | // Power Management Capabilities (Offset = 2)
|
---|
22592 | //
|
---|
22593 |
|
---|
22594 | union {
|
---|
22595 | PCI_PMC Capabilities;
|
---|
22596 | USHORT AsUSHORT;
|
---|
22597 | } PMC;
|
---|
22598 |
|
---|
22599 | //
|
---|
22600 | // Power Management Control/Status (Offset = 4)
|
---|
22601 | //
|
---|
22602 |
|
---|
22603 | union {
|
---|
22604 | PCI_PMCSR ControlStatus;
|
---|
22605 | USHORT AsUSHORT;
|
---|
22606 | } PMCSR;
|
---|
22607 |
|
---|
22608 | //
|
---|
22609 | // PMCSR PCI-PCI Bridge Support Extensions
|
---|
22610 | //
|
---|
22611 |
|
---|
22612 | union {
|
---|
22613 | PCI_PMCSR_BSE BridgeSupport;
|
---|
22614 | UCHAR AsUCHAR;
|
---|
22615 | } PMCSR_BSE;
|
---|
22616 |
|
---|
22617 | //
|
---|
22618 | // Optional read only 8 bit Data register. Contents controlled by
|
---|
22619 | // DataSelect and DataScale in ControlStatus.
|
---|
22620 | //
|
---|
22621 |
|
---|
22622 | UCHAR Data;
|
---|
22623 |
|
---|
22624 | } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
|
---|
22625 |
|
---|
22626 | //
|
---|
22627 | // AGP Capability
|
---|
22628 | //
|
---|
22629 | typedef struct _PCI_AGP_CAPABILITY {
|
---|
22630 |
|
---|
22631 | PCI_CAPABILITIES_HEADER Header;
|
---|
22632 |
|
---|
22633 | USHORT Minor:4;
|
---|
22634 | USHORT Major:4;
|
---|
22635 | USHORT Rsvd1:8;
|
---|
22636 |
|
---|
22637 | struct _PCI_AGP_STATUS {
|
---|
22638 | ULONG Rate:3;
|
---|
22639 | ULONG Agp3Mode:1;
|
---|
22640 | ULONG FastWrite:1;
|
---|
22641 | ULONG FourGB:1;
|
---|
22642 | ULONG HostTransDisable:1;
|
---|
22643 | ULONG Gart64:1;
|
---|
22644 | ULONG ITA_Coherent:1;
|
---|
22645 | ULONG SideBandAddressing:1; // SBA
|
---|
22646 | ULONG CalibrationCycle:3;
|
---|
22647 | ULONG AsyncRequestSize:3;
|
---|
22648 | ULONG Rsvd1:1;
|
---|
22649 | ULONG Isoch:1;
|
---|
22650 | ULONG Rsvd2:6;
|
---|
22651 | ULONG RequestQueueDepthMaximum:8; // RQ
|
---|
22652 | } AGPStatus;
|
---|
22653 |
|
---|
22654 | struct _PCI_AGP_COMMAND {
|
---|
22655 | ULONG Rate:3;
|
---|
22656 | ULONG Rsvd1:1;
|
---|
22657 | ULONG FastWriteEnable:1;
|
---|
22658 | ULONG FourGBEnable:1;
|
---|
22659 | ULONG Rsvd2:1;
|
---|
22660 | ULONG Gart64:1;
|
---|
22661 | ULONG AGPEnable:1;
|
---|
22662 | ULONG SBAEnable:1;
|
---|
22663 | ULONG CalibrationCycle:3;
|
---|
22664 | ULONG AsyncReqSize:3;
|
---|
22665 | ULONG Rsvd3:8;
|
---|
22666 | ULONG RequestQueueDepth:8;
|
---|
22667 | } AGPCommand;
|
---|
22668 |
|
---|
22669 | } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
|
---|
22670 |
|
---|
22671 | //
|
---|
22672 | // An AGPv3 Target must have an extended capability,
|
---|
22673 | // but it's only present for a Master when the Isoch
|
---|
22674 | // bit is set in its status register
|
---|
22675 | //
|
---|
22676 | typedef enum _EXTENDED_AGP_REGISTER {
|
---|
22677 | IsochStatus,
|
---|
22678 | AgpControl,
|
---|
22679 | ApertureSize,
|
---|
22680 | AperturePageSize,
|
---|
22681 | GartLow,
|
---|
22682 | GartHigh,
|
---|
22683 | IsochCommand
|
---|
22684 | } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
|
---|
22685 |
|
---|
22686 | typedef struct _PCI_AGP_ISOCH_STATUS {
|
---|
22687 | ULONG ErrorCode: 2;
|
---|
22688 | ULONG Rsvd1: 1;
|
---|
22689 | ULONG Isoch_L: 3;
|
---|
22690 | ULONG Isoch_Y: 2;
|
---|
22691 | ULONG Isoch_N: 8;
|
---|
22692 | ULONG Rsvd2: 16;
|
---|
22693 | } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
|
---|
22694 |
|
---|
22695 | typedef struct _PCI_AGP_CONTROL {
|
---|
22696 | ULONG Rsvd1: 7;
|
---|
22697 | ULONG GTLB_Enable: 1;
|
---|
22698 | ULONG AP_Enable: 1;
|
---|
22699 | ULONG CAL_Disable: 1;
|
---|
22700 | ULONG Rsvd2: 22;
|
---|
22701 | } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
|
---|
22702 |
|
---|
22703 | typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
|
---|
22704 | USHORT PageSizeMask: 11;
|
---|
22705 | USHORT Rsvd1: 1;
|
---|
22706 | USHORT PageSizeSelect: 4;
|
---|
22707 | } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
|
---|
22708 |
|
---|
22709 | typedef struct _PCI_AGP_ISOCH_COMMAND {
|
---|
22710 | USHORT Rsvd1: 6;
|
---|
22711 | USHORT Isoch_Y: 2;
|
---|
22712 | USHORT Isoch_N: 8;
|
---|
22713 | } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
|
---|
22714 |
|
---|
22715 | typedef struct PCI_AGP_EXTENDED_CAPABILITY {
|
---|
22716 |
|
---|
22717 | PCI_AGP_ISOCH_STATUS IsochStatus;
|
---|
22718 |
|
---|
22719 | //
|
---|
22720 | // Target only ----------------<<-begin->>
|
---|
22721 | //
|
---|
22722 | PCI_AGP_CONTROL AgpControl;
|
---|
22723 | USHORT ApertureSize;
|
---|
22724 | PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
|
---|
22725 | ULONG GartLow;
|
---|
22726 | ULONG GartHigh;
|
---|
22727 | //
|
---|
22728 | // ------------------------------<<-end->>
|
---|
22729 | //
|
---|
22730 |
|
---|
22731 | PCI_AGP_ISOCH_COMMAND IsochCommand;
|
---|
22732 |
|
---|
22733 | } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
|
---|
22734 |
|
---|
22735 |
|
---|
22736 | #define PCI_AGP_RATE_1X 0x1
|
---|
22737 | #define PCI_AGP_RATE_2X 0x2
|
---|
22738 | #define PCI_AGP_RATE_4X 0x4
|
---|
22739 |
|
---|
22740 | //
|
---|
22741 | // MSI (Message Signalled Interrupts) Capability
|
---|
22742 | //
|
---|
22743 |
|
---|
22744 | typedef struct _PCI_MSI_CAPABILITY {
|
---|
22745 |
|
---|
22746 | PCI_CAPABILITIES_HEADER Header;
|
---|
22747 |
|
---|
22748 | struct _PCI_MSI_MESSAGE_CONTROL {
|
---|
22749 | USHORT MSIEnable:1;
|
---|
22750 | USHORT MultipleMessageCapable:3;
|
---|
22751 | USHORT MultipleMessageEnable:3;
|
---|
22752 | USHORT CapableOf64Bits:1;
|
---|
22753 | USHORT Reserved:8;
|
---|
22754 | } MessageControl;
|
---|
22755 |
|
---|
22756 | union {
|
---|
22757 | struct _PCI_MSI_MESSAGE_ADDRESS {
|
---|
22758 | ULONG_PTR Reserved:2; // always zero, DWORD aligned address
|
---|
22759 | ULONG_PTR Address:30;
|
---|
22760 | } Register;
|
---|
22761 | ULONG_PTR Raw;
|
---|
22762 | } MessageAddress;
|
---|
22763 |
|
---|
22764 | //
|
---|
22765 | // The rest of the Capability structure differs depending on whether
|
---|
22766 | // 32bit or 64bit addressing is being used.
|
---|
22767 | //
|
---|
22768 | // (The CapableOf64Bits bit above determines this)
|
---|
22769 | //
|
---|
22770 |
|
---|
22771 | union {
|
---|
22772 |
|
---|
22773 | // For 64 bit devices
|
---|
22774 |
|
---|
22775 | struct _PCI_MSI_64BIT_DATA {
|
---|
22776 | ULONG MessageUpperAddress;
|
---|
22777 | USHORT MessageData;
|
---|
22778 | } Bit64;
|
---|
22779 |
|
---|
22780 | // For 32 bit devices
|
---|
22781 |
|
---|
22782 | struct _PCI_MSI_32BIT_DATA {
|
---|
22783 | USHORT MessageData;
|
---|
22784 | ULONG Unused;
|
---|
22785 | } Bit32;
|
---|
22786 | } Data;
|
---|
22787 |
|
---|
22788 | } PCI_MSI_CAPABILITY, *PPCI_PCI_CAPABILITY;
|
---|
22789 |
|
---|
22790 |
|
---|
22791 | //
|
---|
22792 | // Base Class Code encodings for Base Class (from PCI spec rev 2.1).
|
---|
22793 | //
|
---|
22794 |
|
---|
22795 | #define PCI_CLASS_PRE_20 0x00
|
---|
22796 | #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
|
---|
22797 | #define PCI_CLASS_NETWORK_CTLR 0x02
|
---|
22798 | #define PCI_CLASS_DISPLAY_CTLR 0x03
|
---|
22799 | #define PCI_CLASS_MULTIMEDIA_DEV 0x04
|
---|
22800 | #define PCI_CLASS_MEMORY_CTLR 0x05
|
---|
22801 | #define PCI_CLASS_BRIDGE_DEV 0x06
|
---|
22802 | #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
|
---|
22803 | #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
|
---|
22804 | #define PCI_CLASS_INPUT_DEV 0x09
|
---|
22805 | #define PCI_CLASS_DOCKING_STATION 0x0a
|
---|
22806 | #define PCI_CLASS_PROCESSOR 0x0b
|
---|
22807 | #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
|
---|
22808 | #define PCI_CLASS_WIRELESS_CTLR 0x0d
|
---|
22809 | #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
|
---|
22810 | #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
|
---|
22811 | #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
|
---|
22812 | #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
|
---|
22813 |
|
---|
22814 | // 0d thru fe reserved
|
---|
22815 |
|
---|
22816 | #define PCI_CLASS_NOT_DEFINED 0xff
|
---|
22817 |
|
---|
22818 | //
|
---|
22819 | // Sub Class Code encodings (PCI rev 2.1).
|
---|
22820 | //
|
---|
22821 |
|
---|
22822 | // Class 00 - PCI_CLASS_PRE_20
|
---|
22823 |
|
---|
22824 | #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
|
---|
22825 | #define PCI_SUBCLASS_PRE_20_VGA 0x01
|
---|
22826 |
|
---|
22827 | // Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
|
---|
22828 |
|
---|
22829 | #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
|
---|
22830 | #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
|
---|
22831 | #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
|
---|
22832 | #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
|
---|
22833 | #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
|
---|
22834 | #define PCI_SUBCLASS_MSC_OTHER 0x80
|
---|
22835 |
|
---|
22836 | // Class 02 - PCI_CLASS_NETWORK_CTLR
|
---|
22837 |
|
---|
22838 | #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
|
---|
22839 | #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
|
---|
22840 | #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
|
---|
22841 | #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
|
---|
22842 | #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
|
---|
22843 | #define PCI_SUBCLASS_NET_OTHER 0x80
|
---|
22844 |
|
---|
22845 | // Class 03 - PCI_CLASS_DISPLAY_CTLR
|
---|
22846 |
|
---|
22847 | // N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
|
---|
22848 |
|
---|
22849 | #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
|
---|
22850 | #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
|
---|
22851 | #define PCI_SUBLCASS_VID_3D_CTLR 0x02
|
---|
22852 | #define PCI_SUBCLASS_VID_OTHER 0x80
|
---|
22853 |
|
---|
22854 | // Class 04 - PCI_CLASS_MULTIMEDIA_DEV
|
---|
22855 |
|
---|
22856 | #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
|
---|
22857 | #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
|
---|
22858 | #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
|
---|
22859 | #define PCI_SUBCLASS_MM_OTHER 0x80
|
---|
22860 |
|
---|
22861 | // Class 05 - PCI_CLASS_MEMORY_CTLR
|
---|
22862 |
|
---|
22863 | #define PCI_SUBCLASS_MEM_RAM 0x00
|
---|
22864 | #define PCI_SUBCLASS_MEM_FLASH 0x01
|
---|
22865 | #define PCI_SUBCLASS_MEM_OTHER 0x80
|
---|
22866 |
|
---|
22867 | // Class 06 - PCI_CLASS_BRIDGE_DEV
|
---|
22868 |
|
---|
22869 | #define PCI_SUBCLASS_BR_HOST 0x00
|
---|
22870 | #define PCI_SUBCLASS_BR_ISA 0x01
|
---|
22871 | #define PCI_SUBCLASS_BR_EISA 0x02
|
---|
22872 | #define PCI_SUBCLASS_BR_MCA 0x03
|
---|
22873 | #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
|
---|
22874 | #define PCI_SUBCLASS_BR_PCMCIA 0x05
|
---|
22875 | #define PCI_SUBCLASS_BR_NUBUS 0x06
|
---|
22876 | #define PCI_SUBCLASS_BR_CARDBUS 0x07
|
---|
22877 | #define PCI_SUBCLASS_BR_RACEWAY 0x08
|
---|
22878 | #define PCI_SUBCLASS_BR_OTHER 0x80
|
---|
22879 |
|
---|
22880 | // Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
|
---|
22881 |
|
---|
22882 | // N.B. Sub Class 00 and 01 additional info in Interface byte
|
---|
22883 |
|
---|
22884 | #define PCI_SUBCLASS_COM_SERIAL 0x00
|
---|
22885 | #define PCI_SUBCLASS_COM_PARALLEL 0x01
|
---|
22886 | #define PCI_SUBCLASS_COM_MULTIPORT 0x02
|
---|
22887 | #define PCI_SUBCLASS_COM_MODEM 0x03
|
---|
22888 | #define PCI_SUBCLASS_COM_OTHER 0x80
|
---|
22889 |
|
---|
22890 | // Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
|
---|
22891 |
|
---|
22892 | // N.B. See Interface byte for additional info.
|
---|
22893 |
|
---|
22894 | #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
|
---|
22895 | #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
|
---|
22896 | #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
|
---|
22897 | #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
|
---|
22898 | #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
|
---|
22899 | #define PCI_SUBCLASS_SYS_OTHER 0x80
|
---|
22900 |
|
---|
22901 | // Class 09 - PCI_CLASS_INPUT_DEV
|
---|
22902 |
|
---|
22903 | #define PCI_SUBCLASS_INP_KEYBOARD 0x00
|
---|
22904 | #define PCI_SUBCLASS_INP_DIGITIZER 0x01
|
---|
22905 | #define PCI_SUBCLASS_INP_MOUSE 0x02
|
---|
22906 | #define PCI_SUBCLASS_INP_SCANNER 0x03
|
---|
22907 | #define PCI_SUBCLASS_INP_GAMEPORT 0x04
|
---|
22908 | #define PCI_SUBCLASS_INP_OTHER 0x80
|
---|
22909 |
|
---|
22910 | // Class 0a - PCI_CLASS_DOCKING_STATION
|
---|
22911 |
|
---|
22912 | #define PCI_SUBCLASS_DOC_GENERIC 0x00
|
---|
22913 | #define PCI_SUBCLASS_DOC_OTHER 0x80
|
---|
22914 |
|
---|
22915 | // Class 0b - PCI_CLASS_PROCESSOR
|
---|
22916 |
|
---|
22917 | #define PCI_SUBCLASS_PROC_386 0x00
|
---|
22918 | #define PCI_SUBCLASS_PROC_486 0x01
|
---|
22919 | #define PCI_SUBCLASS_PROC_PENTIUM 0x02
|
---|
22920 | #define PCI_SUBCLASS_PROC_ALPHA 0x10
|
---|
22921 | #define PCI_SUBCLASS_PROC_POWERPC 0x20
|
---|
22922 | #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
|
---|
22923 |
|
---|
22924 | // Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
|
---|
22925 |
|
---|
22926 | #define PCI_SUBCLASS_SB_IEEE1394 0x00
|
---|
22927 | #define PCI_SUBCLASS_SB_ACCESS 0x01
|
---|
22928 | #define PCI_SUBCLASS_SB_SSA 0x02
|
---|
22929 | #define PCI_SUBCLASS_SB_USB 0x03
|
---|
22930 | #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
|
---|
22931 | #define PCI_SUBCLASS_SB_SMBUS 0x05
|
---|
22932 |
|
---|
22933 | // Class 0d - PCI_CLASS_WIRELESS_CTLR
|
---|
22934 |
|
---|
22935 | #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
|
---|
22936 | #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
|
---|
22937 | #define PCI_SUBCLASS_WIRELESS_RF 0x10
|
---|
22938 | #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
|
---|
22939 |
|
---|
22940 | // Class 0e - PCI_CLASS_INTELLIGENT_IO_CTLR
|
---|
22941 |
|
---|
22942 | #define PCI_SUBCLASS_INTIO_I2O 0x00
|
---|
22943 |
|
---|
22944 | // Class 0f - PCI_CLASS_SATELLITE_CTLR
|
---|
22945 |
|
---|
22946 | #define PCI_SUBCLASS_SAT_TV 0x01
|
---|
22947 | #define PCI_SUBCLASS_SAT_AUDIO 0x02
|
---|
22948 | #define PCI_SUBCLASS_SAT_VOICE 0x03
|
---|
22949 | #define PCI_SUBCLASS_SAT_DATA 0x04
|
---|
22950 |
|
---|
22951 | // Class 10 - PCI_CLASS_ENCRYPTION_DECRYPTION
|
---|
22952 |
|
---|
22953 | #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
|
---|
22954 | #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
|
---|
22955 | #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
|
---|
22956 |
|
---|
22957 | // Class 11 - PCI_CLASS_DATA_ACQ_SIGNAL_PROC
|
---|
22958 |
|
---|
22959 | #define PCI_SUBCLASS_DASP_DPIO 0x00
|
---|
22960 | #define PCI_SUBCLASS_DASP_OTHER 0x80
|
---|
22961 |
|
---|
22962 |
|
---|
22963 |
|
---|
22964 |
|
---|
22965 |
|
---|
22966 | //
|
---|
22967 | // Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
|
---|
22968 | //
|
---|
22969 |
|
---|
22970 | #define PCI_ADDRESS_IO_SPACE 0x00000001 // (ro)
|
---|
22971 | #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 // (ro)
|
---|
22972 | #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 // (ro)
|
---|
22973 |
|
---|
22974 | #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
|
---|
22975 | #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
|
---|
22976 | #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
|
---|
22977 |
|
---|
22978 | #define PCI_TYPE_32BIT 0
|
---|
22979 | #define PCI_TYPE_20BIT 2
|
---|
22980 | #define PCI_TYPE_64BIT 4
|
---|
22981 |
|
---|
22982 | //
|
---|
22983 | // Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
|
---|
22984 | //
|
---|
22985 |
|
---|
22986 | #define PCI_ROMADDRESS_ENABLED 0x00000001
|
---|
22987 |
|
---|
22988 |
|
---|
22989 | //
|
---|
22990 | // Reference notes for PCI configuration fields:
|
---|
22991 | //
|
---|
22992 | // ro these field are read only. changes to these fields are ignored
|
---|
22993 | //
|
---|
22994 | // ro+ these field are intended to be read only and should be initialized
|
---|
22995 | // by the system to their proper values. However, driver may change
|
---|
22996 | // these settings.
|
---|
22997 | //
|
---|
22998 | // ---
|
---|
22999 | //
|
---|
23000 | // All resources consumed by a PCI device start as unitialized
|
---|
23001 | // under NT. An uninitialized memory or I/O base address can be
|
---|
23002 | // determined by checking it's corresponding enabled bit in the
|
---|
23003 | // PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
|
---|
23004 | // if it contains the value of -1.
|
---|
23005 | //
|
---|
23006 |
|
---|
23007 |
|
---|
23008 |
|
---|
23009 |
|
---|
23010 | //
|
---|
23011 | // Portable portion of HAL & HAL bus extender definitions for BUSHANDLER
|
---|
23012 | // BusData for installed PCI buses.
|
---|
23013 | //
|
---|
23014 |
|
---|
23015 | typedef VOID
|
---|
23016 | (*PciPin2Line) (
|
---|
23017 | IN struct _BUS_HANDLER *BusHandler,
|
---|
23018 | IN struct _BUS_HANDLER *RootHandler,
|
---|
23019 | IN PCI_SLOT_NUMBER SlotNumber,
|
---|
23020 | IN PPCI_COMMON_CONFIG PciData
|
---|
23021 | );
|
---|
23022 |
|
---|
23023 | typedef VOID
|
---|
23024 | (*PciLine2Pin) (
|
---|
23025 | IN struct _BUS_HANDLER *BusHandler,
|
---|
23026 | IN struct _BUS_HANDLER *RootHandler,
|
---|
23027 | IN PCI_SLOT_NUMBER SlotNumber,
|
---|
23028 | IN PPCI_COMMON_CONFIG PciNewData,
|
---|
23029 | IN PPCI_COMMON_CONFIG PciOldData
|
---|
23030 | );
|
---|
23031 |
|
---|
23032 | typedef VOID
|
---|
23033 | (*PciReadWriteConfig) (
|
---|
23034 | IN struct _BUS_HANDLER *BusHandler,
|
---|
23035 | IN PCI_SLOT_NUMBER Slot,
|
---|
23036 | IN PVOID Buffer,
|
---|
23037 | IN ULONG Offset,
|
---|
23038 | IN ULONG Length
|
---|
23039 | );
|
---|
23040 |
|
---|
23041 | #define PCI_DATA_TAG ' ICP'
|
---|
23042 | #define PCI_DATA_VERSION 1
|
---|
23043 |
|
---|
23044 | typedef struct _PCIBUSDATA {
|
---|
23045 | ULONG Tag;
|
---|
23046 | ULONG Version;
|
---|
23047 | PciReadWriteConfig ReadConfig;
|
---|
23048 | PciReadWriteConfig WriteConfig;
|
---|
23049 | PciPin2Line Pin2Line;
|
---|
23050 | PciLine2Pin Line2Pin;
|
---|
23051 | PCI_SLOT_NUMBER ParentSlot;
|
---|
23052 | PVOID Reserved[4];
|
---|
23053 | } PCIBUSDATA, *PPCIBUSDATA;
|
---|
23054 |
|
---|
23055 | typedef ULONG (*PCI_READ_WRITE_CONFIG)(
|
---|
23056 | IN PVOID Context,
|
---|
23057 | IN UCHAR BusOffset,
|
---|
23058 | IN ULONG Slot,
|
---|
23059 | IN PVOID Buffer,
|
---|
23060 | IN ULONG Offset,
|
---|
23061 | IN ULONG Length
|
---|
23062 | );
|
---|
23063 |
|
---|
23064 | typedef VOID (*PCI_PIN_TO_LINE)(
|
---|
23065 | IN PVOID Context,
|
---|
23066 | IN PPCI_COMMON_CONFIG PciData
|
---|
23067 | );
|
---|
23068 |
|
---|
23069 | typedef VOID (*PCI_LINE_TO_PIN)(
|
---|
23070 | IN PVOID Context,
|
---|
23071 | IN PPCI_COMMON_CONFIG PciNewData,
|
---|
23072 | IN PPCI_COMMON_CONFIG PciOldData
|
---|
23073 | );
|
---|
23074 |
|
---|
23075 | typedef struct _PCI_BUS_INTERFACE_STANDARD {
|
---|
23076 | //
|
---|
23077 | // generic interface header
|
---|
23078 | //
|
---|
23079 | USHORT Size;
|
---|
23080 | USHORT Version;
|
---|
23081 | PVOID Context;
|
---|
23082 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
23083 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
23084 | //
|
---|
23085 | // standard PCI bus interfaces
|
---|
23086 | //
|
---|
23087 | PCI_READ_WRITE_CONFIG ReadConfig;
|
---|
23088 | PCI_READ_WRITE_CONFIG WriteConfig;
|
---|
23089 | PCI_PIN_TO_LINE PinToLine;
|
---|
23090 | PCI_LINE_TO_PIN LineToPin;
|
---|
23091 | } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
|
---|
23092 |
|
---|
23093 | #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
|
---|
23094 |
|
---|
23095 |
|
---|
23096 |
|
---|
23097 | #define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1
|
---|
23098 |
|
---|
23099 | //
|
---|
23100 | // Flags for PCI_DEVICE_PRESENCE_PARAMETERS
|
---|
23101 | //
|
---|
23102 | #define PCI_USE_SUBSYSTEM_IDS 0x00000001
|
---|
23103 | #define PCI_USE_REVISION 0x00000002
|
---|
23104 | // The following flags are only valid for IsDevicePresentEx
|
---|
23105 | #define PCI_USE_VENDEV_IDS 0x00000004
|
---|
23106 | #define PCI_USE_CLASS_SUBCLASS 0x00000008
|
---|
23107 | #define PCI_USE_PROGIF 0x00000010
|
---|
23108 | #define PCI_USE_LOCAL_BUS 0x00000020
|
---|
23109 | #define PCI_USE_LOCAL_DEVICE 0x00000040
|
---|
23110 |
|
---|
23111 | //
|
---|
23112 | // Search parameters structure for IsDevicePresentEx
|
---|
23113 | //
|
---|
23114 | typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
|
---|
23115 |
|
---|
23116 | ULONG Size;
|
---|
23117 | ULONG Flags;
|
---|
23118 |
|
---|
23119 | USHORT VendorID;
|
---|
23120 | USHORT DeviceID;
|
---|
23121 | UCHAR RevisionID;
|
---|
23122 | USHORT SubVendorID;
|
---|
23123 | USHORT SubSystemID;
|
---|
23124 | UCHAR BaseClass;
|
---|
23125 | UCHAR SubClass;
|
---|
23126 | UCHAR ProgIf;
|
---|
23127 |
|
---|
23128 | } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
|
---|
23129 |
|
---|
23130 | typedef
|
---|
23131 | BOOLEAN
|
---|
23132 | (*PPCI_IS_DEVICE_PRESENT) (
|
---|
23133 | IN USHORT VendorID,
|
---|
23134 | IN USHORT DeviceID,
|
---|
23135 | IN UCHAR RevisionID,
|
---|
23136 | IN USHORT SubVendorID,
|
---|
23137 | IN USHORT SubSystemID,
|
---|
23138 | IN ULONG Flags
|
---|
23139 | );
|
---|
23140 |
|
---|
23141 | typedef
|
---|
23142 | BOOLEAN
|
---|
23143 | (*PPCI_IS_DEVICE_PRESENT_EX) (
|
---|
23144 | IN PVOID Context,
|
---|
23145 | IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
|
---|
23146 | );
|
---|
23147 |
|
---|
23148 | typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
|
---|
23149 | //
|
---|
23150 | // generic interface header
|
---|
23151 | //
|
---|
23152 | USHORT Size;
|
---|
23153 | USHORT Version;
|
---|
23154 | PVOID Context;
|
---|
23155 | PINTERFACE_REFERENCE InterfaceReference;
|
---|
23156 | PINTERFACE_DEREFERENCE InterfaceDereference;
|
---|
23157 | //
|
---|
23158 | // pci device info
|
---|
23159 | //
|
---|
23160 | PPCI_IS_DEVICE_PRESENT IsDevicePresent;
|
---|
23161 |
|
---|
23162 | PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
|
---|
23163 |
|
---|
23164 | } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
|
---|
23165 |
|
---|
23166 |
|
---|
23167 |
|
---|
23168 |
|
---|
23169 | #ifdef POOL_TAGGING
|
---|
23170 | #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,' kdD')
|
---|
23171 | #define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,' kdD')
|
---|
23172 | #endif
|
---|
23173 |
|
---|
23174 | extern POBJECT_TYPE *IoFileObjectType;
|
---|
23175 | extern POBJECT_TYPE *ExEventObjectType;
|
---|
23176 | extern POBJECT_TYPE *ExSemaphoreObjectType;
|
---|
23177 |
|
---|
23178 | //
|
---|
23179 | // Define exported ZwXxx routines to device drivers.
|
---|
23180 | //
|
---|
23181 |
|
---|
23182 | NTSYSAPI
|
---|
23183 | NTSTATUS
|
---|
23184 | NTAPI
|
---|
23185 | ZwCreateFile(
|
---|
23186 | OUT PHANDLE FileHandle,
|
---|
23187 | IN ACCESS_MASK DesiredAccess,
|
---|
23188 | IN POBJECT_ATTRIBUTES ObjectAttributes,
|
---|
23189 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
23190 | IN PLARGE_INTEGER AllocationSize OPTIONAL,
|
---|
23191 | IN ULONG FileAttributes,
|
---|
23192 | IN ULONG ShareAccess,
|
---|
23193 | IN ULONG CreateDisposition,
|
---|
23194 | IN ULONG CreateOptions,
|
---|
23195 | IN PVOID EaBuffer OPTIONAL,
|
---|
23196 | IN ULONG EaLength
|
---|
23197 | );
|
---|
23198 |
|
---|
23199 | NTSYSAPI
|
---|
23200 | NTSTATUS
|
---|
23201 | NTAPI
|
---|
23202 | ZwOpenFile(
|
---|
23203 | OUT PHANDLE FileHandle,
|
---|
23204 | IN ACCESS_MASK DesiredAccess,
|
---|
23205 | IN POBJECT_ATTRIBUTES ObjectAttributes,
|
---|
23206 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
23207 | IN ULONG ShareAccess,
|
---|
23208 | IN ULONG OpenOptions
|
---|
23209 | );
|
---|
23210 |
|
---|
23211 | NTSYSAPI
|
---|
23212 | NTSTATUS
|
---|
23213 | NTAPI
|
---|
23214 | ZwQueryInformationFile(
|
---|
23215 | IN HANDLE FileHandle,
|
---|
23216 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
23217 | OUT PVOID FileInformation,
|
---|
23218 | IN ULONG Length,
|
---|
23219 | IN FILE_INFORMATION_CLASS FileInformationClass
|
---|
23220 | );
|
---|
23221 |
|
---|
23222 | NTSYSAPI
|
---|
23223 | NTSTATUS
|
---|
23224 | NTAPI
|
---|
23225 | ZwSetInformationFile(
|
---|
23226 | IN HANDLE FileHandle,
|
---|
23227 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
23228 | IN PVOID FileInformation,
|
---|
23229 | IN ULONG Length,
|
---|
23230 | IN FILE_INFORMATION_CLASS FileInformationClass
|
---|
23231 | );
|
---|
23232 |
|
---|
23233 | NTSYSAPI
|
---|
23234 | NTSTATUS
|
---|
23235 | NTAPI
|
---|
23236 | ZwReadFile(
|
---|
23237 | IN HANDLE FileHandle,
|
---|
23238 | IN HANDLE Event OPTIONAL,
|
---|
23239 | IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
---|
23240 | IN PVOID ApcContext OPTIONAL,
|
---|
23241 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
23242 | OUT PVOID Buffer,
|
---|
23243 | IN ULONG Length,
|
---|
23244 | IN PLARGE_INTEGER ByteOffset OPTIONAL,
|
---|
23245 | IN PULONG Key OPTIONAL
|
---|
23246 | );
|
---|
23247 |
|
---|
23248 | NTSYSAPI
|
---|
23249 | NTSTATUS
|
---|
23250 | NTAPI
|
---|
23251 | ZwWriteFile(
|
---|
23252 | IN HANDLE FileHandle,
|
---|
23253 | IN HANDLE Event OPTIONAL,
|
---|
23254 | IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
---|
23255 | IN PVOID ApcContext OPTIONAL,
|
---|
23256 | OUT PIO_STATUS_BLOCK IoStatusBlock,
|
---|
23257 | IN PVOID Buffer,
|
---|
23258 | IN ULONG Length,
|
---|
23259 | IN PLARGE_INTEGER ByteOffset OPTIONAL,
|
---|
23260 | IN PULONG Key OPTIONAL
|
---|
23261 | );
|
---|
23262 |
|
---|
23263 | NTSYSAPI
|
---|
23264 | NTSTATUS
|
---|
23265 | NTAPI
|
---|
23266 | ZwClose(
|
---|
23267 | IN HANDLE Handle
|
---|
23268 | );
|
---|
23269 |
|
---|
23270 | NTSYSAPI
|
---|
23271 | NTSTATUS
|
---|
23272 | NTAPI
|
---|
23273 | ZwCreateDirectoryObject(
|
---|
23274 | OUT PHANDLE DirectoryHandle,
|
---|
23275 | IN ACCESS_MASK DesiredAccess,
|
---|
23276 | IN POBJECT_ATTRIBUTES ObjectAttributes
|
---|
23277 | );
|
---|
23278 |
|
---|
23279 | NTSYSAPI
|
---|
23280 | NTSTATUS
|
---|
23281 | NTAPI
|
---|
23282 | ZwMakeTemporaryObject(
|
---|
23283 | IN HANDLE Handle
|
---|
23284 | );
|
---|
23285 |
|
---|
23286 | NTSYSAPI
|
---|
23287 | NTSTATUS
|
---|
23288 | NTAPI
|
---|
23289 | ZwCreateSection (
|
---|
23290 | OUT PHANDLE SectionHandle,
|
---|
23291 | IN ACCESS_MASK DesiredAccess,
|
---|
23292 | IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
---|
23293 | IN PLARGE_INTEGER MaximumSize OPTIONAL,
|
---|
23294 | IN ULONG SectionPageProtection,
|
---|
23295 | IN ULONG AllocationAttributes,
|
---|
23296 | IN HANDLE FileHandle OPTIONAL
|
---|
23297 | );
|
---|
23298 |
|
---|
23299 | NTSYSAPI
|
---|
23300 | NTSTATUS
|
---|
23301 | NTAPI
|
---|
23302 | ZwOpenSection(
|
---|
23303 | OUT PHANDLE SectionHandle,
|
---|
23304 | IN ACCESS_MASK DesiredAccess,
|
---|
23305 | IN POBJECT_ATTRIBUTES ObjectAttributes
|
---|
23306 | );
|
---|
23307 |
|
---|
23308 | NTSYSAPI
|
---|
23309 | NTSTATUS
|
---|
23310 | NTAPI
|
---|
23311 | ZwMapViewOfSection(
|
---|
23312 | IN HANDLE SectionHandle,
|
---|
23313 | IN HANDLE ProcessHandle,
|
---|
23314 | IN OUT PVOID *BaseAddress,
|
---|
23315 | IN ULONG ZeroBits,
|
---|
23316 | IN SIZE_T CommitSize,
|
---|
23317 | IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
|
---|
23318 | IN OUT PSIZE_T ViewSize,
|
---|
23319 | IN SECTION_INHERIT InheritDisposition,
|
---|
23320 | IN ULONG AllocationType,
|
---|
23321 | IN ULONG Protect
|
---|
23322 | );
|
---|
23323 |
|
---|
23324 | NTSYSAPI
|
---|
23325 | NTSTATUS
|
---|
23326 | NTAPI
|
---|
23327 | ZwUnmapViewOfSection(
|
---|
23328 | IN HANDLE ProcessHandle,
|
---|
23329 | IN PVOID BaseAddress
|
---|
23330 | );
|
---|
23331 |
|
---|
23332 | NTSYSAPI
|
---|
23333 | NTSTATUS
|
---|
23334 | NTAPI
|
---|
23335 | ZwSetInformationThread(
|
---|
23336 | IN HANDLE ThreadHandle,
|
---|
23337 | IN THREADINFOCLASS ThreadInformationClass,
|
---|
23338 | IN PVOID ThreadInformation,
|
---|
23339 | IN ULONG ThreadInformationLength
|
---|
23340 | );
|
---|
23341 |
|
---|
23342 | NTSYSAPI
|
---|
23343 | NTSTATUS
|
---|
23344 | NTAPI
|
---|
23345 | ZwCreateKey(
|
---|
23346 | OUT PHANDLE KeyHandle,
|
---|
23347 | IN ACCESS_MASK DesiredAccess,
|
---|
23348 | IN POBJECT_ATTRIBUTES ObjectAttributes,
|
---|
23349 | IN ULONG TitleIndex,
|
---|
23350 | IN PUNICODE_STRING Class OPTIONAL,
|
---|
23351 | IN ULONG CreateOptions,
|
---|
23352 | OUT PULONG Disposition OPTIONAL
|
---|
23353 | );
|
---|
23354 |
|
---|
23355 | NTSYSAPI
|
---|
23356 | NTSTATUS
|
---|
23357 | NTAPI
|
---|
23358 | ZwOpenKey(
|
---|
23359 | OUT PHANDLE KeyHandle,
|
---|
23360 | IN ACCESS_MASK DesiredAccess,
|
---|
23361 | IN POBJECT_ATTRIBUTES ObjectAttributes
|
---|
23362 | );
|
---|
23363 |
|
---|
23364 | NTSYSAPI
|
---|
23365 | NTSTATUS
|
---|
23366 | NTAPI
|
---|
23367 | ZwDeleteKey(
|
---|
23368 | IN HANDLE KeyHandle
|
---|
23369 | );
|
---|
23370 |
|
---|
23371 | NTSYSAPI
|
---|
23372 | NTSTATUS
|
---|
23373 | NTAPI
|
---|
23374 | ZwDeleteValueKey(
|
---|
23375 | IN HANDLE KeyHandle,
|
---|
23376 | IN PUNICODE_STRING ValueName
|
---|
23377 | );
|
---|
23378 |
|
---|
23379 | NTSYSAPI
|
---|
23380 | NTSTATUS
|
---|
23381 | NTAPI
|
---|
23382 | ZwEnumerateKey(
|
---|
23383 | IN HANDLE KeyHandle,
|
---|
23384 | IN ULONG Index,
|
---|
23385 | IN KEY_INFORMATION_CLASS KeyInformationClass,
|
---|
23386 | OUT PVOID KeyInformation,
|
---|
23387 | IN ULONG Length,
|
---|
23388 | OUT PULONG ResultLength
|
---|
23389 | );
|
---|
23390 |
|
---|
23391 | NTSYSAPI
|
---|
23392 | NTSTATUS
|
---|
23393 | NTAPI
|
---|
23394 | ZwEnumerateValueKey(
|
---|
23395 | IN HANDLE KeyHandle,
|
---|
23396 | IN ULONG Index,
|
---|
23397 | IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
|
---|
23398 | OUT PVOID KeyValueInformation,
|
---|
23399 | IN ULONG Length,
|
---|
23400 | OUT PULONG ResultLength
|
---|
23401 | );
|
---|
23402 |
|
---|
23403 | NTSYSAPI
|
---|
23404 | NTSTATUS
|
---|
23405 | NTAPI
|
---|
23406 | ZwFlushKey(
|
---|
23407 | IN HANDLE KeyHandle
|
---|
23408 | );
|
---|
23409 |
|
---|
23410 | NTSYSAPI
|
---|
23411 | NTSTATUS
|
---|
23412 | NTAPI
|
---|
23413 | ZwQueryKey(
|
---|
23414 | IN HANDLE KeyHandle,
|
---|
23415 | IN KEY_INFORMATION_CLASS KeyInformationClass,
|
---|
23416 | OUT PVOID KeyInformation,
|
---|
23417 | IN ULONG Length,
|
---|
23418 | OUT PULONG ResultLength
|
---|
23419 | );
|
---|
23420 |
|
---|
23421 | NTSYSAPI
|
---|
23422 | NTSTATUS
|
---|
23423 | NTAPI
|
---|
23424 | ZwQueryValueKey(
|
---|
23425 | IN HANDLE KeyHandle,
|
---|
23426 | IN PUNICODE_STRING ValueName,
|
---|
23427 | IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
|
---|
23428 | OUT PVOID KeyValueInformation,
|
---|
23429 | IN ULONG Length,
|
---|
23430 | OUT PULONG ResultLength
|
---|
23431 | );
|
---|
23432 |
|
---|
23433 | NTSYSAPI
|
---|
23434 | NTSTATUS
|
---|
23435 | NTAPI
|
---|
23436 | ZwSetValueKey(
|
---|
23437 | IN HANDLE KeyHandle,
|
---|
23438 | IN PUNICODE_STRING ValueName,
|
---|
23439 | IN ULONG TitleIndex OPTIONAL,
|
---|
23440 | IN ULONG Type,
|
---|
23441 | IN PVOID Data,
|
---|
23442 | IN ULONG DataSize
|
---|
23443 | );
|
---|
23444 |
|
---|
23445 | NTSYSAPI
|
---|
23446 | NTSTATUS
|
---|
23447 | NTAPI
|
---|
23448 | ZwOpenSymbolicLinkObject(
|
---|
23449 | OUT PHANDLE LinkHandle,
|
---|
23450 | IN ACCESS_MASK DesiredAccess,
|
---|
23451 | IN POBJECT_ATTRIBUTES ObjectAttributes
|
---|
23452 | );
|
---|
23453 |
|
---|
23454 | NTSYSAPI
|
---|
23455 | NTSTATUS
|
---|
23456 | NTAPI
|
---|
23457 | ZwQuerySymbolicLinkObject(
|
---|
23458 | IN HANDLE LinkHandle,
|
---|
23459 | IN OUT PUNICODE_STRING LinkTarget,
|
---|
23460 | OUT PULONG ReturnedLength OPTIONAL
|
---|
23461 | );
|
---|
23462 |
|
---|
23463 | NTSTATUS
|
---|
23464 | ZwCreateTimer (
|
---|
23465 | OUT PHANDLE TimerHandle,
|
---|
23466 | IN ACCESS_MASK DesiredAccess,
|
---|
23467 | IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
---|
23468 | IN TIMER_TYPE TimerType
|
---|
23469 | );
|
---|
23470 |
|
---|
23471 | NTSTATUS
|
---|
23472 | ZwOpenTimer (
|
---|
23473 | OUT PHANDLE TimerHandle,
|
---|
23474 | IN ACCESS_MASK DesiredAccess,
|
---|
23475 | IN POBJECT_ATTRIBUTES ObjectAttributes
|
---|
23476 | );
|
---|
23477 |
|
---|
23478 | NTSTATUS
|
---|
23479 | ZwCancelTimer (
|
---|
23480 | IN HANDLE TimerHandle,
|
---|
23481 | OUT PBOOLEAN CurrentState OPTIONAL
|
---|
23482 | );
|
---|
23483 |
|
---|
23484 | NTSTATUS
|
---|
23485 | ZwSetTimer (
|
---|
23486 | IN HANDLE TimerHandle,
|
---|
23487 | IN PLARGE_INTEGER DueTime,
|
---|
23488 | IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
|
---|
23489 | IN PVOID TimerContext OPTIONAL,
|
---|
23490 | IN BOOLEAN WakeTimer,
|
---|
23491 | IN LONG Period OPTIONAL,
|
---|
23492 | OUT PBOOLEAN PreviousState OPTIONAL
|
---|
23493 | );
|
---|
23494 |
|
---|
23495 | #ifdef VERIFIER_DDK_EXTENSIONS
|
---|
23496 | #include <ddk_ext.h>
|
---|
23497 | #endif
|
---|
23498 |
|
---|
23499 | #endif // _NTDDK_
|
---|
23500 |
|
---|