diff options
author | pg9182 <96569817+pg9182@users.noreply.github.com> | 2022-08-08 06:12:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 11:12:11 +0100 |
commit | 5e7668c2cd7ef9d017536f1e2e4ec89708f5b74f (patch) | |
tree | 6c55b909fd258251c238bfad9caf83113fd88f33 /loader_wsock32_proxy/loader.cpp | |
parent | 286cea5f6280e568f5cb4c953d93993c98625ce4 (diff) | |
download | NorthstarLauncher-5e7668c2cd7ef9d017536f1e2e4ec89708f5b74f.tar.gz NorthstarLauncher-5e7668c2cd7ef9d017536f1e2e4ec89708f5b74f.zip |
Fix most clang/mingw issues (#226)
- Fix include case.
- Replace MSVC-specific align with standard alignas.
- Type fixes.
- Delete operator noexcept.
- A few other minor issues.
- clang-format everything.
- Use c++20 instead of c++17.
- Rewrite ERROR macro for launcher_wsock32_proxy.
- Use a plain ifstream for the audio.cpp wavStream.
Note: When compiling with clang, you'll need -municode.
Related to #212.
Diffstat (limited to 'loader_wsock32_proxy/loader.cpp')
-rw-r--r-- | loader_wsock32_proxy/loader.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/loader_wsock32_proxy/loader.cpp b/loader_wsock32_proxy/loader.cpp index 61b4daf3..c53f5c00 100644 --- a/loader_wsock32_proxy/loader.cpp +++ b/loader_wsock32_proxy/loader.cpp @@ -14,7 +14,11 @@ void LibraryLoadError(DWORD dwMessageId, const wchar_t* libName, const wchar_t* 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); + 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 Wsock32 Proxy Error", 0); } @@ -32,7 +36,7 @@ bool ShouldLoadNorthstar() std::stringstream runNorthstarFileBuffer; runNorthstarFileBuffer << runNorthstarFile.rdbuf(); runNorthstarFile.close(); - if (!runNorthstarFileBuffer.str()._Starts_with("0")) + if (!runNorthstarFileBuffer.str().starts_with("0")) loadNorthstar = true; } return loadNorthstar; @@ -44,7 +48,8 @@ bool LoadNorthstar() { swprintf_s(buffer1, L"%s\\Northstar.dll", exePath); auto hHookModule = LoadLibraryExW(buffer1, 0, LOAD_WITH_ALTERED_SEARCH_PATH); - if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar"); + if (hHookModule) + Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar"); if (!hHookModule || Hook_Init == nullptr) { LibraryLoadError(GetLastError(), L"Northstar.dll", buffer1); @@ -52,11 +57,11 @@ bool LoadNorthstar() } } - ((bool (*)()) Hook_Init)(); + ((bool (*)())Hook_Init)(); return true; } -typedef int(*LauncherMainType)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); +typedef int (*LauncherMainType)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); LauncherMainType LauncherMainOriginal; int LauncherMainHook(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) @@ -73,19 +78,28 @@ bool ProvisionNorthstar() if (MH_Initialize() != MH_OK) { - MessageBoxA(GetForegroundWindow(), "MH_Initialize failed\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0); + MessageBoxA( + GetForegroundWindow(), "MH_Initialize failed\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0); return false; } auto launcherHandle = GetModuleHandleA("launcher.dll"); if (!launcherHandle) { - MessageBoxA(GetForegroundWindow(), "Launcher isn't loaded yet.\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0); + MessageBoxA( + GetForegroundWindow(), + "Launcher isn't loaded yet.\nThe game cannot continue and has to exit.", + "Northstar Wsock32 Proxy Error", + 0); return false; } HookEnabler hook; - ENABLER_CREATEHOOK(hook, GetProcAddress(launcherHandle, "LauncherMain"), &LauncherMainHook, reinterpret_cast<LPVOID*>(&LauncherMainOriginal)); + ENABLER_CREATEHOOK( + hook, + reinterpret_cast<void*>(GetProcAddress(launcherHandle, "LauncherMain")), + &LauncherMainHook, + reinterpret_cast<LPVOID*>(&LauncherMainOriginal)); return true; -}
\ No newline at end of file +} |