gdb_video_transfer.py 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. # Arguments of WE's TransferVideoFrame call (wallpaper64.exe 2.8.42 sub_1400F3480 at 0x1400f353f) on a live WE: the
  2. # destination texture, source rect, destination rect and the player's video info (+0x68 w, +0x6c h, +0x70 fps).
  3. # OUT=transfer.txt COUNT=10 gdb -q -batch -p <wallpaper64.exe pid> -x gdb_video_transfer.py
  4. import gdb, os, struct
  5. gdb.execute('set pagination off')
  6. gdb.execute('set confirm off')
  7. out = open(os.environ.get('OUT', 'video_transfer.txt'), 'w')
  8. inf = gdb.selected_inferior()
  9. count = [0]
  10. def reg(n):
  11. return int(gdb.selected_frame().read_register(n)) & 0xffffffffffffffff
  12. def mem(addr, n):
  13. return bytes(inf.read_memory(addr, n))
  14. class B(gdb.Breakpoint):
  15. def __init__(self):
  16. super().__init__('*0x1400f353f', internal=False)
  17. def stop(self):
  18. rbx, rdx, r8, r9 = reg('rbx'), reg('rdx'), reg('r8'), reg('r9')
  19. src = struct.unpack('4f', mem(r8, 16))
  20. dst = struct.unpack('4i', mem(r9, 16))
  21. w, h, fps = struct.unpack('iif', mem(rbx + 0x68, 12))
  22. target = struct.unpack('Q', mem(rbx + 0x88, 8))[0]
  23. out.write('player %#x dst tex %#x src %s dst %s info %dx%d fps %.3f target %#x\n'
  24. % (rbx, rdx, src, dst, w, h, fps, target))
  25. out.flush()
  26. count[0] += 1
  27. if count[0] >= int(os.environ.get('COUNT', 10)):
  28. gdb.execute('delete')
  29. out.close()
  30. gdb.post_event(lambda: gdb.execute('detach'))
  31. return False
  32. B()
  33. gdb.execute('continue')