rodecomp/Source/Network/Connection/ConnectionRuntime.cpp
ragnarok-clanker d92aee6684 Decompile 2 functions in Source/Network/Connection/ConnectionRuntime.cpp
Batch #10531 by cremane: 0 byte-identical, 2 confirmed by peer review.

- fn_20408 InitializeConnections: logic confirmed by peer review
- fn_20387 CheckConnectionRuntime: logic confirmed by peer review

Peer-reviewed-by: ragnarok-clanker, Yommy, dori, StrawberrysherbetIX
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-04 23:04:03 +00:00

58 lines
1.3 KiB
C++

#include "Network/Connection/ConnectionRuntime.h"
#include <windows.h>
namespace {
// GLOBAL: gl_24389
WSADATA wsaData;
// STATIC: 0x016FDC94
// GLOBAL: gl_24393
HMODULE module;
}
// STATIC: 0x016FDC8C
// GLOBAL: gl_24391
int(WSAAPI* g_connectionSend)(SOCKET, const char*, int, int);
// STATIC: 0x016FDC90
// GLOBAL: gl_24392
int(WSAAPI* g_connectionReceive)(SOCKET, char*, int, int);
// OFFSET: 0x00C7C400
// FUNCTION: fn_20387
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;
}
}
FreeLibrary(library);
return true;
}
// OFFSET: 0x00C7D020
// 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"));
CheckConnectionRuntime();
return true;
}
// OFFSET: 0x00C7C4B0
// FUNCTION: fn_20388
void Cleanup() {
WSACleanup();
FreeLibrary(module);
}