Skip to content

Instantly share code, notes, and snippets.

@Riesi
Last active September 7, 2023 13:09
Show Gist options
  • Save Riesi/9ba1b9fea1696359d9d27b6ac8f32053 to your computer and use it in GitHub Desktop.
Save Riesi/9ba1b9fea1696359d9d27b6ac8f32053 to your computer and use it in GitHub Desktop.
Advanced apitracing

Advanced capturing via hooking the game exe

Some games don't load the apitrace DLLs from their working directory, so you can use apitrace to hook the graphics API you are interested in instead with the following command:

apitrace.exe trace -a <API> <game.exe>

Advanced capturing for games not loading local DLLS via path overrides

Some programs prevent apitrace DLLs to be loaded from next to their executable or directly load system DLLs. This means we have to put apitrace into the system folder, but this prevents apitrace from loading a proper DirectX implementation since it will try to load itself. Luckily apitrace has a feature to set a custom folder from which the DirectX DLLs will be loaded.

Be sure to use the appropriate architecture for the DLLs and the corresponding system folder. On 64bit Wine prefixes system32 corresponds to the 64bit and syswow64 to 32bit files.

Create a <custom_folder> somewhere which will contain the appropriate d3d9.dll, d3d11.dll, dxgi.dll, etc files. These can be Wine's stub DLLs copied from your prefix's system32/syswow64 folders or DXVK's DLLs, depending on the trace requirements. After preparing the <custom_folder> it is time to place the apitrace DLLs into the right system folder.

With all these preparations done its time to trace! All you have to do is to set the correct DLL overrides as described in the previous section and to export the following environment variable then can run your game and get a trace file from it.

export APITRACE_FORCE_MODULE_PATH="/home/<path_to>/<custom_folder>"

wine /path/to/executable/program.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment