Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ntosdef.h

Go to the documentation of this file.
00001 /*++ BUILD Version: 0003 // Increment this if a change has global effects 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 ntosdef.h 00008 00009 Abstract: 00010 00011 Common type definitions for the NTOS component that are private to 00012 NTOS, but shared between NTOS sub-components. 00013 00014 Author: 00015 00016 Steve Wood (stevewo) 08-May-1989 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #ifndef _NTOSDEF_ 00023 #define _NTOSDEF_ 00024 00025 // 00026 // Define interlocked sequenced list structure. 00027 // 00028 // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntndis 00029 00030 #if defined(_WIN64) 00031 00032 typedef union _SLIST_HEADER { 00033 ULONGLONG Alignment; 00034 struct { 00035 ULONGLONG Depth : 16; 00036 ULONGLONG Sequence : 8; 00037 ULONGLONG Next : 40; 00038 }; 00039 } SLIST_HEADER, *PSLIST_HEADER; 00040 00041 #else 00042 00043 typedef union _SLIST_HEADER { 00044 ULONGLONG Alignment; 00045 struct { 00046 SINGLE_LIST_ENTRY Next; 00047 USHORT Depth; 00048 USHORT Sequence; 00049 }; 00050 } SLIST_HEADER, *PSLIST_HEADER; 00051 00052 #endif 00053 00054 // end_ntddk end_wdm end_nthal end_ntifs end_ntndis 00055 00056 // 00057 // Define per processor nonpaged lookaside list descriptor structure. 00058 // 00059 00060 struct _NPAGED_LOOKASIDE_LIST; 00061 00062 typedef struct _PP_LOOKASIDE_LIST { 00063 struct _NPAGED_LOOKASIDE_LIST *P; 00064 struct _NPAGED_LOOKASIDE_LIST *L; 00065 } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST; 00066 00067 // begin_nthal 00068 00069 // 00070 // Define per processor lock queue structure. 00071 // 00072 // N.B. The lock field of the spin lock queue structure contains the address 00073 // of the associated kernel spin lock, an owner bit, and a lock bit. Bit 00074 // 0 of the spin lock address is the wait bit and bit 1 is the owner bit. 00075 // The use of this field is such that the bits can be set and cleared 00076 // noninterlocked, however, the back pointer must be preserved. 00077 // 00078 // The lock wait bit is set when a processor enqueues itself on the lock 00079 // queue and it is not the only entry in the queue. The processor will 00080 // spin on this bit waiting for the lock to be granted. 00081 // 00082 // The owner bit is set when the processor owns the respective lock. 00083 // 00084 // The next field of the spin lock queue structure is used to line the 00085 // queued lock structures together in fifo order. It also can set set and 00086 // cleared noninterlocked. 00087 // 00088 00089 #define LOCK_QUEUE_WAIT 1 00090 #define LOCK_QUEUE_OWNER 2 00091 00092 typedef enum _KSPIN_LOCK_QUEUE_NUMBER { 00093 LockQueueDispatcherLock, 00094 LockQueueContextSwapLock, 00095 LockQueuePfnLock, 00096 LockQueueSystemSpaceLock, 00097 LockQueueVacbLock, 00098 LockQueueMasterLock, 00099 LockQueueMaximumLock 00100 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; 00101 00102 typedef struct _KSPIN_LOCK_QUEUE { 00103 struct _KSPIN_LOCK_QUEUE *Next; 00104 PKSPIN_LOCK Lock; 00105 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; 00106 00107 // end_nthal 00108 00109 // 00110 // Define the number of small pool lists. 00111 // 00112 // N.B. This value is used in pool.h and is used to allocate single entry 00113 // lookaside lists in the processor block of each processor. 00114 00115 #define POOL_SMALL_LISTS 8 00116 00117 // begin_ntddk begin_wdm begin_nthal begin_ntifs 00118 00119 // 00120 // Define alignment macros to align structure sizes and pointers up and down. 00121 // 00122 00123 #define ALIGN_DOWN(length, type) \ 00124 ((ULONG)(length) & ~(sizeof(type) - 1)) 00125 00126 #define ALIGN_UP(length, type) \ 00127 (ALIGN_DOWN(((ULONG)(length) + sizeof(type) - 1), type)) 00128 00129 #define ALIGN_DOWN_POINTER(address, type) \ 00130 ((PVOID)((ULONG_PTR)(address) & ~((ULONG_PTR)sizeof(type) - 1))) 00131 00132 #define ALIGN_UP_POINTER(address, type) \ 00133 (ALIGN_DOWN_POINTER(((ULONG_PTR)(address) + sizeof(type) - 1), type)) 00134 00135 #define POOL_TAGGING 1 00136 00137 #ifndef DBG 00138 #define DBG 0 00139 #endif 00140 00141 #if DBG 00142 #define IF_DEBUG if (TRUE) 00143 #else 00144 #define IF_DEBUG if (FALSE) 00145 #endif 00146 00147 #if DEVL 00148 00149 // end_ntddk end_wdm end_nthal end_ntifs 00150 // 00151 // Global flag set by NtPartyByNumber(6) controls behaviour of 00152 // NT. See \nt\sdk\inc\ntexapi.h for flag definitions 00153 // 00154 // begin_ntddk begin_wdm begin_nthal begin_ntifs 00155 00156 extern ULONG NtGlobalFlag; 00157 00158 #define IF_NTOS_DEBUG( FlagName ) \ 00159 if (NtGlobalFlag & (FLG_ ## FlagName)) 00160 00161 #else 00162 #define IF_NTOS_DEBUG( FlagName ) if (FALSE) 00163 #endif 00164 00165 // 00166 // Kernel definitions that need to be here for forward reference purposes 00167 // 00168 00169 // begin_ntndis 00170 // 00171 // Processor modes. 00172 // 00173 00174 typedef CCHAR KPROCESSOR_MODE; 00175 00176 typedef enum _MODE { 00177 KernelMode, 00178 UserMode, 00179 MaximumMode 00180 } MODE; 00181 00182 // end_ntndis 00183 // 00184 // APC function types 00185 // 00186 00187 // 00188 // Put in an empty definition for the KAPC so that the 00189 // routines can reference it before it is declared. 00190 // 00191 00192 struct _KAPC; 00193 00194 typedef 00195 VOID 00196 (*PKNORMAL_ROUTINE) ( 00197 IN PVOID NormalContext, 00198 IN PVOID SystemArgument1, 00199 IN PVOID SystemArgument2 00200 ); 00201 00202 typedef 00203 VOID 00204 (*PKKERNEL_ROUTINE) ( 00205 IN struct _KAPC *Apc, 00206 IN OUT PKNORMAL_ROUTINE *NormalRoutine, 00207 IN OUT PVOID *NormalContext, 00208 IN OUT PVOID *SystemArgument1, 00209 IN OUT PVOID *SystemArgument2 00210 ); 00211 00212 typedef 00213 VOID 00214 (*PKRUNDOWN_ROUTINE) ( 00215 IN struct _KAPC *Apc 00216 ); 00217 00218 typedef 00219 BOOLEAN 00220 (*PKSYNCHRONIZE_ROUTINE) ( 00221 IN PVOID SynchronizeContext 00222 ); 00223 00224 typedef 00225 BOOLEAN 00226 (*PKTRANSFER_ROUTINE) ( 00227 VOID 00228 ); 00229 00230 // 00231 // 00232 // Asynchronous Procedure Call (APC) object 00233 // 00234 00235 typedef struct _KAPC { 00236 CSHORT Type; 00237 CSHORT Size; 00238 ULONG Spare0; 00239 struct _KTHREAD *Thread; 00240 LIST_ENTRY ApcListEntry; 00241 PKKERNEL_ROUTINE KernelRoutine; 00242 PKRUNDOWN_ROUTINE RundownRoutine; 00243 PKNORMAL_ROUTINE NormalRoutine; 00244 PVOID NormalContext; 00245 00246 // 00247 // N.B. The following two members MUST be together. 00248 // 00249 00250 PVOID SystemArgument1; 00251 PVOID SystemArgument2; 00252 CCHAR ApcStateIndex; 00253 KPROCESSOR_MODE ApcMode; 00254 BOOLEAN Inserted; 00255 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; 00256 00257 // begin_ntndis 00258 // 00259 // DPC routine 00260 // 00261 00262 struct _KDPC; 00263 00264 typedef 00265 VOID 00266 (*PKDEFERRED_ROUTINE) ( 00267 IN struct _KDPC *Dpc, 00268 IN PVOID DeferredContext, 00269 IN PVOID SystemArgument1, 00270 IN PVOID SystemArgument2 00271 ); 00272 00273 // 00274 // Define DPC importance. 00275 // 00276 // LowImportance - Queue DPC at end of target DPC queue. 00277 // MediumImportance - Queue DPC at end of target DPC queue. 00278 // HighImportance - Queue DPC at front of target DPC DPC queue. 00279 // 00280 // If there is currently a DPC active on the target processor, or a DPC 00281 // interrupt has already been requested on the target processor when a 00282 // DPC is queued, then no further action is necessary. The DPC will be 00283 // executed on the target processor when its queue entry is processed. 00284 // 00285 // If there is not a DPC active on the target processor and a DPC interrupt 00286 // has not been requested on the target processor, then the exact treatment 00287 // of the DPC is dependent on whether the host system is a UP system or an 00288 // MP system. 00289 // 00290 // UP system. 00291 // 00292 // If the DPC is of medium or high importance, the current DPC queue depth 00293 // is greater than the maximum target depth, or current DPC request rate is 00294 // less the minimum target rate, then a DPC interrupt is requested on the 00295 // host processor and the DPC will be processed when the interrupt occurs. 00296 // Otherwise, no DPC interupt is requested and the DPC execution will be 00297 // delayed until the DPC queue depth is greater that the target depth or the 00298 // minimum DPC rate is less than the target rate. 00299 // 00300 // MP system. 00301 // 00302 // If the DPC is being queued to another processor and the depth of the DPC 00303 // queue on the target processor is greater than the maximum target depth or 00304 // the DPC is of high importance, then a DPC interrupt is requested on the 00305 // target processor and the DPC will be processed when the interrupt occurs. 00306 // Otherwise, the DPC execution will be delayed on the target processor until 00307 // the DPC queue depth on the target processor is greater that the maximum 00308 // target depth or the minimum DPC rate on the target processor is less than 00309 // the target mimimum rate. 00310 // 00311 // If the DPC is being queued to the current processor and the DPC is not of 00312 // low importance, the current DPC queue depth is greater than the maximum 00313 // target depth, or the minimum DPC rate is less than the minimum target rate, 00314 // then a DPC interrupt is request on the current processor and the DPV will 00315 // be processed whne the interrupt occurs. Otherwise, no DPC interupt is 00316 // requested and the DPC execution will be delayed until the DPC queue depth 00317 // is greater that the target depth or the minimum DPC rate is less than the 00318 // target rate. 00319 // 00320 00321 typedef enum _KDPC_IMPORTANCE { 00322 LowImportance, 00323 MediumImportance, 00324 HighImportance 00325 } KDPC_IMPORTANCE; 00326 00327 // 00328 // Deferred Procedure Call (DPC) object 00329 // 00330 00331 typedef struct _KDPC { 00332 CSHORT Type; 00333 UCHAR Number; 00334 UCHAR Importance; 00335 LIST_ENTRY DpcListEntry; 00336 PKDEFERRED_ROUTINE DeferredRoutine; 00337 PVOID DeferredContext; 00338 PVOID SystemArgument1; 00339 PVOID SystemArgument2; 00340 PULONG_PTR Lock; 00341 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC; 00342 00343 // 00344 // Interprocessor interrupt worker routine function prototype. 00345 // 00346 00347 typedef PVOID PKIPI_CONTEXT; 00348 00349 typedef 00350 VOID 00351 (*PKIPI_WORKER)( 00352 IN PKIPI_CONTEXT PacketContext, 00353 IN PVOID Parameter1, 00354 IN PVOID Parameter2, 00355 IN PVOID Parameter3 00356 ); 00357 00358 // 00359 // Define interprocessor interrupt performance counters. 00360 // 00361 00362 typedef struct _KIPI_COUNTS { 00363 ULONG Freeze; 00364 ULONG Packet; 00365 ULONG DPC; 00366 ULONG APC; 00367 ULONG FlushSingleTb; 00368 ULONG FlushMultipleTb; 00369 ULONG FlushEntireTb; 00370 ULONG GenericCall; 00371 ULONG ChangeColor; 00372 ULONG SweepDcache; 00373 ULONG SweepIcache; 00374 ULONG SweepIcacheRange; 00375 ULONG FlushIoBuffers; 00376 ULONG GratuitousDPC; 00377 } KIPI_COUNTS, *PKIPI_COUNTS; 00378 00379 #if defined(NT_UP) 00380 00381 #define HOT_STATISTIC(a) a 00382 00383 #else 00384 00385 #define HOT_STATISTIC(a) (KeGetCurrentPrcb()->a) 00386 00387 #endif 00388 00389 // 00390 // I/O system definitions. 00391 // 00392 // Define a Memory Descriptor List (MDL) 00393 // 00394 // An MDL describes pages in a virtual buffer in terms of physical pages. The 00395 // pages associated with the buffer are described in an array that is allocated 00396 // just after the MDL header structure itself. In a future compiler this will 00397 // be placed at: 00398 // 00399 // ULONG Pages[]; 00400 // 00401 // Until this declaration is permitted, however, one simply calculates the 00402 // base of the array by adding one to the base MDL pointer: 00403 // 00404 // Pages = (PULONG) (Mdl + 1); 00405 // 00406 // Notice that while in the context of the subject thread, the base virtual 00407 // address of a buffer mapped by an MDL may be referenced using the following: 00408 // 00409 // Mdl->StartVa | Mdl->ByteOffset 00410 // 00411 00412 00413 typedef struct _MDL { 00414 struct _MDL *Next; 00415 CSHORT Size; 00416 CSHORT MdlFlags; 00417 struct _EPROCESS *Process; 00418 PVOID MappedSystemVa; 00419 PVOID StartVa; 00420 ULONG ByteCount; 00421 ULONG ByteOffset; 00422 } MDL, *PMDL; 00423 00424 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001 00425 #define MDL_PAGES_LOCKED 0x0002 00426 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004 00427 #define MDL_ALLOCATED_FIXED_SIZE 0x0008 00428 #define MDL_PARTIAL 0x0010 00429 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020 00430 #define MDL_IO_PAGE_READ 0x0040 00431 #define MDL_WRITE_OPERATION 0x0080 00432 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100 00433 #define MDL_LOCK_HELD 0x0200 00434 #define MDL_PHYSICAL_VIEW 0x0400 00435 #define MDL_IO_SPACE 0x0800 00436 #define MDL_NETWORK_HEADER 0x1000 00437 #define MDL_MAPPING_CAN_FAIL 0x2000 00438 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000 00439 00440 00441 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \ 00442 MDL_PAGES_LOCKED | \ 00443 MDL_SOURCE_IS_NONPAGED_POOL | \ 00444 MDL_PARTIAL_HAS_BEEN_MAPPED | \ 00445 MDL_PARENT_MAPPED_SYSTEM_VA | \ 00446 MDL_LOCK_HELD | \ 00447 MDL_SYSTEM_VA | \ 00448 MDL_IO_SPACE ) 00449 00450 // end_ntndis 00451 // 00452 // switch to DBG when appropriate 00453 // 00454 00455 #if DBG 00456 #define PAGED_CODE() \ 00457 if (KeGetCurrentIrql() > APC_LEVEL) { \ 00458 KdPrint(( "EX: Pageable code called at IRQL %d\n", KeGetCurrentIrql() )); \ 00459 ASSERT(FALSE); \ 00460 } 00461 #else 00462 #define PAGED_CODE() 00463 #endif 00464 00465 // end_ntddk end_wdm end_nthal end_ntifs 00466 00467 00468 // begin_ntifs 00469 // 00470 // Data structure used to represent client security context for a thread. 00471 // This data structure is used to support impersonation. 00472 // 00473 // THE FIELDS OF THIS DATA STRUCTURE SHOULD BE CONSIDERED OPAQUE 00474 // BY ALL EXCEPT THE SECURITY ROUTINES. 00475 // 00476 00477 typedef struct _SECURITY_CLIENT_CONTEXT { 00478 SECURITY_QUALITY_OF_SERVICE SecurityQos; 00479 PACCESS_TOKEN ClientToken; 00480 BOOLEAN DirectlyAccessClientToken; 00481 BOOLEAN DirectAccessEffectiveOnly; 00482 BOOLEAN ServerIsRemote; 00483 TOKEN_CONTROL ClientTokenControl; 00484 } SECURITY_CLIENT_CONTEXT, *PSECURITY_CLIENT_CONTEXT; 00485 00486 // end_ntifs 00487 00488 // 00489 // where 00490 // 00491 // SecurityQos - is the security quality of service information in effect 00492 // for this client. This information is used when directly accessing 00493 // the client's token. In this case, the information here over-rides 00494 // the information in the client's token. If a copy of the client's 00495 // token is requested, it must be generated using this information, 00496 // not the information in the client's token. In all cases, this 00497 // information may not provide greater access than the information 00498 // in the client's token. In particular, if the client's token is 00499 // an impersonation token with an impersonation level of 00500 // "SecurityDelegation", but the information in this field indicates 00501 // an impersonation level of "SecurityIdentification", then 00502 // the server may only get a copy of the token with an Identification 00503 // level of impersonation. 00504 // 00505 // ClientToken - If the DirectlyAccessClientToken field is FALSE, 00506 // then this field contains a pointer to a duplicate of the 00507 // client's token. Otherwise, this field points directly to 00508 // the client's token. 00509 // 00510 // DirectlyAccessClientToken - This boolean flag indicates whether the 00511 // token pointed to by ClientToken is a copy of the client's token 00512 // or is a direct reference to the client's token. A value of TRUE 00513 // indicates the client's token is directly accessed, FALSE indicates 00514 // a copy has been made. 00515 // 00516 // DirectAccessEffectiveOnly - This boolean flag indicates whether the 00517 // the disabled portions of the token that is currently directly 00518 // referenced may be enabled. This field is only valid if the 00519 // DirectlyAccessClientToken field is TRUE. In that case, this 00520 // value supersedes the EffectiveOnly value in the SecurityQos 00521 // FOR THE CURRENT TOKEN ONLY! If the client changes to impersonate 00522 // another client, this value may change. This value is always 00523 // minimized by the EffectiveOnly flag in the SecurityQos field. 00524 // 00525 // ServerIsRemote - If TRUE indicates that the server of the client's 00526 // request is remote. This is used for determining the legitimacy 00527 // of certain levels of impersonation and to determine how to 00528 // track context. 00529 // 00530 // ClientTokenControl - If the ServerIsRemote flag is TRUE, and the 00531 // tracking mode is DYNAMIC, then this field contains a copy of 00532 // the TOKEN_SOURCE from the client's token to assist in deciding 00533 // whether the information at the remote server needs to be 00534 // updated to match the current state of the client's security 00535 // context. 00536 // 00537 // 00538 // NOTE: At some point, we may find it worthwhile to keep an array of 00539 // elements in this data structure, where each element of the 00540 // array contains {ClientToken, ClientTokenControl} fields. 00541 // This would allow efficient handling of the case where a client 00542 // thread was constantly switching between a couple different 00543 // contexts - presumably impersonating client's of its own. 00544 // 00545 00546 // begin_ntddk begin_wdm begin_nthal begin_ntndis begin_ntifs 00547 // 00548 // Define function decoration depending on whether a driver, a file system, 00549 // or a kernel component is being built. 00550 // 00551 // end_wdm 00552 00553 #if (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)) && !defined(_BLDR_) 00554 00555 #define NTKERNELAPI DECLSPEC_IMPORT // wdm 00556 00557 #else 00558 00559 #define NTKERNELAPI 00560 00561 #endif 00562 00563 // 00564 // Define function decoration depending on whether the HAL or other kernel 00565 // component is being build. 00566 // 00567 00568 #if !defined(_NTHAL_) && !defined(_BLDR_) 00569 00570 #define NTHALAPI DECLSPEC_IMPORT // wdm 00571 00572 #else 00573 00574 #define NTHALAPI 00575 00576 #endif 00577 00578 // end_ntddk end_nthal end_ntndis end_ntifs 00579 00580 #endif // _NTOSDEF_

Generated on Sat May 15 19:41:01 2004 for test by doxygen 1.3.7