aboutsummaryrefslogtreecommitdiff
path: root/loader_launcher_proxy/dllmain.cpp
diff options
context:
space:
mode:
authorp0358 <p0358@users.noreply.github.com>2021-12-29 06:38:54 +0100
committerp0358 <p0358@users.noreply.github.com>2021-12-29 06:38:54 +0100
commit213bf6412410a09b0bdce62b8598bfa23ba096cf (patch)
tree68c650c35639a71e834d4e3fc964ee5bf65a9d28 /loader_launcher_proxy/dllmain.cpp
parent8a1a2e97624d15617197248a5e292c5ead5e74a2 (diff)
downloadNorthstarLauncher-213bf6412410a09b0bdce62b8598bfa23ba096cf.tar.gz
NorthstarLauncher-213bf6412410a09b0bdce62b8598bfa23ba096cf.zip
Add direct launcher
Diffstat (limited to 'loader_launcher_proxy/dllmain.cpp')
-rw-r--r--loader_launcher_proxy/dllmain.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/loader_launcher_proxy/dllmain.cpp b/loader_launcher_proxy/dllmain.cpp
index 6e0d1f07..31360a8e 100644
--- a/loader_launcher_proxy/dllmain.cpp
+++ b/loader_launcher_proxy/dllmain.cpp
@@ -22,7 +22,7 @@ extern "C" _declspec(dllexport) void* __fastcall CreateInterface(const char* pNa
return res;
}
-bool GetExePathWide(wchar_t* dest, size_t destSize)
+bool GetExePathWide(wchar_t* dest, DWORD destSize)
{
if (!dest) return NULL;
if (destSize < MAX_PATH) return NULL;
@@ -66,45 +66,48 @@ BOOL APIENTRY DllMain( HMODULE hModule,
wchar_t exePath[4096];
wchar_t dllPath[4096];
-extern "C" _declspec(dllexport) void LauncherMain(__int64, __int64, __int64, uint32_t)
+extern "C" __declspec(dllexport) int LauncherMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
{
-
if (!GetExePathWide(exePath, 4096))
{
MessageBoxA(GetForegroundWindow(), "Failed getting game directory.\nThe game cannot continue and has to exit.", "Launcher Error", 0);
- return;
+ return 1;
}
- FARPROC Hook_Init = nullptr;
+ bool loadNorthstar = !strstr(GetCommandLineA(), "-vanilla");
+ if (loadNorthstar)
{
- swprintf_s(dllPath, L"%s\\Northstar.dll", exePath);
- hHookModule = LoadLibraryExW(dllPath, 0i64, 8u);
- if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar");
- if (!hHookModule || Hook_Init == nullptr)
+ FARPROC Hook_Init = nullptr;
{
- LibraryLoadError(GetLastError(), L"Northstar.dll", dllPath);
- return;
+ swprintf_s(dllPath, L"%s\\Northstar.dll", exePath);
+ hHookModule = LoadLibraryExW(dllPath, 0i64, 8u);
+ if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar");
+ if (!hHookModule || Hook_Init == nullptr)
+ {
+ LibraryLoadError(GetLastError(), L"Northstar.dll", dllPath);
+ return 1;
+ }
}
- }
- ((void (*)()) Hook_Init)();
- }
+ ((bool (*)()) Hook_Init)();
+ }
- {
swprintf_s(dllPath, L"%s\\bin\\x64_retail\\launcher.org.dll", exePath);
hLauncherModule = LoadLibraryExW(dllPath, 0i64, 8u);
if (!hLauncherModule)
{
LibraryLoadError(GetLastError(), L"launcher.org.dll", dllPath);
- return;
+ return 1;
}
}
auto LauncherMain = GetLauncherMain();
+ if (!LauncherMain)
+ MessageBoxA(GetForegroundWindow(), "Failed loading launcher.org.dll.\nThe game cannot continue and has to exit.", "Launcher Error", 0);
//auto result = ((__int64(__fastcall*)())LauncherMain)();
//auto result = ((signed __int64(__fastcall*)(__int64))LauncherMain)(0i64);
- auto result = ((signed __int64(__fastcall*)(__int64, __int64, __int64, uint32_t))LauncherMain)(0i64, 0i64, 0i64, 0);
+ return ((int(__fastcall*)(HINSTANCE, HINSTANCE, LPSTR, int))LauncherMain)(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
// doubt that will help us here (in launcher.dll) though