BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { #if defined(_WIN64) const char* pBitDepth = "64"; #else const char* pBitDepth = "32"; #endif switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: ReviveModule = (HMODULE)hModule; swprintf(ovrModuleName, MAX_PATH, L"LibOVRRT%hs_%d.dll", pBitDepth, OVR_MAJOR_VERSION); swprintf(revModuleName, MAX_PATH, L"LibRevive%hs_%d.dll", pBitDepth, OVR_MAJOR_VERSION); swprintf(ovrPlatformName, MAX_PATH, L"LibOVRPlatform%hs_%d", pBitDepth, OVR_MAJOR_VERSION); TrueIsError = (_IsError)DetourIATptr("ovr_Message_IsError", ovr_Message_IsError, GetModuleHandle(NULL)); DetourIATptr("ovr_IsEntitled", ovr_IsEntitled, GetModuleHandle(NULL)); MH_Initialize(); MH_CreateHook(LoadLibraryW, HookLoadLibrary, (PVOID*)&TrueLoadLibrary); MH_CreateHook(OpenEventW, HookOpenEvent, (PVOID*)&TrueOpenEvent); MH_EnableHook(LoadLibraryW); MH_EnableHook(OpenEventW); break; case DLL_PROCESS_DETACH: MH_RemoveHook(LoadLibraryW); MH_RemoveHook(OpenEventW); MH_Uninitialize(); break; default: break; } return TRUE; }
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { #if defined(_WIN64) const char* pBitDepth = "64"; #else const char* pBitDepth = "32"; #endif switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: ReviveModule = (HMODULE)hModule; swprintf(ovrModuleName, MAX_PATH, L"LibOVRRT%hs_%d.dll", pBitDepth, OVR_MAJOR_VERSION); MH_Initialize(); MH_CreateHook(LoadLibraryW, HookLoadLibrary, (PVOID*)&TrueLoadLibrary); MH_CreateHook(OpenEventW, HookOpenEvent, (PVOID*)&TrueOpenEvent); MH_CreateHook(GetProcAddress, HookGetProcAddress, (PVOID*)&TrueGetProcAddress); MH_EnableHook(LoadLibraryW); MH_EnableHook(OpenEventW); break; case DLL_PROCESS_DETACH: MH_RemoveHook(LoadLibraryW); MH_RemoveHook(OpenEventW); MH_RemoveHook(GetProcAddress); MH_Uninitialize(); break; default: break; } return TRUE; }
bool Utility::RemoveHook(void *target) { if (MH_DisableHook(target) != MH_OK) { return false; } return MH_RemoveHook(target) == MH_OK; }
AasAnimatedModelFactory::~AasAnimatedModelFactory() { functions.Exit(); MH_RemoveHook(temple::GetPointer<void*>(0x10269430)); MH_RemoveHook(functions.Free); sInstance = nullptr; }