1 $if (_WDMDDK_ || _NTDDK_) 2 /****************************************************************************** 3 * Executive Types * 4 ******************************************************************************/ 5 $endif (_WDMDDK_ || _NTDDK_) 6 $if (_WDMDDK_) 7 #define EX_RUNDOWN_ACTIVE 0x1 8 #define EX_RUNDOWN_COUNT_SHIFT 0x1 9 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) 10 11 typedef struct _FAST_MUTEX { 12 volatile LONG Count; 13 PKTHREAD Owner; 14 ULONG Contention; 15 KEVENT Event; 16 ULONG OldIrql; 17 } FAST_MUTEX, *PFAST_MUTEX; 18 19 typedef enum _SUITE_TYPE { 20 SmallBusiness, 21 Enterprise, 22 BackOffice, 23 CommunicationServer, 24 TerminalServer, 25 SmallBusinessRestricted, 26 EmbeddedNT, 27 DataCenter, 28 SingleUserTS, 29 Personal, 30 Blade, 31 EmbeddedRestricted, 32 SecurityAppliance, 33 StorageServer, 34 ComputeServer, 35 WHServer, 36 MaxSuiteType 37 } SUITE_TYPE; 38 39 typedef enum _EX_POOL_PRIORITY { 40 LowPoolPriority, 41 LowPoolPrioritySpecialPoolOverrun = 8, 42 LowPoolPrioritySpecialPoolUnderrun = 9, 43 NormalPoolPriority = 16, 44 NormalPoolPrioritySpecialPoolOverrun = 24, 45 NormalPoolPrioritySpecialPoolUnderrun = 25, 46 HighPoolPriority = 32, 47 HighPoolPrioritySpecialPoolOverrun = 40, 48 HighPoolPrioritySpecialPoolUnderrun = 41 49 } EX_POOL_PRIORITY; 50 51 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) 52 #define LOOKASIDE_ALIGN 53 #else 54 #define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN 55 #endif 56 57 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; 58 59 _IRQL_requires_same_ 60 _Function_class_(ALLOCATE_FUNCTION) 61 typedef PVOID 62 (NTAPI *PALLOCATE_FUNCTION)( 63 _In_ POOL_TYPE PoolType, 64 _In_ SIZE_T NumberOfBytes, 65 _In_ ULONG Tag); 66 67 _IRQL_requires_same_ 68 _Function_class_(ALLOCATE_FUNCTION_EX) 69 typedef PVOID 70 (NTAPI *PALLOCATE_FUNCTION_EX)( 71 _In_ POOL_TYPE PoolType, 72 _In_ SIZE_T NumberOfBytes, 73 _In_ ULONG Tag, 74 _Inout_ PLOOKASIDE_LIST_EX Lookaside); 75 76 _IRQL_requires_same_ 77 _Function_class_(FREE_FUNCTION) 78 typedef VOID 79 (NTAPI *PFREE_FUNCTION)( 80 _In_ PVOID Buffer); 81 82 _IRQL_requires_same_ 83 _Function_class_(FREE_FUNCTION_EX) 84 typedef VOID 85 (NTAPI *PFREE_FUNCTION_EX)( 86 _In_ PVOID Buffer, 87 _Inout_ PLOOKASIDE_LIST_EX Lookaside); 88 89 _IRQL_requires_same_ 90 _Function_class_(CALLBACK_FUNCTION) 91 typedef VOID 92 (NTAPI CALLBACK_FUNCTION)( 93 _In_opt_ PVOID CallbackContext, 94 _In_opt_ PVOID Argument1, 95 _In_opt_ PVOID Argument2); 96 typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; 97 98 #define GENERAL_LOOKASIDE_LAYOUT \ 99 _ANONYMOUS_UNION union { \ 100 SLIST_HEADER ListHead; \ 101 SINGLE_LIST_ENTRY SingleListHead; \ 102 } DUMMYUNIONNAME; \ 103 USHORT Depth; \ 104 USHORT MaximumDepth; \ 105 ULONG TotalAllocates; \ 106 _ANONYMOUS_UNION union { \ 107 ULONG AllocateMisses; \ 108 ULONG AllocateHits; \ 109 } DUMMYUNIONNAME2; \ 110 ULONG TotalFrees; \ 111 _ANONYMOUS_UNION union { \ 112 ULONG FreeMisses; \ 113 ULONG FreeHits; \ 114 } DUMMYUNIONNAME3; \ 115 POOL_TYPE Type; \ 116 ULONG Tag; \ 117 ULONG Size; \ 118 _ANONYMOUS_UNION union { \ 119 PALLOCATE_FUNCTION_EX AllocateEx; \ 120 PALLOCATE_FUNCTION Allocate; \ 121 } DUMMYUNIONNAME4; \ 122 _ANONYMOUS_UNION union { \ 123 PFREE_FUNCTION_EX FreeEx; \ 124 PFREE_FUNCTION Free; \ 125 } DUMMYUNIONNAME5; \ 126 LIST_ENTRY ListEntry; \ 127 ULONG LastTotalAllocates; \ 128 _ANONYMOUS_UNION union { \ 129 ULONG LastAllocateMisses; \ 130 ULONG LastAllocateHits; \ 131 } DUMMYUNIONNAME6; \ 132 ULONG Future[2]; 133 134 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE { 135 GENERAL_LOOKASIDE_LAYOUT 136 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; 137 138 typedef struct _GENERAL_LOOKASIDE_POOL { 139 GENERAL_LOOKASIDE_LAYOUT 140 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; 141 142 #define LOOKASIDE_CHECK(f) \ 143 C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) 144 145 LOOKASIDE_CHECK(TotalFrees); 146 LOOKASIDE_CHECK(Tag); 147 LOOKASIDE_CHECK(Future); 148 149 typedef struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST { 150 GENERAL_LOOKASIDE L; 151 #if !defined(_AMD64_) && !defined(_IA64_) 152 FAST_MUTEX Lock__ObsoleteButDoNotDelete; 153 #endif 154 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; 155 156 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { 157 GENERAL_LOOKASIDE L; 158 #if !defined(_AMD64_) && !defined(_IA64_) 159 KSPIN_LOCK Lock__ObsoleteButDoNotDelete; 160 #endif 161 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; 162 163 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) 164 165 typedef struct _LOOKASIDE_LIST_EX { 166 GENERAL_LOOKASIDE_POOL L; 167 } LOOKASIDE_LIST_EX; 168 169 #if (NTDDI_VERSION >= NTDDI_VISTA) 170 171 #define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL 172 #define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL 173 174 #define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 175 #define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 176 177 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 178 179 typedef struct _EX_RUNDOWN_REF { 180 _ANONYMOUS_UNION union { 181 volatile ULONG_PTR Count; 182 volatile PVOID Ptr; 183 } DUMMYUNIONNAME; 184 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; 185 186 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; 187 188 typedef enum _WORK_QUEUE_TYPE { 189 CriticalWorkQueue, 190 DelayedWorkQueue, 191 HyperCriticalWorkQueue, 192 MaximumWorkQueue 193 } WORK_QUEUE_TYPE; 194 195 _IRQL_requires_same_ 196 _Function_class_(WORKER_THREAD_ROUTINE) 197 typedef VOID 198 (NTAPI WORKER_THREAD_ROUTINE)( 199 _In_ PVOID Parameter); 200 typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; 201 202 typedef struct _WORK_QUEUE_ITEM { 203 LIST_ENTRY List; 204 PWORKER_THREAD_ROUTINE WorkerRoutine; 205 volatile PVOID Parameter; 206 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; 207 208 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; 209 210 typedef struct _OWNER_ENTRY { 211 ERESOURCE_THREAD OwnerThread; 212 _ANONYMOUS_UNION union { 213 _ANONYMOUS_STRUCT struct { 214 ULONG IoPriorityBoosted:1; 215 ULONG OwnerReferenced:1; 216 ULONG OwnerCount:30; 217 } DUMMYSTRUCTNAME; 218 ULONG TableSize; 219 } DUMMYUNIONNAME; 220 } OWNER_ENTRY, *POWNER_ENTRY; 221 222 typedef struct _ERESOURCE { 223 LIST_ENTRY SystemResourcesList; 224 POWNER_ENTRY OwnerTable; 225 SHORT ActiveCount; 226 USHORT Flag; 227 volatile PKSEMAPHORE SharedWaiters; 228 volatile PKEVENT ExclusiveWaiters; 229 OWNER_ENTRY OwnerEntry; 230 ULONG ActiveEntries; 231 ULONG ContentionCount; 232 ULONG NumberOfSharedWaiters; 233 ULONG NumberOfExclusiveWaiters; 234 #if defined(_WIN64) 235 PVOID Reserved2; 236 #endif 237 _ANONYMOUS_UNION union { 238 PVOID Address; 239 ULONG_PTR CreatorBackTraceIndex; 240 } DUMMYUNIONNAME; 241 KSPIN_LOCK SpinLock; 242 } ERESOURCE, *PERESOURCE; 243 244 /* ERESOURCE.Flag */ 245 #define ResourceNeverExclusive 0x0010 246 #define ResourceReleaseByOtherThread 0x0020 247 #define ResourceOwnedExclusive 0x0080 248 249 #define RESOURCE_HASH_TABLE_SIZE 64 250 251 typedef struct _RESOURCE_HASH_ENTRY { 252 LIST_ENTRY ListEntry; 253 PVOID Address; 254 ULONG ContentionCount; 255 ULONG Number; 256 } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; 257 258 typedef struct _RESOURCE_PERFORMANCE_DATA { 259 ULONG ActiveResourceCount; 260 ULONG TotalResourceCount; 261 ULONG ExclusiveAcquire; 262 ULONG SharedFirstLevel; 263 ULONG SharedSecondLevel; 264 ULONG StarveFirstLevel; 265 ULONG StarveSecondLevel; 266 ULONG WaitForExclusive; 267 ULONG OwnerTableExpands; 268 ULONG MaximumTableExpand; 269 LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; 270 } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; 271 272 /* Global debug flag */ 273 #if DEVL 274 extern NTKERNELAPI ULONG NtGlobalFlag; 275 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) 276 #else 277 #define IF_NTOS_DEBUG(FlagName) if(FALSE) 278 #endif 279 280 #if (NTDDI_VERSION >= NTDDI_WINBLUE) 281 282 typedef struct _EXT_SET_PARAMETERS_V0 283 { 284 ULONG Version; 285 ULONG Reserved; 286 LONGLONG NoWakeTolerance; 287 } EXT_SET_PARAMETERS, *PEXT_SET_PARAMETERS; 288 289 typedef EXT_SET_PARAMETERS KT2_SET_PARAMETERS, *PKT2_SET_PARAMETERS; 290 291 typedef struct _EX_TIMER *PEX_TIMER; 292 293 _Function_class_(EXT_CALLBACK) 294 _IRQL_requires_(DISPATCH_LEVEL) 295 _IRQL_requires_same_ 296 typedef 297 VOID 298 NTAPI 299 EXT_CALLBACK( 300 _In_ PEX_TIMER Timer, 301 _In_opt_ PVOID Context); 302 303 typedef EXT_CALLBACK *PEXT_CALLBACK; 304 305 _Function_class_(EXT_DELETE_CALLBACK) 306 _IRQL_requires_(DISPATCH_LEVEL) 307 _IRQL_requires_same_ 308 typedef 309 VOID 310 NTAPI 311 EXT_DELETE_CALLBACK( 312 _In_opt_ PVOID Context); 313 314 typedef EXT_DELETE_CALLBACK *PEXT_DELETE_CALLBACK; 315 typedef PVOID PEXT_CANCEL_PARAMETERS; 316 typedef struct _EXT_DELETE_PARAMETERS 317 { 318 ULONG Version; 319 ULONG Reserved; 320 PEXT_DELETE_CALLBACK DeleteCallback; 321 PVOID DeleteContext; 322 } EXT_DELETE_PARAMETERS, *PEXT_DELETE_PARAMETERS; 323 324 #endif // NTDDI_WINBLUE 325 326 $endif (_WDMDDK_) 327 $if (_NTDDK_) 328 typedef struct _ZONE_SEGMENT_HEADER { 329 SINGLE_LIST_ENTRY SegmentList; 330 PVOID Reserved; 331 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; 332 333 typedef struct _ZONE_HEADER { 334 SINGLE_LIST_ENTRY FreeList; 335 SINGLE_LIST_ENTRY SegmentList; 336 ULONG BlockSize; 337 ULONG TotalSegmentSize; 338 } ZONE_HEADER, *PZONE_HEADER; 339 340 #define PROTECTED_POOL 0x80000000 341 342 $endif (_NTDDK_) 343 $if (_NTIFS_) 344 #define INVALID_PROCESSOR_INDEX 0xffffffff 345 346 #define EX_PUSH_LOCK ULONG_PTR 347 #define PEX_PUSH_LOCK PULONG_PTR 348 $endif (_NTIFS_) 349 350 $if (_WINNT_ || _WDMDDK_) 351 #if (NTDDI_VERSION >= NTDDI_VISTA) 352 typedef enum _FIRMWARE_TYPE { 353 FirmwareTypeUnknown, 354 FirmwareTypeBios, 355 FirmwareTypeUefi, 356 FirmwareTypeMax 357 } FIRMWARE_TYPE, *PFIRMWARE_TYPE; 358 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 359 $endif (_WINNT_ || _WDMDDK_) 360