1. #include <idc.idc>
  2. // 1 = Success, 0 = Failure
  3. static RenameFunc( dwAddress, sFunction )
  4. {
  5. auto dwRet;
  6. dwRet = MakeNameEx( dwAddress, sFunction, SN_NOWARN );
  7. if( dwRet == 0 )
  8. {
  9. auto sTemp, i;
  10. for( i = 0; i < 32; i++ )
  11. {
  12. sTemp = form( "%s_%i", sFunction, i );
  13. if( ( dwRet = MakeNameEx( dwAddress, sTemp, SN_NOWARN ) ) != 0 )
  14. {
  15. Message( "Info: Renamed to %s instead of %s\n", sTemp, sFunction );
  16. break;
  17. }
  18. }
  19. }
  20. return dwRet;
  21. }
  22. static LabelScripts( funcOffset )
  23. {
  24. auto xref;
  25. xref = RfirstB( funcOffset );
  26. do
  27. {
  28. auto nameArrPtr, funcArrPtr, funcName, iterVal, iterInc, iterMax;
  29. iterVal = 0;
  30. iterMax = GetOperandValue( NextHead ( NextHead( xref, NextFunction( xref ) ), NextFunction( xref ) ), 1);
  31. iterInc = GetOperandValue( NextHead ( xref, NextFunction( xref ) ), 1);
  32. nameArrPtr = GetOperandValue( PrevHead ( xref, PrevFunction( xref ) ), 1);
  33. funcArrPtr = GetOperandValue( PrevHead ( PrevHead( xref, PrevFunction( xref ) ), PrevFunction( xref ) ), 1);
  34. //Message("Name Array: %x Pointer Array: %x Iteration Increment: %d Iteration Max: %d\n", nameArrPtr, funcArrPtr, iterInc, iterMax);
  35. do
  36. {
  37. auto name, func;
  38. func = Dword( funcArrPtr + iterVal );
  39. name = GetString( Dword( nameArrPtr + iterVal ), -1, 0 );
  40. Message( "0x%08X \"Script_%s\"\n", func, name );
  41. MakeName( func, form( "Script_%s", name ) );
  42. iterVal = iterVal + iterInc;
  43. } while ( iterVal < iterMax );
  44. } while ( (xref = RnextB( funcOffset, xref )) != -1 );
  45. }
  46. #define FrameScript__RegisterFunction 0x00704120
  47. static main()
  48. {
  49. LabelScripts( FrameScript__RegisterFunction );
  50. }