SRL Archive - FAQ

Help with Plugin


Rick

2010-09-01 12:31:52

I'm trying to make a plugin for Simba, however I receive the following error when testing the plugin:


Exception in Script: Error loading plugin C:\Simba\Plugins\TestPlug.dll

I have installed Lazarus + fpc 2.4.3.


library TestPlug;

{$mode objfpc}{$H+}

uses
Classes, sysutils;

{$R *.res}

function Test_Func(var T: String): Integer; register;
begin
T := 'abc';
Result := 123;
end;

function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 1;
end;

function GetFunctionCallingConv(x : integer) : integer; stdcall;
begin
result := 0;
case x of
0 : result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;
begin
case x of
0:
begin
ProcAddr := @Test_Func;
StrPCopy(ProcDef, 'function Test_Func(var T: String): Integer;');
end;
else
x := -1;
end;
Result := x;
end;

exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.

The above compiles in Lazarus, however when run the debugger "enters error state". I can compile and run the source of IrokiPlugin with no errors.

Any help with this would be appreciated :)

Wizzup?

2010-09-01 14:12:16

Are you by any chance using a 64 bit compiler? Also, I think you should export the GetFunctionInfo function, as Simba calls those too. (Same for GetCallingConv)

Rick

2010-09-01 16:40:20

From: Wizzup?
Are you by any chance using a 64 bit compiler? Also, I think you should export the GetFunctionInfo function, as Simba calls those too. (Same for GetCallingConv)


Yes that was it, switched to 32-Bit and it works, thanks :)