CynicRus
2014-09-26 05:21:23
Hey guys. I think, I found the Bug in Simba. When I trying return the value of the function of the delphi plugin, I always get Exception in Script: Runtime error: "Access violation" at line 11, column 10.
When I try to debug Simba with this plugin, I get External:Sigsegv in ffi_call(FCif,
Func, Res, Args); of the lpffi unit, line 418. Args is empty.
I assume, this is mostly the lape bug, so I am writing this message here.
I use Delphi XE3, plugin code is:
Test script:
Output:
Cheers,Cynic.
When I try to debug Simba with this plugin, I get External:Sigsegv in ffi_call(FCif,
Func, Res, Args); of the lpffi unit, line 418. Args is empty.
I assume, this is mostly the lape bug, so I am writing this message here.
I use Delphi XE3, plugin code is:
uses
System.SysUtils,
System.Classes,Windows,VCL.Dialogs,
{ uMSScript in 'uMSScript.pas', }
math;
var
memisset: Boolean = False;
OldMemoryManager: TMemoryManager;
function GetPluginABIVersion: Integer; Cdecl;export;
begin
Result := 2;
end;
procedure SetPluginMemManager(MemMgr : TMemoryManager); Cdecl;export;
begin
if memisset then
exit;
GetMemoryManager(OldMemoryManager);
SetMemoryManager(MemMgr);
memisset := true;
end;
procedure OnDetach; Cdecl; export;
begin
SetMemoryManager(OldMemoryManager);
end;
function Hello(S: AnsiString):AnsiString;cdecl;
begin
result:=S;
end;
function HelloAgain():AnsiString;cdecl;
begin
result:='HelloAgain';
end;
function GetFunctionCount(): Integer; Cdecl; export;
begin
Result := 2;
end;
function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PAnsiChar): Integer;Cdecl; export;
begin
case x of
0:
begin
ProcAddr := [MENTION=7782]Hello[/MENTION];
StrPCopy(ProcDef, 'function Hello(S: String):String;');
end;
1:
begin
ProcAddr := [MENTION=7782]Hello[/MENTION]Again;
StrPCopy(ProcDef, 'function HelloAgain():String;');
end;
else
x := -1;
end;
Result := x;
end;
exports GetPluginABIVersion;
exports SetPluginMemManager;
{exports GetTypeCount;
exports GetTypeInfo;}
exports GetFunctionCount;
exports GetFunctionInfo;
exports OnDetach;
begin
end.
Test script:
program new;
{$loadlib mylib.dll}
procedure TestPlug;
begin
WriteLn(Hello('simba -=> delphi'));
WriteLn(HelloAgain);
end;
begin
TestPlug;
end.
Output:
Compiled successfully in 343 ms.
simba -=> delphi
Exception in Script: Runtime error: "Access violation" at line 8, column 10Simba version is 1.0.4, heh.Cheers,Cynic.
