Disassembly c++/c determine the location of the main function

Source: Internet
Author: User

When loading a file with OD, it will not stay on the main function, how to determine main the location, which needs to have a knowledge of the program loading process.
Using IDA, you can precisely position main the starting position of a function.

void __cdecl Start () {DWORD V0;//eax@1  intv1;//eax@4V0= GetVersion (); DWORD_4101A4 = BYTE1 (v0); dword_4101a0= V0; dword_41019c = BYTE1 (v0) + (V0<<8); dword_410198 = V0>> -;if(!sub_4068ee (0)) Fast_error_exit (0x1Cu);  _ioinit (); dword_411704 =*getcommandlinea*();  dword_41017c = __crtgetenvironmentstringsa ();  _SETARGV ();  _SETENVP ();  _cinit ();  Dword_4101b8 = ENVP; V1 = Main (argc, argv, ENVP);Exit(v1);}

As you can see, there is a lot of initialization work before the main function starts. OD is not fully recognized, the only function that can be recognized is GetCommandLine that after this function is executed, it is common to call 4 functions again __crtGetEnviromentStrings、setargv、setenvp、cinit before executing the main function.

Therefore, as long as you skip 4 functions after getcommandline, you can generally reach main the position of the function.

If you do not want to use the IDA loader to get the main function location, use this method to quickly find the main function. is not skipped 4, generally with the compiler has a great relationship, so, this method can only be counted as experience accumulation.

Disassembly c++/c determine the location of the main function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.