aboutsummaryrefslogtreecommitdiff
path: root/LauncherInjector
diff options
context:
space:
mode:
Diffstat (limited to 'LauncherInjector')
-rw-r--r--LauncherInjector/main.cpp73
-rw-r--r--LauncherInjector/ns_startup_args.txt1
-rw-r--r--LauncherInjector/ns_startup_args_dedi.txt1
3 files changed, 58 insertions, 17 deletions
diff --git a/LauncherInjector/main.cpp b/LauncherInjector/main.cpp
index 04aadf03..0fb025a7 100644
--- a/LauncherInjector/main.cpp
+++ b/LauncherInjector/main.cpp
@@ -7,6 +7,11 @@
#include <Shlwapi.h>
#include <iostream>
+#pragma comment(lib, "Ws2_32.lib")
+
+#include <winsock2.h>
+#include <WS2tcpip.h>
+
namespace fs = std::filesystem;
extern "C"
@@ -125,6 +130,34 @@ void LibraryLoadError(DWORD dwMessageId, const wchar_t* libName, const wchar_t*
MessageBoxA(GetForegroundWindow(), text, "Northstar Launcher Error", 0);
}
+void AwaitOriginStartup()
+{
+ WSADATA wsaData;
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+ SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ if (sock != INVALID_SOCKET)
+ {
+ const int LSX_PORT = 3216;
+
+ sockaddr_in lsxAddr;
+ lsxAddr.sin_family = AF_INET;
+ inet_pton(AF_INET, "127.0.0.1", &(lsxAddr.sin_addr));
+ lsxAddr.sin_port = htons(LSX_PORT);
+
+ std::cout << "LSX: connect()" << std::endl;
+ connect(sock, (struct sockaddr*)&lsxAddr, sizeof(lsxAddr));
+
+ char buf[4096];
+ recv(sock, buf, 4096, 0);
+ std::cout << buf << std::endl;
+
+ Sleep(8000);
+ }
+
+ WSACleanup();
+}
+
void EnsureOriginStarted()
{
if (GetProcessByName(L"Origin.exe") || GetProcessByName(L"EADesktop.exe"))
@@ -147,7 +180,7 @@ void EnsureOriginStarted()
return;
}
- printf("[*] Starting Origin...\n");
+ std::cout << "[*] Starting Origin..." << std::endl;
PROCESS_INFORMATION pi;
memset(&pi, 0, sizeof(pi));
@@ -168,11 +201,16 @@ void EnsureOriginStarted()
(LPSTARTUPINFOA)&si,
&pi);
- printf("[*] Waiting for Origin...\n");
+ std::cout << "[*] Waiting for Origin..." << std::endl;
+
+ // wait for origin process to boot
+ do
+ {
+ Sleep(500);
+ } while (!GetProcessByName(L"OriginClientService.exe") && !GetProcessByName(L"EADesktop.exe"));
- // 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 to start
+ AwaitOriginStartup();
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
@@ -253,7 +291,7 @@ bool LoadNorthstar()
LoadPlugins = GetProcAddress(hHookModule, "LoadPlugins");
if (!hHookModule || LoadPlugins == nullptr)
{
- printf("Failed to get function pointer to LoadPlugins of Northstar.dll\n");
+ std::cout << "Failed to get function pointer to LoadPlugins of Northstar.dll" << std::endl;
LibraryLoadError(GetLastError(), L"Northstar.dll", buffer);
return false;
}
@@ -266,7 +304,7 @@ bool LoadNorthstar()
HMODULE LoadDediStub(const char* name)
{
// this works because materialsystem_dx11.dll uses relative imports, and even a DLL loaded with an absolute path will take precedence
- printf("[*] Loading %s\n", name);
+ std::cout << "[*] Loading " << name << std::endl;
swprintf_s(buffer, L"%s\\bin\\x64_dedi\\%hs", exePath, name);
HMODULE h = LoadLibraryExW(buffer, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
if (!h)
@@ -310,7 +348,7 @@ int main(int argc, char* argv[])
if (dedicated && !nostubs)
{
- printf("[*] Loading stubs\n");
+ std::cout << "[*] Loading stubs" << std::endl;
HMODULE gssao, gtxaa, d3d11;
if (!(gssao = GetModuleHandleA("GFSDK_SSAO.win64.dll")) && !(gtxaa = GetModuleHandleA("GFSDK_TXAA.win64.dll")) &&
!(d3d11 = GetModuleHandleA("d3d11.dll")))
@@ -320,8 +358,8 @@ int main(int argc, char* argv[])
{
if ((!gssao || FreeLibrary(gssao)) && (!gtxaa || FreeLibrary(gtxaa)) && (!d3d11 || FreeLibrary(d3d11)))
{
- printf("[*] WARNING: Failed to load d3d11/gfsdk stubs from bin/x64_dedi. "
- "The stubs have been unloaded and the original libraries will be used instead.\n");
+ std::cout <<"[*] WARNING: Failed to load d3d11/gfsdk stubs from bin/x64_dedi. "
+ "The stubs have been unloaded and the original libraries will be used instead" << std::endl;
}
else
{
@@ -339,8 +377,8 @@ int main(int argc, char* argv[])
else
{
// this should never happen
- printf("[*] WARNING: Failed to load stubs because conflicting modules are already loaded, so those will be used instead "
- "(did Northstar initialize too late?).\n");
+ std::cout << "[*] WARNING: Failed to load stubs because conflicting modules are already loaded, so those will be used instead "
+ "(did Northstar initialize too late?)." << std::endl;
}
}
@@ -362,7 +400,7 @@ int main(int argc, char* argv[])
file.close();
}
- printf("[*] Loading tier0.dll\n");
+ std::cout << "[*] Loading tier0.dll" << std::endl;
swprintf_s(buffer, L"%s\\bin\\x64_retail\\tier0.dll", exePath);
hTier0Module = LoadLibraryExW(buffer, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
if (!hTier0Module)
@@ -374,14 +412,14 @@ int main(int argc, char* argv[])
bool loadNorthstar = ShouldLoadNorthstar(argc, argv);
if (loadNorthstar)
{
- printf("[*] Loading Northstar\n");
+ std::cout << "[*] Loading Northstar" << std::endl;
if (!LoadNorthstar())
return 1;
}
else
- printf("[*] Going to load the vanilla game\n");
+ std::cout << "[*] Going to load the vanilla game" << std::endl;
- printf("[*] Loading launcher.dll\n");
+ std::cout << "[*] Loading launcher.dll" << std::endl;
swprintf_s(buffer, L"%s\\bin\\x64_retail\\launcher.dll", exePath);
hLauncherModule = LoadLibraryExW(buffer, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
if (!hLauncherModule)
@@ -391,7 +429,7 @@ int main(int argc, char* argv[])
}
}
- printf("[*] Launching the game...\n");
+ std::cout << "[*] Launching the game..." << std::endl;
auto LauncherMain = GetLauncherMain();
if (!LauncherMain)
MessageBoxA(
@@ -402,6 +440,7 @@ int main(int argc, char* argv[])
// auto result = ((__int64(__fastcall*)())LauncherMain)();
// auto result = ((signed __int64(__fastcall*)(__int64))LauncherMain)(0i64);
+ std::cout.flush();
return ((int(/*__fastcall*/*)(HINSTANCE, HINSTANCE, LPSTR, int))LauncherMain)(
NULL, NULL, NULL, 0); // the parameters aren't really used anyways
}
diff --git a/LauncherInjector/ns_startup_args.txt b/LauncherInjector/ns_startup_args.txt
new file mode 100644
index 00000000..0713aef2
--- /dev/null
+++ b/LauncherInjector/ns_startup_args.txt
@@ -0,0 +1 @@
+-multiple \ No newline at end of file
diff --git a/LauncherInjector/ns_startup_args_dedi.txt b/LauncherInjector/ns_startup_args_dedi.txt
new file mode 100644
index 00000000..ce1dcf5f
--- /dev/null
+++ b/LauncherInjector/ns_startup_args_dedi.txt
@@ -0,0 +1 @@
++setplaylist private_match \ No newline at end of file