From 4ae3cafbbd0bf7bdf4a52080cd357e6582cf3e7e Mon Sep 17 00:00:00 2001 From: kb1000 Date: Fri, 10 Jan 2025 01:37:04 +0100 Subject: [PATCH] Add launcher command line parameter to run legacy binaries from bin_legacy --- Star Ruler 2.exe | Bin 26624 -> 45568 bytes StarRuler2.sh | 28 +++-- source/loader/SR2Loader/HybridCRT.props | 38 +++++++ source/loader/SR2Loader/SR2Loader.vcxproj | 39 ++++--- .../SR2Loader/SR2Loader.vcxproj.filters | 1 + source/loader/main.c | 101 ++++++++++++------ source/msvc/Star Ruler 2/Star Ruler 2.sln | 6 +- 7 files changed, 154 insertions(+), 59 deletions(-) create mode 100644 source/loader/SR2Loader/HybridCRT.props diff --git a/Star Ruler 2.exe b/Star Ruler 2.exe index 3d6eba2b9b6625acd954445946321f58d0442799..7e3bc44e98b2191235254783479c04756f6712c0 100644 GIT binary patch delta 19975 zcmeHvdwf*Y_3xe}lT0At43fd9C<6uzVlWa^FkojOfipO<5yDFznIV}#Y97;h@UZAf z7@~~FXe_or+aI@0d4|^8V(mph@2?YrCK1$t?e7O_HE1h?p*B8#5Y#gFyY|^98AfY+ z|GxL|S!eCF_S$Q&z4qQ~KTd{*9z(;QlUimP`k$ILM|pnFxyFl~kDk=wL;IFD`$2zb z554&%$D7~m0lxhEtdp03o8~_9=I6i{J0CguB5=U|WiB)n1Qhrjgh=9&rp!p zznrmFVze-3Lz*=(_D&Kp#M94M4hr=zWX${2xa&smUjRWc1|J(^rlhCFU3=A(fM-Jh z?8pSX%z%m8J~G^}s`W-BZGarW&49SahMXyt?tq(kCV&?}wciVfdu-4;#j6Q&>l%{lmX%%8)^4>YU(SrHZZh>Yu_Iyge2r?Z3 z*AaR>CaZVK&6XcRNLF8uK6MRaO_5+a%KZkczR?c#6*(5EDw>fqH+VsAt|?}6=;dTN z)M=7KeTHDWtZvF#TC84_JKJGQ>>#;QzW5henvJZkm}Oi(V@|bKR!^Z;>4`76Z5Qn7 z$FizS`x|P0O4OXqYnHa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SpecificDefaultLibraries);libucrtd.lib + %(AdditionalOptions) /defaultlib:ucrtd.lib + + + + + + MultiThreaded + + + + %(IgnoreSpecificDefaultLibraries);libucrt.lib + %(AdditionalOptions) /defaultlib:ucrt.lib + + + + diff --git a/source/loader/SR2Loader/SR2Loader.vcxproj b/source/loader/SR2Loader/SR2Loader.vcxproj index 983de293..7b34a13b 100644 --- a/source/loader/SR2Loader/SR2Loader.vcxproj +++ b/source/loader/SR2Loader/SR2Loader.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -11,15 +11,17 @@ + 17.0 + Win32Proj + {93B31A9C-7169-47CA-80DB-CF3BB398291E} Application - MultiByte v143 - {93B31A9C-7169-47CA-80DB-CF3BB398291E} - SR2Loader + Unicode 10.0 + true false @@ -28,6 +30,9 @@ + + + @@ -37,14 +42,15 @@ $(SolutionDir)\..\..\..\ - - Star Ruler 2 Level3 - Disabled + true + _DEBUG;%(PreprocessorDefinitions) + true + stdc17 true @@ -53,23 +59,19 @@ Level3 - MinSpace true - true + MinSpace Size - MultiThreaded + true + true + NDEBUG;%(PreprocessorDefinitions) + true stdc17 - false - false - false - None - false true true - Windows - mainCRTStartup + true @@ -84,6 +86,9 @@ + + + diff --git a/source/loader/SR2Loader/SR2Loader.vcxproj.filters b/source/loader/SR2Loader/SR2Loader.vcxproj.filters index 07f91028..fa0eacc7 100644 --- a/source/loader/SR2Loader/SR2Loader.vcxproj.filters +++ b/source/loader/SR2Loader/SR2Loader.vcxproj.filters @@ -16,6 +16,7 @@ + diff --git a/source/loader/main.c b/source/loader/main.c index a6f9263e..c25c1350 100644 --- a/source/loader/main.c +++ b/source/loader/main.c @@ -1,43 +1,80 @@ -#include - -static inline __forceinline __declspec(allocator) wchar_t* wstrdup(const wchar_t *_String) { - size_t i = 0; - while (_String[i] != 0) - i++; - wchar_t* ret = (wchar_t *)HeapAlloc(GetProcessHeap(), 0, sizeof(wchar_t) * (i + 1)); - wsprintfW(ret, L"%s", _String); - return ret; -} +#include +#include +#include -DWORD __stdcall mainCRTStartup(LPVOID p) { - //Create command, passing all of our arguments - LPWSTR cmdline = GetCommandLineW(); - wchar_t search = ' '; - if (cmdline[0] == '"') { - search = '"'; - cmdline++; - } - while (cmdline[0] != 0) { - cmdline++; - if (cmdline[0] == search) { - cmdline++; - break; +int wmain(int argc, wchar_t* argv[]) { + + STARTUPINFOW startup = {}; + startup.cb = sizeof(startup); + + PROCESS_INFORMATION process = {}; + + wchar_t* path = L"bin\\win64\\Star Ruler 2.exe"; + + size_t size = 0; + for (int i = 0; i < argc; i++) { + if (wcscmp(argv[i], L"--legacy") == 0) { + path = L"bin_legacy\\win64\\Star Ruler 2.exe"; + } + else { + // worst-case estimate of expected escaped argument size, two output characters for every input character + // (to handle quotes and backslashes), one separator space and a leading and trailing quote + // first argument has no space, use it for the null terminator + size += wcslen(argv[i]) * 2 + 3; } } - while (cmdline[0] == ' ') { - cmdline++; - } - STARTUPINFOW startup; - SecureZeroMemory(&startup, sizeof(startup)); - startup.cb = sizeof(startup); + //Create command, passing all of our arguments + + wchar_t* cmdline = malloc(size * sizeof(wchar_t)); + wchar_t* cur = cmdline; - PROCESS_INFORMATION process; - SecureZeroMemory(&process, sizeof(process)); + for (int i = 0; i < argc; i++) { + if (wcscmp(argv[i], L"--legacy") == 0) { + continue; + } + + for (wchar_t* arg = argv[i]; *arg != L'\0'; arg++) { + if (i != 0) { + *cur++ = L' '; + } + *cur++ = L'"'; + switch (*arg) { + case L'"': + *cur++ = L'\\'; + *cur++ = L'"'; + arg++; + break; + case L'\\': + int backslashes = 0; + do { + backslashes++; + } while (arg[backslashes] == L'\\'); + if (arg[backslashes] != 0 && arg[backslashes] != L'"') { + for (int j = 0; j < backslashes; j++) { + *cur++ = L'\\'; + } + } + else { + for (int j = 0; j < backslashes; j++) { + *cur++ = L'\\'; + *cur++ = L'\\'; + } + } + arg += backslashes; + break; + default: + *cur++ = *arg++; + } + *cur++ = L'"'; + } + } + *cur = L'\0'; - if(CreateProcessW(L"bin\\win64\\Star Ruler 2.exe", wstrdup(cmdline), NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &startup, &process) != FALSE) { + if (CreateProcessW(path, cmdline, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &startup, &process) != FALSE) { CloseHandle(process.hProcess); CloseHandle(process.hThread); } + free(cmdline); return 0; } diff --git a/source/msvc/Star Ruler 2/Star Ruler 2.sln b/source/msvc/Star Ruler 2/Star Ruler 2.sln index b2ece365..e9b77e27 100644 --- a/source/msvc/Star Ruler 2/Star Ruler 2.sln +++ b/source/msvc/Star Ruler 2/Star Ruler 2.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.32407.337 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Star Ruler 2", "Star Ruler 2.vcxproj", "{50CA85BE-6640-4824-8CB6-9D65F77518F6}" ProjectSection(ProjectDependencies) = postProject @@ -89,7 +89,9 @@ Global {A1E1942C-36D2-4824-9ECB-B4727543E958}.Non-Steam Release|x64.ActiveCfg = Release|x64 {A1E1942C-36D2-4824-9ECB-B4727543E958}.Non-Steam Release|x64.Build.0 = Release|x64 {93B31A9C-7169-47CA-80DB-CF3BB398291E}.Debug|x64.ActiveCfg = Debug|x64 + {93B31A9C-7169-47CA-80DB-CF3BB398291E}.Debug|x64.Build.0 = Debug|x64 {93B31A9C-7169-47CA-80DB-CF3BB398291E}.Non-Steam Release|x64.ActiveCfg = Release|x64 + {93B31A9C-7169-47CA-80DB-CF3BB398291E}.Non-Steam Release|x64.Build.0 = Release|x64 {ABEA2C04-40F0-4D98-9191-A026E1D0DF07}.Debug|x64.ActiveCfg = Debug|x64 {ABEA2C04-40F0-4D98-9191-A026E1D0DF07}.Debug|x64.Build.0 = Debug|x64 {ABEA2C04-40F0-4D98-9191-A026E1D0DF07}.Non-Steam Release|x64.ActiveCfg = Release|x64