4 ms·
Hooking keyboard input to play Snake in Notepad.exe (2020)
- hprotagonist 6y agohttps://github.com/emacs-mirror/emacs/blob/master/lisp/play/snake.el https://github.com/emacs-mirror/emacs/blob/master/lisp/play/... 1997 is actually later than I would've thought.
- Kaze404 6y agoThis is great. I didn't expect `M-x snake` to be available out of the box like that :)
- hprotagonist 6y agotry dunnet, tetris, hanoi, blackbox, bubbles, pong, gomoku,...
- thefourthchime 6y agoI did socket hooking via DLL injection for a company i worked for. I was somewhat amazed that it was allowed, and I'm amazed it still is.
- banana_giraffe 6y agoI've mentioned it here before. I have a "cd" replacement tool for Windows. It works by writing a separate thread to cmd.exe's process and remotely running it to do things in cmd's process (change the current directory, update a few enviornment variables cmd.exe uses behind the scenes). I am flabbergasted that it works, and it still works after all of these years.
- dgellow 6y agoIs the code available somewhere? I would be interested to read it
- banana_giraffe 6y agoIf you really want to see it, I put the core of it here: https://pastebin.com/v92Aesty https://pastebin.com/v92Aesty ExecuteRemoteThread() does what it's name says, copying RemoteThread to cmd.exe, and running it. The rest of the code is about getting pointers to a few WinAPIs that are used in a safe way, and dancing around not having a CRT that can be sanely used inside of cmd.exe.
- dgellow 6y agoThanks!
- JoshGlazebrook 6y agoI've also done some socket hooking work in C/C++. Any idea if it's feasible to do with Go?
- amake 6y agoIt seems a lot of people have the same idea of implementing Snake where it has no business being https://twitter.com/neilsardesai/status/1379185826920300545?s=21 https://twitter.com/neilsardesai/status/1379185826920300545?...
- pp19dd 6y agoAnd ... it's in Sub Rosa, the obscure cult-like game stuck in the 80s universe of shady business dealings: https://twitter.com/crypticsea/status/1377433014674714624 https://twitter.com/crypticsea/status/1377433014674714624 For those of you who don't know it, it's a rather obscure and in some ways delightfully refreshing game, albeit populated by unsavory players worth of the Mos Eisley cantina quote taken at its face value. It's based on two things, physics-based movement and the prisoner's dilemma split three-ways. "Deal-making, deal-breaking, and the occasional high-speed car chase." And of course, having to walk up to a computer and type MS-DOS commands to play snake. The developer plans to make the game's computer a "full 6502 or Z80 emulation so players can write their own games."
- computerex 6y agoCould have probably gotten the keyboard input with https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate https://docs.microsoft.com/en-us/windows/win32/api/winuser/n... instead of the hooks.
- iamevn 6y agoExcellent write-up. I think the first place I encountered this sort of thing in notepad was http://thesiteformerlyknownas.zachtronicsindustries.com/notepad-weekend/ http://thesiteformerlyknownas.zachtronicsindustries.com/note...
- lifthrasiir 6y agoSomeone also uses notepad as a debug console [1]. There is even a Rust crate for that [2]. [1] https://www.reddit.com/r/programming/comments/gnazif/ray_tracing_in_notepadexe_at_30_fps/fr8uy2l/ https://www.reddit.com/r/programming/comments/gnazif/ray_tra... (I've first seen this from Steve Klabnik's tweet https://twitter.com/steveklabnik/status/1263190719721766918 https://twitter.com/steveklabnik/status/1263190719721766918) [2] https://crates.io/crates/notepad_logger https://crates.io/crates/notepad_logger
- Kaze404 6y agoPretty cool. The next step is, of course, porting Doom to it :)
- devit 6y ago"Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should."