ida - idc - easyF8

#include

static getBaseAddr(ptr){
    return SegStart( ptr);
}

static printAddr(name , addr){
    Message("%s : 0x%x\n",name,addr);
}

static saveLastAddr(){
    auto nowPtr ;
    nowPtr = ScreenEA();
    auto base = getBaseAddr(nowPtr);
    printAddr("base",base);
    auto addr_offest = nowPtr - base;
    printAddr("offset",addr_offest);
    //nowPtr = nowPtr - base;
    auto fp = fopen("test.log","w");
    auto code =  GetDisasm(nowPtr);
    auto addr_str = sprintf("0x%x",nowPtr);
    //savefile(fp,0,nowPtr,8);
    Message("save last addr-> %s : %s \n", addr_str,code);
    //Message(code);
    writelong(fp,addr_offest,0);
    writestr(fp , addr_str);
    writestr(fp , "\n");
    writestr(fp,code);

    fclose(fp);
}

static loadLastAddr(){
    auto nowPtr = ScreenEA();
    auto base  = getBaseAddr(nowPtr);
    printAddr("base",base);
    auto fp = fopen("test.log","rb");
    auto offset_addr = readlong(fp,0);
    printAddr("offset_addr",offset_addr);
    auto addr = base + offset_addr;
    printAddr("addr",addr);

    //readstr(fp);
    auto addr_str = readstr(fp);
    //auto addr = sprintf("0x%s",addr_str);
    Message("load last addr: %s" +addr_str);
    auto code = readstr(fp);
    Message(code);
    Jump(addr);
    fclose(fp);
}

// static main()
// {
//     //saveLastAddr();
//     loadLastAddr();
//     return 0;
// }
ida - idc - easyF8_第1张图片
image.png

https://www.hex-rays.com/products/ida/support/idadoc/1213.shtml
https://www.cnblogs.com/0xHack/p/9399321.html

ida - idc - easyF8_第2张图片
image.png

ida - idc - easyF8_第3张图片
image.png

你可能感兴趣的:(ida - idc - easyF8)