Solved How to Replace GDI with DirectX in Fleep's tutorials?

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Heisa

Jr.Coder
Full Member
Nobleman
Jul 3, 2013
77
703
3
Hi. How do I implement fleep's ESP source with this one ?


.CPP

C++:
#include "hDirectX.h"

IDirect3D9Ex* p_Object = 0;
IDirect3DDevice9Ex* p_Device = 0;
D3DPRESENT_PARAMETERS p_Params;

ID3DXLine* p_Line;
ID3DXFont* pFontSmall = 0;

int DirectXInit(HWND hWnd)
{
	if(FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &p_Object)))
		exit(1);

	ZeroMemory(&p_Params, sizeof(p_Params));    
    p_Params.Windowed = TRUE;   
    p_Params.SwapEffect = D3DSWAPEFFECT_DISCARD;    
    p_Params.hDeviceWindow = hWnd;    
	p_Params.MultiSampleQuality   = D3DMULTISAMPLE_NONE;
    p_Params.BackBufferFormat = D3DFMT_A8R8G8B8 ;     
    p_Params.BackBufferWidth = Width;    
    p_Params.BackBufferHeight = Height;    
    p_Params.EnableAutoDepthStencil = TRUE;
    p_Params.AutoDepthStencilFormat = D3DFMT_D16;

	if(FAILED(p_Object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &p_Params, 0, &p_Device)))
		exit(1);

	if(!p_Line)
		D3DXCreateLine(p_Device, &p_Line);
		//p_Line->SetAntialias(1); *removed cuz crosshair was blurred*

	D3DXCreateFont(p_Device, 18, 0, 0, 0, false, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Calibri", &pFontSmall);

	return 0;
}

int Render()
{
	p_Device->Clear(0, 0, D3DCLEAR_TARGET, 0, 1.0f, 0);
	p_Device->BeginScene();

	if(tWnd == GetForegroundWindow())
	{
		//text with shadow
		DrawShadowString("unkn0wncheats.me - Debug Overlay - by Grab", 5, 0, 240, 240, 250, pFontSmall);
		
		//text without shadow
		DrawString("unkn0wncheats.me - Debug Overlay - by Grab", 5, 15, 240, 240, 250, pFontSmall);

		//colored rects
		FillRGB(30, 40, 10, 10, 255, 0, 0, 155);
		FillRGB(30, 60, 10, 10, 0, 255, 0, 155);
		FillRGB(30, 80, 10, 10, 0, 0, 255, 155);

		//crosshair
		FillRGB(Width / 2 - 22, Height / 2, 44, 1, 240, 240, 250, 255); 
		FillRGB(Width / 2, Height / 2 - 22, 1, 44, 240, 240, 250, 255);
	}

	p_Device->EndScene();
	p_Device->PresentEx(0, 0, 0, 0, 0);
	return 0;
}


C++:
#include "hDrawings.h"

int DrawString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont)
{
	RECT ShadowPos;
	ShadowPos.left = x + 1;
	ShadowPos.top = y + 1;
	RECT FontPos;
	FontPos.left = x;
	FontPos.top = y;
	ifont->DrawTextA(0, String, strlen(String), &ShadowPos, DT_NOCLIP, D3DCOLOR_ARGB(255, r / 3, g / 3, b / 3));
	ifont->DrawTextA(0, String, strlen(String), &FontPos, DT_NOCLIP, D3DCOLOR_ARGB(255, r, g, b));
	return 0;
}
int DrawShadowString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont)
{
	RECT Font;
	Font.left = x;
	Font.top = y;
	RECT Fonts;
	Fonts.left = x+1;
	Fonts.top = y;
	RECT Fonts1;
	Fonts1.left = x-1;
	Fonts1.top = y;
	RECT Fonts2;
	Fonts2.left = x;
	Fonts2.top = y+1;
	RECT Fonts3;
	Fonts3.left = x;
	Fonts3.top = y-1;
	ifont->DrawTextA(0, String, strlen(String), &Fonts3, DT_NOCLIP , D3DCOLOR_ARGB(255, 1, 1, 1));
	ifont->DrawTextA(0, String, strlen(String), &Fonts2, DT_NOCLIP, D3DCOLOR_ARGB(255, 1, 1, 1));
	ifont->DrawTextA(0, String, strlen(String), &Fonts1, DT_NOCLIP, D3DCOLOR_ARGB(255, 1, 1, 1));
	ifont->DrawTextA(0, String, strlen(String), &Fonts, DT_NOCLIP, D3DCOLOR_ARGB(255, 1, 1, 1));
	ifont->DrawTextA(0, String, strlen(String), &Font, DT_NOCLIP, D3DCOLOR_ARGB(255, r, g, b));
	return 0;
}

void GradientFunc(int x, int y, int w, int h,int r, int g, int b, int a)
{
	int iColorr,iColorg,iColorb;
	for(int i = 1; i < h; i++)
	{
		iColorr = (int)((float)i/h*r);
		iColorg = (int)((float)i/h*g);
		iColorb = (int)((float)i/h*b);
		FillRGB(x ,y+ i,w,1,r-iColorr,g-iColorg,b-iColorb,a);
	}
}
void DrawLine(float x, float y, float xx, float yy, int r, int g, int b, int a)
{
	D3DXVECTOR2 dLine[2];

	p_Line->SetWidth( 1 );

	dLine[0].x = x;
	dLine[0].y = y;

	dLine[1].x = xx;
	dLine[1].y = yy;

	p_Line->Draw( dLine, 2, D3DCOLOR_ARGB(a, r , g, b));

} 
void FillRGB(float x, float y, float w, float h, int r, int g, int b, int a) 
{ 
    D3DXVECTOR2 vLine[2]; 

    p_Line->SetWidth( w ); 
     
    vLine[0].x = x + w/2; 
    vLine[0].y = y; 
    vLine[1].x = x + w/2; 
    vLine[1].y = y + h; 

    p_Line->Begin( ); 
    p_Line->Draw( vLine, 2, D3DCOLOR_RGBA( r, g, b, a ) ); 
    p_Line->End( ); 
} 
void DrawBox(float x, float y, float width, float height, float px, int r, int g, int b, int a) 
{ 
	D3DXVECTOR2 points[5];  
	points[0] = D3DXVECTOR2(x,		y);  
	points[1] = D3DXVECTOR2(x+width,	y);  
	points[2] = D3DXVECTOR2(x+width,	y+height);  
	points[3] = D3DXVECTOR2(x,		y+height);  
	points[4] = D3DXVECTOR2(x,		y);  
	p_Line->SetWidth(1);
	p_Line->Draw(points, 5, D3DCOLOR_RGBA(r, g, b, a));
} 
void DrawGUIBox(float x, float y, float w, float h, int r, int g, int b, int a, int rr, int gg, int bb, int aa) 
{ 
    DrawBox(x,y,w,h, 1,r ,g ,b ,a);    
    FillRGB(x,y,w,h,rr,gg,bb,a);   
} 
void DrawHealthBar(float x, float y, float w, float h, int r, int g) 
{     
    FillRGB(x,y,w,h,r,g,0,255);      
} 
void DrawHealthBarBack(float x, float y, float w, float h) 
{     
    FillRGB(x,y,w,h,0,0,0,255);      
} 
void DrawCenterLine(float x, float y, int width, int r, int g, int b)
{
	D3DXVECTOR2 dPoints[2];
	dPoints[0] = D3DXVECTOR2(x, y);
	dPoints[1] = D3DXVECTOR2(Width / 2, Height);
	p_Line->SetWidth(width);
	p_Line->Draw(dPoints, 2, D3DCOLOR_RGBA(r, g, b, 255));
}

C++:
#include "hMain.h"

int Width = 800;
int Height = 600;

const MARGINS Margin = { 0, 0, Width, Height };

char lWindowName[256] = "Basic Overlay - v0.1 - Credits: Grab";
HWND hWnd;

char tWindowName[256] = "Counter-Strike Source"; /* tWindowName ? Target Window Name */
HWND tWnd;
RECT tSize;

MSG Message;

LRESULT CALLBACK WinProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message)
	{	
	case WM_PAINT:
		Render();
		break;

	case WM_CREATE:
		DwmExtendFrameIntoClientArea(hWnd, &Margin);
		break;

	case WM_DESTROY:
		PostQuitMessage(1);
		return 0;

	default:
		return DefWindowProc(hWnd, Message, wParam, lParam);
		break;
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hSecInstance, LPSTR nCmdLine, INT nCmdShow)
{

	CreateThread(0, 0, (LPTHREAD_START_ROUTINE)SetWindowToTarget, 0, 0, 0);

	WNDCLASSEX wClass;
	wClass.cbClsExtra = NULL;
	wClass.cbSize = sizeof(WNDCLASSEX);
	wClass.cbWndExtra = NULL;
	wClass.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(0, 0, 0));
	wClass.hCursor = LoadCursor(0, IDC_ARROW);
	wClass.hIcon = LoadIcon(0, IDI_APPLICATION);
	wClass.hIconSm = LoadIcon(0, IDI_APPLICATION);
	wClass.hInstance = hInstance;
	wClass.lpfnWndProc = WinProc;
	wClass.lpszClassName = lWindowName;
	wClass.lpszMenuName = lWindowName;
	wClass.style = CS_VREDRAW | CS_HREDRAW;

	if(!RegisterClassEx(&wClass))
		exit(1);

	tWnd = FindWindow(0, tWindowName);
	if (tWnd)
	{
		GetWindowRect(tWnd, &tSize);
		Width = tSize.right - tSize.left;
		Height = tSize.bottom - tSize.top;
		hWnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_LAYERED, lWindowName, lWindowName,  WS_POPUP, 1, 1, Width, Height, 0, 0, 0, 0);
		SetLayeredWindowAttributes(hWnd, 0, 1.0f, LWA_ALPHA);
		SetLayeredWindowAttributes(hWnd, 0, RGB(0, 0, 0), LWA_COLORKEY);
		ShowWindow( hWnd, SW_SHOW);
	}

	DirectXInit(hWnd);

	for (;;)
	{
		if(PeekMessage(&Message, hWnd, 0, 0, PM_REMOVE))
		{
			DispatchMessage(&Message);
			TranslateMessage(&Message);
		}
		Sleep(1);
	}
	return 0;
}

void SetWindowToTarget()
{
	while(true)
	{
		tWnd = FindWindow(0, tWindowName);
		if (tWnd)
		{
			GetWindowRect(tWnd, &tSize);
			Width = tSize.right - tSize.left;
			Height = tSize.bottom - tSize.top;
			DWORD dwStyle = GetWindowLong(tWnd, GWL_STYLE);
			if(dwStyle & WS_BORDER)
			{
				tSize.top += 23;
				Height -= 23;
			}
			MoveWindow(hWnd, tSize.left, tSize.top, Width, Height, true);
		}
		else
		{
			char ErrorMsg[125];
			sprintf(ErrorMsg, "Make sure %s is running!", tWindowName);
			MessageBox(0, ErrorMsg, "Error - Cannot find the game!", MB_OK | MB_ICONERROR);
			exit(1);
		}
		Sleep(100);
	}
}

HEADERS

C++:
#ifndef HDIRECTX_H
#define HDIRECTX_H

#include "hMain.h"
#include "hDrawings.h"

#include <Windows.h>
#include <iostream>

#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")

extern IDirect3D9Ex* p_Object;
extern IDirect3DDevice9Ex* p_Device;
extern D3DPRESENT_PARAMETERS p_Params;
extern ID3DXLine* p_Line;
extern ID3DXFont* pFontSmall;

int DirectXInit(HWND hWnd);
int Render();

#endif

C++:
#ifndef HDRAWFUNC_H
#define HDRAWFUNC_H

#include "hDirectX.h"

#pragma warning( disable : 4244 ) //remove the incoming warns
#pragma warning( disable : 4996 ) //remove the incoming warns

#include <d3dx9.h>
#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

void GradientFunc(int x, int y, int w, int h,int r, int g, int b, int a);
void DrawCenterLine(float x, float y, int r, int g, int b, int a);
void DrawLine(float x, float y, float xx, float yy, int r, int g, int b, int a);
void FillRGB(float x, float y, float w, float h, int r, int g, int b, int a); 
void DrawBox(float x, float y, float width, float height, float px, int r, int g, int b, int a); 
void DrawGUIBox(float x, float y, float w, float h, int r, int g, int b, int a, int rr, int gg, int bb, int aa); 
void DrawHealthBar(float x, float y, float w, float h, int r, int g);
void DrawHealthBarBack(float x, float y, float w, float h); 

int DrawString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont);
int DrawShadowString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont);

#endif


C++:
#ifndef HMAIN_H
#define HMAIN_H

#include "hDirectX.h"

#include <Windows.h>
#include <iostream>

#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")

extern int Width;
extern int Height;
extern char lWindowName[256];
extern HWND hWnd;
extern char tWindowName[256];
extern HWND tWnd;
extern RECT tSize;
extern MSG Message;
extern bool Debug_Border;

LRESULT CALLBACK WinProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hSecInstance, LPSTR nCmdLine, INT nCmdShow);
void SetWindowToTarget();

#endif

Credits: unkn0wncheats.me - Debug Overlay - by Grab
 

sl1ne

Newbie
Full Member
Apr 5, 2014
13
413
1
What I would do:

Watch Fleeps DirectX Menu Tutorial. Figure out whats needed for DirectX. Replace GDI drawing with D3D:
C++:
void DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
{
	D3DRECT BarRect = { x, y, x + w, y + h }; 	
	dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}
void DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR color, IDirect3DDevice9* dev)
{	
	DrawFilledRect(x, y, w, thickness, color,dev);	
	DrawFilledRect( x, y, thickness, h, color,dev);	
	DrawFilledRect((x + w), y, thickness, h, color,dev);	
	DrawFilledRect(x, y + h, w+thickness, thickness, color,dev);
}
void DrawLine(LPDIRECT3DDEVICE9 pDevice, float x1, float y1, float x2, float y2, DWORD color)
{
	ID3DXLine *m_Line;
	D3DXCreateLine(pDevice, &m_Line);
	D3DXVECTOR2 line[] = { D3DXVECTOR2(x1, y1), D3DXVECTOR2(x2, y2) };
	m_Line->Begin();
	m_Line->Draw(line, 2, color);
	m_Line->End();
	m_Line->Release();
}
void DrawString(char pString[], int x, int y, D3DCOLOR col, ID3DXFont *font)
{
	RECT FontRect = { x, y, x+500, y+30 };
	font->DrawTextA( NULL, pString, -1, &FontRect, DT_LEFT | DT_WORDBREAK, col);//pString
}
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
Maybe if you'd actually learn programming you could figure it out?
 

Heisa

Jr.Coder
Full Member
Nobleman
Jul 3, 2013
77
703
3
Maybe if you'd actually learn programming you could figure it out?
What do you mean learn how to code? I did it, I just had one error and thought someone smart could help me quicker.
Thanks Kaz. And thanks c5, for being an ass.

#CloseRequest
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
What do you mean learn how to code? I did it, I just had one error and thought someone smart could help me quicker.
Thanks Kaz. And thanks c5, for being an ass.

#CloseRequest
You don't show any errors whatsoever.

Hi. How do I implement fleep's ESP source with this one ?
You simply copied a bunch of code and expect us to work it out for you.

Happy to help as always
 

Heisa

Jr.Coder
Full Member
Nobleman
Jul 3, 2013
77
703
3
You don't show any errors whatsoever.



You simply copied a bunch of code and expect us to work it out for you.

Happy to help as always
Work it out for me? No. I simply wanted to see how someone else would do it.
 

Heisa

Jr.Coder
Full Member
Nobleman
Jul 3, 2013
77
703
3
What I would do:

Watch Fleeps DirectX Menu Tutorial. Figure out whats needed for DirectX. Replace GDI drawing with D3D:
C++:
void DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
{
	D3DRECT BarRect = { x, y, x + w, y + h }; 	
	dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}
void DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR color, IDirect3DDevice9* dev)
{	
	DrawFilledRect(x, y, w, thickness, color,dev);	
	DrawFilledRect( x, y, thickness, h, color,dev);	
	DrawFilledRect((x + w), y, thickness, h, color,dev);	
	DrawFilledRect(x, y + h, w+thickness, thickness, color,dev);
}
void DrawLine(LPDIRECT3DDEVICE9 pDevice, float x1, float y1, float x2, float y2, DWORD color)
{
	ID3DXLine *m_Line;
	D3DXCreateLine(pDevice, &m_Line);
	D3DXVECTOR2 line[] = { D3DXVECTOR2(x1, y1), D3DXVECTOR2(x2, y2) };
	m_Line->Begin();
	m_Line->Draw(line, 2, color);
	m_Line->End();
	m_Line->Release();
}
void DrawString(char pString[], int x, int y, D3DCOLOR col, ID3DXFont *font)
{
	RECT FontRect = { x, y, x+500, y+30 };
	font->DrawTextA( NULL, pString, -1, &FontRect, DT_LEFT | DT_WORDBREAK, col);//pString
}
 

TastyHorror

Coder
Dank Tier Donator
Nobleman
Oct 11, 2012
179
2,268
8
I know my tutorials a little ... meh, and needs a lot of work (keep in mind that I have not coded it and all credits go to grab or w.e. u spell it). But give it a shot.

I would suggest you look at the code first, like really look at it, and then watch the video.

https://guidedhacking.com/showthread.php?4056-How-to-make-a-DirectX-Menu-C

Also there is a screen/res problem which isn't really noticeable at first, but I'll let you figure it out.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods