I'm having an issue catching an exception , this is the error:
Unhandled exception at 0x01034BB1 in Hello.exe: 0xC0000005: Access violation reading location 0x02343DA2.
This is my code:
bool VerifyAddress(HANDLE hwnd, DWORD dwAddress, char* bMask, char *szMask )
{
PBYTE *pTemp = { 0 };
for ( int i = 0; *szMask; ++szMask, ++bMask, ++i )
{
try {
if ( !ReadProcessMemory( hwnd, reinterpret_cast<LPCVOID>(dwAddress + i), &pTemp, sizeof(pTemp), 0 ) ){
failedRPM++;
return false;
}
} catch(...) {
failedRPM++;
return false;
}
if ( *szMask == 'x' && reinterpret_cast<char*>(pTemp) != reinterpret_cast<char*>(*bMask)){
failedMask++;
return false;
}
}
return true;
}
DWORD FindPattern(HANDLE hwnd, char* bMask, char *szMask )
{
for ( DWORD dwCurrentAddress = 0x015A1DB4; dwCurrentAddress < 0x7FFFFFF; dwCurrentAddress++ ){
if ( VerifyAddress( hwnd, dwCurrentAddress, bMask, szMask )) {
return dwCurrentAddress;
}
}
return 0x0;
}
I have just a question: why the catch is not catching?