ReactOS  0.4.13-dev-52-g0efcfec
mspatcha.c File Reference
#include <windows.h>
#include "wine/test.h"
#include <patchapi.h>
Include dependency graph for mspatcha.c:

Go to the source code of this file.

Classes

struct  _bin_file
 
struct  _patch_data
 

Macros

#define WIN32_NO_STATUS
 
#define MAKE_BIN(data_)   { data_, sizeof(data_) }
 
#define compare_file(filename, data, len, test_name)   compare_file_(filename, data, len, test_name, __LINE__)
 

Typedefs

typedef struct _bin_file bin_file
 
typedef struct _patch_data patch_data
 

Functions

BOOL extract2 (char *filename, const unsigned char *data, size_t len)
 
BOOL extract (char *filename, const bin_file *bin)
 
HANDLE open_file (char *filename, BOOL bWrite)
 
void compare_file_ (char *filename, const unsigned char *data, size_t len, const char *test_name, int line)
 
static void validate_signature (const char *casename, const char *fieldname, const bin_file *bin, const char *expected)
 
unsigned int crc32 (unsigned int seed, unsigned char *msg, unsigned int msglen)
 
static void validate_patch (patch_data *current)
 
static void apply_patch (patch_data *current)
 
void test_one (patch_data *current)
 
 START_TEST (mspatcha)
 

Variables

unsigned char in1_bin [8]
 
unsigned char out1_bin [26]
 
unsigned char patch1_bin [75]
 
unsigned char patch1_header_bin [31]
 
unsigned char in2_bin [25]
 
unsigned char out2_bin [25]
 
unsigned char patch2_bin [75]
 
unsigned char patch2_header_bin [31]
 
unsigned char in3_bin [138]
 
unsigned char out3_bin [152]
 
unsigned char patch3_bin [88]
 
unsigned char patch3_header_bin [32]
 
char temp_path [MAX_PATH]
 
static const unsigned int crc_32_tab []
 
static patch_data data []
 

Macro Definition Documentation

◆ compare_file

#define compare_file (   filename,
  data,
  len,
  test_name 
)    compare_file_(filename, data, len, test_name, __LINE__)

Definition at line 209 of file mspatcha.c.

◆ MAKE_BIN

#define MAKE_BIN (   data_)    { data_, sizeof(data_) }

Definition at line 121 of file mspatcha.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 8 of file mspatcha.c.

Typedef Documentation

◆ bin_file

◆ patch_data

Function Documentation

◆ apply_patch()

static void apply_patch ( patch_data current)
static

Definition at line 343 of file mspatcha.c.

344 {
345  char patchname[MAX_PATH], targetname[MAX_PATH], outputname[MAX_PATH];
346  BOOL bResult;
347  DWORD dwErr;
348  HANDLE hPatch, hTarget, hFind;
349  WIN32_FIND_DATAA wfd = { sizeof(wfd) };
350 
351  if (!GetTempFileNameA(temp_path, "MPO", 0, outputname))
352  {
353  ok(0, "GetTempFileNameA failed %lu, %s\n", GetLastError(), current->name);
354  return;
355  }
356  DeleteFileA(outputname);
357 
358  if (!extract(patchname, &current->patch))
359  return;
360  if (!extract(targetname, &current->input))
361  {
362  DeleteFileA(patchname);
363  return;
364  }
365  // There is a bug in 2k3, where calling 'TestApplyPatchToFileA' gives an AV...
366 #if 0
367  bResult = TestApplyPatchToFileA(patchname, targetname, 0);
368 #else
369  hPatch = open_file(patchname, FALSE);
370  hTarget = open_file(targetname, FALSE);
371  bResult = TestApplyPatchToFileByHandles(hPatch, hTarget, 0);
372  CloseHandle(hPatch);
373  CloseHandle(hTarget);
374 #endif
375  ok(bResult, "TestApplyPatchToFileA failed %lu, %s\n", GetLastError(), current->name);
376  // Files are not touched
377  compare_file(patchname, current->patch.data, current->patch.len, current->name);
378  compare_file(targetname, current->input.data, current->input.len, current->name);
379  DeleteFileA(patchname);
380  DeleteFileA(targetname);
381 
382 
383  if (!extract2(patchname, current->patch.data, current->patch.len -1))
384  return;
385  if (!extract(targetname, &current->input))
386  {
387  DeleteFileA(patchname);
388  return;
389  }
390  hPatch = open_file(patchname, FALSE);
391  hTarget = open_file(targetname, FALSE);
392  bResult = TestApplyPatchToFileByHandles(hPatch, hTarget, 0);
393  dwErr = GetLastError();
394  CloseHandle(hPatch);
395  CloseHandle(hTarget);
396  ok(!bResult, "TestApplyPatchToFileA succeeded, %s\n", current->name);
397  ok(dwErr == ERROR_PATCH_CORRUPT, "TestApplyPatchToFileA GetLastError %lx, %s\n", dwErr, current->name);
398  // Files are not touched
399  compare_file(patchname, current->patch.data, current->patch.len - 1, current->name);
400  compare_file(targetname, current->input.data, current->input.len, current->name);
401  DeleteFileA(patchname);
402  DeleteFileA(targetname);
403 
404  if (!extract(patchname, &current->patch))
405  return;
406  if (!extract2(targetname, current->input.data, current->input.len -1))
407  {
408  DeleteFileA(patchname);
409  return;
410  }
411  hPatch = open_file(patchname, FALSE);
412  hTarget = open_file(targetname, FALSE);
413  bResult = TestApplyPatchToFileByHandles(hPatch, hTarget, 0);
414  dwErr = GetLastError();
415  CloseHandle(hPatch);
416  CloseHandle(hTarget);
417  ok(!bResult, "TestApplyPatchToFileA succeeded, %s\n", current->name);
418  ok(dwErr == ERROR_PATCH_WRONG_FILE, "TestApplyPatchToFileA GetLastError %lx, %s\n", dwErr, current->name);
419  // Files are not touched
420  compare_file(patchname, current->patch.data, current->patch.len, current->name);
421  compare_file(targetname, current->input.data, current->input.len -1, current->name);
422  DeleteFileA(patchname);
423  DeleteFileA(targetname);
424 
425  if (!extract(patchname, &current->patch))
426  return;
427  if (!extract(targetname, &current->input))
428  {
429  DeleteFileA(patchname);
430  return;
431  }
432  bResult = ApplyPatchToFileA(patchname, targetname, outputname, APPLY_OPTION_TEST_ONLY);
433 
434  ok(bResult, "ApplyPatchToFileA failed %lu, %s\n", GetLastError(), current->name);
435  // Files are not touched
436  compare_file(patchname, current->patch.data, current->patch.len, current->name);
437  compare_file(targetname, current->input.data, current->input.len, current->name);
438  // W2k3 creates an empty file, W10 does not create a file
439  hFind = FindFirstFileA(outputname, &wfd);
440  ok(hFind == INVALID_HANDLE_VALUE || wfd.nFileSizeLow == 0, "Got a (non-empty) file, %s\n", current->name);
441  if (hFind != INVALID_HANDLE_VALUE)
442  FindClose(hFind);
443  DeleteFileA(patchname);
444  DeleteFileA(targetname);
445  DeleteFileA(outputname);
446 
447  if (!extract(patchname, &current->patch))
448  return;
449  if (!extract(targetname, &current->input))
450  {
451  DeleteFileA(patchname);
452  return;
453  }
454  bResult = ApplyPatchToFileA(patchname, targetname, outputname, 0);
455  ok(bResult, "ApplyPatchToFileA failed %lu, %s\n", GetLastError(), current->name);
456  // Files are not touched
457  compare_file(patchname, current->patch.data, current->patch.len, current->name);
458  compare_file(targetname, current->input.data, current->input.len, current->name);
459  // One output file
460  compare_file(outputname, current->output.data, current->output.len, current->name);
461  DeleteFileA(patchname);
462  DeleteFileA(targetname);
463  DeleteFileA(outputname);
464 }
#define CloseHandle
Definition: compat.h:398
BOOL extract2(char *filename, const unsigned char *data, size_t len)
Definition: mspatcha.c:125
#define APPLY_OPTION_TEST_ONLY
Definition: patchapi.h:28
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL extract(char *filename, const bin_file *bin)
Definition: mspatcha.c:158
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI TestApplyPatchToFileByHandles(HANDLE patch_file, HANDLE old_file, ULONG apply_flags)
#define ok(value,...)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define compare_file(filename, data, len, test_name)
Definition: mspatcha.c:209
DWORD dwErr
Definition: service.c:36
BOOL WINAPI ApplyPatchToFileA(LPCSTR patch_file, LPCSTR old_file, LPCSTR new_file, ULONG apply_flags)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI TestApplyPatchToFileA(LPCSTR patch_file, LPCSTR old_file, ULONG apply_flags)
#define ERROR_PATCH_CORRUPT
Definition: patchapi.h:36
#define ERROR_PATCH_WRONG_FILE
Definition: patchapi.h:38
HANDLE WINAPI FindFirstFileA(IN LPCSTR lpFileName, OUT LPWIN32_FIND_DATAA lpFindFileData)
Definition: find.c:263
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
HANDLE open_file(char *filename, BOOL bWrite)
Definition: mspatcha.c:163
struct task_struct * current
Definition: linux.c:32
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by test_one().

◆ compare_file_()

void compare_file_ ( char filename,
const unsigned char data,
size_t  len,
const char test_name,
int  line 
)

Definition at line 171 of file mspatcha.c.

172 {
173  char* buf;
174  size_t size;
177 
179  {
180  ok_(__FILE__, line)(0, "Unable to open file %s(%lu), %s\n", filename, GetLastError(), test_name);
181  return;
182  }
184  ok(size == len, "Filesize is %u instead of %u, %s\n", size, len, test_name);
185 
186  buf = malloc(size);
187  if (buf)
188  {
189  DWORD dwRead;
190  if (ReadFile(hFile, buf, size, &dwRead, NULL) && dwRead == size)
191  {
192  ok(!memcmp(buf, data, min(size,len)), "Data mismatch, %s\n", test_name);
193  }
194  else
195  {
196  ok_(__FILE__, line)(0, "Unable to read %s(%lu), %s\n", filename, GetLastError(), test_name);
197  }
198 
199  free(buf);
200  }
201  else
202  {
203  ok_(__FILE__, line)(0, "Unable to allocate %u, %s\n", size, test_name);
204  }
205 
207 }
#define CloseHandle
Definition: compat.h:398
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok_(x1, x2)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define free
Definition: debug_ros.c:5
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:125
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define OPEN_EXISTING
Definition: compat.h:426
GLsizeiptr size
Definition: glext.h:5919
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
static const char * test_name
Definition: run.c:166
#define min(a, b)
Definition: monoChain.cc:55
#define malloc
Definition: debug_ros.c:4
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

◆ crc32()

unsigned int crc32 ( unsigned int  seed,
unsigned char msg,
unsigned int  msglen 
)

Definition at line 319 of file mspatcha.c.

320 {
321  unsigned int rem = seed;
322  unsigned int i;
323 
324  for (i = 0; i < msglen; i++)
325  {
326  rem = crc_32_tab[(rem ^ msg[i]) & 0xff] ^ (rem >> 8);
327  }
328 
329  return rem;
330 }
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
static const unsigned int crc_32_tab[]
Definition: mspatcha.c:272
#define msg(x)
Definition: auth_time.c:54

Referenced by validate_patch().

◆ extract()

BOOL extract ( char filename,
const bin_file bin 
)

Definition at line 158 of file mspatcha.c.

159 {
160  return extract2(filename, bin->data, bin->len);
161 }
BOOL extract2(char *filename, const unsigned char *data, size_t len)
Definition: mspatcha.c:125
const char * filename
Definition: ioapi.h:135
static struct _PeImage bin

Referenced by apply_patch(), halveImage3D(), test_FDIIsCabinet(), and validate_signature().

◆ extract2()

BOOL extract2 ( char filename,
const unsigned char data,
size_t  len 
)

Definition at line 125 of file mspatcha.c.

126 {
127  HANDLE hFile;
128  BOOL bRet;
129  DWORD dwWritten;
130 
131  if (!GetTempFileNameA(temp_path, "mpa", 0, filename))
132  {
133  ok(0, "GetTempFileNameA failed %lu\n", GetLastError());
134  return FALSE;
135  }
136 
139  {
140  ok(0, "CreateFileA failed %lu\n", GetLastError());
142  return FALSE;
143  }
144 
145  bRet = WriteFile(hFile, data, len, &dwWritten, NULL);
147  bRet = bRet && (dwWritten == len);
148 
149  if (!bRet)
150  {
151  ok(0, "WriteFile failed %lu\n", GetLastError());
153  }
154 
155  return bRet;
156 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
GLenum GLsizei len
Definition: glext.h:6722
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
char temp_path[MAX_PATH]
Definition: mspatcha.c:123

Referenced by apply_patch(), and extract().

◆ open_file()

HANDLE open_file ( char filename,
BOOL  bWrite 
)

Definition at line 163 of file mspatcha.c.

164 {
165  DWORD dwAccess = GENERIC_READ | (bWrite ? GENERIC_WRITE : 0);
168  dwAttr, NULL);
169 }
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399

Referenced by apply_patch(), and scan_specified_files().

◆ START_TEST()

START_TEST ( mspatcha  )

Definition at line 509 of file mspatcha.c.

510 {
511  size_t n;
512 
514 
515  for (n = 0; n < _countof(data); ++n)
516  {
517  test_one(data + n);
518  }
519 }
void test_one(patch_data *current)
Definition: mspatcha.c:467
#define _countof(array)
Definition: fontsub.cpp:30
GLdouble n
Definition: glext.h:7729
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
char temp_path[MAX_PATH]
Definition: mspatcha.c:123

◆ test_one()

void test_one ( patch_data current)

Definition at line 467 of file mspatcha.c.

468 {
469  validate_signature(current->name, "input", &current->input, current->input_signature);
470  validate_signature(current->name, "output", &current->output, current->output_signature);
473 }
static void validate_signature(const char *casename, const char *fieldname, const bin_file *bin, const char *expected)
Definition: mspatcha.c:211
static void apply_patch(patch_data *current)
Definition: mspatcha.c:343
static void validate_patch(patch_data *current)
Definition: mspatcha.c:332
struct task_struct * current
Definition: linux.c:32

Referenced by START_TEST().

◆ validate_patch()

static void validate_patch ( patch_data current)
static

Definition at line 332 of file mspatcha.c.

333 {
334  UINT crc;
335 
336  crc = crc32(~0, current->patch.data, current->patch.len);
337  ok(crc == 0, "Invalid patch crc 0x%x for %s\n", crc, current->name);
338 
339  crc = crc32(~0, current->patch_header.data, current->patch_header.len);
340  ok(crc == 0, "Invalid patch_header crc 0x%x for %s\n", crc, current->name);
341 }
#define ok(value,...)
unsigned int crc32(unsigned int seed, unsigned char *msg, unsigned int msglen)
Definition: mspatcha.c:319
unsigned int UINT
Definition: ndis.h:50
struct task_struct * current
Definition: linux.c:32

Referenced by test_one().

◆ validate_signature()

static void validate_signature ( const char casename,
const char fieldname,
const bin_file bin,
const char expected 
)
static

Definition at line 211 of file mspatcha.c.

212 {
213  char filename[MAX_PATH];
215  HANDLE hFile;
216  unsigned char data[0x100];
217  char signature[0x20] = {0};
218  WCHAR signatureW[0x20] = {0};
219  BOOL bResult;
220 
221  memset(signature, 0xaa, sizeof(signature));
222  memcpy(data, bin->data, bin->len);
223 
224  if (!extract(filename, bin))
225  return;
226 
227  memset(signature, 0xaa, sizeof(signature)-1);
228  bResult = GetFilePatchSignatureA(filename, 0, NULL, 0, NULL, 0, NULL, sizeof(signature), signature);
229  ok(bResult, "GetFilePatchSignatureA failed %lu, %s.%s\n", GetLastError(), casename, fieldname);
230  if (bResult)
231  {
232  // Signature is crc32 of data
233  ok(!_stricmp(expected, signature), "Got %s for %s.%s\n", signature, casename, fieldname);
234  }
235 
236  memset(signature, 0xaa, sizeof(signature)-1);
237  memset(signatureW, 0xaa, sizeof(signatureW)-sizeof(WCHAR));
238  // Widechar version has a widechar signature
240  bResult = GetFilePatchSignatureW(filenameW, 0, NULL, 0, NULL, 0, NULL, sizeof(signatureW), signatureW);
241  ok(bResult, "GetFilePatchSignatureW failed %lu, %s.%s\n", GetLastError(), casename, fieldname);
242  if (bResult)
243  {
244  WideCharToMultiByte(CP_ACP, 0, signatureW, -1, signature, _countof(signature), NULL, NULL);
245  // Signature is crc32 of data
246  ok(!_stricmp(expected, signature), "Got %s for %s.%s\n", signature, casename, fieldname);
247  }
248 
249  memset(signature, 0xaa, sizeof(signature)-1);
250  // 'Handle' version has ansi signature
252  ok(hFile != INVALID_HANDLE_VALUE, "Unable to open file %lu\n", GetLastError());
254  {
255  bResult = GetFilePatchSignatureByHandle(hFile, 0, NULL, 0, NULL, 0, NULL, sizeof(signature), signature);
256  ok(bResult, "GetFilePatchSignatureByHandle failed %lu, %s.%s\n", GetLastError(), casename, fieldname);
257  if (bResult)
258  {
259  // Signature is crc32 of data
260  ok(!_stricmp(expected, signature), "Got %s for %s.%s\n", signature, casename, fieldname);
261  }
262 
264  }
265 
267 }
#define CloseHandle
Definition: compat.h:398
#define WideCharToMultiByte
Definition: compat.h:101
BOOL WINAPI GetFilePatchSignatureW(LPCWSTR filename, ULONG flags, PVOID data, ULONG ignore_range_count, PPATCH_IGNORE_RANGE ignore_range, ULONG retain_range_count, PPATCH_RETAIN_RANGE retain_range, ULONG bufsize, PVOID buffer)
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
BOOL WINAPI GetFilePatchSignatureByHandle(HANDLE hFile, ULONG flags, PVOID data, ULONG ignore_range_count, PPATCH_IGNORE_RANGE ignore_range, ULONG retain_range_count, PPATCH_RETAIN_RANGE retain_range, ULONG bufsize, PVOID buffer)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
const char * filename
Definition: ioapi.h:135
#define _stricmp
Definition: cat.c:22
#define FILE_SHARE_READ
Definition: compat.h:125
BOOL extract(char *filename, const bin_file *bin)
Definition: mspatcha.c:158
static const WCHAR filenameW[]
Definition: amstream.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define OPEN_EXISTING
Definition: compat.h:426
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL WINAPI GetFilePatchSignatureA(LPCSTR filename, ULONG flags, PVOID data, ULONG ignore_range_count, PPATCH_IGNORE_RANGE ignore_range, ULONG retain_range_count, PPATCH_RETAIN_RANGE retain_range, ULONG bufsize, PVOID buffer)
#define MultiByteToWideChar
Definition: compat.h:100
static struct _PeImage bin
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define memset(x, y, z)
Definition: compat.h:39
BOOL expected
Definition: store.c:2063

Referenced by test_one().

Variable Documentation

◆ crc_32_tab

const unsigned int crc_32_tab[]
static

Definition at line 272 of file mspatcha.c.

Referenced by calc_crc32(), and crc32().

◆ data

patch_data data[]
static
Initial value:
=
{
{
"in1_text",
"99e5365e",
"f651d108",
},
{
"in2_binary",
"fc54c21d",
"028aa0fa",
},
{
"in3_compression",
"f10a52d9",
"411dd8f9",
},
}
unsigned char patch3_header_bin[32]
Definition: mspatcha.c:98
unsigned char out1_bin[26]
Definition: mspatcha.c:20
unsigned char out2_bin[25]
Definition: mspatcha.c:44
unsigned char patch1_bin[75]
Definition: mspatcha.c:25
unsigned char patch2_bin[75]
Definition: mspatcha.c:49
unsigned char patch3_bin[88]
Definition: mspatcha.c:89
unsigned char in2_bin[25]
Definition: mspatcha.c:39
unsigned char in1_bin[8]
Definition: mspatcha.c:16
unsigned char out3_bin[152]
Definition: mspatcha.c:76
#define MAKE_BIN(data_)
Definition: mspatcha.c:121
unsigned char patch2_header_bin[31]
Definition: mspatcha.c:57
unsigned char in3_bin[138]
Definition: mspatcha.c:64
unsigned char patch1_header_bin[31]
Definition: mspatcha.c:33

Definition at line 477 of file mspatcha.c.

◆ in1_bin

unsigned char in1_bin[8]
Initial value:
=
{
0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61,
}

Definition at line 16 of file mspatcha.c.

◆ in2_bin

unsigned char in2_bin[25]
Initial value:
=
{
0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xaa,
0x00, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00,
}

Definition at line 39 of file mspatcha.c.

◆ in3_bin

unsigned char in3_bin[138]
Initial value:
=
{
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
}

Definition at line 64 of file mspatcha.c.

◆ out1_bin

unsigned char out1_bin[26]
Initial value:
=
{
0x74, 0x65, 0x73, 0x74, 0x20, 0x44, 0x61, 0x74, 0x61, 0x0d, 0x0a, 0x57, 0x69, 0x74, 0x68, 0x20,
0x73, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x74, 0x72, 0x61,
}

Definition at line 20 of file mspatcha.c.

◆ out2_bin

unsigned char out2_bin[25]
Initial value:
=
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xbb,
0x00, 0xbb, 0x00, 0xbb, 0x00, 0xbb, 0x00, 0xbb, 0x00,
}

Definition at line 44 of file mspatcha.c.

◆ out3_bin

unsigned char out3_bin[152]
Initial value:
=
{
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
}

Definition at line 76 of file mspatcha.c.

◆ patch1_bin

unsigned char patch1_bin[75]
Initial value:
=
{
0x50, 0x41, 0x31, 0x39, 0x01, 0x00, 0xc4, 0x00, 0x4e, 0x28, 0xb3, 0x5b, 0x9a, 0x08, 0xd1, 0x51,
0xf6, 0x01, 0xd2, 0x5e, 0x36, 0xe5, 0x99, 0x00, 0x00, 0x80, 0xac, 0x2a, 0x00, 0x00, 0x30, 0xa0,
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73,
0x74, 0x20, 0x44, 0x61, 0x74, 0x61, 0x0d, 0x0a, 0x57, 0x69, 0x74, 0x68, 0x20, 0x73, 0x6f, 0x6d,
0x65, 0x20, 0x65, 0x78, 0x74, 0x72, 0x61, 0xa7, 0x19, 0x4a, 0x68,
}

Definition at line 25 of file mspatcha.c.

◆ patch1_header_bin

unsigned char patch1_header_bin[31]
Initial value:
=
{
0x50, 0x41, 0x31, 0x39, 0x01, 0x00, 0xc4, 0x00, 0x4e, 0x28, 0xb3, 0x5b, 0x9a, 0x08, 0xd1, 0x51,
0xf6, 0x01, 0xd2, 0x5e, 0x36, 0xe5, 0x99, 0x00, 0x00, 0x80, 0xac, 0xe9, 0xf0, 0x53, 0xf7,
}

Definition at line 33 of file mspatcha.c.

◆ patch2_bin

unsigned char patch2_bin[75]
Initial value:
=
{
0x50, 0x41, 0x31, 0x39, 0x01, 0x00, 0xc4, 0x00, 0x62, 0x35, 0xb3, 0x5b, 0x99, 0xfa, 0xa0, 0x8a,
0x02, 0x01, 0x80, 0x1d, 0xc2, 0x54, 0xfc, 0x00, 0x00, 0x80, 0xac, 0x2a, 0x00, 0x00, 0x30, 0x90,
0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xbb, 0x00, 0xbb, 0x00,
0xbb, 0x00, 0xbb, 0x00, 0xbb, 0x00, 0x00, 0x14, 0x06, 0xeb, 0x61,
}

Definition at line 49 of file mspatcha.c.

◆ patch2_header_bin

unsigned char patch2_header_bin[31]
Initial value:
=
{
0x50, 0x41, 0x31, 0x39, 0x01, 0x00, 0xc4, 0x00, 0x62, 0x35, 0xb3, 0x5b, 0x99, 0xfa, 0xa0, 0x8a,
0x02, 0x01, 0x80, 0x1d, 0xc2, 0x54, 0xfc, 0x00, 0x00, 0x80, 0xac, 0xce, 0x5d, 0x8c, 0xed,
}

Definition at line 57 of file mspatcha.c.

◆ patch3_bin

unsigned char patch3_bin[88]
Initial value:
=
{
0x50, 0x41, 0x31, 0x39, 0x01, 0x00, 0xc4, 0x00, 0xb1, 0x57, 0xb3, 0x5b, 0x18, 0x81, 0xf9, 0xd8,
0x1d, 0x41, 0x01, 0xce, 0xd9, 0x52, 0x0a, 0xf1, 0x00, 0x00, 0x80, 0xb8, 0x36, 0x00, 0x00, 0x10,
0x82, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x0f, 0x22, 0xff, 0xff, 0x35, 0xd8,
0xfb, 0x8f, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x03, 0xb7, 0x08, 0xf7, 0x7d,
0x7e, 0xdf, 0x40, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x0d, 0x20, 0x7d, 0xbe,
0xf9, 0xbe, 0x68, 0xf4, 0x1f, 0x45, 0x3e, 0x35,
}

Definition at line 89 of file mspatcha.c.

◆ patch3_header_bin

unsigned char patch3_header_bin[32]
Initial value:
=
{
0x50, 0x41, 0x31, 0x39, 0x01, 0x00, 0xc4, 0x00, 0xb1, 0x57, 0xb3, 0x5b, 0x18, 0x81, 0xf9, 0xd8,
0x1d, 0x41, 0x01, 0xce, 0xd9, 0x52, 0x0a, 0xf1, 0x00, 0x00, 0x80, 0xb8, 0xbd, 0xeb, 0x70, 0xdd,
}

Definition at line 98 of file mspatcha.c.

◆ temp_path