Welcome to the UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats.
You have to register before you can post and see and access any of the advanced forum features, please click the register link to proceed to the registration form. To start viewing threads or posts, select a forum that you want to visit from the selection below.
Direct3D hacking programming reversing
You are Unregistered, please register to gain Full access.
Don't get scared away by my low post count. There are no binaries here and none of this code is stolen, or in use on a pay site. With that said I will now begin the thread
Features of this release:
- Mouse controlled menu (with tabs)
- Easy to expand on
- Mostly clean code
- Save/load settings included
- Works in any game or hook
I left out certain features like multiple window support, combo boxes, sliders, console window, and some other things. The reason is I wanted to make the post simple, and maybe get some creative juices flowing.
Menu Notes:
I am releasing this because I am no longer working on it and someone should give it the love and attention it deserves.
Quote:
How to add items to the menu:
Here is the function definition for adding an item
CItem * CMenu::AddItem(CItem * pItem)
Here is the constructor for a checkbox
CCheckBox(int x, int y, char* szName, int iTab, float DefaultValue, float *pVar);
This is one way you can use it
pMenu->AddItem(new CCheckBox(20, 70, "Check1", 1, 0, &g_Vars.Check1));
What I dereference is a float, defined like this
float Check1;
When you click the checkbox it will modify that float, so i can do this outside of the menu
if(g_Vars.Check1)
//Hack code here
I'm going to leave adding a button up to you but it's not hard at all
Renderer Notes:
The primitive renderer is not only kind of slow but you may run into issues in certain games.
Quote:
I did not have permission from the author of the renderer I originally used to release it with this menu. I included a simple primitive renderer, however, I highly recommend you switch to sprite rendering because it is much faster.
Main Include "CMenu.h":
Code:
#pragma once
//////////////////////////////////////////////////////
/*
THIS IS A UC-FORUM ONLY RELEASE
www.uc-forum.com
This code is not to be sold, it is public code ONLY and is for learning purposes.
*/
//////////////////////////////////////////////////////
/*Constructors of importance:
CMenu::CMenu
CItem::CCheckBox
CItem::CButton
CItem::CTab
Functions of importance:
CMenu::AddItem
CMenu::DoMenu
CINIReader::FileToVariable
CINIReader::VariableToFile
*/
/*
How to add items to the menu:
Here is the function definition for adding an item
CItem * CMenu::AddItem(CItem * pItem)
Here is the constructor for a checkbox
CCheckBox(int x, int y, char* szName, int iTab, float DefaultValue, float *pVar);
This is one way you can use it
pMenu->AddItem(new CCheckBox(20, 70, "Check1", 1, 0, &g_Vars.Check1));
What I dereference is a float, defined like this
float Check1;
When you click the checkbox it will modify that float, so i can do this outside of the menu
if(g_Vars.Check1)
//Hack code here
I'm going to leave adding a button up to you but it's not hard at all
Renderer notes:
I did not have permission from the author of the renderer I originally used to release it with this menu.
I included a simple primitive renderer, however, I highly recommend you switch to sprite rendering because it is much faster.
*/
//Colors
#define COLOR_NORMAL D3DCOLOR_ARGB(255, 25, 25, 25)
#define COLOR_MOUSEOVER D3DCOLOR_ARGB(255, 40, 40, 40)
#define COLOR_MOUSECLICK D3DCOLOR_ARGB(255, 55, 55, 55)
#define COLOR_TEXT D3DCOLOR_ARGB(255, 255, 255, 255)
#define COLOR_BACK D3DCOLOR_ARGB(255, 30, 30, 30)
#define COLOR_ITEM_BACK D3DCOLOR_ARGB(255, 45, 45, 45)
#define COLOR_CURSOR D3DCOLOR_ARGB(255, 255, 50, 0)
//These are used for saving/loading settings
#define ITEMTYPE_TAB 0
#define ITEMTYPE_CHECKBOX 1
#define ITEMTYPE_BUTTON 2
#pragma warning(disable: 4244)
class CVariables;
class CMenuInfo;
class CBaseMenu;
class CMenu;
class CItem;
class CCheckBox;
class CButton;
class CTab;
#include "CBaseMenu.h"
#include "CMenuItem.h"
#include "CVariableManager.h"
Main Menu Code "CBaseMenu.h":
Code:
#pragma once
#define LIST_SIZE 18
//Everything in the menu gets a pointer to this
class CMenuInfo
{
public:
//Mouse stuff
int Left, Right;
int aLeft, aRight;
POINT CursorPos;
RECT WndRect;
HWND WindowHandle;
//Is menu open
bool * pbOpen;
int iNumItems;
CMenu * pWindow;
};
//Everything gets a pointer to this, which holds the Info pointer
class CBaseMenu
{
public:
CBaseMenu();
~CBaseMenu();
BOOL IsPointInRect(int PointX, int PointY, int RectX, int RectY, int RectW, int RectH);
int GetMouseInfo();
CMenuInfo* Info;
D3DVIEWPORT9 Viewport;
};
class CMenu : public CBaseMenu
{
public:
CMenu(LPDIRECT3DDEVICE9 pDevice, int X, int Y, int W, int H, char * szName);
~CMenu();
void DoMenu();
void DrawCursor(int type);
void LoadSettings();
void SaveSettings();
CItem * AddItem(CItem* pItem);
int iNumItems;
int iCurrentTab;
int iNumTabs;
int OldX, OldY;
int x, y, w, h;
bool bIsOpen;
bool bMoving;
DWORD dwColor;
private:
int CheckMove();
bool bFirstCall;
char * szName;
CItem * pItemList[LIST_SIZE];
};
#pragma once
class CItem : public CBaseMenu
{
public:
virtual void Draw() = 0;
virtual int CheckMouse() = 0;
int x, y, w, h, iTabnum;
int index;
float type;
float DefaultValue;
DWORD dwColor;
float * value;
char * szName;
//The window that made this item
CMenu * pWindow;
};
class CCheckBox : public CItem
{
public:
CCheckBox(int x, int y, char* szName, int iTab, float DefaultValue, float *pVar);
void Draw();
int CheckMouse();
};
class CButton : public CItem
{
public:
CButton(int x, int y, int w, int h, char* szName, int iTab, DWORD *pFunctionToCall);
void Draw();
int CheckMouse();
void HandleClick();
bool bHandleClick;
DWORD pFunction;
};
class CTab : public CItem
{
public:
CTab(int x, int y, int w, int h, char* szName, int iTab);
void Draw();
int CheckMouse();
};
CMenuItem.cpp:
Code:
#include "stdafx.h"
////////////////////////////////////////////////////////////////
//Menu Item Code
////////////////////////////////////////////////////////////////
//I tried to use the same function order for every different item type
CCheckBox::CCheckBox(int x, int y, char* szName, int iTab, float DefaultValue, float *pVar)
{
this->x = x;
this->y = y;
this->w = 10;
this->h = 10;
this->dwColor = COLOR_NORMAL;
this->szName = szName;
this->type = 1;
this->value = 0;
this->iTabnum = iTab;
this->DefaultValue = DefaultValue;
value = pVar;
*value = DefaultValue;
}
void CCheckBox::Draw()
{
int x = this->x + pWindow->x;
int y = this->y + pWindow->y;
pRenderer->FillRect(x, y, w, h, dwColor);
pRenderer->DrawBox(x, y, w, h, COLOR_TEXT);
pRenderer->DrawText(x + w + 5, y + (h/2), COLOR_TEXT, szName, DT_VCENTER);
if(*value == 1)
pRenderer->DrawText(x+ (w/2), y+ (h/2) - 1, COLOR_TEXT, "x", DT_CENTER | DT_VCENTER);
CheckMouse();
}
int CCheckBox::CheckMouse()
{
int x = this->x + pWindow->x;
int y = this->y + pWindow->y;
if(IsPointInRect(pWindow->Info->CursorPos.x, pWindow->Info->CursorPos.y, x, y, w, h))
{
if(pWindow->Info->aLeft)
dwColor = COLOR_MOUSECLICK;
else
dwColor = COLOR_MOUSEOVER;
if(pWindow->Info->Left)
{
if(*value == 0)
*value = 1;
else
*value = 0;
return 1;
}
}
else
dwColor = COLOR_NORMAL;
return 0;
}
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
//Pass in the address of a function
CButton::CButton(int x, int y, int w, int h, char* szName, int iTab, DWORD *pFunctionToCall)
{
this->x = x;
this->y = y;
this->w = w;
this->h = h;
this->dwColor = COLOR_NORMAL;
this->szName = szName;
this->type = 2;
this->iTabnum = iTab;
pFunction = (DWORD)pFunctionToCall;
}
void CButton::Draw()
{
int x = this->x + pWindow->x;
int y = this->y + pWindow->y;
pRenderer->FillRect(x, y, w, h, dwColor);
pRenderer->DrawBox(x, y, w, h, COLOR_TEXT);
pRenderer->DrawText(x + (w/2), y + (h/2), COLOR_TEXT, szName, DT_CENTER | DT_VCENTER);
CheckMouse();
}
int CButton::CheckMouse()
{
int x = this->x + pWindow->x;
int y = this->y + pWindow->y;
if(IsPointInRect(pWindow->Info->CursorPos.x, pWindow->Info->CursorPos.y, x, y, w, h))
{
if(pWindow->Info->aLeft)
dwColor = COLOR_MOUSECLICK;
else
dwColor = COLOR_MOUSEOVER;
if(pWindow->Info->Left)
{
HandleClick();
return 1;
}
}
else
dwColor = COLOR_NORMAL;
return 0;
}
void CButton::HandleClick()
{
//Single execution button code
DWORD func = pFunction;
_asm
{
mov eax, func
call eax
}
}
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
CTab::CTab(int x, int y, int w, int h, char* szName, int iTab)
{
this->x = x;
this->y = y;
this->w = w;
this->h = h;
this->dwColor = COLOR_NORMAL;
this->szName = szName;
this->type = 0;
this->iTabnum = iTab;
//this->pWindow->iNumTabs++;
}
void CTab::Draw()
{
int x = this->x + pWindow->x;
int y = this->y + pWindow->y;
pRenderer->FillRect(x, y, w, h, dwColor);
pRenderer->DrawBox(x, y, w, h, COLOR_TEXT);
pRenderer->DrawText(x + (w/2)+1, y + (h/2), COLOR_TEXT, szName, DT_CENTER | DT_VCENTER);
CheckMouse();
}
int CTab::CheckMouse()
{
int x = this->x + pWindow->x;
int y = this->y + pWindow->y;
if(IsPointInRect(pWindow->Info->CursorPos.x, pWindow->Info->CursorPos.y, x, y, w, h))
{
if(pWindow->Info->aLeft)
dwColor = COLOR_MOUSECLICK;
else
dwColor = COLOR_MOUSEOVER;
if(pWindow->Info->Left)
{
pWindow->iCurrentTab = iTabnum;
return 1;
}
}
else
dwColor = COLOR_NORMAL;
if(pWindow->iCurrentTab == iTabnum)
dwColor = COLOR_MOUSEOVER + D3DCOLOR_ARGB(0, 6, 6, 6);
return 0;
}
/////////////////////////////////////////////////////////////////////////////
Cool menu. Just a tip: instead of using an array of items (where you have to keep in track with a total items define) you could use a vector to store all your items. Its much more easy to manage cause it basically dynamically resizable, and overall just better.
Or create your own linked list, but depends on how you want to do it.
A linked list has more overhead when you iterate through it. Since you don't modify the list very much, it would be a better idea to use an array implementation.
Quote:
Originally Posted by |KungFuPenguin|
Cool menu. Just a tip: instead of using an array of items (where you have to keep in track with a total items define) you could use a vector to store all your items. Its much more easy to manage cause it basically dynamically resizable, and overall just better.
yep.. let vector handle all the bs for you.
Quote:
Originally Posted by SEGnosis
Nice, but absolutely no features I haven't seen before D:
He didn't release some of the harder gui objects... leaving an open window for creativity.
__________________
[22:22] monster64: yo dawg i heard u like chams so i put chams in your chams so you can see through shit while you see through shit
[09:07] Tally: grab your ak47 and put on your bomb jacket.... its gonna be a long morning
A linked list has more overhead when you iterate through it. Since you don't modify the list very much, it would be a better idea to use an array implementation.
Not if you code and implement it correctly; and I wasn't swinging a dick saying it was better than anything else, I was simply suggesting more options.
Not if you code and implement it correctly; and I wasn't swinging a dick saying it was better than anything else, I was simply suggesting more options.
for iterating the overhead is minimal, if any (if implemented correctly)
for getting the nth item, there is overhead in linked list.
for getting the nth item, there is overhead in linked list.
That's very very true, but you shouldn't be getting a specific item from the linked list when dealing with a GUI (Ideally). If you are, I wouldn't deal with a linked list either.