Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: C++ Plugins!

  1. #1
    Join Date
    Feb 2006
    Location
    Berkeley, CA
    Posts
    1,837
    Mentioned
    52 Post(s)
    Quoted
    60 Post(s)

    Default C++ Plugins!

    Anyway, I was trying to make a c++ plugin for scar, and it didn't work. So I went through the trouble of making a plugin that would manualy inject a c++ dll into scar, only to find out that I had messed up an address for a pointer... Needless to say its easier than memory injection Ask questions, etc.

    Code:
    #include <windows.h>
    #define Export _declspec(dllexport)
    #define DelphiExport extern "C" Export
    
    HINSTANCE inst;
    
    Export BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID checks) {
        switch(reason) {
            case DLL_PROCESS_ATTACH:
                //Do you're init here, but don't change anything else (besides cleanup)
                inst = instance;
            case DLL_THREAD_ATTACH:
                return true;
            case DLL_PROCESS_DETACH:
                //Do you're cleanup here, but don't change anything else (besides init)
                FreeLibrary(inst);
            case DLL_THREAD_DETACH:
                return true;
        }
        return false;
    }
    
    //Add in your functions
    
    DelphiExport void __stdcall Test(void) { 
        //Shows a message box.
        MessageBox(NULL, "Testing 1 2 3", "DLL", MB_OK);
    }
    
    //Export name changed in def file
    DelphiExport int __stdcall GetFunctionCount(void) {
        return 1; //Change depending on number to export
    }
    
    //Export name changed in def file
    DelphiExport int __stdcall GetFunctionInfo(int x, void*& address, char*& def) {
        switch (x) {
            case 0:
                address = GetProcAddress(inst,"_Test@0");  //Remember C naming scheme?
                strcpy(def,"procedure DllTest;"); //Have to strcpy, how you want it to be called
                return x;
        }
        return -1;
    }
    Plus the REQUIRED def file:
    Code:
    LIBRARY    ScarPlugin
    EXPORTS
    GetFunctionInfo = _GetFunctionInfo@12
    GetFunctionCount = _GetFunctionCount@0

  2. #2
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Muahah No One Cares Ben!

  3. #3
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe cause we don't understand
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  4. #4
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Remember this post by Lorax:
    Quote Originally Posted by Lorax View Post
    you know BenLand is this little math kid that no one understands.
    So because we don't understand we just do like: "mmhm, yeah, woaw, jubii, hello, mmhm, yea, neat, hey, juhu" or stuff like that, so it goes in one of the eyes and out the other
    Ben is just too smart for us normal people to understand
    I made a new script, check it out!.

  5. #5
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    yes. ben is smart but doesnt mean he always uses his brain. XD

  6. #6
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Haha, apparently Ben is a quick learner.

    About what SKy said:

    Quote Originally Posted by BenLand100
    erm... i didn't even know there was a general public board , they've been minimized at the bottom of my srl page
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  7. #7
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    lol, {lol sorry ben had to save that }

    Another neat thing to do is take some 10-8 guage wire, wrap it in 5-7 loops around a coke can (0.5 inches spacing) and put that coil (without the can!!!) into the center of a satalite dish (comming through the back. Now hook that coil up to a large energy source (em pulser or cap bank) and *quickly* dump the entire load into it. The wire will vaporize into an almost superconductive plasma and...
    Ben Land says:
    generate a massive em field which will be focused at a target by the dish effectivly destroying any electronics in its range

  8. #8
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey, if you don't mind me asking,

    What are you planing to do with C++ plugins?

  9. #9
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by SKy Scripter View Post
    Another neat thing to do is take some 10-8 guage wire, wrap it in 5-7 loops around a coke can (0.5 inches spacing) and put that coil (without the can!!!) into the center of a satalite dish (comming through the back. Now hook that coil up to a large energy source (em pulser or cap bank) and *quickly* dump the entire load into it. The wire will vaporize into an almost superconductive plasma and...
    Ben Land says:
    generate a massive em field which will be focused at a target by the dish effectivly destroying any electronics in its range
    wow...

  10. #10
    Join Date
    Jun 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    so, this lets me use C++ on scar?

    GREAT!

    next week i am taking a C++ camp/course

    I cant wait to apply my new c++ skills in scar!

    thanks!

  11. #11
    Join Date
    Feb 2006
    Location
    Belgium
    Posts
    3,137
    Mentioned
    3 Post(s)
    Quoted
    5 Post(s)

    Default

    Heh, my tutorial was the best I could do without actually learning c++

    EDIT: Hmm, ben, with what compiler do you have to compile this? Borland C++ Builder 6 compiles it, but it doesn't import into SCAR

  12. #12
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    its great if you want to run c code in scar, the most universal language!

    And check out my pascal interpreter!
    <R0b0t1> No, really, I went to a bar and picked up a transvestite.

  13. #13
    Join Date
    Feb 2006
    Location
    Berkeley, CA
    Posts
    1,837
    Mentioned
    52 Post(s)
    Quoted
    60 Post(s)

    Default

    Quote Originally Posted by Freddy1990 View Post
    EDIT: Hmm, ben, with what compiler do you have to compile this? Borland C++ Builder 6 compiles it, but it doesn't import into SCAR
    Should compile on anything. I used VC++ 6. Make sure you have the .def file to change the export names

  14. #14
    ronny.m.p Guest

    Default

    Hey ben. How exactly do these files work (what do I have to do) and what do I save those two text files as (ext)?

  15. #15
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    Eh. How do I use the DEF file?


    *sorry for mega-bump*
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  16. #16
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,691
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Big bump again. Thanks, Ben.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  17. #17
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Big bump again. Thanks, Ben.
    That's an infraction.. No grave digging here.. I'm sorry.
    Verrekte Koekwous

  18. #18
    Join Date
    Dec 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Suppose that works, not the way I would do it benland, but that's because I angst windows programming.

    By the by, why are you declaring them as standard calls; Isn't that default?

    And the functions don't do much, so technically __fastcall is your friend!

  19. #19
    Join Date
    Oct 2006
    Location
    MI USA
    Posts
    3,166
    Mentioned
    6 Post(s)
    Quoted
    11 Post(s)

    Default

    Quote Originally Posted by pplsuqbawlz View Post
    Suppose that works, not the way I would do it benland, but that's because I angst(against) windows programming.

    By the way, why are you declaring them as standard calls; Isn't that default?

    And the functions don't do much, so technically __fastcall is your friend!
    Wow, an Old topic keeps getting bumped, seems there is still an interest in this....and considering who is bumping, I think we'll let it slide and await Ben's reply here

    BTW, Welcome pplsuqbawlz, your reputation precedes you

    ~RAM

  20. #20
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,691
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by RAM View Post
    Wow, an Old topic keeps getting bumped, seems there is still an interest in this....
    Could be... since Embedded Smart.dll is made in C++.
    I'll try to link BenLand to this topic next time he's online.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  21. #21
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Could be... since Embedded Smart.dll is made in C++.
    I'll try to link BenLand to this topic next time he's online.
    Evil undecompiling c++


  22. #22
    Join Date
    Feb 2006
    Location
    Berkeley, CA
    Posts
    1,837
    Mentioned
    52 Post(s)
    Quoted
    60 Post(s)

    Default

    Quote Originally Posted by Farseercccp View Post
    This is all useless for scar scripting. C++ is only useful if you are working on a project similar to autorune.
    Or making something like SMART... Pwnt?

    Quote Originally Posted by pplsuqbawlz View Post
    Suppose that works, not the way I would do it benland, but that's because I angst windows programming.

    By the by, why are you declaring them as standard calls; Isn't that default?

    And the functions don't do much, so technically __fastcall is your friend!
    Ya, I'm kind of tied to windows programming anyway since its mostly responsible for making the screen an image, and I need to control parts of that As for the standard calls, I'd rather be explicit than vague, plus the scar/delphi end requires them to be stdcall. I'm not sure if it would work another way (never tried, the delphi versions always explicitly used stdcall), though I'm pretty sure fastcall would use registers, and since scar/delphi does not know to do that... Basically i'm tied to whatever scar already knows how to do, if that makes any sense.

  23. #23
    Join Date
    Mar 2007
    Location
    Jersey
    Posts
    135
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well coding scar in C++ is like someone in the english (what we use in U.S.) measuring system trying to convert to SI (system international what foreign use) for comparing data, SMART is the only thing that should be in C++ for scar o.O its too much for our normal minds...
    http://i183.photobucket.com/albums/x181/logik00/sig.jpg

    Windows 95 is a 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company, that can't stand 1 bit of competition.

    This is how you can tell someone is a true RS autoer.
    Quote Originally Posted by xraye View Post
    Who is Andrew? lol
    http://i183.photobucket.com/albums/x...newonecopy.jpg

  24. #24
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,691
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Well Ben, it doesn't work on Code::Blocks. I can't get to compile the first part of your code.

    Code:
    F:\CodeBlocks Projects\SCARPlugin.cpp|39|error: invalid conversion from `int (*)()' to `void*'|
    Also, maybe you could be more clear on this .def file?



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  25. #25
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Well Ben, it doesn't work on Code::Blocks. I can't get to compile the first part of your code.

    Code:
    F:\CodeBlocks Projects\SCARPlugin.cpp|39|error: invalid conversion from `int (*)()' to `void*'|
    Also, maybe you could be more clear on this .def file?
    I've got it to work at only 1 compiler
    Verrekte Koekwous

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 12-20-2008, 06:19 PM
  2. plugins..help?
    By n0n4m311 in forum OSR Help
    Replies: 3
    Last Post: 10-04-2008, 03:59 PM
  3. Replies: 2
    Last Post: 01-18-2008, 10:20 PM

Posting Permissions

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