Solved Strange Problem

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Superseb

Newbie
Full Member
Jan 5, 2015
20
329
0
Hey guys, I seem to have encountered a strange error when making an internal overlay for Garry's Mod.

Here's how it looks when I inject it into a D3D9 Test Environment.


So it works fine in the Test Window but this is what happens when I inject it into Gmod,


I've tested it in Windowed and Full-screen, neither work, any advice?
 

Superseb

Newbie
Full Member
Jan 5, 2015
20
329
0
Pasting Source Code here,
Base.cpp
C++:
#pragma once
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <d3dx9core.h>
#include <math.h>
#include <DbgHelp.h>
#include <Mmsystem.h>
#include <ShellAPI.h>
#include <fstream>
#include <iostream>
#include <iosfwd>
#include "detours.h"
#include <vector>
#include <algorithm>

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "WinMM.Lib")
#pragma comment(lib, "detours.Lib")

using namespace std;


#include "Sprite.h"
#include "D3DColor.h"
#include "Tools.h"
#include "Variables.h"
#include "DrawPrimitives.h"
#include "OtherDraw.h"
#include "Menu.h"


cFun Fun;

#pragma region D3D9_Interface_Hook

bool hooked = false;
#define HOOK(func,addy) p##func = (o##func)DetourFunction((PBYTE)addy,(PBYTE)my##func) 
#define UNHOOK(func,addy) p##func = (o##func)DetourFunction((PBYTE)addy,(PBYTE)p##func) 

typedef HRESULT(WINAPI* oEndScene)(LPDIRECT3DDEVICE9 pDevice);
oEndScene pEndScene = NULL;
HRESULT APIENTRY myEndScene(LPDIRECT3DDEVICE9 pDevice)
{
	while (!pDevice) { pDevice = pDevice; }

	if (!Create)
	{
		D3DXCreateLine(pDevice, &pLine);
		Font("System", 15, FW_MEDIUM, pDevice);
		Create = true;
	}
	if (!pFont || !pLine)
	{
		pFont->OnLostDevice();
		pLine->OnLostDevice();
	}
	else
	{
		if (GetAsyncKeyState(VK_INSERT) & 1) Show = (!Show);
		if (Show) WF_XVTT(pDevice);

		pFont->OnLostDevice();
		pFont->OnResetDevice();
		pLine->OnLostDevice();
		pLine->OnResetDevice();
	}
	return pEndScene(pDevice);
}

LPDIRECT3DDEVICE9 nm_pD3Ddev;
PBYTE HookVTable(PDWORD* dwVTable, PBYTE dwHook, INT Index)
{
	DWORD dwOld = 0;
	VirtualProtect((void*)((*dwVTable) + (Index * 4)), 4, PAGE_EXECUTE_READWRITE, &dwOld);
	PBYTE pOrig = ((PBYTE)(*dwVTable)[Index]);
	(*dwVTable)[Index] = (DWORD)dwHook;
	VirtualProtect((void*)((*dwVTable) + (Index * 4)), 4, dwOld, &dwOld);

	return pOrig;
}
LRESULT CALLBACK MsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ return DefWindowProc(hwnd, uMsg, wParam, lParam); }
void DX_Init(DWORD* table)
{
	WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "DX", NULL };
	RegisterClassExA(&wc);
	HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL);
	LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	LPDIRECT3DDEVICE9 pd3dDevice;
	pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice);

	DWORD* pVTable = (DWORD*)pd3dDevice;
	pVTable = (DWORD*)pVTable[0];

	table[0] = pVTable[42];

	DestroyWindow(hWnd);
}

DWORD WINAPI VMT_Patching(LPVOID  Param)
{
	while (1)
	{
		Sleep(100);

		HookVTable((PDWORD*)nm_pD3Ddev, (PBYTE)myEndScene, 42);
	}
	return 1;
}


void LoopFunction()
{
	if (hooked == false)
	{
		DWORD VTable[3] = { 0 };
		while (GetModuleHandleA("d3d9.dll") == NULL)
		{
			Sleep(250);
		}
		DX_Init(VTable);
		HOOK(EndScene, VTable[0]);
		while (!nm_pD3Ddev)
		{
			Sleep(50);
		}
		UNHOOK(EndScene, VTable[0]);
		*(PDWORD)&pEndScene = VTable[0];
		CreateThread(NULL, 0, &VMT_Patching, NULL, 0, NULL);
		hooked = true;
	}
}

bool bExitThread;
void RenderHook()
{
	StartRoutine(LoopFunction);
	ExitThread(bExitThread);
}
#pragma endregion




BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, LPVOID)
{

	if (dwReason == DLL_PROCESS_ATTACH)
	{
		
		StartRoutine(RenderHook);
	
		

	}
	return TRUE;
}
Menu.h
C++:
int S;
int Ar, Ag, Ab;
bool SA;
D3DCOLOR TColOff = DARK18; //Öâåò òåêñòà    [Âûêë]
D3DCOLOR TColIsIn = DARK18; //Öâåò òåêñòà    [IsInBox]
D3DCOLOR TColOn = DARK2; //Öâåò òåêñòà    [Âêë]
D3DCOLOR EColOff = DARK10; //Öâåò åëåìåíòîâ  [Âûêë]
D3DCOLOR EColIsIn = DARK12;//Öâåò åëåìåíòîâ  [IsInBox]
void  WF_XVTT(LPDIRECT3DDEVICE9 pDevice)
{
	lm = GetAsyncKeyState(VK_LBUTTON) & 1;
	flm = GetAsyncKeyState(VK_LBUTTON);


	DrawMenu(AS.GC.x, AS.GC.y, 400, 180, "Garry's Mod Cheat by Superseb", pDevice);
//	Pircture(45, 40,pDevice);
	FolderButton(NOC.Title1, 250, 80, 3, Choose, 120, pDevice);
	if (Choose == 1)
	{
		AS.AIMC.bpos.y2 = 110 + 21 * 3;
		AS.GC.bpos.s1 = 130 + 21 * 3, AS.GC.bpos.s2 = AS.GC.bpos.s1 + 21, AS.GC.bpos.s3 = AS.GC.bpos.s2 + 22;
		AddFolder_Button(250, 100, "Aimbot", 120,Aim, pDevice); 
		AddFolder_Button(250, 121, "Misc", 120,Player, pDevice);
		AddFolder_Button(250, 142, "Close All",120, Nope, pDevice);
	}
	else AS.AIMC.bpos.y2 = 110, AS.GC.bpos.s1 = 130, AS.GC.bpos.s2 = AS.GC.bpos.s1 + 20, AS.GC.bpos.s3 = AS.GC.bpos.s2 + 20;
	if (Aim == 1)
	{
		DrawMenu(AS.AIMC.x, AS.AIMC.y, 400, 180, "Aimbot", pDevice);
	}
	FolderButton(NOC.Title2, 250, AS.AIMC.bpos.y2, 3, Choose2, 120, pDevice);
	if (Player == 1)
	{
		DrawMenu(AS.ESPC.x, AS.ESPC.y, 140, 250, "Misc", pDevice);
		Check(15, 330, "Accuracy", Fun.Aim, pDevice);
		Check(15, 350, "No Reload", Fun.reload, pDevice);
		Check(15, 370, "ESP Player", Fun.EspGM, pDevice);
		Check(15, 390, "No Anti-Cheat", Fun.reload, pDevice);
		Check(15, 410, "Anti-CAC", Fun.reload, pDevice);
		Check(15, 430, "No Body Shots", Fun.reload, pDevice);
		
		


	}
	if (Choose2 == 1)
	{
		AddFolder_Button(250, AS.GC.bpos.s1, "Save Func.", 120, sf, pDevice);
		AddFolder_Button(250, AS.GC.bpos.s2, "Load Func.", 120, lf, pDevice);
		AddFolder_Button(250, AS.GC.bpos.s3, "Go to forum", 120, forum, pDevice);
	}



}

Can't paste the other ones because of max characters.
 
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.

Similar threads

Community Mods