Results 1 to 11 of 11

Thread: .dll in c++ --> to Simba

  1. #1
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default .dll in c++ --> to Simba

    This is first time I make DLL ,so I'm green ,please be patient.

    I read this:
    http://villavu.com/forum/showthread.php?t=39677

    and this:

    http://rvelthuis.de/articles/articles-cppobjs.html

    and made this in Dec-C++ :

    http://pastebin.com/pBz3PbAi


    Tried:

    Simba Code:
    program new;
    {$loadlib project2.dll}

    begin
    addC(2);
    end.
    Code:
    [Error] (8:1): Unknown identifier 'addC' at line 7
    What's wrong?

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Don't you need that whole functioncount stuff etc?

    http://villavu.com/forum/showthread.php?t=71883

    function GetFunctionCount: integer; stdcall;
    function GetFunctionInfo (x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): integer; stdcall;
    function GetFunctionCallingConv(x: integer): integer; stdcall;
    function GetTypeCount: integer; stdcall;
    function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
    procedure SetPluginMemManager(MemMgr : TMemoryManager); stdcall;
    Working on: Tithe Farmer

  3. #3
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Don't you need that whole functioncount stuff etc?

    http://villavu.com/forum/showthread.php?t=71883

    function GetFunctionCount: integer; stdcall;
    function GetFunctionInfo (x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): integer; stdcall;
    function GetFunctionCallingConv(x: integer): integer; stdcall;
    function GetTypeCount: integer; stdcall;
    function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
    procedure SetPluginMemManager(MemMgr : TMemoryManager); stdcall;
    I don't know ,compiler makes .def file itself ,I can't change it ,because it will be overwritten. And it's looks like:
    Code:
    ; dlltool --base-file C:\Users\user\AppData\Local\Temp/cca05276.base --output-exp Project2.exp --dllname Project2.dll --output-def libProject2.def --no-export-all-symbols --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def C:\Users\user\AppData\Local\Temp/cca05276.def --output-lib libProject2.a
    EXPORTS
    	addC@4 @ 1
    	addC = addC@4 @ 2

  4. #4
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    In the thread you posted from villavu read the section titled: "Exporting Functions"

  5. #5
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by mormonman View Post
    In the thread you posted from villavu read the section titled: "Exporting Functions"
    You mean this?
    http://villavu.com/forum/showthread.php?t=39677
    there is no such section.

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Just look at these two files:

    https://github.com/BenLand100/SMART/...c/libsmart.def

    https://github.com/BenLand100/SMART/...r/src/Main.cpp

    You will note that there is a deff file and that this is used to communicate with simba:

    PHP Code:
    #define NumExports 79

    //STDCALL - SCAR/Simba
    long GetFunctionCount() {
        return 
    NumExports;
    }

    //STDCALL - SCAR/Simba
    long GetFunctionInfo(int indexvoid*& addresschar*& def) {
        if (
    index NumExports) {
            
    address dlsym(RTLD_DEFAULT,exports[index*2]);
            
    strcpy(defexports[index*2+1]);
            return 
    index;
        }
        return -
    1;

    Working on: Tithe Farmer

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    No.. the .def file is the DLL definition file and it's only needed when you don't use _declspec(dllexport)..

    he's just missing the simba requirements which is the function count and stuff..
    I am Ggzz..
    Hackintosher

  8. #8
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by ggzz View Post
    No.. the .def file is the DLL definition file and it's only needed when you don't use _declspec(dllexport)..

    he's just missing the simba requirements which is the function count and stuff..
    I've never came much farther with c++ than "hello world" . Also it is hard to see what he was missing if the source of his dll is gone. Maybe we need a C++ plugin template? Cause I've searched a lot for this information.
    Working on: Tithe Farmer

  9. #9
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Post the dll here, for some reason i cant access the pastebin. Also, did you use 'extern C' while exporting the func/proc anywhere in your code? Because c++ does name mangling unless you tell it not to.

  10. #10
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Well ,I added some stuff found in this thread:

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

    .cpp:
    http://pastebin.com/uQ7kwkMm

    .h:
    http://pastebin.com/M1tYYQXp

    and:

    Simba Code:
    program new;
    {$loadlib Project2.dll}
    begin
    addc(1);
    end.

    Code:
    Your DLL Project2.dll has not been found
    Your DLL Project2.dll has not been found
    Exception in Script: Unknown compiler directives at 3:3
    Maybe we need a C++ plugin template?
    That's great idea.

    Also, did you use 'extern C' while exporting the func/proc anywhere in your code?
    Yes,I did.
    Last edited by bg5; 03-03-2012 at 06:32 AM.

  11. #11
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    I think either we need an export table OR u need to compile with Mingw and that stupid .def file..

    I don't think it'll work with codeblocks because codeblocks overwrites the .def file upon compiling and after a little reading, it seems u need it ={
    AND since it's pascal types the compiler should have something called #PASCAL defined as __attribute(declspec) or something like that..

    Also since it's being exported to pascal, I just read that u MUST provide the Symbolic/Mangled Name for the functions instead.. so.. cdecl or __stdcall should remove the _ from the symbolic name.. OR it could be a __fastcall? can't remember

    Code:
    DLL_EXPORT int __stdcall GetFunctionInfo(int x, void*& address, char*& def)
    {
        switch(x)
        {
            case 0:
                address = (void*)GetProcAddress(hinstance, "_AddC@0");  //Cast to (Void*)   Where it says _AddC@0 must be the symbolic name.. Found in the .def I think
                strcpy(def ,"procedure AddC(I: Integer);"); //This is how pascal will call the function..
                return x;
        }
        return -1;
    }
    I am Ggzz..
    Hackintosher

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
  •