Solved Direct3D Detected after 30sec by Xigncode

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

steb

Jr.Coder
Full Member
Nobleman
Aug 16, 2016
63
383
1
So I got this d3d hook to work however it gets detected by xingcode3 after 30 sec :(

Credits:
RedAppleCoder | Help with Sprites
JoshRose | Hook

Code:
C++:
LPDIRECT3DDEVICE9 npDevice; //pDevice is stored here so we can hook through the VTable
							//---------------------------------------------------------------------------------------------------------------------------------
LPD3DXFONT      g_pFont = NULL; //D3D Font
LPD3DXLINE      g_pLine = NULL; //D3D Line
D3DVIEWPORT9    g_ViewPort; //ViewPort
							//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DVERTEXBUFFER9 Stream_Data;
UINT Offset = 0;
UINT Stride = 0;
//---------------------------------------------------------------------------------------------------------------------------------
ofstream myfile; //Used for logging to a text file
				 //---------------------------------------------------------------------------------------------------------------------------------
typedef HRESULT(WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
tEndScene oEndScene = NULL;

typedef HRESULT(WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
tDrawIndexedPrimitive oDrawIndexedPrimitive = NULL;

typedef HRESULT(WINAPI* tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
tReset oReset = NULL;
//---------------------------------------------------------------------------------------------------------------------------------
PBYTE HookVTableFunction(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;
}
//-----------------------------------------------------------------------------------------------------------------------------------

void CreateSprite(LPDIRECT3DDEVICE9 pDevice)
{
	{
		D3DXCreateTextureFromFileInMemoryEx(pDevice, &myFile, sizeof(myFile), SpriteSize_X, SpriteSize_Y, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &SpriteTexture);
		D3DXCreateSprite(pDevice, &Sprite);
	}
}

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

void DrawSprite(LPDIRECT3DDEVICE9 pDevice) {
	D3DXVECTOR3 POS;
	POS.x = 5;
	POS.y = 5;
	POS.z = 0;
	if (SpriteTexture == NULL) { CreateSprite(pDevice); }
	Sprite->Begin(D3DXSPRITE_ALPHABLEND);
	Sprite->Draw(SpriteTexture, NULL, NULL, &POS, 0xFFFFFFFF);
	Sprite->End();
}

HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
	float CenterX = 0.0f;
	float CenterY = 0.0f;

	while (!npDevice) {
		npDevice = pDevice;                       //Here we store pDevice so we can re-hook with a VTable hook later.
	}

	if (g_pFont == NULL) D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &g_pFont); //Create fonts

	if (g_pLine == NULL) D3DXCreateLine(pDevice, &g_pLine); //Create lines

	CenterX = (float)g_ViewPort.Width / 2;
	CenterY = (float)g_ViewPort.Height / 2;

	if (cross) {
		FillRGB(CenterX - 20, CenterY, 40, 1, oPurple, pDevice);//Purple
		FillRGB(CenterX, CenterY - 20, 1, 40, oPurple, pDevice);

		FillRGB(CenterX - 17, CenterY, 34, 1, oBlue, pDevice);//Blue
		FillRGB(CenterX, CenterY - 17, 1, 34, oBlue, pDevice);

		FillRGB(CenterX - 14, CenterY, 28, 1, oCyan, pDevice);//Cyan
		FillRGB(CenterX, CenterY - 14, 1, 28, oCyan, pDevice);

		FillRGB(CenterX - 11, CenterY, 22, 1, oGreen, pDevice);//Green
		FillRGB(CenterX, CenterY - 11, 1, 22, oGreen, pDevice);

		FillRGB(CenterX - 9, CenterY, 18, 1, oYellow, pDevice);//Yellow
		FillRGB(CenterX, CenterY - 9, 1, 18, oYellow, pDevice);

		FillRGB(CenterX - 6, CenterY, 12, 1, oOrange, pDevice);//Orange
		FillRGB(CenterX, CenterY - 6, 1, 12, oOrange, pDevice);

		FillRGB(CenterX - 3, CenterY, 6, 1, oRed, pDevice);//Red
		FillRGB(CenterX, CenterY - 3, 1, 6, oRed, pDevice);
	}

	if (logo)
	{
		DrawSprite(pDevice);
	}

	pDevice->GetViewport(&g_ViewPort);
	return oEndScene(pDevice);
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
{
	if (pDevice->GetStreamSource(0, &Stream_Data, &Offset, &Stride) == D3D_OK)
		Stream_Data->Release();

	return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);

}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{  
	if (g_pFont)
		g_pFont->OnLostDevice();

	if (g_pLine)
		g_pLine->OnLostDevice();

	HRESULT iReturnValue = oReset(pDevice, pPresentationParameters);

	if (iReturnValue == D3D_OK) {

		if (g_pFont)
			g_pFont->OnResetDevice();

		if (g_pLine)
			g_pLine->OnResetDevice();
	}

	return iReturnValue;

}
//-----------------------------------------------------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hwnd, uMsg, wParam, lParam); }
void DX_Init(DWORD* table)
{
	WNDCLASSEX wc = { sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,"DX",NULL };
	RegisterClassEx(&wc);
	HWND hWnd = CreateWindow("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[ES] = pVTable[42];                    //EndScene address
	table[DIP] = pVTable[82];                    //DrawIndexedPrimitive address
	table[RES] = pVTable[16];                    //Reset address

	DestroyWindow(hWnd);
}
//------------------------------------------------------------------------------------------------------------------------------------
DWORD WINAPI VirtualMethodTableRepatchingLoopToCounterExtensionRepatching(LPVOID  Param)
{
	while (1) {
		Sleep(100);
		HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkDrawIndexedPrimitive, 82); //Hook DrawIndexedPrimitive
		HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkEndScene, 42); //Hook EndScene
		HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkReset, 16); //Hook Reset

	}

	return 1;
}
//------------------------------------------------------------------------------------------------------------------------------------
bool hooked = false;
DWORD WINAPI LoopFunction(LPVOID lpParam)
{
	while (1) {
		if (hooked == false) {
			DWORD VTable[3] = { 0 };

			while (GetModuleHandle("d3d9.dll") == NULL) {
				Sleep(250);
			}

			DX_Init(VTable);
			HOOK(EndScene, VTable[ES]);            //Hook EndScene as a device discovery hook

			while (!npDevice) {
				Sleep(50); //Sleep until npDevice is not equal to NULL
			}
			UNHOOK(EndScene, VTable[ES]);         //Unhook as soon as we have a valid pointer to pDevice

			*(PDWORD)&oDrawIndexedPrimitive = VTable[DIP];
			*(PDWORD)&oEndScene = VTable[ES];
			*(PDWORD)&oReset = VTable[RES];

			CreateThread(NULL, 0, &VirtualMethodTableRepatchingLoopToCounterExtensionRepatching, NULL, 0, NULL); //Create hooking thread

			hooked = true;

			Sleep(200);

		}
	}
	return 0;
}
//------------------------------------------------------------------------------------------------------------------------------------
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
	DisableThreadLibraryCalls(hModule);
	if (dwReason == DLL_PROCESS_ATTACH) {
		MessageBox(0, "StebX", "StebX", MB_OK);
		CreateThread(0, 0, LoopFunction, 0, 0, 0);
	}
	return TRUE;
}
//------------------------------------------------------------------------------------------------------------------------------------
 

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,745
40,528
316
write 0x3C to AVA.exe + 0x1D340

BOOM no ShitCode3

you need to write the value to game as soon as it starts up.
Irrc it's an __stdcall meaning that you should clean up the stack yourself. Do ret 4 (C2 04 00) instead of just ret (C3).

Lol you just told him to patch a byte... what method? At least drop a signature or something sheesh lol
Basically this: Bypass XIGNCODE3 AVA - unkn0wncheats Game Hacking Wiki

It's a shitty method though. Any game with a hearbeat will disconnect after a few seconds/minutes.
For D3D hooking with Xigncode it's easier to hook where the game calls EndScene or w/e you want to hook than hooking in the d3d9.dll.

Guide - How to bypass XignCode Anticheat?
 
Last edited by a moderator:

cNoEvil

Coder
Full Member
Nobleman
Jun 6, 2016
159
1,218
1
write 0x3C to AVA.exe + 0x1D340

BOOM no ShitCode3

you need to write the value to game as soon as it starts up.
 
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