I want to change context (Rdx, Rax etc.) everytime a specific function gets called.
My solution: I seted up a breakpoint at function event.get_thread().set_context({"Rdx" : "bla bla"})
My problem: The FPS of the game drops to 16 Is there another method to do this without FPS problem ?
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import os,code
import winappdbg
import psutil
pid = None
process_name = "process.exe"
for process in psutil.process_iter():
if process.name() == process_name:
pid = process.pid
def handle(event):
global count
count += 1
os.system("cls")
print(f"Changed Slot: {count}")
global event2, count, alloc
alloc = None
event2 = None
count = 0
def eventHandler(event):
code = event.get_event_code()
if code == winappdbg.win32.LOAD_DLL_DEBUG_EVENT:
module = event.get_module()
if module.match_name("user32.dll"):
print ("Setting breakpoint")
global event2
event2 = event
event.debug.break_at(event.get_pid(), 0x7FF60DA6C47E, handle)
debu = winappdbg.Debug(eventHandler, bKillOnExit=False)
proc = debu.attach(pid)
try:
debu.loop()
except KeyboardInterrupt:
event2.debug.dont_break_at(event2.get_pid(), 0x7FF60DA6C47E)
jmp myFunctionAddress
pushf; inc <your counter>; popf; <whatever instructions you overwrote with the jmp>; jmp <back to the next instruction after what you overwrote>
. The instructions above are x86, and all assumes your target function has a valid stack frame to use, and makes some assumptions about the calling conventions of your platform.