Packer plugin for specific SFX EXE files - problems

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
gigaman
Member
Member
Posts: 131
Joined: 2003-02-14, 11:28 UTC

Packer plugin for specific SFX EXE files - problems

Post by *gigaman »

Hello!

I'm working on a packer plugin for Total Commander 5.51 to handle some specific installer archives - i.e. "self-extracting EXE files". I've encountered a couple of problems... some of them may be due to my code (I dare not to claim my code bug-free :oops:, but it looks like Total Commander has some problems as well.

Since the plugin should handle specific EXE files, I return (PK_CAPS_MULTIPLE + PK_CAPS_BY_CONTENT + PK_CAPS_HIDE) in the GetPackerCaps() function. I have also implemented the CanYouHandleThisFile() function to distinguish the supported archive EXE files from other EXE files.
Now, there is a question what to associate the plugin to.

If I associate the plugin to .exe extension, it turns off the internal Total Commander functions for SFX archives processing - i.e. when I press Ctrl+PgDn on a WinRAR SFX archive, I get the "bad archive" message, since only my plugin is called; the internal Total Commander code is not used anymore.

Since I definitelly don't want to sacrifice the internal Total Commander SFX unpacker, I tried associating the plugin to some virtual extension, for example to .xxxxxxxx. I don't think I ever meet any file with such an extension, so there shouldn't be any conflict, and the plugin still should work when I press Ctrl+PgDn (thanks to the PK_CAPS_BY_CONTENT flag).

Now, entering the archive with Ctrl+PgDn and copying the files out of the archive with F5 works OK. Using Alt+F9, however, behaves rather strange. When I press Alt+F9 when I'm outside of the archive (i.e. the cursor points to the archive EXE file), I get an "Error in archive file" message - the plugin functions ReadHeader/ProcessFile are not called at all. When I enter the archive using Ctrl+PgDn (which works OK - the archive is read and I can see its content) and press Alt+F9, the usual "Unpack files" dialog appears; when I press OK to unpack the files, however, the installer is started (i.e. the SFX EXE is executed :shock:)!
Another thing that stopped working when I associated the file to .xxxxxxxx extension, is starting the files from inside the archive; when the plugin was associated to .exe, pressing Enter on a file inside the archive showed the usual "Properties of packed file" dialog, with the possibility to "Unpack and execute". Now, however, pressing Enter doesn't do anything, even though the files inside the archive are well known (i.e. their extensions are associated). (It starts to work again when I rename the SFX archive to that virtual .xxxxxxxx extension).
The same I wrote about Alt+F9 holds for Shift+Alt+F9 (Test archive) as well.

So my questions are:
1. Is it possible to use a packer plugin without associating it to a specific extension? If the plugin has PK_CAPS_BY_CONTENT capability, the extension is not necessary... so, it would be nice if Total Commander could use the plugin even when it's associated to "nothing", or to some "special" extension like "*"...
2. Why does the plugin association influence starting the files from inside the curresponding archive ("Unpack and execute")?
3. Is Alt+F9 consistent with Ctrl+PgDn, considering the PK_CAPS_BY_CONTENT plugins?

Any suggestions are welcome!
Thanks a lot

gigaman
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

PK_CAPS_BY_CONTENT is unfortunately a bit limited, so things like unpack and execute don't work. I plan to add support for this in the next version, so it would be nice if you could e-mail me a list of functions which do not work with non-associated extensions like .exe.
Author of Total Commander
https://www.ghisler.com
gigaman
Member
Member
Posts: 131
Joined: 2003-02-14, 11:28 UTC

Post by *gigaman »

Hello ghisler, thanks for your answer.

For archives with unasociated extensions handled by a PK_CAPS_BY_CONTENT plugin, I found the following functions not to work:
  • - Test archive (Shift+Alt+F9), both from inside and outside the archive
    - Unpack files (Alt+F9), both from inside and outside the archive
    - Search (Alt+F7), both files and text (PK_CAPS_SEARCHTEXT is set)
    - Properties of packed file (Enter / Shift+F9 / Win / Alt+Enter / whatever)
    - Compare by content
If the archive has an extension associated to the plugin, it all works OK.

My plugin does not support archive modification, so I couldn't check Packing/Deleting files thoroughly. However, to try it, I temporarily added (empty) functions PackFiles / DeleteFiles and I noticed the following problem(?), independent on the file association:
When I try to delete a file from the archive (press Del on it), the functions SetProcessDataProc and SetChangeVolProc are called (followed by DeleteFiles call), without calling OpenArchive first; the value of hArcData passed to these functions is 0xFFFFFFFF. I don't know whether it's on purpose, but it is not mentioned anywhere in the documentation. I was checking hArcData for NULL, but not for 0xFFFFFFFF, so it crashed my plugin.
The same holds for adding a file to the archive (F5) or creating a new archive (Alt+F5) - first SetProcessDataProc and SetChangeVolProc with hArcData=0xFFFFFFFF are called, then PackFiles; nothing else.


Speaking of packer plugins, a little suggestion: could the SetChangeVolProc dialog ("Please insert disk containing:") include a Browse button?

Hope this helps!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks, I will add support for thse functions in the next version of TC.
When I try to delete a file from the archive (press Del on it), the functions SetProcessDataProc and SetChangeVolProc are called (followed by DeleteFiles call), without calling OpenArchive first; the value of hArcData passed to these functions is 0xFFFFFFFF.
Indeed packing doesn't use OpenArchive, it's only used for unpacking. -1 (or 0xFFFFFFFF) is used to signal that the callback functions are for packing, not unpacking. I will update the documentation.
Speaking of packer plugins, a little suggestion: could the SetChangeVolProc dialog ("Please insert disk containing:") include a Browse button?
Good idea, I will add it to my wish list.
Author of Total Commander
https://www.ghisler.com
Post Reply