I wrote a kind of program that creates a win32 console process (say cmd.exe) with std i/o handles redirected to my own made Pipes which I can read and write with ReadFile and WriteFile. So I can manually send characters to the process like the user pressed the key, and I can receive the output from the process like if it was to be written to the screen. Sounds maye like a shellcode, except the network stuff, but it should become something totally different.

Everything works fine, except this: in cmd.exe, if you press , you'll get a filename over your cursor that matches the wildcard you entered (if any). if you press up, you'll get your last command, etc.

My question is: how can i fake these keys, like the user entered them? and how do programs like cmd.exe check for these keys?

Thanks in advance.
Posted on 2004-08-08 12:37:31 by Mbee
The only option I can think of, short of writing a new console device driver, is creating a console and then giving the new process the input handle from your console. Then you should be able to write to it with WriteConsoleInput. A downside to this is that a blank console window will be shown.
Posted on 2004-08-09 10:14:52 by Sephiroth3
You want to generate these events without having a visible console screen?
Posted on 2004-08-09 11:56:25 by f0dder
f0dder: yes.
Sephiroth3: I don't think that way is worth all the work.
Posted on 2004-08-10 04:39:51 by Mbee
Hmmm... sounds tricky. A really crude workaround would be creating the child process, injecting code to get the window handle of the console, hiding this window with showwindow, and passing the console handles along to the parent process...

I hope there's some nice and easy way I haven't thought of :)
Posted on 2004-08-10 07:35:00 by f0dder
hehehe, that is really a crude way indeed :)
btw, what i am coding is a kind of console to moviestyle-console modifier. the standard console/dosbox you are used to but then with a glow around the characters, funky backgrounds (3d stuff), etc. it was more a little project and i thought that it could have been done quite easily, but appearantly it isn't :(

attached is a screenshot of the current layout.
Posted on 2004-08-10 07:42:49 by Mbee
Posted on 2004-08-10 07:43:37 by Mbee