[C++]Pattern Search Not Working
it compiling perfectly but when i try to inject it and press F2 it would just kill the game but with CE it works can someone help me please?? 
@luizimloko

Code:
#include "stdafx.h"
DWORD FindPattern( DWORD dwStart, DWORD dwLen, BYTE *pszPatt, char pszMask[] )
{
unsigned int i = NULL;
int iLen = strlen( pszMask ) - 1;
for( DWORD dwRet = dwStart; dwRet < dwStart + dwLen; dwRet++ )
{
if( *( BYTE * ) dwRet == pszPatt[ i ] || pszMask[ i ] == '?' )
{
if( pszMask[ i + 1 ] == '\0' )
return( dwRet - iLen );
i++;
}
else i = NULL;
}
return NULL;
}
void memwrite(void *adr,void *ptr,int size)
{
DWORD Protection;
VirtualProtect(adr,size,PAGE_EXECUTE_READWRITE,&Protection);
memcpy(adr,ptr,size);
VirtualProtect(adr,size,Protection,&Protection);
}
DWORD client = (DWORD)GetModuleHandleA("client.exe");
DWORD speedhack = FindPattern(client,0xFFFFFF,(BYTE *)"\x66\x0F\x5A\xC0\xF3\x0F\x11\x45\xF0\x8B\x4E","xxxxxxxxxxx");
void Engine()
{
while (TRUE)
{
//////////////////////////////////////////////////
if (GetAsyncKeyState(VK_F2) & 0x8000)
{
memwrite((void*)(speedhack), (void *) (PBYTE) "\x66\x0F\x5A\xC1\xF3\x0F\x11\x45\xF0\x8B\x4E", 11);
Beep(750, 500);
}
//////////////////////////////////////////////////
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Engine, 0, 0, 0);
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
