Export All relational ASM in idapro (Just Copied)
yanmin (serenade) <serenadexyzgmailcom> Wednesday, January 9 2008 05:49.11 CST


#include "idc.idc"

static ElementExist(arrayid,size,val)
{
  auto i,v;
  for(i=0;i<size;i++)
  {
    v=GetArrayElement(AR_LONG,arrayid,i);
    if(v==val)
      return 1;
  }
  return 0;
}
static GenFuncIns(st,arrayid,size)
{
  auto start,end,i,ins,x,xt,funcend;
  start=st;
  end=FindFuncEnd(start);
  for(i=start;i<end;)
  {
    ins=GetDisasm(i);
    for(x=Rfirst(i);x!=BADADDR;x=Rnext(i,x))
    {
      xt=XrefType();
      if(xt == fl_CN && !ElementExist(arrayid,size,x))
      {
        SetArrayLong(arrayid,size,x);
        size++;
      }
    }
    i=ItemEnd(i);/*FindCode(i,1);*/
    //Message(form("%s\r\n",ins));
  }
  return size;
}
static main()
{
  auto arrayid,size,pos,st,file,funcend,path;
  st=ScreenEA();
  path = GetIdbPath();
  path = substr(path, 0, strlen(path) - 4) + "Part.asm";
  file=fopen(path,"w+");
  if(st==BADADDR)
  {
    Warning("Please put the cursor at a function start.");
    return;
  }
  arrayid=CreateArray("gen_func_ins");
  if(arrayid<0)
  {    
    arrayid=GetArrayId("gen_func_ins");
  }
  pos=0;
  SetArrayLong(arrayid,pos,st);
  size=1;
  for(pos=0;pos<size;pos++)
  {
    st=GetArrayElement(AR_LONG,arrayid,pos);  
    Message(form("proc:%8.8x\r\n",st));  
    funcend=FindFuncEnd(st);
    if (funcend!=BADADDR)
    {
      Message("Writing the function to %s \n",path);  
      GenerateFile(OFILE_ASM,file, st,funcend, 0);
    }
    else
    {
      Message(form("proc:%8.8x Write false\r\n",st));
    }
    size=GenFuncIns(st,arrayid,size);
  }
  DeleteArray(arrayid);
  fclose(file);
Message("All done, exiting...\n");
}


Comments
c1de0x Posted: Tuesday, January 22 2008 11:52.43 CST
cmon, commit it to http://openrce-snippets.googlecode.com !

c1de0x Posted: Tuesday, January 22 2008 11:53.23 CST
cmon, commit it to http://openrce-snippets.googlecode.com !