Results 1 to 7 of 7
  1. #1
    mestrelost's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    4

    Arrow [HELP] Base Menu D3D9

    Well I'm trying to learn basic menu D3D9 learned a few things in some of the tutorial here MPGH

    Then I found some code to hack a D3D9 I know is "CA ", but the other does not know
    will be that you can see if it's Crossfire
    or have half a basis of a hack crossfire D3D9
    the rest I turn

    Base d3d9 CA

    Code:
    include <d3d9.h>
    #include <d3dx9.h>
    #include <windows.h>
    #include <tchar.h>
    #include <stdio.h>
    #include "detours.h"
    HMODULE D3D9Handle = NULL;
    DWORD** VtablePtr = NULL;
    DWORD* VTable = NULL;
    ID3DXFont* pfont = NULL;
    
    typedef HRESULT (*oPresent) (LPDIRECT3DDEVICE9, CONST RECT* ,CONST RECT* , HWND, CONST RGNDATA* );
    typedef HRESULT (*oReset)(LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
    oPresent pPresent = NULL;
    oReset pReset = NULL;
    
    HRESULT myPresent(LPDIRECT3DDEVICE9 pDevice, CONST RECT* pSourceRect,CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)
    {
        RECT font_rect;
            SetRect(&font_rect,20,50,500,50+23);
            pfont->DrawTextA(NULL,                //pSprite
                            "THATS THE WAY IT IS!",                //your text
                            -1,                    //Count(-1 to disregard)
                            &font_rect,            //pRect(controls positioning)
                            DT_LEFT|DT_NOCLIP,    //Format (DT_WORDBREAK for wrapping)
                            0xFFFFFFFF);            //Color (ARGB)
            return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
    }
    
    HRESULT myReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pParam)
    {
        HRESULT hr = NULL;
        pfont->OnLostDevice();
        hr = pReset(pDevice, pParam);
        pfont->OnResetDevice();
        return hr;
    }
    
    DWORD** FindDevice(DWORD Base,DWORD Len)
    {
        unsigned long i = 0, n = 0;
    
        for( i = 0; i < Len; i++ )
        {
            if(*(BYTE *)(Base+i+0x00)==0xC7)n++;
            if(*(BYTE *)(Base+i+0x01)==0x06)n++;
            if(*(BYTE *)(Base+i+0x06)==0x89)n++;
            if(*(BYTE *)(Base+i+0x07)==0x86)n++;    
            if(*(BYTE *)(Base+i+0x0C)==0x89)n++;
            if(*(BYTE *)(Base+i+0x0D)==0x86)n++;
    
            if(n == 6) return (DWORD**)
                (Base + i + 2);n = 0;
        }
        return(0);
    }
    
    VOID Hook(VOID)
    {          
        D3D9Handle = GetModuleHandleA("d3d9.dll");
        VtablePtr = FindDevice((DWORD)D3D9Handle,0x128000);
        VTable = *VtablePtr;    
        pPresent = (oPresent)DetourAttach( &(PVOID&)VTable[17], myPresent);
        pReset   = (oReset)DetourAttach(&(PVOID&)VTable[16],myReset);
    
        D3DXCreateFontA((LPDIRECT3DDEVICE9)VtablePtr,     //D3D Device
                            22,                  //Font height
                            0,                //Font width
                            FW_NORMAL,        //Font Weight
                            1,                //MipLevels
                            false,            //Italic
                            DEFAULT_CHARSET,  //CharSet
                            OUT_DEFAULT_PRECIS, //OutputPrecision
                            ANTIALIASED_QUALITY, //Quality
                            DEFAULT_PITCH|FF_DONTCARE,//PitchAndFamily
                            "Arial",          //pFacename,
                            &pfont);         //ppFont
    }
    
    void UnHook()
    {
        DetourDetach(&(PVOID&)VTable[17], &(PVOID&)myPresent);
        DetourDetach(&(PVOID&)VTable[16], &(PVOID&)myReset);
        return;
    }
    
    
    void mainthread()
    {
        while(1)
        {
            Sleep(200);
        }
    }
            
    
    BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpvReserved)
    {
        switch(dwReason)
        {
            case DLL_PROCESS_ATTACH:
                DisableThreadLibraryCalls( hModule );
                while((!GetModuleHandleA("d3d9.dll") || !GetModuleHandleA("ClientFX.fxd")|| !GetModuleHandleA("CShell.dll")))
                {Sleep(200);}//waiting for modules to load
                DetourTransactionBegin();
                DetourUpdateThread( GetCurrentThread() );
                Hook();
                DetourTransactionCommit();
                //CreateThread( 0, 0, ( LPTHREAD_START_ROUTINE )Hook, 0, 0, 0 );
                CreateThread( 0, 0, ( LPTHREAD_START_ROUTINE )mainthread, 0, 0, 0 );
                
    
            case DLL_PROCESS_DETACH:
                DetourTransactionBegin();
                UnHook();
                DetourTransactionCommit();
    
        }
    }
    _________________

    Code:
    #include "CMenu.h"
    #include "d3d9.h"
    #include <windows.h>
    #include <vector>
    #include <string>
    #include <sstream>
    
    using namespace std;
    
    
    CMenu::CMenu(LPDIRECT3DDEVICE9 lpDev) : m_pDev(lpDev)
    {
        hack_selection = 0;
    
        hack_offset = 17;
        hack_offset_width = 160;
        title_offset_height = 26;
    
        bMenu = FALSE;
    
        text_title_text = "None";
    
        hacks.clear();
    
        D3DXCreateFont(m_pDev, 14, 5, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &font_body);
        D3DXCreateFont(m_pDev, 16, 7, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &font_title);
        D3DXCreateFont(m_pDev, 15, 5, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &font_free);
    
    
        itcp_buf = (char *)malloc(5); // 2 extra for the lulz
    }
    
    
    
    
    /***[BOX]***/
    void CMenu::SetBodyBox(int x, int y, int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b, int text_r, int text_g, int text_b, int value_r, int value_g, int value_b, int highlight_r, int highlight_g, int highlight_b)
    {
        body_box.x1 = x;
        body_box.x2 = x + hack_offset_width;
        body_box.y1 = y;
        body_box.y2 = y + (hack_offset * GetNumHacks() - 1);
    
        body_box_color = D3DCOLOR_ARGB(255, r, g, b);
    
        body_box_border.x1 = body_box.x1 - border_width;
        body_box_border.x2 = body_box.x2 + border_width;
        body_box_border.y1 = body_box.y1 - border_height;
        body_box_border.y2 = body_box.y2 + border_height;
        
        /***[TEXT]***/
        body_box_rect.top = body_box.y1;
        body_box_rect.bottom = body_box.y2;
        body_box_rect.right = body_box.x2;
        body_box_rect.left = body_box.x1;
    
        body_box_text_color = D3DCOLOR_XRGB(text_r, text_g, text_b);
        body_box_value_color = D3DCOLOR_XRGB(value_r, value_g, value_b);
        body_box_highlight_color = D3DCOLOR_XRGB(highlight_r, highlight_g, highlight_b);
        /***[\TEXT]***/
    
        body_box_border_color = D3DCOLOR_ARGB(255, border_r, border_g, border_b);
    }
    
    void CMenu::SetBodyBox(int x, int y, int width, int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b, int text_r, int text_g, int text_b, int value_r, int value_g, int value_b, int highlight_r, int highlight_g, int highlight_b)
    {
        hack_offset_width = width;
        
        body_box.x1 = x;
        body_box.x2 = x + hack_offset_width;
        body_box.y1 = y;
        body_box.y2 = y + (hack_offset * GetNumHacks() - 1);
    
        body_box_color = D3DCOLOR_ARGB(255, r, g, b);
    
        body_box_border.x1 = body_box.x1 - border_width;
        body_box_border.x2 = body_box.x2 + border_width;
        body_box_border.y1 = body_box.y1 - border_height;
        body_box_border.y2 = body_box.y2 + border_height;
        
        /***[TEXT]***/
        body_box_rect.top = body_box.y1;
        body_box_rect.bottom = body_box.y2;
        body_box_rect.right = body_box.x2;
        body_box_rect.left = body_box.x1;
    
        body_box_text_color = D3DCOLOR_XRGB(text_r, text_g, text_b);
        body_box_value_color = D3DCOLOR_XRGB(value_r, value_g, value_b);
        body_box_highlight_color = D3DCOLOR_XRGB(highlight_r, highlight_g, highlight_b);
        /***[\TEXT]***/
    
        body_box_border_color = D3DCOLOR_ARGB(255, border_r, border_g, border_b);
    }
    
    void CMenu::SetTitleBox(int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b)
    {
        title_box.x1 = body_box.x1;
        title_box.x2 = body_box.x2;
        title_box.y1 = body_box.y1 - title_offset_height;
        title_box.y2 = body_box.y1;
    
        title_box_color = D3DCOLOR_ARGB(255, r, g, b);
    
        title_box_border.x1 = title_box.x1 - border_width;
        title_box_border.x2 = title_box.x2 + border_width;
        title_box_border.y1 = title_box.y1 - border_height;
        title_box_border.y2 = title_box.y2 + border_height;
    
        title_box_border_color = D3DCOLOR_ARGB(255, border_r, border_g, border_b);
    }
    /***[\BOX]***/
    
    
    
    
    /***[TEXT]***/
    void CMenu::SetTitleText(int r, int g, int b, char *text)
    {
        text_title_box.top = title_box.y1;
        text_title_box.bottom = title_box.y2;
        text_title_box.right = title_box.x2;
        text_title_box.left = title_box.x1;
        
        text_title_color = D3DCOLOR_XRGB(r, g, b);
    
        text_title_text = text;
    }
    
    void CMenu::DrawFreeMenuText(int x, int y, int width, int height, int r, int g, int b, char *text)
    {
        if(bMenu)
        {
            RECT rect = {x, y, width, height};
            font_free->DrawTextA(NULL, text, -1, &rect, 0, D3DCOLOR_XRGB(r, g, b));
        }
    }
    /***[\TEXT]***/
    
    
    
    
    /***[HACKS]***/
    void CMenu::AddHack(char *hack_name, int default_value, int max_value)
    {
        HACK hack = {hack_name, default_value, max_value, default_value};
        hacks.push_back(hack);
    }
    
    BOOL CMenu::UpdateHack(char *hack_name, int value, int number)
    {
        if(hacks.at(number - 1).szName == hack_name)
        {
            if(hacks.at(number - 1).current_value == value)
            {
                return TRUE;
            }
        }
        
        return FALSE;
    }
    /***[\HACKS]***/
    
    
    
    
    /***[MISC]***/
    void CMenu::DrawMenu()
    {
        if(bMenu)
        {
            DrawBox(&body_box, body_box_color, &body_box_border, body_box_border_color);
            DrawHacks();
            
            if(text_title_text != "None")
            {
                DrawBox(&title_box, title_box_color, &title_box_border, title_box_border_color);
                DrawTitleText();
            }
        }
    }
    
    void CMenu::DoInput()
    {
        while(1)
        {
            if(GetAsyncKeyState(VK_INSERT))
                bMenu = !bMenu;
    
            if(bMenu)
            {
                if(GetAsyncKeyState(VK_UP))
                {
                    if(hack_selection == 0)
                    {
                        hack_selection = (GetNumHacks() - 1);
                    }
                    else if(hack_selection >= 1)
                    {
                        hack_selection--;
                    }
                }
    
                else if(GetAsyncKeyState(VK_DOWN))
                {
                    if(hack_selection == (GetNumHacks() - 1))
                    {
                        hack_selection = 0;
                    }
                    else if(hack_selection < (GetNumHacks() - 1))
                    {
                        hack_selection++;
                    }
                }
    
                if(GetAsyncKeyState(VK_RIGHT))
                {
                    if(hacks.at(hack_selection).current_value < hacks.at(hack_selection).max_value)
                    {
                        hacks.at(hack_selection).current_value++;
                    }
                    else
                    {
                        hacks.at(hack_selection).current_value = 0;
    
                    }
                }
    
                else if(GetAsyncKeyState(VK_LEFT))
                {
                    if(hacks.at(hack_selection).current_value > 0)
                    {
                        hacks.at(hack_selection).current_value--;
                    }
                    else
                    {
                        hacks.at(hack_selection).current_value = hacks.at(hack_selection).max_value;
                    }
                }
            }
    
            Sleep(103);
        }
    }
    
    int CMenu::GetNumHacks()
    {
        return ((int)hacks.size());
    }
    /***[\MISC]***/
    
    
    
    /***[PRIVATE]***/
    void CMenu::DrawBox(D3DRECT *dimensions, D3DCOLOR back_color, D3DRECT *border_dimensions, D3DCOLOR border_color)
    {
        m_pDev->Clear(1, border_dimensions, D3DCLEAR_TARGET, border_color, 1.0f, 0);
        m_pDev->Clear(1, dimensions, D3DCLEAR_TARGET, back_color, 1.0f, 0);
    }
    
    void CMenu::DrawTitleText()
    {
        font_title->DrawTextA(NULL, text_title_text, -1, &text_title_box, DT_CENTER | DT_VCENTER, text_title_color);
    }
    
    void CMenu::DrawHackText(LPRECT rect, D3DCOLOR color, char *text)
    {
        font_body->DrawTextA(NULL, text, -1, rect, 0, color);
    }
    
    void CMenu::DrawHackText(LPRECT rect, D3DCOLOR color, int number)
    {
        font_body->DrawTextA(NULL, int_to_char_p(number), -1, rect, 0, color);
    }
    
    void CMenu::DrawHacks()
    {
        for(int i = 0;i < hacks.size();i++)
        {    
            /***[DRAW HACKS]***/
            if(hack_selection == i)
                DrawHackText(&body_box_rect, body_box_highlight_color, hacks.at(i).szName);
            else
                DrawHackText(&body_box_rect, body_box_text_color, hacks.at(i).szName);
            
    
            body_box_rect.left += hack_offset_width - 8;
            if(strlen(int_to_char_p(hacks.at(i).current_value)) > strlen("a"))
            {
                for(int j = 1;j <= (strlen(int_to_char_p(hacks.at(i).current_value)) - 1);j++)
                {
                    body_box_rect.left -= 6;
                }
            }
            DrawHackText(&body_box_rect, body_box_value_color, hacks.at(i).current_value);
            body_box_rect.left = body_box.x1;
            /***[\DRAW HACKS]***/
    
            body_box_rect.top += hack_offset;
        }
    
        body_box_rect.top = body_box.y1;
    }
    
    char *CMenu::int_to_char_p(int to_char_p)
    {
        stringstream ss;
        ss << to_char_p;
    
        strcpy(itcp_buf, ss.str().c_str());
    
        return itcp_buf;
    }
    /***[\PRIVATE]***/




  2. The Following 2 Users Say Thank You to mestrelost For This Useful Post:

    MrJupi (10-07-2011),slonick (08-22-2013)

  3. #2
    “I fear the day technology will surpass our human interaction. The world will have a generation of idiots.” ~Albert Einstein
    MPGH Member
    SteamAss's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Location
    Crossfire
    Posts
    2,278
    Reputation
    28
    Thanks
    770
    My Mood
    Asleep
    Wow u learned a littel bit or all... =D nice code I will try to make it



    If you need my Help:
    PM/VM

    Because The People Who Are Crazy Enough To Think They Can Change The World, Are The Ones Who Do. ~Steve Jobs

  4. #3
    mestrelost's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    4
    This code will be something that has to be taken advantage of?




  5. #4
    godhacks's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Sin city
    Posts
    907
    Reputation
    5
    Thanks
    32
    My Mood
    Amazed
    you made this?

  6. #5
    mestrelost's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    4
    but I'm not learning a lot and finally found the base menu to D3D9
    Crossfire will do the hack aki then put the base here:]
    Last edited by mestrelost; 01-31-2011 at 06:44 PM.




  7. #6
    Swiftdude's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Illinois.
    Posts
    12,572
    Reputation
    1130
    Thanks
    2,995
    My Mood
    Cynical
    dont think this is for cf...but it sure as hell is missing some files.
    Still love you Giggletron

  8. #7
    firefox800's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    294
    Reputation
    10
    Thanks
    2,136
    My Mood
    Fine
    Hey mate you have a nice base...Try Topblast/Hans Menu its quite simple and works on Crossfire which I used now..

    https://sphotos.ak.fbcdn.net/hphotos-..._6549953_n.jpg
    Credits: Topblast & Hans