SRL Archive - OSR Help

C plugin halp


slushpuppy

2012-04-21 05:14:43

I got this C code



#include <string.h>
#define DllExport extern __declspec( dllexport ) __stdcall


static int __stdcall a() {
return 42;
}

DllExport int GetFuncCount(void) {
return 1;
}

DllExport int 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;
}
DllExport int GetFunctionCallingConv(int x) {
return 1;
}

This is the def file generated by the linker

EXPORTS
GetFuncCount@0 @ 1
GetFuncInfo = GetFuncInfo@12 @ 2
GetFuncInfo@12 @ 3
GetFunctionCallingConv = GetFunctionCallingConv@4 @ 4
GetFunctionCallingConv@4 @ 5
GetFuncCount = GetFuncCount@0 @ 6

Simba code
program New;
{$loadlib test.dll}

begin
writeln(inttostr(a()));
end.

This is my error

Your DLL test.dll has not been found
Your DLL test.dll has not been found
Exception in Script: Unknown compiler directives at 3:3

slushpuppy

2012-04-21 05:33:19

Wow… actually adding this to the end of the C code


__declspec(dllexport) int GetFunctionCount(void) __attribute__((alias("GetFuncCount@0")));
__declspec(dllexport) int GetFunctionInfo(int x, void **addr, char **def) __attribute__((alias("GetFuncInfo@12")));

thanks - http://villavu.com/forum/showthread.php?t=66021

made all the difference o.O I wonder why…