4

As a beginner I'm trying to disassemble a file with IDA Pro 6.8. I write some IDC script for time-consuming work.

Now, I want to get the execution time of my script, but I can not find appropriate IDC function. Are there anyone to tell me how to write script get execution time?

Thanks in advance.

5
  • 1
    If you would allow me to make a suggestion, I would highly recommend using idapython instead of idc. From what I've heard it seems easier to use/gives you all the python runtime too.
    – Abigail
    Commented Sep 14, 2018 at 4:19
  • @Abigail: there may be reasons for using IDC over Python; we should try to answer the question as asked, unless it's obviously misguided.
    – Igor Skochinsky
    Commented Sep 14, 2018 at 8:39
  • Fair enough. @user6903 you could try using call_system in IDC to get the system time somehow and wrap your functionality within calls to get the system time.
    – Abigail
    Commented Sep 14, 2018 at 9:48
  • @Abigail. I can not find call_system in the list of IDC functions for IDA Pro 6.8. You mean other version of the IDA Pro?
    – user6903
    Commented Sep 14, 2018 at 10:56
  • 1
    It's possibly called Exec in 6.8. I don't know - since I don't have IDA Pro. Since you're a customer I would try their support if nobody else here can help.
    – Abigail
    Commented Sep 14, 2018 at 13:45

1 Answer 1

5

What you could do as a workaround for the missing time-support in Ida:

IDC has an "Exec" command (as mentioned in a comment) allowing you to make arbitrary calls to the OS. This might help. In the "Exec" bracktes you enter a command in much the same way as typing it on the command line.

The following is an idc script file

  • Writing the date and time with some comment into the file C:\tmp\mytime.tim.
  • Reading this file and displying its contents to Ida's output window.

    static main()
    {
        writeTime();
    }
    
    static writeTime()
    {
        Exec ("echo Date of script run #1234 was %date% >> c:\\tmp\\mytime.tim");
        Exec ("echo Time of script run #1234 %time% >> c:\\tmp\\mytime.tim");
        print("Time written into C:\\tmp\\mytime.tim");
    
        auto h = fopen("c:\\tmp\\mytime.tim", "r");
        auto date = readstr(h);
        auto time = readstr(h);
        if (date != -1 && time != -1)
        {   
            Message("%s", date);
            Message("%s", time);
        }
        else
            Message("error\n");
        fclose(h);
    }
    

    Ida's output window shows the following:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.