Hi all,
i've successfully get the GCC instrument functions functional with MSYS/MinGW. When i use instrument functions I only have the pointer as reference of the module, which has invoked the instrument function...
Now I try to get more detailed information of the module. Using Linux OS i could use the dladdr function to grab the name of the module. But this method is part of the dlfcn header which is not included in MSYS/MinGW.
By this reason I've tried to implement a win32 wrapper using win32 API methods (GetModuleFileNameA), but i fail. I only got the path to the execution file as module name instead of the method. Following the specification of the win32 API this only should happend if the module handle is invalid (NULL), but it is valid ...
void dladdrWrapper(void *addr){
printf("Enter testprint!\n");
MEMORY_BASIC_INFORMATION mbi;
HMODULE hMod;
if (!VirtualQuery (addr, &mbi, sizeof (mbi)))
{
printf("VirtualQuery call failed!");
exit(1);
}
hMod = (HMODULE) mbi.AllocationBase;
char module_name[MAX_PATH];
printf("HMODULE: %p\n", hMod);
if (!GetModuleFileNameA (hMod, module_name, sizeof (module_name)))
{
printf("GetModuleFileNameA call failed!");
exit(1);
}
printf("Identfied module name: %s\n", module_name);
printf("Exit testprint\n");
}
Has anyone successfully request the module name of the instruction function caller using a dladdr win32 API call wrapper or get the dladdr runable with MSYS/MinGW ?
Thanks for any hint. Best regards, Christian