#define DLL_EXPORT
#include "dllheader.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>

/*	Call of Duty 4	
	Y-Hack v1
	By Yeasiz   
	www.1990y.com

	Credits:
	Me
	UC-Forum
	Quicktime
	R4z8r
	K@N@VEL
*/

//Boolean's
bool SetNoRecoil = 0;
bool SetMINIMAP = 0;
bool SetLASER = 0;
bool SetNAMETAGS = 0;
bool SetFOG = 0;
bool SetDVAR = 0;
bool SetWALLHACK = 0;


//Handle
HANDLE CallOfDuty4 = GetCurrentProcess();


//Game Base Address
DWORD GameBase = 0x400000; 


//Hack Offsets
DWORD NORECOIL					=			GameBase + 0x57CCF;    // Done
DWORD MINIMAP					=			GameBase + 0x02A0B4;   // Done 
DWORD MINIMAP1					=			GameBase + 0x02A0B5;   // Done
DWORD MINIMAP2					=			GameBase + 0x02A0B6;   // Done
DWORD MINIMAP3					=			GameBase + 0x02A0B7;   // Done
DWORD MINIMAP4					=			GameBase + 0x02A0B8;   // Done
DWORD LASER						=			GameBase + 0x0056E78;  // Done
DWORD NAMETAGS					=			GameBase + 0x02E1CE;   // Done
DWORD NAMETAGS1					=			GameBase + 0x02E1CF;   // Done
DWORD NAMETAGS2					=			GameBase + 0x02E1AC;   // Done
DWORD NAMETAGS3					=			GameBase + 0x02E1AD;   // Done
DWORD NAMETAGS4					=			GameBase + 0x02E1AF;   // Done
DWORD NAMETAGS5					=			GameBase + 0x02E1B0;   // Done
DWORD NAMETAGS6					=			GameBase + 0x02E1B1;   // Done
DWORD FOG						=			GameBase + 0x23DB0D;   // Done
DWORD FOG1						=			GameBase + 0x23DB0E;   // Done
DWORD DVAR						=			GameBase + 0x16B386;   // Done
DWORD WALLHACK					=			GameBase + 0x045480;   // Done
DWORD NOFLASH					=			GameBase + 0x051FB9;   // Done
DWORD CROSSHAIR					=			GameBase + 0x030EE3;   // Done
DWORD CROSSHAIR2				=			GameBase + 0x030ED5;   // Done


// Features
BYTE NoRecoil[]		= {0x75, 0x12}; 
BYTE Wallhack[]		= {0x6a, 0x12}; 
BYTE Laser[]		= {0x74, 0x04}; 
BYTE NameTags[]		= {0x75, 0x12}; 
BYTE Dvar[]			= {0x74, 0x19}; 

//Nops
BYTE NopOne[]		= {0x90}; 
BYTE NopTwo[]		= {0x90,0x90}; 
BYTE NopThree[]		= {0x90,0x90,0x90}; 
BYTE NopFour[]		= {0x90,0x90,0x90,0x90}; 


//Write to Console Function.
void SendCommandToConsole(char* command)
	{
		__asm
		{
			push	command
			push	0
			push	0
			mov	esi, 0x004F9AB0
			call	esi
			add	esp, 0x0C
		}
	}

//Setup Hack Dvars
DWORD WINAPI SetupDvars(LPVOID)
{
    SendCommandToConsole("dvar_int laser 0 0 1");
	SendCommandToConsole("dvar_int wallhack 0 0 1");
	SendCommandToConsole("dvar_int esp 0 0 1");
	SendCommandToConsole("dvar_int nofog 0 0 1");
	SendCommandToConsole("dvar_int dvarunlock 0 0 1");
	SendCommandToConsole("dvar_int minimap 0 0 1");
	SendCommandToConsole("dvar_int norecoil 0 0 1");
return true; 	
}
//---------------------------------------------------------------------------
BOOL WINAPI DllMain (HINSTANCE hModule, DWORD dwAttached, LPVOID lpvReserved)
{
    if (dwAttached == DLL_PROCESS_ATTACH)
    {
		 //WriteProcessMemory(CallOfDuty4, (void*)LASER, &Laser, 2, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)MINIMAP, &NopTwo, 2, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)MINIMAP1, &NopTwo, 2, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)MINIMAP2, &NopTwo, 2, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)MINIMAP3, &NopTwo, 2, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS1, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS2, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS3, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS4, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS5, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NAMETAGS6, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)FOG, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)FOG1, &NopOne, 1, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)DVAR, &Dvar, 2, 0);
		 //WriteProcessMemory(CallOfDuty4, (void*)WALLHACK, &Wallhack, 2, 0);
		 WriteProcessMemory(CallOfDuty4, (void*)NORECOIL, &NoRecoil, 2, 0);
		 //CreateThread(NULL, NULL, HotKeysThread, NULL, NULL, NULL);
	     CreateThread(0,0,SetupDvars,0,0,0);
		 Beep(150,150);
 
    }
    
  return 1; 
}