Is there a way to GetModuleHandle(NULL) on Linux to be able to pass that handle into dlsym 3
Asked
Active
Viewed 5,035 times
5
Josh Darnell
- 11,304
- 9
- 38
- 66
user877329
- 6,717
- 8
- 46
- 88
2 Answers
11
The documentation for dlopen(3) states:
The function
dlopen()loads the dynamic library file named by the null-terminated stringfilenameand returns an opaque "handle" for the dynamic library. IffilenameisNULL, then the returned handle is for the main program.
Therefore, you can use the value returned by dlopen(NULL) as the handle argument to dlsym().
Frédéric Hamidi
- 258,201
- 41
- 486
- 479
2
dlopen(NULL) will give you a handle for the executable.
Ignacio Vazquez-Abrams
- 776,304
- 153
- 1,341
- 1,358