Page 1 of 1

DLOpen: how to get the Elf32_Handle roothandle?

Posted: Sun Nov 06, 2016 2:54 pm
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?

Re: DLOpen: how to get the Elf32_Handle roothandle?

Posted: Sun Nov 06, 2016 10:28 pm
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.