crt0.c
Beware - the crt0*.c files are a tad on the unreadable side ;)
Printable View
crt0.c
Beware - the crt0*.c files are a tad on the unreadable side ;)
I know, I already scanned through them :)
But I followed the code of the BaseCRTStartup (mainCRTStartup, wmainCRTStartup, WinMainCRTStartup and wWinMainCRTStartup) including subfunctions already and still can't find the place where AllocConsole is called...
Use Find Files and search for anything with the text AllocConsole :)
Well, it doesn't find it. I searched the whole VC98 directory, and all it found was the declaration in wincon.h.
I searched the whole Visual Studio tree. It's in WINCON.h, which is no help.
It's also in NCB files, and in compiled projects in .pch files.
This explains how it gets into the project, sort of. The compiler must be pulling the reference in the .ncb file.
No source declaration anywhere.
Ooooohhhhh...
You want the source? Too bad, it's an API function :D
I thought you wanted to know where it was actually called.
Yes I do want the place where it is called. I know that I don't get the source of the API. But I searched my whole VC++ directory including CRT source, MFC source and all includes for the text "AllocConsole", and the only place I found it was the API declaration in wincon.h. No call to it anywhere.
*looks carefully at the .exe file format*
It appears that there is a value there which decides whether Windows itself allocates a console before running the program.
Have a look on MSDN at "peering inside the PE file format". So you can theoretically change a single value (unless the file has a checksum in which case you'd have to reset that) and your program would no longer have a console.
So it's just the linker option /subsystem:[windows/console]
I somehow suspected that, but I wasn't sure.
The interesting thing is, why does a project started in VC++ set this option? If it is not set, VC++ determines the type of app automatically by searching for main and WinMain: main -> console
WinMain -> windows.
Anyway, this search has shown me how to find out if any console is runnning: the window is always of the class "tty".
tty is the standard unix console device - that is where C got it from. Stands for teletype. I'm giving away my age here....
120? :D
I didn't know the exact meaning of TTY but I knew where it comes from. I use such apps like PuTTY to contact my linux server...
Is this new with VC++6 or something? With mine the linker settings are setup depending on what project type you created.Quote:
Originally posted by CornedBee
So it's just the linker option /subsystem:[windows/console]
I somehow suspected that, but I wasn't sure.
The interesting thing is, why does a project started in VC++ set this option? If it is not set, VC++ determines the type of app automatically by searching for main and WinMain: main -> console
WinMain -> windows.
Anyway, this search has shown me how to find out if any console is runnning: the window is always of the class "tty".
Yes, the linker setting depends on the project type. But Jeffrey Richter said in his book that if you remove the setting, VC++ will search for the startup functions and react accordingly.