[英]Decompile VB.NET exe to C# (dotPeek & JustDecompile)
因此,我有一個基於VB.NET構建的程序,但是沒有源代碼,無法獲取源代碼,我需要修改該程序,因此我可以使用dotPeek和JustDecompile將其反編譯為C#,因為我可以在C#,但我從未真正學習過VB.NET(我也嘗試過使用JustDecompile將其反編譯為VB.NET,但對我來說,它看起來比C#更加混亂)。 但是反編譯的項目充滿了奇怪的代碼,當我嘗試將C#exe和dll反編譯為C#項目時,我看不到這些代碼。 它充滿了看起來不應該存在的代碼(看起來像是幕后代碼),例如:
private static List<WeakReference> __ENCList;
lock (finvendor.__ENCList)
finvendor.__ENCList.Add(new WeakReference((object) this));
[AccessedThroughProperty("controlname")] //for every controls
對於我在C#中找不到的每個控件,它也充滿了此類代碼:
internal virtual CheckEdit chkNonAktif
{
[DebuggerNonUserCode] get
{
return this._chkNonAktif;
}
[DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.chk_CheckedChanged);
if (this._chkNonAktif != null)
this._chkNonAktif.CheckedChanged -= eventHandler;
this._chkNonAktif = value;
if (this._chkNonAktif == null)
return;
this._chkNonAktif.CheckedChanged += eventHandler;
}
}
它使用的是Devexpress版本10,是因為這些代碼嗎? 是正常現象還是我可以刪除這些代碼?
您具有VB Winform項目的調試版本。 弱參考資料由調試器使用,不會在發行版本中發出。
VB為每個Dim WithEvents ControlName As ControlType
創建一個屬性,為此,還有一個用Handles ContolName.EventName
裝飾的方法。 屬性設置器包含使Handles Event東西起作用的事件連接代碼。
例如,按鈕及其單擊事件。
Friend WithEvents Button1 As Button
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'some code
End Sub
將導致生成此屬性:
Friend Overridable Property Button1 As Button
<CompilerGenerated> _
Get
Return Me._Button1
End Get
<MethodImpl(MethodImplOptions.Synchronized), CompilerGenerated> _
Set(ByVal WithEventsValue As Button)
Dim handler As EventHandler = New EventHandler(AddressOf Me.Button1_Click)
Dim button As Button = Me._Button1
If (Not button Is Nothing) Then
RemoveHandler button.Click, handler
End If
Me._Button1 = WithEventsValue
button = Me._Button1
If (Not button Is Nothing) Then
AddHandler button.Click, handler
End If
End Set
End Property
您可能還會有許多類以My_XYZ的形式命名,它們支持VB的應用程序框架。
我建議您使用幾個控件/事件處理程序創建一個新的VB WinForm項目,然后對其進行反編譯,以便您可以看到反編譯器如何從IL中復制樣板文件。 一旦知道了模式,它將變得容易得多。
我是這個答案可以幫助某人理解問題並找到自己的解決方案。
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.