English 中文(简体)
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 or 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. :)





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签