1
0
Fork 0

DBG: added boundary checks on DbgMemRead and DbgMemWrite (might solve some unexpected crashes like the ones I experienced today with a random enigma file)

This commit is contained in:
Mr. eXoDia 2014-07-08 00:07:35 +02:00
parent e038d690da
commit f6adccaef8
2 changed files with 12 additions and 0 deletions

View File

@ -208,6 +208,11 @@ BRIDGE_IMPEXP int BridgeGetDbgVersion()
//Debugger
BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size)
{
if(IsBadWritePtr(dest, size))
{
GuiAddLogMessage("DbgMemRead with invalid boundaries!\n");
return false;
}
bool ret=_dbg_memread(va, dest, size, 0);
if(!ret)
memset(dest, 0x90, size);
@ -216,6 +221,11 @@ BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size)
BRIDGE_IMPEXP bool DbgMemWrite(duint va, const unsigned char* src, duint size)
{
if(IsBadReadPtr(src, size))
{
GuiAddLogMessage("DbgMemWrite with invalid boundaries!\n");
return false;
}
return _dbg_memwrite(va, src, size, 0);
}

View File

@ -927,6 +927,8 @@ int_t Disassembly::getNextInstructionRVA(int_t rva, uint_t count)
int_t wMaxByteCountToRead;
int_t wNewRVA;
if(mMemPage->getSize() < rva)
return rva;
wRemainingBytes = mMemPage->getSize() - rva;
wMaxByteCountToRead = 16 * (count + 1);