All pastes #373513 Raw Edit

Someone

public cpp v1 · immutable
#373513 ·published 2007-02-26 20:47 UTC
rendered paste body
bool CDetour::RestoreFunction( BYTE* func, int len ){	MEMORY_BASIC_INFORMATION mbi;	bool bRet = false;	VirtualQuery( ( void* )orig, &mbi, sizeof( mbi ) );	VirtualProtect( mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect );	memcpy( ( void* )func, ( void* )bBackup, len );	if( *( BYTE* )func == *( BYTE* )bBackup )	{		bRet = true;	}else{		bRet = false;	}	VirtualProtect( mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &mbi.Protect );	FlushInstructionCache( GetCurrentProcess( ), ( void* )func, len );	return bRet;}bool CDetour::BackupFunction( BYTE* func, int len ){	MEMORY_BASIC_INFORMATION mbi;	bool bRet = false;	VirtualQuery( ( void* )orig, &mbi, sizeof( mbi ) );	VirtualProtect( mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect );	memcpy( ( void* )bBackup, ( void* )func, len );	if( *( BYTE* )bBackup == *( BYTE* )func )	{		bRet = true;	}else{		bRet = false;	}	VirtualProtect( mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &mbi.Protect );	FlushInstructionCache( GetCurrentProcess( ), ( void* )func, len );	return bRet;}