Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find an application's entry point in Visual Studio (C++)

The question may apply to any programming language written in Visual Studio, but I am more concerned about C++.

Is there a way to easily determine the application entry point in Visual Studio?

For a relatively small application this could be easy, but for large ones, it will be pretty hard. In my particular case I know that the project which is set as startup is the one which has the entry point, but I was unable to find it, even though the application starts and runs well.

like image 502
meJustAndrew Avatar asked Aug 17 '16 15:08

meJustAndrew


People also ask

How do I change the entry point in Visual Studio?

Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > Linker > Advanced property page. Modify the Entry Point property.

Which function is the entry point of a C++ program?

The main function ( main() ) is the entry point to a C/C++ program and is called when the application starts executing. Calls to other functions, for example from the main function, provide entry points to function code. Program control is transferred to the called function.

What is WinMain function?

The WinMain function is identical to wWinMain, except the command-line arguments are passed as an ANSI string. The Unicode version is preferred. You can use the ANSI WinMain function even if you compile your program as Unicode. To get a Unicode copy of the command-line arguments, call the GetCommandLine function.


2 Answers

If you want to find what C++ project is executable than search for <ConfigurationType>Application</ConfigurationType> in all your *.vcxproj files.

If you are looking for the entry point function inside this application, than search for main, wmain or WinMain functions.

Also entry point can be redefined with /ENTRY parameter, so you can check Configuration Properties > Linker > Advanced > Entry Point project parameter or search for /ENTRY in your *.vcxproj.

like image 72
Nikita Avatar answered Sep 21 '22 01:09

Nikita


In C++, a fully compiled program can have only one defined main method. If there's more than one, the compiler will complain about "multiple definitions of main" or some other similarly worded message.

So, the simplest option is to do a search for the symbol main (or, if compiling as a Windows Subsystem program, WinMain) and figure out which ones correspond to the "startup" project. There shouldn't be that many, even in a relatively large solution.

like image 26
Xirema Avatar answered Sep 19 '22 01:09

Xirema