TC7.55a, crash in searchdialog after PackerPlugin ReadHeader

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Holyhead
Junior Member
Junior Member
Posts: 14
Joined: 2006-03-03, 20:06 UTC

TC7.55a, crash in searchdialog after PackerPlugin ReadHeader

Post by *Holyhead »

Hi,

I've written my own packer-plugin. Extraction and copying works well.
I've compiled my packer-plugin PK_CAPS_SEARCHTEXT. If I'm doing a search including packer, total commander crashes after the first call of my plugins's ReadHeader:

First-chance exception at 0x004027e1 in TOTALCMD.EXE: 0xC0000005: Access violation writing location 0x0067c9a6.
Unhandled exception at 0x004027e1 in TOTALCMD.EXE: 0xC0000005: Access violation writing location 0x0067c9a6.

The disassembly-line reads
004027E0 std
004027E1 rep movs dword ptr es:[edi],dword ptr [esi]

[ESI] points to the last character of my archive-name (in multi-byte notation), CX is 0xB (string length/2), and the direction flag is set (that is, the string-copying is performed backwards).
The address es:edi is invalid.

The code looks like some memcpy (string assignment) to an unallocated memory.

I could reproduce this with TC7.5 and 7.55a.
My plugin only currently supports the ANSI-functions. Searching inside a ZIP did not crash, but I suppose the internal ZIP packer supports/uses the unicode interface.

Is this a TC problem or plugin-problem?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50512
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I haven't seen this error with any other plugins. Can you send me a sample plugin so I can check it in the debugger, please?
Author of Total Commander
https://www.ghisler.com
Holyhead
Junior Member
Junior Member
Posts: 14
Joined: 2006-03-03, 20:06 UTC

Post by *Holyhead »

I've sent a simplfied example to support at ghisler dot com. I did not find an option to post attachments here.

Please send me a PM if I should send the file to another address, or if I need to upload it on a web location.

Thanks for your efforts.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50512
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks, I will check it! Please do not post my e-mail address in clear text here, I'm already getting enough spam. (I have changed it in your post.)
Author of Total Commander
https://www.ghisler.com
Holyhead
Junior Member
Junior Member
Posts: 14
Joined: 2006-03-03, 20:06 UTC

Problem solved, wrong calling convention

Post by *Holyhead »

To everyone facing the same problem and reading this thread:

Christian debugged my example and found the reason. I've used a wrong calling convention (DLLIMPORT(a) extern "C" __declspec (dllexport) a).

But Total Commander needs __stdcall, hence

#define DLLIMPORT(a) a APIENTRY
DLLIMPORT(int) someFunc() {}

does the trick.

Thanks.
Last edited by Holyhead on 2010-07-26, 06:29 UTC, edited 1 time in total.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It is not TC uses STDCALL but it is operating system uses STDCALL for all functions that are exported from DLL by default - and there is no way to change it for entry point.
Post Reply