1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxGlobalsUm.h 8 9 Abstract: 10 11 This module contains user-mode specific globals definitions 12 for the frameworks. 13 14 For common definitions common between km and um please see 15 FxGlobals.h 16 17 Author: 18 19 Environment: 20 21 kernel mode only 22 23 Revision History: 24 25 26 --*/ 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 #include "FxGlobals.h" 32 33 extern IUMDFPlatform *g_IUMDFPlatform; 34 extern IWudfHost2 *g_IWudfHost2; 35 36 _Must_inspect_result_ 37 __inline 38 BOOLEAN 39 FxIsProcessorGroupSupported( 40 VOID 41 ) 42 { 43 // 44 // UMDF 2.0 is targeted for platforms that support processor groups. 45 // 46 return TRUE; 47 } 48 49 50 __inline 51 VOID 52 FX_TRACK_DRIVER( 53 __in PFX_DRIVER_GLOBALS FxDriverGlobals 54 ) 55 { 56 UNREFERENCED_PARAMETER(FxDriverGlobals); 57 // 58 // Not yet supported for UMDF 59 // 60 } 61 62 _Must_inspect_result_ 63 __inline 64 PVOID 65 FxAllocateFromNPagedLookasideListNoTracking ( 66 __in PNPAGED_LOOKASIDE_LIST Lookaside 67 ) 68 { 69 UNREFERENCED_PARAMETER(Lookaside); 70 ASSERTMSG("Not implemented for UMDF!\n", FALSE); 71 return NULL; 72 } 73 74 __inline 75 PVOID 76 FxAllocateFromNPagedLookasideList ( 77 _In_ PNPAGED_LOOKASIDE_LIST Lookaside, 78 _In_opt_ size_t ElementSize = 0 79 ) 80 { 81 UNREFERENCED_PARAMETER(Lookaside); 82 83 // 84 // UMDF doesn't yet use a look-aside list, so just alloc memory from pool. 85 // 86 return MxMemory::MxAllocatePoolWithTag(NonPagedPool, // not used 87 ElementSize, 88 0 // not used 89 ); 90 } 91 92 __inline 93 PVOID 94 FxAllocateFromPagedLookasideList ( 95 __in PPAGED_LOOKASIDE_LIST Lookaside 96 ) 97 { 98 UNREFERENCED_PARAMETER(Lookaside); 99 ASSERTMSG("Not implemented for UMDF!\n", FALSE); 100 return NULL; 101 } 102 103 __inline 104 VOID 105 FxFreeToNPagedLookasideListNoTracking ( 106 __in PNPAGED_LOOKASIDE_LIST Lookaside, 107 __in PVOID Entry 108 ) 109 { 110 UNREFERENCED_PARAMETER(Lookaside); 111 UNREFERENCED_PARAMETER(Entry); 112 ASSERTMSG("Not implemented for UMDF!\n", FALSE); 113 } 114 115 __inline 116 VOID 117 FxFreeToPagedLookasideList ( 118 __in PPAGED_LOOKASIDE_LIST Lookaside, 119 __in PVOID Entry 120 ) 121 { 122 UNREFERENCED_PARAMETER(Lookaside); 123 UNREFERENCED_PARAMETER(Entry); 124 ASSERTMSG("Not implemented for UMDF!\n", FALSE); 125 } 126 127 __inline 128 VOID 129 FxFreeToNPagedLookasideList ( 130 __in PNPAGED_LOOKASIDE_LIST Lookaside, 131 __in PVOID Entry 132 ) 133 { 134 UNREFERENCED_PARAMETER(Lookaside); 135 136 MxMemory::MxFreePool(Entry); 137 } 138 139 __inline 140 BOOL 141 IsCurrentThreadImpersonated( ) 142 { 143 return g_IWudfHost2->IsCurrentThreadImpersonated(); 144 } 145 146 __inline 147 PWDF_ACTIVATION_FRAME * 148 GetActivationList( 149 VOID 150 ) 151 { 152 return g_IUMDFPlatform->GetActivationListHead(); 153 } 154 155 // 156 // This has to be a macro (as opposed an inline function) beacause of the activation frame is 157 // allocated in the caller's stack. 158 // 159 // NOTE: This must not be wrapped in {}'s since that puts the activation frame in a very 160 // short lived scope. It's destructor will be called when control leaves the block 161 // rather than when the function returns and that defeats the entire purpose of the 162 // activation frame (which is to live for the life of the DDI call). 163 // 164 // NOTE 2: 165 // WDF_ACTIVATION constructor includes a default argument which is the _ReturnAddress() 166 // instrinsic. This macro should be placed in methods such that the _ReturnAddress 167 // points to calling driver code. 168 // 169 170 #define DDI_ENTRY_IMPERSONATION_OK() \ 171 WDF_ACTIVATION activationFrame(GetActivationList()); \ 172 173 #define DDI_ENTRY() \ 174 DDI_ENTRY_IMPERSONATION_OK() \ 175 FX_VERIFY( \ 176 DRIVER(BadArgument, TODO), \ 177 CHECK("It is illegal to invoke this DDI while " \ 178 "thread is impersonated", \ 179 (FALSE == IsCurrentThreadImpersonated())) \ 180 ); 181 182 #ifdef __cplusplus 183 } 184 #endif 185