gpt4 book ai didi

c# - 如果没有 PDB 文件,C# 反编译器如何工作?

转载 作者:行者123 更新时间:2023-11-30 21:32:39 24 4
gpt4 key购买 nike

我从John Robbins blog知道.NET PDB 文件包含源文件名、行号和局部变量名。但是像 ILSpy.Net Reflector 这样的逆向工程软件仍然可以找出大部分代码。

代码流更容易获得。但是这些软件如何提取函数名、变量名等数据?

最佳答案

Code flow is easier to obtain. But how do these software extract data like function names, variable names ?

程序集在元数据中包含此类信息。如 spec 中所述,

New types—value types and reference types—are introduced into the CTS (Common Type System) via type declarations expressed in metadata. In addition, metadata is a structured way to represent all information that the CLI (Common Language Infrastructure) uses to locate and load classes, lay out instances in memory, resolve method invocations, translate CIL (Common Intermediate Language) to native code, enforce security, and set up runtime context boundaries.

此外,需要注意的是,这些信息不仅可以通过这些“逆向工程”工具访问,还可以通过 Reflection 访问您的 C#(或 VB)代码。 .例如,可以通过反射了解给定类型中方法的名称,因为它是元数据的一部分。

以下是 .Net Guide 的摘录这解释了元数据中包含的内容:

Metadata describes every type and member defined in your code in a language-neutral manner. Metadata stores the following information:

  • Description of the assembly.

    • Identity (name, version, culture, public key).

    • The types that are exported.

    • Other assemblies that this assembly depends on.

    • Security permissions needed to run.

  • Description of types.

    • Name, visibility, base class, and interfaces implemented.

    • Members (methods, fields, properties, events, nested types).

  • Attributes.

    • Additional descriptive elements that modify types and members.

现在这不一定包括局部变量名称,此类工具通常无法正确地对其进行逆向工程。

关于c# - 如果没有 PDB 文件,C# 反编译器如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52161782/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com