aboutsummaryrefslogtreecommitdiff
path: root/loader_launcher_proxy
diff options
context:
space:
mode:
Diffstat (limited to 'loader_launcher_proxy')
-rw-r--r--loader_launcher_proxy/Memory.cpp11
-rw-r--r--loader_launcher_proxy/Memory.h36
-rw-r--r--loader_launcher_proxy/dllmain.cpp229
-rw-r--r--loader_launcher_proxy/framework.h4
-rw-r--r--loader_launcher_proxy/loader_launcher_proxy.vcxproj4
-rw-r--r--loader_launcher_proxy/pch.h2
6 files changed, 153 insertions, 133 deletions
diff --git a/loader_launcher_proxy/Memory.cpp b/loader_launcher_proxy/Memory.cpp
index 200246eb..344fa834 100644
--- a/loader_launcher_proxy/Memory.cpp
+++ b/loader_launcher_proxy/Memory.cpp
@@ -1,4 +1,5 @@
#include "pch.h"
+#include "Memory.h"
extern HMODULE hTier0Module;
IMemAlloc** g_ppMemAllocSingleton;
@@ -77,6 +78,12 @@ void* realloc(void* old_ptr, size_t size)
return nullptr;
}
-void* operator new(size_t n) { return malloc(n); }
+void* operator new(size_t n)
+{
+ return malloc(n);
+}
-void operator delete(void* p) { return free(p); }
+void operator delete(void* p) noexcept
+{
+ return free(p);
+}
diff --git a/loader_launcher_proxy/Memory.h b/loader_launcher_proxy/Memory.h
index c983966c..824d9d0f 100644
--- a/loader_launcher_proxy/Memory.h
+++ b/loader_launcher_proxy/Memory.h
@@ -2,23 +2,23 @@
class IMemAlloc
{
-public:
- struct VTable
- {
- void* unknown[1]; // alloc debug
- void* (*Alloc) (IMemAlloc* memAlloc, size_t nSize);
- void* unknown2[1]; // realloc debug
- void* (*Realloc)(IMemAlloc* memAlloc, void* pMem, size_t nSize);
- void* unknown3[1]; // free #1
- void (*Free) (IMemAlloc* memAlloc, void* pMem);
- void* unknown4[2]; // nullsubs, maybe CrtSetDbgFlag
- size_t(*GetSize) (IMemAlloc* memAlloc, void* pMem);
- void* unknown5[9]; // they all do literally nothing
- void (*DumpStats) (IMemAlloc* memAlloc);
- void (*DumpStatsFileBase) (IMemAlloc* memAlloc, const char* pchFileBase);
- void* unknown6[4];
- int (*heapchk) (IMemAlloc* memAlloc);
- };
+ public:
+ struct VTable
+ {
+ void* unknown[1]; // alloc debug
+ void* (*Alloc)(IMemAlloc* memAlloc, size_t nSize);
+ void* unknown2[1]; // realloc debug
+ void* (*Realloc)(IMemAlloc* memAlloc, void* pMem, size_t nSize);
+ void* unknown3[1]; // free #1
+ void (*Free)(IMemAlloc* memAlloc, void* pMem);
+ void* unknown4[2]; // nullsubs, maybe CrtSetDbgFlag
+ size_t (*GetSize)(IMemAlloc* memAlloc, void* pMem);
+ void* unknown5[9]; // they all do literally nothing
+ void (*DumpStats)(IMemAlloc* memAlloc);
+ void (*DumpStatsFileBase)(IMemAlloc* memAlloc, const char* pchFileBase);
+ void* unknown6[4];
+ int (*heapchk)(IMemAlloc* memAlloc);
+ };
- VTable* m_vtable;
+ VTable* m_vtable;
};
diff --git a/loader_launcher_proxy/dllmain.cpp b/loader_launcher_proxy/dllmain.cpp
index 1215ca1f..a382bc97 100644
--- a/loader_launcher_proxy/dllmain.cpp
+++ b/loader_launcher_proxy/dllmain.cpp
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string>
#include <system_error>
-#include <Shlwapi.h>
+#include <shlwapi.h>
#include <sstream>
#include <fstream>
#include <filesystem>
@@ -14,61 +14,64 @@ HMODULE hTier0Module;
using CreateInterfaceFn = void* (*)(const char* pName, int* pReturnCode);
// does not seem to ever be used
-extern "C" _declspec(dllexport) void* __fastcall CreateInterface(const char* pName, int* pReturnCode)
+extern "C" __declspec(dllexport) void* __fastcall CreateInterface(const char* pName, int* pReturnCode)
{
- //AppSystemCreateInterfaceFn(pName, pReturnCode);
- printf("external CreateInterface: name: %s\n", pName);
+ // AppSystemCreateInterfaceFn(pName, pReturnCode);
+ printf("external CreateInterface: name: %s\n", pName);
- static CreateInterfaceFn launcher_CreateInterface = (CreateInterfaceFn)GetProcAddress(hLauncherModule, "CreateInterface");
- auto res = launcher_CreateInterface(pName, pReturnCode);
+ static CreateInterfaceFn launcher_CreateInterface = (CreateInterfaceFn)GetProcAddress(hLauncherModule, "CreateInterface");
+ auto res = launcher_CreateInterface(pName, pReturnCode);
- printf("external CreateInterface: return code: %p\n", res);
- return res;
+ printf("external CreateInterface: return code: %p\n", res);
+ return res;
}
bool GetExePathWide(wchar_t* dest, DWORD destSize)
{
- if (!dest) return NULL;
- if (destSize < MAX_PATH) return NULL;
+ if (!dest)
+ return NULL;
+ if (destSize < MAX_PATH)
+ return NULL;
- DWORD length = GetModuleFileNameW(NULL, dest, destSize);
- return length && PathRemoveFileSpecW(dest);
+ DWORD length = GetModuleFileNameW(NULL, dest, destSize);
+ return length && PathRemoveFileSpecW(dest);
}
FARPROC GetLauncherMain()
{
- static FARPROC Launcher_LauncherMain;
- if (!Launcher_LauncherMain)
- Launcher_LauncherMain = GetProcAddress(hLauncherModule, "LauncherMain");
- return Launcher_LauncherMain;
+ static FARPROC Launcher_LauncherMain;
+ if (!Launcher_LauncherMain)
+ Launcher_LauncherMain = GetProcAddress(hLauncherModule, "LauncherMain");
+ return Launcher_LauncherMain;
}
void LibraryLoadError(DWORD dwMessageId, const wchar_t* libName, const wchar_t* location)
{
- char text[4096];
- std::string message = std::system_category().message(dwMessageId);
- sprintf_s(text, "Failed to load the %ls at \"%ls\" (%lu):\n\n%hs", libName, location, dwMessageId, message.c_str());
- if (dwMessageId == 126 && std::filesystem::exists(location))
- {
- sprintf_s(text, "%s\n\nThe file at the specified location DOES exist, so this error indicates that one of its *dependencies* failed to be found.", text);
- }
- MessageBoxA(GetForegroundWindow(), text, "Northstar Launcher Proxy Error", 0);
+ char text[4096];
+ std::string message = std::system_category().message(dwMessageId);
+ sprintf_s(text, "Failed to load the %ls at \"%ls\" (%lu):\n\n%hs", libName, location, dwMessageId, message.c_str());
+ if (dwMessageId == 126 && std::filesystem::exists(location))
+ {
+ sprintf_s(
+ text,
+ "%s\n\nThe file at the specified location DOES exist, so this error indicates that one of its *dependencies* failed to be "
+ "found.",
+ text);
+ }
+ MessageBoxA(GetForegroundWindow(), text, "Northstar Launcher Proxy Error", 0);
}
-BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
+BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
}
wchar_t exePath[4096];
@@ -76,86 +79,96 @@ wchar_t dllPath[4096];
bool ShouldLoadNorthstar()
{
- bool loadNorthstar = !strstr(GetCommandLineA(), "-vanilla");
-
- if (!loadNorthstar)
- return loadNorthstar;
-
- auto runNorthstarFile = std::ifstream("run_northstar.txt");
- if (runNorthstarFile)
- {
- std::stringstream runNorthstarFileBuffer;
- runNorthstarFileBuffer << runNorthstarFile.rdbuf();
- runNorthstarFile.close();
- if (runNorthstarFileBuffer.str()._Starts_with("0"))
- loadNorthstar = false;
- }
- return loadNorthstar;
+ bool loadNorthstar = !strstr(GetCommandLineA(), "-vanilla");
+
+ if (!loadNorthstar)
+ return loadNorthstar;
+
+ auto runNorthstarFile = std::ifstream("run_northstar.txt");
+ if (runNorthstarFile)
+ {
+ std::stringstream runNorthstarFileBuffer;
+ runNorthstarFileBuffer << runNorthstarFile.rdbuf();
+ runNorthstarFile.close();
+ if (runNorthstarFileBuffer.str().starts_with("0"))
+ loadNorthstar = false;
+ }
+ return loadNorthstar;
}
bool LoadNorthstar()
{
- FARPROC Hook_Init = nullptr;
- {
- swprintf_s(dllPath, L"%s\\Northstar.dll", exePath);
- hHookModule = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar");
- if (!hHookModule || Hook_Init == nullptr)
- {
- LibraryLoadError(GetLastError(), L"Northstar.dll", dllPath);
- return false;
- }
- }
-
- ((bool (*)()) Hook_Init)();
- return true;
+ FARPROC Hook_Init = nullptr;
+ {
+ swprintf_s(dllPath, L"%s\\Northstar.dll", exePath);
+ hHookModule = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (hHookModule)
+ Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar");
+ if (!hHookModule || Hook_Init == nullptr)
+ {
+ LibraryLoadError(GetLastError(), L"Northstar.dll", dllPath);
+ return false;
+ }
+ }
+
+ ((bool (*)())Hook_Init)();
+ return true;
}
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.", "Northstar Launcher Proxy Error", 0);
- return 1;
- }
-
- bool loadNorthstar = ShouldLoadNorthstar();
-
- if (loadNorthstar)
- {
- swprintf_s(dllPath, L"%s\\bin\\x64_retail\\tier0.dll", exePath);
- hTier0Module = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (!hTier0Module)
- {
- LibraryLoadError(GetLastError(), L"tier0.dll", dllPath);
- return 1;
- }
-
- if (!LoadNorthstar())
- return 1;
- }
- //else printf("\n\n WILL !!!NOT!!! LOAD NORTHSTAR\n\n");
-
- swprintf_s(dllPath, L"%s\\bin\\x64_retail\\launcher.org.dll", exePath);
- hLauncherModule = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (!hLauncherModule)
- {
- LibraryLoadError(GetLastError(), L"launcher.org.dll", dllPath);
- return 1;
- }
- }
-
- auto LauncherMain = GetLauncherMain();
- if (!LauncherMain)
- MessageBoxA(GetForegroundWindow(), "Failed loading launcher.org.dll.\nThe game cannot continue and has to exit.", "Northstar Launcher Proxy Error", 0);
- //auto result = ((__int64(__fastcall*)())LauncherMain)();
- //auto result = ((signed __int64(__fastcall*)(__int64))LauncherMain)(0i64);
- return ((int(__fastcall*)(HINSTANCE, HINSTANCE, LPSTR, int))LauncherMain)(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+ {
+ if (!GetExePathWide(exePath, 4096))
+ {
+ MessageBoxA(
+ GetForegroundWindow(),
+ "Failed getting game directory.\nThe game cannot continue and has to exit.",
+ "Northstar Launcher Proxy Error",
+ 0);
+ return 1;
+ }
+
+ bool loadNorthstar = ShouldLoadNorthstar();
+
+ if (loadNorthstar)
+ {
+ swprintf_s(dllPath, L"%s\\bin\\x64_retail\\tier0.dll", exePath);
+ hTier0Module = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (!hTier0Module)
+ {
+ LibraryLoadError(GetLastError(), L"tier0.dll", dllPath);
+ return 1;
+ }
+
+ if (!LoadNorthstar())
+ return 1;
+ }
+ // else printf("\n\n WILL !!!NOT!!! LOAD NORTHSTAR\n\n");
+
+ swprintf_s(dllPath, L"%s\\bin\\x64_retail\\launcher.org.dll", exePath);
+ hLauncherModule = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (!hLauncherModule)
+ {
+ LibraryLoadError(GetLastError(), L"launcher.org.dll", dllPath);
+ return 1;
+ }
+ }
+
+ auto LauncherMain = GetLauncherMain();
+ if (!LauncherMain)
+ MessageBoxA(
+ GetForegroundWindow(),
+ "Failed loading launcher.org.dll.\nThe game cannot continue and has to exit.",
+ "Northstar Launcher Proxy Error",
+ 0);
+ // auto result = ((__int64(__fastcall*)())LauncherMain)();
+ // auto result = ((signed __int64(__fastcall*)(__int64))LauncherMain)(0i64);
+ return ((int(__fastcall*)(HINSTANCE, HINSTANCE, LPSTR, int))LauncherMain)(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
// doubt that will help us here (in launcher.dll) though
-extern "C" {
- __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
- __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
+extern "C"
+{
+ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
+ __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}
diff --git a/loader_launcher_proxy/framework.h b/loader_launcher_proxy/framework.h
index d1b49600..2fd581a2 100644
--- a/loader_launcher_proxy/framework.h
+++ b/loader_launcher_proxy/framework.h
@@ -1,7 +1,7 @@
#pragma once
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from windows.headers
#define WIN32_EXTRA_LEAN
#define VC_EXTRALEAN
// Windows Header Files
-#include <Windows.h>
+#include <windows.h>
diff --git a/loader_launcher_proxy/loader_launcher_proxy.vcxproj b/loader_launcher_proxy/loader_launcher_proxy.vcxproj
index 24cdabc0..b62ac63f 100644
--- a/loader_launcher_proxy/loader_launcher_proxy.vcxproj
+++ b/loader_launcher_proxy/loader_launcher_proxy.vcxproj
@@ -59,7 +59,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
- <LanguageStandard>stdcpp17</LanguageStandard>
+ <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -78,7 +78,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
- <LanguageStandard>stdcpp17</LanguageStandard>
+ <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
diff --git a/loader_launcher_proxy/pch.h b/loader_launcher_proxy/pch.h
index 885d5d62..cc757129 100644
--- a/loader_launcher_proxy/pch.h
+++ b/loader_launcher_proxy/pch.h
@@ -10,4 +10,4 @@
// add headers that you want to pre-compile here
#include "framework.h"
-#endif //PCH_H
+#endif // PCH_H