From 51d6a71c87f877c0baf6efe8b760c6977db70b67 Mon Sep 17 00:00:00 2001 From: JustAnotherGuid <46401660+JustAnotherGuid@users.noreply.github.com> Date: Sat, 30 Mar 2019 23:36:29 +0100 Subject: [PATCH 1/2] mpqapi_reg_load_modification_time bin exact --- Source/mpqapi.cpp | 39 ++++++++++++++++++--------------------- Source/mpqapi.h | 2 +- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index a7393dc8f..e4072fc9a 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -55,31 +55,28 @@ void __fastcall mpqapi_store_creation_time(const char *pszArchive, int dwChar) } // 679660: using guessed type char gbMaxPlayers; -BOOLEAN __fastcall mpqapi_reg_load_modification_time(char *dst, int size) +BOOL __fastcall mpqapi_reg_load_modification_time(char *dst, int size) { - unsigned int v2; // esi - char *v3; // edi - unsigned int v6; // esi - char *v7; // ecx - int nbytes_read; // [esp+8h] [ebp-4h] - - v2 = size; - v3 = dst; + unsigned int iSize; + char *pszDst; + char *pbData; + int nbytes_read; + + iSize = size; + pszDst = dst; memset(dst, 0, size); - if (!SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2, (LPDWORD)&nbytes_read) || nbytes_read != v2) - return 0; - if (v2 >= 8) { - v6 = v2 >> 3; - do { - v7 = v3; - v3 += 8; - mpqapi_xor_buf(v7); - --v6; - } while (v6); + if (SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)pszDst, iSize, (LPDWORD)&nbytes_read)) + if (nbytes_read != size) + return FALSE; + + for (; iSize >= 8; iSize -=8) { + pbData = pszDst; + pszDst += 8; + mpqapi_xor_buf(pbData); } - return 1; -} + return TRUE; +} void __fastcall mpqapi_xor_buf(char *pbData) { signed int v1; // eax diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 67eaf4b45..ff46804cb 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -8,7 +8,7 @@ extern BOOLEAN save_archive_open; // weak BOOL __fastcall mpqapi_set_hidden(const char *pszArchive, BOOL hidden); void __fastcall mpqapi_store_creation_time(const char *pszArchive, int dwChar); -BOOLEAN __fastcall mpqapi_reg_load_modification_time(char *dst, int size); +BOOL __fastcall mpqapi_reg_load_modification_time(char *dst, int size); void __fastcall mpqapi_xor_buf(char *pbData); void __fastcall mpqapi_update_multi_creation_time(DWORD dwChar); BOOLEAN __fastcall mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen); From 2b561be90f10215de919e1d1d1efa65a68074c21 Mon Sep 17 00:00:00 2001 From: JustAnotherGuid <46401660+JustAnotherGuid@users.noreply.github.com> Date: Sat, 30 Mar 2019 23:58:27 +0100 Subject: [PATCH 2/2] mpqapi_reg_load_modification_time bin exact - really --- Source/mpqapi.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index e4072fc9a..8c7bafeaf 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -65,10 +65,13 @@ BOOL __fastcall mpqapi_reg_load_modification_time(char *dst, int size) iSize = size; pszDst = dst; memset(dst, 0, size); - if (SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)pszDst, iSize, (LPDWORD)&nbytes_read)) - if (nbytes_read != size) - return FALSE; + if (!SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)pszDst, iSize, (LPDWORD)&nbytes_read)) { + return FALSE; + } + if (nbytes_read != size) + return FALSE; + for (; iSize >= 8; iSize -=8) { pbData = pszDst; pszDst += 8; @@ -77,6 +80,7 @@ BOOL __fastcall mpqapi_reg_load_modification_time(char *dst, int size) return TRUE; } + void __fastcall mpqapi_xor_buf(char *pbData) { signed int v1; // eax