DLOpen: how to get the Elf32_Handle roothandle?

This forum is for general developer support questions.
Post Reply
User avatar
jaokim
Beta Tester
Beta Tester
Posts: 90
Joined: Sat Jun 18, 2011 12:41 am

DLOpen: how to get the Elf32_Handle roothandle?

Post by jaokim »

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
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: DLOpen: how to get the Elf32_Handle roothandle?

Post by salass00 »

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.
Post Reply