PDA

View Full Version : Getting the current module name from the disassembler window?


DeathPum
July 7th, 2011, 10:19
Hey guys, I'm creating a plugin and I wonder if there is any function/structure that returns the name of the current module which the user is working with in the disassembler window?

Kayaker
July 7th, 2011, 20:56
I would suspect t_dump->filename for the CPU window

DeathPum
July 8th, 2011, 07:44
kayaker, thank you for your answer, it helped me to look better inside t_dump.
I just made a simple function that returns not only the name, but a pointer to the module, in case someone is interested here it is:
Code:

t_module* GetModuleBeingDisassembled()
{
t_dump *pCPUDASM = (t_dump*)Plugingetvalue(VAL_CPUDASM);
t_table *pModTable = (t_table*)Plugingetvalue(VAL_MODULES);
t_module *pModule = 0;
int i = 0;
while (i < pModTable->data.n)
{
if(!pModule)
pModule = (t_module*)pModTable->data.data;
else
{
// if module being currently debugged is found then returns it
if(pModule->codebase == pCPUDASM->base)
{
return pModule;
}
pModule++;
}
i++;
}
return NULL;
}

Kayaker
July 8th, 2011, 12:19
Thanks, code snippets are always welcome