Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetModuleHandle(NULL) on Linux

Tags:

linux

Is there a way to GetModuleHandle(NULL) on Linux to be able to pass that handle into dlsym 3

like image 229
user877329 Avatar asked Aug 07 '11 10:08

user877329


2 Answers

The documentation for dlopen(3) states:

The function dlopen() loads the dynamic library file named by the null-terminated string filename and returns an opaque "handle" for the dynamic library. If filename is NULL, 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().

like image 84
Frédéric Hamidi Avatar answered Nov 20 '22 23:11

Frédéric Hamidi


dlopen(NULL) will give you a handle for the executable.

like image 39
Ignacio Vazquez-Abrams Avatar answered Nov 20 '22 22:11

Ignacio Vazquez-Abrams