[英]How can I decompile native within C#
I was doing research on a program (executable). 我正在研究程序(可执行)。 I decompiled the program using ILSpy.
我使用ILSpy反编译程序。 While I reviewed the source code, I discovered a function that looked like this:
在查看源代码时,我发现了一个看起来像这样的函数:
/ <Module>
[SuppressUnmanagedCodeSecurity]
[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig)]
internal unsafe static extern PointerObject* Function(sbyte*);
There was no implementation. 没有执行。 How can I disassemble this?
我该如何拆卸?
A method with the extern
keyword means that the implementation of that method is specified in some external file. 具有
extern
关键字的方法表示在某些外部文件中指定了该方法的实现。 You can read more about extern
in the MSDN Docs . 您可以在MSDN Docs中阅读有关
extern
更多信息。 Normally you would see a DLLImportAttribute
which would specify the name of the assembly that the method is implemented in. 通常,您会看到一个
DLLImportAttribute
,它将指定在其中实现该方法的程序集的名称。
MethodImpOptions.Unmanaged
implies that the call is being made to unmanaged code (C, C++, etc) and MethodImpOptions.PreserveSig
means that the method being called has the exact same method signature. MethodImpOptions.Unmanaged
表示正在对非托管代码(C,C ++等)进行调用,而MethodImpOptions.PreserveSig
表示所调用的方法具有完全相同的方法签名。
Beyond that, I can't tell you much. 除此之外,我不能告诉你太多。
Since this is a native call, you need a native disassembler. 由于这是一个本地调用,因此您需要一个本地反汇编程序。 There's plenty to choose from with wildly different level of output, but you'll most likely need a good understanding of x86 assembly and Windows programming to get anythig useful from the disassembly - it's nothing like disassembled C# code, for example.
有很多可供选择的输出水平差异很大,但是您很可能需要对x86汇编和Windows编程有很好的了解,才能从反汇编中获得有用的信息-例如,这与反汇编的C#代码完全不同。
The native code might be in a separate DLL, or in a native module in the same assembly - you'll need to check where that extern
definition is pointing. 本机代码可能在单独的DLL中,或在同一程序集中的本机模块中-您需要检查该
extern
定义所指向的位置。
Disclaimer: disassembly and/or using any knowledge obtained in this way may be illegal where you are; 免责声明:在您所在的地方,拆卸和/或使用通过这种方式获得的任何知识可能是非法的; make sure you're aware of the applicable laws.
确保您了解适用法律。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.