Advertisement
fastman92

[IDC] Function renamer

Apr 5th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <idc.idc>
  2. /*
  3.     Author: fastman92
  4.    
  5.     Description: this script renames functions from the old names to the new names.
  6.     Names are specified by a list.
  7. */
  8.  
  9. class CListOfFunctionsNames
  10. {
  11.     CListOfFunctionsNames()
  12.     {
  13.         this.numberOfFunctions = 0;
  14.         this.arrayOfFunctionNames = object();
  15.     }
  16.    
  17.     Clear()
  18.     {
  19.         this.numberOfFunctions = 0;
  20.         this.arrayOfFunctionNames = object();
  21.     }
  22.    
  23.     AddMember(currentName, newName)
  24.     {
  25.         auto item = object();
  26.         item.currentName = currentName;
  27.         item.newName = newName;
  28.    
  29.         this.arrayOfFunctionNames[this.numberOfFunctions++] = item;
  30.     }
  31. }
  32.  
  33. static RenameFunctionsInOrder(list)
  34. {
  35.     auto i;
  36.    
  37.     for(i = 0; i < list.numberOfFunctions; i++)
  38.     {
  39.         auto functionInfo = list.arrayOfFunctionNames[i];
  40.         auto functionEA = LocByName(functionInfo.currentName);     
  41.        
  42.         if(functionEA == BADADDR)
  43.             Message("Item with name %s does not exist!\n", functionInfo.currentName);
  44.         else
  45.         {
  46.             if(MakeName(functionEA, functionInfo.newName))
  47.                 Message("Function %s renamed to %s\n", functionInfo.currentName, functionInfo.newName);
  48.             else
  49.                 Message("Error while trying to rename a function %s with address 0x%X\n", functionInfo.currentName, functionEA);
  50.         }
  51.     }
  52. }
  53.  
  54. static main()
  55. {
  56.     Message("\n----- bStarting a function renamer by fastman92 -----\n");
  57.  
  58.     auto list = CListOfFunctionsNames();
  59.    
  60.     list.AddMember("_sub_550170", "png_set_unknown_chunks");
  61.     list.AddMember("$CPool_CPtrNodeSingle__constructor", "png_set_unknown_chunk_location");
  62.    
  63.     // Rename functions
  64.     RenameFunctionsInOrder(&list); 
  65.  
  66.     Message("\----- Finished a function renamer by fastman92 -----\n");
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement