Change DivaGL detection method, fix non_nv_name

This commit is contained in:
nastys
2024-03-26 20:16:40 +01:00
parent 2c10f27ab0
commit b6fc62bbf1
5 changed files with 80 additions and 9 deletions
@@ -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;
}
@@ -1,6 +1,7 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <psapi.h>
#include <string>
#include <vector>
#include <map>
@@ -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;
}