Need Help With Chams DLL Source Code

Posts 1–11 of 11 · Page 1 of 1
Need Help With Chams DLL Source Code
I have no reload/infinite ammo and nametags working fine I just need some help finishing the chams. I've attempted to learn Drawindexedprimitive to complete the source listed at the top of this thread but I can't figure it out.

Before you flame me, I do realize I'm an extreme novice to this type of stuff so please work with me. Thanks.

Heres a pic:

http://img714.imageshack.us/i/chamsissue2.png/

This is what I have so far:

Code:
// Hax.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include <wchar.h>
#include <windows.h>
#include <d3d9.h>
#include <time.h>
#include <stdlib.h>
#include <fstream>
#include <vector>    
#include <stdio.h> 
#include <time.h>
#include <tchar.h>
#include <iostream>
#pragma warning(disable:4996)
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

#define D3DHOOK_TEXTURES
#define ThreadMake(x) CreateThread(NULL,0, (LPTHREAD_START_ROUTINE)&x,NULL,0,NULL); 
#define ThreadMakeParam(x, param) CreateThread(NULL,0, (LPTHREAD_START_ROUTINE)&x,param,0,NULL);
#define CRYSIS2CHAMS ((m_Stride == 16 && NumVertices ==  8391 && primCount == 5677) || (m_Stride == 16 &&  NumVertices == 8391 && primCount == 5677) || (m_Stride == 12  && NumVertices == 8 && primCount == 10) || (m_Stride ==  12 && NumVertices == 30 && primCount == 14) || (m_Stride  == 16 && NumVertices == 2000 && primCount == 2549) ||  (m_Stride == 16 && NumVertices == 93 && primCount == 80)  || (m_Stride == 16 && NumVertices == 2406 && primCount  == 2365) || (m_Stride == 16 && NumVertices == 2259 &&  primCount == 1846) || (m_Stride == 16 && NumVertices == 190  && primCount == 172) || (m_Stride == 16 && NumVertices  == 621 && primCount == 712) || (m_Stride == 16 &&  NumVertices == 3107 && primCount == 3372) || (m_Stride == 16  && NumVertices == 1179 && primCount == 752) || (m_Stride  == 16 && NumVertices == 898 && primCount == 990) ||  (m_Stride == 16 && NumVertices == 3040 && primCount ==  2882) || (m_Stride == 16 && NumVertices == 5272 &&  primCount == 5595) || (m_Stride == 16 && NumVertices == 13248  && primCount == 13263) || (m_Stride == 16 && NumVertices  == 59 && primCount == 83) || (m_Stride == 16 &&  NumVertices == 120 && primCount == 28) || (m_Stride == 16  && NumVertices == 2124 && primCount == 657) || (m_Stride  == 16 && NumVertices == 466 && primCount == 185) ||  (m_Stride == 16 && NumVertices == 8572 && primCount ==  5694) || (m_Stride == 16 && NumVertices == 11127 &&  primCount == 9012) || (m_Stride == 16 && NumVertices == 2456  && primCount == 999) || (m_Stride == 16 && NumVertices  == 3414 && primCount == 2369))
#define CRYSIS2CHAMSOTHER (m_Stride == 16 && NumVertices == 260 && primCount == 434)
#define REMOVALS (m_Stride == 16 && NumVertices == 204  && primCount == 207 || (m_Stride == 16 && NumVertices ==  636 && primCount == 659) || (m_Stride == 16 &&  NumVertices == 349 && primCount == 243) || (m_Stride == 16  && NumVertices == 794 && primCount == 688) || (m_Stride  == 12 && NumVertices == 8 && primCount == 10))
#define BEEP_ACTIVATED Beep(2000, 500);
#define BEEP_DEACTIVATED Beep(1000, 500);
#define NULL 0;

void Initialize();
void ToggleAmmo();
void ToggleTagHack();
void ToggleChamsHack();
void Write2Asm(void*, BYTE*, int);

DWORD pAmmo;
DWORD pTagHack;

IDirect3DPixelShader9* texGreen;
IDirect3DPixelShader9* texYellow;


void Hotkeys()
{
	while(true)
	{
		if (GetAsyncKeyState(VK_F4))
		{
			ToggleAmmo();
		}

		if (GetAsyncKeyState(VK_F3))
		{
			ToggleTagHack();
		}

		if (GetAsyncKeyState(VK_F2))
		{
			ToggleChamsHack();
		}
		Sleep(500);
	}
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		Beep(5000, 1000);
		Initialize();
		ThreadMake(Hotkeys);
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

void Initialize()
{
	DWORD CrysisBase = (DWORD)GetModuleHandle(L"CryGameCrysis2");
	pAmmo = (CrysisBase + 0x4225D);
	pTagHack = (CrysisBase + 0xF50C2);

	//WCHAR tempChar[256];
	//swprintf(tempChar, 256, L"0x%X", pAmmoOffset);
	//MessageBox(NULL, tempChar,  L"Info", MB_OK | MB_ICONASTERISK);
}

void ToggleAmmo()
{
	static bool hack_activated = false;

	if(hack_activated)
	{
		Write2Asm((void*)pAmmo,(PBYTE)"\x89\x70\x04",3);
		hack_activated = false;
		BEEP_DEACTIVATED
	} 
	else
	{
		Write2Asm((void*)pAmmo,(PBYTE)"\x90\x90\x90",3);
		hack_activated = true;
		BEEP_ACTIVATED
	}
}

void ToggleTagHack()
{
	static int hack_state = 0;
	
	switch(hack_state)
	{
		case 0:
			Write2Asm((void*)pTagHack,(PBYTE)"\xB3\x01",2);			
			hack_state++;
			BEEP_ACTIVATED
			break;	
		case 1:
			Write2Asm((void*)pTagHack,(PBYTE)"\xB3\x02",2);			
			hack_state++;
			BEEP_ACTIVATED
			break;	
		case 2:
			Write2Asm((void*)pTagHack,(PBYTE)"\x8A\xD8",2);			
			hack_state = 0;
			BEEP_DEACTIVATED
			break;	
	}

}
void Write2Asm(void* pxAddress, BYTE * MyBytes,  int size)
{
	unsigned long Protection;
	VirtualProtect((void*)pxAddress, size, PAGE_READWRITE, &Protection);
	memcpy((void*)pxAddress, (const void*)MyBytes, size);
	VirtualProtect((void*)pxAddress, size, Protection, 0);
}


typedef HRESULT (WINAPI* CreateDevice_Prototype)        (LPDIRECT3D9, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, LPDIRECT3DDEVICE9*);
typedef HRESULT (WINAPI* Reset_Prototype)               (LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
typedef HRESULT (WINAPI* EndScene_Prototype)            (LPDIRECT3DDEVICE9);
typedef HRESULT (WINAPI* DrawIndexedPrimitive_Prototype)(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);

CreateDevice_Prototype         CreateDevice_Pointer         = NULL;
Reset_Prototype                Reset_Pointer                = NULL;
EndScene_Prototype             EndScene_Pointer             = NULL;
DrawIndexedPrimitive_Prototype DrawIndexedPrimitive_Pointer = NULL;

HRESULT WINAPI Direct3DCreate9_VMTable    (VOID);
HRESULT WINAPI CreateDevice_Detour        (LPDIRECT3D9, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, LPDIRECT3DDEVICE9*);
HRESULT WINAPI Reset_Detour               (LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
HRESULT WINAPI EndScene_Detour            (LPDIRECT3DDEVICE9);
HRESULT WINAPI DrawIndexedPrimitive_Detour(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);



void ToggleChamsHack()
{
	static bool hack_activated = false;

	if(hack_activated)
	{

		HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE Type, INT BaseVertexIndex, 
        UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
		{

			UINT m_Stride;
			UINT m_pD3Ddev;
			UINT OffsetInBytes;
			LPDIRECT3DDEVICE9 StreamData;


			if(m_pD3Ddev->GetStreamSource(0,&StreamData,&OffsetInBytes,&m_Stride) == D3D_OK) 
			{
				StreamData->Release();
			}

			if (REMOVALS && removals)   
			{
				return null;
			}

			if(CRYSIS2CHAMS)				
			{
				DWORD dwOldZEnable = D3DZB_TRUE; 
				m_pD3Ddev->SetTexture(0, texYellow);
				m_pD3Ddev->GetRenderState(D3DRS_ZENABLE, &dwOldZEnable);
				m_pD3Ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
				m_pD3Ddev->DrawIndexedPrimitive(Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
				m_pD3Ddev->SetRenderState(D3DRS_ZENABLE, dwOldZEnable);
				m_pD3Ddev->SetTexture(0, texGreen);
			}

			return m_pD3Ddev->DrawIndexedPrimitive(Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
		}
	}
}
See that's one of my issues, I'm not even sure how to setup everything I need/don't need to finish this. I've been using ideas from multiple forums to compile a general idea of what I'm looking for. I need assist with what to #include and what not to #include as well as, specifically, what I need to finish the chams (which has been giving me errors on compile, mainly because I'm almost positive I don't even have them setup right).

As of now the only issue going on is the Chams part, the other two are working perfect.

Thanks for the reply,
Hit me back with any more information you can give.

Cheers.
I suggest you learn c++ is the only way you will get it right and will understand the concept
I didn't ask for suggestions, I asked for some help. I can learn or "get it right" from constructive criticism, not self-scrutiny. If you're willing to assist in this matter, feel free to comment.


Also, I've limited down the solution a bit for those who are truly willing to help; I'll post in a few.

Cheers.
You could at least give me credits. It's 90% my code.
Take it, I never said I wrote all of it... not to mention, I clearly stated I used the code from the top of the thread. l2r
for chams you need D3D base. if you make with strides and etc.
/closed means /closed.

Thanks for trying though.
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?