Guest User

Label VSH

a guest
May 25th, 2014
223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <idc.idc>
  2.  
  3. static CreateStructure(name) {
  4.   auto id;
  5.  
  6.   Message(form("Creating structure %s\n", name));
  7.  
  8.   id = GetStrucIdByName(name);
  9.   if (id != -1) {
  10.     Message(form("Structure %s already exists. Renaming it\n", name));
  11.     if (SetStrucName(id, form("%s_renamed", name)) == 0) {
  12.       Message(form("Structure %s_renamed already exists. deleting existing structure\n", name));
  13.       DelStruc(id);
  14.     }
  15.     id = -1;
  16.   }
  17.   id = AddStrucEx(-1, name, 0);
  18.   if (id == -1) {
  19.     Message (form("Error creating %s structure\n", name));
  20.     return 0;
  21.   }
  22.  
  23.   return id;
  24. }
  25.  
  26. static CreateSettingStructure()
  27. {
  28.     auto id = CreateStructure("PS3Setting_s");
  29.  
  30.     AddStrucMember(id, "index", 0x00, FF_DWRD | FF_0OFF, 0, 4);
  31.     AddStrucMember(id, "name", 0x04, FF_DWRD | FF_0OFF, 0, 4);
  32.     AddStrucMember(id, "unk0", 0x08, FF_DWRD | FF_0OFF, 0, 4);
  33.     AddStrucMember(id, "unk1", 0x0C, FF_BYTE | FF_0OFF, 0, 1);
  34.     AddStrucMember(id, "default", 0x10, FF_DWRD | FF_0OFF, 0, 4);
  35.     AddStrucMember(id, "type", 0x14, FF_DWRD | FF_0OFF, 0, 4);
  36.     AddStrucMember(id, "unk2", 0x18, FF_DWRD | FF_0OFF, 0, 4);
  37. }
  38.  
  39. static main()
  40. {
  41.     auto string, settings;
  42.    
  43.     string = FindBinary(0x10000, SEARCH_DOWN|SEARCH_CASE, "70 61 73 73 77 6F  72 64 4E 75 6D 62 65 72");
  44.    
  45.     if (string != BADADDR)
  46.     {
  47.         CreateSettingStructure();
  48.         string = string - 0x12;
  49.        
  50.         settings = FindBinary(0x10000, SEARCH_DOWN|SEARCH_CASE, sprintf("%08X", string));
  51.        
  52.         if (settings == BADADDR)
  53.         {
  54.             Message("Could not find settings array.\n");
  55.             return;
  56.         }
  57.        
  58.         settings = settings - 4;
  59.        
  60.         while (1)
  61.         {
  62.             MakeUnknown(settings, 0x1C, DOUNK_SIMPLE);
  63.             MakeStructEx(settings, 0x1C, "PS3Setting_s");
  64.             settings = settings + 0x1C;
  65.            
  66.             if (Dword(settings + 4) == 0)
  67.             {
  68.                 Message("Done\n");
  69.                 return;
  70.             }
  71.         }
  72.        
  73.         return;
  74.     }
  75.    
  76.     Message("Could not find reference string.\n");
  77. }
RAW Paste Data