DivaGL, glut32, and conflict detection in Launcher
This commit is contained in:
@@ -190,6 +190,7 @@ namespace Launcher {
|
||||
|
||||
updateStyle();
|
||||
|
||||
checkHasInvalidGLUT();
|
||||
|
||||
glutInit(&argc, argv);
|
||||
int window = glutCreateWindow("glut"); // a context must be created to use glGetString
|
||||
@@ -1095,10 +1096,64 @@ private: System::Void SaveSettings() {
|
||||
private: System::Void Button_Help_Click(System::Object^ sender, System::EventArgs^ e) {
|
||||
System::Diagnostics::Process::Start("https://github.com/PDModdingCommunity/PD-Loader/wiki");
|
||||
}
|
||||
private: System::Boolean hasInvalidGLUT = false;
|
||||
private: System::Void checkHasInvalidGLUT()
|
||||
{
|
||||
HMODULE glutHm = GetModuleHandleW(L"glut32.dll");
|
||||
hasInvalidGLUT = glutHm != NULL && GetProcAddress(glutHm, "__glutGetFCB") == NULL;
|
||||
|
||||
if (hasInvalidGLUT)
|
||||
{
|
||||
SkinnedMessageBox::Show(this, "Support for custom versions of \"glut32.dll\" is deprecated and will be removed in future versions of PD Loader.\nPlease restore a valid copy of the original file, then validate your files and make sure \"glut32.dll\" passes.\n\nPlease DO NOT ASK for a copy of the file in our support channels!\nWe cannot provide it to you.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
||||
}
|
||||
}
|
||||
private: System::Boolean hasInvalidSettings()
|
||||
{
|
||||
bool divaGLEnabled = false;
|
||||
bool novidiaEnabled = false;
|
||||
bool shaderPatchEnabled = false;
|
||||
|
||||
for (ConfigOptionBase* option : AllPluginOpts)
|
||||
{
|
||||
if (lstrcmpW(option->_friendlyName, L"DivaGL") == 0)
|
||||
{
|
||||
divaGLEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked;
|
||||
if (divaGLEnabled)
|
||||
{
|
||||
if (hasInvalidGLUT) goto divagl_freeglut;
|
||||
else if (novidiaEnabled) goto divagl_novidia;
|
||||
else if (shaderPatchEnabled) goto divagl_shaderpatch;
|
||||
}
|
||||
}
|
||||
else if (lstrcmpW(option->_friendlyName, L"Novidia") == 0)
|
||||
{
|
||||
novidiaEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked;
|
||||
if (novidiaEnabled && divaGLEnabled) goto divagl_novidia;
|
||||
}
|
||||
else if (lstrcmpW(option->_friendlyName, L"ShaderPatch") == 0)
|
||||
{
|
||||
shaderPatchEnabled = ((CheckBox^)CheckBox::FromHandle(option->mainControlHandle))->Checked;
|
||||
if (shaderPatchEnabled && divaGLEnabled) goto divagl_shaderpatch;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
divagl_freeglut:
|
||||
SkinnedMessageBox::Show(this, "Plugins: DivaGL does not support custom versions of \"glut32.dll\".\nPlease restore a valid copy of the original file, then validate your files and make sure \"glut32.dll\" passes.\n\nPlease DO NOT ASK for a copy of the file in our support channels!\nWe cannot provide it to you.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
||||
return true;
|
||||
|
||||
divagl_novidia:
|
||||
divagl_shaderpatch:
|
||||
SkinnedMessageBox::Show(this, "Plugins: Novidia and ShaderPatch must be disabled if DivaGL is enabled.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
||||
return true;
|
||||
}
|
||||
private: System::Void Button_Launch_Click(System::Object^ sender, System::EventArgs^ e) {
|
||||
|
||||
//SkinnedMessageBox::Show(this, "It looks like the executable has been tampered with, or the version of the game is not 7.10.\n\nPlease use the \"patches\" folder instead of modifying the executable directly (or disable verification).", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
||||
|
||||
if (hasInvalidSettings()) return;
|
||||
|
||||
SaveSettings();
|
||||
|
||||
if (GetPrivateProfileIntW(LAUNCHER_SECTION, L"use_divahook_bat", FALSE, CONFIG_FILE))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
//#include <windows.h>
|
||||
//#include <psapi.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -119,36 +119,54 @@ void InjectCode(void* address, const std::vector<uint8_t> data)
|
||||
VirtualProtect(address, byteCount, oldProtect, nullptr);
|
||||
}
|
||||
|
||||
//bool hasConflicts()
|
||||
//{
|
||||
// printf("[Novidia] 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("[Novidia] Detected DivaGL! Quitting!\n");
|
||||
//#ifdef _DEBUG
|
||||
// MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0);
|
||||
//#endif
|
||||
// delete[] hModules;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// printf("[Novidia] No conflicts found.\n");
|
||||
// delete[] hModules;
|
||||
// return false;
|
||||
//}
|
||||
|
||||
bool hasConflicts()
|
||||
{
|
||||
HMODULE hModules[1024];
|
||||
HANDLE hProcess;
|
||||
DWORD cbNeeded;
|
||||
printf("[Novidia] 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("[Novidia] Detected DivaGL! Quitting!\n");
|
||||
if(GetModuleHandleW(L"DivaGL.dva") != NULL)
|
||||
{
|
||||
// detected DivaGL
|
||||
printf("[Novidia] Detected DivaGL! Quitting!\n");
|
||||
#ifdef _DEBUG
|
||||
MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0);
|
||||
MessageBoxExW(NULL, L"Detected DivaGL! Quitting!\n", L"Novidia", MB_OK, 0);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
printf("[Novidia] No conflicts found.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user