# HG changeset patch # User Ritor1 # Date 1412256781 -21600 # Node ID 160e12614310e8c96874ecb2cc45a94a86606362 # Parent e3a619609dae95a4c6c94d5b3909ff12fffcf83d RegOpenKeyExA diff -r e3a619609dae -r 160e12614310 Engine/Registry.cpp --- a/Engine/Registry.cpp Fri Sep 19 18:03:18 2014 +0600 +++ b/Engine/Registry.cpp Thu Oct 02 19:33:01 2014 +0600 @@ -97,7 +97,7 @@ //----- (00464BEF) -------------------------------------------------------- void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue) { - LSTATUS (__stdcall *v4)(HKEY); // esi@1 + //LSTATUS (__stdcall *v4)(HKEY); // esi@1 LSTATUS result; // eax@7 DWORD Type; // [sp+Ch] [bp-24h]@5 LPCSTR lpValueName; // [sp+10h] [bp-20h]@1 @@ -116,40 +116,29 @@ v13 = 0; hKey = 0; phkResult = 0; - v4 = RegCloseKey; - if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) - || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) - || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition) - || RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) ) - { - result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); - } - else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) - { - RegCloseKey(v14); - v14 = 0; - result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); - } - else + result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); + if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) { - v4 = RegCloseKey; - RegCloseKey(v14); - v14 = 0; - RegCloseKey(v13); - v13 = 0; - RegCloseKey(phkResult); - phkResult = 0; - result = RegCloseKey(hKey); - hKey = 0; + if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition)) + { + if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition)) + { + if( !RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) ) + { + if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) + GetLastError(); + RegCloseKey(v14); + v14 = NULL; + } + RegCloseKey(v13); + v13 = NULL; + } + RegCloseKey(phkResult); + phkResult = NULL; + } + RegCloseKey(hKey); + hKey = NULL; } - if ( v14 ) - result = v4(v14); - if ( v13 ) - result = v4(v13); - if ( hKey ) - result = v4(hKey); - if ( phkResult ) - result = v4(phkResult); } //----- (00464D32) --------------------------------------------------------