ChunItachi/dllmain.cpp
//function for hooking and jumping back
function for hooking and jumping back
function for hooking and jumping back
BOOL HOOK(void * toHook, void * ourFunct, int len) {
	if (len < 5) {
		return false;
	}
	DWORD curProtection;
	VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);
	memset(toHook, 0x90, len);
	DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5;
	*(BYTE*)toHook = 0xE9;
	*(DWORD*)((DWORD)toHook + 1) = relativeAddress;
	DWORD temp;
	VirtualProtect(toHook, len, curProtection, &temp);
	return true;
}
BOOL HOOK ( void * toHook , void * ourFunct , int len ) { if ( len < 5 ) { return false ; } DWORD curProtection ; VirtualProtect ( toHook , len , PAGE_EXECUTE_READWRITE , & curProtection ) ; memset ( toHook , 0x90 , len ) ; DWORD relativeAddress = ( ( DWORD ) ourFunct - ( DWORD ) toHook ) - 5 ; * ( BYTE * ) toHook = 0xE9 ; * ( DWORD * ) ( ( DWORD ) toHook + 1 ) = relativeAddress ; DWORD temp ; VirtualProtect ( toHook , len , curProtection , & temp ) ; return true ; }
function for hooking and jumping back
function for hooking and jumping back
//jump call is going to be 5 long, so if what we overwrite is less than 5 we're boned //free the existing memory //null the existing memory to NOP //figure out how far to where we go, minus 5 because jump is 5 //write jump instruction //set the existing memory location back to the previous security //return