kkrunchy - 如何删除 Delphi 可执行文件中的 tls 数据?
只是为了好玩和咯咯笑,我试图在 delphi 中创建一个 64k 介绍。对于这种大小的应用程序来说,最好的可执行加壳程序之一是 Farbrausch 的 kkrunchy。然而,当我在一个(否则为空的)Delphi 可执行文件上运行它时,我得到以下输出,
- ERROR: files with exports or tls data are not supported
我猜测 Delphi 可执行文件都可能是罪魁祸首,而且我没有真正的麻烦,花大量的时间试图找出哪个一个是修改可执行文件或类似的东西......但也许你们中的一个人已经知道,或者甚至有一些关于如何规避这个问题的信息?
Just for fun and giggles I'm trying to create a 64k intro in delphi. One of the best executable packers for applications of this size is kkrunchy by Farbrausch. However, when I run it on an (otherwise empty) Delphi executable, I get the following output
- ERROR: files with exports or tls data are not supported
I'm guessing with a Delphi executable both could be the culprit, and I have no real troubles putting in the sweaty hours trying to figure out which one it is and post modifying the executable or something similar... but perhaps one of you already knows, or even has some information on how to circumvent this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
导出用于 DLL;您的 EXE 不太可能进行任何导出。另一方面,TLS 是线程本地存储。如果您在某处声明了任何 threadvar 变量,则可能会导致此问题。另外,我认为 TLS 用于内置异常处理,但我不清楚所有细节。如果是这样,那么你可能根本无法使用这个加壳器。
Exports are for DLLs; it's not likely that your EXE is doing any exporting. TLS, on the other hand, is thread-local storage. If you have any threadvar variabled declared somewhere, that might be causing it. Also, I think TLS is uses in the built-in exception handling, but I'm not clear on all the details. If that's it, then you might not be able to use this packer at all.
(除了梅森的答案之外,这是正确的)。
我启动了 PE 查看器/编辑器,并可以确认没有导出。所以现在的问题是:为什么在没有线程的应用程序中分配了 TLS,我该怎么办?从 PE 表中删除它效果很好,除了关闭时的应用程序错误。
System.pas 包含 2 个线程变量,InOutRes(用于 IO 错误)和 RaiseListPtr。我不需要这两个在我的应用程序中成为线程变量,但它们似乎在整个 system.pas 中都是硬连线的。看起来是一个很难破解的难题。
作为一种解决方法,我现在提前终止自己的进程,
以防止在正确关闭期间出现任何错误(在 Delphi 的 _Halt0 中更优雅的 ExitProcess 深处)。在构建后步骤中,我从 PE 中删除 TLS 并使用 kkrunchy 打包。降至 8192 字节,没有问题。目前。从代码道德角度来看,我感觉我应该被关进监狱。 :)
(In addition to Mason's answer, which is correct).
I fired up a PE Viewer/Editor, and can confirm there are no exports. So now the question is: why is there a TLS allocated in an application without threads, and what do I do about it? Removing it from the PE table works nicely, except for the application error at shutdown.
System.pas contains 2 threadvars, InOutRes (for IO errors) and RaiseListPtr. I don't need those two to be threadvars in my application, but they seem kinda hardwired throughout system.pas. Looks like a hard nut to crack.
As a workaround, I now prematurely terminate my own process using
to prevent any errors during proper shutdown (deep inside the more elegant ExitProcess from Delphi's _Halt0). In a postbuild step I remove the TLS from the PE and pack with kkrunchy. Down to 8192 bytes, and no problems. For now. Code-ethically, it feels like I should be put behind bars. :)