@@ -74,7 +74,7 @@ typedef struct { |
74 | 74 | typedef struct { |
75 | 75 | LPVOID address; |
76 | 76 | LPVOID alignedAddress; |
77 | | - DWORD size; |
| 77 | + SIZE_T size; |
78 | 78 | DWORD characteristics; |
79 | 79 | BOOL last; |
80 | 80 | } SECTIONFINALIZEDATA, *PSECTIONFINALIZEDATA; |
@@ -192,7 +192,7 @@ static int ProtectionFlags[2][2][2] = { |
192 | 192 | }, |
193 | 193 | }; |
194 | 194 |
|
195 | | -static DWORD |
| 195 | +static SIZE_T |
196 | 196 | GetRealSectionSize(PMEMORYMODULE module, PIMAGE_SECTION_HEADER section) { |
197 | 197 | DWORD size = section->SizeOfRawData; |
198 | 198 | if (size == 0) { |
@@ -202,7 +202,7 @@ GetRealSectionSize(PMEMORYMODULE module, PIMAGE_SECTION_HEADER section) { |
202 | 202 | size = module->headers->OptionalHeader.SizeOfUninitializedData; |
203 | 203 | } |
204 | 204 | } |
205 | | - return size; |
| 205 | + return (SIZE_T) size; |
206 | 206 | } |
207 | 207 |
|
208 | 208 | static BOOL |
@@ -271,7 +271,7 @@ FinalizeSections(PMEMORYMODULE module) |
271 | 271 | for (i=1; i<module->headers->FileHeader.NumberOfSections; i++, section++) { |
272 | 272 | LPVOID sectionAddress = (LPVOID)((uintptr_t)section->Misc.PhysicalAddress | imageOffset); |
273 | 273 | LPVOID alignedAddress = AlignAddressDown(sectionAddress, module->pageSize); |
274 | | - DWORD sectionSize = GetRealSectionSize(module, section); |
| 274 | + SIZE_T sectionSize = GetRealSectionSize(module, section); |
275 | 275 | // Combine access flags of all sections that share a page |
276 | 276 | // TODO(fancycode): We currently share flags of a trailing large section |
277 | 277 | // with the page of a first small section. This should be optimized. |
@@ -282,7 +282,7 @@ FinalizeSections(PMEMORYMODULE module) |
282 | 282 | } else { |
283 | 283 | sectionData.characteristics |= section->Characteristics; |
284 | 284 | } |
285 | | - sectionData.size = (((uintptr_t)sectionAddress) + sectionSize) - (uintptr_t) sectionData.address; |
| 285 | + sectionData.size = (((uintptr_t)sectionAddress) + ((uintptr_t) sectionSize)) - (uintptr_t) sectionData.address; |
286 | 286 | continue; |
287 | 287 | } |
288 | 288 |
|
@@ -868,7 +868,11 @@ static PIMAGE_RESOURCE_DIRECTORY_ENTRY _MemorySearchResourceEntry( |
868 | 868 | cmp = _wcsnicmp(searchKey, resourceString->NameString, resourceString->Length); |
869 | 869 | if (cmp == 0) { |
870 | 870 | // Handle partial match |
871 | | - cmp = searchKeyLen - resourceString->Length; |
| 871 | + if (searchKeyLen > resourceString->Length) { |
| 872 | + cmp = 1; |
| 873 | + } else if (searchKeyLen < resourceString->Length) { |
| 874 | + cmp = -1; |
| 875 | + } |
872 | 876 | } |
873 | 877 | if (cmp < 0) { |
874 | 878 | end = (middle != end ? middle : middle-1); |
|