From 2d504b533e698b3816d399708b00f99e2fcc53ed Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Sun, 21 Sep 2014 17:33:18 +0200 Subject: [PATCH] Check architecture of library to load. --- MemoryModule.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MemoryModule.c b/MemoryModule.c index 4fb4655..a7eda08 100644 --- a/MemoryModule.c +++ b/MemoryModule.c @@ -370,6 +370,15 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, return NULL; } +#ifdef _WIN64 + if (old_header->FileHeader.Machine == IMAGE_FILE_MACHINE_I386) { +#else + if (old_header->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) { +#endif + SetLastError(ERROR_BAD_EXE_FORMAT); + return NULL; + } + // reserve memory for image of library // XXX: is it correct to commit the complete memory region at once? // calling DllEntry raises an exception if we don't...