Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't flash (open/close) a console on Windows #433

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sredna
Copy link
Contributor

@sredna sredna commented Feb 2, 2022

The console code tries to determine if it has a real console by calling AllocConsole but this will briefly show a console window in the non-debugger version. GetConsoleMode does not work on redirected handles, it is a much better choice.

This only checks if stdout is connected to a real console, it does not check stdin on purpose. This should in theory allow something like sameboy_debugger.exe < commands_to_execute.txt.

@sredna
Copy link
Contributor Author

sredna commented Mar 23, 2022

Just in case there is some doubt about using this technique, MSDN says:

...determine whether the output handle is a console handle (one method is to call the GetConsoleMode function and check whether it succeeds).

@LIJI32 LIJI32 force-pushed the master branch 4 times, most recently from 4ebe973 to 0989ee2 Compare December 30, 2022 17:45
GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &output_mode);
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_VIRTUAL_TERMINAL_INPUT);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_WRAP_AT_EOL_OUTPUT | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
has_con_input = GetConsoleMode(hSI, &input_mode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this is not used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants