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.

class soulsgym.core.speedhack.SpeedHackConnector(*args: Any, **kwargs: Any)#

Inject 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 Game objects might exist. The connector provides a thread-safe method to communicate with the injected pipe using only a single client.

Note

The SpeedHackDLL.dll is compiled to soulsgym/core/speedhack/_C/x64/Release. In order to use it for the injection, either update the path or move the dll file into the _C folder.

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.