make cheat with menu to css in c#

Posts 1–10 of 10 · Page 1 of 1
make cheat with menu to css in c#
i know c# very well but i wanna start make cheats and menus in game
for counter strike source
what i need to learn?
directx?
hooking?
injecting?

can u guys give me a tutorial for begginers?
thx
Hey TheMaTriX,

I will advice you to create a menu in C++, if you are familiar to C# I will suggest you to get your hands dirty with some C++ tuts.
This thread will help you a lot.
http://www.mpgh.net/forum/31-c-c-pro...resources.html

This will help you to create a D3D Menu

CMenu.h :
Code:
#pragma once

#include "d3d9.h"
#include <windows.h>
#include <vector>

using namespace std;


class CMenu
{
public:
	CMenu(LPDIRECT3DDEVICE9 lpDev);

	/***[BOX]***/
	void 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);
	void 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);
	void SetTitleBox(int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b);
	/***[\BOX]***/

	/***[TEXT]***/
	void SetTitleText(int r, int g, int b, char *text);
	void DrawFreeMenuText(int x, int y, int width, int height, int r, int g, int b, char *text);
	/***[\TEXT]***/

	/***[HACKS]***/
	void AddHack(char *hack_name, int default_value, int max_value);
	BOOL UpdateHack(char *hack_name, int value, int number);
	/***[\HACKS]***/

	/***[MISC]***/
	void DrawMenu();
	void DoInput();
	int GetNumHacks();
	/***[\MISC]***/

private:
	void DrawBox(D3DRECT *dimensions, D3DCOLOR back_color, D3DRECT *border_dimensions, D3DCOLOR border_color);
	void DrawTitleText();
	void DrawHackText(LPRECT rect, D3DCOLOR color, char *text);
	void DrawHackText(LPRECT rect, D3DCOLOR color, int number);
	void DrawHacks();
	char *int_to_char_p(int to_char_p);
	
	struct HACK
	{
		char *szName;
		int default_value, max_value, current_value;
	};

	vector<HACK> hacks;
	
	int hack_selection;
	int hack_offset;
	int hack_offset_width;
	int title_offset_height;

	BOOL bMenu;
	
	D3DRECT body_box;
	D3DCOLOR body_box_color;
	D3DRECT body_box_border;
	D3DCOLOR body_box_border_color;

	D3DCOLOR body_box_text_color;
	D3DCOLOR body_box_value_color;
	D3DCOLOR body_box_highlight_color;
	RECT body_box_rect;

	D3DRECT title_box;
	D3DCOLOR title_box_color;
	D3DRECT title_box_border;
	D3DCOLOR title_box_border_color;

	RECT text_title_box;
	D3DCOLOR text_title_color;
	char *text_title_text;
	
	LPDIRECT3DDEVICE9 m_pDev;

	LPD3DXFONT font_body;
	LPD3DXFONT font_title;
	LPD3DXFONT font_free;


	char *itcp_buf;
};
CMenu.cpp :

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]***/
Thanks and credits to Plux
what need i install for #include "d3d9.h"?
this code write memory too?
its inject the code to the game?
can u explain me the code
its a dll project or console?
and there is an errors in ur code:
Code:
1>------ Build started: Project: d3d, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(81): error C2146: syntax error : missing ';' before identifier 'font_body'
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(81): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(81): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(82): error C2146: syntax error : missing ';' before identifier 'font_title'
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(82): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(82): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(83): error C2146: syntax error : missing ';' before identifier 'font_free'
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(83): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\cmenu.h(83): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(25): error C2065: 'font_body' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(25): error C3861: 'D3DXCreateFont': identifier not found
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(26): error C2065: 'font_title' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(26): error C3861: 'D3DXCreateFont': identifier not found
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(27): error C2065: 'font_free' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(27): error C3861: 'D3DXCreateFont': identifier not found
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(134): error C2065: 'font_free' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(134): error C2227: left of '->DrawTextA' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(262): error C2065: 'font_title' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(262): error C2227: left of '->DrawTextA' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(267): error C2065: 'font_body' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(267): error C2227: left of '->DrawTextA' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(272): error C2065: 'font_body' : undeclared identifier
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(272): error C2227: left of '->DrawTextA' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(277): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\amit\documents\visual studio 2010\projects\d3d\d3d\main.cpp(289): warning C4018: '<=' : signed/unsigned mismatch
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Wow you can't just copy/paste it.
This Piece of code will help you to create your own menu, but you don't really understand what's this is all about..do you?
Please Pm me with some detailed information about what you are trying to do, and i will help you to build your menu step by step.

Kind Regards,

Cruciimperio
just a little question:
if i build a d3d menu
can i use it for all of the games?
or i need to build for a Specific game
With some little changes (Most of the time) you can use it with every game you want to.
there is a tutorial for begginers because i dont understand it with code
but i need a good tutorial that i can learn from
edit:
i have learned the basic of directx
i have put the basic code in dll and i inject it to a directx window and its dosent work
Code:
#include <stdio.h>
#include <tchar.h>
#include <D3DX9.h>
#include <windows.h>
#include <d3d9.h>


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


LPDIRECT3D9 d3d;    
LPDIRECT3DDEVICE9 d3ddev;    


void initD3D(HWND hWnd);   
void render_frame(void);   
void cleanD3D(void);    


LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 
void initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);    

    D3DPRESENT_PARAMETERS d3dpp;   

    ZeroMemory(&d3dpp, sizeof(d3dpp));    
    d3dpp.Windowed = TRUE;   
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;   
    d3dpp.hDeviceWindow = hWnd;    

   
    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);
}

void render_frame(void)
{

    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);

    d3ddev->BeginScene();  



    d3ddev->EndScene();  

    d3ddev->Present(NULL, NULL, NULL, NULL);  
}

void cleanD3D(void)
{
    d3ddev->Release();    
    d3d->Release();   
}
Hmm alright.. If you cant find a good tut i can teach you some basic structures of C++ if you want me to.
i have find a good tut
but i try the code and its dosent work
nothing happend
here is the code again:
Code:
#include <stdio.h>
#include <tchar.h>
#include <D3DX9.h>
#include <windows.h>
#include <d3d9.h>


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


LPDIRECT3D9 d3d;    
LPDIRECT3DDEVICE9 d3ddev;    


void initD3D(HWND hWnd);   
void render_frame(void);   
void cleanD3D(void);    


LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 
void initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);    

    D3DPRESENT_PARAMETERS d3dpp;   

    ZeroMemory(&d3dpp, sizeof(d3dpp));    
    d3dpp.Windowed = TRUE;   
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;   
    d3dpp.hDeviceWindow = hWnd;    

   
    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);
}

void render_frame(void)
{

    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);

    d3ddev->BeginScene();  



    d3ddev->EndScene();  

    d3ddev->Present(NULL, NULL, NULL, NULL);  
}

void cleanD3D(void)
{
    d3ddev->Release();    
    d3d->Release();   
}
edit:
if u have a realy easy tutorial for begginers please send me(for d3d)
edit num 2:


directx is very hard for me and i cant remember all of this
there is a real man that remember all of this shit, i am just cant
maybe i will start in opengl? or sdl?
can some one give me a tutorial for beginers and give me some advices

can some one help me??
just tell me : there is a people that remember all of this
NeHe Productions: Creating an OpenGL Window (Win32)
and its only for make the window
directx is very hard for me its a lot of lines to remember
i wanna something for start more easy but a good engine not a shit (3d)
so... SDL or opengl
If you want to include dll files you should use System InterOp. and then [DllImport ""] sadly this work for some system files only. The other way to implement Direct X elements is by using the MICROSOFT.DIRECTX and MICROSOFT.DIRECTX.DIRECT3D references. the 3rd way is by creating a simple dll that alters Hex values when imported as the one in C++.

All i do wan't to say is that the 3rd way is already fixed for most games unless you know how to pack it up well enough (older hacks used to be made in C#6.0 as well).

Ok basic syntax of C# of the above file:
Namespace std; <- this one should be valid as it is a standart that even microcontrollers can support.
#include is not available in C# unless you encapsulate it with EXTERN "C" or EXTERN "C_PLUS_PLUS"(or "C++" i can't recall it from my memory anymore).


Code:
LPDIRECT3D9 d3d;    
LPDIRECT3DDEVICE9 d3ddev;    
D3DPRESENT_PARAMETERS d3dpp;
will be replaced by

d3d would be the main file where you have included the references.
Code:
Device d3ddev;
d3ddev = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, d3dpp);
..
OR
..
Device d3ddev = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, d3dpp);
Code:
PresentParameters d3dpp= new PresentParameters();
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us