ReactOS 0.4.17-dev-966-gf06eace
image.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winver.h>
#include <winnt.h>
#include <winuser.h>
#include <imagehlp.h>
#include "wine/test.h"
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for image.c:

Go to the source code of this file.

Classes

struct  imports
 
struct  image
 
struct  imports64
 
struct  image64
 
struct  blob
 
struct  expected_blob
 
struct  update_accum
 
struct  expected_update_accum
 

Macros

#define VA_START   0x400000
 
#define FILE_PE_START   0x50
 
#define NUM_SECTIONS   3
 
#define FILE_TEXT   0x200
 
#define RVA_TEXT   0x1000
 
#define RVA_BSS   0x2000
 
#define FILE_IDATA   0x400
 
#define RVA_IDATA   0x3000
 
#define FILE_TOTAL   0x600
 
#define RVA_TOTAL   0x4000
 
#define EXIT_PROCESS   (VA_START + RVA_IDATA + FIELD_OFFSET(struct imports, thunks))
 

Functions

static char * load_resource (const char *name)
 
static BOOL WINAPI accumulating_stream_output (DIGEST_HANDLE handle, BYTE *pb, DWORD cb)
 
static void check_updates (LPCSTR header, const struct expected_update_accum *expected, const struct update_accum *got)
 
static void free_updates (struct update_accum *accum)
 
static HANDLE create_temp_file (char *temp_file)
 
static DWORD compute_checksum (const WORD *image, DWORD image_size)
 
static void test_get_digest_stream (void)
 
static BOOL WINAPI bind_image_cb (IMAGEHLP_STATUS_REASON reason, const char *file, const char *module, ULONG_PTR va, ULONG_PTR param)
 
static void test_bind_image_ex (void)
 
static void test_image_load (void)
 
 START_TEST (image)
 

Variables

static struct image bin
 
static struct image64 bin64
 
static const struct expected_blob b1 []
 
static const struct expected_update_accum a1 = { ARRAY_SIZE(b1), b1, TRUE }
 
static const struct expected_blob b2 []
 
static const struct expected_update_accum a2 = { ARRAY_SIZE(b2), b2, FALSE }
 
static const struct expected_blob b3 []
 
static const struct expected_update_accum a3 = { ARRAY_SIZE(b3), b3, TRUE }
 
static const struct expected_blob b4 []
 
static const struct expected_update_accum a4 = { ARRAY_SIZE(b4), b4, FALSE }
 
static unsigned int got_SysAllocString
 
static unsigned int got_GetOpenFileNameA
 
static unsigned int got_SHRegGetIntW
 

Macro Definition Documentation

◆ EXIT_PROCESS

#define EXIT_PROCESS   (VA_START + RVA_IDATA + FIELD_OFFSET(struct imports, thunks))

Definition at line 81 of file image.c.

◆ FILE_IDATA

#define FILE_IDATA   0x400

Definition at line 63 of file image.c.

◆ FILE_PE_START

#define FILE_PE_START   0x50

Definition at line 58 of file image.c.

◆ FILE_TEXT

#define FILE_TEXT   0x200

Definition at line 60 of file image.c.

◆ FILE_TOTAL

#define FILE_TOTAL   0x600

Definition at line 65 of file image.c.

◆ NUM_SECTIONS

#define NUM_SECTIONS   3

Definition at line 59 of file image.c.

◆ RVA_BSS

#define RVA_BSS   0x2000

Definition at line 62 of file image.c.

◆ RVA_IDATA

#define RVA_IDATA   0x3000

Definition at line 64 of file image.c.

◆ RVA_TEXT

#define RVA_TEXT   0x1000

Definition at line 61 of file image.c.

◆ RVA_TOTAL

#define RVA_TOTAL   0x4000

Definition at line 66 of file image.c.

◆ VA_START

#define VA_START   0x400000

Definition at line 57 of file image.c.

Function Documentation

◆ accumulating_stream_output()

static BOOL WINAPI accumulating_stream_output ( DIGEST_HANDLE  handle,
BYTE *  pb,
DWORD  cb 
)
static

Definition at line 253 of file image.c.

255{
256 struct update_accum *accum = (struct update_accum *)handle;
257 BOOL ret = FALSE;
258
259 if (accum->cUpdates)
260 accum->updates = HeapReAlloc(GetProcessHeap(), 0, accum->updates,
261 (accum->cUpdates + 1) * sizeof(struct blob));
262 else
263 accum->updates = HeapAlloc(GetProcessHeap(), 0, sizeof(struct blob));
264 if (accum->updates)
265 {
266 struct blob *blob = &accum->updates[accum->cUpdates];
267
269 if (blob->pb)
270 {
271 memcpy(blob->pb, pb, cb);
272 blob->cb = cb;
273 ret = TRUE;
274 }
275 accum->cUpdates++;
276 }
277 return ret;
278}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: image.c:229
DWORD cb
Definition: image.c:230
BYTE * pb
Definition: image.c:231
DWORD cUpdates
Definition: msg.c:494
CRYPT_DATA_BLOB * updates
Definition: msg.c:495

◆ bind_image_cb()

static BOOL WINAPI bind_image_cb ( IMAGEHLP_STATUS_REASON  reason,
const char *  file,
const char *  module,
ULONG_PTR  va,
ULONG_PTR  param 
)
static

Definition at line 485 of file image.c.

487{
488 static char last_module[MAX_PATH];
489
490 if (winetest_debug > 1)
491 trace("reason %u, file %s, module %s, va %#Ix, param %#Ix\n",
493
495 {
496 ok(!strchr(module, '\\'), "got module name %s\n", debugstr_a(module));
497 strcpy(last_module, module);
498 ok(!va, "got VA %#Ix\n", va);
499 ok(!param, "got param %#Ix\n", param);
500 }
501 else if (reason == BindImportProcedure)
502 {
503 char full_path[MAX_PATH];
504 BOOL ret;
505
506 todo_wine ok(!!va, "expected nonzero VA\n");
507 ret = SearchPathA(NULL, last_module, ".dll", sizeof(full_path), full_path, NULL);
508 ok(ret, "got error %lu\n", GetLastError());
509 ok(!strcmp(module, full_path), "expected %s, got %s\n", debugstr_a(full_path), debugstr_a(module));
510
511 if (!strcmp((const char *)param, "SysAllocString"))
512 {
513 ok(!strcmp(last_module, "oleaut32.dll"), "got wrong module %s\n", debugstr_a(module));
515 }
516 else if (!strcmp((const char *)param, "GetOpenFileNameA"))
517 {
518 ok(!strcmp(last_module, "comdlg32.dll"), "got wrong module %s\n", debugstr_a(module));
520 }
521 else if (!strcmp((const char *)param, "Ordinal117"))
522 {
523 ok(!strcmp(last_module, "shlwapi.dll"), "got wrong module %s\n", debugstr_a(module));
525 }
526 }
527 else
528 {
529 ok(0, "got unexpected reason %#x\n", reason);
530 }
531 return TRUE;
532}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1971
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI SearchPathA(IN LPCSTR lpPath OPTIONAL, IN LPCSTR lpFileName, IN LPCSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart OPTIONAL)
Definition: path.c:1222
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3291
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
GLfloat param
Definition: glext.h:5796
@ BindImportModule
Definition: imagehlp.h:105
@ BindImportProcedure
Definition: imagehlp.h:106
#define debugstr_a
Definition: kernel32.h:31
int winetest_debug
#define todo_wine
Definition: minitest.h:80
static unsigned int got_SHRegGetIntW
Definition: image.c:483
static unsigned int got_GetOpenFileNameA
Definition: image.c:483
static unsigned int got_SysAllocString
Definition: image.c:483
strcpy
Definition: string.h:131
Definition: fci.c:123
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_bind_image_ex().

◆ check_updates()

static void check_updates ( LPCSTR  header,
const struct expected_update_accum *  expected,
const struct update_accum *  got 
)
static

Definition at line 280 of file image.c.

282{
283 DWORD i;
284
285 todo_wine_if (expected->todo)
286 ok(expected->cUpdates == got->cUpdates, "%s: expected %ld updates, got %ld\n",
287 header, expected->cUpdates, got->cUpdates);
288 for (i = 0; i < min(expected->cUpdates, got->cUpdates); i++)
289 {
290 ok(expected->updates[i].cb == got->updates[i].cb, "%s, update %ld: expected %ld bytes, got %ld\n",
291 header, i, expected->updates[i].cb, got->updates[i].cb);
292 if (expected->updates[i].cb && expected->updates[i].cb == got->updates[i].cb)
293 ok(!memcmp(expected->updates[i].pb, got->updates[i].pb, got->updates[i].cb),
294 "%s, update %ld: unexpected value\n", header, i);
295 }
296}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
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
Definition: glfuncs.h:248
#define todo_wine_if(is_todo)
Definition: minitest.h:81
BOOL expected
Definition: store.c:2000
#define min(a, b)
Definition: monoChain.cc:55
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)

◆ compute_checksum()

static DWORD compute_checksum ( const WORD *  image,
DWORD  image_size 
)
static

Definition at line 378 of file image.c.

379{
380 const WORD *ptr = image;
381 DWORD size, sum = 0;
382
383 for (size = (image_size + 1) / sizeof(WORD); size > 0; ptr++, size--)
384 {
385 sum += *ptr;
386 if (HIWORD(sum)) sum = LOWORD(sum) + HIWORD(sum);
387 }
388 sum = (WORD)(LOWORD(sum) + HIWORD(sum));
389 sum += image_size;
390
391 return sum;
392}
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
static GLint image_size(GLint width, GLint height, GLenum format, GLenum type)
Definition: mipmap.c:4858
static PVOID ptr
Definition: dispmode.c:27
#define LOWORD(l)
Definition: pedump.c:82
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
Definition: image.c:84
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by test_get_digest_stream().

◆ create_temp_file()

static HANDLE create_temp_file ( char *  temp_file)
static

Definition at line 364 of file image.c.

365{
367 char temp_path[MAX_PATH];
368
369 if (GetTempPathA(sizeof(temp_path), temp_path))
370 {
371 if (GetTempFileNameA(temp_path, "img", 0, temp_file))
374 }
375 return file;
376}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2072
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define CREATE_ALWAYS
Definition: disk.h:72
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:106

◆ free_updates()

static void free_updates ( struct update_accum *  accum)
static

Definition at line 299 of file image.c.

300{
301 DWORD i;
302
303 for (i = 0; i < accum->cUpdates; i++)
304 HeapFree(GetProcessHeap(), 0, accum->updates[i].pb);
305 HeapFree(GetProcessHeap(), 0, accum->updates);
306 accum->updates = NULL;
307 accum->cUpdates = 0;
308}
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ load_resource()

static char * load_resource ( const char *  name)
static

Definition at line 31 of file image.c.

32{
33 static char path[MAX_PATH];
34 DWORD written;
36 HRSRC res;
37 void *ptr;
38
41
43 ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %lu.\n",
45
46 res = FindResourceA(NULL, name, "TESTDLL");
47 ok(!!res, "Failed to load resource, error %lu.\n", GetLastError());
50 ok(written == SizeofResource(GetModuleHandleA(NULL), res), "Failed to write resource.\n");
52
53 return path;
54}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLuint res
Definition: glext.h:9613
strcat
Definition: string.h:92
Definition: name.c:39

◆ START_TEST()

START_TEST ( image  )

Definition at line 633 of file image.c.

634{
638}
static void test_bind_image_ex(void)
Definition: image.c:534
static void test_image_load(void)
Definition: image.c:557
static void test_get_digest_stream(void)
Definition: image.c:394

◆ test_bind_image_ex()

static void test_bind_image_ex ( void  )
static

Definition at line 534 of file image.c.

535{
536 const char *filename = load_resource("testdll.dll");
537 BOOL ret;
538
539 SetLastError(0xdeadbeef);
541 "nonexistent.dll", 0, 0, bind_image_cb);
542 ok(!ret, "expected failure\n");
544 "got error %lu\n", GetLastError());
545
548 ok(ret, "got error %lu\n", GetLastError());
549 ok(got_SysAllocString == 1, "got %u imports of SysAllocString\n", got_SysAllocString);
550 ok(got_GetOpenFileNameA == 1, "got %u imports of GetOpenFileNameA\n", got_GetOpenFileNameA);
551 todo_wine ok(got_SHRegGetIntW == 1, "got %u imports of SHRegGetIntW\n", got_SHRegGetIntW);
552
554 ok(ret, "got error %lu\n", GetLastError());
555}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI BindImageEx(DWORD flags, const char *module, const char *dll_path, const char *symbol_path, PIMAGEHLP_STATUS_ROUTINE cb)
Definition: modify.c:48
#define BIND_NO_UPDATE
Definition: imagehlp.h:35
#define BIND_NO_BOUND_IMPORTS
Definition: imagehlp.h:34
#define BIND_ALL_IMAGES
Definition: imagehlp.h:36
const char * filename
Definition: ioapi.h:137
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define load_resource(a, b, c)
Definition: font.c:46
static BOOL WINAPI bind_image_cb(IMAGEHLP_STATUS_REASON reason, const char *file, const char *module, ULONG_PTR va, ULONG_PTR param)
Definition: image.c:485

Referenced by START_TEST().

◆ test_get_digest_stream()

static void test_get_digest_stream ( void  )
static

Definition at line 394 of file image.c.

395{
396 BOOL ret;
397 HANDLE file;
398 char temp_file[MAX_PATH];
400 struct update_accum accum = { 0, NULL };
401
402 SetLastError(0xdeadbeef);
405 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
408 {
409 skip("couldn't create temp file\n");
410 return;
411 }
412 SetLastError(0xdeadbeef);
415 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
416 SetLastError(0xdeadbeef);
419 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
420 /* Even with "valid" parameters, it fails with an empty file */
421 SetLastError(0xdeadbeef);
424 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
425 /* Finally, with a valid executable in the file, it succeeds. Note that
426 * the file pointer need not be positioned at the beginning.
427 */
428 bin.nt_headers.OptionalHeader.CheckSum = 0;
429 checksum = compute_checksum((const WORD *)&bin, sizeof(bin));
430 bin.nt_headers.OptionalHeader.CheckSum = checksum;
431
432 WriteFile(file, &bin, sizeof(bin), &count, NULL);
434
435 /* zero out some fields ImageGetDigestStream would zero out */
436 bin.nt_headers.OptionalHeader.CheckSum = 0;
437 bin.nt_headers.OptionalHeader.SizeOfInitializedData = 0;
438 bin.nt_headers.OptionalHeader.SizeOfImage = 0;
439
441 ok(ret, "ImageGetDigestStream failed: %ld\n", GetLastError());
442 check_updates("flags = 0", &a1, &accum);
443 free_updates(&accum);
446 ok(ret, "ImageGetDigestStream failed: %ld\n", GetLastError());
447 check_updates("flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO", &a2, &accum);
448 free_updates(&accum);
451
454 {
455 skip("couldn't create temp file\n");
456 return;
457 }
458
459 bin64.nt_headers.OptionalHeader.CheckSum = 0;
460 checksum = compute_checksum((const WORD *)&bin64, sizeof(bin64));
461 bin64.nt_headers.OptionalHeader.CheckSum = checksum;
462
463 WriteFile(file, &bin64, sizeof(bin64), &count, NULL);
465
466 bin64.nt_headers.OptionalHeader.CheckSum = 0;
467 bin64.nt_headers.OptionalHeader.SizeOfInitializedData = 0;
468 bin64.nt_headers.OptionalHeader.SizeOfImage = 0;
469
471 ok(ret, "ImageGetDigestStream failed: %lu\n", GetLastError());
472 check_updates("flags = 0", &a3, &accum);
473 free_updates(&accum);
476 ok(ret, "ImageGetDigestStream failed: %lu\n", GetLastError());
477 check_updates("flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO", &a4, &accum);
478 free_updates(&accum);
481}
#define skip(...)
Definition: atltest.h:64
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
BOOL WINAPI ImageGetDigestStream(HANDLE FileHandle, DWORD DigestLevel, DIGEST_FUNCTION DigestFunction, DIGEST_HANDLE DigestHandle)
Definition: integrity.c:782
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO
Definition: imagehlp.h:45
static void check_updates(LPCSTR header, const struct expected_update_accum *expected, const struct update_accum *got)
Definition: image.c:280
static BOOL WINAPI accumulating_stream_output(DIGEST_HANDLE handle, BYTE *pb, DWORD cb)
Definition: image.c:253
static const struct expected_update_accum a4
Definition: image.c:359
static struct image64 bin64
static const struct expected_update_accum a1
Definition: image.c:324
static struct image bin
static HANDLE create_temp_file(char *temp_file)
Definition: image.c:364
static const struct expected_update_accum a2
Definition: image.c:334
static void free_updates(struct update_accum *accum)
Definition: image.c:299
static DWORD compute_checksum(const WORD *image, DWORD image_size)
Definition: image.c:378
static const struct expected_update_accum a3
Definition: image.c:349

Referenced by START_TEST().

◆ test_image_load()

static void test_image_load ( void  )
static

Definition at line 557 of file image.c.

558{
559 char temp_file[MAX_PATH];
561 DWORD ret, count;
562 HANDLE file;
563
566 {
567 skip("couldn't create temp file\n");
568 return;
569 }
570
571 WriteFile(file, &bin, sizeof(bin), &count, NULL);
573
575 ok(img != NULL, "ImageLoad unexpectedly failed\n");
576
577 if (img)
578 {
579 ok(!strcmp(img->ModuleName, temp_file),
580 "unexpected ModuleName, got %s instead of %s\n", img->ModuleName, temp_file);
581 ok(img->MappedAddress != NULL, "MappedAddress != NULL\n");
582 if (img->MappedAddress)
583 {
584 ok(!memcmp(img->MappedAddress, &bin.dos_header, sizeof(bin.dos_header)),
585 "MappedAddress doesn't point to IMAGE_DOS_HEADER\n");
586 }
587 ok(img->FileHeader != NULL, "FileHeader != NULL\n");
588 if (img->FileHeader)
589 {
590 ok(!memcmp(img->FileHeader, &bin.nt_headers, sizeof(bin.nt_headers)),
591 "FileHeader doesn't point to IMAGE_NT_HEADERS32\n");
592 }
593 ok(img->NumberOfSections == 3,
594 "unexpected NumberOfSections, got %ld instead of 3\n", img->NumberOfSections);
595 if (img->NumberOfSections >= 3)
596 {
597 ok(!strcmp((const char *)img->Sections[0].Name, ".text"),
598 "unexpected name for section 0, expected .text, got %s\n",
599 (const char *)img->Sections[0].Name);
600 ok(!strcmp((const char *)img->Sections[1].Name, ".bss"),
601 "unexpected name for section 1, expected .bss, got %s\n",
602 (const char *)img->Sections[1].Name);
603 ok(!strcmp((const char *)img->Sections[2].Name, ".idata"),
604 "unexpected name for section 2, expected .idata, got %s\n",
605 (const char *)img->Sections[2].Name);
606 }
607 ok(img->Characteristics == 0x102,
608 "unexpected Characteristics, got 0x%lx instead of 0x102\n", img->Characteristics);
609 ok(img->fSystemImage == 0,
610 "unexpected fSystemImage, got %d instead of 0\n", img->fSystemImage);
611 ok(img->fDOSImage == 0,
612 "unexpected fDOSImage, got %d instead of 0\n", img->fDOSImage);
613 todo_wine ok(img->fReadOnly == 1 || broken(!img->fReadOnly) /* <= WinXP */,
614 "unexpected fReadOnly, got %d instead of 1\n", img->fReadOnly);
615 todo_wine ok(img->Version == 1 || broken(!img->Version) /* <= WinXP */,
616 "unexpected Version, got %d instead of 1\n", img->Version);
617 ok(img->SizeOfImage == 0x600,
618 "unexpected SizeOfImage, got 0x%lx instead of 0x600\n", img->SizeOfImage);
619
620 count = 0xdeadbeef;
623 ok(ret == 448, "GetImageUnusedHeaderBytes returned %lu instead of 448\n", ret);
625 ok(count == 64, "unexpected size for unused header bytes, got %lu instead of 64\n", count);
626
628 }
629
631}
#define broken(x)
Definition: atltest.h:178
PLOADED_IMAGE WINAPI ImageLoad(PCSTR dll_name, PCSTR dll_path)
Definition: access.c:71
BOOL WINAPI ImageUnload(PLOADED_IMAGE loaded_image)
Definition: access.c:97
DWORD WINAPI GetImageUnusedHeaderBytes(PLOADED_IMAGE LoadedImage, LPDWORD SizeUnusedHeaderBytes)
Definition: access.c:57
GLint GLvoid * img
Definition: gl.h:1956

Referenced by START_TEST().

Variable Documentation

◆ a1

Definition at line 324 of file image.c.

◆ a2

Definition at line 334 of file image.c.

◆ a3

Definition at line 349 of file image.c.

◆ a4

Definition at line 359 of file image.c.

◆ b1

const struct expected_blob b1[]
static
Initial value:
= {
{sizeof(bin.nt_headers), &bin.nt_headers},
{sizeof(bin.sections), &bin.sections},
{FILE_IDATA-FILE_TEXT, &bin.text_section},
{sizeof(bin.idata_section.descriptors[0].OriginalFirstThunk),
&bin.idata_section.descriptors[0].OriginalFirstThunk},
{FIELD_OFFSET(struct imports, thunks)-
&bin.idata_section.descriptors[0].Name},
&bin.idata_section.ibn}
}
LPWSTR Name
Definition: desk.c:124
#define FILE_IDATA
Definition: image.c:63
#define FILE_TOTAL
Definition: image.c:65
#define FILE_TEXT
Definition: image.c:60
#define FILE_PE_START
Definition: image.c:58
Definition: image.c:70
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Definition at line 310 of file image.c.

◆ b2

const struct expected_blob b2[]
static
Initial value:
= {
{sizeof(bin.nt_headers), &bin.nt_headers},
{sizeof(bin.sections), &bin.sections},
{FILE_IDATA-FILE_TEXT, &bin.text_section},
{FILE_TOTAL-FILE_IDATA, &bin.idata_section}
}

Definition at line 326 of file image.c.

◆ b3

const struct expected_blob b3[]
static
Initial value:
= {
{sizeof(bin64.nt_headers), &bin64.nt_headers},
{sizeof(bin64.sections), &bin64.sections},
{FILE_IDATA - FILE_TEXT, &bin64.text_section},
{sizeof(bin64.idata_section.descriptors[0].OriginalFirstThunk),
&bin64.idata_section.descriptors[0].OriginalFirstThunk},
{FIELD_OFFSET(struct imports64, thunks) -
&bin64.idata_section.descriptors[0].Name},
{FILE_TOTAL - FILE_IDATA - FIELD_OFFSET(struct imports64, ibn), &bin64.idata_section.ibn}
}

Definition at line 336 of file image.c.

◆ b4

const struct expected_blob b4[]
static
Initial value:
= {
{sizeof(bin64.nt_headers), &bin64.nt_headers},
{sizeof(bin64.sections), &bin64.sections},
{FILE_IDATA - FILE_TEXT, &bin64.text_section},
{FILE_TOTAL - FILE_IDATA, &bin64.idata_section}
}

Definition at line 351 of file image.c.

◆ bin

◆ bin64

struct image64 bin64
static

◆ got_GetOpenFileNameA

unsigned int got_GetOpenFileNameA
static

Definition at line 483 of file image.c.

Referenced by bind_image_cb(), and test_bind_image_ex().

◆ got_SHRegGetIntW

unsigned int got_SHRegGetIntW
static

Definition at line 483 of file image.c.

Referenced by bind_image_cb(), and test_bind_image_ex().

◆ got_SysAllocString

unsigned int got_SysAllocString
static

Definition at line 483 of file image.c.

Referenced by bind_image_cb(), and test_bind_image_ex().