0

I have a fortran dll/so which needs to know its own programhandle.

On windows, I can obtain the handle from the DLLMain routine:

integer(4) function DllMain(hInst, ul_reason_being_called, lpReserved)
  !DEC$ ATTRIBUTES STDCALL, ALIAS : 'DllMain' :: DllMain
  integer(8) hInst, ul_reason_being_called, lpReserved, program_handle 
  program_handle = hInst
  DllMain = 1
end

But as far as I understand, the DLLMain function is only called on windows. How can I obtain the handle on linux?

The dll opens a child dll that needs to call a method in the parent dll. For this purpose I need the handle of the parent dll: getprocaddress(parent_dll_handle, 'method_name')

4
  • 1
    Which handle? What do you need it for? The handle that dlopen returns? How do you open the library? Commented Oct 8 at 13:25
  • 1
    This would be better with an example use-case minimal reproducible example that shows what you mean by "handle" (do you mean the pointer returned by dlopen()?) and what you want to do with it (that you can't by simply passing a suitable function pointer as argument). Commented Oct 8 at 15:27
  • See also: stackoverflow.com/q/4651803/1216776 Commented Oct 8 at 15:38
  • Would the special handle value RTLD_NEXT work? Commented Oct 8 at 16:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.