aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LauncherInjector/LauncherInjector.vcxproj73
-rw-r--r--LauncherInjector/LauncherInjector.vcxproj.filters6
-rw-r--r--LauncherInjector/main.cpp265
-rw-r--r--LauncherInjector/memalloc.cpp64
-rw-r--r--LauncherInjector/memalloc.h15
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj73
-rw-r--r--NorthstarDedicatedTest/dedicated.cpp5
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp26
-rw-r--r--NorthstarDedicatedTest/gameutils.cpp31
-rw-r--r--NorthstarDedicatedTest/hooks.cpp136
-rw-r--r--NorthstarDedicatedTest/main.h2
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp75
-rw-r--r--NorthstarDedicatedTest/masterserver.h3
-rw-r--r--NorthstarDedicatedTest/memalloc.cpp30
-rw-r--r--R2Northstar.sln19
-rw-r--r--loader_launcher_proxy/Memory.cpp59
-rw-r--r--loader_launcher_proxy/Memory.h15
-rw-r--r--loader_launcher_proxy/dllmain.cpp158
-rw-r--r--loader_launcher_proxy/framework.h5
-rw-r--r--loader_launcher_proxy/loader_launcher_proxy.vcxproj109
-rw-r--r--loader_launcher_proxy/loader_launcher_proxy.vcxproj.filters39
-rw-r--r--loader_launcher_proxy/pch.cpp5
-rw-r--r--loader_launcher_proxy/pch.h15
23 files changed, 923 insertions, 305 deletions
diff --git a/LauncherInjector/LauncherInjector.vcxproj b/LauncherInjector/LauncherInjector.vcxproj
index e205207d..289d66ae 100644
--- a/LauncherInjector/LauncherInjector.vcxproj
+++ b/LauncherInjector/LauncherInjector.vcxproj
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
@@ -27,19 +19,6 @@
<ProjectName>NorthstarLauncher</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
@@ -58,12 +37,6 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
@@ -71,50 +44,12 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -122,10 +57,13 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
+ <AdditionalOptions>/F8000000 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <StackReserveSize>8000000</StackReserveSize>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -137,18 +75,23 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
+ <AdditionalOptions>/F8000000 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <StackReserveSize>8000000</StackReserveSize>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
+ <ClCompile Include="memalloc.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="memalloc.h" />
<ClInclude Include="resource1.h" />
</ItemGroup>
<ItemGroup>
diff --git a/LauncherInjector/LauncherInjector.vcxproj.filters b/LauncherInjector/LauncherInjector.vcxproj.filters
index 87e25fa8..2e935b08 100644
--- a/LauncherInjector/LauncherInjector.vcxproj.filters
+++ b/LauncherInjector/LauncherInjector.vcxproj.filters
@@ -18,11 +18,17 @@
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="memalloc.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource1.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="memalloc.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources.rc">
diff --git a/LauncherInjector/main.cpp b/LauncherInjector/main.cpp
index 5828e9e2..1eca067a 100644
--- a/LauncherInjector/main.cpp
+++ b/LauncherInjector/main.cpp
@@ -1,12 +1,25 @@
+#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <TlHelp32.h>
#include <filesystem>
#include <sstream>
-#include <iostream>
#include <fstream>
+#include <Shlwapi.h>
namespace fs = std::filesystem;
+extern "C" {
+ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
+ __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
+}
+
+HMODULE hLauncherModule;
+HMODULE hHookModule;
+HMODULE hTier0Module;
+
+wchar_t exePath[4096];
+wchar_t buffer[8196];
+
DWORD GetProcessByName(std::wstring processName)
{
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
@@ -33,132 +46,194 @@ DWORD GetProcessByName(std::wstring processName)
return 0;
}
-#define PROCESS_NAME L"Titanfall2-unpacked.exe"
-#define DLL_NAME L"Northstar.dll"
+bool GetExePathWide(wchar_t* dest, DWORD destSize)
+{
+ if (!dest) return NULL;
+ if (destSize < MAX_PATH) return NULL;
-int main(int argc, char* argv[]) {
- if (!fs::exists(PROCESS_NAME))
- {
- MessageBoxA(0, "Titanfall2-unpacked.exe not found! Please launch from your titanfall 2 directory and ensure you have Northstar installed correctly!", "", MB_OK);
- return 1;
- }
+ DWORD length = GetModuleFileNameW(NULL, dest, destSize);
+ return length && PathRemoveFileSpecW(dest);
+}
- if (!fs::exists(DLL_NAME))
+FARPROC GetLauncherMain()
+{
+ 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[2048];
+ std::string message = std::system_category().message(dwMessageId);
+ sprintf_s(text, "Failed to load the %ls at \"%ls\" (%lu):\n\n%hs\n\nMake sure you followed the Northstar installation instructions carefully.", libName, location, dwMessageId, message.c_str());
+ MessageBoxA(GetForegroundWindow(), text, "Northstar Launcher Error", 0);
+}
+
+void EnsureOriginStarted()
+{
+ if (GetProcessByName(L"Origin.exe") || GetProcessByName(L"EADesktop.exe"))
+ return; // already started
+
+ // unpacked exe will crash if origin isn't open on launch, so launch it
+ // get origin path from registry, code here is reversed from OriginSDK.dll
+ HKEY key;
+ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Origin", 0, KEY_READ, &key) != ERROR_SUCCESS)
{
- MessageBoxA(0, "Northstar.dll not found! Please launch from your titanfall 2 directory and ensure you have Northstar installed correctly!", "", MB_OK);
- return 1;
+ MessageBoxA(0, "Error: failed reading origin path!", "", MB_OK);
+ return;
}
- bool isdedi = false;
- for (int i = 0; i < argc; i++)
- if (!strcmp(argv[i], "-dedicated"))
- isdedi = true;
-
- if (!isdedi && !GetProcessByName(L"Origin.exe") && !GetProcessByName(L"EADesktop.exe"))
+ char originPath[520];
+ DWORD originPathLength = 520;
+ if (RegQueryValueExA(key, "ClientPath", 0, 0, (LPBYTE)&originPath, &originPathLength) != ERROR_SUCCESS)
{
- // unpacked exe will crash if origin isn't open on launch, so launch it
- // get origin path from registry, code here is reversed from OriginSDK.dll
- HKEY key;
- if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Origin", 0, KEY_READ, &key) != ERROR_SUCCESS)
- {
- MessageBoxA(0, "Error: failed reading origin path!", "", MB_OK);
- return 1;
- }
+ MessageBoxA(0, "Error: failed reading origin path!", "", MB_OK);
+ return;
+ }
- char originPath[520];
- DWORD originPathLength = 520;
- if (RegQueryValueExA(key, "ClientPath", 0, 0, (LPBYTE)&originPath, &originPathLength) != ERROR_SUCCESS)
- {
- MessageBoxA(0, "Error: failed reading origin path!", "", MB_OK);
- return 1;
- }
+ PROCESS_INFORMATION pi;
+ memset(&pi, 0, sizeof(pi));
+ STARTUPINFO si;
+ memset(&si, 0, sizeof(si));
+ CreateProcessA(originPath, (char*)"", NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP, NULL, NULL, (LPSTARTUPINFOA)&si, &pi);
- PROCESS_INFORMATION pi;
- memset(&pi, 0, sizeof(pi));
- STARTUPINFO si;
- memset(&si, 0, sizeof(si));
- CreateProcessA(originPath, (LPSTR)"", NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP, NULL, NULL, (LPSTARTUPINFOA)&si, &pi);
+ printf("[*] Waiting for Origin...\n");
- // wait for origin to be ready, this process is created when origin is ready enough to launch game without any errors
- while (!GetProcessByName(L"OriginClientService.exe") && !GetProcessByName(L"EADesktop.exe"))
- Sleep(200);
- }
+ // wait for origin to be ready, this process is created when origin is ready enough to launch game without any errors
+ while (!GetProcessByName(L"OriginClientService.exe") && !GetProcessByName(L"EADesktop.exe"))
+ Sleep(200);
- // get cmdline args from file
- std::wstring args;
- std::ifstream cmdlineArgFile;
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+}
- args.append(L" ");
- for (int i = 0; i < argc; i++)
+void PrependPath()
+{
+ wchar_t* pPath;
+ size_t len;
+ errno_t err = _wdupenv_s(&pPath, &len, L"PATH");
+ if (!err)
{
- std::string str = argv[i];
-
- args.append(std::wstring(str.begin(), str.end()));
- args.append(L" ");
+ swprintf_s(buffer, L"PATH=%s\\bin\\x64_retail\\;%s", exePath, pPath);
+ auto result = _wputenv(buffer);
+ if (result == -1)
+ {
+ MessageBoxW(GetForegroundWindow(), L"Warning: could not prepend the current directory to app's PATH environment variable. Something may break because of that.", L"Northstar Launcher Warning", 0);
+ }
+ //free(pPath);
}
-
- if (!isdedi)
- cmdlineArgFile = std::ifstream("ns_startup_args.txt");
else
- cmdlineArgFile = std::ifstream("ns_startup_args_dedi.txt");
-
- if (cmdlineArgFile)
{
- std::stringstream argBuffer;
- argBuffer << cmdlineArgFile.rdbuf();
- cmdlineArgFile.close();
-
- std::string str = argBuffer.str();
- args.append(std::wstring(str.begin(), str.end()));
+ MessageBoxW(GetForegroundWindow(), L"Warning: could not get current PATH environment variable in order to prepend the current directory to it. Something may break because of that.", L"Northstar Launcher Warning", 0);
}
+}
- //if (isdedi)
- // // copy -dedicated into args if we have it in commandline args
- // args.append(L" -dedicated");
+bool ShouldLoadNorthstar(int argc, char* argv[])
+{
+ bool loadNorthstar = true;
+ for (int i = 0; i < argc; i++)
+ if (!strcmp(argv[i], "-vanilla"))
+ loadNorthstar = false;
- STARTUPINFO startupInfo;
- PROCESS_INFORMATION processInfo;
+ if (!loadNorthstar)
+ return loadNorthstar;
- memset(&startupInfo, 0, sizeof(startupInfo));
- memset(&processInfo, 0, sizeof(processInfo));
+ 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;
+}
- CreateProcessW(PROCESS_NAME, (LPWSTR)args.c_str(), NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &processInfo);
+bool LoadNorthstar()
+{
+ FARPROC Hook_Init = nullptr;
+ {
+ swprintf_s(buffer, L"%s\\Northstar.dll", exePath);
+ hHookModule = LoadLibraryExW(buffer, 0i64, 8u);
+ if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar");
+ if (!hHookModule || Hook_Init == nullptr)
+ {
+ LibraryLoadError(GetLastError(), L"Northstar.dll", buffer);
+ return false;
+ }
+ }
- HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
- LPTHREAD_START_ROUTINE pLoadLibraryW = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32, "LoadLibraryW");
+ ((bool (*)()) Hook_Init)();
+ return true;
+}
- SIZE_T dwLength = (wcslen(DLL_NAME) + 1) * 2;
- LPVOID lpLibName = VirtualAllocEx(processInfo.hProcess, NULL, dwLength, MEM_COMMIT, PAGE_READWRITE);
+int main(int argc, char* argv[]) {
- SIZE_T written = 0;
- WriteProcessMemory(processInfo.hProcess, lpLibName, DLL_NAME, dwLength, &written);
+ // checked to avoid starting origin, Northstar.dll will check for -dedicated as well on its own
+ bool isDedicated = false;
+ for (int i = 0; i < argc; i++)
+ if (!strcmp(argv[i], "-dedicated"))
+ isDedicated = true;
- HANDLE hThread = CreateRemoteThread(processInfo.hProcess, NULL, NULL, pLoadLibraryW, lpLibName, NULL, NULL);
+ bool noOriginStartup = false;
+ for (int i = 0; i < argc; i++)
+ if (!strcmp(argv[i], "-noOriginStartup"))
+ noOriginStartup = true;
- if (hThread == NULL)
+ if (!isDedicated && !noOriginStartup)
{
- // injection failed
-
- std::string errorMessage = "Injection failed! CreateRemoteThread returned ";
- errorMessage += std::to_string(GetLastError()).c_str();
- errorMessage += ", make sure bob hasn't accidentally shipped a debug build";
-
- MessageBoxA(0, errorMessage.c_str(), "", MB_OK);
- return 0;
+ EnsureOriginStarted();
}
- WaitForSingleObject(hThread, INFINITE);
+ {
- //MessageBoxA(0, std::to_string(GetLastError()).c_str(), "", MB_OK);
+ if (!GetExePathWide(exePath, 4096))
+ {
+ MessageBoxA(GetForegroundWindow(), "Failed getting game directory.\nThe game cannot continue and has to exit.", "Northstar Launcher Error", 0);
+ return 1;
+ }
- CloseHandle(hThread);
+ PrependPath();
- ResumeThread(processInfo.hThread);
+ bool loadNorthstar = ShouldLoadNorthstar(argc, argv);
+ if (loadNorthstar)
+ {
+ printf("[*] Loading Northstar\n");
+ if (!LoadNorthstar())
+ return 1;
+ }
+ else
+ printf("[*] Going to load the vanilla game\n");
- VirtualFreeEx(processInfo.hProcess, lpLibName, dwLength, MEM_RELEASE);
+ printf("[*] Loading launcher.dll\n");
+ swprintf_s(buffer, L"%s\\bin\\x64_retail\\launcher.dll", exePath);
+ hLauncherModule = LoadLibraryExW(buffer, 0i64, 8u);
+ if (!hLauncherModule)
+ {
+ LibraryLoadError(GetLastError(), L"launcher.dll", buffer);
+ return 1;
+ }
- CloseHandle(processInfo.hProcess);
- CloseHandle(processInfo.hThread);
+ printf("[*] Loading tier0.dll\n");
+ // this makes zero sense given tier0.dll is already loaded via imports on launcher.dll, but we do it for full consistency with original launcher exe
+ // and to also let load callbacks in Northstar work for tier0.dll
+ swprintf_s(buffer, L"%s\\bin\\x64_retail\\tier0.dll", exePath);
+ hTier0Module = LoadLibraryW(buffer);
+ if (!hTier0Module)
+ {
+ LibraryLoadError(GetLastError(), L"tier0.dll", buffer);
+ return 1;
+ }
+ }
- return 0;
+ printf("[*] Launching the game...\n");
+ auto LauncherMain = GetLauncherMain();
+ if (!LauncherMain)
+ MessageBoxA(GetForegroundWindow(), "Failed loading launcher.dll.\nThe game cannot continue and has to exit.", "Northstar Launcher Error", 0);
+ //auto result = ((__int64(__fastcall*)())LauncherMain)();
+ //auto result = ((signed __int64(__fastcall*)(__int64))LauncherMain)(0i64);
+ return ((int(/*__fastcall*/*)(HINSTANCE, HINSTANCE, LPSTR, int))LauncherMain)(NULL, NULL, NULL, 0); // the parameters aren't really used anyways
} \ No newline at end of file
diff --git a/LauncherInjector/memalloc.cpp b/LauncherInjector/memalloc.cpp
new file mode 100644
index 00000000..1d0f13e6
--- /dev/null
+++ b/LauncherInjector/memalloc.cpp
@@ -0,0 +1,64 @@
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h>
+#include "memalloc.h"
+#include <stdio.h>
+
+extern HMODULE hTier0Module;
+IMemAlloc** g_ppMemAllocSingleton;
+
+void LoadTier0Handle()
+{
+ if (!hTier0Module) hTier0Module = GetModuleHandleA("tier0.dll");
+ if (!hTier0Module) return;
+
+ g_ppMemAllocSingleton = (IMemAlloc**)GetProcAddress(hTier0Module, "g_pMemAllocSingleton");
+}
+
+const int STATIC_ALLOC_SIZE = 16384;
+
+size_t g_iStaticAllocated = 0;
+char pStaticAllocBuf[STATIC_ALLOC_SIZE];
+
+// they should never be used here, except in LibraryLoadError // haha not true
+
+void* malloc(size_t n)
+{
+ //printf("NorthstarLauncher malloc: %llu\n", n);
+ // allocate into static buffer
+ if (g_iStaticAllocated + n <= STATIC_ALLOC_SIZE)
+ {
+ void* ret = pStaticAllocBuf + g_iStaticAllocated;
+ g_iStaticAllocated += n;
+ return ret;
+ }
+ else
+ {
+ // try to fallback to g_pMemAllocSingleton
+ if (!hTier0Module || !g_ppMemAllocSingleton) LoadTier0Handle();
+ if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton)
+ return (*g_ppMemAllocSingleton)->m_vtable->Alloc(*g_ppMemAllocSingleton, n);
+ else
+ throw "Cannot allocate";
+ }
+}
+
+void free(void* p)
+{
+ //printf("NorthstarLauncher free: %p\n", p);
+ // if it was allocated into the static buffer, just do nothing, safest way to deal with it
+ if (p >= pStaticAllocBuf && p <= pStaticAllocBuf + STATIC_ALLOC_SIZE)
+ return;
+
+ if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton)
+ (*g_ppMemAllocSingleton)->m_vtable->Free(*g_ppMemAllocSingleton, p);
+}
+
+void* operator new(size_t n)
+{
+ return malloc(n);
+}
+
+void operator delete(void* p)
+{
+ free(p);
+}
diff --git a/LauncherInjector/memalloc.h b/LauncherInjector/memalloc.h
new file mode 100644
index 00000000..928e403c
--- /dev/null
+++ b/LauncherInjector/memalloc.h
@@ -0,0 +1,15 @@
+#pragma once
+
+class IMemAlloc
+{
+public:
+ struct VTable
+ {
+ void* unknown[1];
+ void* (*Alloc) (IMemAlloc* memAlloc, size_t nSize);
+ void* unknown2[3];
+ void(*Free) (IMemAlloc* memAlloc, void* pMem);
+ };
+
+ VTable* m_vtable;
+};
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index 03481a2c..137a5639 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
@@ -27,19 +19,6 @@
<ProjectName>Northstar</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
@@ -58,12 +37,6 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
@@ -71,56 +44,12 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;_DEBUG;NORTHSTARDEDICATEDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableUAC>false</EnableUAC>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;NDEBUG;NORTHSTARDEDICATEDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableUAC>false</EnableUAC>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -633,9 +562,7 @@
<ClCompile Include="masterserver.cpp" />
<ClCompile Include="modmanager.cpp" />
<ClCompile Include="pch.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="pdef.cpp" />
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp
index 83a9950a..e628a011 100644
--- a/NorthstarDedicatedTest/dedicated.cpp
+++ b/NorthstarDedicatedTest/dedicated.cpp
@@ -6,7 +6,8 @@
bool IsDedicated()
{
- return CommandLine()->CheckParm("-dedicated");
+ //return CommandLine()->CheckParm("-dedicated");
+ return strstr(GetCommandLineA(), "-dedicated");
}
// CDedidcatedExports defs
@@ -209,7 +210,7 @@ void InitialiseDedicated(HMODULE engineAddress)
TempReadWrite rw(ptr);
// remove call to Shader_Connect
- *ptr = 0x90;
+ *ptr = (char)0x90;
*(ptr + 1) = (char)0x90;
*(ptr + 2) = (char)0x90;
*(ptr + 3) = (char)0x90;
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index 78edb297..dfc3afe1 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -43,9 +43,10 @@ BOOL APIENTRY DllMain( HMODULE hModule,
break;
}
- if (!initialised)
- InitialiseNorthstar();
- initialised = true;
+ // pls no xD
+ //if (!initialised)
+ // InitialiseNorthstar();
+ //initialised = true;
return TRUE;
}
@@ -53,7 +54,8 @@ BOOL APIENTRY DllMain( HMODULE hModule,
void WaitForDebugger(HMODULE baseAddress)
{
// earlier waitfordebugger call than is in vanilla, just so we can debug stuff a little easier
- if (CommandLine()->CheckParm("-waitfordebugger"))
+ //if (CommandLine()->CheckParm("-waitfordebugger"))
+ if (strstr(GetCommandLineA(), "-waitfordebugger"))
{
spdlog::info("waiting for debugger...");
spdlog::info("{} bytes have been statically allocated", g_iStaticAllocated);
@@ -64,16 +66,22 @@ void WaitForDebugger(HMODULE baseAddress)
}
// in the future this will be called from launcher instead of dllmain
-void InitialiseNorthstar()
+bool InitialiseNorthstar()
{
+ if (initialised)
+ {
+ fprintf(stderr, "[info] Called InitialiseNorthstar more than once!\n");
+ return false;
+ }
+ initialised = true;
+
InitialiseLogging();
// apply initial hooks
InstallInitialHooks();
InitialiseInterfaceCreationHooks();
- // adding a callback to tier0 won't work for some reason
- AddDllLoadCallback("launcher.dll", InitialiseTier0GameUtilFunctions);
+ AddDllLoadCallback("tier0.dll", InitialiseTier0GameUtilFunctions);
AddDllLoadCallback("engine.dll", WaitForDebugger);
AddDllLoadCallback("engine.dll", InitialiseEngineGameUtilFunctions);
AddDllLoadCallback("server.dll", InitialiseServerGameUtilFunctions);
@@ -82,7 +90,7 @@ void InitialiseNorthstar()
// dedi patches
{
AddDllLoadCallback("engine.dll", InitialiseDedicated);
- AddDllLoadCallback("launcher.dll", InitialiseDedicatedOrigin);
+ AddDllLoadCallback("tier0.dll", InitialiseDedicatedOrigin);
AddDllLoadCallback("server.dll", InitialiseDedicatedServerGameDLL);
AddDllLoadCallback("materialsystem_dx11.dll", InitialiseDedicatedMaterialSystem);
// this fucking sucks, but seemingly we somehow load after rtech_game???? unsure how, but because of this we have to apply patches here, not on rtech_game load
@@ -120,4 +128,6 @@ void InitialiseNorthstar()
// mod manager after everything else
AddDllLoadCallback("engine.dll", InitialiseModManager);
+
+ return true;
} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/gameutils.cpp b/NorthstarDedicatedTest/gameutils.cpp
index 642c44e6..3e62037c 100644
--- a/NorthstarDedicatedTest/gameutils.cpp
+++ b/NorthstarDedicatedTest/gameutils.cpp
@@ -78,12 +78,27 @@ void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
void InitialiseTier0GameUtilFunctions(HMODULE baseAddress)
{
- baseAddress = GetModuleHandleA("tier0.dll");
-
- CreateGlobalMemAlloc = (CreateGlobalMemAllocType)GetProcAddress(baseAddress, "CreateGlobalMemAlloc");
- g_pMemAllocSingleton = CreateGlobalMemAlloc();
-
- Error = (ErrorType)GetProcAddress(baseAddress, "Error");
- CommandLine = (CommandLineType)GetProcAddress(baseAddress, "CommandLine");
- Plat_FloatTime = (Plat_FloatTimeType)GetProcAddress(baseAddress, "Plat_FloatTime");
+ CreateGlobalMemAlloc = reinterpret_cast<CreateGlobalMemAllocType>(GetProcAddress(baseAddress, "CreateGlobalMemAlloc"));
+ IMemAlloc** ppMemAllocSingleton = reinterpret_cast<IMemAlloc**>(GetProcAddress(baseAddress, "g_pMemAllocSingleton"));
+ if (!ppMemAllocSingleton)
+ {
+ spdlog::critical("Address of g_pMemAllocSingleton is a null pointer, this should never happen");
+ throw "Address of g_pMemAllocSingleton is a null pointer, this should never happen";
+ }
+ if (!*ppMemAllocSingleton)
+ {
+ g_pMemAllocSingleton = CreateGlobalMemAlloc();
+ *ppMemAllocSingleton = g_pMemAllocSingleton;
+ spdlog::warn("Created new g_pMemAllocSingleton");
+ }
+ else
+ {
+ g_pMemAllocSingleton = *ppMemAllocSingleton;
+ extern size_t g_iStaticAllocated;
+ spdlog::info("Using existing g_pMemAllocSingleton for memory allocations, preallocated {} bytes beforehand", g_iStaticAllocated);
+ }
+
+ Error = reinterpret_cast<ErrorType>(GetProcAddress(baseAddress, "Error"));
+ CommandLine = reinterpret_cast<CommandLineType>(GetProcAddress(baseAddress, "CommandLine"));
+ Plat_FloatTime = reinterpret_cast<Plat_FloatTimeType>(GetProcAddress(baseAddress, "Plat_FloatTime"));
} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp
index 3de8d483..e58b7afc 100644
--- a/NorthstarDedicatedTest/hooks.cpp
+++ b/NorthstarDedicatedTest/hooks.cpp
@@ -5,15 +5,32 @@
#include <wchar.h>
#include <iostream>
#include <vector>
+#include <fstream>
+#include <sstream>
+#include <filesystem>
+
+typedef LPSTR(*GetCommandLineAType)();
+LPSTR GetCommandLineAHook();
+
+// note that these load library callbacks only support explicitly loaded dynamic libraries
typedef HMODULE(*LoadLibraryExAType)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
+typedef HMODULE(*LoadLibraryAType)(LPCSTR lpLibFileName);
+HMODULE LoadLibraryAHook(LPCSTR lpLibFileName);
+
typedef HMODULE(*LoadLibraryExWType)(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
HMODULE LoadLibraryExWHook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
+typedef HMODULE(*LoadLibraryWType)(LPCWSTR lpLibFileName);
+HMODULE LoadLibraryWHook(LPCWSTR lpLibFileName);
+
+GetCommandLineAType GetCommandLineAOriginal;
LoadLibraryExAType LoadLibraryExAOriginal;
+LoadLibraryAType LoadLibraryAOriginal;
LoadLibraryExWType LoadLibraryExWOriginal;
+LoadLibraryWType LoadLibraryWOriginal;
void InstallInitialHooks()
{
@@ -21,8 +38,57 @@ void InstallInitialHooks()
spdlog::error("MH_Initialize failed");
HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, &GetCommandLineA, &GetCommandLineAHook, reinterpret_cast<LPVOID*>(&GetCommandLineAOriginal));
ENABLER_CREATEHOOK(hook, &LoadLibraryExA, &LoadLibraryExAHook, reinterpret_cast<LPVOID*>(&LoadLibraryExAOriginal));
+ ENABLER_CREATEHOOK(hook, &LoadLibraryA, &LoadLibraryAHook, reinterpret_cast<LPVOID*>(&LoadLibraryAOriginal));
ENABLER_CREATEHOOK(hook, &LoadLibraryExW, &LoadLibraryExWHook, reinterpret_cast<LPVOID*>(&LoadLibraryExWOriginal));
+ ENABLER_CREATEHOOK(hook, &LoadLibraryW, &LoadLibraryWHook, reinterpret_cast<LPVOID*>(&LoadLibraryWOriginal));
+}
+
+char* cmdlineResult;
+LPSTR GetCommandLineAHook()
+{
+ static char* cmdlineOrg;
+
+ if (cmdlineOrg == nullptr || cmdlineResult == nullptr)
+ {
+ cmdlineOrg = GetCommandLineAOriginal();
+ bool isDedi = strstr(cmdlineOrg, "-dedicated"); // well, this one has to be a real argument
+
+ std::string args;
+ std::ifstream cmdlineArgFile;
+
+ // it looks like CommandLine() prioritizes parameters apprearing first, so we want the real commandline to take priority
+ // not to mention that cmdlineOrg starts with the EXE path
+ args.append(cmdlineOrg);
+ args.append(" ");
+
+ // append those from the file
+
+ cmdlineArgFile = std::ifstream(!isDedi ? "ns_startup_args.txt" : "ns_startup_args_dedi.txt");
+
+ if (cmdlineArgFile)
+ {
+ std::stringstream argBuffer;
+ argBuffer << cmdlineArgFile.rdbuf();
+ cmdlineArgFile.close();
+
+ args.append(argBuffer.str());
+ }
+
+ auto len = args.length();
+ cmdlineResult = reinterpret_cast<char*>(malloc(len + 1));
+ if (!cmdlineResult)
+ {
+ spdlog::error("malloc failed for command line");
+ return cmdlineOrg;
+ }
+ memcpy(cmdlineResult, args.c_str(), len + 1);
+
+ spdlog::info("Command line: {}", cmdlineResult);
+ }
+
+ return cmdlineResult;
}
// dll load callback stuff
@@ -46,20 +112,51 @@ void AddDllLoadCallback(std::string dll, DllLoadCallbackFuncType callback)
dllLoadCallbacks.push_back(callbackStruct);
}
+void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
+{
+ for (auto& callbackStruct : dllLoadCallbacks)
+ {
+ if (!callbackStruct->called && strstr(lpLibFileName + (strlen(lpLibFileName) - strlen(callbackStruct->dll.c_str())), callbackStruct->dll.c_str()) != nullptr)
+ {
+ callbackStruct->callback(moduleAddress);
+ callbackStruct->called = true;
+ }
+ }
+}
+
+void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
+{
+ for (auto& callbackStruct : dllLoadCallbacks)
+ {
+ std::wstring wcharStrDll = std::wstring(callbackStruct->dll.begin(), callbackStruct->dll.end());
+ const wchar_t* callbackDll = wcharStrDll.c_str();
+ if (!callbackStruct->called && wcsstr(lpLibFileName + (wcslen(lpLibFileName) - wcslen(callbackDll)), callbackDll) != nullptr)
+ {
+ callbackStruct->callback(moduleAddress);
+ callbackStruct->called = true;
+ }
+ }
+}
+
HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
HMODULE moduleAddress = LoadLibraryExAOriginal(lpLibFileName, hFile, dwFlags);
if (moduleAddress)
{
- for (auto& callbackStruct : dllLoadCallbacks)
- {
- if (!callbackStruct->called && strstr(lpLibFileName + (strlen(lpLibFileName) - strlen(callbackStruct->dll.c_str())), callbackStruct->dll.c_str()) != nullptr)
- {
- callbackStruct->callback(moduleAddress);
- callbackStruct->called = true;
- }
- }
+ CallLoadLibraryACallbacks(lpLibFileName, moduleAddress);
+ }
+
+ return moduleAddress;
+}
+
+HMODULE LoadLibraryAHook(LPCSTR lpLibFileName)
+{
+ HMODULE moduleAddress = LoadLibraryAOriginal(lpLibFileName);
+
+ if (moduleAddress)
+ {
+ CallLoadLibraryACallbacks(lpLibFileName, moduleAddress);
}
return moduleAddress;
@@ -71,16 +168,19 @@ HMODULE LoadLibraryExWHook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
if (moduleAddress)
{
- for (auto& callbackStruct : dllLoadCallbacks)
- {
- std::wstring wcharStrDll = std::wstring(callbackStruct->dll.begin(), callbackStruct->dll.end());
- const wchar_t* callbackDll = wcharStrDll.c_str();
- if (!callbackStruct->called && wcsstr(lpLibFileName + (wcslen(lpLibFileName) - wcslen(callbackDll)), callbackDll) != nullptr)
- {
- callbackStruct->callback(moduleAddress);
- callbackStruct->called = true;
- }
- }
+ CallLoadLibraryWCallbacks(lpLibFileName, moduleAddress);
+ }
+
+ return moduleAddress;
+}
+
+HMODULE LoadLibraryWHook(LPCWSTR lpLibFileName)
+{
+ HMODULE moduleAddress = LoadLibraryWOriginal(lpLibFileName);
+
+ if (moduleAddress)
+ {
+ CallLoadLibraryWCallbacks(lpLibFileName, moduleAddress);
}
return moduleAddress;
diff --git a/NorthstarDedicatedTest/main.h b/NorthstarDedicatedTest/main.h
index ef5d86dc..90e88912 100644
--- a/NorthstarDedicatedTest/main.h
+++ b/NorthstarDedicatedTest/main.h
@@ -1,3 +1,3 @@
#pragma once
-extern "C" __declspec(dllexport) void InitialiseNorthstar(); \ No newline at end of file
+extern "C" __declspec(dllexport) bool InitialiseNorthstar(); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index c4f576e3..615197b7 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -38,6 +38,39 @@ CHostState__State_ChangeLevelSPType CHostState__State_ChangeLevelSP;
typedef void(*CHostState__State_GameShutdownType)(CHostState* hostState);
CHostState__State_GameShutdownType CHostState__State_GameShutdown;
+const char* HttplibErrorToString(httplib::Error error)
+{
+ switch (error)
+ {
+ case httplib::Error::Success:
+ return "httplib::Error::Success";
+ case httplib::Error::Unknown:
+ return "httplib::Error::Unknown";
+ case httplib::Error::Connection:
+ return "httplib::Error::Connection";
+ case httplib::Error::BindIPAddress:
+ return "httplib::Error::BindIPAddress";
+ case httplib::Error::Read:
+ return "httplib::Error::Read";
+ case httplib::Error::Write:
+ return "httplib::Error::Write";
+ case httplib::Error::ExceedRedirectCount:
+ return "httplib::Error::ExceedRedirectCount";
+ case httplib::Error::Canceled:
+ return "httplib::Error::Canceled";
+ case httplib::Error::SSLConnection:
+ return "httplib::Error::SSLConnection";
+ case httplib::Error::SSLLoadingCerts:
+ return "httplib::Error::SSLLoadingCerts";
+ case httplib::Error::SSLServerVerification:
+ return "httplib::Error::SSLServerVerification";
+ case httplib::Error::UnsupportedMultipartBoundaryChars:
+ return "httplib::Error::UnsupportedMultipartBoundaryChars";
+ }
+
+ return "";
+}
+
RemoteServerInfo::RemoteServerInfo(const char* newId, const char* newName, const char* newDescription, const char* newMap, const char* newPlaylist, int newPlayerCount, int newMaxPlayers, bool newRequiresPassword)
{
// passworded servers don't have public ips
@@ -271,7 +304,7 @@ void MasterServerManager::RequestServerList()
std::sort(m_remoteServers.begin(), m_remoteServers.end(), [](RemoteServerInfo& a, RemoteServerInfo& b)
{
return a.playerCount > b.playerCount;
- });
+ });
}
else
{
@@ -643,26 +676,26 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name
modinfoDoc.SetObject();
modinfoDoc.AddMember("Mods", rapidjson::Value(rapidjson::kArrayType), modinfoDoc.GetAllocator());
- int currentModIndex = 0;
- for (Mod& mod : g_ModManager->m_loadedMods)
- {
- if (!mod.Enabled || (!mod.RequiredOnClient && !mod.Pdiff.size()))
- continue;
+ int currentModIndex = 0;
+ for (Mod& mod : g_ModManager->m_loadedMods)
+ {
+ if (!mod.Enabled || (!mod.RequiredOnClient && !mod.Pdiff.size()))
+ continue;
- modinfoDoc["Mods"].PushBack(rapidjson::Value(rapidjson::kObjectType), modinfoDoc.GetAllocator());
- modinfoDoc["Mods"][currentModIndex].AddMember("Name", rapidjson::StringRef(&mod.Name[0]), modinfoDoc.GetAllocator());
- modinfoDoc["Mods"][currentModIndex].AddMember("Version", rapidjson::StringRef(&mod.Version[0]), modinfoDoc.GetAllocator());
- modinfoDoc["Mods"][currentModIndex].AddMember("RequiredOnClient", mod.RequiredOnClient, modinfoDoc.GetAllocator());
- modinfoDoc["Mods"][currentModIndex].AddMember("Pdiff", rapidjson::StringRef(&mod.Pdiff[0]), modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"].PushBack(rapidjson::Value(rapidjson::kObjectType), modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"][currentModIndex].AddMember("Name", rapidjson::StringRef(&mod.Name[0]), modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"][currentModIndex].AddMember("Version", rapidjson::StringRef(&mod.Version[0]), modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"][currentModIndex].AddMember("RequiredOnClient", mod.RequiredOnClient, modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"][currentModIndex].AddMember("Pdiff", rapidjson::StringRef(&mod.Pdiff[0]), modinfoDoc.GetAllocator());
- currentModIndex++;
- }
+ currentModIndex++;
+ }
- rapidjson::StringBuffer buffer;
- buffer.Clear();
- rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
- modinfoDoc.Accept(writer);
- const char* modInfoString = buffer.GetString();
+ rapidjson::StringBuffer buffer;
+ buffer.Clear();
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
+ modinfoDoc.Accept(writer);
+ const char* modInfoString = buffer.GetString();
CURL* curl = curl_easy_init();
@@ -739,8 +772,8 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name
goto REQUEST_END_CLEANUP;
}
- strncpy(m_ownServerId, serverAddedJson["id"].GetString(), sizeof(m_ownServerId));
- m_ownServerId[sizeof(m_ownServerId) - 1] = 0;
+ strncpy(m_ownServerId, serverAddedJson["id"].GetString(), sizeof(m_ownServerId));
+ m_ownServerId[sizeof(m_ownServerId) - 1] = 0;
// heartbeat thread
@@ -899,7 +932,7 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata,
curl_easy_cleanup(curl);
- m_savingPersistentData = false;
+ m_savingPersistentData = false;
});
requestThread.detach();
diff --git a/NorthstarDedicatedTest/masterserver.h b/NorthstarDedicatedTest/masterserver.h
index 9b55adda..dc06c933 100644
--- a/NorthstarDedicatedTest/masterserver.h
+++ b/NorthstarDedicatedTest/masterserver.h
@@ -94,6 +94,9 @@ public:
bool m_bHasMainMenuPromoData = false;
MainMenuPromoData m_MainMenuPromoData;
+private:
+ void SetHttpClientOptions(httplib::Client& http);
+
public:
MasterServerManager();
void ClearServerList();
diff --git a/NorthstarDedicatedTest/memalloc.cpp b/NorthstarDedicatedTest/memalloc.cpp
index 113f56b9..cff0ecac 100644
--- a/NorthstarDedicatedTest/memalloc.cpp
+++ b/NorthstarDedicatedTest/memalloc.cpp
@@ -17,24 +17,48 @@ const int STATIC_ALLOC_SIZE = 100000; // alot more than we need, could reduce to
size_t g_iStaticAllocated = 0;
char pStaticAllocBuf[STATIC_ALLOC_SIZE];
-void* operator new(size_t n)
+// TODO: rename to malloc and free after removing statically compiled .libs
+
+void* malloc_(size_t n)
{
// allocate into static buffer if g_pMemAllocSingleton isn't initialised
if (g_pMemAllocSingleton)
+ {
+ //printf("Northstar malloc (g_pMemAllocSingleton): %llu\n", n);
return g_pMemAllocSingleton->m_vtable->Alloc(g_pMemAllocSingleton, n);
+ }
else
{
+ if (g_iStaticAllocated + n > STATIC_ALLOC_SIZE)
+ {
+ throw "Ran out of prealloc space"; // we could log, but spdlog probably does use allocations as well...
+ }
+ //printf("Northstar malloc (prealloc): %llu\n", n);
void* ret = pStaticAllocBuf + g_iStaticAllocated;
g_iStaticAllocated += n;
return ret;
- }
+ }
}
-void operator delete(void* p)
+void free_(void* p)
{
// if it was allocated into the static buffer, just do nothing, safest way to deal with it
if (p >= pStaticAllocBuf && p <= pStaticAllocBuf + STATIC_ALLOC_SIZE)
+ {
+ //printf("Northstar free (prealloc): %p\n", p);
return;
+ }
+ //printf("Northstar free (g_pMemAllocSingleton): %p\n", p);
g_pMemAllocSingleton->m_vtable->Free(g_pMemAllocSingleton, p);
+}
+
+void* operator new(size_t n)
+{
+ return malloc_(n);
+}
+
+void operator delete(void* p)
+{
+ free_(p);
} \ No newline at end of file
diff --git a/R2Northstar.sln b/R2Northstar.sln
index 1b664dd9..c113a437 100644
--- a/R2Northstar.sln
+++ b/R2Northstar.sln
@@ -1,35 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30621.155
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Northstar", "NorthstarDedicatedTest\NorthstarDedicatedTest.vcxproj", "{CFAD2623-064F-453C-8196-79EE10292E32}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NorthstarLauncher", "LauncherInjector\LauncherInjector.vcxproj", "{0EA82CB0-53FE-4D4C-96DF-47FA970513D0}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader_launcher_proxy", "loader_launcher_proxy\loader_launcher_proxy.vcxproj", "{F65C322D-66DF-4AF1-B650-70221DE334C0}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
Release|x64 = Release|x64
- Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CFAD2623-064F-453C-8196-79EE10292E32}.Debug|x64.ActiveCfg = Debug|x64
{CFAD2623-064F-453C-8196-79EE10292E32}.Debug|x64.Build.0 = Debug|x64
- {CFAD2623-064F-453C-8196-79EE10292E32}.Debug|x86.ActiveCfg = Debug|Win32
{CFAD2623-064F-453C-8196-79EE10292E32}.Release|x64.ActiveCfg = Release|x64
{CFAD2623-064F-453C-8196-79EE10292E32}.Release|x64.Build.0 = Release|x64
- {CFAD2623-064F-453C-8196-79EE10292E32}.Release|x86.ActiveCfg = Release|Win32
- {CFAD2623-064F-453C-8196-79EE10292E32}.Release|x86.Build.0 = Release|Win32
{0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Debug|x64.ActiveCfg = Debug|x64
{0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Debug|x64.Build.0 = Debug|x64
- {0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Debug|x86.ActiveCfg = Debug|Win32
- {0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Debug|x86.Build.0 = Debug|Win32
{0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Release|x64.ActiveCfg = Release|x64
{0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Release|x64.Build.0 = Release|x64
- {0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Release|x86.ActiveCfg = Release|Win32
- {0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Release|x86.Build.0 = Release|Win32
+ {F65C322D-66DF-4AF1-B650-70221DE334C0}.Debug|x64.ActiveCfg = Debug|x64
+ {F65C322D-66DF-4AF1-B650-70221DE334C0}.Debug|x64.Build.0 = Debug|x64
+ {F65C322D-66DF-4AF1-B650-70221DE334C0}.Release|x64.ActiveCfg = Release|x64
+ {F65C322D-66DF-4AF1-B650-70221DE334C0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/loader_launcher_proxy/Memory.cpp b/loader_launcher_proxy/Memory.cpp
new file mode 100644
index 00000000..6c69d80f
--- /dev/null
+++ b/loader_launcher_proxy/Memory.cpp
@@ -0,0 +1,59 @@
+#include "pch.h"
+
+extern HMODULE hTier0Module;
+IMemAlloc** g_ppMemAllocSingleton;
+
+void LoadTier0Handle()
+{
+ if (!hTier0Module) hTier0Module = GetModuleHandleA("tier0.dll");
+ if (!hTier0Module) return;
+
+ g_ppMemAllocSingleton = (IMemAlloc**)GetProcAddress(hTier0Module, "g_pMemAllocSingleton");
+}
+
+const int STATIC_ALLOC_SIZE = 4096;
+
+size_t g_iStaticAllocated = 0;
+char pStaticAllocBuf[STATIC_ALLOC_SIZE];
+
+// they should never be used here, except in LibraryLoadError?
+
+void* malloc(size_t n)
+{
+ // allocate into static buffer
+ if (g_iStaticAllocated + n <= STATIC_ALLOC_SIZE)
+ {
+ void* ret = pStaticAllocBuf + g_iStaticAllocated;
+ g_iStaticAllocated += n;
+ return ret;
+ }
+ else
+ {
+ // try to fallback to g_pMemAllocSingleton
+ if (!hTier0Module || !g_ppMemAllocSingleton) LoadTier0Handle();
+ if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton)
+ return (*g_ppMemAllocSingleton)->m_vtable->Alloc(*g_ppMemAllocSingleton, n);
+ else
+ throw "Cannot allocate";
+ }
+}
+
+void free(void* p)
+{
+ // if it was allocated into the static buffer, just do nothing, safest way to deal with it
+ if (p >= pStaticAllocBuf && p <= pStaticAllocBuf + STATIC_ALLOC_SIZE)
+ return;
+
+ if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton)
+ (*g_ppMemAllocSingleton)->m_vtable->Free(*g_ppMemAllocSingleton, p);
+}
+
+void* operator new(size_t n)
+{
+ return malloc(n);
+}
+
+void operator delete(void* p)
+{
+ return free(p);
+}
diff --git a/loader_launcher_proxy/Memory.h b/loader_launcher_proxy/Memory.h
new file mode 100644
index 00000000..928e403c
--- /dev/null
+++ b/loader_launcher_proxy/Memory.h
@@ -0,0 +1,15 @@
+#pragma once
+
+class IMemAlloc
+{
+public:
+ struct VTable
+ {
+ void* unknown[1];
+ void* (*Alloc) (IMemAlloc* memAlloc, size_t nSize);
+ void* unknown2[3];
+ void(*Free) (IMemAlloc* memAlloc, void* pMem);
+ };
+
+ VTable* m_vtable;
+};
diff --git a/loader_launcher_proxy/dllmain.cpp b/loader_launcher_proxy/dllmain.cpp
new file mode 100644
index 00000000..7a778208
--- /dev/null
+++ b/loader_launcher_proxy/dllmain.cpp
@@ -0,0 +1,158 @@
+#include "pch.h"
+#include <stdio.h>
+#include <string>
+#include <system_error>
+#include <Shlwapi.h>
+#include <sstream>
+#include <fstream>
+
+HMODULE hLauncherModule;
+HMODULE hHookModule;
+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)
+{
+ //AppSystemCreateInterfaceFn(pName, pReturnCode);
+ printf("external CreateInterface: name: %s\n", pName);
+
+ static CreateInterfaceFn launcher_CreateInterface = (CreateInterfaceFn)GetProcAddress(hLauncherModule, "CreateInterface");
+ auto res = launcher_CreateInterface(pName, pReturnCode);
+
+ 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;
+
+ 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;
+}
+
+void LibraryLoadError(DWORD dwMessageId, const wchar_t* libName, const wchar_t* location)
+{
+ char text[2048];
+ 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());
+ MessageBoxA(GetForegroundWindow(), text, "Northstar Launcher Proxy Error", 0);
+}
+
+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;
+}
+
+wchar_t exePath[4096];
+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()
+{
+ FARPROC Hook_Init = nullptr;
+ {
+ 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 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)
+ {
+ 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, 0i64, 8u);
+ if (!hLauncherModule)
+ {
+ LibraryLoadError(GetLastError(), L"launcher.org.dll", dllPath);
+ return 1;
+ }
+
+ // this makes zero sense given tier0.dll is already loaded via imports on launcher.dll, but we do it for full consistency with original launcher exe
+ // and to also let load callbacks in Northstar work for tier0.dll
+ swprintf_s(dllPath, L"%s\\bin\\x64_retail\\tier0.dll", exePath);
+ hTier0Module = LoadLibraryW(dllPath);
+ if (!hTier0Module)
+ {
+ LibraryLoadError(GetLastError(), L"tier0.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;
+}
diff --git a/loader_launcher_proxy/framework.h b/loader_launcher_proxy/framework.h
new file mode 100644
index 00000000..54b83e94
--- /dev/null
+++ b/loader_launcher_proxy/framework.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files
+#include <windows.h>
diff --git a/loader_launcher_proxy/loader_launcher_proxy.vcxproj b/loader_launcher_proxy/loader_launcher_proxy.vcxproj
new file mode 100644
index 00000000..9cc7a4c7
--- /dev/null
+++ b/loader_launcher_proxy/loader_launcher_proxy.vcxproj
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>16.0</VCProjectVersion>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectGuid>{f65c322d-66df-4af1-b650-70221de334c0}</ProjectGuid>
+ <RootNamespace>loaderlauncherproxy</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <TargetName>launcher</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <TargetName>launcher</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;LOADERLAUNCHERPROXY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableUAC>false</EnableUAC>
+ <AdditionalDependencies>shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;LOADERLAUNCHERPROXY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableUAC>false</EnableUAC>
+ <AdditionalOptions>/HIGHENTROPYVA:NO %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="framework.h" />
+ <ClInclude Include="Memory.h" />
+ <ClInclude Include="pch.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dllmain.cpp" />
+ <ClCompile Include="Memory.cpp" />
+ <ClCompile Include="pch.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/loader_launcher_proxy/loader_launcher_proxy.vcxproj.filters b/loader_launcher_proxy/loader_launcher_proxy.vcxproj.filters
new file mode 100644
index 00000000..519ed674
--- /dev/null
+++ b/loader_launcher_proxy/loader_launcher_proxy.vcxproj.filters
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="framework.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="pch.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Memory.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dllmain.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="pch.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Memory.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/loader_launcher_proxy/pch.cpp b/loader_launcher_proxy/pch.cpp
new file mode 100644
index 00000000..64b7eef6
--- /dev/null
+++ b/loader_launcher_proxy/pch.cpp
@@ -0,0 +1,5 @@
+// pch.cpp: source file corresponding to the pre-compiled header
+
+#include "pch.h"
+
+// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
diff --git a/loader_launcher_proxy/pch.h b/loader_launcher_proxy/pch.h
new file mode 100644
index 00000000..30257bb2
--- /dev/null
+++ b/loader_launcher_proxy/pch.h
@@ -0,0 +1,15 @@
+// pch.h: This is a precompiled header file.
+// Files listed below are compiled only once, improving build performance for future builds.
+// This also affects IntelliSense performance, including code completion and many code browsing features.
+// However, files listed here are ALL re-compiled if any one of them is updated between builds.
+// Do not add files here that you will be updating frequently as this negates the performance advantage.
+
+#ifndef PCH_H
+#define PCH_H
+
+#include "Memory.h"
+
+// add headers that you want to pre-compile here
+#include "framework.h"
+
+#endif //PCH_H