Page 1 of 4 123 ... LastLast
Results 1 to 25 of 89

Thread: OpenGL.

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

    Default OpenGL.

    UPDATED: August 9th 2012.


    PROPER Location of Text Rendering coming soon (HOPEFULLY). VertexBuffer Hook coming soon (HOPEFULLY). This will allow me to grab the actual vertices rather than vertex #0. That way I can click objects even if only 1 pixel of it is showing. Atm, it clicks dead center of an object unless you specify the offset vertex.
    I plan to use Base 36 for ID's to shorten them. Well maybe only on the Simba side. Probably leave it as Base 10 on the C++ side.





    https://github.com/Brandon-T/GLHook

    While reading below, you'll realize I said I have trouble with Triangle Enumeration and 3D Programming math.. This is an updated Edit: http://www.arcsynthesis.org/gltut/Ba...roduction.html

    That's where I'm learning the math to build on this foundation.. I already know calculus and stuff but this is some next level crap.

    Note: The github only contains the basic layout.. It doesn't contain the most updated version so it doesn't reflect how far I got but meh that's ok for now.
    I guess now is about the right time to tell the world I was working on the OpenGL hooking.. Since SRL is down, everyone is looking at alternatives and I guess I'll start showing one too. Mato has DirectX I have OpenGL. I'm not taking anything away from him. He is a brilliant fellow and I hope he continues without rushing. I may or may not finish or continue this but here is a brief explanation of how the shit works right now.

    First I used "DLLExport Viewer x64" to figure out what Jagex's OGL has compared to the one in my System32/SysWOW64.

    They use a library/DLL called Corona for imaging, etc.. I saved a list of all exported functions from Jagex's DLL and with the same program saved a list with the one on my system. With a little reading I learned to Detour Functions and Inject by writing to process memory. Both of which I provided in the GitLink.

    A detour function is a function that has the exact same syntax as the original function. Aka the one we are trying to hook.

    So lets say OpenGL.dll has one that looks like: void glBegin(GLEnum mode);
    Our Detour would look like GLHook_glBegin(GLEnum mode);

    Now what does that have to do with anything.. well here is some sample code:
    C++ Code:
    GLHook_glBegin(GLEnum mode)
    {
        //Do whatever we want in here.. then below, we pass the parameters to the original function.
        (*optr_glBegin(mode);
    }

    In our detour, we are getting the client's data FIRST! Then we pass it to the OpenGL32.dll in our system folder. That *optr_glBegin is a function pointer to the original OpenGL32.dll in sys32.

    Now that that's clear, the next thing I did was learn what each function does. I did this by reading through the entire MSDN database on OpenGL functions :c Yes I know.. a lot of reading and shit.

    When I saw how many functions there were to write, I gave up and wrote function generator which looks like:

    C++ Code:
    //#define _WIN32_WINNT 0x0403
    #include <windows.h>
    #include <iostream>
    #include "Functions.hpp"
    #include "Strings.hpp"

    using namespace std;

    StringArray GLTypes = StringArray("GLint ", "GLuint ", "GLenum ", "GLfloat ", "GLclampf ",
                                      "GLsizei ", "GLboolean ", "GLubyte ", "GLvoid ", "const ",
                                      "GLbitfield ", "GLclampd ", "GLdouble ", "GLshort ", "GLbyte",
                                      "GLushort ", "GLclampi ", "GLbitfield ", "void", "HDC ", "DWORD ",
                                      "LPGLYPHMETRICSFLOAT ", "FLOAT ", "DOUBLE ", "UINT", "INT ", "float ",
                                      "double ", "int ", "LPCSTR ", "LPSTR ", "LPTSTR ", "LPCTSTR ", "LPLAYERPLANEDESCRIPTOR ",
                                      "LPPIXELFORMATDESCRIPTOR", "PIXELFORMATDESCRIPTOR ", "HGLRC ", "COLORREF ", "BOOL ", "*",
                                      "**");

    void CreateGLFunctionsFromTypedefs()
    {
        StringArray FileContents;
        ifstream File("C:/Users/Brandon/Desktop/OGL Editing/GLTypedefs.hpp", std::ios::in);
        if (File.is_open())
        {
            string Line;
            while (getline(File, Line))
                FileContents(Line);
            File.close();
        }

        string Temp = string();
        string FuncType = string();
        string PtrStr = string();
        string Final = string();
        ReplacementFlags FalseFlags = ReplacementFlags(false, false);

        for (size_t I = 0; I < FileContents.Size(); I++)
        {
            if ((FileContents[I][0] == 't') && (FileContents[I][1] == 'y'))
            {
                FuncType = Copy(FileContents[I], 9, Pos("(WINAPI", FileContents[I], 9) - 9);
                Temp = Replace(FileContents[I], "typedef ", "", FalseFlags);
                Temp = Replace(Temp, "(WINAPI *ptr_", "", FalseFlags);
                PtrStr = Replace(Temp, ";", "", FalseFlags);
                PtrStr = Copy(PtrStr, Pos(" ", PtrStr, 0) + 2, PtrStr.end() - (PtrStr.begin() + Pos(" ", PtrStr, 0)) + 2);
                Temp = Replace(Temp, ";", "\n{\n\t", FalseFlags);
                Temp = Replace(Temp, ") (", "(", FalseFlags);
                PtrStr = ((FuncType[0] == 'c' && FuncType[1] == 'o') && (PtrStr[0] == 'G' && PtrStr[1] == 'L')) ? Copy(PtrStr, Pos(" ", PtrStr, 0) + 2, PtrStr.end() - PtrStr.begin() - 2) : PtrStr;
                Temp = (FuncType[0] == 'c' && FuncType[1] == 'o') ? Replace(Temp, " gl", " GLHook_gl", FalseFlags) : Replace(Temp, " ", " GLHook_", FalseFlags);
                Temp = "GL_EXPORT __stdcall " + Temp; //__stdcall added.

                for (size_t J = 0; J < GLTypes.Size(); J++)
                {
                    PtrStr = Replace(PtrStr, GLTypes[J], "", ReplacementFlags(true, false));
                    PtrStr = Replace(PtrStr, "*params", "params", ReplacementFlags(true, false));
                }
                PtrStr = "(*optr_" + PtrStr + ";";
                PtrStr = ((FuncType != "void") ? "return " : "") + PtrStr;
                Temp += PtrStr + "\n}\n\n";
                Final += Temp;
            }
        }
        WriteFile("C:/Users/Brandon/Desktop/OGL Editing/GLFunctions.hpp", Final);
    }

    void CreateGLAddressesFromDefinitions()
    {
        StringArray FileContents;
        ifstream File("C:/Users/Brandon/Desktop/OGL Editing/GLHook.def", std::ios::in);
        if (File.is_open())
        {
            string Line;
            while (getline(File, Line))
                FileContents(Line);
            File.close();
        }

        string Final = string();
        for (size_t I = 0; I < FileContents.Size(); I++)
        {
            if ((FileContents[I][0] != ';' ) && (Pos("LIBRARY", FileContents[I], 0) == -1) && (Pos("DESCRIPTION", FileContents[I], 0) == -1) && (Pos("EXPORTS", FileContents[I], 0) == -1))
            {
                StringArray Split = SplitString(FileContents[I], "=    ");
                for (size_t J = 0; J < Split.Size(); J++)
                {
                    //if (Split[J][0] != 'G' && Split[J][1] != 'L' && Split[J][2] != 'H' && Split[J][3] != 'O' && Split[J][4] != 'O' && Split[J][5] != 'K')
                    if (Pos("GLHook", Split[J], 0) == -1)
                    {
                        //Final += "MessageBox(NULL, \"" + Split[J] + "\", \"CrashReport\", 0);\n";
                        Final += "if ((optr_" + Split[J] + " = (ptr_" + Split[J] + ") GetProcAddress(OriginalGL, \"" + Split[J];
                        Final += "\")) == NULL)\n{\n\treturn false;\n}\n\n";

                        //Final += "\")) == NULL)\n{\n\t";
                        //Final += "MessageBox(NULL, \"" + Split[J] + "\", \"CrashReport\", 0);\n\t";
                        //Final += "return false;\n}\n\n";
                    }
                }
            }
        }
        WriteFile("C:/Users/Brandon/Desktop/OGL Editing/GLProcAddresses.hpp", Final);
    }

    void CreateGLExternsFromTypedefs()
    {
        StringArray FileContents;
        ifstream File("C:/Users/Brandon/Desktop/OGL Editing/GLTypedefs.hpp", std::ios::in);
        if (File.is_open())
        {
            string Line;
            while (getline(File, Line))
                FileContents(Line);
            File.close();
        }

        string Temp = string();
        string Final = string();
        for (size_t I = 0; I < FileContents.Size(); I++)
        {
            int Position = Pos("*ptr_", FileContents[I], 0) + 5;
            if (FileContents[I][0] == 't' && FileContents[I][1] == 'y')
            {
                Temp = Copy(FileContents[I], Position + 1, Pos(") ", FileContents[I], Position) - Position);
                Final += "extern ptr_" + Pad(Temp, 27, " ", false) + "optr_" + Temp + ";\n";
            }
            else
            {
                Final += FileContents[I] + "\n";
                Final = Replace(Final, "TYPEDEFS", "NAMING", ReplacementFlags(false, false));
            }
        }
        WriteFile("C:/Users/Brandon/Desktop/OGL Editing/GLExterns.hpp", Final);
    }

    void CreateGLDefinitionsFromTypedefs()
    {
        StringArray FileContents;
        ifstream File("C:/Users/Brandon/Desktop/OGL Editing/GLTypedefs.hpp", std::ios::in);
        if (File.is_open())
        {
            string Line;
            while (getline(File, Line))
                FileContents(Line);
            File.close();
        }

        string Temp = string();
        string Final = string();

        Final += ";     @Author : Brandon T.\n";
        Final += ";\n";
        Final += ";     @param  : GLHook Definition File.\n";
        Final += ";     @param  : Info From MSDN Documentation.\n\n\n";
        Final += "LIBRARY GLHook\n";
        Final += "DESCRIPTION \"GLHook Definition File\"\n";
        Final += "EXPORTS\n\n";

        for (size_t I = 0; I < FileContents.Size(); I++)
        {
            int Position = Pos("*ptr_", FileContents[I], 0) + 5;
            if (FileContents[I][0] == 't' && FileContents[I][1] == 'y')
            {
                Temp = Copy(FileContents[I], Position + 1, Pos(") ", FileContents[I], Position) - Position);
                Final += Pad(Temp, 27, " ", false) + "=    GLHook_" + Temp + ";\n";
            }
        }
        WriteFile("C:/Users/Brandon/Desktop/OGL Editing/GLHook.def", Final);
    }

    void CreateGLNamingListFromExterns()
    {
        StringArray FileContents;
        ifstream File("C:/Users/Brandon/Desktop/OGL Editing/GLExterns.hpp", std::ios::in);
        if (File.is_open())
        {
            string Line;
            while (getline(File, Line))
                FileContents(Line);
            File.close();
        }

        string Final = string();
        for (size_t I = 0; I < FileContents.Size(); I++)
        {
            if (FileContents[I][0] == 'e')
                Final += Replace(FileContents[I], "extern ", "", ReplacementFlags(false, false)) + "\n";
        }
        WriteFile("C:/Users/Brandon/Desktop/OGL Editing/GLNamingList.hpp", Final);
    }

    void GLCompare()
    {
        string ListOfGLExports = ReadFile("C:/Users/Brandon/Desktop/ListOfGLExports.hpp", false);
        string CurrentExports = ReadFile("C:/Users/Brandon/Desktop/CurrentExports.hpp", false);

        StringArray ListOfGLExportsSplit = SplitString(ListOfGLExports, "\n");
        StringArray CurrentExportsSplit = SplitString(CurrentExports, "\n");
        string Temp = string();
        string Final = string();

        for (size_t I = 0; I < ListOfGLExportsSplit.Size(); I++)
        {
            if (Pos(ListOfGLExportsSplit[I], CurrentExports, 0) == -1)
            {
                cout<<ListOfGLExportsSplit[I]<<endl;
            }
        }
    }


    int main(int argc, char* argv[])
    {
        StreamFlags(std::cout);

        CreateGLFunctionsFromTypedefs();
        CreateGLExternsFromTypedefs();
        CreateGLDefinitionsFromTypedefs();
        CreateGLAddressesFromDefinitions();
        CreateGLNamingListFromExterns();

        //GLCompare();

        cin.get();
        return 0;
    }

    What the above does, is generate a list of ALL OpenGL functions, its externs, its Definitions, its Detours, and its Address Procs. It uses a library I wrote myself called Purely-CPlusPlus. I posted it on SRL about last week when it got no attention so I removed it :c

    To do it manually is a waste of time! Trust me! it's a total of 6000 lines of code being generated. Not including the undocumented ones which I decided to remove.

    From that code, put it all into a DLL Module and LoadRS. RS Will load your DLL first which will in turn load the original OpenGL but instead of RS passing commands to the original, it will pass it to yours which will read it and log it and then pass it to the original. Thus we can modify calls, log them, do whatever with them, and as such, create wireframes which look like:



    Edit: Item Recognition is Ok.. Algorithm is still shit.


    Edit 2:
    I'm getting close and close to model recognition. Don't have an algorithm for ID's yet. I believe I can actually store a list of vertices due to the way I wrote the model code. I stored the vertex pointer's pointer. I get the index count and divide by 3 for triangle count. Iterate the pointer for each triangle and store the vertex (THEORETICAL. It should work though.. I hope). At the time of posting the following pictures, I store only the first vertex and offset the Y by 213 (50 for the bar).




    EDIT3: Grabbing Texts are working.. Positions are off but I THINK I can fix that (What I have in mind is theoretical, Heavy use of matrices ={ ).. Also as you can see, it renders shadows too so I've provided parameters to the function to specify whether the text we want should have a shadow or not. I have to fix positions first though.






    Now it's up to you guys to do stuff with the logs OR teach me the math required to generate ID's out of those models above or throw some ideas out there for whoever decides to pick this shit up if I leave or whatever.. Now I have to learn the math required to generate ID's. Yes I did a bit of hacking and all that crap before but this math is OpenGL math.. It's not the same :c. Math with depth, height, width, view, etc.. I did calculus but i'm not sure if that is enough. So you guys pitch in where you can. Try to learn OpenGL too. It took me a total of 6 days to get this far. 2 Days of trial and error and testing and crashes due to jagex's bs and the fact that my generator messed up a couple functions (though that is fixed now). With a little CPP background, OGL won't take long to catch on.. The github is 4 days old but it took me 6 to get this far. I don't know how far I can push this project so everyone needs to learn it and pitch in. That goes for directX too. I'll help mato wherever I can.

    P.S. I was asked to show u guys this. I actually wasn't going to show anything just yet because questions will hit me left right and center like OMG when is ETA and all that stuff such as the ones seen on Mato's thread.
    Last edited by Brandon; 08-09-2012 at 07:58 PM.
    I am Ggzz..
    Hackintosher

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

    Default

    Nice, all I can say, I'm totally clueless on OpenGL programming.

  3. #3
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Now this is brilliant, good work you got further than i have with my failed attempt

  4. #4
    Join Date
    Feb 2007
    Location
    Colorado, USA
    Posts
    3,716
    Mentioned
    51 Post(s)
    Quoted
    624 Post(s)

    Default

    I am also clueless with this level of stuff, as always I offer my VM's if they would be of any use, up to 10cores & 10gb of memory

    really good work though, maybe we can get everyone working on 1 project instead of like 5 different ones
    The only true authority stems from knowledge, not from position.

    You can contact me via matrix protocol: @grats:grats.win or you can email me at the same domain, any user/email address.

  5. #5
    Join Date
    Mar 2012
    Location
    Canada
    Posts
    870
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    Looks very good. Can't wait to see this in action.
    My scripts:
    Advanced Barb Agility Course(outdated), MonkeyThieverV0.11, MahoganyTableV0.4(outdated)
    Questions? I bet that for 98% of those, you'll find answer HERE

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

    Default

    Have you looked through Silab's OGL source on Github? This might have some of what you're looking for.

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


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

    Default

    Quote Originally Posted by Flight View Post
    Have you looked through Silab's OGL source on Github? This might have some of what you're looking for.
    I looked at it but I didn't like the C-style coding. I don't want to rely on guess work either. According to that source, it says an item is an inv item if it's vertex or triangle count is between 135 to 37 or something.

    Right now all I have is the wrapper dll and an injector and a couple functions done. I wrote a DebugWindow function, a couple Bitmaps from client function using DC's and GDI and glReadPixels and yeah. That's about it I think.

    I gotta learn the math though to count verticies, normalize crap, etc.. That's what's killing me. I'll learn it eventually. I can only work on this when I have free time so yeah.
    I am Ggzz..
    Hackintosher

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

    Default

    Quote Originally Posted by Brandon View Post
    I looked at it but I didn't like the C-style coding. I don't want to rely on guess work either. According to that source, it says an item is an inv item if it's vertex or triangle count is between 135 to 37 or something.

    Right now all I have is the wrapper dll and an injector and a couple functions done. I wrote a DebugWindow function, a couple Bitmaps from client function using DC's and GDI and glReadPixels and yeah. That's about it I think.

    I gotta learn the math though to count verticies, normalize crap, etc.. That's what's killing me. I'll learn it eventually. I can only work on this when I have free time so yeah.
    Yes if I read Aftermath's notes correctly he was identifying inventory items, like you said, based on the triangle count. I would imagine this was a simple difference between 2D and 3D sprites (mainscreen sprites vs everything else).

    You're off to a promising start and I surely look forward to seeing this develop. I'll check back on this thread as much as I can.

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


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

    Default

    This is very nice.

    Quote Originally Posted by Brandon View Post
    I looked at it but I didn't like the C-style coding. I don't want to rely on guess work either. According to that source, it says an item is an inv item if it's vertex or triangle count is between 135 to 37 or something.

    Right now all I have is the wrapper dll and an injector and a couple functions done. I wrote a DebugWindow function, a couple Bitmaps from client function using DC's and GDI and glReadPixels and yeah. That's about it I think.

    I gotta learn the math though to count verticies, normalize crap, etc.. That's what's killing me. I'll learn it eventually. I can only work on this when I have free time so yeah.
    I suppose it would be useful to keep some contact with Aftermath, because I think it looks like he was actually quite far. Also, to be honest, I don't really dislike their coding style much, but I'm not sure if that's what you meant.

    Great job so far! This requires a lot of dedication.



    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)

  10. #10
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Is the math for OGL and DirectX different? Could Mato help you with any of the math?

    If that makes sense...

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

    Default

    Quote Originally Posted by abu_jwka View Post
    Is the math for OGL and DirectX different? Could Mato help you with any of the math?

    If that makes sense...
    It should be the same. I looked into DX API so that I could help him wherever I can as well.
    It's not hard to go from DX to GL. I'm actually reading up on the algorithms and math crap right about now. At the same time logging calls from the client to figure out what to hook for what and which calls are useless, etc..

    I put in a couple hotkeys for different functions already made.
    I am Ggzz..
    Hackintosher

  12. #12
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Glad to see you made progress

  13. #13
    Join Date
    Jan 2012
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow nice

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

    Default

    Finding Items by Texture Checksum ID I got working but it labels the wrong Item :S Meaning it draws ID's at the wrong coordinates.

    List Of ID's some of the ID's I got from Saving the Items as images with their corresponding checksum ID:



    Labeling the wrong ID's:



    Anyone got any clue what the problem could be? I hooked it like so:

    C++ Code:
    #include <gl/gl.h>
    #include <gl/glu.h>
    #include "PurelyCPlusPlus/Defines.hpp"

    struct InventoryItem
    {
        GLint X, Y;
        GLint TextureID;
        GLint CheckSum;
    };

    struct Model
    {
        GLfloat X, Y, Z, W;
        uint32_t Stride, ID;
        uint32_t XS, YS;

        struct Triangles
        {
            GLfloat X1, Y1, Z1;
            GLfloat X2, Y2, Z2;
            GLfloat X3, Y3, Z3;
        };
    };

    int CheckSum(int Width, int Height, void* PixelData, uint32_t BitsPerPixel)
    {
        int Result = 0;
        int CheckSum = 0;
        unsigned char* BuffPos = static_cast<unsigned char*>(PixelData);
        Height = (Height < 0 ? -Height : Height);

        for (int I = 12; I < Height; I++)       //Starts at 12-14 so that it doesn't include the digits (Item Amount).
        {
            for (int J = 0; J < Width; J++)
            {
                Result += *(BuffPos++);
                Result += *(BuffPos++);
                Result += *(BuffPos++);
                CheckSum += (BitsPerPixel > 24 ? *(BuffPos++) : 0);
            }
            if (BitsPerPixel == 24)
                BuffPos += Width % 4;
        }
        Result = CheckSum;      //For now just use the Alpha pixels as the checksum.. Todo: Fix it later! This is a shitty checksum.
        return Result;
    }

    C++ Code:
    bool ItemFound = false;
    bool DrawItem = false;
    InventoryItem CurrentItem;
    std::vector<InventoryItem> ListOfItems;
    std::vector<Model> ListOfModels;

    GL_EXPORT __stdcall void GLHook_glEnd(void)
    {
        if (ItemFound)
        {
            ListOfItems.push_back(CurrentItem);
            ItemFound = false;
        }
        (*optr_glEnd) ();
    }

    GL_EXPORT __stdcall void GLHook_glBindTexture(GLenum target, GLuint texture)
    {
        if (LogCalls)
        {
            if (target == GL_TEXTURE_RECTANGLE_NV)
            {
                GLint Width = 0, Height = 0; int BitsPerPixel = 32;
                glGetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_NV, 0, GL_TEXTURE_WIDTH, &Width);
                glGetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_NV, 0, GL_TEXTURE_HEIGHT, &Height);
                if (Width <= 60 || Height <= 60 || Width >= 30 || Height >= 30)
                {
                    ItemFound = true;
                    std::vector<unsigned char> PixelData(((Width * BitsPerPixel + 31) / 32) * 4 * Height);
                    glGetTexImage(GL_TEXTURE_RECTANGLE_NV, 0, BitsPerPixel > 24 ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, &PixelData[0]);
                    CurrentItem.CheckSum = CheckSum(Width, Height, &PixelData[0], BitsPerPixel);
                    CurrentItem.TextureID = texture;
                    //Bitmaps BMP = Bitmaps(Width, Height, PixelData, 32);
                    //std::string SavePath = "C:/Users/Brandon/Desktop/GLImages/" + ToString(CurrentItem.CheckSum) + ".bmp";
                    //BMP.Save(SavePath.c_str());
                }
            }
        }
        (*optr_glBindTexture) (target, texture);
    }

    GL_EXPORT __stdcall void GLHook_glVertex2i(GLint x, GLint y)
    {
        if (ItemFound)
        {
            CurrentItem.X = x;
            CurrentItem.Y = y;
        }
        (*optr_glVertex2i) (x, y);
    }

    GL_EXPORT __stdcall BOOL GLHook_wglSwapBuffers(HDC hdc)
    {
        Commands();
        bool Result = (*optr_wglSwapBuffers) (hdc);  //Ah shit.. :c Bad.. Need to find a better way of passing + drawing.
        if (LogCalls)
        {
            if (DrawItem)
            {
                for (int I = 0; I < ListOfItems.size(); I++)
                {
                    HDC DC = wglGetCurrentDC();
                    glPrint(DC, RGB(255, 0, 0), ListOfItems[I].X, ListOfItems[I].Y, "%i", ListOfItems[I].CheckSum);
                }
            }
            ListOfItems.clear();
        }
        return Result;
    }

    C++ Code:
    #include <windows.h>
    #include "Models.hpp"
    #include "PurelyCPlusPlus/Functions.hpp"
    #include <vector>
    #include <cstdio>       //I really hate having to use variadic functions instead of templates.. //Todo: Fix it (glPrint).

    extern bool DrawItem;
    extern InventoryItem CurrentItem;
    extern std::vector<InventoryItem> ListOfItems;
    bool LogCalls = false;

    void Commands()
    {
        if (GetAsyncKeyState(VK_F11) & 1)
        {
            DrawItem = !DrawItem;
            GLint SearchItemID = 0;
            //std::string FileData = ReadFile("C:/Users/Brandon/Desktop/ItemID.txt", false);
            SearchItemID = 90270;
            for (std::vector<InventoryItem>::iterator it = ListOfItems.begin(); it != ListOfItems.end(); it++)
            {
                if (it->CheckSum == SearchItemID)
                {
                    CurrentItem.CheckSum = SearchItemID;
                    CurrentItem.TextureID = it->TextureID;
                    CurrentItem.X = it->X;
                    CurrentItem.Y = it->Y;
                    break;
                }
            }
        }

        if (GetAsyncKeyState(VK_F12) & 1)
        {
            LogCalls = !LogCalls;
        }
    }

    void glPrint(HDC &DC, COLORREF Colour, int X, int Y, const char* format, ...)
    {
        if (format == NULL) return;
        char text[256];
        va_list    ap;
        va_start(ap, format);
        vsprintf(text, format, ap);
        va_end(ap);

        SelectObject(DC, GetStockObject(NULL_BRUSH));
        SetBkMode(DC, TRANSPARENT);
        SetTextColor(DC, Colour);

        TextOut(DC, X, Y, text, strlen(text));
    }


    Also why is my text not being drawn with a transparent background.. I literally tried everything!! I know it looks dirty right now but I'll clean it up after I figure out why it labels wrong :S Oh and what should I use to generate ID's my algorithm is horrible.. I had to cut off the part that contains the numbers for stacked items.. The slight change in colour will affect it if I use R, G, and B as the checksum so I used alpha alone. Either way I still had to cut off the top to ignore the numbers which is bad. Any ideas?
    Last edited by Brandon; 07-26-2012 at 02:22 AM.
    I am Ggzz..
    Hackintosher

  15. #15
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Erm, try setting the background color to transparent before you select the object? sometimes shifting stuff around works -.-
    Last edited by Kasi; 07-26-2012 at 02:29 AM.

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

    Default

    Quote Originally Posted by pur3b100d View Post
    Erm, try setting the background color to transparent before you select the object?
    Tried that already.. doesn't work :S

    EDIT: Fixed the ID's labelling problem:
    The algorithm is soooo bad.. Notice how the two Items in the invent have the same ID? I forgot what they're called :P ID: 71145.



    EDIT: Got Item/Panel/Icon ID's looking much much cleaner!
    Last edited by Brandon; 07-28-2012 at 04:51 PM.
    I am Ggzz..
    Hackintosher

  17. #17
    Join Date
    May 2008
    Posts
    87
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I remember reading on the DirectX topic a similar problem, the "talismans" :P or ID 7115 have the same id because they use the same model.

    Therefore with the way that you calculate IDs, objects that use the same model, runes, talismans, arrows (guessing) would all have the same ID

    Im not sure if Mato ever figured a way around this or not...just throwing my 2 cents in hah
    http://img577.imageshack.us/img577/3239/srlsig.png
    Hmmm...nah probably a coincidence.

  18. #18
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by whaevr View Post
    I remember reading on the DirectX topic a similar problem, the "talismans" :P or ID 7115 have the same id because they use the same model.

    Therefore with the way that you calculate IDs, objects that use the same model, runes, talismans, arrows (guessing) would all have the same ID

    Im not sure if Mato ever figured a way around this or not...just throwing my 2 cents in hah
    Use ID to check item-type (rune,talisman,arrow) then use colour to determine whether or not it is a specific one of those.

  19. #19
    Join Date
    May 2008
    Posts
    87
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by P1ng View Post
    Use ID to check item-type (rune,talisman,arrow) then use colour to determine whether or not it is a specific one of those.
    Right I know that would probably be possible. I was referring to if Mato ever figured out a way to develop unique IDs for EVERY item
    http://img577.imageshack.us/img577/3239/srlsig.png
    Hmmm...nah probably a coincidence.

  20. #20
    Join Date
    Oct 2011
    Location
    Chicago
    Posts
    3,352
    Mentioned
    21 Post(s)
    Quoted
    437 Post(s)

    Default

    God man, you blow me out of the water with this stuff. Best of luck
    Oh grats on senior member




    Anti-Leech Movement Prevent Leeching Spread the word
    Insanity 60 Days (Killer workout)
    XoL Blog (Workouts/RS/Misc)

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

    Default

    Quote Originally Posted by whaevr View Post
    I remember reading on the DirectX topic a similar problem, the "talismans" :P or ID 7115 have the same id because they use the same model.

    Therefore with the way that you calculate IDs, objects that use the same model, runes, talismans, arrows (guessing) would all have the same ID

    Im not sure if Mato ever figured a way around this or not...just throwing my 2 cents in hah
    From my point of view similar items like that share the same model ID; the basic shape. But as far as I know we can go further and grab textures for each item. Kinda like colour for OGL.

    I'm not sure if that's right but that's my understanding 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..."


  22. #22
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Code from silentwolf:
    Code:
    DWORD QuickChecksum(DWORD *pData, int size)
    {
    	if(!pData) { return 0x0; }
    
    	DWORD sum;
    	DWORD tmp;
    	sum = *pData;
    
    	for(int i = 1; i < (size/4); i++)
    	{
    		tmp = pData[i];
    		tmp = (DWORD)(sum >> 29) + tmp;
    		tmp = (DWORD)(sum >> 17) + tmp;
    		sum = (DWORD)(sum << 3)  ^ tmp;
    	}
    
    	return sum;
    }
    Usage:
    Code:
    void sys_glBufferDataARB(GLenum target, GLsizei size, const void* data, GLenum usage)
    {
    	bufferCRC[lastBuffer] = QuickChecksum((DWORD*)data, size);
    
    	orig_glBufferDataARB(target, size, data, usage);
    }
    There used to be something meaningful here.

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

    Default

    Quote Originally Posted by Frement View Post
    Code from silentwolf:
    Code:
    DWORD QuickChecksum(DWORD *pData, int size)
    {
        if(!pData) { return 0x0; }
    
        DWORD sum;
        DWORD tmp;
        sum = *pData;
    
        for(int i = 1; i < (size/4); i++)
        {
            tmp = pData[i];
            tmp = (DWORD)(sum >> 29) + tmp;
            tmp = (DWORD)(sum >> 17) + tmp;
            sum = (DWORD)(sum << 3)  ^ tmp;
        }
    
        return sum;
    }
    Usage:
    Code:
    void sys_glBufferDataARB(GLenum target, GLsizei size, const void* data, GLenum usage)
    {
        bufferCRC[lastBuffer] = QuickChecksum((DWORD*)data, size);
    
        orig_glBufferDataARB(target, size, data, usage);
    }
    Problem with that is that glBufferDataARB doesn't exist in OpenGL anymore.. well at least I cannot find any documentation on it. After decompiling the OpenGL in system32, it's not there either. Infact, none of the ARB functions are. It doesn't seem to be a wiggle function either. I'll look into it more. For now I figured out how to render properly and label things as I go along cleaner than before and faster. Had to ditch GDI completely:




    Just have to clear it up more and remove unneccesary ones such as the border of the chatbox and background ID's, etc. And work on a better algorithm or see if I can grab textures before the digits get draw on it. I think I messed up somewhere though.. that little mind rune isn't showing up properly unless I hover over it.
    I am Ggzz..
    Hackintosher

  24. #24
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    All the ARB methods should be there, as far as I know, and last I've checked.
    There used to be something meaningful here.

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

    Default

    Quote Originally Posted by Frement View Post
    All the ARB methods should be there, as far as I know, and last I've checked.
    Decompile it and you get:
    https://github.com/Brandon-T/GLHook/.../GLExports.txt

    Not on MSDN either.
    I am Ggzz..
    Hackintosher

Page 1 of 4 123 ... 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
  •