summaryrefslogtreecommitdiff
path: root/tools/checksum/checksum.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-27 16:38:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-27 16:38:34 +0300
commit09b722976957029a3d581c0ff16088a367b41f14 (patch)
tree69187ae9da470130e1dff4f5942e6aeda15511af /tools/checksum/checksum.cpp
parent9ec3c7e78e560356066b272ad7a38d3d333de1b5 (diff)
patch that excludes PRODUCTVERSION from calculating checksum - will cause reload of all modules in PU
Diffstat (limited to 'tools/checksum/checksum.cpp')
-rw-r--r--tools/checksum/checksum.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/checksum/checksum.cpp b/tools/checksum/checksum.cpp
index a3aefec80f..affaea11a4 100644
--- a/tools/checksum/checksum.cpp
+++ b/tools/checksum/checksum.cpp
@@ -16,26 +16,31 @@
#define RESULT_NONE 100
int debug = 0;
+DWORD dwVersion = 0;
-static void PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY pIRD, PBYTE pBase);
+static void PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY pIRD, PBYTE pBase, DWORD dwType);
-static void PatchResourceEntry(PIMAGE_RESOURCE_DIRECTORY_ENTRY pIRDE, PBYTE pBase)
+static void PatchResourceEntry(PIMAGE_RESOURCE_DIRECTORY_ENTRY pIRDE, PBYTE pBase, DWORD dwType)
{
if (pIRDE->DataIsDirectory)
- PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY(pBase + pIRDE->OffsetToDirectory), pBase);
+ PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY(pBase + pIRDE->OffsetToDirectory), pBase, dwType == 0 ? pIRDE->Name : dwType);
+ else if (dwType == 16) {
+ PIMAGE_RESOURCE_DATA_ENTRY pItem = PIMAGE_RESOURCE_DATA_ENTRY(pBase + pIRDE->OffsetToData);
+ dwVersion = pItem->OffsetToData;
+ }
}
-static void PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY pIRD, PBYTE pBase)
+static void PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY pIRD, PBYTE pBase, DWORD dwType)
{
UINT i;
pIRD->TimeDateStamp = 0;
PIMAGE_RESOURCE_DIRECTORY_ENTRY pIRDE = PIMAGE_RESOURCE_DIRECTORY_ENTRY(pIRD + 1);
for (i = 0; i < pIRD->NumberOfNamedEntries; i++, pIRDE++)
- PatchResourceEntry(pIRDE, pBase);
+ PatchResourceEntry(pIRDE, pBase, dwType);
for (i = 0; i < pIRD->NumberOfIdEntries; i++, pIRDE++)
- PatchResourceEntry(pIRDE, pBase);
+ PatchResourceEntry(pIRDE, pBase, dwType);
}
__forceinline bool Contains(PIMAGE_SECTION_HEADER pISH, DWORD address, DWORD size = 0)
@@ -214,7 +219,14 @@ int PEChecksum(wchar_t *filename, BYTE digest[16])
if (resSize > 0 && resAddr >= pISH->VirtualAddress && resAddr + resSize <= pISH->VirtualAddress + pISH->SizeOfRawData) {
DWORD shift = resAddr - pISH->VirtualAddress + pISH->PointerToRawData;
IMAGE_RESOURCE_DIRECTORY *pIRD = (IMAGE_RESOURCE_DIRECTORY*)(ptr + shift);
- PatchResourcesDirectory(pIRD, ptr + shift);
+ PatchResourcesDirectory(pIRD, ptr + shift, 0);
+
+ // patch version
+ if (dwVersion) {
+ shift = dwVersion - pISH->VirtualAddress + pISH->PointerToRawData;
+ VS_FIXEDFILEINFO *pVersion = (VS_FIXEDFILEINFO*)(ptr + shift);
+ pVersion->dwProductVersionLS = pVersion->dwProductVersionMS = 0;
+ }
}
// rebase to zero address