Cxbx-Reloaded/doc/development/IDA-MissedHLF.txt

78 lines
1.8 KiB
Plaintext

Technique for locating missed interceptions. The following IDAPro script, followed by the manual
removal of functions that are detected by the HLE database, is excellent for detecting functions
that should have been intercepted but were missed.
I typically clear the IDAPro console window, run the below script, then copy the resulting struct
as a static global variable in Emu.cpp. I then use the CPP code immediately before the Xbe entry
point, which will mark all uncaught functions with a breakpoint (0xCC). Obviously this will catch
all HLE functions too, unless you remove them first. I haven't written a script to automate this
yet, so it takes a few minutes.
-caustik
<begin idapro code>
auto addr;
auto funcEnd;
auto count;
auto startAddr;
auto endAddr;
startAddr = AskAddr(0, "Input Start Address");
endAddr = AskAddr(0, "Input End Address");
addr = FindCode(startAddr, SEARCH_DOWN | SEARCH_NEXT);
count = 0;
Message("uint32 funcAddr[]=\n");
Message("{\n");
Jump(addr);
while(1)
{
count = count+1;
addr = NextFunction(addr+1);
if(addr == BADADDR || addr > endAddr)
{
break;
}
funcEnd = FindFuncEnd(addr);
Message(" 0x%.08X, // -> 0x%.08X (Size : %d bytes)\n", addr, funcEnd, funcEnd - addr);
Jump(addr);
}
Message("}\n");
</end idapro code>
<begin c code>
Where funcExclude is an array of uint32 addresses to exclude from the search...
for(int v=0;v<sizeof(funcAddr)/sizeof(uint32);v++)
{
bool bExclude = false;
for(int r=0;r<sizeof(funcExclude)/sizeof(uint32);r++)
{
if(funcAddr[v] == funcExclude[r])
{
bExclude = true;
break;
}
}
if(!bExclude)
{
*(uint08*)(funcAddr[v]) = 0xCC;
}
}
</end c code>