Type | Name | Developer | Price | License | Website |
---|---|---|---|---|---|
Decompiler | dotPeek | JetBrains | Free | Commercial | Official Website |
Deobfuscator | de4dot | 0xd4d | Open source | GPL v3 | GitHub Fork |
You will also need to install the correct Unity Editor from the official Unity download archive.
For Unity 2017.2 and above. For older versions, see 0xd4d's guide to debugging Unity games.
Before you do anything, backup the game's player .exe
, UnityPlayer.dll
, and the Managed
folder.
Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations
folder.win32_development_mono
or win64_development_mono
..exe
and UnityPlayer.dll
.WindowsPlayer.exe
and UnityPlayer.dll
to the game's root directory.WindowsPlayer.exe
appropriately.Data\Managed
to the game's respective folder, overwriting all files when prompted.boot.config
.boot.config
, add the line player-connection-debug=1
, and save.mono-2.0-bdwgc.dll
in the game's MonoBleedingEdge
folder with the debug version from the Unity Editor's MonoBleedingEdge
folder.Steamworks .NET interferes with debug logging. (See: Known Issue/Won't Fix)
Most GOG builds still use Steamworks, if the game is available on Steam.
steam_appid.txt
.These instructions are intended to allow developers and other technical users to obtain detailed call stacks from release builds. If you are compiling the game's assemblies with full debug symbols, you don't need to follow these instructions, although Step 3 could be useful.
If you haven't already, compile this fork of de4dot, which makes these changes.
This step is required for assemblies that were not compiled with the /debug
option.
dotPeek does not allow generating PDBs for non-debug assemblies because debuggers do not support them. The Generate Pdb...
option on the Assembly Explorer context menu will be grayed out and the tooltip will indicate the assembly is missing its debug
directory.
Using our fork of de4dot, we need to "trick" dotPeek so that we can generate a new Full PDB. Execute the following command:
de4dot --dont-rename --keep-types --preserve-tokens --preserve-strings -fpdb <input_assembly.dll> -o <output_assembly.dll>
The output assembly should A) have the same name as the input assembly and B) be located at the same path. To achieve B, relocate the input assembly.
A dummy PDB will be produced in the output folder. Delete this file before loading the assembly into dotPeek.
Alternatively, download peupdate and run a command sequence like:
de4dot --dont-rename --keep-types --preserve-tokens --preserve-strings -fpdb Assembly-CSharp.dll -o Assembly-CSharp2.dll
peupdate -u Assembly-CSharp.dll Assembly-CSharp2.dll
copy /Y Assembly-CSharp2.dll Assembly-CSharp.dll
del Assembly-CSharp.pdb
del Assembly-CSharp2.pdb
Export to Project...
Create *.pdb file
Export
buttonCall stacks will reference line numbers in files located in the project's destination folder.
Do not use the
Generate Pdb...
option. The PDB produced by this option will cause call stacks to reference files in theDecompilerCache
.
For assemblies compiled with msc
(the Mono compiler), Unity loads MDB files, not PDB files, so for those assemblies, we need to generate an MDB from our new PDB.
Execute this command:
"%UNITY_MONO%\bin\mono.exe" "%UNITY_MONO%\lib\mono\4.5\pdb2mdb.exe" "<target_assembly_dll>"
%UNITY_MONO%
is the absolute path to Unity's MonoBleedingEdge
folder, like G:\Unity\Editors\2019.4.26f1\Editor\Data\MonoBleedingEdge
.
The MDB file will be generated in the same folder as the target assembly DLL.
Type | Name | Developer | Price | License | Website |
---|---|---|---|---|---|
Decompiler/IL Editor | dnSpy | 0xd4d | Open source | GPL v3 | GitHub |
This procedure is only useful for live debugging non-debug assemblies. If your only goal is to produce complete call stacks, you can skip this.
Using dnSpy, load the assembly and modify the assembly attributes from:
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
To:
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations
| DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
For more information, see 0xd4d's guide to Making an Image Easier to Debug.
Save the module with the following MD Writer Options: