1
0
Fork 0

DBG: MemPatch/assemble dialog now show errors when unable to write memory

This commit is contained in:
Nukem 2015-10-19 20:11:27 -04:00
parent dc1cd2ebc1
commit e19196781c
3 changed files with 32 additions and 12 deletions

View File

@ -68,14 +68,26 @@ bool assembleat(duint addr, const char* instruction, int* size, char* error, boo
*size = destSize;
bool ret = MemPatch(addr, dest, destSize);
if(ret && fillnop && nopsize)
{
if(size)
*size += nopsize;
// Ignored if the memory patch for NOPs fail (although it should not)
MemPatch(addr + destSize, nops, nopsize);
if (ret)
{
if (fillnop && nopsize)
{
if (size)
*size += nopsize;
// Ignored if the memory patch for NOPs fail (although it should not)
MemPatch(addr + destSize, nops, nopsize);
}
// Update GUI if any patching succeeded
GuiUpdatePatches();
}
GuiUpdatePatches();
return true;
else
{
// Tell the user writing is blocked
strcpy_s(error, MAX_ERROR_SIZE, "Error while writing process memory");
}
return ret;
}

View File

@ -297,10 +297,18 @@ bool MemPatch(duint BaseAddress, const void* Buffer, duint Size, duint* NumberOf
return false;
}
for(duint i = 0; i < Size; i++)
PatchSet(BaseAddress + i, oldData()[i], ((const unsigned char*)Buffer)[i]);
// Are we able to write on this page?
if (MemWrite(BaseAddress, Buffer, Size, NumberOfBytesWritten))
{
for (duint i = 0; i < Size; i++)
PatchSet(BaseAddress + i, oldData()[i], ((const unsigned char*)Buffer)[i]);
return MemWrite(BaseAddress, Buffer, Size, NumberOfBytesWritten);
// Done
return true;
}
// Unable to write memory
return false;
}
bool MemIsValidReadPtr(duint Address)

View File

@ -934,7 +934,7 @@ void CPUDisassembly::assembleAt()
LineEditDialog mLineEdit(this);
mLineEdit.setText(actual_inst);
mLineEdit.setWindowTitle("Assemble at " + addr_text);
mLineEdit.setCheckBoxText("&Fill with NOP's");
mLineEdit.setCheckBoxText("&Fill with NOPs");
mLineEdit.enableCheckBox(true);
mLineEdit.setCheckBox(ConfigBool("Disassembler", "FillNOPs"));
if(mLineEdit.exec() != QDialog::Accepted)