marked new tests as todo_wine
From: Mark Jansen learn0more@gmail.com
Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com --- dlls/imagehlp/tests/image.c | 95 +++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+)
diff --git a/dlls/imagehlp/tests/image.c b/dlls/imagehlp/tests/image.c index c0a26c39dc..dd2d60b626 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 @@ -425,6 +429,93 @@ 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"); @@ -437,9 +528,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); }
From: Michael Müller michael@fds-team.de
Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com --- dlls/imagehlp/access.c | 85 +++++++++++++++++++++---------------- dlls/imagehlp/tests/image.c | 12 +++--- 2 files changed, 54 insertions(+), 43 deletions(-)
diff --git a/dlls/imagehlp/access.c b/dlls/imagehlp/access.c index 6a33c0c677..897f2d553b 100644 --- a/dlls/imagehlp/access.c +++ b/dlls/imagehlp/access.c @@ -33,8 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(imagehlp); /*********************************************************************** * Data */ - -static PLOADED_IMAGE IMAGEHLP_pFirstLoadedImage=NULL; +LIST_ENTRY image_list = { &image_list, &image_list };
DECLSPEC_HIDDEN extern HANDLE IMAGEHLP_hHeap;
@@ -69,57 +68,69 @@ DWORD WINAPI GetImageUnusedHeaderBytes( /*********************************************************************** * ImageLoad (IMAGEHLP.@) */ -PLOADED_IMAGE WINAPI ImageLoad(PCSTR DllName, PCSTR DllPath) +PLOADED_IMAGE WINAPI ImageLoad(PCSTR dll_name, PCSTR dll_path) { - 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; + 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) +BOOL WINAPI ImageUnload(PLOADED_IMAGE loaded_image) { - LIST_ENTRY *pCurrent, *pFind; + LIST_ENTRY *entry, *mark; + PLOADED_IMAGE image; + + FIXME("(%p)\n", loaded_image);
- TRACE("(%p)\n", pLoadedImage); - - if(!IMAGEHLP_pFirstLoadedImage || !pLoadedImage) + if (!loaded_image) { - /* No image loaded or null pointer */ - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + /* 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) + /* FIXME: do we really need to check this? */ + mark = &image_list; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { - /* Not found */ - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + image = CONTAINING_RECORD(entry, LOADED_IMAGE, Links); + if (image == loaded_image) + break; }
- if(pCurrent->Blink) - pCurrent->Blink->Flink = pCurrent->Flink; - else - IMAGEHLP_pFirstLoadedImage = pCurrent->Flink?CONTAINING_RECORD( - pCurrent->Flink, LOADED_IMAGE, Links):NULL; + if (entry == mark) + { + /* Not found */ + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + }
- if(pCurrent->Flink) - pCurrent->Flink->Blink = pCurrent->Blink; + entry->Blink->Flink = entry->Flink; + entry->Flink->Blink = entry->Blink;
- return FALSE; + UnMapAndLoad(loaded_image); + HeapFree(IMAGEHLP_hHeap, 0, loaded_image); + + return TRUE; }
/*********************************************************************** diff --git a/dlls/imagehlp/tests/image.c b/dlls/imagehlp/tests/image.c index dd2d60b626..b8583ecd60 100644 --- a/dlls/imagehlp/tests/image.c +++ b/dlls/imagehlp/tests/image.c @@ -462,9 +462,9 @@ static void test_image_load(void)
if (img) { - todo_wine ok(!strcmp(img->ModuleName, temp_file), + 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"); + ok(img->MappedAddress != NULL, "MappedAddress != NULL\n"); if (img->MappedAddress) { ok(!memcmp(img->MappedAddress, &bin.dos_header, sizeof(bin.dos_header)), @@ -473,10 +473,10 @@ static void test_image_load(void) ok(img->FileHeader != NULL, "FileHeader != NULL\n"); if (img->FileHeader) { - todo_wine ok(!memcmp(img->FileHeader, &bin.nt_headers, sizeof(bin.nt_headers)), + 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, + ok(img->NumberOfSections == 3, "unexpected NumberOfSections, got %d instead of 3\n", img->NumberOfSections); if (img->NumberOfSections >= 3) { @@ -490,7 +490,7 @@ static void test_image_load(void) "unexpected name for section 2, expected .idata, got %s\n", (const char *)img->Sections[2].Name); } - todo_wine ok(img->Characteristics == 0x102, + 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); @@ -500,7 +500,7 @@ static void test_image_load(void) "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, + ok(img->SizeOfImage == 0x600, "unexpected SizeOfImage, got 0x%x instead of 0x600\n", img->SizeOfImage);
count = 0xdeadbeef;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49826
Your paranoid android.
=== w2008s64 (task log) ===
Task errors: The previous 1 run(s) terminated abnormally