Dgby714
2011-06-12 22:55:22
FreePascal
C
Feel Free to post more info. =)
library libDG;
{$mode objfpc}{$H+}
uses
cmem, Classes, Sysutils;
function a(): integer;
begin
Result := 42;
end;
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 1;
end;
function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0: begin
ProcAddr := @a;
StrPCopy(ProcDef, 'function a(): integer;');
end;
else
x := -1;
end;
Result := x;
end;
exports GetFunctionCount;
exports GetFunctionInfo;
initialization
end.C
#include <string.h>
static int __stdcall a() {
return 42;
}
static int __stdcall GetFuncCount(void) {
return 1;
}
static int __stdcall GetFuncInfo(int x, void **addr, char **def) {
switch (x) {
case 0:
*addr = (void *)&a;
strcpy(*def, "function a(): integer;");
break;
default:
x = -1;
}
return x;
}
int GetFunctionCount(void) __attribute__((alias("GetFuncCount@0")));
int GetFunctionInfo(int x, void **addr, char **def) __attribute__((alias("GetFuncInfo@12")));Feel Free to post more info. =)