views:

203

answers:

1

Is there any way to reliably capture all changes made to the win32 console buffer, as they happen? The idea is to convert the screen updates of a text mode app to ANSI escape sequences, for a telnet/ssh server. I need to capture cursor movements, colors, window title, etc. Mouse clicks, too, if possible.

The only technique I've seen used for this so far is to basically take frequent snapshots of console buffer contents, and compare to a previous snapshot. If there are changes, then figure out what has changed and generate ANSI escape sequences.

This kind of works, but a good diffing algorithm to minimize amount of data sent down the line would be complex. Sometimes the screen buffer is updated so quickly that some updates are not sent at all. This is a show stopper; I need all the data captured 100% reliably.

+1  A: 

Sadly, this can not be done reliably cleanly. Redirecting standard handles will only catch high-level console I/O. The only way I am aware of catching everything is hooking the console APIs from the target process (and its children), sadly.

Koro