aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichel Zou <xantares09@hotmail.com>2021-03-15 11:21:09 +0100
committerMichel Zou <xantares09@hotmail.com>2021-04-09 21:58:09 +0200
commit36b92340d489345ff226930dabd133ba36d3a674 (patch)
treee9cd658684e7485e72fe2137d29ee03bb651c5ce /src
parent522c301ec366e9b42205ae21617780d37cc0e9f0 (diff)
downloaddlfcn-win32-36b92340d489345ff226930dabd133ba36d3a674.tar.gz
dlfcn-win32-36b92340d489345ff226930dabd133ba36d3a674.tar.bz2
dlfcn-win32-36b92340d489345ff226930dabd133ba36d3a674.zip
dladdr: const void *addr
on unix the addr argument seems to be const fix that for consistency
Diffstat (limited to 'src')
-rw-r--r--src/dlfcn.c18
-rw-r--r--src/dlfcn.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/src/dlfcn.c b/src/dlfcn.c
index 86f24df..7bca267 100644
--- a/src/dlfcn.c
+++ b/src/dlfcn.c
@@ -216,7 +216,7 @@ static void save_err_ptr_str( const void *ptr, DWORD dwMessageId )
216 save_err_str( ptr_buf, dwMessageId ); 216 save_err_str( ptr_buf, dwMessageId );
217} 217}
218 218
219static HMODULE MyGetModuleHandleFromAddress( void *addr ) 219static HMODULE MyGetModuleHandleFromAddress( const void *addr )
220{ 220{
221 static BOOL (WINAPI *GetModuleHandleExAPtr)(DWORD, LPCSTR, HMODULE *) = NULL; 221 static BOOL (WINAPI *GetModuleHandleExAPtr)(DWORD, LPCSTR, HMODULE *) = NULL;
222 static BOOL failed = FALSE; 222 static BOOL failed = FALSE;
@@ -237,7 +237,7 @@ static HMODULE MyGetModuleHandleFromAddress( void *addr )
237 if( !failed ) 237 if( !failed )
238 { 238 {
239 /* If GetModuleHandleExA is available use it with GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS */ 239 /* If GetModuleHandleExA is available use it with GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS */
240 if( !GetModuleHandleExAPtr( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) addr, &hModule ) ) 240 if( !GetModuleHandleExAPtr( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, addr, &hModule ) )
241 return NULL; 241 return NULL;
242 } 242 }
243 else 243 else
@@ -595,7 +595,7 @@ static BOOL get_image_section( HMODULE module, int index, void **ptr, DWORD *siz
595} 595}
596 596
597/* Return symbol name for a given address from export table */ 597/* Return symbol name for a given address from export table */
598static const char *get_export_symbol_name( HMODULE module, IMAGE_EXPORT_DIRECTORY *ied, void *addr, void **func_address ) 598static const char *get_export_symbol_name( HMODULE module, IMAGE_EXPORT_DIRECTORY *ied, const void *addr, void **func_address )
599{ 599{
600 DWORD i; 600 DWORD i;
601 void *candidateAddr = NULL; 601 void *candidateAddr = NULL;
@@ -628,7 +628,7 @@ static const char *get_export_symbol_name( HMODULE module, IMAGE_EXPORT_DIRECTOR
628 return NULL; 628 return NULL;
629} 629}
630 630
631static BOOL is_valid_address( void *addr ) 631static BOOL is_valid_address( const void *addr )
632{ 632{
633 MEMORY_BASIC_INFORMATION info; 633 MEMORY_BASIC_INFORMATION info;
634 SIZE_T result; 634 SIZE_T result;
@@ -652,7 +652,7 @@ static BOOL is_valid_address( void *addr )
652 * the import address table (iat), which is partially maintained by 652 * the import address table (iat), which is partially maintained by
653 * the runtime linker. 653 * the runtime linker.
654 */ 654 */
655static BOOL is_import_thunk( void *addr ) 655static BOOL is_import_thunk( const void *addr )
656{ 656{
657 return *(short *) addr == 0x25ff ? TRUE : FALSE; 657 return *(short *) addr == 0x25ff ? TRUE : FALSE;
658} 658}
@@ -660,7 +660,7 @@ static BOOL is_import_thunk( void *addr )
660/* Return adress from the import address table (iat), 660/* Return adress from the import address table (iat),
661 * if the original address points to a thunk table entry. 661 * if the original address points to a thunk table entry.
662 */ 662 */
663static void *get_address_from_import_address_table( void *iat, DWORD iat_size, void *addr ) 663static void *get_address_from_import_address_table( void *iat, DWORD iat_size, const void *addr )
664{ 664{
665 BYTE *thkp = (BYTE *) addr; 665 BYTE *thkp = (BYTE *) addr;
666 /* Get offset from thunk table (after instruction 0xff 0x25) 666 /* Get offset from thunk table (after instruction 0xff 0x25)
@@ -691,7 +691,7 @@ static void *get_address_from_import_address_table( void *iat, DWORD iat_size, v
691/* Holds module filename */ 691/* Holds module filename */
692static char module_filename[2*MAX_PATH]; 692static char module_filename[2*MAX_PATH];
693 693
694static BOOL fill_info( void *addr, Dl_info *info ) 694static BOOL fill_info( const void *addr, Dl_info *info )
695{ 695{
696 HMODULE hModule; 696 HMODULE hModule;
697 DWORD dwSize; 697 DWORD dwSize;
@@ -718,13 +718,13 @@ static BOOL fill_info( void *addr, Dl_info *info )
718 else 718 else
719 info->dli_sname = NULL; 719 info->dli_sname = NULL;
720 720
721 info->dli_saddr = info->dli_sname == NULL ? NULL : funcAddress != NULL ? funcAddress : addr; 721 info->dli_saddr = info->dli_sname == NULL ? NULL : funcAddress != NULL ? funcAddress : (void *) addr;
722 722
723 return TRUE; 723 return TRUE;
724} 724}
725 725
726DLFCN_EXPORT 726DLFCN_EXPORT
727int dladdr( void *addr, Dl_info *info ) 727int dladdr( const void *addr, Dl_info *info )
728{ 728{
729 if( info == NULL ) 729 if( info == NULL )
730 return 0; 730 return 0;
diff --git a/src/dlfcn.h b/src/dlfcn.h
index 164216f..bf5c7d4 100644
--- a/src/dlfcn.h
+++ b/src/dlfcn.h
@@ -85,7 +85,7 @@ DLFCN_EXPORT void *dlsym(void *handle, const char *name);
85DLFCN_EXPORT char *dlerror(void); 85DLFCN_EXPORT char *dlerror(void);
86 86
87/* Translate address to symbolic information (no POSIX standard) */ 87/* Translate address to symbolic information (no POSIX standard) */
88DLFCN_EXPORT int dladdr(void *addr, Dl_info *info); 88DLFCN_EXPORT int dladdr(const void *addr, Dl_info *info);
89 89
90#ifdef __cplusplus 90#ifdef __cplusplus
91} 91}