diff options
author | F1F7Y <64418963+F1F7Y@users.noreply.github.com> | 2023-07-17 20:26:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-17 20:26:59 +0200 |
commit | 9841d698f89e1ec6cc9b0c04df10bad6010a54fe (patch) | |
tree | cf4f0c2068094325f56a6f69f04ef14ba7ddb90d | |
parent | 06825e30962d512aa374fa9cf0ab5a369e180a57 (diff) | |
download | NorthstarLauncher-1.17.0-rc2.tar.gz NorthstarLauncher-1.17.0-rc2.zip |
Search for Northstar.dll in profile directory (#451)v1.17.0-rc2v1.17.0-rc1v1.17.0
Looks for `Northstar.dll` in the specified profile directory using `-profile=<dir>`. If it doesn't exist it defaults to the `Northstar.dll` in the root directory.
This allows for having a separate DLL for each profile.
-rw-r--r-- | NorthstarLauncher/main.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/NorthstarLauncher/main.cpp b/NorthstarLauncher/main.cpp index 9f641036..ecc18c45 100644 --- a/NorthstarLauncher/main.cpp +++ b/NorthstarLauncher/main.cpp @@ -274,7 +274,42 @@ bool LoadNorthstar() { FARPROC Hook_Init = nullptr; { - swprintf_s(buffer, L"%s\\Northstar.dll", exePath); + std::string strProfile = "R2Northstar"; + char* clachar = strstr(GetCommandLineA(), "-profile="); + if (clachar) + { + std::string cla = std::string(clachar); + if (strncmp(cla.substr(9, 1).c_str(), "\"", 1)) + { + int space = cla.find(" "); + std::string dirname = cla.substr(9, space - 9); + std::cout << "[*] Found profile in command line arguments: " << dirname << std::endl; + strProfile = dirname.c_str(); + } + else + { + std::string quote = "\""; + int quote1 = cla.find(quote); + int quote2 = (cla.substr(quote1 + 1)).find(quote); + std::string dirname = cla.substr(quote1 + 1, quote2); + std::cout << "[*] Found profile in command line arguments: " << dirname << std::endl; + strProfile = dirname; + } + } + else + { + std::cout << "[*] Profile was not found in command line arguments. Using default: R2Northstar" << std::endl; + strProfile = "R2Northstar"; + } + + // Check if "Northstar.dll" exists in profile directory, if it doesnt fall back to root + swprintf_s(buffer, L"%s\\%s\\Northstar.dll", exePath, std::wstring(strProfile.begin(), strProfile.end()).c_str()); + + if (!fs::exists(fs::path(buffer))) + swprintf_s(buffer, L"%s\\Northstar.dll", exePath); + + std::wcout << L"[*] Using: " << buffer << std::endl; + hHookModule = LoadLibraryExW(buffer, 0, 8u); if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar"); |