mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-28 13:52:07 -04:00
move loadGeode call to geode's DllMain
This commit is contained in:
parent
9031328821
commit
9acb07229b
3 changed files with 15 additions and 22 deletions
loader
|
@ -1,2 +1 @@
|
|||
#include <Windows.h>
|
||||
__declspec(dllexport) DWORD WINAPI loadGeode(void* arg) { return 0; }
|
||||
__declspec(dllexport) void fake() { }
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue