DLOpen: how to get the Elf32_Handle roothandle?

This forum is for general developer support questions.

DLOpen: how to get the Elf32_Handle roothandle?

Postby jaokim » Sun Nov 06, 2016 3:54 pm

In the autodoc for elf.library the DLOpen function is said to require an ELF handle:
RootHandle - The ELF handle of the program using this function.
The user program is responsible for passing this, which MUST be
a valid elf handle and MUST be this program's elf handle, plus
it must have been re-opened. The handle may be re-closed after
this call, but must be open anytime a DL#? function is called.


What is the correct way of getting this handle from my current running program?
User avatar
jaokim
Beta Tester
Beta Tester
 
Posts: 89
Joined: Sat Jun 18, 2011 1:41 am

Re: DLOpen: how to get the Elf32_Handle roothandle?

Postby salass00 » Sun Nov 06, 2016 11:28 pm

Using IDOS->GetSegListInfoTags():

Code: Select all
Elf32_Handle elfh = NULL;
IDOS->GetSegListInfoTags(seglist,
    GSLI_ElfHandle, &elfh,
    TAG_END);


The elf handle must also be reopened with IElf->OpenElfTags():

Code: Select all
elfh = IElf->OpenElfTags(
    OET_ElfHandle, elfh,
    TAG_END);


And then closed when you're done with it using:

Code: Select all
IElf->CloseElfTags(elfh,
    CET_ReClose, TRUE,
    TAG_END);


If you use libdl it takes care of all this.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 477
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 5 guests