Results 1 to 13 of 13

Thread: CRT startup for console

  1. #1

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    crt0.c

    Beware - the crt0*.c files are a tad on the unreadable side
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use Find Files and search for anything with the text AllocConsole
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Well, it doesn't find it. I searched the whole VC98 directory, and all it found was the declaration in wincon.h.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    jim mcnamara
    Guest
    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.

  6. #6

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Ooooohhhhh...

    You want the source? Too bad, it's an API function

    I thought you wanted to know where it was actually called.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    *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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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".
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    jim mcnamara
    Guest
    tty is the standard unix console device - that is where C got it from. Stands for teletype. I'm giving away my age here....

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    120?

    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...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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".
    Is this new with VC++6 or something? With mine the linker settings are setup depending on what project type you created.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    Last edited by CornedBee; Dec 28th, 2001 at 07:33 AM.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width