GetModuleHandle(NULL) on Linux

前端 未结 2 1372
借酒劲吻你
借酒劲吻你 2021-01-05 22:52

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

相关标签:
2条回答
  • 2021-01-05 23:18

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

    0 讨论(0)
  • 2021-01-05 23:40

    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().

    0 讨论(0)
提交回复
热议问题