aboutsummaryrefslogtreecommitdiff
path: root/loader_wsock32_proxy/dllmain.cpp
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-08-08 06:12:11 -0400
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-14 14:37:24 +0200
commitc0e8e576df16171da6f0e68cbfa18123e8d1e7e0 (patch)
treefb157acfec3c1a510644481aade8f7115efb2295 /loader_wsock32_proxy/dllmain.cpp
parentd20cf6f08af37830d3bfc934cef356fa6a1aa102 (diff)
downloadNorthstarLauncher-c0e8e576df16171da6f0e68cbfa18123e8d1e7e0.tar.gz
NorthstarLauncher-c0e8e576df16171da6f0e68cbfa18123e8d1e7e0.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/dllmain.cpp')
-rw-r--r--loader_wsock32_proxy/dllmain.cpp64
1 files changed, 45 insertions, 19 deletions
diff --git a/loader_wsock32_proxy/dllmain.cpp b/loader_wsock32_proxy/dllmain.cpp
index f4c0d604..7feb278d 100644
--- a/loader_wsock32_proxy/dllmain.cpp
+++ b/loader_wsock32_proxy/dllmain.cpp
@@ -1,7 +1,7 @@
#include "pch.h"
#include "loader.h"
-#include <Shlwapi.h>
+#include <shlwapi.h>
#include <filesystem>
HINSTANCE hLThis = 0;
@@ -10,8 +10,10 @@ HINSTANCE hL = 0;
bool GetExePathWide(wchar_t* dest, DWORD destSize)
{
- if (!dest) return NULL;
- if (destSize < MAX_PATH) return NULL;
+ if (!dest)
+ return NULL;
+ if (destSize < MAX_PATH)
+ return NULL;
DWORD length = GetModuleFileNameW(NULL, dest, destSize);
return length && PathRemoveFileSpecW(dest);
@@ -29,7 +31,11 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
if (!GetExePathWide(exePath, 4096))
{
- MessageBoxA(GetForegroundWindow(), "Failed getting game directory.\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0);
+ MessageBoxA(
+ GetForegroundWindow(),
+ "Failed getting game directory.\nThe game cannot continue and has to exit.",
+ "Northstar Wsock32 Proxy Error",
+ 0);
return true;
}
@@ -59,7 +65,14 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
{
if (!std::filesystem::exists(temp_dir))
{
- swprintf_s(buffer2, L"Failed copying wsock32.dll from system32 to \"%s\"\n\n%S\n\nFurthermore, we failed copying wsock32.dll into temporary directory at \"%s\"\n\n%S", buffer1, e1.what(), temp_dir.c_str(), e2.what());
+ swprintf_s(
+ buffer2,
+ L"Failed copying wsock32.dll from system32 to \"%s\"\n\n%S\n\nFurthermore, we failed copying wsock32.dll into "
+ L"temporary directory at \"%s\"\n\n%S",
+ buffer1,
+ e1.what(),
+ temp_dir.c_str(),
+ e2.what());
MessageBoxW(GetForegroundWindow(), buffer2, L"Northstar Wsock32 Proxy Error", 0);
return false;
}
@@ -68,7 +81,8 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
}
}
hL = LoadLibraryExW(buffer1, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (!hL) {
+ if (!hL)
+ {
LibraryLoadError(GetLastError(), L"wsock32.org.dll", buffer1);
return false;
}
@@ -104,52 +118,64 @@ extern "C"
FARPROC PA = NULL;
int RunASM();
- void PROXY_EnumProtocolsA() {
+ void PROXY_EnumProtocolsA()
+ {
PA = p[1];
RunASM();
}
- void PROXY_EnumProtocolsW() {
+ void PROXY_EnumProtocolsW()
+ {
PA = p[2];
RunASM();
}
- void PROXY_GetAddressByNameA() {
+ void PROXY_GetAddressByNameA()
+ {
PA = p[4];
RunASM();
}
- void PROXY_GetAddressByNameW() {
+ void PROXY_GetAddressByNameW()
+ {
PA = p[5];
RunASM();
}
- void PROXY_WEP() {
+ void PROXY_WEP()
+ {
PA = p[17];
RunASM();
}
- void PROXY_WSARecvEx() {
+ void PROXY_WSARecvEx()
+ {
PA = p[30];
RunASM();
}
- void PROXY___WSAFDIsSet() {
+ void PROXY___WSAFDIsSet()
+ {
PA = p[36];
RunASM();
}
- void PROXY_getnetbyname() {
+ void PROXY_getnetbyname()
+ {
PA = p[45];
RunASM();
}
- void PROXY_getsockopt() {
+ void PROXY_getsockopt()
+ {
PA = p[52];
RunASM();
}
- void PROXY_inet_network() {
+ void PROXY_inet_network()
+ {
PA = p[56];
RunASM();
}
- void PROXY_s_perror() {
+ void PROXY_s_perror()
+ {
PA = p[67];
RunASM();
}
- void PROXY_setsockopt() {
+ void PROXY_setsockopt()
+ {
PA = p[72];
RunASM();
}
-} \ No newline at end of file
+}