This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: [patch]: Add MS __ImageBase symbol to 32-bit pe.em
The usual expression is:
#if defined(_M_IA64)
#pragma section(".base", long, read)
extern "C" __declspec(allocate(".base"))
const IMAGE_DOS_HEADER __ImageBase;
#else
extern "C" const IMAGE_DOS_HEADER __ImageBase;
#endif
and used like:
PIMAGE_DOS_HEADER dhd = &__ImageBase;
or:
HINSTANCE hModulehandle = (HINSTANCE)&__ImageBase; // e.g. ATL
Where __ImageBase represents the PE DOS header of a binary. This variable is not defined anywhere, nor is it documented. ATL uses this method to get the module handle (HINSTANCE) of the current process, thus it must always point to the current executable image, right? As I understand, using __ImageBase in a DLL, you will get the PE header of the executable.
I always thought it was defined by the MS compiler. So this variable is valid for mingw also?
cheers
Jerker BÃck