Page 10 of 12 FirstFirst ... 89101112 LastLast
Results 226 to 250 of 287

Thread: Interception with DirectX

  1. #226
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Wow, Nice work on this mate!

    Forum account issues? Please send me a PM

  2. #227
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks everyone

    I have a problem with the plugin now, simba just crashes for some reason when it tries to load my plugin. It is a weird problem because if i set GetFunctionCount() to return 1, it works fine but if it is set to anything higher it will somehow mess up. And i have 3 functions that i am trying to export, the addresses and pascal-type declaration are checked and they are fine.

    If someone who has more experience in plugins could take a look at the source i would appreciate it.

    Some things are from silentwolf's plugin so credits to him.

    And yea i can change any of the other two exports to be the first and they work well when GFC returns 1 so there is no problem with any specific export. I compile it with Visual Studio C++ 2008 Express.

    Code:
    #include <windows.h>
    #include <stdio.h>
    
    #define Export __declspec(dllexport)
    #define DelphiExport extern "C" Export
    
    #define DX_PIPE "\\\\.\\pipe\\DxInterceptPipe"
    
    DelphiExport int GetPluginABIVersion();
    DelphiExport int GetFunctionCount();
    DelphiExport int GetFunctionInfo(int x, void** address, char** def);
    
    DelphiExport bool DXI_Connect();
    DelphiExport void DXI_Disconnect();
    DelphiExport int DXI_MakeCompass(int angle);
    
    HINSTANCE inst = NULL;
    HANDLE hPipe = INVALID_HANDLE_VALUE;
    
    BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID reserved)
    {
        switch(reason) 
    	{
        case DLL_PROCESS_ATTACH:
    		{
                inst = hInstance;
    			return true;
    		} break;
    
        case DLL_PROCESS_DETACH:
    		{
                FreeLibrary(inst);
    		} break;
        }
        return false;
    }
    
    DelphiExport bool DXI_Connect()
    {
    	if(hPipe != INVALID_HANDLE_VALUE)
    		return true;
    
    	hPipe = CreateFile(DX_PIPE, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
    	return (hPipe != INVALID_HANDLE_VALUE);
    }
    
    DelphiExport void DXI_Disconnect()
    {
    	if(hPipe != INVALID_HANDLE_VALUE)
    		CloseHandle(hPipe);
            hPipe = INVALID_HANDLE_VALUE;
    }
    
    DelphiExport int DXI_MakeCompass(int angle)
    {
    	if(hPipe == INVALID_HANDLE_VALUE)
    		return -1;
    
    	float request = (float)angle;
    	DWORD written = 0;
    	BOOL success = WriteFile(hPipe, &request, 4, &written, NULL);
    	if(!success || written != 4)
    	{
    		return -1;
    	}
    
    	float receive;
    	DWORD read = 0;
    	success = ReadFile(hPipe, &receive, 4, &read, NULL);
    	if(success && read == 4)
    	{
    		return (int)receive;
    	}
    
    	return -1;
    }
    
    DelphiExport int GetPluginABIVersion()
    {
        return 2;
    }
    
    DelphiExport int GetFunctionCount()
    {
        return 1; //with 1 works well, 2 or 3 makes it crash
    }
    
    #pragma warning(disable : 4996) //strcpy not safe
    DelphiExport int GetFunctionInfo(int x, void** address, char** def) 
    {
        switch(x) 
    	{
        case 0:
    		{
                *address = GetProcAddress(inst, "DXI_MakeCompass");
    			strcpy(*def, "function DXI_MakeCompass(angle: integer): integer;");
    		} break;
    
    	case 1:
    		{
                *address = GetProcAddress(inst, "DXI_Connect");
    			strcpy(*def, "function DXI_Connect: boolean;");
    		} break;
    
    	case 2:
    		{
                *address = GetProcAddress(inst, "DXI_Disconnect");
    			strcpy(*def, "procedure DXI_Disconnect();");
    		} break;
    
    	default:
    		{
    			char buff[128];
    			memset(buff, 0, 128);
    			sprintf_s(buff, 128, "Wrong function index: %i", x);
    			MessageBox(NULL, buff, "info", MB_OK);
    			x = -1;
    		}
        }
    
    	return x;
    }
    #pragma warning(default : 4996)
    Last edited by Mato; 07-09-2012 at 12:50 PM.

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

    Default

    Use *& to assign to a pointer. Don't assign to the pointer like that. Use a reinterpret_cast if you're strict on this being C++ rather than a c-style cast. Static won't work here. That's all I changed I think?

    Sorry I removed your pragma warnings because I used sprintf instead of sprintf_s.

    C++ Code:
    #include <windows.h>
    #include <stdio.h>

    #define Export __declspec(dllexport)
    #define DelphiExport extern "C" Export

    #define DX_PIPE "\\\\.\\pipe\\DxInterceptPipe"

    DelphiExport int GetPluginABIVersion();
    DelphiExport int GetFunctionCount();
    DelphiExport int GetFunctionInfo(int x, void*& address, char*& def);

    DelphiExport bool DXI_Connect();
    DelphiExport void DXI_Disconnect();
    DelphiExport int DXI_MakeCompass(int angle);

    HINSTANCE inst = NULL;
    HANDLE hPipe = INVALID_HANDLE_VALUE;

    BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID reserved)
    {
        switch(reason)
        {
        case DLL_PROCESS_ATTACH:
            {
                inst = hInstance;
                return true;
            } break;

        case DLL_PROCESS_DETACH:
            {
                FreeLibrary(inst);
            } break;
        }
        return false;
    }

    DelphiExport bool DXI_Connect()
    {
        if(hPipe != INVALID_HANDLE_VALUE)
            return true;

        hPipe = CreateFile(DX_PIPE, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
        return (hPipe != INVALID_HANDLE_VALUE);
    }

    DelphiExport void DXI_Disconnect()
    {
        if(hPipe != INVALID_HANDLE_VALUE)
            CloseHandle(hPipe);
            hPipe = INVALID_HANDLE_VALUE;
    }

    DelphiExport int DXI_MakeCompass(int angle)
    {
        if(hPipe == INVALID_HANDLE_VALUE)
            return -1;

        float request = (float)angle;
        DWORD written = 0;
        BOOL success = WriteFile(hPipe, &request, 4, &written, NULL);
        if(!success || written != 4)
        {
            return -1;
        }

        float receive;
        DWORD read = 0;
        success = ReadFile(hPipe, &receive, 4, &read, NULL);
        if(success && read == 4)
        {
            return (int)receive;
        }

        return -1;
    }

    DelphiExport int GetPluginABIVersion()
    {
        return 2;
    }

    DelphiExport int GetFunctionCount()
    {
        return 3; //with 1 works well, 2 or 3 makes it crash
    }

    DelphiExport int GetFunctionInfo(int x, void*& address, char*& def)
    {
        switch(x)
        {
        case 0:
            {
                address = reinterpret_cast<void*>(GetProcAddress(inst, "DXI_MakeCompass"));
                strcpy(def, "function DXI_MakeCompass(angle: integer): integer;");
            } break;

        case 1:
            {
                address = reinterpret_cast<void*>(GetProcAddress(inst, "DXI_Connect"));
                strcpy(def, "function DXI_Connect: boolean;");
            } break;

        case 2:
            {
                address = reinterpret_cast<void*>(GetProcAddress(inst, "DXI_Disconnect"));
                strcpy(def, "procedure DXI_Disconnect();");
            } break;

        default:
            {
                char buff[128];
                memset(buff, 0, 128);
                sprintf(buff, "Wrong function index: %i", 128);
                MessageBox(NULL, buff, "info", MB_OK);
                x = -1;
            }
        }

        return x;
    }

    Last edited by Brandon; 07-09-2012 at 01:53 PM.
    I am Ggzz..
    Hackintosher

  4. #229
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the help but it still crashes with the exact same code you have there. I think its something to do with the simba version, i see you use 990 and i use 984. Ill download the newest one too and check if it works with it.

    EDIT: Yep, that was it. Works beutifully now Again thanks for the help.
    Last edited by Mato; 07-09-2012 at 02:10 PM.

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

    Default

    You're right.. I just downgraded Simba to 0.984, it crashes.. I got a stacktrace though but it isn't helpful in any way.
    I also tried it with the new libsmart (Not remote) and it also crashes. Made my own plugin and that crashes too. Dunno why either.

    With that said, use the 0.99 I guess since it works there.. The below shows 0.984 trying to load your plugin twice. Time to re-upgrade then.

    For any on lookers, You can try running simba through CMD and see what I mean.. It'll look like:
    Code:
    Microsoft Windows [Version 6.2.8400]
    (c) 2012 Microsoft Corporation. All rights reserved.
    
    C:\Users\Brandon>C:/Simba/Simba.exe
    Setting LastConfig/MainForm/RecentFiles/File10 to
    You cannot hide the window, since its not created by Simba
    No valid command line args are passed
    Init procedure successfully called
    Init procedure successfully called
    Init procedure successfully called
    Setting Extensions/ExtensionCount to 10
    Adding Plugin Path: C:\Simba\Plugins\
    Adding Plugin Path: C:\Simba\Plugins\
    Current Simba version: 984
    Latest Simba Version: 984
    Loading plugin ExportPascal at C:\Simba\Plugins\
    funcinfo 0
    funcinfo 1
    funcinfo 2
    Loading plugin ExportPascal at C:\Simba\Plugins\
    funcinfo 0
    funcinfo 1
    funcinfo 2
    TApplication.HandleException Access violation
      Stack trace:
      $0040C2C8
      $0053B8AE
      $759C7704
      $759C842B
      $759C81ED
      $759C82DA
      $0053E505
      $00421E39
      $0042227F
      $00460513
      $0042223A
      $0042223A
    
    C:\Users\Brandon>
    I am Ggzz..
    Hackintosher

  6. #231
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Mato how does your direct x walking work? Can work out a way to get tiles or what :P Just wondering.

  7. #232
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    He uses the Geometry of runescape surface I think pretty clever and accurate

  8. #233
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thats right. The paths are just arrays of points relative to the path starting point. The starting point is found by searching the surface geometry for that point so it only has to find the one point once and then it can walk along the path correctly regardless of compass angle.

  9. #234
    Join Date
    Oct 2011
    Location
    Australia, Vic
    Posts
    1,517
    Mentioned
    2 Post(s)
    Quoted
    120 Post(s)

    Default

    Quote Originally Posted by Mato View Post
    Thats right. The paths are just arrays of points relative to the path starting point. The starting point is found by searching the surface geometry for that point so it only has to find the one point once and then it can walk along the path correctly regardless of compass angle.
    I'm Guessing you dont have an ETA on this? I can't wait to Integrate this into my scripts

  10. #235
    Join Date
    Nov 2011
    Posts
    1,589
    Mentioned
    9 Post(s)
    Quoted
    17 Post(s)

    Default

    Same as John
    It'll be amazing if you had a vague ETA
    Mat



    ^^

  11. #236
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    I've been eager for this myself we just have to be patient as this is a one man show atm.

    I'm currently looking into the basics of C++ myself so I could possible help in the near future but I have to admit the language is ugly as hell.

  12. #237
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This might be a stupid question but what do you mean by ETA? I tried to search for it in google but didnt find anything that would fit this topic.

  13. #238
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    haha you need to watch more action films estimated time arrival

  14. #239
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oh yea haha :P I was linking it to some copyright related stuff But yea i cant give a accurate ETA cause i just do this in my freetime when i feel like it

  15. #240
    Join Date
    Oct 2011
    Location
    Australia, Vic
    Posts
    1,517
    Mentioned
    2 Post(s)
    Quoted
    120 Post(s)

    Default

    Quote Originally Posted by Mato View Post
    Oh yea haha :P I was linking it to some copyright related stuff But yea i cant give a accurate ETA cause i just do this in my freetime when i feel like it
    It's all good Just don't leave us like Silent wolf

  16. #241
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by John View Post
    It's all good Just don't leave us like Silent wolf
    This looks familiar... Oh right!

    Quote Originally Posted by Sex View Post
    Awesome . Just don't leave us like silentwolf .

    Silentwolf left long before you were around here, John.

    On another note, Silentwolf worked with OpenGL and the project was continued by Aftermath and MissSilabsoft over at MITB. Infact, an OGL plugin for Simba is still fully functional to this day; Aftermath wrote many anti-randoms through the plugin alone. So Silentwolf's leaving was not "the end of it".

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  17. #242
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Alrite bud been tryng to play with the pluggin having trouble injecting the dll now which i wasnt befoe this version has anything changed to effect the injection process ?

  18. #243
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Mato, how long did it take to get it this far, like, when did you start working on it?

  19. #244
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I started with this about 1 and a half months ago. And no, nothing in that side has changed so the injection should go just like before. Can you give me a more detailed report of the problem and the log file if it ran long enough to print it so i could see where the problem is? And also did you switch to directx first, reload the game and then inject or did you just try to switch to directx after injection? If you did like last way, do it the way i said first.

  20. #245
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    ive tried it both ways
    here is the log file

    Code:
    HandlePipe(): Pipe succesfully created
    addrCallCreateDevice: 0x634A257A
    hWnd: 0x000402CE
    Hooks initialized
    also i have no problems using the other DLL injects perfect with that one allows me Show id ect while this one doesnt also tried running the Compas procedure from pluggin it correcty calls the function Mouse moves ect but due to it not injecting doesnt correctly change angle.

  21. #246
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If the mouse moves even a bit it means that it should be running properly. Did you remember to press numpad 4 ingame so the text pops out? Im on my phone atm so i cant check but you might need to press that key for it to start updating the minimap position and angle so try that. If no luck with that, i cant do more from my phone.

  22. #247
    Join Date
    Mar 2012
    Posts
    690
    Mentioned
    2 Post(s)
    Quoted
    40 Post(s)

    Default

    Nice work on the first post but you forgot the links to download your project :P

  23. #248
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Quote Originally Posted by Mato View Post
    If the mouse moves even a bit it means that it should be running properly. Did you remember to press numpad 4 ingame so the text pops out? Im on my phone atm so i cant check but you might need to press that key for it to start updating the minimap position and angle so try that. If no luck with that, i cant do more from my phone.
    Yeah i pressed num 4 but nothing shows up like it used to will have to try later on
    busy sorting y fishing gear tonite the mrs been chewing my ear off to sort the shed out for awhile now :/

  24. #249
    Join Date
    Jun 2012
    Location
    THE Students-City of Holland
    Posts
    332
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Nice project! Subscribed and +REP. I hope this will still work after optimus though
    Former Name: MasterCrimeZ.
    ToDo: 1. Finish my private bot 2. Make some cool bots for this community 3. Become a member
    If you have any questions about scripting, feel free to PM me

  25. #250
    Join Date
    Oct 2011
    Location
    Australia, Vic
    Posts
    1,517
    Mentioned
    2 Post(s)
    Quoted
    120 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    This looks familiar... Oh right!




    Silentwolf left long before you were around here, John.

    On another note, Silentwolf worked with OpenGL and the project was continued by Aftermath and MissSilabsoft over at MITB. Infact, an OGL plugin for Simba is still fully functional to this day; Aftermath wrote many anti-randoms through the plugin alone. So Silentwolf's leaving was not "the end of it".
    I knew i read about him some where

Page 10 of 12 FirstFirst ... 89101112 LastLast

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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