Is there a working way to embed the windows console in disasm code? I tried AllocConsole with GetStdHandle or AttachConsole with PID of an existing console but it didn't work. I have tried printf and putchar with no success. I can make a console and be able to change the title (fancy way to get printf:))) but instead of output I get a black screen. I'm on XP and trying to get the status of I/O ports in an old MFC application. MessageBox is a good alternative, but I/O ports send thousands of messages per second. I will be happy even if x32dbg will have this function for logging registry value somehow but new versions doesn't work on my XP
1 Answer
Ok, I got it... In an arbitrary place in the program I put this:
call 0x7C8731B9 // kernel32.AllocConsole()
push 0x21 // '!'
call _putch // this print one char '!'
push 0x00553D91 // some string
call _cputs // this print string
In my case no need to use GetStdHandle after AllocConsole
-
Odd, I'd expect you have to open the respective pseudo-devices. At least that's how I had to do it whenever I used consoles for tracing purposes in GUI apps.– 0xC0000022L ♦Commented Dec 2, 2022 at 9:58
-
@0xC0000022L Windows C functions which starts from _ do magic :) Commented Dec 2, 2022 at 10:19
DeviceIoControl
calls orReadFile
/WriteFile
on some device handle (which you could glean via a tool like Process Hacker or Process Explorer).