Hello all,
I have tried to create a Windows plugin dll for the Sylpheed
e-mail client in FreePascal but couldn't get past a strange
side effect: the mere fact of the plugin being loaded makes
GTK's window-showing functions crash the whole program.
This happens even with the smallest and emptiest plugin pos-
sible, when it neither subscribes for any event nor calls
any API functions. The minimal plugin only provides minimal
implementations of the basic interface functions simply
reporting the start of every function to the debug log,
which is created when Sylpheed is invoked with the --debug
option.
Then I tried coding the same plugin in C, using the Tiny C
Compiler, and it worked pretty well, wherefrom I concluded
that something must be wrong with FreePascal's DLL genera-
tion, so I have come here for help.
Attached are the C and Pascal sources of the minimal plugin.
A package with the same sources plus the binaries can be
downloaded here:
http://uploadbox.com/files/6d08a0b625/
This is the original report of the problem on the Sylpheed
mailing list:
http://www.sraoss.jp/pipermail/sylpheed/2011-May/004525.html
After I had encountered the problem I started to strip the
plugin of its functionality and dependencies until I had the
bare skeleton which still didn't work and which I have
attached.
If you need any further information, please ask.
Thanks in advnace,
Anton
#include <io.h>
#include <windows.h>
typedef void (*TEmptyCallBack)(void);
// PEmptyCallBack = ^TEmptyCallBack;
typedef char* PGChar;
typedef void* GPointer;
typedef long GInt;
struct SylPluginInfo {
PGChar name;
PGChar version;
PGChar author;
PGChar description;
pad1, pad2, pad3, pad4;
};
typedef struct SylPluginInfo SylPluginInfo;
typedef SylPluginInfo* PSylPluginInfo;
//Below define is Tiny C Compiler's way of exporting DLL functions
#define DLL __attribute__ ((dllexport))
const long SYL_PLUGIN_INTERFACE_VERSION = 0x0107;
void plugin_load (void) DLL;
void plugin_unload (void) DLL;
PSylPluginInfo plugin_info (void) DLL;
GInt plugin_interface_version (void) DLL;
static SylPluginInfo info =
{ "Test Plugin",
"0.0.1",
"Anton Shepelev",
"It had better work"
};
void plugin_load(void)
{ printf("Ant: loaded.\n"); }
void plugin_unload(void)
{ printf("Ant: plugin unloaded.\n"); }
PSylPluginInfo plugin_info(void)
{ printf("Ant: Plugin info requested.\n");
return (PSylPluginInfo)&info;
}
GInt plugin_interface_version(void)
{ printf("Ant: Interface version requested.\n");
return SYL_PLUGIN_INTERFACE_VERSION;
}
Library Test;
Type
TEmptyCallBack = procedure;
PEmptyCallBack = ^TEmptyCallBack;
PGChar = PChar;
GPointer = Pointer;
GInt = LongInt;
SylPluginInfo = packed record
name: PGChar;
version: PGChar;
author: PGChar;
description: PGChar;
pad1, pad2,
pad3, pad4: GPointer;
end;
PSylPluginInfo = ^SylPluginInfo;
const
SYL_PLUGIN_INTERFACE_VERSION = $0107;
var
PI: SylPluginInfo;
Procedure plugin_unload; CDecl;
begin
WriteLn('Ant: plugin unloaded!');
end;
Function plugin_info(): PSylPluginInfo; CDecl;
begin
WriteLn('Ant: Plugin info is being requested...');
plugin_info := nil;
end;
Function plugin_interface_version():gint; CDecl;
begin
WriteLn('Ant: Interface version is being requested...');
plugin_interface_version := SYL_PLUGIN_INTERFACE_VERSION;
end;
Procedure plugin_load; CDecl;
begin
WriteLn('Ant: plugin loading...');
pi.name := 'Test Plugin';
pi.version := '0.0.1';
pi.author := 'Anton';
pi.description := 'It had better work.';
WriteLn('Ant: plugin loaded.');
end;
Exports
plugin_load,
plugin_unload,
plugin_info,
plugin_interface_version;
end.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal