Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { Example based upon the SPS Plugin }
- library test;
- {$mode objfpc}{$H+}
- {$macro on}
- {$define callconv:=
- {$IFDEF WINDOWS}{$IFDEF CPU32}cdecl;{$ELSE}{$ENDIF}{$ENDIF}
- {$IFDEF LINUX}{$IFDEF CPU32}cdecl;{$ELSE}{$ENDIF}{$ENDIF}
- }
- uses
- classes, sysutils, math
- { you can add units after this };
- var
- OldMemoryManager: TMemoryManager;
- memisset: Boolean = False;
- type
- TIntegerArray = array of Integer;
- function Leak: TIntegerArray; callconv
- var
- i: Integer;
- begin
- SetLength(Result, 1000000);
- for i := 0 to 999999 do
- Result[i] := i;
- end;
- function GetPluginABIVersion: Integer; callconv export;
- begin
- Result := 2;
- end;
- procedure SetPluginMemManager(MemMgr : TMemoryManager); callconv export;
- begin
- if memisset then
- Exit;
- GetMemoryManager(OldMemoryManager);
- SetMemoryManager(MemMgr);
- memisset := True;
- end;
- procedure OnDetach; callconv export;
- begin
- SetMemoryManager(OldMemoryManager);
- end;
- function GetFunctionCount(): Integer; callconv export;
- begin
- Result := 1;
- end;
- function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; callconv export;
- begin
- case x of
- 0:
- begin
- ProcAddr := @Leak;
- StrPCopy(ProcDef, 'function Leak: TIntegerArray;');
- end;
- else
- x := -1;
- end;
- Result := x;
- end;
- exports GetPluginABIVersion;
- exports SetPluginMemManager;
- exports GetFunctionCount;
- exports GetFunctionInfo;
- exports OnDetach;
- begin
- end.
Advertisement
Add Comment
Please, Sign In to add comment