gdb_force_led.py 1.0 KB

123456789101112131415161718
  1. # Switches the LED plugin of a running WE 2.8.42 (wallpaper64.exe under Wine) on, as if a device were connected and the wallpaper's LEDs enabled:
  2. # LED_RAW=1 gdb -q -batch -p <wallpaper64.exe pid> -x gdb_force_led.py
  3. # The plugin's options never arrive without the Wallpaper Engine UI, so the first controller's "wanted" and "granted"
  4. # flags are set by hand (ledextensions64.dll +9 and +0xA). LED_RAW=1 also turns "Boost LED colors" off for raw frames
  5. import gdb, os
  6. gdb.execute('handle SIGSEGV SIGUSR1 SIGUSR2 SIGILL SIGTRAP SIGPIPE nostop noprint pass')
  7. inf = gdb.selected_inferior()
  8. def rd(a, n): return bytes(inf.read_memory(a, n))
  9. def q(a): return int.from_bytes(rd(a, 8), 'little')
  10. node = q(q(0x1404E6270))
  11. plugin = q(node + 72)
  12. wallpaper = q(q(plugin + 16))
  13. controller = q(q(wallpaper + 48))
  14. inf.write_memory(controller + 9, b'\x01')
  15. inf.write_memory(controller + 10, b'\x01')
  16. if os.environ.get('LED_RAW') == '1':
  17. inf.write_memory(wallpaper + 74, b'\x00')
  18. print('forced', rd(controller + 8, 4).hex(), 'boost', rd(wallpaper + 74, 1).hex())