开发者

kkrunchy - how to get rid of the tls data in a Delphi executable?

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 o开发者_运维技巧r something similar... but perhaps one of you already knows, or even has some information on how to circumvent this problem?


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.


(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

TerminateProcess( GetCurrentProcess, 0 )

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. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜