From 536a5978360eb967c02ed69118da773d8427d1cb Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Sat, 9 Mar 2013 00:37:11 +0100 Subject: [PATCH] Use "SetLastError" for errors in "GetProcAddress". --- MemoryModule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MemoryModule.c b/MemoryModule.c index 4690a41..8b81da4 100644 --- a/MemoryModule.c +++ b/MemoryModule.c @@ -448,12 +448,14 @@ FARPROC MemoryGetProcAddress(HMEMORYMODULE module, const char *name) PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE)module, IMAGE_DIRECTORY_ENTRY_EXPORT); if (directory->Size == 0) { // no export table found + SetLastError(ERROR_PROC_NOT_FOUND); return NULL; } exports = (PIMAGE_EXPORT_DIRECTORY) (codeBase + directory->VirtualAddress); if (exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0) { // DLL doesn't export anything + SetLastError(ERROR_PROC_NOT_FOUND); return NULL; } @@ -469,11 +471,13 @@ FARPROC MemoryGetProcAddress(HMEMORYMODULE module, const char *name) if (idx == -1) { // exported symbol not found + SetLastError(ERROR_PROC_NOT_FOUND); return NULL; } if ((DWORD)idx > exports->NumberOfFunctions) { // name <-> ordinal number don't match + SetLastError(ERROR_PROC_NOT_FOUND); return NULL; }