ReactOS  r75214
image.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Juan Lang
3  * Copyright 2010 Andrey Turkin
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 #include <stdio.h>
20 #include <stdarg.h>
21 
22 #define NONAMELESSUNION
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winver.h>
26 #include <winnt.h>
27 #include <imagehlp.h>
28 
29 #include "wine/test.h"
30 
32 
33 static BOOL (WINAPI *pImageGetDigestStream)(HANDLE, DWORD, DIGEST_FUNCTION, DIGEST_HANDLE);
34 static BOOL (WINAPI *pBindImageEx)(DWORD Flags, const char *ImageName, const char *DllPath,
36 static DWORD (WINAPI* pGetImageUnusedHeaderBytes)(PLOADED_IMAGE, LPDWORD);
37 static PLOADED_IMAGE (WINAPI* pImageLoad)(PCSTR, PCSTR);
38 static BOOL (WINAPI* pImageUnload)(PLOADED_IMAGE);
39 
40 
41 /* minimal PE file image */
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
52 #include <pshpack1.h>
53 struct Imports {
59  char funcname[0x20];
60  } ibn;
61  char dllname[0x10];
62 };
63 #define EXIT_PROCESS (VA_START+RVA_IDATA+FIELD_OFFSET(struct Imports, thunks))
64 
65 static struct _PeImage {
74  char __alignment3[FILE_TOTAL-FILE_IDATA-sizeof(struct Imports)];
75 } bin = {
76  /* dos header */
77  {IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, 0, 0, {0}, FILE_PE_START},
78  /* alignment before PE header */
79  {0},
80  /* nt headers */
82  /* basic headers - 3 sections, no symbols, EXE file */
85  /* optional header */
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,
91  {{0, 0},
92  {RVA_IDATA, sizeof(struct Imports)}
93  }
94  }
95  },
96  /* sections */
97  {
98  {".text", {0x100}, RVA_TEXT, FILE_IDATA-FILE_TEXT, FILE_TEXT,
100  {".bss", {0x400}, RVA_BSS, 0, 0, 0, 0, 0, 0,
102  {".idata", {sizeof(struct Imports)}, RVA_IDATA, FILE_TOTAL-FILE_IDATA, FILE_IDATA, 0,
104  },
105  /* alignment before first section */
106  {0},
107  /* .text section */
108  {
109  0x31, 0xC0, /* xor eax, eax */
110  0xFF, 0x25, EXIT_PROCESS&0xFF, (EXIT_PROCESS>>8)&0xFF, (EXIT_PROCESS>>16)&0xFF,
111  (EXIT_PROCESS>>24)&0xFF, /* jmp ExitProcess */
112  0
113  },
114  /* .idata section */
115  {
116  {
117  {{RVA_IDATA + FIELD_OFFSET(struct Imports, original_thunks)}, 0, 0,
120  },
121  {{0}, 0, 0, 0, 0}
122  },
123  {{{RVA_IDATA+FIELD_OFFSET(struct Imports, ibn)}}, {{0}}},
124  {{{RVA_IDATA+FIELD_OFFSET(struct Imports, ibn)}}, {{0}}},
125  {0,"ExitProcess"},
126  "KERNEL32.DLL"
127  },
128  /* final alignment */
129  {0}
130 };
131 #include <poppack.h>
132 
133 struct blob
134 {
137 };
138 
140 {
142  const void *pb;
143 };
144 
145 struct update_accum
146 {
147  DWORD cUpdates;
148  struct blob *updates;
149 };
150 
152 {
154  const struct expected_blob *updates;
156 };
157 
159 
160 
162  DWORD cb)
163 {
164  struct update_accum *accum = (struct update_accum *)handle;
165  BOOL ret = FALSE;
166 
167  if (accum->cUpdates)
168  accum->updates = HeapReAlloc(GetProcessHeap(), 0, accum->updates,
169  (accum->cUpdates + 1) * sizeof(struct blob));
170  else
171  accum->updates = HeapAlloc(GetProcessHeap(), 0, sizeof(struct blob));
172  if (accum->updates)
173  {
174  struct blob *blob = &accum->updates[accum->cUpdates];
175 
176  blob->pb = HeapAlloc(GetProcessHeap(), 0, cb);
177  if (blob->pb)
178  {
179  memcpy(blob->pb, pb, cb);
180  blob->cb = cb;
181  ret = TRUE;
182  }
183  accum->cUpdates++;
184  }
185  return ret;
186 }
187 
189  const struct update_accum *got)
190 {
191  DWORD i;
192 
193  todo_wine_if (expected->todo)
194  ok(expected->cUpdates == got->cUpdates, "%s: expected %d updates, got %d\n",
195  header, expected->cUpdates, got->cUpdates);
196  for (i = 0; i < min(expected->cUpdates, got->cUpdates); i++)
197  {
198  ok(expected->updates[i].cb == got->updates[i].cb, "%s, update %d: expected %d bytes, got %d\n",
199  header, i, expected->updates[i].cb, got->updates[i].cb);
200  if (expected->updates[i].cb && expected->updates[i].cb == got->updates[i].cb)
201  ok(!memcmp(expected->updates[i].pb, got->updates[i].pb, got->updates[i].cb),
202  "%s, update %d: unexpected value\n", header, i);
203  }
204 }
205 
206 /* Frees the updates stored in accum */
207 static void free_updates(struct update_accum *accum)
208 {
209  DWORD i;
210 
211  for (i = 0; i < accum->cUpdates; i++)
212  HeapFree(GetProcessHeap(), 0, accum->updates[i].pb);
213  HeapFree(GetProcessHeap(), 0, accum->updates);
214  accum->updates = NULL;
215  accum->cUpdates = 0;
216 }
217 
218 static const struct expected_blob b1[] = {
219  {FILE_PE_START, &bin},
220  /* with zeroed Checksum/SizeOfInitializedData/SizeOfImage fields */
221  {sizeof(bin.nt_headers), &bin.nt_headers},
222  {sizeof(bin.sections), &bin.sections},
223  {FILE_IDATA-FILE_TEXT, &bin.text_section},
224  {sizeof(bin.idata_section.descriptors[0].u.OriginalFirstThunk),
225  &bin.idata_section.descriptors[0].u.OriginalFirstThunk},
226  {FIELD_OFFSET(struct Imports, thunks)-
228  &bin.idata_section.descriptors[0].Name},
230  &bin.idata_section.ibn}
231 };
232 static const struct expected_update_accum a1 = { sizeof(b1) / sizeof(b1[0]), b1, TRUE };
233 
234 static const struct expected_blob b2[] = {
235  {FILE_PE_START, &bin},
236  /* with zeroed Checksum/SizeOfInitializedData/SizeOfImage fields */
237  {sizeof(bin.nt_headers), &bin.nt_headers},
238  {sizeof(bin.sections), &bin.sections},
239  {FILE_IDATA-FILE_TEXT, &bin.text_section},
240  {FILE_TOTAL-FILE_IDATA, &bin.idata_section}
241 };
242 static const struct expected_update_accum a2 = { sizeof(b2) / sizeof(b2[0]), b2, FALSE };
243 
244 /* Creates a test file and returns a handle to it. The file's path is returned
245  * in temp_file, which must be at least MAX_PATH characters in length.
246  */
248 {
250  char temp_path[MAX_PATH];
251 
252  if (GetTempPathA(sizeof(temp_path), temp_path))
253  {
254  if (GetTempFileNameA(temp_path, "img", 0, temp_file))
255  file = CreateFileA(temp_file, GENERIC_READ | GENERIC_WRITE, 0, NULL,
257  }
258  return file;
259 }
260 
261 static void update_checksum(void)
262 {
263  WORD const * ptr;
264  DWORD size;
265  DWORD sum = 0;
266 
267  bin.nt_headers.OptionalHeader.CheckSum = 0;
268 
269  for(ptr = (WORD const *)&bin, size = (sizeof(bin)+1)/sizeof(WORD); size > 0; ptr++, size--)
270  {
271  sum += *ptr;
272  if (HIWORD(sum) != 0)
273  {
274  sum = LOWORD(sum) + HIWORD(sum);
275  }
276  }
277  sum = (WORD)(LOWORD(sum) + HIWORD(sum));
278  sum += sizeof(bin);
279 
280  bin.nt_headers.OptionalHeader.CheckSum = sum;
281 }
282 
284  const char *DllName, ULONG_PTR Va, ULONG_PTR Parameter)
285 {
286  char kernel32_path[MAX_PATH];
287 
288  if (0 <= (int)reason && reason <= BindSymbolsNotUpdated)
289  status_routine_called[reason]++;
290  else
291  ok(0, "expected reason between 0 and %d, got %d\n", BindSymbolsNotUpdated+1, reason);
292 
293  switch(reason)
294  {
295  case BindImportModule:
296  ok(!strcmp(DllName, "KERNEL32.DLL"), "expected DllName to be KERNEL32.DLL, got %s\n",
297  DllName);
298  break;
299 
300  case BindImportProcedure:
301  case BindForwarderNOT:
302  GetSystemDirectoryA(kernel32_path, MAX_PATH);
303  strcat(kernel32_path, "\\KERNEL32.DLL");
304  ok(!lstrcmpiA(DllName, kernel32_path), "expected DllName to be %s, got %s\n",
305  kernel32_path, DllName);
306  ok(!strcmp((char *)Parameter, "ExitProcess"),
307  "expected Parameter to be ExitProcess, got %s\n", (char *)Parameter);
308  break;
309 
310  default:
311  ok(0, "got unexpected reason %d\n", reason);
312  break;
313  }
314  return TRUE;
315 }
316 
317 static void test_get_digest_stream(void)
318 {
319  BOOL ret;
320  HANDLE file;
321  char temp_file[MAX_PATH];
322  DWORD count;
323  struct update_accum accum = { 0, NULL };
324 
325  if (!pImageGetDigestStream)
326  {
327  win_skip("ImageGetDigestStream function is not available\n");
328  return;
329  }
330  SetLastError(0xdeadbeef);
331  ret = pImageGetDigestStream(NULL, 0, NULL, NULL);
333  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
334  file = create_temp_file(temp_file);
335  if (file == INVALID_HANDLE_VALUE)
336  {
337  skip("couldn't create temp file\n");
338  return;
339  }
340  SetLastError(0xdeadbeef);
341  ret = pImageGetDigestStream(file, 0, NULL, NULL);
343  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
344  SetLastError(0xdeadbeef);
345  ret = pImageGetDigestStream(NULL, 0, accumulating_stream_output, &accum);
347  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
348  /* Even with "valid" parameters, it fails with an empty file */
349  SetLastError(0xdeadbeef);
350  ret = pImageGetDigestStream(file, 0, accumulating_stream_output, &accum);
352  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
353  /* Finally, with a valid executable in the file, it succeeds. Note that
354  * the file pointer need not be positioned at the beginning.
355  */
356  update_checksum();
357  WriteFile(file, &bin, sizeof(bin), &count, NULL);
358  FlushFileBuffers(file);
359 
360  /* zero out some fields ImageGetDigestStream would zero out */
361  bin.nt_headers.OptionalHeader.CheckSum = 0;
362  bin.nt_headers.OptionalHeader.SizeOfInitializedData = 0;
363  bin.nt_headers.OptionalHeader.SizeOfImage = 0;
364 
365  ret = pImageGetDigestStream(file, 0, accumulating_stream_output, &accum);
366  ok(ret, "ImageGetDigestStream failed: %d\n", GetLastError());
367  check_updates("flags = 0", &a1, &accum);
368  free_updates(&accum);
369  ret = pImageGetDigestStream(file, CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO,
371  ok(ret, "ImageGetDigestStream failed: %d\n", GetLastError());
372  check_updates("flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO", &a2, &accum);
373  free_updates(&accum);
374  CloseHandle(file);
375  DeleteFileA(temp_file);
376 }
377 
378 static void test_bind_image_ex(void)
379 {
380  BOOL ret;
381  HANDLE file;
382  char temp_file[MAX_PATH];
383  DWORD count;
384 
385  if (!pBindImageEx)
386  {
387  win_skip("BindImageEx function is not available\n");
388  return;
389  }
390 
391  /* call with a non-existent file */
392  SetLastError(0xdeadbeef);
393  ret = pBindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES, "nonexistent.dll", 0, 0,
395  ok(!ret && ((GetLastError() == ERROR_FILE_NOT_FOUND) ||
397  "expected ERROR_FILE_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n",
398  GetLastError());
399 
400  file = create_temp_file(temp_file);
401  if (file == INVALID_HANDLE_VALUE)
402  {
403  skip("couldn't create temp file\n");
404  return;
405  }
406 
407  WriteFile(file, &bin, sizeof(bin), &count, NULL);
408  CloseHandle(file);
409 
410  /* call with a proper PE file, but with StatusRoutine set to NULL */
411  ret = pBindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES, temp_file, 0, 0,
412  NULL);
413  ok(ret, "BindImageEx failed: %d\n", GetLastError());
414 
415  /* call with a proper PE file and StatusRoutine */
416  ret = pBindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES, temp_file, 0, 0,
418  ok(ret, "BindImageEx failed: %d\n", GetLastError());
419 
420  ok(status_routine_called[BindImportModule] == 1,
421  "StatusRoutine was called %d times\n", status_routine_called[BindImportModule]);
422 
423  ok((status_routine_called[BindImportProcedure] == 1)
424 #if defined(_WIN64)
425  || broken(status_routine_called[BindImportProcedure] == 0) /* < Win8 */
426 #endif
427  , "StatusRoutine was called %d times\n", status_routine_called[BindImportProcedure]);
428 
429  DeleteFileA(temp_file);
430 }
431 
432 static void test_image_load(void)
433 {
434  char temp_file[MAX_PATH];
436  DWORD ret, count;
437  HANDLE file;
438 
439  if (!pImageLoad || !pImageUnload)
440  {
441  win_skip("ImageLoad or ImageUnload function is not available\n");
442  return;
443  }
444  if (!pGetImageUnusedHeaderBytes)
445  {
446  win_skip("GetImageUnusedHeaderBytes function is not available\n");
447  return;
448  }
449 
450  file = create_temp_file(temp_file);
451  if (file == INVALID_HANDLE_VALUE)
452  {
453  skip("couldn't create temp file\n");
454  return;
455  }
456 
457  WriteFile(file, &bin, sizeof(bin), &count, NULL);
458  CloseHandle(file);
459 
460  img = pImageLoad(temp_file, NULL);
461  ok(img != NULL, "ImageLoad unexpectedly failed\n");
462 
463  if (img)
464  {
465  ok(!strcmp(img->ModuleName, temp_file),
466  "unexpected ModuleName, got %s instead of %s\n", img->ModuleName, temp_file);
467  ok(img->MappedAddress != NULL, "MappedAddress != NULL\n");
468  if (img->MappedAddress)
469  {
470  ok(!memcmp(img->MappedAddress, &bin.dos_header, sizeof(bin.dos_header)),
471  "MappedAddress doesn't point to IMAGE_DOS_HEADER\n");
472  }
473  ok(img->FileHeader != NULL, "FileHeader != NULL\n");
474  if (img->FileHeader)
475  {
476  ok(!memcmp(img->FileHeader, &bin.nt_headers, sizeof(bin.nt_headers)),
477  "FileHeader doesn't point to IMAGE_NT_HEADERS32\n");
478  }
479  ok(img->NumberOfSections == 3,
480  "unexpected NumberOfSections, got %d instead of 3\n", img->NumberOfSections);
481  if (img->NumberOfSections >= 3)
482  {
483  ok(!strcmp((const char *)img->Sections[0].Name, ".text"),
484  "unexpected name for section 0, expected .text, got %s\n",
485  (const char *)img->Sections[0].Name);
486  ok(!strcmp((const char *)img->Sections[1].Name, ".bss"),
487  "unexpected name for section 1, expected .bss, got %s\n",
488  (const char *)img->Sections[1].Name);
489  ok(!strcmp((const char *)img->Sections[2].Name, ".idata"),
490  "unexpected name for section 2, expected .idata, got %s\n",
491  (const char *)img->Sections[2].Name);
492  }
493  ok(img->Characteristics == 0x102,
494  "unexpected Characteristics, got 0x%x instead of 0x102\n", img->Characteristics);
495  ok(img->fSystemImage == 0,
496  "unexpected fSystemImage, got %d instead of 0\n", img->fSystemImage);
497  ok(img->fDOSImage == 0,
498  "unexpected fDOSImage, got %d instead of 0\n", img->fDOSImage);
499  todo_wine
500  ok(img->fReadOnly == 1 || broken(!img->fReadOnly) /* <= WinXP */,
501  "unexpected fReadOnly, got %d instead of 1\n", img->fReadOnly);
502  todo_wine
503  ok(img->Version == 1 || broken(!img->Version) /* <= WinXP */,
504  "unexpected Version, got %d instead of 1\n", img->Version);
505  ok(img->SizeOfImage == 0x600,
506  "unexpected SizeOfImage, got 0x%x instead of 0x600\n", img->SizeOfImage);
507 
508  count = 0xdeadbeef;
509  ret = pGetImageUnusedHeaderBytes(img, &count);
510  todo_wine
511  ok(ret == 448, "GetImageUnusedHeaderBytes returned %u instead of 448\n", ret);
512  todo_wine
513  ok(count == 64, "unexpected size for unused header bytes, got %u instead of 64\n", count);
514 
515  pImageUnload(img);
516  }
517 
518  DeleteFileA(temp_file);
519 }
520 
522 {
523  hImageHlp = LoadLibraryA("imagehlp.dll");
524 
525  if (!hImageHlp)
526  {
527  win_skip("ImageHlp unavailable\n");
528  return;
529  }
530 
531  pImageGetDigestStream = (void *) GetProcAddress(hImageHlp, "ImageGetDigestStream");
532  pBindImageEx = (void *) GetProcAddress(hImageHlp, "BindImageEx");
533  pGetImageUnusedHeaderBytes = (void *) GetProcAddress(hImageHlp, "GetImageUnusedHeaderBytes");
534  pImageLoad = (void *) GetProcAddress(hImageHlp, "ImageLoad");
535  pImageUnload = (void *) GetProcAddress(hImageHlp, "ImageUnload");
536 
539  test_image_load();
540 
542 }
struct _IMAGE_OPTIONAL_HEADER IMAGE_OPTIONAL_HEADER32
#define FILE_PE_START
Definition: image.c:43
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static const char const char const char PIMAGEHLP_STATUS_ROUTINE StatusRoutine
Definition: image.c:34
unsigned short WORD
Definition: ntddk_ex.h:93
BOOLEAN fDOSImage
Definition: dbghelp.h:108
#define RVA_IDATA
Definition: image.c:49
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
Definition: fci.c:97
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
DWORD cb
Definition: image.c:135
#define EXIT_PROCESS
Definition: image.c:63
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
Definition: image.c:133
static void test_get_digest_stream(void)
Definition: image.c:317
PIMAGE_SECTION_HEADER Sections
Definition: dbghelp.h:105
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)
Definition: image.c:283
PIMAGE_NT_HEADERS FileHeader
Definition: dbghelp.h:102
static void check_updates(LPCSTR header, const struct expected_update_accum *expected, const struct update_accum *got)
Definition: image.c:188
#define CALLBACK
Definition: compat.h:27
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
struct _IMAGE_NT_HEADERS IMAGE_NT_HEADERS32
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
char __alignment1[FILE_PE_START-sizeof(IMAGE_DOS_HEADER)]
Definition: image.c:67
#define RVA_TOTAL
Definition: image.c:51
char __alignment2[FILE_TEXT-FILE_PE_START-sizeof(IMAGE_NT_HEADERS32)-NUM_SECTIONS *sizeof(IMAGE_SECTION_HEADER)]
Definition: image.c:71
_In_ PVOID Parameter
Definition: ldrtypes.h:239
#define NUM_SECTIONS
Definition: image.c:44
static void test_image_load(void)
Definition: image.c:432
DWORD DWORD
Definition: winlogon.h:75
#define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO
Definition: imagehlp.h:39
ULONG NumberOfSections
Definition: dbghelp.h:104
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define RVA_TEXT
Definition: image.c:46
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
static const char const char const char * SymbolPath
Definition: image.c:34
GLenum GLclampf GLint i
Definition: glfuncs.h:14
char dllname[0x10]
Definition: image.c:61
#define FALSE
Definition: types.h:117
UCHAR Version
Definition: dbghelp.h:110
#define GENERIC_WRITE
Definition: nt_native.h:90
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static PVOID ptr
Definition: dispmode.c:41
static HANDLE create_temp_file(char *temp_file)
Definition: image.c:247
smooth NULL
Definition: ftsmooth.c:513
static const struct expected_update_accum a2
Definition: image.c:242
void UINT cb
Definition: fci.h:175
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define BIND_NO_BOUND_IMPORTS
Definition: imagehlp.h:28
const char * LPCSTR
Definition: xmlstorage.h:183
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static DIGEST_HANDLE
Definition: image.c:33
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define todo_wine_if(is_todo)
Definition: test.h:155
IMAGE_DOS_HEADER dos_header
Definition: image.c:66
#define FreeLibrary(x)
Definition: compat.h:405
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231
unsigned int BOOL
Definition: ntddk_ex.h:94
static void update_checksum(void)
Definition: image.c:261
PUCHAR MappedAddress
Definition: dbghelp.h:101
#define GetProcessHeap()
Definition: compat.h:395
unsigned char text_section[FILE_IDATA-FILE_TEXT]
Definition: image.c:72
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:175
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static int status_routine_called[BindSymbolsNotUpdated+1]
Definition: image.c:158
static const struct expected_update_accum a1
Definition: image.c:232
BOOLEAN fReadOnly
Definition: dbghelp.h:109
Definition: image.c:65
GLint GLvoid * img
Definition: gl.h:1956
static UINT *static UINT UINT UINT UINT *static GdiplusAbort *static BOOL
Definition: image.c:57
const void * pb
Definition: image.c:142
#define RVA_BSS
Definition: image.c:47
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
char __alignment3[FILE_TOTAL-FILE_IDATA-sizeof(struct Imports)]
Definition: image.c:74
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define SetLastError(x)
Definition: compat.h:409
static void test_bind_image_ex(void)
Definition: image.c:378
START_TEST(image)
Definition: image.c:5374
#define FILE_IDATA
Definition: image.c:48
static const struct expected_blob b2[]
Definition: image.c:234
BYTE * pb
Definition: image.c:136
_In_ PUNICODE_STRING Name
Definition: mrx.h:213
#define IMAGE_SCN_MEM_WRITE
Definition: ntimage.h:241
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1927
#define BIND_NO_UPDATE
Definition: imagehlp.h:29
int ret
static const char * ImageName
Definition: image.c:34
static HMODULE hImageHlp
Definition: image.c:31
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define todo_wine
Definition: test.h:154
#define VA_START
Definition: image.c:42
static LPDWORD
Definition: image.c:36
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define IMAGE_SCN_CNT_CODE
Definition: ntimage.h:230
static void free_updates(struct update_accum *accum)
Definition: image.c:207
#define GENERIC_READ
Definition: compat.h:124
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA
Definition: ntimage.h:232
IMAGE_IMPORT_DESCRIPTOR descriptors[2]
Definition: image.c:54
#define BIND_ALL_IMAGES
Definition: imagehlp.h:30
ULONG Characteristics
Definition: dbghelp.h:106
#define WINAPI
Definition: msvc.h:20
struct _IMAGE_DOS_HEADER IMAGE_DOS_HEADER
const struct expected_blob * updates
Definition: image.c:154
#define broken(x)
Definition: _sntprintf.h:21
unsigned char BYTE
Definition: ntddk_ex.h:96
static DIGEST_FUNCTION
Definition: image.c:33
DWORD cb
Definition: image.c:141
IMAGE_THUNK_DATA32 thunks[2]
Definition: image.c:56
#define FILE_TOTAL
Definition: image.c:50
#define CREATE_ALWAYS
Definition: disk.h:72
IMAGE_THUNK_DATA32 original_thunks[2]
Definition: image.c:55
DWORD *typedef HANDLE
Definition: winlogon.h:52
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
BOOL(WINAPI * PIMAGEHLP_STATUS_ROUTINE)(IMAGEHLP_STATUS_REASON, PCSTR, PCSTR, ULONG_PTR, ULONG_PTR)
Definition: imagehlp.h:109
static const char const char * DllPath
Definition: image.c:34
GLsizeiptr size
Definition: glext.h:5919
#define HeapReAlloc
Definition: compat.h:393
#define skip(...)
Definition: CString.cpp:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
PSTR ModuleName
Definition: dbghelp.h:99
char funcname[0x20]
Definition: image.c:59
#define min(a, b)
Definition: monoChain.cc:55
DWORD cUpdates
Definition: msg.c:538
BYTE Name[IMAGE_SIZEOF_SHORT_NAME]
Definition: pedump.c:281
PVOID DIGEST_HANDLE
Definition: imagehlp.h:259
struct blob * updates
Definition: image.c:148
static struct _PeImage bin
HANDLE HMODULE
Definition: typedefs.h:76
Definition: image.c:53
static BOOL WINAPI accumulating_stream_output(DIGEST_HANDLE handle, BYTE *pb, DWORD cb)
Definition: image.c:161
static const struct expected_blob b1[]
Definition: image.c:218
#define HIWORD(l)
Definition: typedefs.h:247
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
CRYPT_DATA_BLOB * updates
Definition: msg.c:539
#define GetProcAddress(x, y)
Definition: compat.h:410
IMAGE_NT_HEADERS32 nt_headers
Definition: image.c:68
#define ok(value,...)
Definition: CImage.cpp:33
static PCSTR
Definition: image.c:37
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
ULONG SizeOfImage
Definition: dbghelp.h:112
#define FILE_TEXT
Definition: image.c:45
struct Imports idata_section
Definition: image.c:73
#define win_skip
Definition: test.h:141
static PLOADED_IMAGE(WINAPI *pImageLoad)(PCSTR
#define LOWORD(l)
Definition: pedump.c:82
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define HeapFree(x, y, z)
Definition: compat.h:394
struct CFHEADER header
Definition: fdi.c:109
static DWORD
Definition: image.c:33
BOOL expected
Definition: store.c:2140
#define IMAGE_SCN_MEM_EXECUTE
Definition: ntimage.h:239
BOOLEAN fSystemImage
Definition: dbghelp.h:107
struct Imports::__IMPORT_BY_NAME ibn
#define IMAGE_SUBSYSTEM_WINDOWS_GUI
Definition: ntimage.h:437
IMAGE_SECTION_HEADER sections[NUM_SECTIONS]
Definition: image.c:69
Definition: fci.c:114
#define IMAGE_FILE_32BIT_MACHINE
Definition: pedump.c:164