libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 6423e75538bbd5225363ccf8304ca34945e29b9a
parent d8a4e1179a4167e7aed934e42eec679a1355af1e
Author: LRN <lrn1986@gmail.com>
Date:   Sun, 16 Jun 2013 03:55:25 +0000

[W32] Get module name relative to the dll, not exe

Diffstat:
Msrc/main/extractor_plugpath.c | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c @@ -158,6 +158,23 @@ get_path_from_proc_exe () #if WINDOWS +static HMODULE le_dll = NULL; + +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + le_dll = (HMODULE) hinstDLL; + break; + } + + return TRUE; +} + /** * Try to determine path with win32-specific function */ @@ -170,7 +187,7 @@ get_path_from_module_filename () if (NULL == (path = malloc (4103))) /* 4096+nil+6 for "/lib/" catenation */ return NULL; - GetModuleFileName (NULL, path, 4096); + GetModuleFileName (le_dll, path, 4096); idx = path + strlen (path); while ( (idx > path) && ('\\' != *idx) &&