All pastes #780126 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-18 14:35 UTC
rendered paste body
#include "StdAfx.h"
#include "HxCrc.h"

static LPCTSTR name2="*crc";
static LPCTSTR desc2="CRC bypass (Maple)";
static LPCTSTR vers2="1.20b44";

static LPCTSTR srchCrc = "00 8B 45 10 56 57";

static DWORD hashBeg=0;
static DWORD hashEnd=0;
static DWORD crcOffset=0;
static DWORD rtnCrc=0;

DWORD getAsmBuffCrc();

bool CHxCrc::disable()
{
	if (_myIo->debugMode()>3) return CBaseHack::disable();
	_myIo->lprintf(MYIO_DEFAULT,"%s cannot be disabled.\r\n", _id);
	return false;
}

CHxCrc::CHxCrc()
: CBaseHack(name2,vers2,desc2)
{

	if (_valid) return;
	DWORD tmpAddy;

	if (!(tmpAddy = _gMem->findAob(_id,"srchCrc",srchCrc))) return;
	regHook( "Crc",tmpAddy, 5)->makeJmp(getAsmBuffCrc(), rtnCrc);

	DWORD hashSize =_gMem->hashSize;
	hashBeg= _gMem->hashBeg;
	hashEnd= hashBeg + hashSize;
	crcOffset = (DWORD) _gMem->getOwnHash() - hashBeg;

	_valid=TRUE;
	//enable();
}
static __declspec( naked ) DWORD getAsmBuffCrc()
{
	__asm
	{
		mov eax, offset buffer_begin ; Get address of first instruction in assembly
		ret

	buffer_begin:
			cmp	ecx, hashBeg
			jb	orig
			cmp	ecx, hashEnd
			ja	orig
			add	ecx, crcOffset
		orig:
			mov	eax, dword ptr[ebp+10h]
			push	esi
			push	edi
			jmp rtnCrc
	buffer_end:
	}
}