From c1dbceefcf9ec4411ea894a9b44494aea9b2cc53 Mon Sep 17 00:00:00 2001 From: hasherezade Date: Wed, 7 Oct 2026 17:56:52 +0200 Subject: [PATCH] [BUGFIX] Fixed registry writes --- pe-bear/base/RegKeyManager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pe-bear/base/RegKeyManager.cpp b/pe-bear/base/RegKeyManager.cpp index 8596cd5..506234b 100644 --- a/pe-bear/base/RegKeyManager.cpp +++ b/pe-bear/base/RegKeyManager.cpp @@ -26,7 +26,7 @@ bool RegKeyManager::removeRegPath(const std::string &extension, const std::strin res1 = RegDeleteKeyA(hKey, "command"); res2 = RegDeleteKeyA(hKey, ""); - res = RegCloseKey(HKEY_CLASSES_ROOT); + res = RegCloseKey(hKey); if (res != ERROR_SUCCESS) { return false; } @@ -54,8 +54,8 @@ bool RegKeyManager::addRegPath(const std::string &extension, const std::string & if (res != ERROR_SUCCESS) { return false; } - res1 = RegSetValueExA(hKey, NULL, 0, REG_SZ, (BYTE*)cmdPath.c_str(), cmdPath.length()); - res = RegCloseKey(HKEY_CLASSES_ROOT); + res1 = RegSetValueExA(hKey, NULL, 0, REG_SZ, reinterpret_cast(cmdPath.c_str()), static_cast(cmdPath.length() + 1)); + res = RegCloseKey(hKey); if (res1 != ERROR_SUCCESS || res != ERROR_SUCCESS) { return false; } @@ -68,9 +68,9 @@ bool RegKeyManager::addRegPath(const std::string &extension, const std::string & } const std::string iconPath = path + ",0"; - res1 = RegSetValueExA(hKey, "Icon", 0, REG_SZ, (BYTE*)iconPath.c_str(), iconPath.length()); + res1 = RegSetValueExA(hKey, "Icon", 0, REG_SZ, reinterpret_cast(iconPath.c_str()), static_cast(iconPath.length() + 1)); - res = RegCloseKey(HKEY_CLASSES_ROOT); + res = RegCloseKey(hKey); if (res1 != ERROR_SUCCESS || res != ERROR_SUCCESS) { return false; } @@ -95,7 +95,7 @@ bool RegKeyManager::isKeySet(const std::string &extension, const std::string &ap if (res != ERROR_SUCCESS) { return false; } - res = RegCloseKey(HKEY_CLASSES_ROOT); + res = RegCloseKey(hKey); if (res == ERROR_SUCCESS) { return true; }