aboutsummaryrefslogtreecommitdiff
path: root/testdll2.c
diff options
context:
space:
mode:
Diffstat (limited to 'testdll2.c')
-rw-r--r--testdll2.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/testdll2.c b/testdll2.c
new file mode 100644
index 0000000..910c820
--- /dev/null
+++ b/testdll2.c
@@ -0,0 +1,55 @@
1/*
2 * dlfcn-win32
3 * Copyright (c) 2007 Ramiro Polla
4 * Copyright (c) 2019 Pali Rohár <pali.rohar@gmail.com>
5 *
6 * dlfcn-win32 is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * dlfcn-win32 is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with dlfcn-win32; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifdef _DEBUG
22#define _CRTDBG_MAP_ALLOC
23#include <stdlib.h>
24#include <crtdbg.h>
25#endif
26#include <stdio.h>
27
28#include "dlfcn.h"
29
30#if defined(_WIN32)
31#define EXPORT __declspec(dllexport)
32#else
33#define EXPORT
34#endif
35
36EXPORT int function2( void )
37{
38 char *error;
39 int (*function2_orig)(void);
40 printf( "Hello, world! from wrapper library\n" );
41 function2_orig = dlsym(RTLD_NEXT, "function2");
42 if (!function2_orig)
43 {
44 error = dlerror( );
45 printf( "ERROR\tCould not get symbol from RTLD_NEXT handle: %s\n",
46 error ? error : "" );
47 return 1;
48 }
49 if (function2_orig() != 0)
50 {
51 printf( "ERROR\tOriginal function from RTLD_NEXT handle did not return correct value\n" );
52 return 1;
53 }
54 return 2;
55}