It was trivial to add a call to MoveWindow, but I included it in the list because this was an important part of how I approached the next issue on the list.While reading about it, I had the thought that it would be really cool to see something similar that worked with stock Windows Notepad.
Notepad Code For Snake Free Time DoingThen I spent way too much of my free time doing exactly that. It seemed like writing up the stuff I learned might make for an interesting read, and give me a chance to show off the dumb stuff I built at the same time, so thats what these next couple blog posts will be about. This first post will talk about how Memory Scanners work, and how I used one to turn notepad.exe into a 30 fps capable render target. ![]() Luckily Visual Studio comes with a tool called Spy that can list all the windows that make up a given application. Once I knew that, it was just a matter of figuring out the right mix of Win32 function calls to get an HWND for that UI element, and then sending key inputs there. Instead youll need to search your Visual Studio Program files for spyxxamd64.exe. It was also really boring, so I didnt spend too long looking for ways to make it go any faster. Its a program that lets users find and modify memory in processes running on their machines. Most of the time its used by people trying to cheat at games or do other stuff that makes game devs sad, but it turns out if can also be a force for good. Lets say youre playing a game and you want to give yourself more health, you could follow a process that look like this. Notepad Code For Snake Trial And ErrorAfter some trial and error, I was able to use CheatEngine to find (and change) the text being displayed. Using that blog post and the bit of experience I had with CheatEngine, I was able to piece together that the basic algorithm for a memory scanner looks something like this. The returned MEMORYBASICINFORMATION stores this shared set of memory attributes, along with the address of the start of its span of pages, and size of the whole span. You can find all the possible values for these vars in the documentation for MEMORYBASICINFORMATION, but the values that my scanner cared about were a state of 0x1000 (MEMCOMMIT) and a protection level of 0x04 (PAGEREADWRITE). Instead, I first needed to copy the contents of a page range to the memory scanners address space. To make things simpler, I ignored the possibility that there could be multiple copies of the target byte pattern in memory in my first scanner implementation. I ended up coming up with a hacky workaronud for this problem later on that saved me from ever having to actually address it in my scanner logic. To do that, I subtracted the starting address of the local buffer from the address that was returned from FindPattern to get an offset, and then added that to the base address of the memory chunk in the target process. Try it on Notepad (it hasnt been tried on anything else, so ymmv). For simple strings, this just involves adding a zero byte after every character. Notepad Code For Snake Code For ThatWriting code for that was trivial, but I quickly learned that just writing to the text buffer wasnt enough to make Notepad redraw its Edit control. There were only three issues that needed to be sorted out to go from what Ive described so far to the ray tracer teased at the beginning of this post.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |