cons: fix Windows console VT mode save and restore#6169
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
519729a to
40466ea
Compare
wargio
reviewed
Apr 8, 2026
Member
wargio
left a comment
There was a problem hiding this comment.
this is ok, but when we refactor the tui code, we need a way to handle all these globals.
wargio
approved these changes
Apr 8, 2026
wargio
reviewed
Apr 8, 2026
40466ea to
2d0a689
Compare
2606ba1 to
bcb19b4
Compare
Rot127
approved these changes
Apr 9, 2026
bcb19b4 to
ccd0249
Compare
a699be4 to
ea4c935
Compare
ea4c935 to
10119aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title:
cons: fix Windows console VT mode save and restoreYour checklist for this pull request
RZ_APIfunction and struct this PR changes.RZ_API).Detailed description
this pr fixes win console mode handling during rizin startup and teardown. (related to #6166)
while testing the table query changes in win in
meson devenv, rizin would complete the requested cmd but still leave the terminal in a bad state and print:the root problem was in the shared win console lifecycle, not in any specific cmd.
this pr keeps the fix limited to the console code paths that actually own and mutate win console state:
librz/cons/cons.clibrz/cons/input.clibrz/core/cconfig.cthe changes are:
save the original console state before VT probing mutates it.
previously, the saved console mode could already reflect side effects from early VT detection. that makes later restore unreliable because the stored state is no longer the real original host state.
restore only the console mode bits Rizin actually owns.
previously, the restore path replayed the full saved mode word. in win, this is fragile, esp. when running under nested shells or
meson devenv, because it may overwrite flags owned by the hosting console instead of only undoing rizin’s own changes.fix VT input enabling in
scr_vtmode().the old code used
mode & ENABLE_VIRTUAL_TERMINAL_INPUT, which effectively stripped other input flags instead of enabling VT input. this pr changes that to the flag preserving behavior.avoid temporary input mode writes on non console stdin.
some temporary console mode transitions assumed stdin was always a valid console handle. this pr guards those paths so batch or redirected runs do not try to call
SetConsoleMode()on non-console input.the idea behind the patch is to fix the shared console state contract directly.
Test plan
verified on win after building
Closing issues
N/A