From 8ff084db7614f875d48f72a2dfb774046d387dec Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 6 Nov 2026 22:12:52 +0000 Subject: [PATCH] Decompile fn_08212 (CNProtectGameGuardMgr::Destroy) Batch #13802 by codeplay: 1 byte-identical, 0 confirmed by peer review. - fn_08212 CNProtectGameGuardMgr::Destroy: byte-identical Merged automatically: every function is byte-identical to the original. --- Source/Security/NProtectGameGuardMgr.cpp | 30 ++++++++++++++---------- Source/Security/NProtectGameGuardMgr.h | 20 +++++++++++----- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/Source/Security/NProtectGameGuardMgr.cpp b/Source/Security/NProtectGameGuardMgr.cpp index 541a20c00..77032409e 100644 --- a/Source/Security/NProtectGameGuardMgr.cpp +++ b/Source/Security/NProtectGameGuardMgr.cpp @@ -29,7 +29,6 @@ int InitNPGameMon(); int __stdcall GameGuardCallback(int code, const int* packet); void SetCallbackToGameMon(int(__stdcall* callback)(int, const int*)); void WriteMyLog(const char* file, int line, const char* format, ...); -void __fastcall DestroyAuthTokenVector(void* tokens); namespace { template @@ -70,6 +69,18 @@ namespace { } } +// OFFSET: 0x0076C3E0 +// FUNCTION: fn_45544 +CNProtectGameGuardMgr::~CNProtectGameGuardMgr() { + if (this->m_gameLib) { + CloseNPGameMon(); + ::operator delete(this->m_gameLib, 1); + this->m_gameLib = nullptr; + } + + DeleteCriticalSection(&this->m_lock); +} + // OFFSET: 0x0076C670 // FUNCTION: fn_08205 void CNProtectGameGuardMgr::ProcessAuth(int, int) { @@ -94,10 +105,8 @@ int CNProtectGameGuardMgr::Create() { // OFFSET: 0x0076CEA0 // FUNCTION: fn_08212 void CNProtectGameGuardMgr::Destroy() { - typedef void(__thiscall * DeletingDestructor)(CNProtectGameGuardMgr*, unsigned char); - if (g_nProtectGameGuardMgr) { - (*reinterpret_cast(g_nProtectGameGuardMgr))[0](g_nProtectGameGuardMgr, 1); + delete g_nProtectGameGuardMgr; g_nProtectGameGuardMgr = nullptr; } } @@ -209,16 +218,11 @@ int __stdcall GameGuardCallback(int code, const int* packet) { return 0; } case 0x3FB: { - const int id = packet[0]; - const int size = packet[1]; + CNProtectGameGuardMgr* manager = g_nProtectGameGuardMgr; const unsigned char* data = reinterpret_cast(packet + 2); - CNProtectGameGuardMgr::CSAuthToken token = {}; - token.id = id; - if (size != 0) { - token.bytes.assign(data, data + size); - } - NSyncObject lock(&g_nProtectGameGuardMgr->m_lock); - g_nProtectGameGuardMgr->m_tokens.push_back(token); + CNProtectGameGuardMgr::lcCSAuthToken token(packet[0], std::vector(data, data + packet[1])); + NSyncObject lock(&manager->m_lock); + manager->m_tokens.push_back(token); break; } default: diff --git a/Source/Security/NProtectGameGuardMgr.h b/Source/Security/NProtectGameGuardMgr.h index 86964d266..ff005ceed 100644 --- a/Source/Security/NProtectGameGuardMgr.h +++ b/Source/Security/NProtectGameGuardMgr.h @@ -6,10 +6,18 @@ #include #include +// VTABLE: vt_00506 class CNProtectGameGuardMgr { public: - struct CSAuthToken { - /* 0000 */ void* vtable; + // VTABLE: vt_00505 + class lcCSAuthToken { + public: + // INLINED + lcCSAuthToken(int id, const std::vector& bytes) : id(id), bytes(bytes) { + } + + virtual ~lcCSAuthToken() = default; + /* 0004 */ int id; /* 0008 */ std::vector bytes; }; @@ -18,14 +26,15 @@ public: static void Destroy(); static const char* GameName(); - /* 0000 */ void* vtable; + virtual ~CNProtectGameGuardMgr(); + /* 0004 */ bool m_initialized; /* 0008 */ unsigned int unknown_0008; /* 000C */ void* m_gameLib; /* 0010 */ bool m_hasError; /* 0014 */ std::string m_errorMessage; /* 002C */ CRITICAL_SECTION m_lock; - /* 0044 */ std::vector m_tokens; + /* 0044 */ std::vector m_tokens; void ProcessAuth(int first, int second); void Stop(); @@ -33,7 +42,6 @@ public: int HasError(); std::string ErrorMessage(); void SetHwnd(HWND window); - void ScalarDeletingDestructor(unsigned char flags); int Initialize(); void IncrementCounter(); void SetError(const char* file, int line, std::string message); @@ -44,7 +52,7 @@ public: static_assert(offsetof(CNProtectGameGuardMgr, m_errorMessage) == 0x14); static_assert(offsetof(CNProtectGameGuardMgr, m_lock) == 0x2C); static_assert(offsetof(CNProtectGameGuardMgr, m_tokens) == 0x44); -static_assert(sizeof(CNProtectGameGuardMgr::CSAuthToken) == 0x14); +static_assert(sizeof(CNProtectGameGuardMgr::lcCSAuthToken) == 0x14); static_assert(sizeof(CNProtectGameGuardMgr) == 0x50); #endif