ReactOS 0.4.16-dev-91-g764881a
image.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winver.h>
#include <winnt.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  Imports::__IMPORT_BY_NAME
 
struct  _PeImage
 
struct  blob
 
struct  expected_blob
 
struct  update_accum
 
struct  expected_update_accum
 

Macros

#define NONAMELESSUNION
 
#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 BOOL (WINAPI *pImageGetDigestStream)(HANDLE
 
static DWORD (WINAPI *pGetImageUnusedHeaderBytes)(PLOADED_IMAGE
 
static PLOADED_IMAGE (WINAPI *pImageLoad)(PCSTR
 
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 void update_checksum (void)
 
static BOOL CALLBACK testing_status_routine (IMAGEHLP_STATUS_REASON reason, const char *ImageName, const char *DllName, ULONG_PTR Va, ULONG_PTR Parameter)
 
static void test_get_digest_stream (void)
 
static void test_bind_image_ex (void)
 
static void test_image_load (void)
 
 START_TEST (image)
 

Variables

static HMODULE hImageHlp
 
static DWORD
 
static DIGEST_FUNCTION
 
static DIGEST_HANDLE
 
static const charImageName
 
static const char const charDllPath
 
static const char const char const charSymbolPath
 
static const char const char const char PIMAGEHLP_STATUS_ROUTINE StatusRoutine
 
static LPDWORD
 
static PCSTR
 
static struct _PeImage bin
 
static int status_routine_called [BindSymbolsNotUpdated+1]
 
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 }
 

Macro Definition Documentation

◆ EXIT_PROCESS

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

Definition at line 63 of file image.c.

◆ FILE_IDATA

#define FILE_IDATA   0x400

Definition at line 48 of file image.c.

◆ FILE_PE_START

#define FILE_PE_START   0x50

Definition at line 43 of file image.c.

◆ FILE_TEXT

#define FILE_TEXT   0x200

Definition at line 45 of file image.c.

◆ FILE_TOTAL

#define FILE_TOTAL   0x600

Definition at line 50 of file image.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 22 of file image.c.

◆ NUM_SECTIONS

#define NUM_SECTIONS   3

Definition at line 44 of file image.c.

◆ RVA_BSS

#define RVA_BSS   0x2000

Definition at line 47 of file image.c.

◆ RVA_IDATA

#define RVA_IDATA   0x3000

Definition at line 49 of file image.c.

◆ RVA_TEXT

#define RVA_TEXT   0x1000

Definition at line 46 of file image.c.

◆ RVA_TOTAL

#define RVA_TOTAL   0x4000

Definition at line 51 of file image.c.

◆ VA_START

#define VA_START   0x400000

Definition at line 42 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 161 of file image.c.

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
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}
#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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
Definition: image.c:134
DWORD cb
Definition: image.c:135
BYTE * pb
Definition: image.c:136
DWORD cUpdates
Definition: msg.c:538
CRYPT_DATA_BLOB * updates
Definition: msg.c:539
int ret

◆ BOOL()

static BOOL ( WINAPI pImageGetDigestStream)
static

◆ check_updates()

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

Definition at line 188 of file image.c.

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}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
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 d
Definition: ke_i.h:81
#define for
Definition: utility.h:88
BOOL expected
Definition: store.c:2063
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define min(a, b)
Definition: monoChain.cc:55

◆ create_temp_file()

static HANDLE create_temp_file ( char temp_file)
static

Definition at line 247 of file image.c.

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))
257 }
258 return file;
259}
#define NULL
Definition: types.h:112
#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 MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
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:127
Definition: fci.c:110

◆ DWORD()

static DWORD ( WINAPI pGetImageUnusedHeaderBytes)
static

◆ free_updates()

static void free_updates ( struct update_accum accum)
static

Definition at line 207 of file image.c.

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}
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ PLOADED_IMAGE()

static PLOADED_IMAGE ( WINAPI pImageLoad)
static

◆ START_TEST()

START_TEST ( image  )

Definition at line 514 of file image.c.

515{
516 hImageHlp = LoadLibraryA("imagehlp.dll");
517
518 if (!hImageHlp)
519 {
520 win_skip("ImageHlp unavailable\n");
521 return;
522 }
523
524 pImageGetDigestStream = (void *) GetProcAddress(hImageHlp, "ImageGetDigestStream");
525 pBindImageEx = (void *) GetProcAddress(hImageHlp, "BindImageEx");
526 pGetImageUnusedHeaderBytes = (void *) GetProcAddress(hImageHlp, "GetImageUnusedHeaderBytes");
527 pImageLoad = (void *) GetProcAddress(hImageHlp, "ImageLoad");
528 pImageUnload = (void *) GetProcAddress(hImageHlp, "ImageUnload");
529
533
535}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void test_bind_image_ex(void)
Definition: image.c:378
static void test_image_load(void)
Definition: image.c:432
static HMODULE hImageHlp
Definition: image.c:31
static void test_get_digest_stream(void)
Definition: image.c:317
#define win_skip
Definition: test.h:163

◆ test_bind_image_ex()

static void test_bind_image_ex ( void  )
static

Definition at line 378 of file image.c.

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,
397 "expected ERROR_FILE_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n",
398 GetLastError());
399
402 {
403 skip("couldn't create temp file\n");
404 return;
405 }
406
407 WriteFile(file, &bin, sizeof(bin), &count, NULL);
409
410 /* call with a proper PE file, but with StatusRoutine set to NULL */
412 NULL);
413 ok(ret, "BindImageEx failed: %d\n", GetLastError());
414
415 /* call with a proper PE file and StatusRoutine */
418 ok(ret, "BindImageEx failed: %d\n", GetLastError());
419
421 "StatusRoutine was called %d times\n", status_routine_called[BindImportModule]);
422
424#if defined(_WIN64)
426#endif
427 , "StatusRoutine was called %d times\n", status_routine_called[BindImportProcedure]);
428
430}
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define CloseHandle
Definition: compat.h:739
#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 WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define BIND_NO_UPDATE
Definition: imagehlp.h:35
#define BIND_NO_BOUND_IMPORTS
Definition: imagehlp.h:34
@ BindImportModule
Definition: imagehlp.h:105
@ BindImportProcedure
Definition: imagehlp.h:106
#define BIND_ALL_IMAGES
Definition: imagehlp.h:36
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
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
static int status_routine_called[BindSymbolsNotUpdated+1]
Definition: image.c:158
static HANDLE create_temp_file(char *temp_file)
Definition: image.c:247
static struct _PeImage bin
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ test_get_digest_stream()

static void test_get_digest_stream ( void  )
static

Definition at line 317 of file image.c.

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());
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 */
357 WriteFile(file, &bin, sizeof(bin), &count, NULL);
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);
376}
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO
Definition: imagehlp.h:45
static void update_checksum(void)
Definition: image.c:261
static void check_updates(LPCSTR header, const struct expected_update_accum *expected, const struct update_accum *got)
Definition: image.c:188
static BOOL WINAPI accumulating_stream_output(DIGEST_HANDLE handle, BYTE *pb, DWORD cb)
Definition: image.c:161
static const struct expected_update_accum a1
Definition: image.c:232
static const struct expected_update_accum a2
Definition: image.c:242
static void free_updates(struct update_accum *accum)
Definition: image.c:207

Referenced by START_TEST().

◆ test_image_load()

static void test_image_load ( void  )
static

Definition at line 432 of file image.c.

433{
434 char temp_file[MAX_PATH];
436 DWORD ret, count;
437 HANDLE file;
438
439 if (!pImageLoad || !pImageUnload || !pGetImageUnusedHeaderBytes)
440 {
441 win_skip("ImageLoad functions are not available\n");
442 return;
443 }
444
447 {
448 skip("couldn't create temp file\n");
449 return;
450 }
451
452 WriteFile(file, &bin, sizeof(bin), &count, NULL);
454
455 img = pImageLoad(temp_file, NULL);
456 ok(img != NULL, "ImageLoad unexpectedly failed\n");
457
458 if (img)
459 {
460 ok(!strcmp(img->ModuleName, temp_file),
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)
464 {
465 ok(!memcmp(img->MappedAddress, &bin.dos_header, sizeof(bin.dos_header)),
466 "MappedAddress doesn't point to IMAGE_DOS_HEADER\n");
467 }
468 ok(img->FileHeader != NULL, "FileHeader != NULL\n");
469 if (img->FileHeader)
470 {
471 ok(!memcmp(img->FileHeader, &bin.nt_headers, sizeof(bin.nt_headers)),
472 "FileHeader doesn't point to IMAGE_NT_HEADERS32\n");
473 }
474 ok(img->NumberOfSections == 3,
475 "unexpected NumberOfSections, got %d instead of 3\n", img->NumberOfSections);
476 if (img->NumberOfSections >= 3)
477 {
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);
487 }
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);
494 todo_wine ok(img->fReadOnly == 1 || broken(!img->fReadOnly) /* <= WinXP */,
495 "unexpected fReadOnly, got %d instead of 1\n", img->fReadOnly);
496 todo_wine ok(img->Version == 1 || broken(!img->Version) /* <= WinXP */,
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);
500
501 count = 0xdeadbeef;
502 ret = pGetImageUnusedHeaderBytes(img, &count);
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);
507
508 pImageUnload(img);
509 }
510
512}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLint GLvoid * img
Definition: gl.h:1956
#define todo_wine
Definition: custom.c:89

Referenced by START_TEST().

◆ testing_status_routine()

static BOOL CALLBACK testing_status_routine ( IMAGEHLP_STATUS_REASON  reason,
const char ImageName,
const char DllName,
ULONG_PTR  Va,
ULONG_PTR  Parameter 
)
static

Definition at line 283 of file image.c.

285{
286 char kernel32_path[MAX_PATH];
287
288 if (0 <= (int)reason && reason <= BindSymbolsNotUpdated)
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
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}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
@ BindSymbolsNotUpdated
Definition: imagehlp.h:113
@ BindForwarderNOT
Definition: imagehlp.h:108
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by test_bind_image_ex().

◆ update_checksum()

static void update_checksum ( void  )
static

Definition at line 261 of file image.c.

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}
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
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
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by test_get_digest_stream().

Variable Documentation

◆ a1

Definition at line 232 of file image.c.

◆ a2

Definition at line 242 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].u.OriginalFirstThunk),
&bin.idata_section.descriptors[0].u.OriginalFirstThunk},
{FIELD_OFFSET(struct Imports, thunks)-
&bin.idata_section.descriptors[0].Name},
&bin.idata_section.ibn}
}
#define FILE_IDATA
Definition: image.c:48
#define FILE_TOTAL
Definition: image.c:50
#define FILE_TEXT
Definition: image.c:45
#define FILE_PE_START
Definition: image.c:43
Definition: image.c:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Definition at line 218 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 234 of file image.c.

◆ bin

◆ DIGEST_FUNCTION

DIGEST_FUNCTION

Definition at line 33 of file image.c.

◆ DIGEST_HANDLE

Definition at line 33 of file image.c.

◆ DllPath

◆ DWORD

Definition at line 33 of file image.c.

◆ hImageHlp

HMODULE hImageHlp
static

Definition at line 31 of file image.c.

Referenced by START_TEST().

◆ ImageName

◆ LPDWORD

Definition at line 36 of file image.c.

◆ PCSTR

Definition at line 37 of file image.c.

◆ status_routine_called

int status_routine_called[BindSymbolsNotUpdated+1]
static

Definition at line 158 of file image.c.

Referenced by test_bind_image_ex(), and testing_status_routine().

◆ StatusRoutine

Definition at line 35 of file image.c.

Referenced by BindImageEx(), and UpdateRegistry().

◆ SymbolPath