Change DivaGL detection method, fix non_nv_name
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "glStuff.h"
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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<uint8_t> data)
|
||||
VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
memcpy(address, data.data(), byteCount);
|
||||
VirtualProtect(address, byteCount, oldProtect, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user