Skip to content

Commit 6c2c3e2

Browse files
committed
Fix more potential conversion issues on 64bit.
1 parent 03cd7c9 commit 6c2c3e2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

MemoryModule.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef struct {
7474
typedef struct {
7575
LPVOID address;
7676
LPVOID alignedAddress;
77-
DWORD size;
77+
SIZE_T size;
7878
DWORD characteristics;
7979
BOOL last;
8080
} SECTIONFINALIZEDATA, *PSECTIONFINALIZEDATA;
@@ -192,7 +192,7 @@ static int ProtectionFlags[2][2][2] = {
192192
},
193193
};
194194

195-
static DWORD
195+
static SIZE_T
196196
GetRealSectionSize(PMEMORYMODULE module, PIMAGE_SECTION_HEADER section) {
197197
DWORD size = section->SizeOfRawData;
198198
if (size == 0) {
@@ -202,7 +202,7 @@ GetRealSectionSize(PMEMORYMODULE module, PIMAGE_SECTION_HEADER section) {
202202
size = module->headers->OptionalHeader.SizeOfUninitializedData;
203203
}
204204
}
205-
return size;
205+
return (SIZE_T) size;
206206
}
207207

208208
static BOOL
@@ -271,7 +271,7 @@ FinalizeSections(PMEMORYMODULE module)
271271
for (i=1; i<module->headers->FileHeader.NumberOfSections; i++, section++) {
272272
LPVOID sectionAddress = (LPVOID)((uintptr_t)section->Misc.PhysicalAddress | imageOffset);
273273
LPVOID alignedAddress = AlignAddressDown(sectionAddress, module->pageSize);
274-
DWORD sectionSize = GetRealSectionSize(module, section);
274+
SIZE_T sectionSize = GetRealSectionSize(module, section);
275275
// Combine access flags of all sections that share a page
276276
// TODO(fancycode): We currently share flags of a trailing large section
277277
// with the page of a first small section. This should be optimized.
@@ -282,7 +282,7 @@ FinalizeSections(PMEMORYMODULE module)
282282
} else {
283283
sectionData.characteristics |= section->Characteristics;
284284
}
285-
sectionData.size = (((uintptr_t)sectionAddress) + sectionSize) - (uintptr_t) sectionData.address;
285+
sectionData.size = (((uintptr_t)sectionAddress) + ((uintptr_t) sectionSize)) - (uintptr_t) sectionData.address;
286286
continue;
287287
}
288288

@@ -868,7 +868,11 @@ static PIMAGE_RESOURCE_DIRECTORY_ENTRY _MemorySearchResourceEntry(
868868
cmp = _wcsnicmp(searchKey, resourceString->NameString, resourceString->Length);
869869
if (cmp == 0) {
870870
// 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+
}
872876
}
873877
if (cmp < 0) {
874878
end = (middle != end ? middle : middle-1);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy