core.speedhack#
Speed hack module for pausing and accelerating the game.
The injection functions inject a DLL into a target process and force it to load the library. First,
we obtain a handle of the target process and allocate memory in the external process. Then we write
the path to the DLL into the allocated memory, create a remote thread in the target process, and
call LoadLibrary on kernel32.lib to force the process to load the DLL. The allocated memory
is subsequently released and the handles are closed. This completes the injection.
The injection reroutes the game’s calls to Windows’ performance timer functions to custom timers. These timers have an adjustable speed parameter to slow and/or accelerate the game. In order to dynamically adjust the speed, a NamedPipe is opened and continuously read by a second process. The values sent over the pipe are then used to update the speed parameter at runtime.
The module implements a singleton that provides thread-safe access to the named pipe created by the DLL. This is necessary because only a limited number of clients can connect to the pipe. Otherwise, multiple game interface objects could not be instantiated.
- soulsgym.core.speedhack.inject_dll(process_name: str, dll_path: Path)#
Inject a DLL into the target process.
Injection opens a process handle of the target process, allocates virtual memory in its address space, writes the DLL path to this address and forces the process to open the DLL by creating a remote thread.
- Parameters:
process_name – Target process name.
dll_path – Path to the DLL file.
- class soulsgym.core.speedhack.SpeedHackConnector(*args: Any, **kwargs: Any)#
Bases:
objectInject the speed hack and connect to the speed command pipe.
The connector is designed as singleton as only a single connection to the pipe is allowed, but multiple
Gameobjects might exist. The connector provides a thread-safe method to communicate with the injected pipe using only a single client.Note
The
speedhack.dllis compiled to soulsgym/core/speedhack/_C/x64/Release and copied over into soulsgym/core/speedhack/_C after the build has succeeded. If you want to use a recompiled version, you have to rerun the build process with Visual Studio.- __init__(process_name: str)#
Connect to the speed hack pipe.
If the pipe is not yet open, inject the DLL into the game.
- Parameters:
process_name – Name of the process to connect to.
- set_game_speed(value: float)#
Set the game speed to a new value.
- Parameters:
value – The new game speed. Can’t be lower than 0.