diff options
author | midipix <writeonce@midipix.org> | 2016-11-19 18:20:42 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-19 18:30:34 -0500 |
commit | 53d5a67988de6f2ea4e8b9b86d29648d25637200 (patch) | |
tree | 435d7b22252ea6d78274d515db0da7fb90b70a1e /src/modules | |
parent | b3ca430ffa338814bcd8d9d42bc638b72076f038 (diff) | |
download | pemagine-53d5a67988de6f2ea4e8b9b86d29648d25637200.tar.bz2 pemagine-53d5a67988de6f2ea4e8b9b86d29648d25637200.tar.xz |
pe_get_module_handle(): code maintenance.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/pe_get_module_handle.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/modules/pe_get_module_handle.c b/src/modules/pe_get_module_handle.c index 0efb1eb..64e804b 100644 --- a/src/modules/pe_get_module_handle.c +++ b/src/modules/pe_get_module_handle.c @@ -26,7 +26,7 @@ void * pe_get_first_module_handle(void) return peb_ldr_tbl_entry->dll_base; } -pe_api + void * pe_get_module_handle(const wchar16_t * name) { wchar16_t * src; @@ -52,21 +52,26 @@ void * pe_get_module_handle(const wchar16_t * name) if (ldr_tbl_entry->base_dll_name.strlen == len) dst = (wchar16_t *)ldr_tbl_entry->base_dll_name.buffer; + else if (ldr_tbl_entry->full_dll_name.strlen == len) dst = (wchar16_t *)ldr_tbl_entry->full_dll_name.buffer; + else dst = (wchar16_t *)0; + if ((intptr_t)(dst)) { src = (wchar16_t *)name; match = 0; while ((match < len) - && ((pe_impl_utf16_char_to_lower(*src)) == (pe_impl_utf16_char_to_lower(*dst)))) { - src = (wchar16_t *)pe_va_from_rva(src,sizeof(wchar16_t)); - dst = (wchar16_t *)pe_va_from_rva(dst,sizeof(wchar16_t)); - match+=sizeof(wchar16_t); - } + && ((pe_impl_utf16_char_to_lower(*src)) + == (pe_impl_utf16_char_to_lower(*dst)))) { + src = (wchar16_t *)pe_va_from_rva(src,sizeof(wchar16_t)); + dst = (wchar16_t *)pe_va_from_rva(dst,sizeof(wchar16_t)); + match+=sizeof(wchar16_t); + } + if (match == len) return ldr_tbl_entry->dll_base; @@ -75,6 +80,5 @@ void * pe_get_module_handle(const wchar16_t * name) plist_current = plist_current->flink; } while (plist_current != plist_head); - /* address not found */ return 0; } |