c++中有什么概念吗?就像.Net中的反射器一样?
我喜欢从 c++ dll 获取代码,我知道我们可以通过反射器轻松从 .Net dll 获取代码。 c++中有没有可用的方法?
提前致谢
i like to get code from c++ dll ,i know we easily get from .Net dll by reflector. Is there any method available in c++ for this?
Thanks In Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
C++ 直接编译为机器代码。没有像 .NET 那样的中间语言。有 一些 C++ 反汇编程序 您可以看一下。 Hex-Rays 反编译器 特别好。
C++ is compiled directly to machine code. There's no intermediary language as in .NET. There are some C++ disassemblers you may take a look at. Hex-Rays decompiler is particularly good.
我相信你正在谈论非托管 C++。在这种情况下,这是不可能的。 C++ 被编译为机器代码,与托管语言不同,托管语言编译为中间语言,其中包含有关已编译代码的元数据。
I believe you are talking about unmanaged C++. In that case, it is not possible. C++ is compiled into machine code unlike the managed languages which compile into an intermediate language which contain the metadata about the code which got compiled.
简而言之,不。任何“反射”都必须通过某种手工编码机制。
In short, no. Any 'reflection' must be through some hand coded mechanism.
不,C++ 没有像 RedGate 的反射器那样的东西,也没有能力做这样的事情。反汇编程序不会接近您正在寻找的内容。
No, C++ has nothing like RedGate's reflector, and is incapable of such a thing. A disassembler will not come close to what you are looking for.
内省功能的代码可以从 Gcc-XML 的输出生成,或者用 OpenC++ 注入,但 C++ 标准本身不需要任何特定的工具,并且任何流行的编译器都没有捆绑任何工具/实用程序。 C++ 程序也可以在其自己的可执行文件中读取调试信息,但它绝对不是特别可移植、快速,也不太可能形成强大的解决方案。
Code for introspective capabilities can be generated from the output of Gcc-XML, or injected with OpenC++, but the C++ Standard itself doesn't require any particular facilities for this and no facilities/utilities for this are bundled with any popular compilers. It's also possible for a C++ program to read the debugging information in its own executable file, but it's definitely not particularly portable, fast, or likely to make for a robust solution.