儲存庫 vbox 的更動 12100
- 時間撮記:
- 2008-9-4 下午05:56:28 (16 年 以前)
- 位置:
- trunk/src/VBox/HostDrivers/Support
- 檔案:
-
- 修改 5 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostDrivers/Support/Makefile.kmk
r12000 r12100 216 216 VBoxDrv_DEFS += VBOX_WITH_IDT_PATCHING 217 217 endif 218 #VBoxDrv_DEFS += SUPDRV_WITH_UNWIND_HACK - post 2.0, need to wrap more APIs and entry functions. 218 VBoxDrv_DEFS.amd64 = SUPDRV_WITH_UNWIND_HACK 219 219 VBoxDrv_SDKS = W2K3DDK WINPSDKINCS 220 220 VBoxDrv_INCS := $(PATH_SUB_CURRENT) -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r12000 r12100 115 115 #endif 116 116 117 /******************************************************************************* 118 * Internal Functions * 119 *******************************************************************************/ 120 static int supdrvMemAdd(PSUPDRVMEMREF pMem, PSUPDRVSESSION pSession); 121 static int supdrvMemRelease(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, SUPDRVMEMREFTYPE eType); 122 #ifdef VBOX_WITH_IDT_PATCHING 123 static int supdrvIOCtl_IdtInstall(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPIDTINSTALL pReq); 124 static PSUPDRVPATCH supdrvIdtPatchOne(PSUPDRVDEVEXT pDevExt, PSUPDRVPATCH pPatch); 125 static int supdrvIOCtl_IdtRemoveAll(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession); 126 static void supdrvIdtRemoveOne(PSUPDRVDEVEXT pDevExt, PSUPDRVPATCH pPatch); 127 static void supdrvIdtWrite(volatile void *pvIdtEntry, const SUPDRVIDTE *pNewIDTEntry); 128 #endif /* VBOX_WITH_IDT_PATCHING */ 129 static int supdrvIOCtl_LdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDROPEN pReq); 130 static int supdrvIOCtl_LdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRLOAD pReq); 131 static int supdrvIOCtl_LdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRFREE pReq); 132 static int supdrvIOCtl_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRGETSYMBOL pReq); 133 static int supdrvIDC_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQGETSYM pReq); 134 static int supdrvLdrSetR0EP(PSUPDRVDEVEXT pDevExt, void *pvVMMR0, void *pvVMMR0EntryInt, void *pvVMMR0EntryFast, void *pvVMMR0EntryEx); 135 static void supdrvLdrUnsetR0EP(PSUPDRVDEVEXT pDevExt); 136 static int supdrvLdrAddUsage(PSUPDRVSESSION pSession, PSUPDRVLDRIMAGE pImage); 137 static void supdrvLdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage); 138 static SUPPAGINGMODE supdrvIOCtl_GetPagingMode(void); 139 static SUPGIPMODE supdrvGipDeterminTscMode(PSUPDRVDEVEXT pDevExt); 140 #ifdef RT_OS_WINDOWS 141 static int supdrvPageGetPhys(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages); 142 static bool supdrvPageWasLockedByPageAlloc(PSUPDRVSESSION pSession, RTR3PTR pvR3); 143 #endif /* RT_OS_WINDOWS */ 144 static int supdrvGipCreate(PSUPDRVDEVEXT pDevExt); 145 static void supdrvGipDestroy(PSUPDRVDEVEXT pDevExt); 146 static DECLCALLBACK(void) supdrvGipSyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick); 147 static DECLCALLBACK(void) supdrvGipAsyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick); 148 static DECLCALLBACK(void) supdrvGipMpEvent(RTMPEVENT enmEvent, RTCPUID idCpu, void *pvUser); 149 150 #ifdef SUPDRV_WITH_UNWIND_HACK 151 DECLASM(int) supdrvNtWrapVMMR0EntryEx(PFNRT pfnVMMR0EntryEx, PVM pVM, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession); 152 DECLASM(int) supdrvNtWrapVMMR0EntryFast(PFNRT pfnVMMR0EntryFast, PVM pVM, unsigned uOperation); 153 DECLASM(void) supdrvNtWrapObjDestructor(PFNRT pfnDestruction, void *pvObj, void *pvUser1, void *pvUser2); 154 DECLASM(void *) supdrvNtWrapQueryFactoryInterface(PFNRT pfnQueryFactoryInterface, struct SUPDRVFACTORY const *pSupDrvFactory, PSUPDRVSESSION pSession, const char *pszInterfaceUuid); 155 DECLASM(int) supdrvNtWrapModuleInit(PFNRT pfnModuleInit); 156 DECLASM(void) supdrvNtWrapModuleTerm(PFNRT pfnModuleTerm); 157 158 DECLASM(int) UNWIND_WRAP(SUPR0ComponentRegisterFactory)(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory); 159 DECLASM(int) UNWIND_WRAP(SUPR0ComponentDeregisterFactory)(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory); 160 DECLASM(int) UNWIND_WRAP(SUPR0ComponentQueryFactory)(PSUPDRVSESSION pSession, const char *pszName, const char *pszInterfaceUuid, void **ppvFactoryIf); 161 DECLASM(void *) UNWIND_WRAP(SUPR0ObjRegister)(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2); 162 DECLASM(int) UNWIND_WRAP(SUPR0ObjAddRef)(void *pvObj, PSUPDRVSESSION pSession); 163 DECLASM(int) UNWIND_WRAP(SUPR0ObjRelease)(void *pvObj, PSUPDRVSESSION pSession); 164 DECLASM(int) UNWIND_WRAP(SUPR0ObjVerifyAccess)(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName); 165 DECLASM(int) UNWIND_WRAP(SUPR0LockMem)(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages); 166 DECLASM(int) UNWIND_WRAP(SUPR0UnlockMem)(PSUPDRVSESSION pSession, RTR3PTR pvR3); 167 DECLASM(int) UNWIND_WRAP(SUPR0ContAlloc)(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys); 168 DECLASM(int) UNWIND_WRAP(SUPR0ContFree)(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr); 169 DECLASM(int) UNWIND_WRAP(SUPR0LowAlloc)(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS paPages); 170 DECLASM(int) UNWIND_WRAP(SUPR0LowFree)(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr); 171 DECLASM(int) UNWIND_WRAP(SUPR0MemAlloc)(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3); 172 DECLASM(int) UNWIND_WRAP(SUPR0MemGetPhys)(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, PSUPPAGE paPages); 173 DECLASM(int) UNWIND_WRAP(SUPR0MemFree)(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr); 174 DECLASM(int) UNWIND_WRAP(SUPR0PageAlloc)(PSUPDRVSESSION pSession, uint32_t cPages, PRTR3PTR ppvR3, PRTHCPHYS paPages); 175 DECLASM(int) UNWIND_WRAP(SUPR0PageFree)(PSUPDRVSESSION pSession, RTR3PTR pvR3); 176 //DECLASM(int) UNWIND_WRAP(SUPR0Printf)(const char *pszFormat, ...); 177 DECLASM(void *) UNWIND_WRAP(RTMemAlloc)(size_t cb) RT_NO_THROW; 178 DECLASM(void *) UNWIND_WRAP(RTMemAllocZ)(size_t cb) RT_NO_THROW; 179 DECLASM(void) UNWIND_WRAP(RTMemFree)(void *pv) RT_NO_THROW; 180 DECLASM(void *) UNWIND_WRAP(RTMemDup)(const void *pvSrc, size_t cb) RT_NO_THROW; 181 DECLASM(void *) UNWIND_WRAP(RTMemDupEx)(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW; 182 DECLASM(void *) UNWIND_WRAP(RTMemRealloc)(void *pvOld, size_t cbNew) RT_NO_THROW; 183 DECLASM(int) UNWIND_WRAP(RTR0MemObjAllocLow)(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable); 184 DECLASM(int) UNWIND_WRAP(RTR0MemObjAllocPage)(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable); 185 DECLASM(int) UNWIND_WRAP(RTR0MemObjAllocPhys)(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest); 186 DECLASM(int) UNWIND_WRAP(RTR0MemObjAllocPhysNC)(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest); 187 DECLASM(int) UNWIND_WRAP(RTR0MemObjAllocCont)(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable); 188 DECLASM(int) UNWIND_WRAP(RTR0MemObjLockUser)(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, RTR0PROCESS R0Process); 189 DECLASM(int) UNWIND_WRAP(RTR0MemObjMapKernel)(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt); 190 DECLASM(int) UNWIND_WRAP(RTR0MemObjMapUser)(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process); 191 DECLASM(void *) UNWIND_WRAP(RTR0MemObjAddress)(RTR0MEMOBJ MemObj); 192 DECLASM(RTR3PTR) UNWIND_WRAP(RTR0MemObjAddressR3)(RTR0MEMOBJ MemObj); 193 DECLASM(size_t) UNWIND_WRAP(RTR0MemObjSize)(RTR0MEMOBJ MemObj); 194 DECLASM(bool) UNWIND_WRAP(RTR0MemObjIsMapping)(RTR0MEMOBJ MemObj); 195 DECLASM(RTHCPHYS) UNWIND_WRAP(RTR0MemObjGetPagePhysAddr)(RTR0MEMOBJ MemObj, size_t iPage); 196 DECLASM(int) UNWIND_WRAP(RTR0MemObjFree)(RTR0MEMOBJ MemObj, bool fFreeMappings); 197 /* RTProcSelf - not necessary */ 198 /* RTR0ProcHandleSelf - not necessary */ 199 DECLASM(int) UNWIND_WRAP(RTSemFastMutexCreate)(PRTSEMFASTMUTEX pMutexSem); 200 DECLASM(int) UNWIND_WRAP(RTSemFastMutexDestroy)(RTSEMFASTMUTEX MutexSem); 201 DECLASM(int) UNWIND_WRAP(RTSemFastMutexRequest)(RTSEMFASTMUTEX MutexSem); 202 DECLASM(int) UNWIND_WRAP(RTSemFastMutexRelease)(RTSEMFASTMUTEX MutexSem); 203 DECLASM(int) UNWIND_WRAP(RTSemEventCreate)(PRTSEMEVENT pEventSem); 204 DECLASM(int) UNWIND_WRAP(RTSemEventSignal)(RTSEMEVENT EventSem); 205 DECLASM(int) UNWIND_WRAP(RTSemEventWait)(RTSEMEVENT EventSem, unsigned cMillies); 206 DECLASM(int) UNWIND_WRAP(RTSemEventWaitNoResume)(RTSEMEVENT EventSem, unsigned cMillies); 207 DECLASM(int) UNWIND_WRAP(RTSemEventDestroy)(RTSEMEVENT EventSem); 208 DECLASM(int) UNWIND_WRAP(RTSemEventMultiCreate)(PRTSEMEVENTMULTI pEventMultiSem); 209 DECLASM(int) UNWIND_WRAP(RTSemEventMultiSignal)(RTSEMEVENTMULTI EventMultiSem); 210 DECLASM(int) UNWIND_WRAP(RTSemEventMultiReset)(RTSEMEVENTMULTI EventMultiSem); 211 DECLASM(int) UNWIND_WRAP(RTSemEventMultiWait)(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies); 212 DECLASM(int) UNWIND_WRAP(RTSemEventMultiWaitNoResume)(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies); 213 DECLASM(int) UNWIND_WRAP(RTSemEventMultiDestroy)(RTSEMEVENTMULTI EventMultiSem); 214 DECLASM(int) UNWIND_WRAP(RTSpinlockCreate)(PRTSPINLOCK pSpinlock); 215 DECLASM(int) UNWIND_WRAP(RTSpinlockDestroy)(RTSPINLOCK Spinlock); 216 DECLASM(void) UNWIND_WRAP(RTSpinlockAcquire)(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp); 217 DECLASM(void) UNWIND_WRAP(RTSpinlockRelease)(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp); 218 DECLASM(void) UNWIND_WRAP(RTSpinlockAcquireNoInts)(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp); 219 DECLASM(void) UNWIND_WRAP(RTSpinlockReleaseNoInts)(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp); 220 /* RTTimeNanoTS - not necessary */ 221 /* RTTimeMilliTS - not necessary */ 222 /* RTTimeSystemNanoTS - not necessary */ 223 /* RTTimeSystemMilliTS - not necessary */ 224 /* RTThreadNativeSelf - not necessary */ 225 DECLASM(int) UNWIND_WRAP(RTThreadSleep)(unsigned cMillies); 226 DECLASM(bool) UNWIND_WRAP(RTThreadYield)(void); 227 #if 0 228 /* RTThreadSelf - not necessary */ 229 DECLASM(int) UNWIND_WRAP(RTThreadCreate)(PRTTHREAD pThread, PFNRTTHREAD pfnThread, void *pvUser, size_t cbStack, 230 RTTHREADTYPE enmType, unsigned fFlags, const char *pszName); 231 DECLASM(RTNATIVETHREAD) UNWIND_WRAP(RTThreadGetNative)(RTTHREAD Thread); 232 DECLASM(int) UNWIND_WRAP(RTThreadWait)(RTTHREAD Thread, unsigned cMillies, int *prc); 233 DECLASM(int) UNWIND_WRAP(RTThreadWaitNoResume)(RTTHREAD Thread, unsigned cMillies, int *prc); 234 DECLASM(const char *) UNWIND_WRAP(RTThreadGetName)(RTTHREAD Thread); 235 DECLASM(const char *) UNWIND_WRAP(RTThreadSelfName)(void); 236 DECLASM(RTTHREADTYPE) UNWIND_WRAP(RTThreadGetType)(RTTHREAD Thread); 237 DECLASM(int) UNWIND_WRAP(RTThreadUserSignal)(RTTHREAD Thread); 238 DECLASM(int) UNWIND_WRAP(RTThreadUserReset)(RTTHREAD Thread); 239 DECLASM(int) UNWIND_WRAP(RTThreadUserWait)(RTTHREAD Thread, unsigned cMillies); 240 DECLASM(int) UNWIND_WRAP(RTThreadUserWaitNoResume)(RTTHREAD Thread, unsigned cMillies); 241 #endif 242 /* RTLogDefaultInstance - a bit of a gamble, but we do not want the overhead! */ 243 /* RTMpCpuId - not necessary */ 244 /* RTMpCpuIdFromSetIndex - not necessary */ 245 /* RTMpCpuIdToSetIndex - not necessary */ 246 /* RTMpIsCpuPossible - not necessary */ 247 /* RTMpGetCount - not necessary */ 248 /* RTMpGetMaxCpuId - not necessary */ 249 /* RTMpGetOnlineCount - not necessary */ 250 /* RTMpGetOnlineSet - not necessary */ 251 /* RTMpGetSet - not necessary */ 252 /* RTMpIsCpuOnline - not necessary */ 253 DECLASM(int) UNWIND_WRAP(RTMpOnAll)(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2); 254 DECLASM(int) UNWIND_WRAP(RTMpOnOthers)(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2); 255 DECLASM(int) UNWIND_WRAP(RTMpOnSpecific)(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2); 256 /* RTLogRelDefaultInstance - not necessary. */ 257 DECLASM(int) UNWIND_WRAP(RTLogSetDefaultInstanceThread)(PRTLOGGER pLogger, uintptr_t uKey); 258 /* RTLogLogger - can't wrap this buster. */ 259 /* RTLogLoggerEx - can't wrap this buster. */ 260 DECLASM(void) UNWIND_WRAP(RTLogLoggerExV)(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args); 261 /* RTLogPrintf - can't wrap this buster. */ /** @todo provide va_list log wrappers in RuntimeR0. */ 262 DECLASM(void) UNWIND_WRAP(RTLogPrintfV)(const char *pszFormat, va_list args); 263 DECLASM(void) UNWIND_WRAP(AssertMsg1)(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction); 264 /* AssertMsg2 - can't wrap this buster. */ 265 #endif /* SUPDRV_WITH_UNWIND_HACK */ 266 117 267 118 268 /******************************************************************************* … … 125 275 { 126 276 /* name function */ 127 { "SUPR0ComponentRegisterFactory", (void *) SUPR0ComponentRegisterFactory},128 { "SUPR0ComponentDeregisterFactory", (void *) SUPR0ComponentDeregisterFactory},129 { "SUPR0ComponentQueryFactory", (void *) SUPR0ComponentQueryFactory},277 { "SUPR0ComponentRegisterFactory", (void *)UNWIND_WRAP(SUPR0ComponentRegisterFactory) }, 278 { "SUPR0ComponentDeregisterFactory", (void *)UNWIND_WRAP(SUPR0ComponentDeregisterFactory) }, 279 { "SUPR0ComponentQueryFactory", (void *)UNWIND_WRAP(SUPR0ComponentQueryFactory) }, 130 280 { "SUPR0ObjRegister", (void *)SUPR0ObjRegister }, 131 281 { "SUPR0ObjAddRef", (void *)SUPR0ObjAddRef }, … … 173 323 { "RTSemFastMutexCreate", (void *)RTSemFastMutexCreate }, 174 324 { "RTSemFastMutexDestroy", (void *)RTSemFastMutexDestroy }, 175 { "RTSemFastMutexRequest", (void *) RTSemFastMutexRequest},325 { "RTSemFastMutexRequest", (void *)UNWIND_WRAP(RTSemFastMutexRequest) }, 176 326 { "RTSemFastMutexRelease", (void *)RTSemFastMutexRelease }, 177 327 { "RTSemEventCreate", (void *)RTSemEventCreate }, 178 328 { "RTSemEventSignal", (void *)RTSemEventSignal }, 179 { "RTSemEventWait", (void *) RTSemEventWait},180 { "RTSemEventWaitNoResume", (void *) RTSemEventWaitNoResume},329 { "RTSemEventWait", (void *)UNWIND_WRAP(RTSemEventWait) }, 330 { "RTSemEventWaitNoResume", (void *)UNWIND_WRAP(RTSemEventWaitNoResume) }, 181 331 { "RTSemEventDestroy", (void *)RTSemEventDestroy }, 182 332 { "RTSemEventMultiCreate", (void *)RTSemEventMultiCreate }, 183 333 { "RTSemEventMultiSignal", (void *)RTSemEventMultiSignal }, 184 334 { "RTSemEventMultiReset", (void *)RTSemEventMultiReset }, 185 { "RTSemEventMultiWait", (void *)RTSemEventMultiWait }, 186 #ifdef SUPDRV_WITH_UNWIND_HACK 187 { "RTSemEventMultiWaitNoResume", (void *)supdrvNtWrapRTSemEventMultiWaitNoResume }, 188 #else 189 { "RTSemEventMultiWaitNoResume", (void *)RTSemEventMultiWaitNoResume }, 190 #endif 335 { "RTSemEventMultiWait", (void *)UNWIND_WRAP(RTSemEventMultiWait) }, 336 { "RTSemEventMultiWaitNoResume", (void *)UNWIND_WRAP(RTSemEventMultiWaitNoResume) }, 191 337 { "RTSemEventMultiDestroy", (void *)RTSemEventMultiDestroy }, 192 338 { "RTSpinlockCreate", (void *)RTSpinlockCreate }, 193 339 { "RTSpinlockDestroy", (void *)RTSpinlockDestroy }, 194 340 { "RTSpinlockAcquire", (void *)RTSpinlockAcquire }, 195 { "RTSpinlockRelease", (void *) RTSpinlockRelease},341 { "RTSpinlockRelease", (void *)UNWIND_WRAP(RTSpinlockRelease) }, 196 342 { "RTSpinlockAcquireNoInts", (void *)RTSpinlockAcquireNoInts }, 197 { "RTSpinlockReleaseNoInts", (void *) RTSpinlockReleaseNoInts},343 { "RTSpinlockReleaseNoInts", (void *)UNWIND_WRAP(RTSpinlockReleaseNoInts) }, 198 344 { "RTTimeNanoTS", (void *)RTTimeNanoTS }, 199 345 { "RTTimeMillieTS", (void *)RTTimeMilliTS }, … … 201 347 { "RTTimeSystemMillieTS", (void *)RTTimeSystemMilliTS }, 202 348 { "RTThreadNativeSelf", (void *)RTThreadNativeSelf }, 203 { "RTThreadSleep", (void *) RTThreadSleep},204 { "RTThreadYield", (void *) RTThreadYield},349 { "RTThreadSleep", (void *)UNWIND_WRAP(RTThreadSleep) }, 350 { "RTThreadYield", (void *)UNWIND_WRAP(RTThreadYield) }, 205 351 #if 0 /* Thread APIs, Part 2. */ 206 352 { "RTThreadSelf", (void *)RTThreadSelf }, … … 243 389 244 390 245 /*******************************************************************************246 * Internal Functions *247 *******************************************************************************/248 static int supdrvMemAdd(PSUPDRVMEMREF pMem, PSUPDRVSESSION pSession);249 static int supdrvMemRelease(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, SUPDRVMEMREFTYPE eType);250 #ifdef VBOX_WITH_IDT_PATCHING251 static int supdrvIOCtl_IdtInstall(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPIDTINSTALL pReq);252 static PSUPDRVPATCH supdrvIdtPatchOne(PSUPDRVDEVEXT pDevExt, PSUPDRVPATCH pPatch);253 static int supdrvIOCtl_IdtRemoveAll(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);254 static void supdrvIdtRemoveOne(PSUPDRVDEVEXT pDevExt, PSUPDRVPATCH pPatch);255 static void supdrvIdtWrite(volatile void *pvIdtEntry, const SUPDRVIDTE *pNewIDTEntry);256 #endif /* VBOX_WITH_IDT_PATCHING */257 static int supdrvIOCtl_LdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDROPEN pReq);258 static int supdrvIOCtl_LdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRLOAD pReq);259 static int supdrvIOCtl_LdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRFREE pReq);260 static int supdrvIOCtl_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRGETSYMBOL pReq);261 static int supdrvIDC_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQGETSYM pReq);262 static int supdrvLdrSetR0EP(PSUPDRVDEVEXT pDevExt, void *pvVMMR0, void *pvVMMR0EntryInt, void *pvVMMR0EntryFast, void *pvVMMR0EntryEx);263 static void supdrvLdrUnsetR0EP(PSUPDRVDEVEXT pDevExt);264 static int supdrvLdrAddUsage(PSUPDRVSESSION pSession, PSUPDRVLDRIMAGE pImage);265 static void supdrvLdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);266 static SUPPAGINGMODE supdrvIOCtl_GetPagingMode(void);267 static SUPGIPMODE supdrvGipDeterminTscMode(PSUPDRVDEVEXT pDevExt);268 #ifdef RT_OS_WINDOWS269 static int supdrvPageGetPhys(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages);270 static bool supdrvPageWasLockedByPageAlloc(PSUPDRVSESSION pSession, RTR3PTR pvR3);271 #endif /* RT_OS_WINDOWS */272 static int supdrvGipCreate(PSUPDRVDEVEXT pDevExt);273 static void supdrvGipDestroy(PSUPDRVDEVEXT pDevExt);274 static DECLCALLBACK(void) supdrvGipSyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick);275 static DECLCALLBACK(void) supdrvGipAsyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick);276 static DECLCALLBACK(void) supdrvGipMpEvent(RTMPEVENT enmEvent, RTCPUID idCpu, void *pvUser);277 278 279 391 /** 280 392 * Initializes the device extentsion structure. … … 569 681 pObj, pObj->enmType, pObj->pvUser1, pObj->pvUser2, pObj->CreatorProcess, RTProcSelf(), pObj->pfnDestructor)); 570 682 if (pObj->pfnDestructor) 683 #ifdef SUPDRV_WITH_UNWIND_HACK 684 supdrvNtWrapObjDestructor((PFNRT)pObj->pfnDestructor, pObj, pObj->pvUser1, pObj->pvUser2); 685 #else 571 686 pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2); 687 #endif 572 688 RTMemFree(pObj); 573 689 } … … 729 845 { 730 846 case SUP_IOCTL_FAST_DO_RAW_RUN: 847 #ifdef SUPDRV_WITH_UNWIND_HACK 848 supdrvNtWrapVMMR0EntryFast((PFNRT)pDevExt->pfnVMMR0EntryFast, pSession->pVM, SUP_VMMR0_DO_RAW_RUN); 849 #else 731 850 pDevExt->pfnVMMR0EntryFast(pSession->pVM, SUP_VMMR0_DO_RAW_RUN); 851 #endif 732 852 break; 733 853 case SUP_IOCTL_FAST_DO_HWACC_RUN: 854 #ifdef SUPDRV_WITH_UNWIND_HACK 855 supdrvNtWrapVMMR0EntryFast((PFNRT)pDevExt->pfnVMMR0EntryFast, pSession->pVM, SUP_VMMR0_DO_HWACC_RUN); 856 #else 734 857 pDevExt->pfnVMMR0EntryFast(pSession->pVM, SUP_VMMR0_DO_HWACC_RUN); 858 #endif 735 859 break; 736 860 case SUP_IOCTL_FAST_DO_NOP: 861 #ifdef SUPDRV_WITH_UNWIND_HACK 862 supdrvNtWrapVMMR0EntryFast((PFNRT)pDevExt->pfnVMMR0EntryFast, pSession->pVM, SUP_VMMR0_DO_NOP); 863 #else 737 864 pDevExt->pfnVMMR0EntryFast(pSession->pVM, SUP_VMMR0_DO_NOP); 865 #endif 738 866 break; 739 867 default: … … 1709 1837 pObj, pObj->enmType, pObj->pvUser1, pObj->pvUser2, pObj->CreatorProcess, RTProcSelf(), pObj->pfnDestructor)); 1710 1838 if (pObj->pfnDestructor) 1839 #ifdef SUPDRV_WITH_UNWIND_HACK 1840 supdrvNtWrapObjDestructor((PFNRT)pObj->pfnDestructor, pObj, pObj->pvUser1, pObj->pvUser2); 1841 #else 1711 1842 pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2); 1843 #endif 1712 1844 RTMemFree(pObj); 1713 1845 } … … 2127 2259 ) 2128 2260 { 2129 const unsignedcPages = RTR0MemObjSize(pBundle->aMem[i].MemObj) >> PAGE_SHIFT;2130 unsignediPage;2261 const size_t cPages = RTR0MemObjSize(pBundle->aMem[i].MemObj) >> PAGE_SHIFT; 2262 size_t iPage; 2131 2263 for (iPage = 0; iPage < cPages; iPage++) 2132 2264 { … … 2304 2436 && RTR0MemObjAddressR3(pBundle->aMem[i].MapObjR3) == pvR3) 2305 2437 { 2306 uint32_t iPage = RTR0MemObjSize(pBundle->aMem[i].MemObj) >> PAGE_SHIFT; 2307 cPages = RT_MIN(iPage, cPages); 2438 uint32_t iPage; 2439 size_t cMaxPages = RTR0MemObjSize(pBundle->aMem[i].MemObj) >> PAGE_SHIFT; 2440 cPages = (uint32_t)RT_MIN(cMaxPages, cPages); 2308 2441 for (iPage = 0; iPage < cPages; iPage++) 2309 2442 paPages[iPage] = RTR0MemObjGetPagePhysAddr(pBundle->aMem[i].MemObj, iPage); … … 2681 2814 && !memcmp(pCur->pFactory->szName, pszName, cchName)) 2682 2815 { 2816 #ifdef SUPDRV_WITH_UNWIND_HACK 2817 void *pvFactory = supdrvNtWrapQueryFactoryInterface((PFNRT)pCur->pFactory->pfnQueryFactoryInterface, pCur->pFactory, pSession, pszInterfaceUuid); 2818 #else 2683 2819 void *pvFactory = pCur->pFactory->pfnQueryFactoryInterface(pCur->pFactory, pSession, pszInterfaceUuid); 2820 #endif 2684 2821 if (pvFactory) 2685 2822 { … … 3692 3829 { 3693 3830 Log(("supdrvIOCtl_LdrLoad: calling pfnModuleInit=%p\n", pImage->pfnModuleInit)); 3831 #ifdef SUPDRV_WITH_UNWIND_HACK 3832 rc = supdrvNtWrapModuleInit((PFNRT)pImage->pfnModuleInit); 3833 #else 3694 3834 rc = pImage->pfnModuleInit(); 3835 #endif 3695 3836 if (rc && pDevExt->pvVMMR0 == pImage->pvImage) 3696 3837 supdrvLdrUnsetR0EP(pDevExt); … … 4162 4303 { 4163 4304 LogFlow(("supdrvIOCtl_LdrLoad: calling pfnModuleTerm=%p\n", pImage->pfnModuleTerm)); 4305 #ifdef SUPDRV_WITH_UNWIND_HACK 4306 supdrvNtWrapModuleTerm(pImage->pfnModuleTerm); 4307 #else 4164 4308 pImage->pfnModuleTerm(); 4309 #endif 4165 4310 } 4166 4311 -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r12000 r12100 241 241 242 242 243 /** @def SUPDRV_WITH_UNWIND_HACK 244 * Changes a function name into the wrapped version if we've 245 * enabled the unwind hack. 246 * 247 * The unwind hack is for making the NT unwind procedures skip 248 * our dynamically loaded code when they try to walk the call 249 * stack. Needless to say, they kind of don't expect what 250 * we're doing here and get kind of confused and may BSOD. */ 251 #ifdef SUPDRV_WITH_UNWIND_HACK 252 # define UNWIND_WRAP(Name) supdrvNtWrap##Name 253 #else 254 # define UNWIND_WRAP(Name) Name 255 #endif 256 257 243 258 /* 244 259 * Error codes. … … 670 685 bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt); 671 686 672 #ifdef SUPDRV_WITH_UNWIND_HACK673 DECLASM(int) supdrvNtWrapVMMR0EntryEx(PFNRT pfnVMMR0EntryEx, PVM pVM, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession);674 DECLASM(int) supdrvNtWrapRTSemEventMultiWaitNoResume(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies);675 #endif676 677 678 687 /******************************************************************************* 679 688 * Shared Functions * -
trunk/src/VBox/HostDrivers/Support/SUPR0.def
r10680 r12100 111 111 RTLogRelDefaultInstance 112 112 RTLogSetDefaultInstanceThread 113 RTLogLogger114 RTLogLoggerEx115 113 RTLogLoggerExV 116 RTLogPrintf117 114 RTLogPrintfV 118 115 AssertMsg1 -
trunk/src/VBox/HostDrivers/Support/win/SUPDrvA-win.asm
r12000 r12100 54 54 55 55 %ifdef SUPDRV_WITH_UNWIND_HACK 56 %if 0 ; def RT_ARCH_AMD64 56 %ifdef RT_ARCH_AMD64 57 58 ;; 59 ; Common prolog, take the proc name as argument. 60 ; This creates a 0x80 byte stack frame. 61 ; 62 %macro NtWrapProlog 1 63 [proc_frame %1] 64 push rbp 65 [pushreg rbp] 66 mov rbp, rsp 67 [setframe rbp, 0] 68 sub rsp, 0x80 69 [allocstack 0x80] 70 71 ; save rdi and load rbp into it 72 mov [rbp - 8h], rdi 73 [savereg rdi, 0x78] 74 mov rdi, rbp 75 [endprolog] 76 %endmacro 77 78 ;; 79 ; Common epilog, take the proc name as argument. 80 %macro NtWrapEpilog 1 81 ; restore rbp and rdi then return. 82 mov rbp, rdi 83 mov rdi, [rdi - 8h] 84 leave 85 ret 86 [endproc_frame %1] 87 %endmacro 88 89 ;; 90 ; Create a stack marker with the rbp. The marker is 32 byte big. 91 ; This is 32-byte aligned and 32 byte in size. 92 ; 93 ; Trashes r10 94 %macro NtWrapCreateMarker 0 95 lea r10, [rbp - 30h] 96 and r10, ~1fh ; 32-byte align it. 97 mov dword [r10 ], 0x20080901 98 mov dword [r10 + 04h], 0x20080902 99 mov qword [r10 + 08h], rbp 100 mov dword [r10 + 10h], 0x20080903 101 mov dword [r10 + 14h], 0x20080904 102 mov qword [r10 + 18h], rbp 103 %endmacro 104 105 ;; 106 ; Destroys the stack marker. 107 ; 108 ; Trashes r10 109 %macro NtWrapDestroyMarker 0 110 lea r10, [rbp - 30h] 111 and r10, ~1fh ; 32-byte align it. 112 mov [r10 ], rbp 113 mov [r10 + 08h], rbp 114 mov [r10 + 10h], rbp 115 mov [r10 + 18h], rbp 116 %endmacro 117 118 ;; 119 ; Find the stack marker with the rbp of the entry frame. 120 ; 121 ; Search the current stack page inline, call a helper function 122 ; which does a safe search of any further stack pages. 123 ; 124 ; Trashes rax, r10 and r11. 125 ; Modifies rbp 126 ; 127 %macro NtWrapLocateMarker 0 128 mov rax, rbp 129 and rax, ~1fh ; 32-byte align it. 130 131 ; 132 ; Calc remainig space in the current page. If we're on a 133 ; page boundrary, we'll search the entire previous page. 134 ; 135 mov r10, rax 136 neg r10 137 and r10, 0fffh 138 inc r10 139 shr r10, 5 ; /= 32 bytes 140 jz %%not_found ; If zero, take the slow path 141 142 ; 143 ; The search loop. 144 ; 145 %%again: 146 dec r10 147 lea rax, [rax + 20h] 148 jz %%not_found 149 cmp dword [rax ], 0x20080901 150 je %%candidate 151 jmp %%again 152 153 %%not_found: 154 call NAME(NtWrapLocateMarkerHelper) 155 jmp %%done 156 157 %%candidate: 158 cmp dword [rax + 04h], 0x20080902 159 jne %%again 160 cmp dword [rax + 10h], 0x20080903 161 jne %%again 162 cmp dword [rax + 14h], 0x20080904 163 jne %%again 164 mov r11, [rax + 08h] 165 cmp r11, [rax + 18h] 166 jne %%again 167 168 ; found it, change rbp. 169 mov rbp, r11 170 %%done: 171 %endmacro 172 173 ;; 174 ; Wraps a function with 4 or less argument that will go into registers. 175 %macro NtWrapFunctionWithAllRegParams 1 176 extern NAME(%1) 177 BEGINPROC supdrvNtWrap%1 178 NtWrapProlog supdrvNtWrap%1 179 NtWrapLocateMarker 180 181 call NAME(%1) 182 183 NtWrapEpilog supdrvNtWrap%1 184 ENDPROC supdrvNtWrap%1 185 %endmacro 186 187 ;; 188 ; Wraps a function with 5 argument, where the first 4 goes into registers. 189 %macro NtWrapFunctionWith5Params 1 190 extern NAME(%1) 191 BEGINPROC supdrvNtWrap%1 192 NtWrapProlog supdrvNtWrap%1 193 NtWrapLocateMarker 194 195 mov r11, [rdi + 30h] 196 mov [rsp + 20h], r11 197 call NAME(%1) 198 199 NtWrapEpilog supdrvNtWrap%1 200 ENDPROC supdrvNtWrap%1 201 %endmacro 202 203 ;; 204 ; Wraps a function with 6 argument, where the first 4 goes into registers. 205 %macro NtWrapFunctionWith6Params 1 206 extern NAME(%1) 207 BEGINPROC supdrvNtWrap%1 208 NtWrapProlog supdrvNtWrap%1 209 NtWrapLocateMarker 210 211 mov r11, [rdi + 30h] 212 mov [rsp + 20h], r11 213 mov r10, [rdi + 38h] 214 mov [rsp + 28h], r10 215 call NAME(%1) 216 217 NtWrapEpilog supdrvNtWrap%1 218 ENDPROC supdrvNtWrap%1 219 %endmacro 220 221 ;; 222 ; Wraps a function with 7 argument, where the first 4 goes into registers. 223 %macro NtWrapFunctionWith7Params 1 224 extern NAME(%1) 225 BEGINPROC supdrvNtWrap%1 226 NtWrapProlog supdrvNtWrap%1 227 NtWrapLocateMarker 228 229 mov r11, [rdi + 30h] 230 mov [rsp + 20h], r11 231 mov r10, [rdi + 38h] 232 mov [rsp + 28h], r10 233 mov rax, [rdi + 40h] 234 mov [rsp + 30h], rax 235 call NAME(%1) 236 237 NtWrapEpilog supdrvNtWrap%1 238 ENDPROC supdrvNtWrap%1 239 %endmacro 240 241 extern IoGetStackLimits 242 243 ;; 244 ; Helper that cautiously continues the stack marker search 245 ; NtWrapLocateMarker started. 246 ; 247 ; The stack layout at the time is something like this. 248 ; rbp+08h callers return address. 249 ; rbp-00h saved rbp 250 ; rbp-08h saved rdi 251 ; rbp-09h 252 ; thru unused. 253 ; rbp-80h 254 ; rbp-88h our return address. 255 ; rbp-89h 256 ; thru callee register dump zone. 257 ; rbp-a0h 258 ; 259 ; @param rax Current stack location. 260 ; @param rdi Parent stack frame pointer. (This should equal rbp on entry.) 261 ; 262 ; Trashes: rax, r10, r11. 263 ; Will use the callers stack frame for register saving ASSUMING that 264 ; rbp-80h thru rbp-09h is unused. 265 ; 266 ; Modifies: rbp 267 ; 268 BEGINPROC NtWrapLocateMarkerHelper 269 ; 270 ; Prolog. Save volatile regs and reserve callee space. 271 ; 272 sub rsp, 20h ; For IoGetStackLimits(). 273 mov [rdi - 80h], rax 274 mov [rdi - 78h], rcx 275 mov [rdi - 70h], rdx 276 mov [rdi - 68h], r8 277 mov [rdi - 60h], r9 278 279 ; 280 ; Call VOID IoGetStackLimits(OUT PULONG_PTR LowLimit, OUT PULONG_PTR HighLimit); 281 ; 282 ; Use rdi-40h for the high limit and rdi-50h for the low one, we're only 283 ; interested in the high one. 284 ; 285 lea rcx, [rdi - 40h] ; arg #1 LowLimit 286 lea rdx, [rdi - 50h] ; arg #2 HighLimit 287 mov [rdx], eax ; paranoia - init to end of current search. 288 call IoGetStackLimits 289 290 ; 291 ; Move the top address into r10, restore rax and continue 292 ; the search. Check that r10 is less than 3 pages from rax. 293 ; 294 mov rax, [rdi - 80h] ; Restore eax (see prolog) 295 mov r10, [rdi - 50h] ; HighLimit 296 and r10, ~1fh ; 32-byte align it (downwards) 297 sub r10, rax 298 jz .not_found ; If already at the top of the stack. 299 cmp r10, 3000h 300 jae .out_of_bounds ; If too far away, something is busted. 301 shr r10, 5 ; /= 32. 302 303 ; The loop body. 304 .search_loop: 305 cmp dword [rax ], 0x20080901 306 je .candidate 307 .continue_searching: 308 dec r10 309 jz .not_found 310 lea rax, [rax + 20h] 311 jmp .search_loop 312 313 ; Found the first marker, check for the rest. 314 .candidate: 315 cmp dword [rax + 04h], 0x20080902 316 jne .continue_searching 317 cmp dword [rax + 10h], 0x20080903 318 jne .continue_searching 319 cmp dword [rax + 14h], 0x20080904 320 jne .continue_searching 321 mov r11, [rax + 08h] 322 cmp r11, [rax + 18h] 323 jne .continue_searching 324 325 ; found it, change rbp. 326 mov rbp, r11 327 328 ; 329 ; Restore registers and pop the stack frame. 330 ; 331 .epilog: 332 mov r9, [rdi - 60h] 333 mov r8, [rdi - 68h] 334 mov rdx, [rdi - 70h] 335 mov rcx, [rdi - 78h] 336 ; mov rax, [rdi - 80h] 337 add rsp, 20h 338 ret 339 340 ; 341 ; Needless to say, this isn't supposed to happen. Thus the int3. 342 ; Note down r10 and rax. 343 ; 344 .out_of_bounds: 345 %ifdef DEBUG 346 int3 347 %endif 348 .not_found: 349 %ifdef DEBUG 350 int3 351 %endif 352 jmp .epilog 353 ENDPROC NtWrapLocateMarkerHelper 354 355 356 357 ; 358 ; This has the same order as the list in SUPDrv.c 359 ; 360 NtWrapFunctionWithAllRegParams SUPR0ComponentRegisterFactory 361 NtWrapFunctionWithAllRegParams SUPR0ComponentDeregisterFactory 362 NtWrapFunctionWithAllRegParams SUPR0ComponentQueryFactory 363 NtWrapFunctionWith5Params SUPR0ObjRegister 364 NtWrapFunctionWithAllRegParams SUPR0ObjAddRef 365 NtWrapFunctionWithAllRegParams SUPR0ObjRelease 366 NtWrapFunctionWithAllRegParams SUPR0ObjVerifyAccess 367 NtWrapFunctionWithAllRegParams SUPR0LockMem 368 NtWrapFunctionWithAllRegParams SUPR0UnlockMem 369 NtWrapFunctionWith5Params SUPR0ContAlloc 370 NtWrapFunctionWithAllRegParams SUPR0ContFree 371 NtWrapFunctionWith5Params SUPR0LowAlloc 372 NtWrapFunctionWithAllRegParams SUPR0LowFree 373 NtWrapFunctionWithAllRegParams SUPR0MemAlloc 374 NtWrapFunctionWithAllRegParams SUPR0MemGetPhys 375 NtWrapFunctionWithAllRegParams SUPR0MemFree 376 NtWrapFunctionWithAllRegParams SUPR0PageAlloc 377 NtWrapFunctionWithAllRegParams SUPR0PageFree 378 ;NtWrapFunctionWithAllRegParams SUPR0Printf - cannot wrap this buster. 379 NtWrapFunctionWithAllRegParams RTMemAlloc 380 NtWrapFunctionWithAllRegParams RTMemAllocZ 381 NtWrapFunctionWithAllRegParams RTMemFree 382 NtWrapFunctionWithAllRegParams RTMemDup 383 NtWrapFunctionWithAllRegParams RTMemDupEx 384 NtWrapFunctionWithAllRegParams RTMemRealloc 385 NtWrapFunctionWithAllRegParams RTR0MemObjAllocLow 386 NtWrapFunctionWithAllRegParams RTR0MemObjAllocPage 387 NtWrapFunctionWithAllRegParams RTR0MemObjAllocPhys 388 NtWrapFunctionWithAllRegParams RTR0MemObjAllocPhysNC 389 NtWrapFunctionWithAllRegParams RTR0MemObjAllocCont 390 NtWrapFunctionWithAllRegParams RTR0MemObjLockUser 391 NtWrapFunctionWith5Params RTR0MemObjMapKernel 392 NtWrapFunctionWith6Params RTR0MemObjMapUser 393 NtWrapFunctionWithAllRegParams RTR0MemObjAddress 394 NtWrapFunctionWithAllRegParams RTR0MemObjAddressR3 395 NtWrapFunctionWithAllRegParams RTR0MemObjSize 396 NtWrapFunctionWithAllRegParams RTR0MemObjIsMapping 397 NtWrapFunctionWithAllRegParams RTR0MemObjGetPagePhysAddr 398 NtWrapFunctionWithAllRegParams RTR0MemObjFree 399 ;NtWrapFunctionWithAllRegParams RTProcSelf - not necessary 400 ;NtWrapFunctionWithAllRegParams RTR0ProcHandleSelf - not necessary 401 NtWrapFunctionWithAllRegParams RTSemFastMutexCreate 402 NtWrapFunctionWithAllRegParams RTSemFastMutexDestroy 403 NtWrapFunctionWithAllRegParams RTSemFastMutexRequest 404 NtWrapFunctionWithAllRegParams RTSemFastMutexRelease 405 NtWrapFunctionWithAllRegParams RTSemEventCreate 406 NtWrapFunctionWithAllRegParams RTSemEventSignal 407 NtWrapFunctionWithAllRegParams RTSemEventWait 408 NtWrapFunctionWithAllRegParams RTSemEventWaitNoResume 409 NtWrapFunctionWithAllRegParams RTSemEventDestroy 410 NtWrapFunctionWithAllRegParams RTSemEventMultiCreate 411 NtWrapFunctionWithAllRegParams RTSemEventMultiSignal 412 NtWrapFunctionWithAllRegParams RTSemEventMultiReset 413 NtWrapFunctionWithAllRegParams RTSemEventMultiWait 414 NtWrapFunctionWithAllRegParams RTSemEventMultiWaitNoResume 415 NtWrapFunctionWithAllRegParams RTSemEventMultiDestroy 416 NtWrapFunctionWithAllRegParams RTSpinlockCreate 417 NtWrapFunctionWithAllRegParams RTSpinlockDestroy 418 NtWrapFunctionWithAllRegParams RTSpinlockAcquire 419 NtWrapFunctionWithAllRegParams RTSpinlockRelease 420 NtWrapFunctionWithAllRegParams RTSpinlockAcquireNoInts 421 NtWrapFunctionWithAllRegParams RTSpinlockReleaseNoInts 422 ;NtWrapFunctionWithAllRegParams RTTimeNanoTS - not necessary 423 ;NtWrapFunctionWithAllRegParams RTTimeMilliTS - not necessary 424 ;NtWrapFunctionWithAllRegParams RTTimeSystemNanoTS - not necessary 425 ;NtWrapFunctionWithAllRegParams RTTimeSystemMilliTS - not necessary 426 ;NtWrapFunctionWithAllRegParams RTThreadNativeSelf - not necessary 427 NtWrapFunctionWithAllRegParams RTThreadSleep 428 NtWrapFunctionWithAllRegParams RTThreadYield 429 %if 0 ; Thread APIs, Part 2 430 ;NtWrapFunctionWithAllRegParams RTThreadSelf 431 NtWrapFunctionWith7Params RTThreadCreate 432 NtWrapFunctionWithAllRegParams RTThreadGetNative 433 NtWrapFunctionWithAllRegParams RTThreadWait 434 NtWrapFunctionWithAllRegParams RTThreadWaitNoResume 435 NtWrapFunctionWithAllRegParams RTThreadGetName 436 NtWrapFunctionWithAllRegParams RTThreadSelfName 437 NtWrapFunctionWithAllRegParams RTThreadGetType 438 NtWrapFunctionWithAllRegParams RTThreadUserSignal 439 NtWrapFunctionWithAllRegParams RTThreadUserReset 440 NtWrapFunctionWithAllRegParams RTThreadUserWait 441 NtWrapFunctionWithAllRegParams RTThreadUserWaitNoResume 442 %endif 443 ;NtWrapFunctionWithAllRegParams RTLogDefaultInstance - a bit of a gamble, but we do not want the overhead! 444 ;NtWrapFunctionWithAllRegParams RTMpCpuId - not necessary 445 ;NtWrapFunctionWithAllRegParams RTMpCpuIdFromSetIndex - not necessary 446 ;NtWrapFunctionWithAllRegParams RTMpCpuIdToSetIndex - not necessary 447 ;NtWrapFunctionWithAllRegParams RTMpIsCpuPossible - not necessary 448 ;NtWrapFunctionWithAllRegParams RTMpGetCount - not necessary 449 ;NtWrapFunctionWithAllRegParams RTMpGetMaxCpuId - not necessary 450 ;NtWrapFunctionWithAllRegParams RTMpGetOnlineCount - not necessary 451 ;NtWrapFunctionWithAllRegParams RTMpGetOnlineSet - not necessary 452 ;NtWrapFunctionWithAllRegParams RTMpGetSet - not necessary 453 ;NtWrapFunctionWithAllRegParams RTMpIsCpuOnline - not necessary 454 NtWrapFunctionWithAllRegParams RTMpOnAll 455 NtWrapFunctionWithAllRegParams RTMpOnOthers 456 NtWrapFunctionWithAllRegParams RTMpOnSpecific 457 ;NtWrapFunctionWithAllRegParams RTLogRelDefaultInstance - not necessary. 458 NtWrapFunctionWithAllRegParams RTLogSetDefaultInstanceThread 459 ;NtWrapFunctionWithAllRegParams RTLogLogger - can't wrap this buster. 460 ;NtWrapFunctionWithAllRegParams RTLogLoggerEx - can't wrap this buster. 461 NtWrapFunctionWithAllRegParams RTLogLoggerExV 462 ;NtWrapFunctionWithAllRegParams RTLogPrintf - can't wrap this buster. ;; @todo provide va_list log wrappers in RuntimeR0. 463 NtWrapFunctionWithAllRegParams RTLogPrintfV 464 NtWrapFunctionWithAllRegParams AssertMsg1 465 ;NtWrapFunctionWithAllRegParams AssertMsg2 - can't wrap this buster. 466 467 57 468 ;; 58 469 ; @cproto DECLASM(int) supdrvNtWrapVMMR0EntryEx(PFNRT pfnVMMR0EntryEx, PVM pVM, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession); … … 66 477 ; 67 478 BEGINPROC supdrvNtWrapVMMR0EntryEx 68 [proc_frame supdrvNtWrapVMMR0EntryEx] 69 push rbp 70 [pushreg rbp] 71 mov rbp, rsp 72 [setframe rbp,0] 73 sub rsp, 80h 74 [allocstack 0x80] 75 ;; @todo save more regs? 76 [endprolog] 77 78 ; 79 ; Create a stack marker with the rbp. The marker is 32 byte big. 80 ; This is 32-byte aligned and 32 byte in size. 81 ; 82 lea r10, [rbp - 30h] 83 and r10, ~1fh ; 32-byte align it. 84 mov dword [r10 ], 0x20080901 85 mov dword [r10 + 4], 0x20080902 86 mov qword [r10 + 8], rbp 87 mov dword [r10 +16], 0x20080903 88 mov dword [r10 +20], 0x20080904 89 mov qword [r10 +24], rbp 90 91 ; 92 ; Forward the call. 93 ; 479 NtWrapProlog supdrvNtWrapVMMR0EntryEx 480 NtWrapCreateMarker 481 94 482 mov rax, rcx 95 483 mov rcx, rdx … … 101 489 call rax 102 490 103 ; 104 ; Trash the stack marker. 105 ; 106 lea r10, [rbp - 30h] 107 and r10, ~1fh ; 32-byte align it. 108 mov qword [r10 ], rax 109 mov qword [r10 + 8], rax 110 mov qword [r10 +16], rax 111 mov qword [r10 +24], rax 112 113 leave 114 ret 115 [endproc_frame supdrvNtWrapVMMR0EntryEx] 491 NtWrapDestroyMarker 492 NtWrapEpilog supdrvNtWrapVMMR0EntryEx 116 493 ENDPROC supdrvNtWrapVMMR0EntryEx 117 494 118 495 119 extern RTSemEventMultiWaitNoResume 120 121 ;; 122 ; @cproto DECLASM(int) supdrvNtWrapRTSemEventMultiWaitNoResume(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies); 123 ; 124 ; @param EventMultiSem rcx 125 ; @param cMillies rdx 126 ; 127 BEGINPROC supdrvNtWrapRTSemEventMultiWaitNoResume 128 [proc_frame supdrvNtWrapRTSemEventMultiWaitNoResume] 129 push rbp 130 [pushreg rbp] 131 mov rbp, rsp 132 [setframe rbp,0] 133 sub rsp, 40h 134 [allocstack 0x40] 135 mov [rbp - 8h], rdi 136 [savereg rdi, 0x38] 137 ;; @todo save more? 138 ;mov [rbp - 10h], rsi 139 ;[savereg rsi, 0x30] 140 [endprolog] 141 142 ; 143 ; Find the stack marker with the rbp of the entry frame. 144 ; Search a maximum of 4096 bytes. 145 ; 146 mov rax, rbp 147 and rax, ~1fh ; 32-byte align it. 148 mov r10, 1000h / 20h 149 .again: 150 dec r10 151 jz .not_found 152 add rax, 20h 153 154 cmp dword [rax], 0x20080901 155 jne .again 156 cmp dword [rax + 4], 0x20080902 157 jne .again 158 cmp dword [rax + 16], 0x20080903 159 jne .again 160 cmp dword [rax + 20], 0x20080904 161 jne .again 162 mov r11, [rax + 8] 163 cmp r11, [rax + 24] 164 jne .again 165 166 ; found it, change rbp. 167 mov rdi, rbp 168 mov rbp, r11 169 170 ; 171 ; Forward the call. 172 ; 173 .resume: 174 call RTSemEventMultiWaitNoResume 175 176 ; 177 ; Restore rbp and any saved registers before returning. 178 ; 179 mov rbp, rdi 180 ;mov rsi, [rbp - 10h] 181 mov rdi, [rbp - 8h] 182 leave 183 ret 184 185 .not_found: 186 int3 187 mov rdi, rbp 188 jmp .resume 189 [endproc_frame supdrvNtWrapRTSemEventMultiWaitNoResume] 190 ENDPROC supdrvNtWrapRTSemEventMultiWaitNoResume 496 ;; 497 ; @cproto DECLASM(int) supdrvNtWrapVMMR0EntryFast(PFNRT pfnVMMR0EntryFast, PVM pVM, unsigned uOperation); 498 ; 499 ; @param pfnVMMR0EntryFast rcx 500 ; @param pVM rdx 501 ; @param uOperation r8 502 ; 503 BEGINPROC supdrvNtWrapVMMR0EntryFast 504 NtWrapProlog supdrvNtWrapVMMR0EntryFast 505 NtWrapCreateMarker 506 507 mov rax, rcx 508 mov rcx, rdx 509 mov rdx, r8 510 call rax 511 512 NtWrapDestroyMarker 513 NtWrapEpilog supdrvNtWrapVMMR0EntryFast 514 ENDPROC supdrvNtWrapVMMR0EntryFast 515 516 517 ;; 518 ; @cproto DECLASM(void) supdrvNtWrapObjDestructor(PFNRT pfnDestruction, void *pvObj, void *pvUser1, void *pvUser2); 519 ; 520 ; @param pfnDestruction rcx 521 ; @param pvObj rdx 522 ; @param pvUser1 r8 523 ; @param pvUser2 r9 524 ; 525 BEGINPROC supdrvNtWrapObjDestructor 526 NtWrapProlog supdrvNtWrapObjDestructor 527 NtWrapCreateMarker 528 529 mov rax, rcx 530 mov rcx, rdx 531 mov rdx, r8 532 mov r8, r9 533 call rax 534 535 NtWrapDestroyMarker 536 NtWrapEpilog supdrvNtWrapObjDestructor 537 ENDPROC supdrvNtWrapObjDestructor 538 539 540 ;; 541 ; @cproto DECLASM(void *) supdrvNtWrapQueryFactoryInterface(PFNRT pfnQueryFactoryInterface, struct SUPDRVFACTORY const *pSupDrvFactory, 542 ; PSUPDRVSESSION pSession, const char *pszInterfaceUuid); 543 ; 544 ; @param pfnQueryFactoryInterface rcx 545 ; @param pSupDrvFactory rdx 546 ; @param pSession r8 547 ; @param pszInterfaceUuid r9 548 ; 549 BEGINPROC supdrvNtWrapQueryFactoryInterface 550 NtWrapProlog supdrvNtWrapQueryFactoryInterface 551 NtWrapCreateMarker 552 553 mov rax, rcx 554 mov rcx, rdx 555 mov rdx, r8 556 mov r8, r9 557 call rax 558 559 NtWrapDestroyMarker 560 NtWrapEpilog supdrvNtWrapQueryFactoryInterface 561 ENDPROC supdrvNtWrapQueryFactoryInterface 562 563 564 ;; 565 ; @cproto DECLASM(int) supdrvNtWrapModuleInit(PFNRT pfnModuleInit); 566 ; 567 ; @param pfnModuleInit rcx 568 ; 569 BEGINPROC supdrvNtWrapModuleInit 570 NtWrapProlog supdrvNtWrapModuleInit 571 NtWrapCreateMarker 572 573 call rcx 574 575 NtWrapDestroyMarker 576 NtWrapEpilog supdrvNtWrapModuleInit 577 ENDPROC supdrvNtWrapModuleInit 578 579 580 ;; 581 ; @cproto DECLASM(void) supdrvNtWrapModuleTerm(PFNRT pfnModuleTerm); 582 ; 583 ; @param pfnModuleInit rcx 584 ; 585 BEGINPROC supdrvNtWrapModuleTerm 586 NtWrapProlog supdrvNtWrapModuleTerm 587 NtWrapCreateMarker 588 589 call rcx 590 591 NtWrapDestroyMarker 592 NtWrapEpilog supdrvNtWrapModuleTerm 593 ENDPROC supdrvNtWrapModuleTerm 594 595 191 596 192 597 %endif ; RT_ARCH_AMD64
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器