1 /** 2 * This file is part of the mingw-w64 runtime package. 3 * No warranty is given; refer to the file DISCLAIMER within this package. 4 */ 5 #ifndef _PATCHAPI_H_ 6 #define _PATCHAPI_H_ 7 8 #include <_mingw_unicode.h> 9 #include <winapifamily.h> 10 11 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #ifdef IMPORTING_PATCHAPI_DLL 18 #define PATCHAPI WINAPI __declspec(dllimport) 19 #else 20 #define PATCHAPI WINAPI 21 #endif 22 23 #define PATCH_OPTION_USE_BEST 0x0 24 #define PATCH_OPTION_USE_LZX_A 0x1 25 #define PATCH_OPTION_USE_LZX_B 0x2 26 #define PATCH_OPTION_USE_LZX_BEST 0x3 27 #define PATCH_OPTION_USE_LZX_LARGE 0x4 28 29 #define PATCH_OPTION_NO_BINDFIX 0x00010000 30 #define PATCH_OPTION_NO_LOCKFIX 0x00020000 31 #define PATCH_OPTION_NO_REBASE 0x00040000 32 #define PATCH_OPTION_FAIL_IF_SAME_FILE 0x00080000 33 #define PATCH_OPTION_FAIL_IF_BIGGER 0x00100000 34 #define PATCH_OPTION_NO_CHECKSUM 0x00200000 35 #define PATCH_OPTION_NO_RESTIMEFIX 0x00400000 36 #define PATCH_OPTION_NO_TIMESTAMP 0x00800000 37 #define PATCH_OPTION_SIGNATURE_MD5 0x01000000 38 #define PATCH_OPTION_INTERLEAVE_FILES 0x40000000 39 #define PATCH_OPTION_RESERVED1 0x80000000 40 41 #define PATCH_OPTION_VALID_FLAGS 0xc0ff0007 42 43 #define PATCH_SYMBOL_NO_IMAGEHLP 0x00000001 44 #define PATCH_SYMBOL_NO_FAILURES 0x00000002 45 #define PATCH_SYMBOL_UNDECORATED_TOO 0x00000004 46 #define PATCH_SYMBOL_RESERVED1 0x80000000 47 48 #define PATCH_TRANSFORM_PE_RESOURCE_2 0x00000100 49 #define PATCH_TRANSFORM_PE_IRELOC_2 0x00000200 50 51 #define APPLY_OPTION_FAIL_IF_EXACT 0x00000001 52 #define APPLY_OPTION_FAIL_IF_CLOSE 0x00000002 53 #define APPLY_OPTION_TEST_ONLY 0x00000004 54 #define APPLY_OPTION_VALID_FLAGS 0x00000007 55 56 #define ERROR_PATCH_ENCODE_FAILURE 0xC00E3101 57 #define ERROR_PATCH_INVALID_OPTIONS 0xC00E3102 58 #define ERROR_PATCH_SAME_FILE 0xC00E3103 59 #define ERROR_PATCH_RETAIN_RANGES_DIFFER 0xC00E3104 60 #define ERROR_PATCH_BIGGER_THAN_COMPRESSED 0xC00E3105 61 #define ERROR_PATCH_IMAGEHLP_FAILURE 0xC00E3106 62 63 #define ERROR_PATCH_DECODE_FAILURE 0xC00E4101 64 #define ERROR_PATCH_CORRUPT 0xC00E4102 65 #define ERROR_PATCH_NEWER_FORMAT 0xC00E4103 66 #define ERROR_PATCH_WRONG_FILE 0xC00E4104 67 #define ERROR_PATCH_NOT_NECESSARY 0xC00E4105 68 #define ERROR_PATCH_NOT_AVAILABLE 0xC00E4106 69 70 typedef WINBOOL (CALLBACK PATCH_PROGRESS_CALLBACK)(PVOID CallbackContext,ULONG CurrentPosition,ULONG MaximumPosition); 71 typedef PATCH_PROGRESS_CALLBACK *PPATCH_PROGRESS_CALLBACK; 72 typedef WINBOOL (CALLBACK PATCH_SYMLOAD_CALLBACK)(ULONG WhichFile,LPCSTR SymbolFileName,ULONG SymType,ULONG SymbolFileCheckSum,ULONG SymbolFileTimeDate,ULONG ImageFileCheckSum,ULONG ImageFileTimeDate,PVOID CallbackContext); 73 typedef PATCH_SYMLOAD_CALLBACK *PPATCH_SYMLOAD_CALLBACK; 74 75 typedef struct _PATCH_IGNORE_RANGE { 76 ULONG OffsetInOldFile; 77 ULONG LengthInBytes; 78 } PATCH_IGNORE_RANGE,*PPATCH_IGNORE_RANGE; 79 80 typedef struct _PATCH_RETAIN_RANGE { 81 ULONG OffsetInOldFile; 82 ULONG LengthInBytes; 83 ULONG OffsetInNewFile; 84 } PATCH_RETAIN_RANGE,*PPATCH_RETAIN_RANGE; 85 86 typedef struct _PATCH_OLD_FILE_INFO_A { 87 ULONG SizeOfThisStruct; 88 LPCSTR OldFileName; 89 ULONG IgnoreRangeCount; 90 PPATCH_IGNORE_RANGE IgnoreRangeArray; 91 ULONG RetainRangeCount; 92 PPATCH_RETAIN_RANGE RetainRangeArray; 93 } PATCH_OLD_FILE_INFO_A,*PPATCH_OLD_FILE_INFO_A; 94 95 typedef struct _PATCH_OLD_FILE_INFO_W { 96 ULONG SizeOfThisStruct; 97 LPCWSTR OldFileName; 98 ULONG IgnoreRangeCount; 99 PPATCH_IGNORE_RANGE IgnoreRangeArray; 100 ULONG RetainRangeCount; 101 PPATCH_RETAIN_RANGE RetainRangeArray; 102 } PATCH_OLD_FILE_INFO_W,*PPATCH_OLD_FILE_INFO_W; 103 104 typedef struct _PATCH_OLD_FILE_INFO_H { 105 ULONG SizeOfThisStruct; 106 HANDLE OldFileHandle; 107 ULONG IgnoreRangeCount; 108 PPATCH_IGNORE_RANGE IgnoreRangeArray; 109 ULONG RetainRangeCount; 110 PPATCH_RETAIN_RANGE RetainRangeArray; 111 } PATCH_OLD_FILE_INFO_H,*PPATCH_OLD_FILE_INFO_H; 112 113 typedef struct _PATCH_OLD_FILE_INFO { 114 ULONG SizeOfThisStruct; 115 __C89_NAMELESS union { 116 LPCSTR OldFileNameA; 117 LPCWSTR OldFileNameW; 118 HANDLE OldFileHandle; 119 }; 120 ULONG IgnoreRangeCount; 121 PPATCH_IGNORE_RANGE IgnoreRangeArray; 122 ULONG RetainRangeCount; 123 PPATCH_RETAIN_RANGE RetainRangeArray; 124 } PATCH_OLD_FILE_INFO,*PPATCH_OLD_FILE_INFO; 125 126 typedef struct _PATCH_INTERLEAVE_MAP { 127 ULONG CountRanges; 128 struct { 129 ULONG OldOffset; 130 ULONG OldLength; 131 ULONG NewLength; 132 } Range[1]; 133 } PATCH_INTERLEAVE_MAP, *PPATCH_INTERLEAVE_MAP; 134 135 typedef struct _PATCH_OPTION_DATA { 136 ULONG SizeOfThisStruct; 137 ULONG SymbolOptionFlags; 138 LPCSTR NewFileSymbolPath; 139 LPCSTR *OldFileSymbolPathArray; 140 ULONG ExtendedOptionFlags; 141 PPATCH_SYMLOAD_CALLBACK SymLoadCallback; 142 PVOID SymLoadContext; 143 PPATCH_INTERLEAVE_MAP *InterleaveMapArray; 144 ULONG MaxLzxWindowSize; 145 } PATCH_OPTION_DATA,*PPATCH_OPTION_DATA; 146 147 WINBOOL PATCHAPI CreatePatchFileA(LPCSTR OldFileName,LPCSTR NewFileName,LPCSTR PatchFileName,ULONG OptionFlags,PPATCH_OPTION_DATA OptionData); 148 WINBOOL PATCHAPI CreatePatchFileW(LPCWSTR OldFileName,LPCWSTR NewFileName,LPCWSTR PatchFileName,ULONG OptionFlags,PPATCH_OPTION_DATA OptionData); 149 #define CreatePatchFile __MINGW_NAME_AW(CreatePatchFile) 150 151 WINBOOL PATCHAPI CreatePatchFileExA(ULONG OldFileCount,PPATCH_OLD_FILE_INFO_A OldFileInfoArray,LPCSTR NewFileName,LPCSTR PatchFileName,ULONG OptionFlags,PPATCH_OPTION_DATA OptionData,PPATCH_PROGRESS_CALLBACK ProgressCallback,PVOID CallbackContext); 152 WINBOOL PATCHAPI CreatePatchFileExW(ULONG OldFileCount,PPATCH_OLD_FILE_INFO_W OldFileInfoArray,LPCWSTR NewFileName,LPCWSTR PatchFileName,ULONG OptionFlags,PPATCH_OPTION_DATA OptionData,PPATCH_PROGRESS_CALLBACK ProgressCallback,PVOID CallbackContext); 153 #define CreatePatchFileEx __MINGW_NAME_AW(CreatePatchFileEx) 154 155 WINBOOL PATCHAPI ExtractPatchHeaderToFileA(LPCSTR PatchFileName,LPCSTR PatchHeaderFileName); 156 WINBOOL PATCHAPI ExtractPatchHeaderToFileW(LPCWSTR PatchFileName,LPCWSTR PatchHeaderFileName); 157 #define ExtractPatchHeaderToFile __MINGW_NAME_AW(ExtractPatchHeaderToFile) 158 159 WINBOOL PATCHAPI TestApplyPatchToFileA(LPCSTR PatchFileName,LPCSTR OldFileName,ULONG ApplyOptionFlags); 160 WINBOOL PATCHAPI TestApplyPatchToFileW(LPCWSTR PatchFileName,LPCWSTR OldFileName,ULONG ApplyOptionFlags); 161 #define TestApplyPatchToFile __MINGW_NAME_AW(TestApplyPatchToFile) 162 163 WINBOOL PATCHAPI ApplyPatchToFileA(LPCSTR PatchFileName,LPCSTR OldFileName,LPCSTR NewFileName,ULONG ApplyOptionFlags); 164 WINBOOL PATCHAPI ApplyPatchToFileW(LPCWSTR PatchFileName,LPCWSTR OldFileName,LPCWSTR NewFileName,ULONG ApplyOptionFlags); 165 #define ApplyPatchToFile __MINGW_NAME_AW(ApplyPatchToFile) 166 167 WINBOOL PATCHAPI ApplyPatchToFileExA(LPCSTR PatchFileName,LPCSTR OldFileName,LPCSTR NewFileName,ULONG ApplyOptionFlags,PPATCH_PROGRESS_CALLBACK ProgressCallback,PVOID CallbackContext); 168 WINBOOL PATCHAPI ApplyPatchToFileExW(LPCWSTR PatchFileName,LPCWSTR OldFileName,LPCWSTR NewFileName,ULONG ApplyOptionFlags,PPATCH_PROGRESS_CALLBACK ProgressCallback,PVOID CallbackContext); 169 #define ApplyPatchToFileEx __MINGW_NAME_AW(ApplyPatchToFileEx) 170 171 WINBOOL PATCHAPI GetFilePatchSignatureA(LPCSTR FileName,ULONG OptionFlags,PVOID OptionData,ULONG IgnoreRangeCount,PPATCH_IGNORE_RANGE IgnoreRangeArray,ULONG RetainRangeCount,PPATCH_RETAIN_RANGE RetainRangeArray,ULONG SignatureBufferSize,PVOID SignatureBuffer); 172 WINBOOL PATCHAPI GetFilePatchSignatureW(LPCWSTR FileName,ULONG OptionFlags,PVOID OptionData,ULONG IgnoreRangeCount,PPATCH_IGNORE_RANGE IgnoreRangeArray,ULONG RetainRangeCount,PPATCH_RETAIN_RANGE RetainRangeArray,ULONG SignatureBufferSizeInBytes,PVOID SignatureBuffer); 173 #define GetFilePatchSignature __MINGW_NAME_AW(GetFilePatchSignature) 174 175 WINBOOL PATCHAPI GetFilePatchSignatureByHandle(HANDLE FileHandle,ULONG OptionFlags,PVOID OptionData,ULONG IgnoreRangeCount,PPATCH_IGNORE_RANGE IgnoreRangeArray,ULONG RetainRangeCount,PPATCH_RETAIN_RANGE RetainRangeArray,ULONG SignatureBufferSize,PVOID SignatureBuffer); 176 WINBOOL PATCHAPI CreatePatchFileByHandles(HANDLE OldFileHandle,HANDLE NewFileHandle,HANDLE PatchFileHandle,ULONG OptionFlags,PPATCH_OPTION_DATA OptionData); 177 WINBOOL PATCHAPI CreatePatchFileByHandlesEx(ULONG OldFileCount,PPATCH_OLD_FILE_INFO_H OldFileInfoArray,HANDLE NewFileHandle,HANDLE PatchFileHandle,ULONG OptionFlags,PPATCH_OPTION_DATA OptionData,PPATCH_PROGRESS_CALLBACK ProgressCallback,PVOID CallbackContext); 178 WINBOOL PATCHAPI ExtractPatchHeaderToFileByHandles(HANDLE PatchFileHandle,HANDLE PatchHeaderFileHandle); 179 WINBOOL PATCHAPI TestApplyPatchToFileByHandles(HANDLE PatchFileHandle,HANDLE OldFileHandle,ULONG ApplyOptionFlags); 180 WINBOOL PATCHAPI ApplyPatchToFileByHandles(HANDLE PatchFileHandle,HANDLE OldFileHandle,HANDLE NewFileHandle,ULONG ApplyOptionFlags); 181 WINBOOL PATCHAPI ApplyPatchToFileByHandlesEx(HANDLE PatchFileHandle,HANDLE OldFileHandle,HANDLE NewFileHandle,ULONG ApplyOptionFlags,PPATCH_PROGRESS_CALLBACK ProgressCallback,PVOID CallbackContext); 182 183 WINBOOL PATCHAPI GetFilePatchSignatureByBuffer(PBYTE FileBufferWritable, ULONG FileSize, ULONG OptionFlags, PVOID OptionData, ULONG IgnoreRangeCount, PPATCH_IGNORE_RANGE IgnoreRangeArray, ULONG RetainRangeCount, PPATCH_RETAIN_RANGE RetainRangeArray, ULONG SignatureBufferSize, LPSTR SignatureBuffer); 184 WINBOOL PATCHAPI ApplyPatchToFileByBuffers(PBYTE PatchFileMapped, ULONG PatchFileSize, PBYTE OldFileMapped, ULONG OldFileSize, PBYTE *NewFileBuffer, ULONG NewFileBufferSize, ULONG *NewFileActualSize, FILETIME *NewFileTime, ULONG ApplyOptionFlags, PPATCH_PROGRESS_CALLBACK ProgressCallback, PVOID CallbackContext); 185 WINBOOL PATCHAPI TestApplyPatchToFileByBuffers(PBYTE PatchFileBuffer, ULONG PatchFileSize, PBYTE OldFileBuffer, ULONG OldFileSize, ULONG *NewFileSize, ULONG ApplyOptionFlags); 186 187 #ifdef __cplusplus 188 } 189 #endif 190 191 #endif 192 #endif 193