• [C#] 使用 dnSpy 反编译


    介绍

    dnSpy是一款针对.NET程序的逆向工程工具 , 可以使用它反编译.NET代码。

    git 链接:https://github.com/dnspy/dnspy


    效果

    为了测试简单写了一个窗体程序,代码如下:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace test_winform
    {
        public partial class Form1 : Form
        {
            int a = 1;
            string b = "asd";
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("123");
    
            }
        }
    }
    
    

    打开 dnSpy ,将程序拖入,反编译完成后如下:
    在这里插入图片描述

    关键代码的反编译效果:

    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    
    namespace test_winform
    {
    	// Token: 0x02000002 RID: 2
    	public class Form1 : Form
    	{
    		// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
    		public Form1()
    		{
    			this.InitializeComponent();
    		}
    
    		// Token: 0x06000002 RID: 2 RVA: 0x0000207A File Offset: 0x0000027A
    		private void button1_Click(object sender, EventArgs e)
    		{
    			MessageBox.Show("123");
    		}
    
    		// Token: 0x06000003 RID: 3 RVA: 0x00002088 File Offset: 0x00000288
    		protected override void Dispose(bool disposing)
    		{
    			bool flag = disposing && this.components != null;
    			if (flag)
    			{
    				this.components.Dispose();
    			}
    			base.Dispose(disposing);
    		}
    
    		// Token: 0x06000004 RID: 4 RVA: 0x000020C0 File Offset: 0x000002C0
    		private void InitializeComponent()
    		{
    			this.button1 = new Button();
    			base.SuspendLayout();
    			this.button1.Location = new Point(394, 156);
    			this.button1.Name = "button1";
    			this.button1.Size = new Size(75, 23);
    			this.button1.TabIndex = 0;
    			this.button1.Text = "button1";
    			this.button1.UseVisualStyleBackColor = true;
    			this.button1.Click += this.button1_Click;
    			base.AutoScaleDimensions = new SizeF(6f, 12f);
    			base.AutoScaleMode = AutoScaleMode.Font;
    			base.ClientSize = new Size(800, 450);
    			base.Controls.Add(this.button1);
    			base.Name = "Form1";
    			this.Text = "Form1";
    			base.ResumeLayout(false);
    		}
    
    		// Token: 0x04000001 RID: 1
    		private int a = 1;
    
    		// Token: 0x04000002 RID: 2
    		private string b = "asd";
    
    		// Token: 0x04000003 RID: 3
    		private IContainer components = null;
    
    		// Token: 0x04000004 RID: 4
    		private Button button1;
    	}
    }
    
    
  • 相关阅读:
    Go 数组与切片
    Go 常用函数
    Go 函数,包(二)
    函数,包及错误处理
    Go 循环控制
    Go 流程控制
    Go 获取键盘输入,进制转换
    Go 指针,标识符命名规范及关键字
    Go 变量及基本数据类型3
    一文详解微服务架构
  • 原文地址:https://www.cnblogs.com/csnd/p/15613320.html
Copyright © 2020-2023  润新知