diff options
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -2,6 +2,7 @@ | |||
2 | * dlfcn-win32 | 2 | * dlfcn-win32 |
3 | * Copyright (c) 2007-2009 Ramiro Polla | 3 | * Copyright (c) 2007-2009 Ramiro Polla |
4 | * Copyright (c) 2014 Tiancheng "Timothy" Gu | 4 | * Copyright (c) 2014 Tiancheng "Timothy" Gu |
5 | * Copyright (c) 2019 Pali Rohár <pali.rohar@gmail.com> | ||
5 | * | 6 | * |
6 | * dlfcn-win32 is free software; you can redistribute it and/or | 7 | * dlfcn-win32 is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public | 8 | * modify it under the terms of the GNU Lesser General Public |
@@ -25,6 +26,7 @@ | |||
25 | #endif | 26 | #endif |
26 | #include <stdio.h> | 27 | #include <stdio.h> |
27 | #include <string.h> | 28 | #include <string.h> |
29 | #include <windows.h> | ||
28 | #include "dlfcn.h" | 30 | #include "dlfcn.h" |
29 | 31 | ||
30 | /* If these dlclose's fails, we don't care as the handles are going to be | 32 | /* If these dlclose's fails, we don't care as the handles are going to be |
@@ -77,6 +79,7 @@ int main() | |||
77 | size_t (*fwrite_local) ( const void *, size_t, size_t, FILE * ); | 79 | size_t (*fwrite_local) ( const void *, size_t, size_t, FILE * ); |
78 | int (*nonexistentfunction)( void ); | 80 | int (*nonexistentfunction)( void ); |
79 | int ret; | 81 | int ret; |
82 | HMODULE library3; | ||
80 | 83 | ||
81 | #ifdef _DEBUG | 84 | #ifdef _DEBUG |
82 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); | 85 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
@@ -335,6 +338,15 @@ int main() | |||
335 | printf("SUCCESS\tGot symbol from global handle: %p\n", function); | 338 | printf("SUCCESS\tGot symbol from global handle: %p\n", function); |
336 | 339 | ||
337 | 340 | ||
341 | library3 = LoadLibraryA("testdll3.dll"); | ||
342 | if (!library3) | ||
343 | { | ||
344 | printf( "ERROR\tCould not open library3 via WINAPI\n" ); | ||
345 | RETURN_ERROR; | ||
346 | } | ||
347 | else | ||
348 | printf( "SUCCESS\tOpened library3 via WINAPI: %p\n", library3 ); | ||
349 | |||
338 | ret = dlclose( library ); | 350 | ret = dlclose( library ); |
339 | if( ret ) | 351 | if( ret ) |
340 | { | 352 | { |
@@ -346,6 +358,21 @@ int main() | |||
346 | else | 358 | else |
347 | printf( "SUCCESS\tClosed library.\n" ); | 359 | printf( "SUCCESS\tClosed library.\n" ); |
348 | 360 | ||
361 | function = dlsym(global, "function3"); | ||
362 | if (!function) | ||
363 | { | ||
364 | error = dlerror(); | ||
365 | printf("ERROR\tCould not get symbol from global handle: %s\n", | ||
366 | error ? error : ""); | ||
367 | CLOSE_LIB; | ||
368 | CLOSE_GLOBAL; | ||
369 | RETURN_ERROR; | ||
370 | } | ||
371 | else | ||
372 | printf("SUCCESS\tGot symbol from global handle: %p\n", function); | ||
373 | |||
374 | RUNFUNC; | ||
375 | |||
349 | ret = dlclose( global ); | 376 | ret = dlclose( global ); |
350 | if( ret ) | 377 | if( ret ) |
351 | { | 378 | { |