diff --git a/loader/launcher/windows/fakeGeode.c b/loader/launcher/windows/fakeGeode.c index c33e5e8e..0928d953 100644 --- a/loader/launcher/windows/fakeGeode.c +++ b/loader/launcher/windows/fakeGeode.c @@ -1,2 +1 @@ -#include <Windows.h> -__declspec(dllexport) DWORD WINAPI loadGeode(void* arg) { return 0; } \ No newline at end of file +__declspec(dllexport) void fake() { } \ No newline at end of file diff --git a/loader/launcher/windows/proxyLoader.c b/loader/launcher/windows/proxyLoader.c index f080545c..d6d9d95f 100644 --- a/loader/launcher/windows/proxyLoader.c +++ b/loader/launcher/windows/proxyLoader.c @@ -5,23 +5,10 @@ #pragma comment(linker, "/export:XInputSetState=xinput1_4.XInputSetState") #pragma comment(linker, "/export:XInputGetCapabilities=xinput1_4.XInputGetCapabilities") +__declspec(dllimport) void fake(); DWORD XInputGetDSoundAudioDeviceGuids(DWORD user, GUID* render, GUID* capture) { + fake(); return ERROR_BAD_ARGUMENTS; } #pragma comment(linker, "/export:XInputGetDSoundAudioDeviceGuids=_XInputGetDSoundAudioDeviceGuids") - -__declspec(dllimport) DWORD WINAPI loadGeode(void*); -BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID _) { - if (reason == DLL_PROCESS_ATTACH) { - // Prevents threads from notifying this DLL on creation or destruction. - // Kind of redundant for a game that isn't multi-threaded but will provide - // some slight optimizations if a mod frequently creates and deletes threads. - DisableThreadLibraryCalls(module); - - DWORD code = loadGeode(module); - if (code != 0) - return FALSE; - } - return TRUE; -} diff --git a/loader/src/platform/windows/main.cpp b/loader/src/platform/windows/main.cpp index e1184f39..85a58c2a 100644 --- a/loader/src/platform/windows/main.cpp +++ b/loader/src/platform/windows/main.cpp @@ -42,7 +42,7 @@ int WINAPI gdMainHook(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd return reinterpret_cast<decltype(&wWinMain)>(geode::base::get() + 0x260ff8)(hInstance, hPrevInstance, lpCmdLine, nCmdShow); } -extern "C" __declspec(dllexport) DWORD WINAPI loadGeode(void* arg) { +bool loadGeode(void* arg) { auto process = GetCurrentProcess(); auto patchAddr = reinterpret_cast<void*>(geode::base::get() + 0x260ff8); @@ -68,10 +68,10 @@ extern "C" __declspec(dllexport) DWORD WINAPI loadGeode(void* arg) { "There was an unknown fatal error hooking " "the GD main function and Geode can not be loaded." ); - return 1; + return false; } - return 0; + return true; } DWORD WINAPI upgradeThread(void*) { @@ -79,16 +79,23 @@ DWORD WINAPI upgradeThread(void*) { return 0; } +extern "C" __declspec(dllexport) void fake() { } BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID) { if (reason == DLL_PROCESS_ATTACH) { + // Prevents threads from notifying this DLL on creation or destruction. + // Kind of redundant for a game that isn't multi-threaded but will provide + // some slight optimizations if a mod frequently creates and deletes threads. DisableThreadLibraryCalls(module); // if we find the old bootstrapper dll, don't load geode, copy new updater and let it do the rest auto workingDir = dirs::getGameDir(); auto error = std::error_code(); - if (ghc::filesystem::exists(workingDir / "GeodeBootstrapper.dll", error) && !error) + bool oldBootstrapperExists = ghc::filesystem::exists(workingDir / "GeodeBootstrapper.dll", error); + if (oldBootstrapperExists && !error) CreateThread(nullptr, 0, upgradeThread, nullptr, 0, nullptr); - if (error) + else if (error) + return FALSE; + else if (!loadGeode(module)) return FALSE; } return TRUE;