From d985a63065d02c9387e04dc3397947557e36f6c4 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Mon, 26 Oct 2026 22:54:37 +0000 Subject: [PATCH] Decompile 4 functions in Source/Utility/RegistryKey.cpp, Source/Utility/RegistryKey.h Batch #864 by ragnarok-clanker: 0 byte-identical, 4 confirmed by peer review. - fn_18150 RegistryKey::Create: logic confirmed by peer review - fn_18151 RegistryKey::Open: logic confirmed by peer review - fn_18152 RegistryKey::Query: logic confirmed by peer review - fn_18153 RegistryKey::Set: logic confirmed by peer review Reviewed-by: ragnarok-clanker Adds to the build: Source/Utility/RegistryKey.cpp --- Source/Utility/RegistryKey.cpp | 23 +++++++++++++++++++++++ Source/Utility/RegistryKey.h | 20 ++++++++++++++++++++ compile.json | 1 + 3 files changed, 44 insertions(+) create mode 100644 Source/Utility/RegistryKey.cpp create mode 100644 Source/Utility/RegistryKey.h diff --git a/Source/Utility/RegistryKey.cpp b/Source/Utility/RegistryKey.cpp new file mode 100644 index 00000000..b678ffa1 --- /dev/null +++ b/Source/Utility/RegistryKey.cpp @@ -0,0 +1,23 @@ +#include "Utility/RegistryKey.h" + +// FUNCTION: fn_18150 +bool RegistryKey::Create(HKEY parent, const char* subKey) { + DWORD disposition; + return RegCreateKeyExA(parent, subKey, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &this->handle, &disposition) == ERROR_SUCCESS; +} + +// FUNCTION: fn_18151 +bool RegistryKey::Open(HKEY parent, const char* subKey) { + return RegOpenKeyExA(parent, subKey, 0, KEY_ALL_ACCESS, &this->handle) == ERROR_SUCCESS; +} + +// FUNCTION: fn_18152 +bool RegistryKey::Query(const char* name, DWORD expectedType, BYTE* data, DWORD size) { + DWORD type; + return this->handle != nullptr && RegQueryValueExA(this->handle, name, nullptr, &type, data, &size) == ERROR_SUCCESS && type == expectedType; +} + +// FUNCTION: fn_18153 +bool RegistryKey::Set(const char* name, DWORD type, const BYTE* data, DWORD size) { + return this->handle != nullptr && RegSetValueExA(this->handle, name, 0, type, data, size) == ERROR_SUCCESS; +} diff --git a/Source/Utility/RegistryKey.h b/Source/Utility/RegistryKey.h new file mode 100644 index 00000000..6e5378a9 --- /dev/null +++ b/Source/Utility/RegistryKey.h @@ -0,0 +1,20 @@ +#ifndef RAGNAROK_SOURCE_UTILITY_REGISTRYKEY_H +#define RAGNAROK_SOURCE_UTILITY_REGISTRYKEY_H + +#include + +class RegistryKey { +public: + /* 0000 */ HKEY handle; + + bool Create(HKEY parent, const char* subKey); + bool Open(HKEY parent, const char* subKey); + bool Query(const char* name, DWORD expectedType, BYTE* data, DWORD size); + bool Set(const char* name, DWORD type, const BYTE* data, DWORD size); +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(RegistryKey) == 4); +#endif + +#endif diff --git a/compile.json b/compile.json index 189075b0..b4d2d2b2 100644 --- a/compile.json +++ b/compile.json @@ -607,6 +607,7 @@ "Source/Utility/NFileLog.cpp": 0, "Source/Utility/NIPAddr.cpp": 0, "Source/Utility/ProcessSecurity.cpp": 0, + "Source/Utility/RegistryKey.cpp": 0, "Source/Utility/Text/Base64.cpp": 0, "Source/Utility/Text/FormatString.cpp": 0, "Source/Utility/Text/GroupedInteger.cpp": 0,