Results 1 to 2 of 2

Thread: C plugin halp

  1. #1
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default C plugin halp

    I got this C code



    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

    Code:
    EXPORTS
    	GetFuncCount@0 @ 1
    	GetFuncInfo = GetFuncInfo@12 @ 2
    	GetFuncInfo@12 @ 3
    	GetFunctionCallingConv = GetFunctionCallingConv@4 @ 4
    	GetFunctionCallingConv@4 @ 5
    	GetFuncCount = GetFuncCount@0 @ 6
    Simba code
    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

  2. #2
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    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...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •