OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* params) { MH_QueueDisableHook(LoadLibraryW); MH_QueueDisableHook(OpenEventW); MH_ApplyQueued(); g_hXInputLib = LoadLibraryW(L"xinput1_3.dll"); if (!g_hXInputLib) return ovrError_LibLoad; g_pXInputGetState = (_XInputGetState)GetProcAddress(g_hXInputLib, "XInputGetState"); if (!g_pXInputGetState) return ovrError_LibLoad; g_pXInputSetState = (_XInputSetState)GetProcAddress(g_hXInputLib, "XInputSetState"); if (!g_pXInputSetState) return ovrError_LibLoad; g_VRSystem = vr::VR_Init(&g_InitError, vr::VRApplication_Scene); MH_QueueEnableHook(LoadLibraryW); MH_QueueEnableHook(OpenEventW); MH_ApplyQueued(); return REV_InitErrorToOvrError(g_InitError); }
OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* params) { MH_QueueDisableHook(LoadLibraryW); MH_QueueDisableHook(OpenEventW); MH_ApplyQueued(); g_VRSystem = vr::VR_Init(&g_InitError, vr::VRApplication_Scene); MH_QueueEnableHook(LoadLibraryW); MH_QueueEnableHook(OpenEventW); MH_ApplyQueued(); return REV_InitErrorToOvrError(g_InitError); }
MH_STATUS WINAPI MH_CreateHookApiEx(LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal,BOOL bQueue) { HMODULE hModule; LPVOID pTarget; MH_STATUS err; hModule = GetModuleHandleW(pszModule); if (hModule == NULL) return MH_ERROR_MODULE_NOT_FOUND; pTarget = (LPVOID)GetProcAddress(hModule, pszProcName); if (pTarget == NULL) return MH_ERROR_FUNCTION_NOT_FOUND; err = MH_CreateHook(pTarget, pDetour, ppOriginal); if (err == MH_OK && bQueue) err = MH_QueueEnableHook(pTarget); return err; }