All pastes #941832 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-13 23:46 UTC
rendered paste body
DWORD (WINAPI *orig_GetTickCount)(VOID);
DWORD WINAPI GetTickCount_Hook(VOID)
{
	DWORD dwReturnAddress = PtrToUlong(_ReturnAddress( ));
	if (dwPBCLBase != 0)
	{
        	if ( dwReturnAddress >= dwPBCLBase && dwReturnAddress <= dwPBCLBase + 0x80000 ) {
        		if ( bMemoryUnpatched ) {
        			ApplyMemoryPatches( );
        			bMemoryUnpatched = FALSE;
        		}
        		bGetTickCountCalled = TRUE;
			}
	}

	return orig_GetTickCount();
}


DWORD (WINAPI *orig_VirtualQuery)(LPCVOID lpAddr, PMEMORY_BASIC_INFORMATION lpBuf, DWORD dwLen);
DWORD WINAPI VirtualQuery_Hook(LPCVOID lpAddr, PMEMORY_BASIC_INFORMATION lpBuf, DWORD dwLen)
{
	DWORD dwReturnAddress = PtrToUlong(_ReturnAddress( ));
	if (dwPBCLBase != 0)
	{
        	if ( dwReturnAddress >= dwPBCLBase && dwReturnAddress <= dwPBCLBase + 0x80000 ) {
        		if ( !bGetTickCountCalled ) {
        			RestoreMemoryPatches( );
        			bMemoryUnpatched = TRUE;
        		} else 
        			bGetTickCountCalled = FALSE;
			}
	}

	return orig_VirtualQuery(lpAddr, lpBuf, dwLen);
}