Page 7 of 9 FirstFirst ... 56789 LastLast
Results 151 to 175 of 220

Thread: OpenGL plugins

  1. #151
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    I have no knowledge of dx hooking/c++, so i couldnt help with the plugin...
    but i'd definitely help out with building and maintaining the include from scratch, all i need are the functions equivalent to those in glxcore.simba. So u won't have to build/maintain the include if that's what u cant be bothered with.

    Also u mentioned before an ogl plugin w/o texture hooks wont have any leaks? but arent the textures already inherently present in the game? (i.e. playing rs w/o the plugin still cause leaks).

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

    Default

    Quote Originally Posted by Brandon View Post
    I understand everyone wants a sort of reflection for RS3 and I understand the OpenGL plugin is absolute crap and is barely usable.. but..

    I don't know :S
    I never planned to do another hook plugin. There's not really anyone around that would be able to work on it with me. I get bored working on things.. Villavu alone has seen a TON of my abandoned scripts and projects. Very few programmers around here took game programming or are only used to engines and api's (not raw api's), so I'd be soloing this one. Direct-X debuggers are scarce or really crap so you'll either have to know assembly or a deep deep understanding of what's going on (and I mean deep! because Jagex).

    I had help with the OpenGL plugin (from Kasi) but that took long.. Believe me.. We both stayed up nights working on that thing to try and fix the problems with it. Sometimes I went to sleep, woke up and saw him still online working on it and vice-versa.. But he had to learn some OpenGL from scratch to help out with that.

    It's also completely different from OpenGL (I really really mean that).. On top of all the game programming is the language itself. HLSL (shader language and shader assembly) and C or C++ (main programming language for Direct-X.. although you can use Pascal or Delphi).

    Direct-X is easier but still time consuming. I don't mind publishing what I currently have at all. Whether I plan to continue it is a different story.

    I honestly don't mind publishing it or making a github for it. Maybe if I feel like working on it, I could push updates in increments but honestly, I CANNOT PROMISE anything.


    Not sure if you were around when Mato was here, but he was good at Direct-X and barely scratched the surface (around the same time I was writing the OpenGL hooks). IIRC he had models and texture ID generation but that was about the most I saw and he left no source or a very very incomplete source.

    I'll try to publish what I have or github it soon. If I do ever work on this again, I'd really really have to sit down and plan out every step. I'd have to think of what features to put in and the implementation, etc..
    I mean my C++ isn't fantastic, but I'd actually sit down and learn how to maintain/update the plugin if you decide to push it to github. Shouldn't be too hard, am I right? :')

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

    Default

    Quote Originally Posted by Brandon View Post
    ...
    Do it in pascal.

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

    Default

    @Kasi; Thanks.

    Quote Originally Posted by Olly View Post
    Do it in pascal.
    Too late.. I uploaded it already and I don't think I want to port to PS.. too much typing.. Language is too wordy for me (maybe in the future).. You guys can find it here: https://github.com/Brandon-T/Genevieve

    I didn't know what to call it but I like that name so that it is.. Do whatever you want with it. I dumped all the important crap into the main file, math file, and graphics files.. A lot of it is incomplete but that's the very BASIC amount you'd need to do anything at all (other than screen-scraping).

    In fact, if you use the functions in there right now, you'd have models hooked and textures hooked and you'd be able to debug things on screen. Just have to put it together and feed it to Simba.

    Models are rendered with stride 12. Floors are stride 16 or 20. Minimap is drawn with DrawPrimitive. Models and textures are drawn with DrawIndexedPrimitive. A model is rendered either when the stride is 12 or when SetStreamSource is called with StreamNumber being 0.
    WorldViewProjection is stored in the shader register C0 and is size 4.

    Now everyone can work on it.. If you use the classes written, you will find that it is impossible to leak any resources (even if exceptions are thrown).. This design concept is known as RAII:

    http://en.wikipedia.org/wiki/Resourc...Initialization

    The code ONLY uses RAII. No resources/memory are manually allocated. Heavy use of C++11, very little ASMx86. Anyway.. enough talk of Direct-X on this OpenGL thread. It's too unorganised.

    Again.. it just needs putting together..
    Last edited by Brandon; 10-07-2014 at 03:16 AM.
    I am Ggzz..
    Hackintosher

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

    Default

    Slight update.. I don't feel like making a D3D hook thread atm..

    http://i.imgur.com/v3jlME2.png
    http://i.imgur.com/YhhRANM.png

    The below code is injected into the game. I didn't get around to making the game "load" it instead of injecting. It's faster to test stuff via injection rather than loading SMART or placing modules in the bin folder. Simple VTable hook really.

    Models hooks are pretty much (almost) complete.. I dumped everything into one file to make the post shorter.. Doesn't look like a lot but it uses all the code from the github so yeah..:

    C++ Code:
    #include <windows.h>
    #include <iostream>
    #include <d3d9.h>
    #include <d3dx9.h>
    #include <detours.h>
    #include <thread>
    #include <cstdint>
    #include <memory>
    #include <fstream>
    #include "Graphics.hxx"

    #pragma comment(lib, "WS2_32.lib")
    #pragma comment(lib, "d3d9.lib")
    #pragma comment(lib, "d3dx9.lib")
    #pragma comment(lib, "detours.lib")

    enum D3D9_vTable
    {
        QUERYINTERFACE,              
        ADDREF,                    
        RELEASE,                    
        TESTCOOPERATIVELEVEL,          
        GETAVAILABLETEXTUREMEM,        
        EVICTMANAGEDRESOURCES,        
        GETDIRECT3D,                  
        GET_DEVICE_CAPS,              
        GETDISPLAYMODE,              
        GETCREATIONPARAMETERS,        
        SETCURSORPROPERTIES,            
        SETCURSORPOSITION,            
        SHOW_CURSOR,                  
        CREATEADDITIONALSWAPCHAIN,      
        GETSWAPCHAIN,                  
        GETNUMBEROFSWAPCHAINS,        
        RESET,                    
        PRESENT,                    
        GETBACKBUFFER,              
        GETRASTERSTATUS,              
        SETDIALOGBOXMODE,              
        GETGAMMARAMP,                  
        SETGAMMARAMP,                  
        CREATETEXTURE,              
        CREATEVOLUMETEXTURE,            
        CREATECUBETEXTURE,            
        CREATEVERTEXBUFFER,            
        CREATEINDEXBUFFER,            
        CREATERENDERTARGET,            
        CREATEDEPTHSTENCILSURFACE,      
        UPDATESURFACE,              
        UPDATETEXTURE,              
        GETRENDERTARGETDATA,            
        GETFRONTBUFFERDATA,            
        STRETCHRECT,                  
        COLORFILL,                  
        CREATEOFFSCREENPLAINSURFACE,      
        SETRENDERTARGET,              
        GETRENDERTARGET,              
        SETDEPTHSTENCILSURFACE,        
        GETDEPTHSTENCILSURFACE,        
        BEGINSCENE,                  
        ENDSCENE,                    
        CLEAR,                    
        SETTRANSFORM,                  
        GETTRANSFORM,                  
        MULTIPLYTRANSFORM,            
        SETVIEWPORT,                  
        GETVIEWPORT,                  
        SETMATERIAL,                  
        GETMATERIAL,                  
        SETLIGHT,                    
        GETLIGHT,                    
        LIGHTENABLE,                  
        GETLIGHTENABLE,              
        SETCLIPPLANE,                  
        GETCLIPPLANE,                  
        SETRENDERSTATE,              
        GETRENDERSTATE,              
        CREATESTATEBLOCK,              
        BEGINSTATEBLOCK,              
        ENDSTATEBLOCK,              
        SETCLIPSTATUS,              
        GETCLIPSTATUS,              
        GETTEXTURE,                  
        SETTEXTURE,                  
        GETTEXTURESTAGESTATE,            
        SETTEXTURESTAGESTATE,            
        GETSAMPLERSTATE,              
        SETSAMPLERSTATE,              
        VALIDATEDEVICE,              
        SET_PALETTE_ENTRIES,            
        GET_PALETTE_ENTRIES,            
        SETCURRENTTEXTUREPALETTE,        
        GETCURRENTTEXTUREPALETTE,        
        SETSCISSORRECT,              
        GETSCISSORRECT,              
        SETSOFTWAREVERTEXPROCESSING,      
        GETSOFTWAREVERTEXPROCESSING,      
        SETNPATCHMODE,              
        GETNPATCHMODE,              
        DRAWPRIMITIVE,              
        DRAWINDEXEDPRIMITIVE,            
        DRAWPRIMITIVEUP,              
        DRAWINDEXEDPRIMITIVEUP,        
        PROCESSVERTICES,              
        CREATEVERTEXDECLARATION,        
        SETVERTEXDECLARATION,            
        GETVERTEXDECLARATION,            
        SETFVF,                    
        GETFVF,                    
        CREATEVERTEXSHADER,            
        SETVERTEXSHADER,              
        GETVERTEXSHADER,              
        SETVERTEXSHADERCONSTANTF,        
        GETVERTEXSHADERCONSTANTF,        
        SETVERTEXSHADERCONSTANTI,        
        GETVERTEXSHADERCONSTANTI,        
        SETVERTEXSHADERCONSTANTB,        
        GETVERTEXSHADERCONSTANTB,        
        SETSTREAMSOURCE,              
        GETSTREAMSOURCE,              
        SETSTREAMSOURCEFREQ,            
        GETSTREAMSOURCEFREQ,            
        SETINDICES,                  
        GETINDICES,                  
        CREATEPIXELSHADER,            
        SETPIXELSHADER,              
        GETPIXELSHADER,              
        SETPIXELSHADERCONSTANTF,          
        GETPIXELSHADERCONSTANTF,        
        SETPIXELSHADERCONSTANTI,        
        GETPIXELSHADERCONSTANTI,        
        SETPIXELSHADERCONSTANTB,        
        GETPIXELSHADERCONSTANTB,        
        DRAWRECTPATCH,              
        DRAWTRIPATCH,                  
        DELETEPATCH,                  
        CREATEQUERY,                  
    };

    typedef HRESULT(__stdcall *EndScene_t)(LPDIRECT3DDEVICE9 pDevice);
    typedef HRESULT(__stdcall *BeginScene_t)(LPDIRECT3DDEVICE9 pDevice);
    typedef HRESULT(__stdcall *Reset_t)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters);
    typedef HRESULT(__stdcall *DrawPrimitive_t)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
    typedef HRESULT(__stdcall *DrawIndexedPrimitive_t)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
    typedef HRESULT(__stdcall *DrawPrimitiveUP_t)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
    typedef HRESULT(__stdcall *DrawIndexedPrimitiveUP_t)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
    typedef HRESULT(__stdcall *SetTexture_t)(LPDIRECT3DDEVICE9 pDevice, DWORD Sampler, IDirect3DBaseTexture9 *pTexture);

    BeginScene_t o_BeginScene;
    EndScene_t o_EndScene;
    Reset_t o_Reset;
    DrawPrimitive_t o_DrawPrimitive;
    DrawIndexedPrimitive_t o_DrawIndexedPrimitive;
    DrawPrimitiveUP_t o_DrawPrimitiveUP;
    DrawIndexedPrimitiveUP_t o_DrawIndexedPrimitiveUP;
    SetTexture_t o_SetTexture;
    Font* font = NULL;

    HRESULT __stdcall DXI_BeginScene(LPDIRECT3DDEVICE9 pDevice)
    {
        static bool init = false;
        if (!init)
        {
            init = true;
            font = new Font(pDevice, "Arial", 8);
        }
        return o_BeginScene(pDevice);
    }

    HRESULT __stdcall DXI_EndScene(LPDIRECT3DDEVICE9 pDevice)
    {
        if (font)
            font->Draw(50, 50, "HELLO");
        return o_EndScene(pDevice);
    }

    //When the application is minimised, resources are destroyed and rebuilt automatically. It's how d3d works.
    HRESULT __stdcall DXI_Reset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters)
    {
        if (font)
            font->OnLostDevice();

        HRESULT res = o_Reset(pDevice, pPresentationParameters);

        if (font)
            font->OnResetDevice();

        return res;
    }

    HRESULT  __stdcall DXI_DrawPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount)
    {
        IDirect3DBaseTexture9* tex = nullptr;
        if (SUCCEEDED(pDevice->GetTexture(0, &tex)))
        {
            LPDIRECT3DTEXTURE9 _tex = (LPDIRECT3DTEXTURE9)tex;
            D3DSURFACE_DESC desc;
            if (SUCCEEDED(_tex->GetLevelDesc(0, &desc)))
            {
                if (desc.Width  && desc.Height) //51 x 51 = mini-map compass. Better to check on the Simba side. 512 x 512 = map.
                {
                    D3DXMATRIX WVP;
                    if (SUCCEEDED(pDevice->GetVertexShaderConstantF(0, (float*)&WVP, 4)))
                    {
                        D3DXMatrixTranspose(&WVP, &WVP);

                        D3DXVECTOR3 out;
                        D3DXVECTOR3 in(0, 0, 0);
                        D3DXVec3TransformCoord(&out, &in, &WVP);

                        D3DVIEWPORT9 viewport;
                        pDevice->GetViewport(&viewport);

                        out.x = (out.x + 1.0f) * viewport.Width * 0.5f + viewport.X;
                        out.y = (1.0f - out.y) * viewport.Height * 0.5f + viewport.Y;

                        if (font)
                            font->Draw(out.x, out.y, "Compass(%, %)", desc.Width, desc.Height);
                    }
                }
            }
            tex->Release();
        }
        return o_DrawPrimitive(pDevice, PrimitiveType, StartVertex, PrimitiveCount);
    }

    //function in which both textures AND models are drawn. Textures have a primCount of 2 and NumVertices of 4. Basically 2 triangles make up one square/rectangular texture.
    //models otherwise..
    HRESULT  __stdcall DXI_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
    {
        DWORD ID = GenerateID(pDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
        D3DXVECTOR3 out = WorldToScreen(pDevice); //Get the base center point of the model.. For more advanced accuracy, you can use ProcessVerts to get each and every vertex of said model (fingers, eyes, etc..)

        static bool debug = false;
        if (GetAsyncKeyState(VK_END) & 1)
            debug = !debug;

        if (font && debug)
            font->Draw(out.x, out.y, 0xFFFF0000, "%", ID);

        return o_DrawIndexedPrimitive(pDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
    }

    HRESULT __stdcall DXI_DrawPrimitiveUP(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride)
    {
        return o_DrawPrimitiveUP(pDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
    }

    HRESULT __stdcall DXI_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride)
    {
        return o_DrawIndexedPrimitiveUP(pDevice, PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
    }

    HRESULT __stdcall DXI_SetTexture(LPDIRECT3DDEVICE9 pDevice, DWORD Sampler, IDirect3DBaseTexture9 *pTexture)
    {
        return o_SetTexture(pDevice, Sampler, pTexture);
    }

    DWORD __stdcall InitialiseHooks(void* param);

    bool __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    {
        switch (fdwReason)
        {
        case DLL_PROCESS_ATTACH:
            DisableThreadLibraryCalls(hinstDLL);
            CreateThread(NULL, 0, InitialiseHooks, NULL, 0, 0);
            return true;

        case DLL_PROCESS_DETACH:
            break;

        default:
            break;
        }
        return true;
    }

    DWORD FindPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, const char* szMask)
    {
        auto bCompare = [](const BYTE* pData, const BYTE* bMask, const char* szMask) -> bool
        {
            for (; *szMask; ++szMask, ++pData, ++bMask)
            if (*szMask == 'x' && *pData != *bMask)
                return 0;
            return (*szMask) == 0;
        };

        for (DWORD i = 0; i < dwLen; ++i)
        if (bCompare(reinterpret_cast<std::uint8_t*>(dwAddress + i), bMask, szMask))
            return static_cast<DWORD>(dwAddress + i);
        return 0;
    }

    template<typename T, typename U>
    void DetourFunction(T &OriginalFunction, U HookFunction)
    {
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourAttach(&reinterpret_cast<void*&>(OriginalFunction), reinterpret_cast<void*>(HookFunction));
        DetourTransactionCommit();
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
    }

    DWORD WINAPI VTableRepatch(void* param)
    {
        while (true)
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(100));
            DetourFunction(o_BeginScene, DXI_BeginScene);
            DetourFunction(o_EndScene, DXI_EndScene);
            DetourFunction(o_Reset, DXI_Reset);
            DetourFunction(o_DrawPrimitive, DXI_DrawPrimitive);
            DetourFunction(o_DrawIndexedPrimitive, DXI_DrawIndexedPrimitive);
            DetourFunction(o_DrawPrimitiveUP, DXI_DrawPrimitiveUP);
            DetourFunction(o_DrawIndexedPrimitiveUP, DXI_DrawIndexedPrimitiveUP);
            DetourFunction(o_SetTexture, DXI_SetTexture);
        }
        return 0;
    }

    DWORD __stdcall InitialiseHooks(void* param)
    {
        while (!GetModuleHandle("d3d9.dll"))
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(100));
        }

        DWORD* VTable = nullptr;
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        static std::uint8_t bMask[] = { 0xC7, 0x06, 0x00, 0x00, 0x00, 0x00, 0x89, 0x86, 0x00, 0x00, 0x00, 0x00, 0x89, 0x86 };
        DWORD Address = FindPattern(reinterpret_cast<DWORD>(GetModuleHandle("d3d9.dll")), 0x128000, bMask, "xx????xx????xx");
        memcpy(&VTable, reinterpret_cast<void*>(Address + 2), 4);

        o_BeginScene = reinterpret_cast<BeginScene_t>(VTable[BEGINSCENE]);
        o_EndScene = reinterpret_cast<EndScene_t>(VTable[ENDSCENE]);
        o_Reset = reinterpret_cast<Reset_t>(VTable[RESET]);
        o_DrawPrimitive = reinterpret_cast<DrawPrimitive_t>(VTable[DRAWPRIMITIVE]);
        o_DrawIndexedPrimitive = reinterpret_cast<DrawIndexedPrimitive_t>(VTable[DRAWINDEXEDPRIMITIVE]);
        o_DrawPrimitiveUP = reinterpret_cast<DrawPrimitiveUP_t>(VTable[DRAWPRIMITIVEUP]);
        o_DrawIndexedPrimitiveUP = reinterpret_cast<DrawIndexedPrimitiveUP_t>(VTable[DRAWINDEXEDPRIMITIVEUP]);
        o_SetTexture = reinterpret_cast<SetTexture_t>(VTable[SETTEXTURE]);

        DetourFunction(o_BeginScene, DXI_BeginScene);
        DetourFunction(o_EndScene, DXI_EndScene);
        DetourFunction(o_Reset, DXI_Reset);
        DetourFunction(o_DrawPrimitive, DXI_DrawPrimitive);
        DetourFunction(o_DrawIndexedPrimitive, DXI_DrawIndexedPrimitive);
        DetourFunction(o_DrawPrimitiveUP, DXI_DrawPrimitiveUP);
        DetourFunction(o_DrawIndexedPrimitiveUP, DXI_DrawIndexedPrimitiveUP);
        DetourFunction(o_SetTexture, DXI_SetTexture);
        CreateThread(NULL, 0, VTableRepatch, NULL, 0, 0);
        return 0;
    }


    With this, the FPS is at 50. FPS drops a bit when drawing the ID's on screen but when you run a script you won't be drawing them on screen anyway so that doesn't matter. What matters is the FPS while the script is running or while you are playing and that itself is at 50-53 (I haven't seen lower). Drawing the ID's with D3DXFont is extremely slow ={ I will speed it up later by drawing them manually. Memory usage is nice too. I haven't noticed any lag. There's no leaks. I tested only the above. I got Kasi to test it. He didn't test FPS but it was running very nicely.

    I took a look at hooking textures. I have to find a way to save textures to the disk and to generate ID's in memory (my current code for saving and generating crashes because the textures aren't stored in ram.. I might have to wrap IDirect3DTexture9). Will take some time to figure out. I just finally got an OKAY debugger to help me.. Before everything was just assembly..

    I dumped shaders such as below:

    ASM Code:
    // Parameters:
    //
    //   float4 DistanceFogPlane;
    //   float4 HeightFogPlane;
    //   float4x2 TexCoordMatrix;
    //   float4x4 WVPMatrix;
    //
    //
    // Registers:
    //
    //   Name             Reg   Size
    //   ---------------- ----- ----
    //   WVPMatrix        c0       4
    //   TexCoordMatrix   c4       2
    //   DistanceFogPlane c6       1
    //   HeightFogPlane   c7       1
    //

        vs_2_0
        def c8, 0, 1, 0, 0
        dcl_position v0
        dcl_texcoord v1
        dcl_color v2
        dp4 oPos.x, v0, c0
        dp4 oPos.y, v0, c1
        dp4 oPos.z, v0, c2
        dp4 oPos.w, v0, c3
        dp4 oT0.x, v1, c4
        dp4 oT0.y, v1, c5
        dp4 r0.x, v0, c7
        max r0.x, r0.x, c8.x
        min oT4.x, r0.x, c8.y
        dp4 r0.x, v0, c6
        max r0.x, r0.x, c8.x
        min oT4.y, r0.x, c8.y
        mov oD0, v2
        mov oT0.zw, c8.x
        mov oT1.xyz, c8.x
        mov oT2.xyz, c8.y
        mov oT3.xyz, c8.x
        mov oT5, c8.x
        mov oT6.xyz, c8.x
        mov oT7, c8.x

    // approximately 20 instruction slots used



    // Parameters:
    //
    //   sampler2D SpriteSampler;
    //
    //
    // Registers:
    //
    //   Name          Reg   Size
    //   ------------- ----- ----
    //   SpriteSampler s0       1
    //

        ps_2_0
        dcl t0.xy
        dcl v0
        dcl_2d s0
        texld r0, t0, s0
        mul r0, r0, v0
        mov oC0, r0

    // approximately 3 instruction slots used (1 texture, 2 arithmetic)



    // Parameters:
    //
    //   sampler2D DiffuseSampler;
    //   float3 DistanceFogColour;
    //   float3 HeightFogColour;
    //
    //
    // Registers:
    //
    //   Name              Reg   Size
    //   ----------------- ----- ----
    //   DistanceFogColour c0       1
    //   HeightFogColour   c1       1
    //   DiffuseSampler    s0       1
    //

        ps_2_0
        def c2, 0, 0, 0, 0
        dcl v0
        dcl t0.xy
        dcl t2.xyz
        dcl t4.xy
        dcl_2d s0
        texld r0, t0, s0
        mul r0.xyz, r0, v0
        mul r1.xyz, r0, t2
        mad r0.xyz, r0, -t2, c1
        mov r1.w, v0.w
        mov r0.w, c2.x
        mad r0, t4.x, r0, r1
        add r1.xyz, -r0, c0
        mov r1.w, c2.x
        mad r0, t4.y, r1, r0
        mov oC0, r0

    // approximately 11 instruction slots used (1 texture, 10 arithmetic)


    //...
        vs_2_0
        dcl_position v0
        dcl_texcoord v1
        dcl_color v2
        mov oPos, v0
        mov oT0.xy, v1
        mov oD0, v2

    // approximately 3 instruction slots used



    // Parameters:
    //
    //   float4x2 TexCoordMatrix;
    //   float4x4 WVPMatrix;
    //
    //
    // Registers:
    //
    //   Name           Reg   Size
    //   -------------- ----- ----
    //   WVPMatrix      c0       4
    //   TexCoordMatrix c4       2
    //

        vs_2_0
        def c6, 0, 0, 0, 0
        dcl_position v0
        dcl_color v1
        dcl_texcoord v2
        dp4 oPos.x, v0, c0
        dp4 oPos.y, v0, c1
        dp4 oPos.z, v0, c2
        dp4 oPos.w, v0, c3
        dp4 oT0.x, v2, c4
        dp4 oT0.y, v2, c5
        mov oD0, v1
        mov oT1.x, c6.x

    // approximately 8 instruction slots used


    It's pretty annoying having to go through these things.. It's a lot harder than OpenGL by far :l There's not really any good debuggers for d3d. PIX (a Microsoft Direct-X debugger) is detected by Jaclib and automatically terminates the process.. You can't just debug RS just like that. It detects it -_-



    It detects it because PIX and Olly-Dbg because they start the game process rather than injecting to it during run-time. Olly-Dbg has the phantom plugin but you can't really use Olly-Dbg for Direct-X.

    So yeah.. It's hard ={ I'll get it done but I got other things to do as well.. Just thought you guys could see how things are done and if you know anything you can contrib..
    Last edited by Brandon; 10-07-2014 at 03:41 AM.
    I am Ggzz..
    Hackintosher

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

    Default

    Meh.. another boring update.. Most textures hooked.. I didn't get all of them but most.. I have to check what functions are being called or what params are being called for the rest but w/e.. Still progress I guess.

    http://i.imgur.com/n3yTYI6.png

    EDIT:
    http://i.imgur.com/LtgrqYD.png
    http://i.imgur.com/NfI7740.png

    Hooked the rest of them.. including bitmap fonts -_-.. Now I gotta figure out which is textures and which is fonts.. and generate ID's.. bleh.. -_-..

    And the code for that is below.. The cords are not in screen.. Even the mini-map trees are coloured..:

    C++ Code:
    void GetTextureCoords(LPDIRECT3DDEVICE9 pDevice, IDirect3DVertexBuffer9 *VertexBuffer, IDirect3DIndexBuffer9 *IndexBuffer, std::uint32_t BaseVertexIndex, std::uint32_t StartIndex, std::uint32_t PrimCount, std::uint32_t Stride)
    {
        std::uint8_t *vertices = NULL;
        std::uint16_t *indices = NULL;
        UINT EndIndex = StartIndex + (PrimCount * 3);

        VertexBuffer->Lock(0, 0, reinterpret_cast<void **>(&vertices), 0);
        IndexBuffer->Lock(0, PrimCount * 3 * sizeof(std::uint16_t), reinterpret_cast<void **>(&indices), 0);

        for (UINT I = StartIndex, J = 0; I < EndIndex; ++I, ++J)
        {
            D3DXVECTOR3 v = GetVertex(vertices, indices[I] + BaseVertexIndex, Stride);
            verts[J].x = v.x;
            verts[J].y = v.y;
            verts[J].z = v.z;
            verts[J].color = D3DCOLOR_ARGB(50, 255, 128, 255);
        }

        IndexBuffer->Unlock();
        VertexBuffer->Unlock();
    }

    HRESULT  __stdcall DXI_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
    {
        DWORD ID = ...;
        D3DXVECTOR3 out = WorldToScreen(pDevice);

        static bool debug = false;
        if (GetAsyncKeyState(VK_END) & 1)
            debug = !debug;

        if (font && debug)
            font->Draw(out.x, out.y, 0xFFFF0000, "%", ID);

        o_DrawIndexedPrimitive(pDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);

        if (NumVertices == 4 && primCount == 2)
        {
            if (PrimitiveType == D3DPT_TRIANGLELIST)
            {
                IDirect3DVertexBuffer9* vb = nullptr;
                IDirect3DIndexBuffer9* ib = nullptr;

                UINT offset, stride;
                pDevice->GetIndices(&ib);
                pDevice->GetStreamSource(0, &vb, &offset, &stride);
                GetTextureCoords(pDevice, vb, ib, BaseVertexIndex, startIndex, primCount, stride);
                ib->Release();
                vb->Release();

                IDirect3DStateBlock9* block;
                pDevice->CreateStateBlock(D3DSBT_ALL, &block);
                block->Capture();

                pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
                pDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
                pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
                pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
                pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
                pDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
                pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
                pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
                pDevice->SetTexture(0, nullptr);
                pDevice->SetPixelShader(nullptr);
                pDevice->SetVertexShader(nullptr);

                #define CUSTOMFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
                pDevice->SetFVF(CUSTOMFVF);
                pDevice->SetTexture(0, nullptr);
                pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, &verts[0], sizeof(CUSTOMVERTEX));
                block->Apply();
                block->Release();
            }
        }
        return D3D_OK; //bad idea.. fix later.
    }
    Last edited by Brandon; 10-08-2014 at 07:14 AM.
    I am Ggzz..
    Hackintosher

  7. #157
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Very impressive. It's nice to hear that the fps is stable and there are no leaks I don't know C++ but I'm down to help write an include!

    E: Nice scholar cup, I want!
    Last edited by The Mayor; 10-08-2014 at 07:29 AM.

  8. #158
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Thanks for all the great work Brandon! Looking forward for the dx hook plugin!
    Btw is it better to just store model IDs as Integer and let it stretch from negative 2.1bil to positive 2.1b? This would make coding easier as u dont have to cast like glGetModels(TCardinalArray[])

  9. #159
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

  10. #160
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

  11. #161
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    @Brandon
    Thanks for updating the plugin, the new version is able to grab some very useful textures! Really appreciate the great work!

    I have a few problems with the opengl plugin though, i didnt post as i thought that u will no longer bother to update it. Seeing that u have just updated the plugin i might as well post it if you are interested to fix them

    Problems with GLX v3.6 (i haven't test on v3.7 extensively to confirm if they still exist)
    1.
    Occasionally GLXMapCoords returns wrong values for me; at the exact same spot, GL_GetLocalPos would sometimes return different values after restarting smart (i have to restart smart again to fix it)

    2.
    Sometimes the script got stuck in GLXTextures/GLXModels/GLXFonts/GLXMapCoords, i added debug right before and after them so i'm pretty sure they are stuck in the plugin method.

    GLX 3.7:
    1.
    Most of the new textures from v3.7 seem to have their x2 > x1 or y2 > y1. I have never come across it in v3.6 (except for texts) as i have the following code in most GLXCore methods:
    Simba Code:
    if ((Result[J].Bounds.X2 < Result[J].Bounds.X1) or (Result[J].Bounds.Y2 < Result[J].Bounds.Y1)) then
          begin
            writeln('x2>x1/y2>y1/y2>y1 in glgettextures!' + toStr(Result[J]));
            TerminateScript;
          end;
    Not a huge problem though as i can simply swap them, but some previously grabbed textures in v3.6 are not present in v3.7. eg. at bank screen.
    v3.6 has
    Code:
    {ID = 13769, COLOURID = 2835022, FULLCOLOURID = 3295314, X = 394, Y = 567, BOUNDS = {X1 = 390, Y1 = 563, X2 = 397, Y2 = 570}}
    In v3.7, this is replaced by
    Code:
    {ID = 13769, COLOURID = 2835022, FULLCOLOURID = 3295314, X = 369, Y = 575, BOUNDS = {X1 = 348, Y1 = 587, X2 = 389, Y2 = 562}}
    So far i haven't come across any crucial textures that i've used in v3.6 that are missing in v3.7 though.

    2.
    I couldn't compile the latest source, gives the following error
    ...\GLX-master\OpenGL32\src\Hooks\Hooks.cpp|227|error: invalid conversion from 'int (*)()' to 'PROC {aka long long int (*)()}' [-fpermissive]|
    at lines containing
    Code:
            return reinterpret_cast<int (__stdcall *)()>(GLHook_glBindBufferARB);
    3. Previously u gave me an update that removed maps to improve fps
    I compared my version to your latest version it seems like u haven't removed that in your latest version?
    Last edited by riwu; 12-18-2014 at 02:03 AM.

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

    Default

    Quote Originally Posted by riwu View Post
    ..
    1. Patched already (v3.7) unless it still occurs.

    2. https://github.com/Brandon-T/GLX/blo...xports.cpp#L72 <--- That line that says WAIT_OBJECT_0 means to wait infinitely until something the server (SMART) responds.. That was a BAD design flaw now that I think about it but meh.. Changing it to "timeout" will fix it. I don't have time to do any more patches atm but maybe tomorrow? I don't know yet.. We'll see.. maybe after dinner.. No promises here.


    1a. Could not replicate the swap. Test the latest patches and see if it still happens. I did not check if animated textures swap their order or not. I patched what I think was causing some older textures to not show up (see releases v3.7 2014-12-17 10:40PM update): https://github.com/Brandon-T/GLX/com...c5c4d07b1bd5f6

    2a. You are trying to compile as 64 bit but that function pointer isn't large enough. It's a 32-bit pointer for 32-bit Simba for 32-bit SMART. Cast it to a FARPROC or PROC instead or else compile as 32-bit.

    3. At that time, I wasn't able to single out maps from regular textures (so I removed it to not degrade the plugin further).. In the latest plugin, I took the time to do that and so it only ever finds the map ONCE. Whenever a new map is loaded, it stores that ID (replacing the previously stored map). This way, it does not have to store EVERY FRAME (as done previously).. The pixels for a single map is stored once until the new map is rendered.. in which case the pixels are replaced with the new map's pixels until the next map is rendered.. This makes for a nice increase in FPS as maps are 512x512x4 bytes in size and I was storing that every frame. Now it's stored only once per area.

    The latest patches should work (I tested it slightly):



    If you remind me (sometime in the next few days.. maybe I'll have some time to patch the "sticking"). It's just one line..
    Last edited by Brandon; 12-18-2014 at 04:44 AM.
    I am Ggzz..
    Hackintosher

  13. #163
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    2a. You are trying to compile as 64 bit but that function pointer isn't large enough. It's a 32-bit pointer for 32-bit Simba for 32-bit SMART. Cast it to a FARPROC or PROC instead or else compile as 32-bit.
    Downloaded 32bit build and moved OpenGL32.layout back and got it to compile

    Quote Originally Posted by Brandon View Post
    1a. Could not replicate the swap. Test the latest patches and see if it still happens. I did not check if animated textures swap their order or not. I patched what I think was causing some older textures to not show up (see releases v3.7 2014-12-17 10:40PM update): https://github.com/Brandon-T/GLX/com...c5c4d07b1bd5f6
    Thanks for the patch bank textures are now fixed:


    When you rotate the compass to east:

    Code:
    [{ID = 37222, COLOURID = 657159, FULLCOLOURID = 7361410, X = 598, Y = 34, BOUNDS = {X1 = 622, Y1 = 6, X2 = 573, Y2 = 61}}
    If it's difficult to fix that it's alright i can simply swap them.

    Quote Originally Posted by Brandon View Post
    2. https://github.com/Brandon-T/GLX/blo...xports.cpp#L72 <--- That line that says WAIT_OBJECT_0 means to wait infinitely until something the server (SMART) responds.. That was a BAD design flaw now that I think about it but meh.. Changing it to "timeout" will fix it. I don't have time to do any more patches atm but maybe tomorrow? I don't know yet.. We'll see.. maybe after dinner.. No promises here.
    I see..why doesnt SMART respond sometimes?

    Also i couldn't compile GLX.dll statically, requiring libgcc_s_sjlj-1.dll, libstdc++-6.dll and libwinpthread-1.dll in my simba folder to work.
    How do i edit the MakeFile? b/w code didn't work
    Code:
    WinDEP = -static -static-libgcc_s_sjlj-1 -static-libstdc++-6 -static-libwinpthread-1 -static-libgcc -static-libstdc++ -shared -s -o
    Is there any way i can rename the opengl32.dll, so that when srl plugin updates it doesn't override it with the color-only version? I renamed the dll (and changed the include's arg) it stopped working...
    Last edited by riwu; 12-21-2014 at 10:23 AM.

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

    Default

    Quote Originally Posted by riwu View Post
    ..
    I'll have to look into it to see why the animated texture values are swapped upon rotation. There's no guarantee that it can be fixed (I mean.. I can force it but that's no good) because if that's the ORDER that the vertices are rendered in, that's the order. Remember that this "rotation" and natural order of things is how we calculate the angle of such a texture. If I did patch it, then the texture is always going to be as rest state (not rotated ever).. That means angle would always be 0.

    It's probably the same for the Map? Have you checked glMapCoords and see if they also get swapped upon rotation? If it is, then I will not patch because that means the order specifies the angle. Otherwise I will patch it.

    I'll look into it.

    Those commands are not how you compile statically. I am sure the makefile already has it in place:

    -static -static-libgcc -static-libstdc++

    compiles statically. The same commands can be set for the codeblocks project->linker settings.

    Last edited by Brandon; 12-21-2014 at 04:07 PM.
    I am Ggzz..
    Hackintosher

  15. #165
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    ...
    Found out why it wasnt compiling statically for me...
    When i built GLX.cbp, the glx.dll was output to bin/Debug folder, and GLX.layout with <ActiveTarget name="Debug" /> was autocreated.
    Changing that to "Release", or adding the static flags under Debug in glx.cbp fixed the problem.

    I only used map for GL_GetLocalPos(), not sure what else i can use it for? Output the current map as bitmap then compare to world map to determine global pos like SPS?

    The WAIT_OBJECT_0 is a more pressing issue though, i had to use another Simba to monitor the scripts and restart them whenever the proggy remains the same for > a few minutes. I have to change it to WAIT_TIMEOUT or something?

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

    Default

    Quote Originally Posted by riwu View Post
    Found out why it wasnt compiling statically for me...
    When i built GLX.cbp, the glx.dll was output to bin/Debug folder, and GLX.layout with <ActiveTarget name="Debug" /> was autocreated.
    Changing that to "Release", or adding the static flags under Debug in glx.cbp fixed the problem.

    I only used map for GL_GetLocalPos(), not sure what else i can use it for? Output the current map as bitmap then compare to world map to determine global pos like SPS?

    The WAIT_OBJECT_0 is a more pressing issue though, i had to use another Simba to monitor the scripts and restart them whenever the proggy remains the same for > a few minutes. I have to change it to WAIT_TIMEOUT or something?
    See the documentation for OpenSingleEvent? It has a timeout parameter (the very last parameter).
    C++ Code:
    /**  Â© 2013, Brandon T. All Rights Reserved.
      *
      *  This file is part of the GLX Library.
      *  GLX is free software: you can redistribute it and/or modify
      *  it under the terms of the GNU General Public License as published by
      *  the Free Software Foundation, either version 3 of the License, or
      *  (at your option) any later version.
      *
      *  GLX is distributed in the hope that it will be useful,
      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      *  GNU General Public License for more details.
      *
      *  You should have received a copy of the GNU General Public License
      *  along with GLX.  If not, see <http://www.gnu.org/licenses/>.
      */


    #ifndef SHAREDMEMORY_HPP_INCLUDED
    #define SHAREDMEMORY_HPP_INCLUDED

    #if defined _WIN32 || defined _WIN64
        #include <windows.h>
    #else
        #include <sys/types.h>
        #include <sys/mman.h>
        #include <dlfcn.h>
        #include <fcntl.h>
        #include <unistd.h>
    #endif

    #include <tchar.h>
    #include <iostream>
    #include <map>

    /** @file SharedMemory.cpp */

    /** @brief A class for mapping
     */

    class SharedMemory
    {
            /** @brief Opens the specified event with the specified access flags.
             *
             * @param EventName                 The unique-name of the event to open.
             * @param InheritHandle             A boolean indicating whether or not to inherit the event's handle.
             * @param SaveHandle                A boolean indicating whether or not to stored the event's handle. Default = false.
             * @param dwDesiredAccess           The specified access flags to use when opening the event. Default = EVENT_ALL_ACCESS.
             * @param dwMilliseconds            Specifies how long to wait for the event. A timeout flag in milliseconds. Default = INFINITE.
             * @return                          An integer indicating whether or not the event was opened successfully. WAIT_FAILED is returned upon failure.
             *
             */

            std::uint32_t OpenSingleEvent(std::string EventName, bool InheritHandle, bool SaveHandle = false, std::uint32_t dwDesiredAccess = EVENT_ALL_ACCESS, std::uint32_t dwMilliseconds = INFINITE);
    };

    #endif // SHAREDMEMORY_HPP_INCLUDED


    That means you can specify the "timeout" value anywhere that you see OpenSingleEvent being used. http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    says WAIT_TIMEOUT is the return value that happens when the timeout is hit. In that case, all functions will return "false"/"nothing"/"NULL"/"nullptr" upon timeout.

    So the only thing you need to change is the timeout value. Nothing more..

    Anyway.. I patched it: https://github.com/Brandon-T/GLX/com...a19d30cfde6bd5

    You can change the timeout(in Exports.hpp) if you don't want to wait "2 seconds at most". Maybe lower it or raise it to your liking. I did not test whether or not the timeout works. It should but it'd require me to run RS for a period of time and code in an infinite loop to check if it gets stuck or not. I could simulate getting stuck but meh.. If it doesn't work, then I'll do that. It SHOULD though.
    Last edited by Brandon; 12-22-2014 at 04:49 PM.
    I am Ggzz..
    Hackintosher

  17. #167
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    @Brandon
    Thanks for the fix, no more frozen issue
    The only remaining problem:
    Occasionally GLXMapCoords returns wrong values for me; at the exact same spot, GL_GetLocalPos would sometimes return different values after restarting smart (i have to restart smart again to fix it)
    still not fixed in the latest version.

    The x-value seems to remain consistent, only the y-value changes occasionally when Smart reloads.

  18. #168
    Join Date
    Jun 2014
    Location
    Lithuania
    Posts
    475
    Mentioned
    27 Post(s)
    Quoted
    200 Post(s)

    Default

    Ok i get this error

    Simba Code:
    Error: Unknown declaration "GLXDebug" at line 142

    I hjad that error, then downloaded brandons setup.zip he posted,

    now i get these:

    Error: Duplicate declaration "procedure((False=0, True=1))" at line 244
    Compiling failed.
    Error: Unknown declaration "SmartGetClientPID" at line 50

    and neither my normal scripts or openglinclude runs

  19. #169
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by cosmasjdz View Post
    Ok i get this error

    Simba Code:
    Error: Unknown declaration "GLXDebug" at line 142

    I hjad that error, then downloaded brandons setup.zip he posted,

    now i get these:

    Error: Duplicate declaration "procedure((False=0, True=1))" at line 244
    Compiling failed.
    Error: Unknown declaration "SmartGetClientPID" at line 50

    and neither my normal scripts or openglinclude runs
    What script are u trying to run?

    @Brandon;
    Is there any extra info to hook from models? Different type of mining rocks have the same model ID, so i have to find color within a box of the model point returned, which makes the ore finding more color-based than hooking based...

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

    Default

    Quote Originally Posted by riwu View Post
    What script are u trying to run?

    @Brandon;
    Is there any extra info to hook from models? Different type of mining rocks have the same model ID, so i have to find color within a box of the model point returned, which makes the ore finding more color-based than hooking based...
    There is.. but I don't have much time to hook it or dive into hooking it. I heard Jagex fixed OpenGL bugs, yeah?

    Everything in RS has a texture. That includes models. If you hook model textures and save them, you'd hash them, you'd have unique ID's per rock model. You could also hook the vertices for each model. Similar to the Direct-X hook code that's on github.
    I am Ggzz..
    Hackintosher

  21. #171
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Hey @Brandon, I think Obscurity may have asked, but would it be too much trouble to add in the camera zoom hook? I understand if you're busy, but this would be a gamechanger and appreciated greatly if you get the chance!

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

    Default

    Quote Originally Posted by Clarity View Post
    Hey @Brandon, I think Obscurity may have asked, but would it be too much trouble to add in the camera zoom hook? I understand if you're busy, but this would be a gamechanger and appreciated greatly if you get the chance!
    We spoke about it yes and the answer I gave him is the same that I will give to you.. but more detailed I guess..

    1. It "might" be possible to hook the camera and its zoom. The first call to glTranslate is the camera's position. However, it would require tracking for me to feed Simba accurate real time camera positions. This is actually VERY hard to do btw.. so it's out of the question.

    2. I tested if they reposition or zoom the camera via glRotate*, glScale*, glFrustum, etc.. No cigar. glRotate is called exactly 3 times [rotate x, rotate y, rotate z to create a rotation matrix] during start-up (before logging in). It is never again called (ever!). glScale is called once per frame with the exact same value every single time regardless of camera zoom.. glScalef(0.0078125, 0.0078125, 1). glFrustum is never ever called and instead glOrtho is called meaning that Jagex uses an Orthographic projection.


    glRotatef(26, 1, 0, 0);
    glRotatef(-12, 0, 1, 0);
    glRotatef(0, 0, 0, 1);
    glTranslatef(274, 226, 0); //possible a character: "U" as in "Username" on the login screen. Can't be 100% sure.



    All in all, everything is calculated on the Java side and then passed to OpenGL. The only thing that I am able to get right now is translations (usually used for fonts as models are positioned via matrices), is the MVPMatrix.

    This matrix contains the following information (See GLXMatrices function)..




    With that said, you will notice the translate changes upon changing your zoom. Here's some rounded off matrices via GLXMatrices:

    [-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 27904, -22267, 16754, 1] //lowest - varrock bank basement compass facing south
    [-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 27904, -22407, 19995, 1] //highest - varrock bank basement compass facing south

    [-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 26880, -21722, 16707, 1] //lowest - varrock bank facing south
    [-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 26880, -21861, 19953, 1] //highest - varrock bank facing south

    In the above, only the Z value (M11) really drastically changes.

    [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -28422, 22686, -7576, 1] //lowest basement facing north
    [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -28423, 23022, -1141, 1] //highest basement facing north


    I tried reversing all the matrix calculations (even used GLM's math library to do it.. same result) to get the camera position that is passed to OpenGL. It is ALWAYS (0, 0, 0). So there's no way to get the camera zoom without being able to get the actual height from the client (developer's console: getcamerapos).

    The best chance you have is calculating it from the matrices.. You'd have to also take into account the compass angle because as you can see above, it affects it.



    EDIT: RS3 does it like:

    Java Code:
    if(var0.equalsIgnoreCase("getcamerapos")) {
                   uw var28 = client.il.g(534416751);
                   if(abp.tl * 768570345 == 4) {
                      ob var26 = fn.ui.ap((byte)6);
                      ob var24 = fn.ui.ao(-1014937429);
                      xa.z("Pos: " + (new uw(dh.nu.b, (int)var26.o >> 9, (int)var26.m >> 9)).toString() + " Height: " + (aok.jb((int)var26.o - (-862318397 * var28.f << 9), (int)var26.m - (var28.u * -2091177201 << 9), dh.nu.b, -1540822537) + (int)var26.g), (byte)-128);
                      xa.z("Look: " + (new uw(dh.nu.b, (int)var24.o >> 9, (int)var24.m >> 9)).toString() + " Height: " + (aok.jb((int)var24.o - (var28.f * -862318397 << 9), (int)var26.m - (var28.u * -2091177201 << 9), dh.nu.b, -840066305) + (int)var26.g), (byte)-50);
                   } else {
                      xa.z("Pos: " + dh.nu.b + "," + (-862318397 * var28.f + (700671177 * ll.ko >> 9) >> 6) + "," + (var28.u * -2091177201 + (va.km * -1603363023 >> 9) >> 6) + "," + ((700671177 * ll.ko >> 9) + var28.f * -862318397 & 63) + "," + (-2091177201 * var28.u + (va.km * -1603363023 >> 9) & 63) + " Height: " + (aok.jb(ll.ko * 700671177, va.km * -1603363023, dh.nu.b, -1051030473) - ik.ke * -964346951), (byte)-16);
                      xa.z("Look: " + dh.nu.b + "," + (1419755433 * ur.tn + var28.f * -862318397 >> 6) + "," + (-2091177201 * var28.u + cp.ta * -1040741291 >> 6) + "," + (var28.f * -862318397 + ur.tn * 1419755433 & 63) + "," + (var28.u * -2091177201 + -1040741291 * cp.ta & 63) + " Height: " + (aok.jb(1419755433 * ur.tn, cp.ta * -1040741291, dh.nu.b, -1063574590) - -447524101 * jg.tm), (byte)-115);
                   }

                   return;
                }
    Last edited by Brandon; 01-22-2015 at 08:02 AM.
    I am Ggzz..
    Hackintosher

  23. #173
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    @Brandon;
    Found 2 weird behavior with the new plugin:
    1.

    There is one small dot at the bottom left of the inventory
    {ID = 88625, COLOURID = 1782589, FULLCOLOURID = 1847612, X = 4, Y = 274, BOUNDS = {X1 = 3, Y1 = 273, X2 = 4, Y2 = 275}}
    When ur inventory is not empty, it disappears, but sometimes turn into the texture ID of a random object in inventory (bones etc).

    2.

    (ignore the red box)
    the minimap symbol for underground (texture ID 36370) was previously not hooked, the new plugin hooks it but it seems like it could only hook 1 at a time?
    the left one is not grabbed when the right one is visible.

    Also any clue why GL_GetLocalPos sometimes return different values after restarting smart?

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

    Default

    Quote Originally Posted by riwu View Post
    @Brandon;


    Found 2 weird behavior with the new plugin:
    1.
    There is one small dot at the bottom left of the inventory
    {ID = 88625, COLOURID = 1782589, FULLCOLOURID = 1847612, X = 4, Y = 274, BOUNDS = {X1 = 3, Y1 = 273, X2 = 4, Y2 = 275}}
    When ur inventory is not empty, it disappears, but sometimes turn into the texture ID of a random object in inventory (bones etc).

    2.

    (ignore the red box)
    the minimap symbol for underground (texture ID 36370) was previously not hooked, the new plugin hooks it but it seems like it could only hook 1 at a time?
    the left one is not grabbed when the right one is visible.

    Also any clue why GL_GetLocalPos sometimes return different values after restarting smart?

    1. is linked to 2. So I'll explain it all in 2.

    2. https://github.com/Brandon-T/GLX/blo...tures.cpp#L256 Animated texture's are determine by a single boolean. As soon as one is found, that boolean is set to false because the next texture loaded COULD be a regular texture OR an animated texture. The real problem is the design of the original plugin.. Same problem that had previously happened with the very first plugin causing me to re-write it and thus 3.5+ was born..

    What's that problem? The problem is "adding" new hooks without changing "layout". This is called ABI compatibility. If I add REAL animated textures to the plugin (not the hacked up stuff that's in there right now), I will have to do one of the following:

    2a. Change the layout of Textures in the include.
    2b. Add new class of Textures to the include.
    2c. Add a new internal class and merge them upon transferring to the Simba side.

    Of course option C is the easiest but I'm not sure about it. Animated textures were only added very recently and adding them does not take a lot of work (only one function is different compared to textures.. float vs. int) but it does change the plugin AND the include and that's because I never anticipated the need for hooking it before. So what I did was I made animated textures and textures one in the same.. Never really wrote the API for adding extra hooks as I thought models, textures, fonts, maps, angles, matrices, would be all that was needed.. then came Animated textures out of no where -___-

    So yes, I can fix it but I'll have to think up a better solution than the above..


    3. For localpos, there's an explanation somewhere that describes the problem with it. If you are still asking this, you haven't grasped the problem yet. Each time you enter a new location, a PORTION of a map is drawn and you are placed at one of its edges. When you log out and re-login, you are placed at the CENTER of the portion that you stand. Hence the need for being able to find globalpos arose..


    The last one is VERY hard to come up with a solution for..

    I'll see what I can do to fix the first two problems. Maybe re-write parts of the plugin and hope I don't break any parts of the include..
    Last edited by Brandon; 01-23-2015 at 02:12 PM.
    I am Ggzz..
    Hackintosher

  25. #175
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    Brandon, I'm at work so can't send any examples ATM, but his map issue may relate to mine.

    Whe tracing the coordinates returned by GLX map coords (I don't remember the exact name - again, work), it's off by up to 200px sometimes, if I recall correctly. It's still a perfect rectangle around the map, but the actual map image is in much farther then the actual point given.

    I'll give examples and screenshots when I get home, mate. Cheers.




    Skype: obscuritySRL@outlook.com

Page 7 of 9 FirstFirst ... 56789 LastLast

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
  •