Decompile fn_20387 (CheckConnectionRuntime)

Batch #12555 by cremane: 0 byte-identical, 1 confirmed by peer review.

- fn_20387 CheckConnectionRuntime: logic confirmed by peer review

Peer-reviewed-by: Yommy, alisonrag, gordaoprogramas, dori
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-05 20:11:33 +00:00
commit 3654696d35

View file

@ -8,10 +8,6 @@ namespace {
// GLOBAL: gl_24390
HMODULE ws2Module;
// STATIC: 0x016FDC94
// GLOBAL: gl_24393
HMODULE module;
}
// STATIC: 0x016FDC8C
// GLOBAL: gl_24391
@ -26,18 +22,17 @@ int(WSAAPI* g_connectionReceive)(SOCKET, char*, int, int);
bool CheckConnectionRuntime() {
const char* names[] = {"connect", "closesocket", "send", "select"};
HMODULE library = LoadLibraryA("ws2_32.dll");
if (!library) {
return true;
}
for (unsigned index = 0; index < 4; ++index) {
if (GetProcAddress(library, names[index]) != GetProcAddress(module, names[index])) {
FreeLibrary(library);
return false;
if (library) {
for (unsigned index = 0; index < 4; ++index) {
if (GetProcAddress(library, names[index]) != GetProcAddress(ws2Module, names[index])) {
FreeLibrary(library);
return false;
}
}
FreeLibrary(library);
}
FreeLibrary(library);
return true;
}
@ -45,9 +40,9 @@ bool CheckConnectionRuntime() {
// FUNCTION: fn_20408
bool InitializeConnections() {
WSAStartup(MAKEWORD(1, 1), &wsaData);
module = LoadLibraryA("ws2_32.dll");
g_connectionSend = reinterpret_cast<decltype(g_connectionSend)>(GetProcAddress(module, "send"));
g_connectionReceive = reinterpret_cast<decltype(g_connectionReceive)>(GetProcAddress(module, "recv"));
ws2Module = LoadLibraryA("ws2_32.dll");
g_connectionSend = reinterpret_cast<decltype(g_connectionSend)>(GetProcAddress(ws2Module, "send"));
g_connectionReceive = reinterpret_cast<decltype(g_connectionReceive)>(GetProcAddress(ws2Module, "recv"));
CheckConnectionRuntime();
return true;