-
[Ida Script] Vanilla - MOP
Hello everyone,
I found this script on OwnedCore and wanted to provide an updated version that supports multiple expansions, from Vanilla to Mists of Pandaria (MoP). This enhanced script is designed to dump Lua functions across all these patches, which can be a huge help for anyone interested in working with these specific game versions.
It's an IDC script intended for use in IDA (Interactive Disassembler), allowing you to extract and rename Lua functions from various patches of the game efficiently. Whether you're working on a project for research, modding, or just exploring how Lua functions are implemented across different WoW expansions, this script should make the process much smoother.
Hopefully, it comes in handy for anyone looking to work with these patches!
This will work on x86, i will update post once i finish 64bit versions from MOP onword.
Code:
#include <idc.idc>
static RenameFunc( dwAddress, sFunction )
{
auto dwRet;
auto part = substr( GetFunctionName( dwAddress ), 0, 7 );
if ( part != "Script_" )
{
auto oldName = GetFunctionName( dwAddress );
dwRet = MakeNameEx( dwAddress, sFunction, SN_NOWARN );
if( dwRet == 0 )
{
auto sTemp, i;
for( i = 1; i < 32; i++ )
{
sTemp = form( "%s_%i", sFunction, i );
if( ( dwRet = MakeNameEx( dwAddress, sTemp, SN_NOWARN ) ) != 0 )
break;
}
}
else if (oldName != "")
Message("Lua function renamed: '%s' -> '%s'\n", oldName, sFunction);
}
return dwRet;
}
static Luafunc_GetName( structAddr )
{
return GetString( Dword( structAddr ), -1, ASCSTR_C );
}
static Luafunc_GetFunc( structAddr )
{
return Dword( structAddr + 4 );
}
static HandleLuaFunc( structBase )
{
auto funcName, funcAddr;
funcName = Luafunc_GetName( structBase );
funcAddr = Luafunc_GetFunc( structBase );
RenameFunc( funcAddr, form( "Script_%s", funcName ) );
}
static RenameLuaFunctionsByReference(registerFunc, structBaseOffset, numFuncOffset)
{
auto xRef;
if(registerFunc == BADADDR)
{
Warning("You do not have a function 0x%x\n");
return;
}
for( xRef = RfirstB( registerFunc ); xRef != BADADDR; xRef = RnextB( registerFunc, xRef ) )
{
auto structBase;
auto numFuncs, i;
structBase = Dword(xRef - structBaseOffset);
numFuncs = GetOperandValue( xRef + numFuncOffset, 1 ) / 4;
if(numFuncs == 0)
numFuncs = 1;
//Message( "xref 0x%x - structBase 0x%x - numfuc %d\n",xRef, structBase, numFuncs);
if ( numFuncs < 1000 && numFuncs > 0)
{
for ( i = 0; i < numFuncs; i++ )
{
HandleLuaFunc(structBase);
structBase = structBase + 0x4;
}
}
}
}
// Vanilla 1.12.1
// luaRegister = 0x704120;
// structBaseOffset = 0x4;
// numFuncOffset = 0x8;
// TBC 2.4.3
// luaRegister = 0x7059B0;
// structBaseOffset = 0x6;
// numFuncOffset = 0xB;
// WOTLK 3.3.5A
// luaRegister = 0x817F90;
// structBaseOffset = 0x6;
// numFuncOffset = 0xB;
// Cata 4.3.4
// luaRegister = 0x83B030;
// structBaseOffset = 0x6;
// numFuncOffset = 0xB;
// MOP 5.4.8
// luaRegister = 0x44ED93;
// structBaseOffset = 0x4;
// numFuncOffset = 0xA;
static main()
{
RenameLuaFunctionsByReference(0x44ED93, 0x4, 0xA);
}
-
Post Thanks / Like - 1 Thanks
Corthezz (1 members gave Thanks to Makkah for this useful post)