diff --git a/source-code/dependencies/GPUModel/GPUModel.h b/source-code/dependencies/GPUModel/GPUModel.h index d7eaaf5..5cf3772 100644 --- a/source-code/dependencies/GPUModel/GPUModel.h +++ b/source-code/dependencies/GPUModel/GPUModel.h @@ -68,7 +68,7 @@ namespace GPUModel //DWORD dwAttrib = GetFileAttributesW(L"amdgfxinfo64.dll"); //if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) struct stat buffer; // for some reason winapi version wasn't working - if (stat("amdgfxinfo64.dll", &buffer) == 0); + if (stat("amdgfxinfo64.dll", &buffer) == 0) { non_nv_name = "AMD"; } diff --git a/source-code/source/plugins/Novidia/src/dllmain.cpp b/source-code/source/plugins/Novidia/src/dllmain.cpp index 62f2441..582c85b 100644 --- a/source-code/source/plugins/Novidia/src/dllmain.cpp +++ b/source-code/source/plugins/Novidia/src/dllmain.cpp @@ -380,10 +380,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - if (GetModuleHandleW(L"DivaGL.dva") != NULL) + if (hasConflicts()) { - // detected DivaGL - printf("[Novidia] Detected DivaGL! Quitting!\n"); + // detected an incompatible plugin (i.e. DivaGL) return TRUE; } diff --git a/source-code/source/plugins/Novidia/src/framework.h b/source-code/source/plugins/Novidia/src/framework.h index 6162c90..04ad41a 100644 --- a/source-code/source/plugins/Novidia/src/framework.h +++ b/source-code/source/plugins/Novidia/src/framework.h @@ -1,8 +1,13 @@ #pragma once -#include "glStuff.h" +#define WIN32_LEAN_AND_MEAN +#include +#include + #include +#include "glStuff.h" + // use this as a hook to perform initialisation void(__cdecl* glutSetCursor)(int cursor) = *(void(__cdecl**)(int))0x140966068; void(__cdecl* uploadModelTransformBuf)(DWORD* a1, int a2) = (void(__cdecl*)(DWORD * a1, int a2))0x140444fa0; @@ -112,4 +117,38 @@ void InjectCode(void* address, const std::vector data) VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect); memcpy(address, data.data(), byteCount); VirtualProtect(address, byteCount, oldProtect, nullptr); -} \ No newline at end of file +} + + +bool hasConflicts() +{ + HMODULE hModules[1024]; + HANDLE hProcess; + DWORD cbNeeded; + + hProcess = GetCurrentProcess(); + + if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { + for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { + TCHAR szModName[MAX_PATH]; + + if (GetModuleFileNameEx(hProcess, hModules[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { + auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); + if (pNameFunc) { + LPCWSTR name = pNameFunc(); + if (lstrcmpW(name, L"DivaGL") == 0) + { + // detected DivaGL + printf("[Novidia] Detected DivaGL! Quitting!\n"); +#ifdef _DEBUG + MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0); +#endif + return true; + } + } + } + } + } + + return false; +} diff --git a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp index 41efe30..ea2b4f0 100644 --- a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp +++ b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp @@ -294,10 +294,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - if (GetModuleHandleW(L"DivaGL.dva") != NULL) + if (hasConflicts()) { - // detected DivaGL - printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); + // detected an incompatible plugin (i.e. DivaGL) return TRUE; } diff --git a/source-code/source/plugins/ShaderPatch/src/framework.h b/source-code/source/plugins/ShaderPatch/src/framework.h index 69d14b1..d6477d9 100644 --- a/source-code/source/plugins/ShaderPatch/src/framework.h +++ b/source-code/source/plugins/ShaderPatch/src/framework.h @@ -1,6 +1,7 @@ #pragma once #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include +#include #include #include #include @@ -127,3 +128,36 @@ LPCWSTR DATA_FILE = DATA_FILE_STRING.c_str(); std::wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\ShaderPatchConfig.ini"; LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); + +bool hasConflicts() +{ + HMODULE hModules[1024]; + HANDLE hProcess; + DWORD cbNeeded; + + hProcess = GetCurrentProcess(); + + if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) { + for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { + TCHAR szModName[MAX_PATH]; + + if (GetModuleFileNameEx(hProcess, hModules[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { + auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName"); + if (pNameFunc) { + LPCWSTR name = pNameFunc(); + if (lstrcmpW(name, L"DivaGL") == 0) + { + // detected DivaGL + printf("[ShaderPatch] Detected DivaGL! Quitting!\n"); +#ifdef _DEBUG + MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0); +#endif + return true; + } + } + } + } + } + + return false; +}