Author: akhaldi
Date: Sun Nov 22 10:24:00 2015
New Revision: 70015
URL:
http://svn.reactos.org/svn/reactos?rev=70015&view=rev
Log:
[IMAGEHLP] Sync with Wine Staging 1.7.55. CORE-10536
Modified:
trunk/reactos/dll/win32/imagehlp/CMakeLists.txt
trunk/reactos/dll/win32/imagehlp/access.c
trunk/reactos/dll/win32/imagehlp/modify.c
trunk/reactos/dll/win32/imagehlp/precomp.h
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/imagehlp/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/imagehlp/CMakeLi…
==============================================================================
--- trunk/reactos/dll/win32/imagehlp/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/imagehlp/CMakeLists.txt [iso-8859-1] Sun Nov 22 10:24:00 2015
@@ -17,7 +17,7 @@
${CMAKE_CURRENT_BINARY_DIR}/imagehlp.def)
set_module_type(imagehlp win32dll)
-target_link_libraries(imagehlp wine)
+target_link_libraries(imagehlp wine ${PSEH_LIB})
add_importlibs(imagehlp dbghelp msvcrt kernel32 ntdll)
add_pch(imagehlp precomp.h SOURCE)
add_cd_file(TARGET imagehlp DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/dll/win32/imagehlp/access.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/imagehlp/access.…
==============================================================================
--- trunk/reactos/dll/win32/imagehlp/access.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/imagehlp/access.c [iso-8859-1] Sun Nov 22 10:24:00 2015
@@ -25,25 +25,7 @@
/***********************************************************************
* Data
*/
-
-static PLOADED_IMAGE IMAGEHLP_pFirstLoadedImage=NULL;
-
-static LOADED_IMAGE IMAGEHLP_EmptyLoadedImage = {
- NULL, /* ModuleName */
- 0, /* hFile */
- NULL, /* MappedAddress */
- NULL, /* FileHeader */
- NULL, /* LastRvaSection */
- 0, /* NumberOfSections */
- NULL, /* Sections */
- 1, /* Characteristics */
- FALSE, /* fSystemImage */
- FALSE, /* fDOSImage */
- FALSE, /* fReadOnly */
- 0, /* Version */
- { &IMAGEHLP_EmptyLoadedImage.Links, &IMAGEHLP_EmptyLoadedImage.Links }, /*
Links */
- 148, /* SizeOfImage; */
-};
+LIST_ENTRY image_list = { &image_list, &image_list };
DECLSPEC_HIDDEN extern HANDLE IMAGEHLP_hHeap;
@@ -78,57 +60,69 @@
/***********************************************************************
* ImageLoad (IMAGEHLP.@)
*/
-PLOADED_IMAGE WINAPI ImageLoad(PCSTR DllName, PCSTR DllPath)
-{
- PLOADED_IMAGE pLoadedImage;
-
- FIXME("(%s, %s): stub\n", DllName, DllPath);
-
- pLoadedImage = HeapAlloc(IMAGEHLP_hHeap, 0, sizeof(LOADED_IMAGE));
- if (pLoadedImage)
- pLoadedImage->FileHeader = HeapAlloc(IMAGEHLP_hHeap, 0,
sizeof(IMAGE_NT_HEADERS));
-
- return pLoadedImage;
+PLOADED_IMAGE WINAPI ImageLoad(PCSTR dll_name, PCSTR dll_path)
+{
+ LOADED_IMAGE *image;
+
+ TRACE("(%s, %s)\n", dll_name, dll_path);
+
+ image = HeapAlloc(IMAGEHLP_hHeap, 0, sizeof(*image));
+ if (!image) return NULL;
+
+ if (!MapAndLoad(dll_name, dll_path, image, TRUE, TRUE))
+ {
+ HeapFree(IMAGEHLP_hHeap, 0, image);
+ return NULL;
+ }
+
+ image->Links.Flink = image_list.Flink;
+ image->Links.Blink = &image_list;
+ image_list.Flink->Blink = &image->Links;
+ image_list.Flink = &image->Links;
+
+ return image;
}
/***********************************************************************
* ImageUnload (IMAGEHLP.@)
*/
-BOOL WINAPI ImageUnload(PLOADED_IMAGE pLoadedImage)
-{
- LIST_ENTRY *pCurrent, *pFind;
-
- TRACE("(%p)\n", pLoadedImage);
-
- if(!IMAGEHLP_pFirstLoadedImage || !pLoadedImage)
- {
- /* No image loaded or null pointer */
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- pFind=&pLoadedImage->Links;
- pCurrent=&IMAGEHLP_pFirstLoadedImage->Links;
- while((pCurrent != pFind) &&
- (pCurrent != NULL))
- pCurrent = pCurrent->Flink;
- if(!pCurrent)
- {
- /* Not found */
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if(pCurrent->Blink)
- pCurrent->Blink->Flink = pCurrent->Flink;
- else
- IMAGEHLP_pFirstLoadedImage = pCurrent->Flink?CONTAINING_RECORD(
- pCurrent->Flink, LOADED_IMAGE, Links):NULL;
-
- if(pCurrent->Flink)
- pCurrent->Flink->Blink = pCurrent->Blink;
-
- return FALSE;
+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;
+ }
+
+ /* FIXME: do we really need to check this? */
+ mark = &image_list;
+ for (entry = mark->Flink; entry != mark; entry = entry->Flink)
+ {
+ image = CONTAINING_RECORD(entry, LOADED_IMAGE, Links);
+ if (image == loaded_image)
+ break;
+ }
+
+ if (entry == mark)
+ {
+ /* Not found */
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ entry->Blink->Flink = entry->Flink;
+ entry->Flink->Blink = entry->Blink;
+
+ UnMapAndLoad(loaded_image);
+ HeapFree(IMAGEHLP_hHeap, 0, loaded_image);
+
+ return TRUE;
}
/***********************************************************************
Modified: trunk/reactos/dll/win32/imagehlp/modify.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/imagehlp/modify.…
==============================================================================
--- trunk/reactos/dll/win32/imagehlp/modify.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/imagehlp/modify.c [iso-8859-1] Sun Nov 22 10:24:00 2015
@@ -20,6 +20,7 @@
#include "precomp.h"
+#include <wine/exception.h>
#include <wine/winternl.h>
static WORD CalcCheckSum(DWORD StartValue, LPVOID BaseAddress, DWORD WordCount);
@@ -151,26 +152,25 @@
/***********************************************************************
* CheckSum (internal)
*/
-static WORD CalcCheckSum(
- DWORD StartValue, LPVOID BaseAddress, DWORD WordCount)
-{
- 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));
+static WORD CalcCheckSum(DWORD StartValue, LPVOID BaseAddress, DWORD ByteCount)
+{
+ 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));
}
@@ -184,37 +184,57 @@
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *) BaseAddress;
PIMAGE_NT_HEADERS32 Header32;
PIMAGE_NT_HEADERS64 Header64;
+ PIMAGE_NT_HEADERS ret = NULL;
DWORD *ChecksumFile;
DWORD CalcSum;
- DWORD HdrSum;
+ DWORD HdrSum = 0;
TRACE("(%p, %d, %p, %p)\n",
BaseAddress, FileLength, HeaderSum, CheckSum
);
- CalcSum = (DWORD)CalcCheckSum(0,
- BaseAddress,
- (FileLength + 1) / sizeof(WORD));
-
- if (dos->e_magic != IMAGE_DOS_SIGNATURE)
- return NULL;
-
- Header32 = (IMAGE_NT_HEADERS32 *)((char *)dos + dos->e_lfanew);
-
- if (Header32->Signature != IMAGE_NT_SIGNATURE)
- return NULL;
-
- 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
- return NULL;
-
- HdrSum = *ChecksumFile;
+ CalcSum = (DWORD)CalcCheckSum(0, BaseAddress, FileLength);
+
+ __TRY
+ {
+ if (dos->e_magic != IMAGE_DOS_SIGNATURE)
+#ifdef __REACTOS__
+ _SEH2_LEAVE;
+#else
+ break;
+#endif
+
+ 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
/* Subtract image checksum from calculated checksum. */
/* fix low word of checksum */
@@ -241,9 +261,9 @@
CalcSum += FileLength;
*CheckSum = CalcSum;
- *HeaderSum = *ChecksumFile;
-
- return (PIMAGE_NT_HEADERS) Header32;
+ *HeaderSum = HdrSum;
+
+ return ret;
}
/***********************************************************************
Modified: trunk/reactos/dll/win32/imagehlp/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/imagehlp/precomp…
==============================================================================
--- trunk/reactos/dll/win32/imagehlp/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/imagehlp/precomp.h [iso-8859-1] Sun Nov 22 10:24:00 2015
@@ -3,7 +3,6 @@
#include <stdarg.h>
-#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Nov 22 10:24:00 2015
@@ -77,7 +77,7 @@
reactos/dll/win32/icmp # Out of sync
reactos/dll/win32/ieframe # Synced to WineStaging-1.7.55
reactos/dll/win32/imaadp32.acm # Synced to WineStaging-1.7.47
-reactos/dll/win32/imagehlp # Synced to WineStaging-1.7.47
+reactos/dll/win32/imagehlp # Synced to WineStaging-1.7.55
reactos/dll/win32/imm32 # Synced to Wine-1.7.27
reactos/dll/win32/inetcomm # Synced to WineStaging-1.7.47
reactos/dll/win32/inetmib1 # Synced to WineStaging-1.7.47