1
0
Fork 0

DBG: get module base using a macro

This commit is contained in:
Mr. eXoDia 2014-07-07 02:37:50 +02:00
parent b5999a9780
commit 67694b087f
1 changed files with 14 additions and 3 deletions

View File

@ -988,6 +988,8 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
strcpy(modname, name);
modname[apiname-name]=0;
apiname++;
if(!strlen(apiname))
return false;
uint modbase=modbasefromname(modname);
char szModName[MAX_PATH];
if(!GetModuleFileNameEx(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH))
@ -1013,9 +1015,18 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
uint addr=(uint)GetProcAddress(mod, apiname);
if(!addr) //not found
{
uint ordinal;
if(valfromstring(apiname, &ordinal))
addr=(uint)GetProcAddress(mod, (LPCSTR)(ordinal&0xFFFF));
if(!_stricmp(apiname, "base") or !_stricmp(apiname, "imagebase") or !_stricmp(apiname, "header"))
addr=modbase;
else
{
uint ordinal;
if(valfromstring(apiname, &ordinal))
{
addr=(uint)GetProcAddress(mod, (LPCSTR)(ordinal&0xFFFF));
if(!addr and !ordinal)
addr=modbase;
}
}
}
FreeLibrary(mod);
if(addr) //found!