ReactOS 0.4.15-dev-8227-g32d615f
patchapi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PATCH_IGNORE_RANGE
 
struct  _PATCH_RETAIN_RANGE
 

Macros

#define APPLY_OPTION_FAIL_IF_EXACT   0x00000001
 
#define APPLY_OPTION_FAIL_IF_CLOSE   0x00000002
 
#define APPLY_OPTION_TEST_ONLY   0x00000004
 
#define APPLY_OPTION_VALID_FLAGS   0x00000007
 
#define ERROR_PATCH_DECODE_FAILURE   0xC00E4101
 
#define ERROR_PATCH_CORRUPT   0xC00E4102
 
#define ERROR_PATCH_NEWER_FORMAT   0xC00E4103
 
#define ERROR_PATCH_WRONG_FILE   0xC00E4104
 
#define ERROR_PATCH_NOT_NECESSARY   0xC00E4105
 
#define ERROR_PATCH_NOT_AVAILABLE   0xC00E4106
 
#define TestApplyPatchToFile   WINELIB_NAME_AW(TestApplyPatchToFile)
 
#define ApplyPatchToFile   WINELIB_NAME_AW(ApplyPatchToFile)
 
#define GetFilePatchSignature   WINELIB_NAME_AW(GetFilePatchSignature)
 

Typedefs

typedef struct _PATCH_IGNORE_RANGE PATCH_IGNORE_RANGE
 
typedef struct _PATCH_IGNORE_RANGEPPATCH_IGNORE_RANGE
 
typedef struct _PATCH_RETAIN_RANGE PATCH_RETAIN_RANGE
 
typedef struct _PATCH_RETAIN_RANGEPPATCH_RETAIN_RANGE
 
typedef ULONG CurrentPosition
 
typedef ULONG ULONG MaximumPosition
 
typedef PATCH_PROGRESS_CALLBACK * PPATCH_PROGRESS_CALLBACK
 

Functions

typedef WINBOOL (CALLBACK PATCH_PROGRESS_CALLBACK)(PVOID CallbackContext
 
BOOL WINAPI TestApplyPatchToFileA (LPCSTR PatchFileName, LPCSTR OldFileName, ULONG ApplyOptionFlags)
 
BOOL WINAPI TestApplyPatchToFileW (LPCWSTR PatchFileName, LPCWSTR OldFileName, ULONG ApplyOptionFlags)
 
BOOL WINAPI TestApplyPatchToFileByHandles (HANDLE PatchFileHandle, HANDLE OldFileHandle, ULONG ApplyOptionFlags)
 
BOOL WINAPI ApplyPatchToFileA (LPCSTR PatchFileName, LPCSTR OldFileName, LPCSTR NewFileName, ULONG ApplyOptionFlags)
 
BOOL WINAPI ApplyPatchToFileW (LPCWSTR PatchFileName, LPCWSTR OldFileName, LPCWSTR NewFileName, ULONG ApplyOptionFlags)
 
BOOL WINAPI ApplyPatchToFileByHandles (HANDLE PatchFileHandle, HANDLE OldFileHandle, HANDLE NewFileHandle, ULONG ApplyOptionFlags)
 
BOOL WINAPI GetFilePatchSignatureA (LPCSTR FileName, ULONG OptionFlags, PVOID OptionData, ULONG IgnoreRangeCount, PPATCH_IGNORE_RANGE IgnoreRangeArray, ULONG RetainRangeCount, PPATCH_RETAIN_RANGE RetainRangeArray, ULONG SignatureBufferSize, PVOID SignatureBuffer)
 
BOOL WINAPI GetFilePatchSignatureW (LPCWSTR FileName, ULONG OptionFlags, PVOID OptionData, ULONG IgnoreRangeCount, PPATCH_IGNORE_RANGE IgnoreRangeArray, ULONG RetainRangeCount, PPATCH_RETAIN_RANGE RetainRangeArray, ULONG SignatureBufferSize, PVOID SignatureBuffer)
 
BOOL WINAPI GetFilePatchSignatureByHandle (HANDLE FileHandle, ULONG OptionFlags, PVOID OptionData, ULONG IgnoreRangeCount, PPATCH_IGNORE_RANGE IgnoreRangeArray, ULONG RetainRangeCount, PPATCH_RETAIN_RANGE RetainRangeArray, ULONG SignatureBufferSize, PVOID SignatureBuffer)
 

Macro Definition Documentation

◆ APPLY_OPTION_FAIL_IF_CLOSE

#define APPLY_OPTION_FAIL_IF_CLOSE   0x00000002

Definition at line 27 of file patchapi.h.

◆ APPLY_OPTION_FAIL_IF_EXACT

#define APPLY_OPTION_FAIL_IF_EXACT   0x00000001

Definition at line 26 of file patchapi.h.

◆ APPLY_OPTION_TEST_ONLY

#define APPLY_OPTION_TEST_ONLY   0x00000004

Definition at line 28 of file patchapi.h.

◆ APPLY_OPTION_VALID_FLAGS

#define APPLY_OPTION_VALID_FLAGS   0x00000007

Definition at line 29 of file patchapi.h.

◆ ApplyPatchToFile

#define ApplyPatchToFile   WINELIB_NAME_AW(ApplyPatchToFile)

Definition at line 69 of file patchapi.h.

◆ ERROR_PATCH_CORRUPT

#define ERROR_PATCH_CORRUPT   0xC00E4102

Definition at line 36 of file patchapi.h.

◆ ERROR_PATCH_DECODE_FAILURE

#define ERROR_PATCH_DECODE_FAILURE   0xC00E4101

Definition at line 35 of file patchapi.h.

◆ ERROR_PATCH_NEWER_FORMAT

#define ERROR_PATCH_NEWER_FORMAT   0xC00E4103

Definition at line 37 of file patchapi.h.

◆ ERROR_PATCH_NOT_AVAILABLE

#define ERROR_PATCH_NOT_AVAILABLE   0xC00E4106

Definition at line 40 of file patchapi.h.

◆ ERROR_PATCH_NOT_NECESSARY

#define ERROR_PATCH_NOT_NECESSARY   0xC00E4105

Definition at line 39 of file patchapi.h.

◆ ERROR_PATCH_WRONG_FILE

#define ERROR_PATCH_WRONG_FILE   0xC00E4104

Definition at line 38 of file patchapi.h.

◆ GetFilePatchSignature

#define GetFilePatchSignature   WINELIB_NAME_AW(GetFilePatchSignature)

Definition at line 81 of file patchapi.h.

◆ TestApplyPatchToFile

#define TestApplyPatchToFile   WINELIB_NAME_AW(TestApplyPatchToFile)

Definition at line 63 of file patchapi.h.

Typedef Documentation

◆ CurrentPosition

Definition at line 57 of file patchapi.h.

◆ MaximumPosition

Definition at line 57 of file patchapi.h.

◆ PATCH_IGNORE_RANGE

◆ PATCH_RETAIN_RANGE

◆ PPATCH_IGNORE_RANGE

◆ PPATCH_PROGRESS_CALLBACK

typedef PATCH_PROGRESS_CALLBACK* PPATCH_PROGRESS_CALLBACK

Definition at line 58 of file patchapi.h.

◆ PPATCH_RETAIN_RANGE

Function Documentation

◆ ApplyPatchToFileA()

BOOL WINAPI ApplyPatchToFileA ( LPCSTR  PatchFileName,
LPCSTR  OldFileName,
LPCSTR  NewFileName,
ULONG  ApplyOptionFlags 
)

Definition at line 230 of file mspatcha_main.c.

231{
232 BOOL ret = FALSE;
233 HANDLE hPatch, hOld, hNew;
234
237 if (hPatch != INVALID_HANDLE_VALUE)
238 {
241 if (hOld != INVALID_HANDLE_VALUE)
242 {
245 if (hNew != INVALID_HANDLE_VALUE)
246 {
247 ret = ApplyPatchToFileByHandles(hPatch, hOld, hNew, apply_flags);
248 CloseHandle(hNew);
249 }
250 CloseHandle(hOld);
251 }
252 CloseHandle(hPatch);
253 }
254
255 return ret;
256}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#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
#define FILE_SHARE_READ
Definition: compat.h:136
static UINT patch_file(MSIPACKAGE *package, MSIFILEPATCH *patch)
Definition: files.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
BOOL WINAPI ApplyPatchToFileByHandles(HANDLE patch_file, HANDLE old_file, HANDLE new_file, ULONG apply_flags)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
int ret

Referenced by apply_patch().

◆ ApplyPatchToFileByHandles()

BOOL WINAPI ApplyPatchToFileByHandles ( HANDLE  PatchFileHandle,
HANDLE  OldFileHandle,
HANDLE  NewFileHandle,
ULONG  ApplyOptionFlags 
)

Definition at line 388 of file mspatcha_main.c.

389{
390 SAFE_READ Patch, OldFile;
393
394 Patch.Root = Patch.Ptr = MapFile(patch_file, &Patch.Size);
395 if (!Patch.Root)
396 {
398 return FALSE;
399 }
400
401 /* Let's decode the header */
404 {
407 return FALSE;
408 }
409
410 OldFile.Root = OldFile.Ptr = MapFile(old_file, &OldFile.Size);
411 if (OldFile.Root)
412 {
413 DWORD dwCrc;
414
415 /* Verify the input file */
416 dwCrc = RtlComputeCrc32(0, OldFile.Root, OldFile.Size);
417 if (OldFile.Size == Header.OldSize && dwCrc == Header.OldCrc)
418 {
419 if (apply_flags & APPLY_OPTION_TEST_ONLY)
421 else
423 }
424 else
425 {
427 }
428 UnmapViewOfFile(OldFile.Root);
429 }
430 else
431 {
435 }
436
439 return dwStatus == STATUS_SUCCESS;
440}
Definition: Header.h:9
Definition: patch.h:62
#define RtlComputeCrc32
Definition: compat.h:810
#define UnmapViewOfFile
Definition: compat.h:746
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
static PBYTE MapFile(HANDLE hFile, DWORD *dwSize)
DWORD CreateNewFileFromPatch(PATCH_HEADER *Header, SAFE_READ *Patch, HANDLE new_file)
DWORD ParseHeader(SAFE_READ *Patch, PATCH_HEADER *Header)
#define ERROR_PATCH_NOT_AVAILABLE
Definition: patchapi.h:40
#define ERROR_PATCH_WRONG_FILE
Definition: patchapi.h:38
#define ERROR_PATCH_CORRUPT
Definition: patchapi.h:36
#define APPLY_OPTION_TEST_ONLY
Definition: patchapi.h:28
DWORD dwStatus
Definition: mediaobj.idl:95
#define STATUS_SUCCESS
Definition: shellext.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by ApplyPatchToFileA(), ApplyPatchToFileW(), and TestApplyPatchToFileByHandles().

◆ ApplyPatchToFileW()

BOOL WINAPI ApplyPatchToFileW ( LPCWSTR  PatchFileName,
LPCWSTR  OldFileName,
LPCWSTR  NewFileName,
ULONG  ApplyOptionFlags 
)

Definition at line 445 of file mspatcha_main.c.

446{
447 BOOL ret = FALSE;
448 HANDLE hPatch, hOld, hNew;
449
452 if (hPatch != INVALID_HANDLE_VALUE)
453 {
456 if (hOld != INVALID_HANDLE_VALUE)
457 {
460 if (hNew != INVALID_HANDLE_VALUE)
461 {
462 ret = ApplyPatchToFileByHandles(hPatch, hOld, hNew, apply_flags);
463 CloseHandle(hNew);
464 }
465 CloseHandle(hOld);
466 }
467 CloseHandle(hPatch);
468 }
469
470 return ret;
471}
#define CreateFileW
Definition: compat.h:741

Referenced by msi_apply_filepatch().

◆ GetFilePatchSignatureA()

BOOL WINAPI GetFilePatchSignatureA ( LPCSTR  FileName,
ULONG  OptionFlags,
PVOID  OptionData,
ULONG  IgnoreRangeCount,
PPATCH_IGNORE_RANGE  IgnoreRangeArray,
ULONG  RetainRangeCount,
PPATCH_RETAIN_RANGE  RetainRangeArray,
ULONG  SignatureBufferSize,
PVOID  SignatureBuffer 
)

Definition at line 476 of file mspatcha_main.c.

479{
480 BOOL ret = FALSE;
482
486 {
487 ret = GetFilePatchSignatureByHandle(hFile, flags, data, ignore_range_count, ignore_range,
488 retain_range_count, retain_range, bufsize, buffer);
490 }
491
492 return ret;
493}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLbitfield flags
Definition: glext.h:7161
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
const char * filename
Definition: ioapi.h:137
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)
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by validate_signature().

◆ GetFilePatchSignatureByHandle()

BOOL WINAPI GetFilePatchSignatureByHandle ( HANDLE  FileHandle,
ULONG  OptionFlags,
PVOID  OptionData,
ULONG  IgnoreRangeCount,
PPATCH_IGNORE_RANGE  IgnoreRangeArray,
ULONG  RetainRangeCount,
PPATCH_RETAIN_RANGE  RetainRangeArray,
ULONG  SignatureBufferSize,
PVOID  SignatureBuffer 
)

Definition at line 498 of file mspatcha_main.c.

501{
502 BOOL ret = FALSE;
503 DWORD dwSize, ulCrc;
504 PBYTE pData;
505
506 if (flags)
507 FIXME("Unhandled flags 0x%x\n", flags);
508 if (ignore_range_count)
509 FIXME("Unhandled ignore_range_count %u\n", ignore_range_count);
510 if (retain_range_count)
511 FIXME("Unhandled ignore_range_count %u\n", retain_range_count);
512
513 if ((pData = MapFile(hFile, &dwSize)))
514 {
515 if (dwSize >= 2 && *(PWORD)pData == IMAGE_DOS_SIGNATURE)
516 {
517 FIXME("Potentially unimplemented case, normalized signature\n");
518 }
519
520 ulCrc = RtlComputeCrc32(0, pData, dwSize);
522 {
523 char *pBuffer = buffer;
524 pBuffer[8] = '\0';
525 for (dwSize = 0; dwSize < 8; ++dwSize)
526 {
527 pBuffer[7 - dwSize] = szHexString[ulCrc & 0xf];
528 ulCrc >>= 4;
529 }
530 ret = TRUE;
531 }
533
536 }
537
538 return ret;
539}
#define FIXME(fmt,...)
Definition: debug.h:114
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static const char szHexString[]
Definition: mspatcha_main.c:31
#define SIGNATURE_MIN_SIZE
Definition: mspatcha_main.c:32
WORD * PWORD
Definition: pedump.c:67
BYTE * PBYTE
Definition: pedump.c:66
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
PVOID pBuffer
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by GetFilePatchSignatureA(), GetFilePatchSignatureW(), and validate_signature().

◆ GetFilePatchSignatureW()

BOOL WINAPI GetFilePatchSignatureW ( LPCWSTR  FileName,
ULONG  OptionFlags,
PVOID  OptionData,
ULONG  IgnoreRangeCount,
PPATCH_IGNORE_RANGE  IgnoreRangeArray,
ULONG  RetainRangeCount,
PPATCH_RETAIN_RANGE  RetainRangeArray,
ULONG  SignatureBufferSize,
PVOID  SignatureBuffer 
)

Definition at line 544 of file mspatcha_main.c.

547{
548 CHAR LocalBuf[SIGNATURE_MIN_SIZE];
549 BOOL ret = FALSE;
551
555 {
556 ret = GetFilePatchSignatureByHandle(hFile, flags, data, ignore_range_count, ignore_range,
557 retain_range_count, retain_range, sizeof(LocalBuf), LocalBuf);
559
560 if (bufsize < (SIGNATURE_MIN_SIZE * sizeof(WCHAR)))
561 {
563 return FALSE;
564 }
565 if (ret)
566 {
567 MultiByteToWideChar(CP_ACP, 0, LocalBuf, -1, buffer, bufsize / sizeof(WCHAR));
568 }
569 }
570
571 return ret;
572}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

Referenced by validate_signature().

◆ TestApplyPatchToFileA()

BOOL WINAPI TestApplyPatchToFileA ( LPCSTR  PatchFileName,
LPCSTR  OldFileName,
ULONG  ApplyOptionFlags 
)

Definition at line 577 of file mspatcha_main.c.

578{
579 BOOL ret = FALSE;
580 HANDLE hPatch, hOld;
581
584 if (hPatch != INVALID_HANDLE_VALUE)
585 {
588 if (hOld != INVALID_HANDLE_VALUE)
589 {
590 ret = TestApplyPatchToFileByHandles(hPatch, hOld, apply_flags);
591 CloseHandle(hOld);
592 }
593 CloseHandle(hPatch);
594 }
595
596 return ret;
597}
BOOL WINAPI TestApplyPatchToFileByHandles(HANDLE patch_file, HANDLE old_file, ULONG apply_flags)

Referenced by apply_patch().

◆ TestApplyPatchToFileByHandles()

BOOL WINAPI TestApplyPatchToFileByHandles ( HANDLE  PatchFileHandle,
HANDLE  OldFileHandle,
ULONG  ApplyOptionFlags 
)

Definition at line 602 of file mspatcha_main.c.

603{
605}

Referenced by apply_patch(), TestApplyPatchToFileA(), and TestApplyPatchToFileW().

◆ TestApplyPatchToFileW()

BOOL WINAPI TestApplyPatchToFileW ( LPCWSTR  PatchFileName,
LPCWSTR  OldFileName,
ULONG  ApplyOptionFlags 
)

Definition at line 610 of file mspatcha_main.c.

611{
612 BOOL ret = FALSE;
613 HANDLE hPatch, hOld;
614
617 if (hPatch != INVALID_HANDLE_VALUE)
618 {
621 if (hOld != INVALID_HANDLE_VALUE)
622 {
623 ret = TestApplyPatchToFileByHandles(hPatch, hOld, apply_flags);
624 CloseHandle(hOld);
625 }
626 CloseHandle(hPatch);
627 }
628
629 return ret;
630}

◆ WINBOOL()

typedef WINBOOL ( CALLBACK  PATCH_PROGRESS_CALLBACK)