简体   繁体   English

将 Delphi .dcu 反编译为 .pas

[英]Decompiling Delphi .dcu to .pas

I'm running RAD Studio Delphi XE2.我正在运行 RAD Studio Delphi XE2。 Something strange appears to have been done to one of my .pas files.我的一个 .pas 文件似乎发生了一些奇怪的事情。 Many of the lines from my unit1.pas have been replaced with simply 'º' and others are missing.我的 unit1.pas 中的许多行已被简单地替换为“º”,而其他行则丢失了。 I am left with a small section of code from somewhere in the middle of my original file.我在原始文件中间的某个地方留下了一小段代码。 Can I get the original unit1.pas back by somehow decompiling unit1.dcu?我可以通过某种方式反编译 unit1.dcu 来取回原始的 unit1.pas 吗?

Also, why would this happen?还有,为什么会出现这种情况? Have you heard of this before?你以前听说过这个吗? The code runs but, obviously, I can't edit anything I can't see.代码运行,但显然,我无法编辑我看不到的任何内容。

Even if you could decompile it, it would likely be an unmaintainable mess compared to your original.即使您可以反编译它,与您的原始版本相比,它也可能是一个无法维护的烂摊子。

Instead, try looking in the __History folder for your project.相反,请尝试在__History文件夹中查找您的项目。 You should find older versions of your code.您应该找到旧版本的代码。 Pick the newest one ;-)选择最新的 ;-)

why would this happen?为什么会发生这种情况?

Any number of reasons.任何数量的原因。 Bug in the IDE? IDE 中的错误? Bug in an IDE plugin or a custom component? IDE 插件或自定义组件中的错误? Bug in your code that overwrites a source file, maybe?错误在你的代码,覆盖源文件,也许?

You cannot decompile a .dcu file to the original source.您无法将 .dcu 文件反编译为原始源。 Information is lost in the translation from source code to executable code.从源代码到可执行代码的转换过程中会丢失信息。 Type declarations, variable names, method names, code layout and so on are simply not present in the compiler's output.类型声明、变量名、方法名、代码布局等根本不存在于编译器的输出中。 Compilation is a one way process.编译是一种单向过程。

If you use revision control, you'll just be able to pull the latest version from the repository.如果您使用版本控制,则只能从存储库中提取最新版本。 If you don't use revision control, you've just learnt a lesson the hard way and you will never again attempt to perform software development without revision control.如果您不使用版本控制,那么您就刚刚从惨痛的教训中吸取了教训,您将再也不会尝试在没有版本控制的情况下进行软件开发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM