生成的代码不包含当前函数调用的子函数,如果要包含子函数可以使用下面的idc脚本。
猛击此处下载插件!
下面的代码来自于看雪学院:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #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("您需要选中一个函数起始地址!"); 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("正在将这个函数代码写入 %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"); } |
原创文章,转载请注明: 转载自 obaby@mars
本文标题: 《Get AsmCode Plugin For IDA》
本文链接地址: http://h4ck.org.cn/2012/06/get-asmcode-plugin-for-ida/