https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bee818a28ab9c355aa256…
commit bee818a28ab9c355aa256b9b349e1673f8b96886
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Sat Nov 2 18:33:24 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sat Nov 2 18:33:24 2019 +0100
[IMAGEHLP] Sync with Wine Staging 4.18. CORE-16441
---
dll/win32/imagehlp/access.c | 18 ++-----
dll/win32/imagehlp/imagehlp_main.c | 21 --------
dll/win32/imagehlp/modify.c | 98 +++++++++++---------------------------
media/doc/README.WINE | 2 +-
4 files changed, 34 insertions(+), 105 deletions(-)
diff --git a/dll/win32/imagehlp/access.c b/dll/win32/imagehlp/access.c
index 897f2d553b4..29315f172ab 100644
--- a/dll/win32/imagehlp/access.c
+++ b/dll/win32/imagehlp/access.c
@@ -33,9 +33,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(imagehlp);
/***********************************************************************
* Data
*/
-LIST_ENTRY image_list = { &image_list, &image_list };
+static LIST_ENTRY image_list = { &image_list, &image_list };
-DECLSPEC_HIDDEN extern HANDLE IMAGEHLP_hHeap;
/***********************************************************************
* GetImageConfigInformation (IMAGEHLP.@)
@@ -74,12 +73,12 @@ PLOADED_IMAGE WINAPI ImageLoad(PCSTR dll_name, PCSTR dll_path)
TRACE("(%s, %s)\n", dll_name, dll_path);
- image = HeapAlloc(IMAGEHLP_hHeap, 0, sizeof(*image));
+ image = HeapAlloc(GetProcessHeap(), 0, sizeof(*image));
if (!image) return NULL;
if (!MapAndLoad(dll_name, dll_path, image, TRUE, TRUE))
{
- HeapFree(IMAGEHLP_hHeap, 0, image);
+ HeapFree(GetProcessHeap(), 0, image);
return NULL;
}
@@ -99,14 +98,7 @@ BOOL WINAPI ImageUnload(PLOADED_IMAGE loaded_image)
LIST_ENTRY *entry, *mark;
PLOADED_IMAGE image;
- FIXME("(%p)\n", loaded_image);
-
- if (!loaded_image)
- {
- /* No image loaded or null pointer */
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
+ TRACE("(%p)\n", loaded_image);
/* FIXME: do we really need to check this? */
mark = &image_list;
@@ -128,7 +120,7 @@ BOOL WINAPI ImageUnload(PLOADED_IMAGE loaded_image)
entry->Flink->Blink = entry->Blink;
UnMapAndLoad(loaded_image);
- HeapFree(IMAGEHLP_hHeap, 0, loaded_image);
+ HeapFree(GetProcessHeap(), 0, loaded_image);
return TRUE;
}
diff --git a/dll/win32/imagehlp/imagehlp_main.c b/dll/win32/imagehlp/imagehlp_main.c
index e505126381d..183b744dab0 100644
--- a/dll/win32/imagehlp/imagehlp_main.c
+++ b/dll/win32/imagehlp/imagehlp_main.c
@@ -25,27 +25,6 @@
#include "imagehlp.h"
#include "wine/debug.h"
-/**********************************************************************/
-DECLSPEC_HIDDEN HANDLE IMAGEHLP_hHeap = NULL;
-
-/***********************************************************************
- * DllMain (IMAGEHLP.init)
- */
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- switch(fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDLL);
- IMAGEHLP_hHeap = HeapCreate(0, 0x10000, 0);
- break;
- case DLL_PROCESS_DETACH:
- if (lpvReserved) break;
- HeapDestroy(IMAGEHLP_hHeap);
- break;
- }
- return TRUE;
-}
/***********************************************************************
* MarkImageAsRunFromSwap (IMAGEHLP.@)
diff --git a/dll/win32/imagehlp/modify.c b/dll/win32/imagehlp/modify.c
index ee68a4ef850..66ab07e745b 100644
--- a/dll/win32/imagehlp/modify.c
+++ b/dll/win32/imagehlp/modify.c
@@ -25,7 +25,6 @@
#include "winternl.h"
#include "winerror.h"
#include "wine/debug.h"
-#include "wine/exception.h"
#include "imagehlp.h"
WINE_DEFAULT_DEBUG_CHANNEL(imagehlp);
@@ -159,25 +158,26 @@ BOOL WINAPI BindImageEx(
/***********************************************************************
* CheckSum (internal)
*/
-static WORD CalcCheckSum(DWORD StartValue, LPVOID BaseAddress, DWORD ByteCount)
+static WORD CalcCheckSum(
+ DWORD StartValue, LPVOID BaseAddress, DWORD WordCount)
{
- LPWORD Ptr;
- DWORD Sum, i;
-
- Sum = StartValue;
- Ptr = (LPWORD)BaseAddress;
- for (i = ByteCount; i > 1; i -= 2)
- {
- Sum += *Ptr;
- if (HIWORD(Sum) != 0)
- Sum = LOWORD(Sum) + HIWORD(Sum);
- Ptr++;
- }
-
- if (i == 1)
- Sum += *(BYTE *)Ptr;
-
- return (WORD)(LOWORD(Sum) + HIWORD(Sum));
+ LPWORD Ptr;
+ DWORD Sum;
+ DWORD i;
+
+ Sum = StartValue;
+ Ptr = (LPWORD)BaseAddress;
+ for (i = 0; i < WordCount; i++)
+ {
+ Sum += *Ptr;
+ if (HIWORD(Sum) != 0)
+ {
+ Sum = LOWORD(Sum) + HIWORD(Sum);
+ }
+ Ptr++;
+ }
+
+ return (WORD)(LOWORD(Sum) + HIWORD(Sum));
}
@@ -188,60 +188,19 @@ PIMAGE_NT_HEADERS WINAPI CheckSumMappedFile(
LPVOID BaseAddress, DWORD FileLength,
LPDWORD HeaderSum, LPDWORD CheckSum)
{
- IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *) BaseAddress;
- PIMAGE_NT_HEADERS32 Header32;
- PIMAGE_NT_HEADERS64 Header64;
- PIMAGE_NT_HEADERS ret = NULL;
- DWORD *ChecksumFile;
+ PIMAGE_NT_HEADERS header;
DWORD CalcSum;
- DWORD HdrSum = 0;
+ DWORD HdrSum;
- TRACE("(%p, %d, %p, %p)\n",
- BaseAddress, FileLength, HeaderSum, CheckSum
- );
+ TRACE("(%p, %d, %p, %p)\n", BaseAddress, FileLength, HeaderSum, CheckSum);
- CalcSum = (DWORD)CalcCheckSum(0, BaseAddress, FileLength);
+ CalcSum = CalcCheckSum(0, BaseAddress, (FileLength + 1) / sizeof(WORD));
+ header = RtlImageNtHeader(BaseAddress);
- __TRY
- {
- if (dos->e_magic != IMAGE_DOS_SIGNATURE)
-#ifdef __REACTOS__
- _SEH2_LEAVE;
-#else
- break;
-#endif
+ if (!header)
+ return NULL;
- Header32 = (IMAGE_NT_HEADERS32 *)((char *)dos + dos->e_lfanew);
- if (Header32->Signature != IMAGE_NT_SIGNATURE)
-#ifdef __REACTOS__
- _SEH2_LEAVE;
-#else
- break;
-#endif
-
- ret = (PIMAGE_NT_HEADERS)Header32;
-
- if (Header32->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
- ChecksumFile = &Header32->OptionalHeader.CheckSum;
- else if (Header32->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
- {
- Header64 = (IMAGE_NT_HEADERS64 *)Header32;
- ChecksumFile = &Header64->OptionalHeader.CheckSum;
- }
- else
-#ifdef __REACTOS__
- _SEH2_LEAVE;
-#else
- break;
-#endif
-
- HdrSum = *ChecksumFile;
- }
- __EXCEPT_PAGE_FAULT
- {
- /* nothing */
- }
- __ENDTRY
+ *HeaderSum = HdrSum = header->OptionalHeader.CheckSum;
/* Subtract image checksum from calculated checksum. */
/* fix low word of checksum */
@@ -268,9 +227,8 @@ PIMAGE_NT_HEADERS WINAPI CheckSumMappedFile(
CalcSum += FileLength;
*CheckSum = CalcSum;
- *HeaderSum = HdrSum;
- return ret;
+ return header;
}
/***********************************************************************
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index 21b3751e007..7f08673178d 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -77,7 +77,7 @@ dll/win32/httpapi # Synced to WineStaging-4.18
dll/win32/iccvid # Synced to WineStaging-4.0
dll/win32/ieframe # Synced to WineStaging-4.18
dll/win32/imaadp32.acm # Synced to WineStaging-4.0
-dll/win32/imagehlp # Synced to WineStaging-3.3
+dll/win32/imagehlp # Synced to WineStaging-4.18
dll/win32/imm32 # Synced to WineStaging-4.0
dll/win32/inetcomm # Synced to WineStaging-4.0
dll/win32/inetmib1 # Synced to WineStaging-3.17