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.

  • 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 Sep 14 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 Sep 14 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 Sep 14 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 Sep 14 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 Sep 14 at 13:45
up vote 5 down vote accepted

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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