aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Do not install test filevariousimprovements2025Pali Rohár2025-04-281-2/+0
|
* Replace CRT's strlen() and memcpy() by open coded variantsPali Rohár2025-04-281-9/+8
| | | | | | After this change there is no usage of of CRT library function. This allows to build CRT-neutral variant of libdl.dll library, which can be used in any application.
* Replace CRT's malloc() and free() by WinAPI's LocalAlloc() and LocalFree() ↵Pali Rohár2025-04-281-6/+23
| | | | | | | | | | | in release mode In debug mode is still used malloc() and free() for as part of memory leak testing done by _CRTDBG_MAP_ALLOC and _CrtDumpMemoryLeaks() in test.c. This change allows to wrap CRT's malloc() via dlsym's RTLD_NEXT. See #112
* Fix includesPali Rohár2025-04-281-3/+3
| | | | | | * Remove unused include stdio.h * Add used include string.h * Add reason comments for includes
* Do not cast between function pointer and data pointer when not requiredPali Rohár2025-04-281-4/+4
| | | | | | | This is undefined in C and also C++. Both gcc and msvc allows to cast between two incompatible function pointers without triggering warnings transitionally via void(*)(void) function pointer. Replace transitional LPVOID cast by void(*)(void) cast.
* Fix compile warning: comparison of integer expressions of different ↵Pali Rohár2025-04-281-1/+1
| | | | signedness: ‘int’ and ‘DWORD’ {aka ‘long unsigned int’}
* Fix compile warning C4244: '=' : conversion from 'int' to 'char', possible ↵Pali Rohár2025-04-281-1/+1
| | | | loss of data
* Fix test compile error C2065: 'errno' : undeclared identifierPali Rohár2025-04-281-0/+1
| | | | | For errno usage it is required to include C header file errno.h and do not depend that some other header file will include it.
* Fix C++ compile error C2065: '_ReturnAddress' : undeclared identifierPali Rohár2025-04-281-1/+6
| | | | | It follows compile warning C4164: '_ReturnAddress' : intrinsic function not declared Declaration can be included also via intrin.h header file.
* Fix C++ compile error C2065: '_alloca' : undeclared identifierPali Rohár2025-04-281-0/+4
| | | | | When compiling in C++ mode, it is required to have C declaration for _alloca. Declaration can be included also via malloc.h header file.
* Fix gcc compile errors in C++ modePali Rohár2025-04-281-2/+2
| | | | Add missing casts which are required in C++.
* Fix is_valid_address() functionPali Rohár2025-04-281-1/+1
| | | | | | | | | | | | | | | Returned structure is valid only if the function return value is same as the size of the structure. So check for the correct size, not just for the non-zero size. "AllocationProtect" member contains the initial protection, valid at the time when VirtualAlloc() was called. "Protect" member contains the current protection of the requested address, valid at the time when VirtualQuery() was called. So is_valid_address() function has to check "Protect" member, not the "AllocationProtect". If "State" member is MEM_FREE or MEM_RESERVE then "Protect" member is undefined. So check "State" member before "Protect" member.
* Consistently always use GetModuleHandleA() to reduce number of importsPali Rohár2025-04-281-5/+5
|
* Store kernel32.dll handle into kernel32 variablePali Rohár2025-04-281-4/+5
|
* Add proper guards for platform codePali Rohár2025-04-282-4/+13
| | | | | | | | | Do not expect that non-ARM code is automatically X86 code as it does not have to be. Returns failure (not thunk) in other case. Make sure that windows test code is not called on non-windows platforms. Test code tests/test-dladdr.c is written to be validated on any platforms, including non-windows.
* Style fixesPali Rohár2025-04-281-16/+16
|
* Fix dlclose() for dlopen(NULL, ...)Pali Rohár2025-04-281-0/+4
| | | | | dlopen(NULL, ...) does not call LoadLibrary(), so do not call FreeLibrary() in dlclose() for this case.
* Merge pull request #117 from dlfcn-win32/traversaro-patch-2v1.4.2Silvio Traversaro2025-03-041-1/+1
|\ | | | | Fix compatibility with CMake 4.0 by bumping policy_max in cmake_minimum_required to 3.10
| * Bump policy_max in cmake_minimum_required to 3.10traversaro-patch-2Silvio Traversaro2025-03-041-1/+1
|/
* Merge pull request #110 from dlfcn-win32/traversaro-patch-1Silvio Traversaro2023-07-301-1/+2
|\ | | | | Add some contributors
| * Add some contributorstraversaro-patch-1Silvio Traversaro2023-05-251-1/+2
| |
* | Merge pull request #111 from pali/masterv1.4.1Silvio Traversaro2023-07-041-1/+1
|\ \ | |/ |/| Add missing check that section index in get_image_section() is valid
| * Add missing check that section index in get_image_section() is validPali Rohár2023-07-031-1/+1
|/ | | | Number is stored in NumberOfRvaAndSizes and it may be less than IMAGE_NUMBEROF_DIRECTORY_ENTRIES.
* Merge pull request #109 from dlfcn-win32/updatecontribv1.4.0Silvio Traversaro2023-05-252-12/+21
|\ | | | | Cleanup README and add CODEOWNERS file
| * Cleanup README and add CODEOWNERS fileSilvio Traversaro2023-05-252-12/+21
|/
* Merge pull request #108 from pali/masterSilvio Traversaro2023-05-251-7/+32
|\ | | | | Fix compilation with older SDK and older MSVC
| * Fix compilation with the first NT SDKPali Rohár2023-05-211-0/+13
| | | | | | | | | | First NT SDK available in the first 32-bit MSVC NT compiler does not provide some defines. Add them for compatibility.
| * Fix compilation with old MSVC compilerPali Rohár2023-05-211-0/+12
| | | | | | | | | | Old pre-4.0 MSVC does not support _ReturnAddress() intrinsic. Provide for it simple implementation via inline assembly.
| * Fix compilation with older SDKPali Rohár2023-05-211-7/+7
|/ | | | | | | | | | | | | | Do not use SIZE_T which is not defined in older SDK. There is only size_t type, so use it instead. Do not use IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR which is not defined in older SDK. Use IMAGE_NUMBEROF_DIRECTORY_ENTRIES macro for checking if directory index is valid. In all SDKs is DataDirectory[] array size defined from IMAGE_NUMBEROF_DIRECTORY_ENTRIES macro. Cast members in IMAGE_EXPORT_DIRECTORY and IMAGE_DIRECTORY_ENTRY_IMPORT to DWORD as in older SDK they are defined as PDWORD and compiler throws error 'cannot add two pointers'.
* Merge pull request #107 from driver1998/arm64Silvio Traversaro2022-12-282-2/+71
|\ | | | | Add Windows ARM64 support
| * Add Windows ARM64 supportGH Cao2022-12-272-2/+71
|/
* Merge pull request #106 from szanni/cmake-fix-wrapper-includeSilvio Traversaro2022-12-021-1/+4
|\ | | | | Fix CMake include directive when using wrappers like meson.
| * Fix CMake include directive when using wrappers like meson.Angelo Haller2022-12-011-1/+4
|/
* Merge pull request #103 from pali/masterv1.3.1Silvio Traversaro2022-04-081-2/+8
|\ | | | | Replace magic numbers by sdk macros in get_image_section()
| * Replace magic numbers by sdk macros in get_image_section()Pali Rohár2022-03-111-2/+8
|/
* Merge pull request #102 from pali/masterSilvio Traversaro2022-01-051-7/+36
|\ | | | | Prefer usage of thread-safe function SetThreadErrorMode() instead of process-global function SetErrorMode()
| * Prefer usage of thread-safe function SetThreadErrorMode() instead of ↵Pali Rohár2021-12-211-4/+33
| | | | | | | | | | | | | | process-global function SetErrorMode() Use GetProcAddress() wrapper as SetThreadErrorMode() is not available on older Windows versions.
| * Try to avoid compile warning: cast between incompatible function types from ↵Pali Rohár2021-12-211-3/+3
|/ | | | | | ‘FARPROC’ warning: cast between incompatible function types from ‘FARPROC’ {aka ‘long long int (*)()’} to ‘BOOL (*)(DWORD, const CHAR *, struct HINSTANCE__ **)’ {aka ‘int (*)(long unsigned int, const char *, struct HINSTANCE__ **)’} [-Wcast-function-type]
* Merge pull request #99 from xantares/wineSilvio Traversaro2021-04-294-25/+9
|\ | | | | cmake: use CROSSCOMPILING_EMULATOR
| * cmake: use CROSSCOMPILING_EMULATORMichel Zou2021-04-274-25/+9
| |
* | Merge pull request #96 from xantares/patch-2Silvio Traversaro2021-04-281-1/+1
|\ \ | |/ |/| CMake: Bump version
| * CMake: Bumpr versionxantares2021-04-271-1/+1
|/ | | | Silents warnings, cmake 3.2 is available in distros since many years
* Merge pull request #98 from xantares/constSilvio Traversaro2021-04-112-10/+10
|\ | | | | dladdr: const void *addr
| * dladdr: const void *addrMichel Zou2021-04-092-10/+10
|/ | | | | on unix the addr argument seems to be const fix that for consistency
* Merge pull request #95 from pali/masterv1.3.0Silvio Traversaro2021-02-242-54/+140
|\ | | | | Various fixes
| * Fix noinline for older compiler versions (e.g. Visual Studio 6.0)Pali Rohár2021-02-031-1/+11
| | | | | | | | | | | | Visual Studio 6.0 does not support __declspec(noinline) and throw error. Add checks for compilers which support noinline to prevent compile errors.
| * Define ULONG_PTR for older SDKPali Rohár2021-02-031-0/+5
| | | | | | | | | | | | If compiling with _WIN32_WINNT target prior 0x0500 then SDK does not define ULONG_PTR type. Such systems are only 32bit so define it explicitly to 32bit type ULONG.
| * Fix MSVC 14.00 compile warning: warning C4244: '=' : conversion from ↵Pali Rohár2021-02-031-1/+1
| | | | | | | | 'ULONG_PTR' to 'char', possible loss of data
| * Add helper function MyGetModuleHandleFromAddress()Pali Rohár2021-02-031-7/+57
| | | | | | | | | | | | | | | | | | | | This function implements calling GetModuleHandleExA() with correct flags to retrieve hModule from passed address. To allow compilation also with older compilers and environments (like WDK) with any _WIN32_WINNT value, retrieve pointer to this function via GetProcAddress(). And as a fallback implementation use old code via VirtualQuery() which was there prior commit 8ec5ffef2eca.
| * Fix helper function MyEnumProcessModules()Pali Rohár2021-02-031-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Call SetErrorMode(SEM_FAILCRITICALERRORS) prior opening Psapi.dll library to avoid GUI error messages. Close Psapi.dll library via FreeLibrary() if symbol was not retrieved to prevent possible memory leaks. Try to get K32EnumProcessModules symbol from Kernel32.dll library as it is preferred way how to call EnumProcessModules() on Windows 7 and newer versions. If retrieving EnumProcessModules symbol failed with both methods then do not try it again on next MyEnumProcessModules() function call.