aboutsummaryrefslogtreecommitdiff
path: root/src/main/extractor_plugpath.c
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2013-06-16 03:55:25 +0000
committerLRN <lrn1986@gmail.com>2013-06-16 03:55:25 +0000
commit6423e75538bbd5225363ccf8304ca34945e29b9a (patch)
tree9512653e6b47f23b015f10dd7e445e6ba98f16a4 /src/main/extractor_plugpath.c
parentd8a4e1179a4167e7aed934e42eec679a1355af1e (diff)
downloadlibextractor-6423e75538bbd5225363ccf8304ca34945e29b9a.tar.gz
libextractor-6423e75538bbd5225363ccf8304ca34945e29b9a.zip
[W32] Get module name relative to the dll, not exe
Diffstat (limited to 'src/main/extractor_plugpath.c')
-rw-r--r--src/main/extractor_plugpath.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c
index dba0932..a5f5b54 100644
--- a/src/main/extractor_plugpath.c
+++ b/src/main/extractor_plugpath.c
@@ -158,6 +158,23 @@ get_path_from_proc_exe ()
158 158
159 159
160#if WINDOWS 160#if WINDOWS
161static HMODULE le_dll = NULL;
162
163BOOL WINAPI
164DllMain (HINSTANCE hinstDLL,
165 DWORD fdwReason,
166 LPVOID lpvReserved)
167{
168 switch (fdwReason)
169 {
170 case DLL_PROCESS_ATTACH:
171 le_dll = (HMODULE) hinstDLL;
172 break;
173 }
174
175 return TRUE;
176}
177
161/** 178/**
162 * Try to determine path with win32-specific function 179 * Try to determine path with win32-specific function
163 */ 180 */
@@ -170,7 +187,7 @@ get_path_from_module_filename ()
170 187
171 if (NULL == (path = malloc (4103))) /* 4096+nil+6 for "/lib/" catenation */ 188 if (NULL == (path = malloc (4103))) /* 4096+nil+6 for "/lib/" catenation */
172 return NULL; 189 return NULL;
173 GetModuleFileName (NULL, path, 4096); 190 GetModuleFileName (le_dll, path, 4096);
174 idx = path + strlen (path); 191 idx = path + strlen (path);
175 while ( (idx > path) && 192 while ( (idx > path) &&
176 ('\\' != *idx) && 193 ('\\' != *idx) &&