DivaGL, glut32, and conflict detection in Launcher

This commit is contained in:
nastys
2024-03-30 21:07:17 +01:00
parent eb6964d0b9
commit 232ac31190
3 changed files with 144 additions and 52 deletions
@@ -1,7 +1,7 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <psapi.h>
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
//#include <windows.h>
//#include <psapi.h>
#include <string>
#include <vector>
#include <map>
@@ -128,36 +128,55 @@ 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()
//{
// printf("[ShaderPatch] Checking for conflicts...\n");
//
// HMODULE* hModules = new HMODULE[USHRT_MAX];
// HANDLE hProcess;
// DWORD cbNeeded;
//
// hProcess = GetCurrentProcess();
//
// if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) {
// for (unsigned long long i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
// auto pNameFunc = (LPCWSTR(*)())GetProcAddress(hModules[i], "GetPluginName");
// if (pNameFunc) {
// LPCWSTR name = pNameFunc();
// if (name && 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
// delete[] hModules;
// return true;
// }
// }
// }
// }
//
// printf("[ShaderPatch] No conflicts found.\n");
// delete[] hModules;
// return false;
//}
bool hasConflicts()
{
HMODULE hModules[1024];
HANDLE hProcess;
DWORD cbNeeded;
printf("[ShaderPatch] Checking for conflicts...\n");
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");
if (GetModuleHandleW(L"DivaGL.dva") != NULL)
{
// detected DivaGL
printf("[ShaderPatch] Detected DivaGL! Quitting!\n");
#ifdef _DEBUG
MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0);
MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"ShaderPatch", MB_OK, 0);
#endif
return true;
}
}
}
}
return true;
}
printf("[ShaderPatch] No conflicts found.\n");
return false;
}