srounet / Pymem

A python library for windows, providing the needed functions to start working on your own with memory editing.
MIT License
303 stars 45 forks source link

Undoing memory changes #74

Closed bcmeireles closed 4 months ago

bcmeireles commented 2 years ago

Hey, I'm trying to write some bytes to the memory of a game but after that undo the changes, how could I go about that? Currently doing

address = assembly.lpBaseOfDll + re.search(rb'\x80\xBB.....\x74\x09\x80\xBB.....', assemblyModule).start()
    game.write_bytes(address, b"\x90\x90\x90\x90\x90\x90\x90\x90\x90", 9)
    game.close_process()

Should I like

print(game.read_bytes(address, 9))

to get the original bytes and then just

game.write_bytes(address, b"\whatever the print above gave me", 9)

or is that the wrong way of approaching it

OpsecGuy commented 2 years ago

You can simply save result of 'address' to another temp variable, then override it with your code and at the end write temp variable into process.