Skip to content

Commit 2d504b5

Browse files
committed
Check architecture of library to load.
1 parent b8125d0 commit 2d504b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

MemoryModule.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,15 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data,
370370
return NULL;
371371
}
372372

373+
#ifdef _WIN64
374+
if (old_header->FileHeader.Machine == IMAGE_FILE_MACHINE_I386) {
375+
#else
376+
if (old_header->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) {
377+
#endif
378+
SetLastError(ERROR_BAD_EXE_FORMAT);
379+
return NULL;
380+
}
381+
373382
// reserve memory for image of library
374383
// XXX: is it correct to commit the complete memory region at once?
375384
// calling DllEntry raises an exception if we don't...

0 commit comments

Comments
 (0)