home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Mammon_ / entrytree_out.idc < prev    next >
Text File  |  2000-05-25  |  2KB  |  51 lines

  1.  
  2. // Entrytree_out.idc code per mammon_ ("use, steal, change, but do not claim.")
  3. // Outputs to a file a recursive tree of the calls from each entry point of the file
  4.  
  5. #include <idc.idc>
  6.  
  7. static OutputLine(ea, x, nest, OutFileH){
  8.     auto j;
  9.     for ( j = 0; j <= nest; j = j + 1) {
  10.         fprintf(OutFileH, "   ");
  11.     }
  12.     fprintf(OutFileH, atoa(ea) + " refers to " + Name(x) + " : " + atoa(x) + "\n");
  13. }
  14. static GetXrefs(ea, nest, OutFileH){
  15.     auto x;
  16.     nest = nest + 1;
  17.     x = Rfirst0(ea);
  18.     if ( x != BADADDR) {
  19.     OutputLine(ea, x, nest, OutFileH);
  20.     GetXrefs(x, nest, OutFileH);
  21.     x = Rnext0(ea,x);
  22.     }
  23.     while ( x != BADADDR) {
  24.         OutputLine(ea, x, nest, OutFileH);
  25.         GetXrefs(x, nest, OutFileH);
  26.         x = Rnext0(ea,x);
  27.     }
  28.     nest = nest - 1;
  29. }
  30.  
  31. static main(){
  32.     auto ea, x, i, nest, f_end, EPOrd, OutFileH, OutFName;
  33.     nest = -1;
  34.     OutFName = AskStr("ida_out.txt", "Enter output filename: ");
  35.     OutFileH = fopen(OutFName, "wt");
  36.     fprintf(OutFileH, "\n*** Code References from " + GetFunctionName(ea) + " : "  + atoa(ea) + "\n");
  37.     for ( i = 0; i < GetEntryPointQty(); i = i + 1) {
  38.         fprintf(OutFileH, "Entry Point " + ltoa(i, 10) + "\n");
  39.         EPOrd = GetEntryOrdinal(i);
  40.         ea = GetEntryPoint(EPOrd);
  41.         f_end = FindFuncEnd(ea);
  42.         for ( ea ; ea <= f_end; ea = NextAddr(ea) ) {
  43.             GetXrefs(ea, nest, OutFileH);
  44.         }
  45.     }
  46.     fclose (OutFileH);
  47.     Message("End of output. \n");
  48. }
  49.  
  50.  
  51.