diff options
author | Michel Zou <xantares09@hotmail.com> | 2021-03-15 11:21:09 +0100 |
---|---|---|
committer | Michel Zou <xantares09@hotmail.com> | 2021-04-09 21:58:09 +0200 |
commit | 36b92340d489345ff226930dabd133ba36d3a674 (patch) | |
tree | e9cd658684e7485e72fe2137d29ee03bb651c5ce /src | |
parent | 522c301ec366e9b42205ae21617780d37cc0e9f0 (diff) | |
download | dlfcn-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.c | 18 | ||||
-rw-r--r-- | src/dlfcn.h | 2 |
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 | ||
219 | static HMODULE MyGetModuleHandleFromAddress( void *addr ) | 219 | static 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 */ |
598 | static const char *get_export_symbol_name( HMODULE module, IMAGE_EXPORT_DIRECTORY *ied, void *addr, void **func_address ) | 598 | static 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 | ||
631 | static BOOL is_valid_address( void *addr ) | 631 | static 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 | */ |
655 | static BOOL is_import_thunk( void *addr ) | 655 | static 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 | */ |
663 | static void *get_address_from_import_address_table( void *iat, DWORD iat_size, void *addr ) | 663 | static 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 */ |
692 | static char module_filename[2*MAX_PATH]; | 692 | static char module_filename[2*MAX_PATH]; |
693 | 693 | ||
694 | static BOOL fill_info( void *addr, Dl_info *info ) | 694 | static 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 | ||
726 | DLFCN_EXPORT | 726 | DLFCN_EXPORT |
727 | int dladdr( void *addr, Dl_info *info ) | 727 | int 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); | |||
85 | DLFCN_EXPORT char *dlerror(void); | 85 | DLFCN_EXPORT char *dlerror(void); |
86 | 86 | ||
87 | /* Translate address to symbolic information (no POSIX standard) */ | 87 | /* Translate address to symbolic information (no POSIX standard) */ |
88 | DLFCN_EXPORT int dladdr(void *addr, Dl_info *info); | 88 | DLFCN_EXPORT int dladdr(const void *addr, Dl_info *info); |
89 | 89 | ||
90 | #ifdef __cplusplus | 90 | #ifdef __cplusplus |
91 | } | 91 | } |