Skip to content

Commit 2d586f8

Browse files
committed
Add exception to Detours for Roblox.
1 parent 174d4f8 commit 2d586f8

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

virtualdesktop-openxr/instance.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -786,24 +786,41 @@ extern "C" __declspec(dllexport) const char* WINAPI getVersionString() {
786786
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
787787
using namespace virtualdesktop_openxr::utils;
788788

789+
const auto getExeName = []() {
790+
char path[_MAX_PATH];
791+
GetModuleFileNameA(nullptr, path, sizeof(path));
792+
std::filesystem::path fullPath(path);
793+
return fullPath.filename().string();
794+
};
795+
789796
switch (ul_reason_for_call) {
790-
case DLL_PROCESS_ATTACH:
797+
case DLL_PROCESS_ATTACH: {
791798
#ifdef _WIN64
792-
DetourRestoreAfterWith();
799+
// Roblox anti-cheat does not like Detours. We only need Detours for OVRPlugin compatibility, hence it is OK to
800+
// skip with Roblox.
801+
const bool noDetours = startsWith(getExeName(), "RobloxPlayer");
802+
if (!noDetours) {
803+
DetourRestoreAfterWith();
804+
}
793805
#endif
794806
TraceLoggingRegister(virtualdesktop_openxr::log::g_traceProvider);
795807
virtualdesktop_openxr::utils::InitializeHighPrecisionTimer();
796808
#ifdef _WIN64
797-
DetourDllAttach("Kernel32", "OpenEventW", hooked_OpenEventW, original_OpenEventW);
809+
if (!noDetours) {
810+
DetourDllAttach("Kernel32", "OpenEventW", hooked_OpenEventW, original_OpenEventW);
811+
}
798812
#endif
799-
break;
813+
} break;
800814

801-
case DLL_PROCESS_DETACH:
815+
case DLL_PROCESS_DETACH: {
802816
#ifdef _WIN64
803-
DetourDllDetach("Kernel32", "OpenEventW", hooked_OpenEventW, original_OpenEventW);
817+
const bool noDetours = startsWith(getExeName(), "RobloxPlayer");
818+
if (!noDetours) {
819+
DetourDllDetach("Kernel32", "OpenEventW", hooked_OpenEventW, original_OpenEventW);
820+
}
804821
#endif
805822
TraceLoggingUnregister(virtualdesktop_openxr::log::g_traceProvider);
806-
break;
823+
} break;
807824

808825
case DLL_THREAD_ATTACH:
809826
case DLL_THREAD_DETACH:

0 commit comments

Comments
 (0)