• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple D3D Menu
#1
Directly to the topic
You just simply copy and paste into your new project

Headers:

Functions.h
Code:
//==================================================================
// This file is part of Qmoainxbase D3D Private part 1
// (c) copyright Qmoainx 2011
// special thanks to: mpgh.net
//==================================================================

#include "SystemIncludes.h"


void PrintText(char pString[], int x, int y, D3DCOLOR col, ID3DXFont *font)
{
    RECT FontRect = { x, y, x+500, y+30 };
    font->DrawText( NULL, pString, -1, &FontRect, DT_LEFT | DT_WORDBREAK, col);
}

void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
    if( w < 0 )w = 1;
    if( h < 0 )h = 1;
    if( x < 0 )x = 1;
    if( y < 0 )y = 1;

    D3DRECT rec = { x, y, x + w, y + h };
    pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}

void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, (y + h - px), w, px,    BorderColor, pDevice );
    FillRGB( x, y, px, h,                BorderColor, pDevice );
    FillRGB( x, y, w, px,                BorderColor, pDevice );
    FillRGB( (x + w - px), y, px, h,    BorderColor, pDevice );
}

void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, y, w, h,        BoxColor, pDevice );
    DrawBorder( x, y, w, h, 1,    BorderColor, pDevice );
}  

bool isMouseinRegion(int x1, int y1, int x2, int y2)
{
        POINT cPos;
        GetCursorPos(&cPos);
        if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){
                return true;
        } else {
                return false;
        }
}

bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
        for(;*szMask;++szMask,++pData,++bMask)
                if(*szMask=='x' && *pData!=*bMask)  
                        return 0;
        return (*szMask) == NULL;
}

DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
        for(DWORD i=0; i<dwLen; i++)
                if (bCompare((BYTE*)(dwAddress+i),bMask,szMask))  
                        return (DWORD)(dwAddress+i);
        return 0;
}

void *DetourFunction (BYTE *src, const BYTE *dst, const int len)//edit if you want to work for the game
{
                BYTE *jmp = (BYTE*)malloc(len+5);
        DWORD dwBack;

        VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
        memcpy(jmp, src, len);  
        jmp += len;
        jmp[0] = 0xE9;
        *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
        src[0] = 0xE9;
        *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
        for (int i=5; i<len; i++)  src[i]=0x90;
        VirtualProtect(src, len, dwBack, &dwBack);
        return (jmp-len);
}

QmoMenuClass.h
Code:
//==================================================================
// This file is part of Qmoainxbase D3D Private part 1
// (c) copyright Qmoainx 2011
// special thanks to:
//   mpgh.net
//==================================================================
#include "Functions.h"


typedef struct{
        int index;
        char * title;
        int *hack;
        int hackmaxval;
        int hacktype;
        DWORD HCOLOR;
}ITEM;

class QmoMenu {
        public:
        LPDIRECT3DDEVICE9 pDevice;
        LPD3DXFONT pFont;

        int hackcount;
        int selector;
        int x,y,w,h;
        DWORD COLOR;

        ITEM HACKITEM[99];
        char hackrval[256];

        void CreateItem(int index, char * title, int *hack,int hackmaxval=1,int hacktype=0);
        void BuildMenu(char * menuname, int x, int y, int h, int w, DWORD TITLECOL, DWORD BACKCOLOR, DWORD BORDERCOLOR, LPDIRECT3DDEVICE9 pDevice);
        void RenderMenu();
};

typedef HRESULT ( WINAPI* oReset )( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );//edit if you want to work for the game
typedef HRESULT (WINAPI* oEndScene)(LPDIRECT3DDEVICE9 pDevice);

//Colors A,R,G,B Please use to make Chams
#define RED D3DCOLOR_ARGB(255, 255, 0, 0)
#define GREEN D3DCOLOR_ARGB(255, 0, 255, 0)
#define BLUE D3DCOLOR_ARGB(255, 0, 0, 255)
#define WHITE D3DCOLOR_ARGB(255, 255, 255, 255)
#define BLACK D3DCOLOR_ARGB(255, 0, 0, 0)
#define YELLOW D3DCOLOR_ARGB(255, 255, 255, 0)
#define TEAL D3DCOLOR_ARGB(255, 0, 255, 255)
#define PINK D3DCOLOR_ARGB(255, 255, 240, 0)
#define ORANGE D3DCOLOR_ARGB(255, 255, 132, 0)
#define LIME D3DCOLOR_ARGB(255, 198, 255, 0)
#define SKYBLUE D3DCOLOR_ARGB(255, 0, 180, 255)
#define MAROON D3DCOLOR_ARGB(255, 142, 30, 0)
#define LGRAY D3DCOLOR_ARGB(255, 174, 174, 174)
#define DGRAY D3DCOLOR_ARGB(255, 71, 65, 64)
#define BROWN D3DCOLOR_ARGB(255, 77, 46, 38)
#define SHIT D3DCOLOR_ARGB(255, 74, 38, 38)

SystemIncludes.h
Code:
/==================================================================
// This file is part of Qmoainxbase D3D Private part 1
// (c) copyright Qmoainx 2011
// special thanks to: mpgh.net
//==================================================================

#include <Windows.h>
#include <stdio.h>
#include <d3d9.h>
#include <d3dx9.h>

#pragma comment(lib,"d3dx9.lib")

Source Files:

D3dbase.cpp
Code:
//==================================================================
// This file is part of Qmoainxbase D3D Private part 1
// (c) copyright Qmoainx 2011
// special thanks to: mpgh.net
//==================================================================
#include "QmoMenuClass.h"

oReset pReset;
oEndScene pEndScene;

QmoMenu dMenu;

LPDIRECT3DDEVICE9 g_pDevice = 0;
//Offset Adjust Font Menu Hack
int xFontOffSet = 15;

int hackopt1;
int MenuHeight = 10;

int show=1;

int b = 0;
//==================================================================
//Menu HACK
int hack1 = 0;
int hack2 = 0;
int hack3 = 0;
int hack4 = 0;
int hack5 = 0;
//==================================================================

void QmoMenu::CreateItem(int index, char * title, int *hack, int hackmaxval,int hacktype)
{
        hackcount++;
        HACKITEM[hackcount].index = index;
        HACKITEM[hackcount].hack = hack;
        HACKITEM[hackcount].hackmaxval = hackmaxval;
        HACKITEM[hackcount].hacktype = hacktype;
        // Set the high and low Menu Hack
        PrintText(title, xFontOffSet, index*15,HACKITEM[hackcount].HCOLOR,pFont);
}

void QmoMenu::BuildMenu(char * menuname, int x, int y, int h, int w, DWORD TITLECOL, DWORD BACKCOLOR, DWORD BORDERCOLOR, LPDIRECT3DDEVICE9 pDevice)
{
        if(GetAsyncKeyState(VK_INSERT)&1)show=(!show); //Bring up the Menu HACK (INSERT)
        if(!show) {
                DrawBox(0,0, w, 20, BACKCOLOR, BORDERCOLOR, pDevice);
                PrintText("Qmoainx D3D MENU", 5, 2, TITLECOL, pFont);
                return;
        }

       // DrawBox(x,y, w, h, BACKCOLOR, BORDERCOLOR, pDevice); // Adjust the Base Menu Hack
        PrintText(menuname, x+10, y+2, TITLECOL, pFont);
        CreateItem(1,"Wallhack", &hack1);
        CreateItem(2,"Chams", &hack2);
        CreateItem(3,"Crosshair", &hack3);
        CreateItem(4,"NO Smoke", &hack4);
        CreateItem(5,"?????", &hack5);
        RenderMenu();
}


void QmoMenu::RenderMenu() //Hotkey menu
{
        if(GetAsyncKeyState(VK_DOWN)&1)
                        selector++;

        if(GetAsyncKeyState(VK_UP)&1)
                if(selector > 1)
                        selector--;

        if (GetAsyncKeyState(VK_RIGHT)<0){
                for(int i=0;i < (hackcount+1);i++){
           if(selector == HACKITEM[i].index){
                           if(*HACKITEM[i].hack < HACKITEM[i].hackmaxval)
                                        *HACKITEM[i].hack += 1;

                                        }
                        }
        }

        if (GetAsyncKeyState(VK_LEFT)<0){
                for(int i=0;i < (hackcount+1);i++){
           if(selector == HACKITEM[i].index){
                           *HACKITEM[i].hack = 0;
                           Sleep(200);
                                }
                        }
        }
        
        for(int i=0;i < (hackcount+1);i++){
                if(selector == HACKITEM[i].index)
                        HACKITEM[i].HCOLOR = GREEN;
                else
                        HACKITEM[i].HCOLOR = RED;
        }

        for(int i=1; i<(hackcount+1); i++){
                if(HACKITEM[i].hacktype == 0){
                if(*HACKITEM[i].hack == 1)

                // Set the high and low Hotkey Menu
                PrintText("On", xFontOffSet+100, HACKITEM[i].index*15,WHITE,pFont);
         else
                PrintText("Off", xFontOffSet+100, HACKITEM[i].index*15,RED,pFont);
        
                }
        }

        if(selector < 1)
                selector = 1;

        if(selector > hackcount)
                selector = 1;

        hackcount = 0;
}

void TestThread() //Raising texk if ON / OFF
{
        if( hack1 == 1)
                PrintText("Wallhack [ON] text will change color", 30, 200, GREEN, dMenu.pFont);
        else
                PrintText("Wallhack [ON] text will change color", 30, 200, RED, dMenu.pFont);
} //Customize it

void ReFont(LPDIRECT3DDEVICE9 pDevice) //For replacement fonts
{
    if (g_pDevice != pDevice)
    {
        g_pDevice = pDevice;
        try
        {
            if (dMenu.pFont != 0)
                dMenu.pFont->Release();
        } catch (...) {}
        dMenu.pFont = 0;
        D3DXCreateFontA(pDevice, 14, 0, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &dMenu.pFont );
    }
}

HRESULT WINAPI Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )
{
        dMenu.pFont->OnLostDevice();

        HRESULT hRet = pReset(pDevice, pPresentationParameters);

        dMenu.pFont->OnResetDevice();

        return hRet;
}

// Menu TITLE
HRESULT WINAPI EndScene(LPDIRECT3DDEVICE9 pDevice)
{
        ReFont(pDevice);
        dMenu.BuildMenu("mpgh.net 2011",0,0,190,200,RED,BLACK,GREEN,pDevice);
        TestThread();
        return pEndScene(pDevice);
}

int D3Dinit(void)//edit if you want to work for the game
{
        DWORD           hD3D, adr, *vtbl;
        hD3D=0;
        do {
                hD3D = (DWORD)GetModuleHandle("d3d9.dll");
                Sleep(10);
        } while(!hD3D);
        adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
        if (adr) {
                memcpy(&vtbl,(void *)(adr+2),4);
                pReset    = (oReset)    DetourFunction((PBYTE)vtbl[16]   , (PBYTE)Reset   ,5);
                pEndScene = (oEndScene) DetourFunction((PBYTE)vtbl[42], (PBYTE)EndScene,5);
        }
        return 0;
}

BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )//edit if you want to work for the game
{
        DisableThreadLibraryCalls(hDll);

        if ( dwReason == DLL_PROCESS_ATTACH ) {

                CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3Dinit, NULL, NULL, NULL);
        }
        if( dwReason == DLL_PROCESS_DETACH)     {
                dMenu.pFont->Release();
        }
        return TRUE;
}

The end result should look like this:
[Image: unledbkt.jpg]

Credits
Qmoainx
  Reply
#2
Good work, Big Grin
  Reply
#3
This is really cool, sucks I suck at c++ :\
  Reply
#4
Haha you made the tuto before i could make my D3D trainer Troll

Good Work man!

Thanks Barata...
Don't worry if things aren't the way you planned, in the end everything will solve itself...
  Reply
#5
ItsModsloader was even more advanced than this...
  Reply
#6
(01-22-2012, 16:53)SuperNovaAO Wrote: ItsModsloader was even more advanced than this...

U JELLY? Troll

Thanks Barata...
Don't worry if things aren't the way you planned, in the end everything will solve itself...
  Reply
#7
(01-22-2012, 16:53)SuperNovaAO Wrote: ItsModsloader was even more advanced than this...

Hence the title "Simple D3D Menu" lol.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Help Admin menu koren30 4 4,758 10-07-2013, 20:17
Last Post: Yamato
  [Tutorial] How-To, Mod menu picture-REVISED/no iwifix needed rotceh_dnih 52 29,522 09-28-2013, 02:08
Last Post: Monkey Arms
  Help How do I open the admin menu for GeKKos QS Mod? conorr 1 2,845 08-15-2013, 13:52
Last Post: Yamato
  Trying to compile a modified menu DidUknowiPwn 7 5,250 07-05-2013, 21:55
Last Post: DidUknowiPwn
  [Release] Mw3 Simple External Console barata 25 20,780 06-30-2013, 16:30
Last Post: nexzhd
  Simple flyable helicopter script port, could use help! akillj 0 2,360 06-15-2013, 09:20
Last Post: akillj
  Preview Admin / Mod Menu Hologramm 5 6,119 05-29-2013, 00:35
Last Post: sleepunknot
  Map Menu in Black Ops 1 EliTeEishiii 2 2,821 04-21-2013, 18:54
Last Post: Nekochan
  Menu base EliTeEishiii 1 2,688 04-17-2013, 16:10
Last Post: Nekochan
Rainbow [Release] [Contest] Scroll Menu iAegle 49 34,158 03-21-2013, 07:30
Last Post: jermC

Forum Jump:


Users browsing this thread: 1 Guest(s)