Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done Reset STD_INPUT_HANDLE after running an external.

May
12,930
170
Some (ill-behaved?) externals apparently monkey with the mode of STD_INPUT_HANDLE (see this thread). I suggest TCC reset the mode after running an external app.
 
How many externals? I mean, if it's just the one, hacking around it with an alias might make more sense than changing TCC.
 
How many externals? I mean, if it's just the one, hacking around it with an alias might make more sense than changing TCC.
Just one for now. I reckon it's a one-liner and probably wouldn't hurt TCC a bit. That beats users having to deal with it.

The kludge/fix works pretty well as POST_EXEC. That'd be a one-line plugin POST_EXEC and no doubt faster. But I figure I could dream up batch scenarios (albeit contrived ones) where POST_EXEC wouldn't be sufficient.
 
TCC already resets STDIN after an external.

Code:
        aGlobals.hSTDIN = GetStdHandle( STD_INPUT_HANDLE );

        // get hidden console mode flags
        GetConsoleMode( aGlobals.hSTDIN, &dwSTDINFlags );
        // turn off mouse input and window input
        dwSTDINFlags = ( dwSTDINFlags | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT ) & ~( ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT );
        SetConsoleMode( aGlobals.hSTDIN, dwSTDINFlags );
 
TCC already resets STDIN after an external.

Code:
        aGlobals.hSTDIN = GetStdHandle( STD_INPUT_HANDLE );

        // get hidden console mode flags
        GetConsoleMode( aGlobals.hSTDIN, &dwSTDINFlags );
        // turn off mouse input and window input
        dwSTDINFlags = ( dwSTDINFlags | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT ) & ~( ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT );
        SetConsoleMode( aGlobals.hSTDIN, dwSTDINFlags );

Like that, only clear ENABLE_VIRTUAL_TERMINAL_INPUT as well.
 
dwSTDINFlags = ( dwSTDINFlags | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT ) & ~( ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT ); SetConsoleMode( aGlobals.hSTDIN, dwSTDINFlags );
Aha! That explains it. I've been working on a CONMODE.EXE to query/manipulate the mode flags for CONIN$ and CONOUT$. In my testing, if I set
ENABLE_WINDOW_INPUT or ENABLE_MOUSE_INPUT they were set successfully and remained set while my app was running. But they were gone (no longer mysteriously) when I queried them in a new instance of my app.
 
Back
Top