https://github.com/0xd4d/dnSpy
下載壓縮包之后,解壓,發現目錄里面有3個exe文件
需要用管理員運行dnSpy.exe,然后打開exe文件,設置好斷點,然后start
使用技巧
edit method
在左側的導航欄,找到某個類里面的某個方法,右鍵,會有2個edit method
1. 白色的是重命名方法,會同步修改reference處的引用
2. 綠色的是修改方法體,也就是方法里面的內容
analyze
找到某一個方法,右鍵analyze
show compiler generated code
這個可以用來查看async關鍵字生成的state machine的代碼
右鍵菜單的Merge with Assembly
假如你打開了HearthBuddy的exe,現在想要引用另外一個dll文件,那就可以直接merge with assembly。另外一個dll文件里面的類,會被直接導入到HearthBuddy.exe里面
Reference another assembly
https://github.com/0xd4d/dnSpy/issues/357
應該用第一個圖標,瀏覽
不支持async和await
關於async的反編譯
https://github.com/0xd4d/dnSpy/issues/687#issuecomment-354990427
await
is just synthetic sugar for what you see in the decompiled code. Usually ILSpy converts this back to what a programmer would normally write, but the version that dnSpy uses didn't have that implemented yet. You can find all implemented language features for the latest version of ILSpy here, but keep in mind that dnSpy still uses ILSpy 2.x, not 3.x.
取消反編譯async methods
// Triton.Bot.Logic.Bots.DefaultBot.DefaultBot // Token: 0x060013A3 RID: 5027 RVA: 0x000BD93C File Offset: 0x000BBB3C private Task method_49(TournamentScene tournamentScene_0) { DefaultBot.Struct88 @struct; @struct.defaultBot_0 = this; @struct.tournamentScene_0 = tournamentScene_0; @struct.asyncTaskMethodBuilder_0 = AsyncTaskMethodBuilder.Create(); @struct.int_0 = -1; AsyncTaskMethodBuilder asyncTaskMethodBuilder_ = @struct.asyncTaskMethodBuilder_0; asyncTaskMethodBuilder_.Start<DefaultBot.Struct88>(ref @struct); return @struct.asyncTaskMethodBuilder_0.Task; }
找到Struct88的定義,然后找到里面的MoveNext方法,右鍵edit method body
然后找到https://www.cnblogs.com/chucklu/p/11184577.html 263行以及672行,進行替換。
Search in framework assemblies