22 #define NONAMELESSUNION 42 #define VA_START 0x400000 43 #define FILE_PE_START 0x50 44 #define NUM_SECTIONS 3 45 #define FILE_TEXT 0x200 46 #define RVA_TEXT 0x1000 47 #define RVA_BSS 0x2000 48 #define FILE_IDATA 0x400 49 #define RVA_IDATA 0x3000 50 #define FILE_TOTAL 0x600 51 #define RVA_TOTAL 0x4000 63 #define EXIT_PROCESS (VA_START+RVA_IDATA+FIELD_OFFSET(struct Imports, thunks)) 77 {
IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, 0, 0, {0},
FILE_PE_START},
88 RVA_TEXT,
RVA_TEXT,
RVA_BSS,
VA_START, 0x1000, 0x200, 4, 0, 1, 0, 4, 0, 0,
90 0x200000, 0x1000, 0x100000, 0x1000, 0, 0x10,
100 {
".bss", {0x400},
RVA_BSS, 0, 0, 0, 0, 0, 0,
198 ok(
expected->updates[
i].cb == got->
updates[
i].cb,
"%s, update %d: expected %d bytes, got %d\n",
202 "%s, update %d: unexpected value\n",
header,
i);
221 {
sizeof(
bin.nt_headers), &
bin.nt_headers},
222 {
sizeof(
bin.sections), &
bin.sections},
224 {
sizeof(
bin.idata_section.descriptors[0].u.OriginalFirstThunk),
225 &
bin.idata_section.descriptors[0].u.OriginalFirstThunk},
228 &
bin.idata_section.descriptors[0].Name},
230 &
bin.idata_section.ibn}
237 {
sizeof(
bin.nt_headers), &
bin.nt_headers},
238 {
sizeof(
bin.sections), &
bin.sections},
267 bin.nt_headers.OptionalHeader.CheckSum = 0;
280 bin.nt_headers.OptionalHeader.CheckSum =
sum;
296 ok(!
strcmp(DllName,
"KERNEL32.DLL"),
"expected DllName to be KERNEL32.DLL, got %s\n",
303 strcat(kernel32_path,
"\\KERNEL32.DLL");
304 ok(!
lstrcmpiA(DllName, kernel32_path),
"expected DllName to be %s, got %s\n",
305 kernel32_path, DllName);
307 "expected Parameter to be ExitProcess, got %s\n", (
char *)
Parameter);
311 ok(0,
"got unexpected reason %d\n",
reason);
325 if (!pImageGetDigestStream)
327 win_skip(
"ImageGetDigestStream function is not available\n");
333 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
337 skip(
"couldn't create temp file\n");
343 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
347 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
352 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
361 bin.nt_headers.OptionalHeader.CheckSum = 0;
362 bin.nt_headers.OptionalHeader.SizeOfInitializedData = 0;
363 bin.nt_headers.OptionalHeader.SizeOfImage = 0;
372 check_updates(
"flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO", &
a2, &accum);
387 win_skip(
"BindImageEx function is not available\n");
397 "expected ERROR_FILE_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n",
403 skip(
"couldn't create temp file\n");
439 if (!pImageLoad || !pImageUnload || !pGetImageUnusedHeaderBytes)
441 win_skip(
"ImageLoad functions are not available\n");
448 skip(
"couldn't create temp file\n");
456 ok(
img !=
NULL,
"ImageLoad unexpectedly failed\n");
461 "unexpected ModuleName, got %s instead of %s\n",
img->ModuleName,
temp_file);
462 ok(
img->MappedAddress !=
NULL,
"MappedAddress != NULL\n");
463 if (
img->MappedAddress)
466 "MappedAddress doesn't point to IMAGE_DOS_HEADER\n");
468 ok(
img->FileHeader !=
NULL,
"FileHeader != NULL\n");
472 "FileHeader doesn't point to IMAGE_NT_HEADERS32\n");
474 ok(
img->NumberOfSections == 3,
475 "unexpected NumberOfSections, got %d instead of 3\n",
img->NumberOfSections);
476 if (
img->NumberOfSections >= 3)
478 ok(!
strcmp((
const char *)
img->Sections[0].Name,
".text"),
479 "unexpected name for section 0, expected .text, got %s\n",
480 (
const char *)
img->Sections[0].Name);
481 ok(!
strcmp((
const char *)
img->Sections[1].Name,
".bss"),
482 "unexpected name for section 1, expected .bss, got %s\n",
483 (
const char *)
img->Sections[1].Name);
484 ok(!
strcmp((
const char *)
img->Sections[2].Name,
".idata"),
485 "unexpected name for section 2, expected .idata, got %s\n",
486 (
const char *)
img->Sections[2].Name);
488 ok(
img->Characteristics == 0x102,
489 "unexpected Characteristics, got 0x%x instead of 0x102\n",
img->Characteristics);
490 ok(
img->fSystemImage == 0,
491 "unexpected fSystemImage, got %d instead of 0\n",
img->fSystemImage);
492 ok(
img->fDOSImage == 0,
493 "unexpected fDOSImage, got %d instead of 0\n",
img->fDOSImage);
495 "unexpected fReadOnly, got %d instead of 1\n",
img->fReadOnly);
497 "unexpected Version, got %d instead of 1\n",
img->Version);
498 ok(
img->SizeOfImage == 0x600,
499 "unexpected SizeOfImage, got 0x%x instead of 0x600\n",
img->SizeOfImage);
504 ok(
ret == 448,
"GetImageUnusedHeaderBytes returned %u instead of 448\n",
ret);
506 ok(
count == 64,
"unexpected size for unused header bytes, got %u instead of 64\n",
count);
struct _IMAGE_OPTIONAL_HEADER IMAGE_OPTIONAL_HEADER32
#define ERROR_INVALID_PARAMETER
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
static const char const char const char PIMAGEHLP_STATUS_ROUTINE StatusRoutine
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
char * strcat(char *DstString, const char *SrcString)
static void test_get_digest_stream(void)
GLuint GLuint GLsizei count
enum _IMAGEHLP_STATUS_REASON IMAGEHLP_STATUS_REASON
static BOOL CALLBACK testing_status_routine(IMAGEHLP_STATUS_REASON reason, const char *ImageName, const char *DllName, ULONG_PTR Va, ULONG_PTR Parameter)
static void check_updates(LPCSTR header, const struct expected_update_accum *expected, const struct update_accum *got)
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
#define IMAGE_SCN_MEM_READ
struct _IMAGE_NT_HEADERS IMAGE_NT_HEADERS32
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetLastError(VOID)
static void test_image_load(void)
#define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO
char __alignment2[FILE_TEXT - FILE_PE_START - sizeof(IMAGE_NT_HEADERS32) - NUM_SECTIONS *sizeof(IMAGE_SECTION_HEADER)]
#define IMAGE_DOS_SIGNATURE
static const char const char const char * SymbolPath
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
static HANDLE create_temp_file(char *temp_file)
static const struct expected_update_accum a2
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
#define BIND_NO_BOUND_IMPORTS
#define ERROR_FILE_NOT_FOUND
static int sum(int x_, int y_)
#define IMAGE_NT_SIGNATURE
#define IMAGE_FILE_MACHINE_I386
IMAGE_DOS_HEADER dos_header
#define IMAGE_SCN_CNT_INITIALIZED_DATA
BOOL(WINAPI * PIMAGEHLP_STATUS_ROUTINE)(IMAGEHLP_STATUS_REASON, PCSTR, PCSTR, ULONG_PTR, ULONG_PTR)
_Must_inspect_result_ _In_ ULONG Flags
static void update_checksum(void)
unsigned char text_section[FILE_IDATA-FILE_TEXT]
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static int status_routine_called[BindSymbolsNotUpdated+1]
static const struct expected_update_accum a1
static UINT *static UINT UINT UINT UINT *static GdiplusAbort *static BOOL
#define todo_wine_if(is_todo)
#define IMAGE_FILE_EXECUTABLE_IMAGE
char __alignment3[FILE_TOTAL-FILE_IDATA-sizeof(struct Imports)]
static void test_bind_image_ex(void)
static const struct expected_blob b2[]
#define IMAGE_SCN_MEM_WRITE
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
static const char * ImageName
#define FILE_ATTRIBUTE_NORMAL
#define memcpy(s1, s2, n)
#define IMAGE_SCN_CNT_CODE
static void free_updates(struct update_accum *accum)
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA
IMAGE_IMPORT_DESCRIPTOR descriptors[2]
struct _IMAGE_DOS_HEADER IMAGE_DOS_HEADER
const struct expected_blob * updates
IMAGE_THUNK_DATA32 thunks[2]
IMAGE_THUNK_DATA32 original_thunks[2]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
char __alignment1[FILE_PE_START - sizeof(IMAGE_DOS_HEADER)]
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
static const char const char * DllPath
#define FIELD_OFFSET(t, f)
static struct _PeImage bin
static HMODULE MODULEINFO DWORD cb
static BOOL WINAPI accumulating_stream_output(DIGEST_HANDLE handle, BYTE *pb, DWORD cb)
static const struct expected_blob b1[]
int strcmp(const char *String1, const char *String2)
CRYPT_DATA_BLOB * updates
#define GetProcAddress(x, y)
IMAGE_NT_HEADERS32 nt_headers
#define CreateFileA(a, b, c, d, e, f, g)
struct Imports idata_section
static PLOADED_IMAGE(WINAPI *pImageLoad)(PCSTR
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
#define HeapFree(x, y, z)
#define IMAGE_SCN_MEM_EXECUTE
struct Imports::__IMPORT_BY_NAME ibn
#define IMAGE_SUBSYSTEM_WINDOWS_GUI
IMAGE_SECTION_HEADER sections[NUM_SECTIONS]
#define IMAGE_FILE_32BIT_MACHINE