Added patch with tests for imagehlp.{ImageLoad,ImageUnload,GetImageUnusedHeaderBytes}.

This commit is contained in:
Sebastian Lackner 2015-05-15 02:48:15 +02:00
parent a3ca9927db
commit dcfee86e79
4 changed files with 259 additions and 30 deletions

2
debian/changelog vendored
View File

@ -31,6 +31,8 @@ wine-staging (1.7.43) UNRELEASED; urgency=low
system32/drivers/etc/{services,hosts,networks,protocol}.
* Added patch to allocate fake hWnd for wineconsole curses backend.
* Added patch to implement kernel32.GetSystemTimePreciseAsFileTime.
* Added patch with tests for
imagehlp.{ImageLoad,ImageUnload,GetImageUnusedHeaderBytes}.
* Removed patch to use lockfree implementation for FD cache (accepted
upstream).
* Removed patch to properly handle closing sockets during a select call

View File

@ -0,0 +1,144 @@
From 1000f8248d714ee0c17ab5fce6c79d7a310666c9 Mon Sep 17 00:00:00 2001
From: Mark Jansen <learn0more@gmail.com>
Date: Thu, 14 May 2015 00:53:20 +0200
Subject: imagehlp/tests: Add tests for ImageLoad, ImageUnload,
GetImageUnusedHeaderBytes.
---
dlls/imagehlp/tests/image.c | 103 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/dlls/imagehlp/tests/image.c b/dlls/imagehlp/tests/image.c
index 48443f5..74068dd 100644
--- a/dlls/imagehlp/tests/image.c
+++ b/dlls/imagehlp/tests/image.c
@@ -33,6 +33,10 @@ static HMODULE hImageHlp;
static BOOL (WINAPI *pImageGetDigestStream)(HANDLE, DWORD, DIGEST_FUNCTION, DIGEST_HANDLE);
static BOOL (WINAPI *pBindImageEx)(DWORD Flags, const char *ImageName, const char *DllPath,
const char *SymbolPath, PIMAGEHLP_STATUS_ROUTINE StatusRoutine);
+static DWORD (WINAPI* pGetImageUnusedHeaderBytes)(PLOADED_IMAGE, LPDWORD);
+static PLOADED_IMAGE (WINAPI* pImageLoad)(PCSTR, PCSTR);
+static BOOL (WINAPI* pImageUnload)(PLOADED_IMAGE);
+
/* minimal PE file image */
#define VA_START 0x400000
@@ -427,6 +431,101 @@ static void test_bind_image_ex(void)
DeleteFileA(temp_file);
}
+static void test_image_load(void)
+{
+ char temp_file[MAX_PATH];
+ PLOADED_IMAGE img;
+ DWORD ret, count;
+ HANDLE file;
+
+ if (!pImageLoad || !pImageUnload)
+ {
+ win_skip("ImageLoad or ImageUnload function is not available\n");
+ return;
+ }
+ if (!pGetImageUnusedHeaderBytes)
+ {
+ win_skip("GetImageUnusedHeaderBytes function is not available\n");
+ return;
+ }
+
+ file = create_temp_file(temp_file);
+ if (file == INVALID_HANDLE_VALUE)
+ {
+ skip("couldn't create temp file\n");
+ return;
+ }
+
+ WriteFile(file, &bin, sizeof(bin), &count, NULL);
+ CloseHandle(file);
+
+ img = pImageLoad(temp_file, NULL);
+ ok(img != NULL, "ImageLoad unexpectedly failed\n");
+
+ if (img)
+ {
+ todo_wine
+ ok(!strcmp(img->ModuleName, temp_file),
+ "unexpected ModuleName, got %s instead of %s\n", img->ModuleName, temp_file);
+ todo_wine
+ ok(img->MappedAddress != NULL, "MappedAddress != NULL\n");
+ if (img->MappedAddress)
+ {
+ ok(!memcmp(img->MappedAddress, &bin.dos_header, sizeof(bin.dos_header)),
+ "MappedAddress doesn't point to IMAGE_DOS_HEADER\n");
+ }
+ ok(img->FileHeader != NULL, "FileHeader != NULL\n");
+ if (img->FileHeader)
+ {
+ todo_wine
+ ok(!memcmp(img->FileHeader, &bin.nt_headers, sizeof(bin.nt_headers)),
+ "FileHeader doesn't point to IMAGE_NT_HEADERS32\n");
+ }
+ todo_wine
+ ok(img->NumberOfSections == 3,
+ "unexpected NumberOfSections, got %d instead of 3\n", img->NumberOfSections);
+ if (img->NumberOfSections >= 3)
+ {
+ ok(!strcmp((const char *)img->Sections[0].Name, ".text"),
+ "unexpected name for section 0, expected .text, got %s\n",
+ (const char *)img->Sections[0].Name);
+ ok(!strcmp((const char *)img->Sections[1].Name, ".bss"),
+ "unexpected name for section 1, expected .bss, got %s\n",
+ (const char *)img->Sections[1].Name);
+ ok(!strcmp((const char *)img->Sections[2].Name, ".idata"),
+ "unexpected name for section 2, expected .idata, got %s\n",
+ (const char *)img->Sections[2].Name);
+ }
+ todo_wine
+ ok(img->Characteristics == 0x102,
+ "unexpected Characteristics, got 0x%x instead of 0x102\n", img->Characteristics);
+ ok(img->fSystemImage == 0,
+ "unexpected fSystemImage, got %d instead of 0\n", img->fSystemImage);
+ ok(img->fDOSImage == 0,
+ "unexpected fDOSImage, got %d instead of 0\n", img->fDOSImage);
+ todo_wine
+ ok(img->fReadOnly == 1 || broken(!img->fReadOnly) /* <= WinXP */,
+ "unexpected fReadOnly, got %d instead of 1\n", img->fReadOnly);
+ todo_wine
+ ok(img->Version == 1 || broken(!img->Version) /* <= WinXP */,
+ "unexpected Version, got %d instead of 1\n", img->Version);
+ todo_wine
+ ok(img->SizeOfImage == 0x600,
+ "unexpected SizeOfImage, got 0x%x instead of 0x600\n", img->SizeOfImage);
+
+ count = 0xdeadbeef;
+ ret = pGetImageUnusedHeaderBytes(img, &count);
+ todo_wine
+ ok(ret == 448, "GetImageUnusedHeaderBytes returned %u instead of 448\n", ret);
+ todo_wine
+ ok(count == 64, "unexpected size for unused header bytes, got %u instead of 64\n", count);
+
+ pImageUnload(img);
+ }
+
+ DeleteFileA(temp_file);
+}
+
START_TEST(image)
{
hImageHlp = LoadLibraryA("imagehlp.dll");
@@ -439,9 +538,13 @@ START_TEST(image)
pImageGetDigestStream = (void *) GetProcAddress(hImageHlp, "ImageGetDigestStream");
pBindImageEx = (void *) GetProcAddress(hImageHlp, "BindImageEx");
+ pGetImageUnusedHeaderBytes = (void *) GetProcAddress(hImageHlp, "GetImageUnusedHeaderBytes");
+ pImageLoad = (void *) GetProcAddress(hImageHlp, "ImageLoad");
+ pImageUnload = (void *) GetProcAddress(hImageHlp, "ImageUnload");
test_get_digest_stream();
test_bind_image_ex();
+ test_image_load();
FreeLibrary(hImageHlp);
}
--
2.4.0

View File

@ -0,0 +1,65 @@
From d6455eb2f3ff2f6d8d663c8254a42c310564c39e Mon Sep 17 00:00:00 2001
From: Mark Jansen <learn0more@gmail.com>
Date: Thu, 14 May 2015 00:52:42 +0200
Subject: imagehlp/tests: msvc compatibility fixes.
---
dlls/imagehlp/tests/image.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/imagehlp/tests/image.c b/dlls/imagehlp/tests/image.c
index 74068dd..8299630 100644
--- a/dlls/imagehlp/tests/image.c
+++ b/dlls/imagehlp/tests/image.c
@@ -60,7 +60,7 @@ struct Imports {
} ibn;
char dllname[0x10];
};
-#define EXIT_PROCESS (VA_START+RVA_IDATA+FIELD_OFFSET(struct Imports, thunks[0]))
+#define EXIT_PROCESS (VA_START+RVA_IDATA+FIELD_OFFSET(struct Imports, thunks))
static struct _PeImage {
IMAGE_DOS_HEADER dos_header;
@@ -74,9 +74,9 @@ static struct _PeImage {
char __alignment3[FILE_TOTAL-FILE_IDATA-sizeof(struct Imports)];
} bin = {
/* dos header */
- {IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {}, 0, 0, {}, FILE_PE_START},
+ {IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, 0, 0, {0}, FILE_PE_START},
/* alignment before PE header */
- {},
+ {0},
/* nt headers */
{IMAGE_NT_SIGNATURE,
/* basic headers - 3 sections, no symbols, EXE file */
@@ -103,7 +103,7 @@ static struct _PeImage {
0, 0, 0, IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE}
},
/* alignment before first section */
- {},
+ {0},
/* .text section */
{
0x31, 0xC0, /* xor eax, eax */
@@ -126,7 +126,7 @@ static struct _PeImage {
"KERNEL32.DLL"
},
/* final alignment */
- {}
+ {0}
};
#include <poppack.h>
@@ -226,7 +226,8 @@ static const struct expected_blob b1[] = {
{FILE_IDATA-FILE_TEXT, &bin.text_section},
{sizeof(bin.idata_section.descriptors[0].u.OriginalFirstThunk),
&bin.idata_section.descriptors[0].u.OriginalFirstThunk},
- {FIELD_OFFSET(struct Imports, thunks)-FIELD_OFFSET(struct Imports, descriptors[0].Name),
+ {FIELD_OFFSET(struct Imports, thunks)-
+ (FIELD_OFFSET(struct Imports, descriptors)+FIELD_OFFSET(IMAGE_IMPORT_DESCRIPTOR, Name)),
&bin.idata_section.descriptors[0].Name},
{FILE_TOTAL-FILE_IDATA-FIELD_OFFSET(struct Imports, ibn),
&bin.idata_section.ibn}
--
2.4.0

View File

@ -55,7 +55,7 @@ version()
echo "Copyright (C) 2014-2015 the Wine Staging project authors."
echo ""
echo "Patchset to be applied on upstream Wine:"
echo " commit f920dfd6984ca9227900d0f0406afb3ceb892cc5"
echo " commit 14c53a58632f89a4d3a6ae449f339806b4c094a0"
echo ""
}
@ -128,6 +128,7 @@ patch_enable_all ()
enable_gdiplus_GdipCreateEffect="$1"
enable_gdiplus_GdipCreateRegionRgnData="$1"
enable_imagehlp_BindImageEx="$1"
enable_imagehlp_ImageLoad="$1"
enable_iphlpapi_TCP_Table="$1"
enable_kernel32_CompareStringEx="$1"
enable_kernel32_CopyFileEx="$1"
@ -450,6 +451,9 @@ patch_enable ()
imagehlp-BindImageEx)
enable_imagehlp_BindImageEx="$2"
;;
imagehlp-ImageLoad)
enable_imagehlp_ImageLoad="$2"
;;
iphlpapi-TCP_Table)
enable_iphlpapi_TCP_Table="$2"
;;
@ -1810,23 +1814,6 @@ if test "$enable_advapi32_ImpersonateAnonymousToken" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-Misc_ACL
# |
# | This patchset fixes the following Wine bugs:
# | * [#15980] GetSecurityInfo returns NULL DACL for process object
# |
# | Modified files:
# | * dlls/advapi32/tests/security.c, server/process.c, server/security.h, server/token.c
# |
if test "$enable_server_Misc_ACL" -eq 1; then
patch_apply server-Misc_ACL/0001-server-Add-default-security-descriptor-ownership-for.patch
patch_apply server-Misc_ACL/0002-server-Add-default-security-descriptor-DACL-for-proc.patch
(
echo '+ { "Erich E. Hoover", "server: Add default security descriptor ownership for processes.", 1 },';
echo '+ { "Erich E. Hoover", "server: Add default security descriptor DACL for processes.", 1 },';
) >> "$patchlist"
fi
# Patchset server-CreateProcess_ACLs
# |
# | This patchset fixes the following Wine bugs:
@ -1846,6 +1833,23 @@ if test "$enable_server_CreateProcess_ACLs" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-Misc_ACL
# |
# | This patchset fixes the following Wine bugs:
# | * [#15980] GetSecurityInfo returns NULL DACL for process object
# |
# | Modified files:
# | * dlls/advapi32/tests/security.c, server/process.c, server/security.h, server/token.c
# |
if test "$enable_server_Misc_ACL" -eq 1; then
patch_apply server-Misc_ACL/0001-server-Add-default-security-descriptor-ownership-for.patch
patch_apply server-Misc_ACL/0002-server-Add-default-security-descriptor-DACL-for-proc.patch
(
echo '+ { "Erich E. Hoover", "server: Add default security descriptor ownership for processes.", 1 },';
echo '+ { "Erich E. Hoover", "server: Add default security descriptor DACL for processes.", 1 },';
) >> "$patchlist"
fi
# Patchset advapi32-LsaLookupSids
# |
# | Modified files:
@ -2511,6 +2515,18 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-wined3d_swapchain_present
# |
# | Modified files:
# | * dlls/wined3d/swapchain.c
# |
if test "$enable_wined3d_wined3d_swapchain_present" -eq 1; then
patch_apply wined3d-wined3d_swapchain_present/0001-wined3d-Silence-repeated-wined3d_swapchain_present-F.patch
(
echo '+ { "Sebastian Lackner", "wined3d: Silence repeated wined3d_swapchain_present FIXME.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-Dirtify_Vertex_Shader
# |
# | This patchset fixes the following Wine bugs:
@ -2599,18 +2615,6 @@ if test "$enable_wined3d_resource_check_usage" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-wined3d_swapchain_present
# |
# | Modified files:
# | * dlls/wined3d/swapchain.c
# |
if test "$enable_wined3d_wined3d_swapchain_present" -eq 1; then
patch_apply wined3d-wined3d_swapchain_present/0001-wined3d-Silence-repeated-wined3d_swapchain_present-F.patch
(
echo '+ { "Sebastian Lackner", "wined3d: Silence repeated wined3d_swapchain_present FIXME.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-CSMT_Main
# |
# | This patchset fixes the following Wine bugs:
@ -3176,6 +3180,20 @@ if test "$enable_imagehlp_BindImageEx" -eq 1; then
) >> "$patchlist"
fi
# Patchset imagehlp-ImageLoad
# |
# | Modified files:
# | * dlls/imagehlp/tests/image.c
# |
if test "$enable_imagehlp_ImageLoad" -eq 1; then
patch_apply imagehlp-ImageLoad/0001-imagehlp-tests-Add-tests-for-ImageLoad-ImageUnload-G.patch
patch_apply imagehlp-ImageLoad/0002-imagehlp-tests-msvc-compatibility-fixes.patch
(
echo '+ { "Mark Jansen", "imagehlp/tests: Add tests for ImageLoad, ImageUnload, GetImageUnusedHeaderBytes.", 1 },';
echo '+ { "Mark Jansen", "imagehlp/tests: msvc compatibility fixes.", 1 },';
) >> "$patchlist"
fi
# Patchset iphlpapi-TCP_Table
# |
# | This patchset fixes the following Wine bugs: