Here's my code
Code:
LONG __stdcall VectoredHandler ( PEXCEPTION_POINTERS ExceptionInfo )
{
PCONTEXT Context;
Context = ExceptionInfo->ContextRecord;
char m[20];
sprintf_s(m,"%X",(unsigned int)(PVOID)(ExceptionInfo->ExceptionRecord->ExceptionAddress));
MessageBoxA(NULL,m,"0",0);
if ( ExceptionInfo->ExceptionRecord->ExceptionAddress == (PVOID)(TargetAddress + CHack::WoWBase) ) {
Context->Eip = (DWORD) (TargetAddress + CHack::WoWBase + 0x51);
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
AddVectoredExceptionHandler(1, VectoredHandler );
DWORD dwOldProtect;
VirtualProtect(reinterpret_cast<LPVOID>(CHack::WoWBase + TargetAddress),1,PAGE_READONLY, &dwOldProtect);
//// Memory::Write<byte>(CHack::WoWBase + TargetAddress, 0xcc);
When exception is passed to my handler. The "ExceptionInfo->ExceptionRecord->ExceptionAddress" isn't "CHack::WoWBase + TargetAddress" at all
if i use "Memory::Write<byte>(CHack::WoWBase + TargetAddress, 0xcc)" instead, then everything is OK
So why VirtualProtect will raise a wrong address exception ?