Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 1.41 KB | Hits: 16 | Expires: Never
Copy text to clipboard
  1. // ida xref call info dumper
  2.  
  3. #include "idc.idc"
  4.  
  5. static GetRegisterValue( ea, name )
  6. {
  7.         auto p1, opname, loop, optype, opvalue, stroffset;
  8.         opname = "";
  9.         p1 = ea;
  10.         loop = 0;
  11.         while( opname != name )
  12.         {
  13.                 p1 = PrevHead( p1, 0 );
  14.                 opname = GetOpnd( p1, 0 );
  15.                 loop = loop+1;
  16.                 if (loop > 100)
  17.                 {
  18.                         Message("safe loop");
  19.                         return "unk";
  20.                 }
  21.         }
  22.        
  23.         optype = GetOpType( p1, 1 );
  24.         //Message("optype: %d  ", optype);
  25.        
  26.         // this type needs some extra work
  27.         if (optype == 2)
  28.         {
  29.                 opvalue = GetOpnd( p1, 1 );
  30.                 stroffset = strstr( opvalue, "=0x");
  31.                 return substr( opvalue, stroffset + 3, strlen(opvalue));
  32.         }
  33.        
  34.         return ltoa( GetOperandValue( p1, 1 ), 16);
  35. }
  36.  
  37. static main() {
  38.   auto ea,flag,x,y;
  39.   auto functname;
  40.   flag = 1;
  41.   ea = ScreenEA();
  42.  
  43.         // currently used for remote rpc calls but it can be used for everything
  44.         Message( "\ncall            prog            proc           msg\n");
  45.         for ( x=RfirstB( ea ); x != BADADDR; x=RnextB(ea,x) )
  46.         {
  47.                 functname = GetFunctionName( x );
  48.                
  49.                 // normal operation
  50.                 //Message( "%-75.75s", functname );
  51.                 //Message( GetRegisterValue(x, "R1") + "    " + GetRegisterValue(x, "R3") + "    " + GetRegisterValue(x, "R2") + "\n");
  52.                
  53.                 // generate wiki
  54.                 Message("|                                || 0x%-11.11s|| 0x%02s, 0x%s || %s\n",  GetRegisterValue(x, "R1"), GetRegisterValue(x, "R3"), GetRegisterValue(x, "R2"), functname);
  55.                 Message("|-\n");
  56.         }
  57. }