Repository navigation
Use NtQueryVolumeInformationFile instead of GetFileType to check if a handle references a console - #356
Conversation
|
Learn Build status updates of commit 40e5da0: 💡 Validation status: suggestions
docs/console-handles.md
For more details, please refer to the build report. Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them. |
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Dustin L. Howett (@DHowett) Leonard Hecker (@lhecker) Could you take a look? This problem affects not only the STL but also the UCRT, which also uses the inefficient GetConsoleMode. |
|
Learn Build status updates of commit a713593: 💡 Validation status: suggestions
docs/console-handles.md
docs/getconsolemode.md
For more details, please refer to the build report. Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them. |
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
Leonard Hecker (lhecker)
left a comment
There was a problem hiding this comment.
Sorry for being late! I read this on my phone after waking up one day and then promptly forgot about it lol. I think everyone knows this personally. 😄
Windows 8+ makes it possible to use `NtQueryVolumeInformationFile` to determine whether a handle is a console. `GetConsoleMode` can be 100 times slower than `NtQueryVolumeInformationFile` because inter-process communication is required. I also contacted the Windows Console team to clarify the availability of the API; see the relevant discussion at microsoft/STL#6483, MicrosoftDocs/Console-Docs#356, and rust-lang/rust#164170.
Windows 8+ makes it possible to use `NtQueryVolumeInformationFile` to determine whether a handle is a console. `GetConsoleMode` can be 100 times slower than `NtQueryVolumeInformationFile` because inter-process communication is required. I also contacted the Windows Console team to clarify the availability of the API; see the relevant discussion at microsoft/STL#6483, MicrosoftDocs/Console-Docs#356, and rust-lang/rust#164170.
Windows 8+ makes it possible to use `NtQueryVolumeInformationFile` to determine whether a handle is a console. `GetConsoleMode` can be 100 times slower than `NtQueryVolumeInformationFile` because inter-process communication is required. I also contacted the Windows Console team to clarify the availability of the API; see the relevant discussion at microsoft/STL#6483, MicrosoftDocs/Console-Docs#356, and rust-lang/rust#164170.
Windows 8+ makes it possible to use `NtQueryVolumeInformationFile` to determine whether a handle is a console. `GetConsoleMode` can be 100 times slower than `NtQueryVolumeInformationFile` because inter-process communication is required. I also contacted the Windows Console team to clarify the availability of the API; see the relevant discussion at microsoft/STL#6483, MicrosoftDocs/Console-Docs#356, and rust-lang/rust#164170. NOKEYCHECK=True GitOrigin-RevId: a865665559b2144da44a580a0fb8517d7c458fed
GetFileTypereturnsFILE_TYPE_CHARfor both handles to a console and handles toNUL, which may cause errors. See the following link for details and discussion: microsoft/STL#6483 (comment) and rust-lang/rust#164170.Many programs also use
GetConsoleMode(including STL and UCRT), which is inefficient compared toNtQueryVolumeInformationFile, so I also add a suggestion in the note ofGetConsoleMode.GetConsoleModecan be 100 times slower thanNtQueryVolumeInformationFilebecause inter-process communication is required, resulting in console output throughput being only half of the optimal.FILE_DEVICE_CONSOLEis available starting with Windows 8.