mirror of
https://github.com/x64dbg/x64dbg.git
synced 2025-02-21 13:33:29 +00:00
GUI: fully use the MemoryPage class, removed mBase + mSize
This commit is contained in:
parent
6f38a0c5e5
commit
b139b6440f
@ -2,8 +2,7 @@
|
||||
|
||||
Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
|
||||
{
|
||||
mBase = 0;
|
||||
mSize = 0;
|
||||
mMemPage = new MemoryPage(0, 0);
|
||||
|
||||
mInstBuffer.clear();
|
||||
|
||||
@ -24,7 +23,7 @@ Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
|
||||
|
||||
mGuiState = Disassembly::NoState;
|
||||
|
||||
setRowCount(mSize);
|
||||
setRowCount(mMemPage->getSize());
|
||||
|
||||
mCharWidth=QFontMetrics(this->font()).width(QChar(' '));
|
||||
|
||||
@ -87,7 +86,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
||||
case 0: // Draw address (+ label)
|
||||
{
|
||||
char label[MAX_LABEL_SIZE]="";
|
||||
int_t cur_addr=mInstBuffer.at(rowOffset).rva+mBase;
|
||||
int_t cur_addr=rvaToVa(mInstBuffer.at(rowOffset).rva);
|
||||
QString addrText="";
|
||||
if(mRvaDisplayEnabled) //RVA display
|
||||
{
|
||||
@ -309,7 +308,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
||||
case 1: //draw bytes (TODO: some spaces between bytes)
|
||||
{
|
||||
//draw functions
|
||||
int_t cur_addr=mInstBuffer.at(rowOffset).rva+mBase;
|
||||
int_t cur_addr=rvaToVa(mInstBuffer.at(rowOffset).rva);
|
||||
Function_t funcType;
|
||||
switch(DbgGetFunctionTypeAt(cur_addr))
|
||||
{
|
||||
@ -346,7 +345,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
||||
|
||||
case 2: //draw disassembly (with colours needed)
|
||||
{
|
||||
int_t cur_addr=mInstBuffer.at(rowOffset).rva+mBase;
|
||||
int_t cur_addr=rvaToVa(mInstBuffer.at(rowOffset).rva);
|
||||
int loopsize=0;
|
||||
int depth=0;
|
||||
|
||||
@ -394,7 +393,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
||||
case 3: //draw comments
|
||||
{
|
||||
char comment[MAX_COMMENT_SIZE]="";
|
||||
if(DbgGetCommentAt(mInstBuffer.at(rowOffset).rva+mBase, comment))
|
||||
if(DbgGetCommentAt(rvaToVa(mInstBuffer.at(rowOffset).rva), comment))
|
||||
{
|
||||
painter->setPen(ConfigColor("DisassemblyCommentColor"));
|
||||
int width = QFontMetrics(this->font()).width(comment)+4;
|
||||
@ -439,7 +438,7 @@ void Disassembly::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
int wI = getIndexOffsetFromY(transY(event->y()));
|
||||
|
||||
if(mSize > 0)
|
||||
if(mMemPage->getSize() > 0)
|
||||
{
|
||||
// Bound
|
||||
wI = wI >= mInstBuffer.size() ? mInstBuffer.size() - 1 : wI;
|
||||
@ -598,7 +597,7 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
else if(key == Qt::Key_Return || key == Qt::Key_Enter)
|
||||
{
|
||||
uint_t dest = DbgGetBranchDestination(getInitialSelection() + mBase);
|
||||
uint_t dest = DbgGetBranchDestination(rvaToVa(getInitialSelection()));
|
||||
if(!dest)
|
||||
return;
|
||||
QString cmd="disasm "+QString("%1").arg(dest, sizeof(int_t)*2, 16, QChar('0')).toUpper();
|
||||
@ -693,9 +692,9 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
|
||||
{
|
||||
int_t destRVA = (int_t)instruction.disasm.Instruction.AddrValue;
|
||||
|
||||
if(destRVA > (int_t)mBase)
|
||||
if(destRVA > (int_t)mMemPage->getBase())
|
||||
{
|
||||
destRVA -= (int_t)mBase;
|
||||
destRVA -= (int_t)mMemPage->getBase();
|
||||
|
||||
if(destRVA < selHeadRVA)
|
||||
{
|
||||
@ -718,7 +717,7 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsExecute=DbgIsJumpGoingToExecute(instruction.rva+mBase);
|
||||
bool bIsExecute=DbgIsJumpGoingToExecute(rvaToVa(instruction.rva));
|
||||
|
||||
if(branchType==JmpType) //unconditional
|
||||
{
|
||||
@ -891,7 +890,7 @@ int_t Disassembly::getPreviousInstructionRVA(int_t rva, uint_t count)
|
||||
wMaxByteCountToRead = wVirtualRVA + 1 + 16;
|
||||
wBuffer.resize(wMaxByteCountToRead);
|
||||
|
||||
DbgMemRead(mBase + wBottomByteRealRVA, reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead);
|
||||
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), wBottomByteRealRVA, wMaxByteCountToRead);
|
||||
|
||||
int_t addr = mDisasm->DisassembleBack(reinterpret_cast<byte_t*>(wBuffer.data()), 0, wMaxByteCountToRead, wVirtualRVA, count);
|
||||
|
||||
@ -917,13 +916,13 @@ int_t Disassembly::getNextInstructionRVA(int_t rva, uint_t count)
|
||||
int_t wMaxByteCountToRead;
|
||||
int_t wNewRVA;
|
||||
|
||||
wRemainingBytes = mSize - rva;
|
||||
wRemainingBytes = mMemPage->getSize() - rva;
|
||||
|
||||
wMaxByteCountToRead = 16 * (count + 1);
|
||||
wMaxByteCountToRead = wRemainingBytes > wMaxByteCountToRead ? wMaxByteCountToRead : wRemainingBytes;
|
||||
wBuffer.resize(wMaxByteCountToRead);
|
||||
|
||||
DbgMemRead(mBase + rva, reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead);
|
||||
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), rva, wMaxByteCountToRead);
|
||||
|
||||
wNewRVA = mDisasm->DisassembleNext(reinterpret_cast<byte_t*>(wBuffer.data()), 0, wMaxByteCountToRead, wVirtualRVA, count);
|
||||
wNewRVA += rva;
|
||||
@ -971,7 +970,7 @@ int_t Disassembly::getInstructionRVA(int_t index, int_t count)
|
||||
Instruction_t Disassembly::DisassembleAt(int_t rva)
|
||||
{
|
||||
QByteArray wBuffer;
|
||||
int_t base = mBase;
|
||||
int_t base = mMemPage->getBase();
|
||||
int_t wMaxByteCountToRead = 16 * 2;
|
||||
|
||||
// Bounding
|
||||
@ -984,7 +983,7 @@ Instruction_t Disassembly::DisassembleAt(int_t rva)
|
||||
|
||||
wBuffer.resize(wMaxByteCountToRead);
|
||||
|
||||
DbgMemRead(mBase+rva, reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead);
|
||||
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), rva, wMaxByteCountToRead);
|
||||
|
||||
return mDisasm->DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, base, rva);
|
||||
}
|
||||
@ -1180,7 +1179,7 @@ void Disassembly::reloadData()
|
||||
************************************************************************************/
|
||||
uint_t Disassembly::rvaToVa(int_t rva)
|
||||
{
|
||||
return mBase + rva;
|
||||
return mMemPage->va(rva);
|
||||
}
|
||||
|
||||
void Disassembly::disassembleAt(int_t parVA, int_t parCIP, bool history, int_t newTableOffset)
|
||||
@ -1221,10 +1220,9 @@ void Disassembly::disassembleAt(int_t parVA, int_t parCIP, bool history, int_t n
|
||||
}
|
||||
|
||||
// Set base and size (Useful when memory page changed)
|
||||
mBase = wBase;
|
||||
mSize = wSize;
|
||||
mMemPage->setAttributes(wBase, wSize);
|
||||
|
||||
if(mRvaDisplayEnabled && mBase != mRvaDisplayPageBase)
|
||||
if(mRvaDisplayEnabled && mMemPage->getBase() != mRvaDisplayPageBase)
|
||||
mRvaDisplayEnabled = false;
|
||||
|
||||
setRowCount(wSize);
|
||||
@ -1332,8 +1330,7 @@ void Disassembly::disassembleClear()
|
||||
mHighlightingMode=false;
|
||||
mHighlightToken.text="";
|
||||
historyClear();
|
||||
mBase = 0;
|
||||
mSize = 0;
|
||||
mMemPage->setAttributes(0, 0);
|
||||
setRowCount(0);
|
||||
reloadData();
|
||||
}
|
||||
@ -1349,12 +1346,12 @@ void Disassembly::debugStateChangedSlot(DBGSTATE state)
|
||||
|
||||
const int_t Disassembly::getBase() const
|
||||
{
|
||||
return mBase;
|
||||
return mMemPage->getBase();
|
||||
}
|
||||
|
||||
int_t Disassembly::getSize()
|
||||
{
|
||||
return mSize;
|
||||
return mMemPage->getSize();
|
||||
}
|
||||
|
||||
void Disassembly::historyClear()
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "QBeaEngine.h"
|
||||
#include "RichTextPainter.h"
|
||||
#include "BeaTokenizer.h"
|
||||
#include "MemoryPage.h"
|
||||
|
||||
class Disassembly : public AbstractTableView
|
||||
{
|
||||
@ -118,9 +119,6 @@ private:
|
||||
|
||||
GuiState_t mGuiState;
|
||||
|
||||
int_t mBase;
|
||||
int_t mSize;
|
||||
|
||||
int_t mCipRva;
|
||||
|
||||
QList<Instruction_t> mInstBuffer;
|
||||
@ -141,6 +139,7 @@ protected:
|
||||
uint_t mRvaDisplayBase;
|
||||
int_t mRvaDisplayPageBase;
|
||||
bool mHighlightingMode;
|
||||
MemoryPage* mMemPage;
|
||||
};
|
||||
|
||||
#endif // DISASSEMBLY_H
|
||||
|
@ -6,9 +6,6 @@ HexDump::HexDump(QWidget *parent) : AbstractTableView(parent)
|
||||
memset(&data, 0, sizeof(SelectionData_t));
|
||||
mSelection = data;
|
||||
|
||||
mBase = 0;
|
||||
mSize = 0;
|
||||
|
||||
mGuiState = HexDump::NoState;
|
||||
|
||||
setRowCount(0);
|
||||
@ -54,8 +51,6 @@ void HexDump::printDumpAt(int_t parVA, bool select)
|
||||
setRowCount(wRowCount); //set the number of rows
|
||||
|
||||
mMemPage->setAttributes(wBase, wSize); // Set base and size (Useful when memory page changed)
|
||||
mBase = wBase;
|
||||
mSize = wSize;
|
||||
|
||||
setTableOffset(-1); //make sure the requested address is always first
|
||||
|
||||
@ -72,6 +67,11 @@ void HexDump::printDumpAt(int_t parVA)
|
||||
printDumpAt(parVA, true);
|
||||
}
|
||||
|
||||
uint_t HexDump::rvaToVa(int_t rva)
|
||||
{
|
||||
return mMemPage->va(rva);
|
||||
}
|
||||
|
||||
void HexDump::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
bool wAccept = true;
|
||||
@ -91,7 +91,7 @@ void HexDump::mouseMoveEvent(QMouseEvent* event)
|
||||
int_t wStartingAddress = getItemStartingAddress(event->x(), event->y());
|
||||
int_t wEndingAddress = wStartingAddress + getSizeOf(mDescriptor.at(wColIndex - 1).data.itemSize) - 1;
|
||||
|
||||
if(wEndingAddress < mSize)
|
||||
if(wEndingAddress < mMemPage->getSize())
|
||||
{
|
||||
if(wStartingAddress < getInitialSelection())
|
||||
expandSelectionUpTo(wStartingAddress);
|
||||
@ -134,7 +134,7 @@ void HexDump::mousePressEvent(QMouseEvent* event)
|
||||
int_t wStartingAddress = getItemStartingAddress(event->x(), event->y());
|
||||
int_t wEndingAddress = wStartingAddress + getSizeOf(mDescriptor.at(wColIndex - 1).data.itemSize) - 1;
|
||||
|
||||
if(wEndingAddress < mSize)
|
||||
if(wEndingAddress < mMemPage->getSize())
|
||||
{
|
||||
if(!(event->modifiers() & Qt::ShiftModifier))
|
||||
setSingleSelection(wStartingAddress);
|
||||
@ -180,7 +180,7 @@ QString HexDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
|
||||
{
|
||||
// Reset byte offset when base address is reached
|
||||
if(rowBase == 0 && mByteOffset != 0)
|
||||
printDumpAt(mBase, false);
|
||||
printDumpAt(mMemPage->getBase(), false);
|
||||
|
||||
// Compute RVA
|
||||
int wBytePerRowCount = getBytePerRowCount();
|
||||
@ -189,7 +189,7 @@ QString HexDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
|
||||
QString wStr = "";
|
||||
if(col == 0) // Addresses
|
||||
{
|
||||
wStr += QString("%1").arg(mBase + wRva, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
wStr += QString("%1").arg(rvaToVa(wRva), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
}
|
||||
else if(mDescriptor.at(col - 1).isData == true) //paint data
|
||||
{
|
||||
@ -287,16 +287,16 @@ QString HexDump::getString(int col, int_t rva)
|
||||
int wByteCount = getSizeOf(mDescriptor.at(col).data.itemSize);
|
||||
int wBufferByteCount = mDescriptor.at(col).itemCount * wByteCount;
|
||||
|
||||
wBufferByteCount = wBufferByteCount > (mSize - rva) ? mSize - rva : wBufferByteCount;
|
||||
wBufferByteCount = wBufferByteCount > (mMemPage->getSize() - rva) ? mMemPage->getSize() - rva : wBufferByteCount;
|
||||
|
||||
byte_t* wData = new byte_t[wBufferByteCount];
|
||||
//byte_t wData[mDescriptor.at(col).itemCount * wByteCount];
|
||||
|
||||
mMemPage->readOriginalMemory(wData, rva, wBufferByteCount);
|
||||
mMemPage->read(wData, rva, wBufferByteCount);
|
||||
|
||||
for(wI = 0; wI < mDescriptor.at(col).itemCount && (rva + wI) < mSize; wI++)
|
||||
for(wI = 0; wI < mDescriptor.at(col).itemCount && (rva + wI) < mMemPage->getSize(); wI++)
|
||||
{
|
||||
if((rva + wI + wByteCount - 1) < mSize)
|
||||
if((rva + wI + wByteCount - 1) < mMemPage->getSize())
|
||||
wStr += toString(mDescriptor.at(col).data, (void*)(wData + wI * wByteCount)).rightJustified(getStringMaxLength(mDescriptor.at(col).data), ' ') + " ";
|
||||
else
|
||||
wStr += QString("?").rightJustified(getStringMaxLength(mDescriptor.at(col).data), ' ') + " ";
|
||||
@ -890,7 +890,7 @@ void HexDump::appendResetDescriptor(int width, QString title, bool clickable, Co
|
||||
int_t wRVA = getTableOffset() * getBytePerRowCount() - mByteOffset;
|
||||
clearDescriptors();
|
||||
appendDescriptor(width, title, clickable, descriptor);
|
||||
printDumpAt(wRVA + mBase, false);
|
||||
printDumpAt(rvaToVa(wRVA), false);
|
||||
}
|
||||
else
|
||||
appendDescriptor(width, title, clickable, descriptor);
|
||||
@ -908,8 +908,7 @@ void HexDump::debugStateChanged(DBGSTATE state)
|
||||
{
|
||||
if(state==stopped)
|
||||
{
|
||||
mBase=0;
|
||||
mSize=0;
|
||||
mMemPage->setAttributes(0, 0);
|
||||
setRowCount(0);
|
||||
reloadData();
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
void clearDescriptors();
|
||||
|
||||
void printDumpAt(int_t parVA, bool select);
|
||||
uint_t rvaToVa(int_t rva);
|
||||
|
||||
public slots:
|
||||
void printDumpAt(int_t parVA);
|
||||
@ -153,8 +154,6 @@ private:
|
||||
|
||||
protected:
|
||||
MemoryPage* mMemPage;
|
||||
int_t mBase;
|
||||
int_t mSize;
|
||||
int mByteOffset;
|
||||
QList<ColumnDescriptor_t> mDescriptor;
|
||||
};
|
||||
|
@ -644,7 +644,7 @@ void CPUDisassembly::assembleAt()
|
||||
|
||||
wBuffer.resize(wMaxByteCountToRead);
|
||||
|
||||
DbgMemRead(wVA, reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead);
|
||||
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), wRVA, wMaxByteCountToRead);
|
||||
|
||||
QBeaEngine* disasm = new QBeaEngine();
|
||||
Instruction_t instr=disasm->DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, 0, wVA);
|
||||
|
@ -148,7 +148,7 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
|
||||
{
|
||||
char label[MAX_LABEL_SIZE]="";
|
||||
QString addrText="";
|
||||
int_t curAddr = (rowBase + rowOffset) * getBytePerRowCount() - mByteOffset + this->mBase;
|
||||
int_t curAddr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
|
||||
addrText = QString("%1").arg(curAddr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
|
||||
if(DbgGetLabelAt(curAddr, SEG_DEFAULT, label)) //has label
|
||||
{
|
||||
@ -180,7 +180,7 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
|
||||
{
|
||||
uint_t data=0;
|
||||
int_t wRva = (rowBase + rowOffset) * getBytePerRowCount() - mByteOffset;
|
||||
mMemPage->readOriginalMemory((byte_t*)&data, wRva, sizeof(uint_t));
|
||||
mMemPage->read((byte_t*)&data, wRva, sizeof(uint_t));
|
||||
char label_text[MAX_LABEL_SIZE]="";
|
||||
if(DbgGetLabelAt(data, SEG_DEFAULT, label_text))
|
||||
wStr=QString(label_text);
|
||||
@ -215,7 +215,7 @@ void CPUDump::setLabelSlot()
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
|
||||
uint_t wVA = getSelectionStart() + this->mBase;
|
||||
uint_t wVA = rvaToVa(getSelectionStart());
|
||||
LineEditDialog mLineEdit(this);
|
||||
QString addr_text=QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
char label_text[MAX_COMMENT_SIZE]="";
|
||||
@ -657,15 +657,15 @@ void CPUDump::disassemblySlot()
|
||||
|
||||
void CPUDump::selectionGet(SELECTIONDATA* selection)
|
||||
{
|
||||
selection->start=getSelectionStart() + mBase;
|
||||
selection->end=getSelectionEnd() + mBase;
|
||||
selection->start=rvaToVa(getSelectionStart());
|
||||
selection->end=rvaToVa(getSelectionEnd());
|
||||
Bridge::getBridge()->BridgeSetResult(1);
|
||||
}
|
||||
|
||||
void CPUDump::selectionSet(const SELECTIONDATA* selection)
|
||||
{
|
||||
int_t selMin=mBase;
|
||||
int_t selMax=selMin + mSize;
|
||||
int_t selMin=mMemPage->getBase();
|
||||
int_t selMax=selMin + mMemPage->getSize();
|
||||
int_t start=selection->start;
|
||||
int_t end=selection->end;
|
||||
if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range
|
||||
|
@ -85,7 +85,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
|
||||
// Compute RVA
|
||||
int wBytePerRowCount = getBytePerRowCount();
|
||||
int_t wRva = (rowBase + rowOffset) * wBytePerRowCount - mByteOffset;
|
||||
uint_t wVa = wRva + mMemPage->getBase();
|
||||
uint_t wVa = rvaToVa(wRva);
|
||||
|
||||
bool wIsSelected=isSelected(wRva);
|
||||
if(wIsSelected) //highlight if selected
|
||||
@ -101,7 +101,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
|
||||
{
|
||||
char label[MAX_LABEL_SIZE]="";
|
||||
QString addrText="";
|
||||
int_t curAddr = (rowBase + rowOffset) * getBytePerRowCount() - mByteOffset + this->mBase;
|
||||
int_t curAddr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
|
||||
addrText = QString("%1").arg(curAddr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
|
||||
if(DbgGetLabelAt(curAddr, SEG_DEFAULT, label)) //has label
|
||||
{
|
||||
@ -158,7 +158,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
|
||||
painter->setPen(QPen(ConfigColor("StackInactiveTextColor")));
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, wStr);
|
||||
}
|
||||
else if(DbgStackCommentGet(mMemPage->getBase()+wRva, &comment)) //paint stack comments
|
||||
else if(DbgStackCommentGet(rvaToVa(wRva), &comment)) //paint stack comments
|
||||
{
|
||||
QString wStr = QString(comment.comment);
|
||||
if(wActiveStack)
|
||||
@ -185,9 +185,8 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event)
|
||||
wMenu->addAction(mGotoBp);
|
||||
wMenu->addAction(mGotoExpression);
|
||||
|
||||
int_t selectedVa = getInitialSelection() + mMemPage->getBase();
|
||||
uint_t selectedData;
|
||||
if(DbgMemRead(selectedVa, (unsigned char*)&selectedData, sizeof(uint_t)))
|
||||
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
|
||||
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
|
||||
{
|
||||
uint_t stackBegin = mMemPage->getBase();
|
||||
@ -244,15 +243,15 @@ void CPUStack::gotoExpressionSlot()
|
||||
|
||||
void CPUStack::selectionGet(SELECTIONDATA* selection)
|
||||
{
|
||||
selection->start=getSelectionStart() + mBase;
|
||||
selection->end=getSelectionEnd() + mBase;
|
||||
selection->start=rvaToVa(getSelectionStart());
|
||||
selection->end=rvaToVa(getSelectionEnd());
|
||||
Bridge::getBridge()->BridgeSetResult(1);
|
||||
}
|
||||
|
||||
void CPUStack::selectionSet(const SELECTIONDATA* selection)
|
||||
{
|
||||
int_t selMin=mBase;
|
||||
int_t selMax=selMin + mSize;
|
||||
int_t selMin=mMemPage->getBase();
|
||||
int_t selMax=selMin + mMemPage->getSize();
|
||||
int_t start=selection->start;
|
||||
int_t end=selection->end;
|
||||
if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range
|
||||
@ -268,9 +267,8 @@ void CPUStack::selectionSet(const SELECTIONDATA* selection)
|
||||
|
||||
void CPUStack::followDisasmSlot()
|
||||
{
|
||||
int_t selectedVa = getInitialSelection() + mMemPage->getBase();
|
||||
uint_t selectedData;
|
||||
if(DbgMemRead(selectedVa, (unsigned char*)&selectedData, sizeof(uint_t)))
|
||||
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
|
||||
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
|
||||
{
|
||||
QString addrText=QString("%1").arg(selectedData, sizeof(int_t)*2, 16, QChar('0')).toUpper();
|
||||
@ -280,9 +278,8 @@ void CPUStack::followDisasmSlot()
|
||||
|
||||
void CPUStack::followDumpSlot()
|
||||
{
|
||||
int_t selectedVa = getInitialSelection() + mMemPage->getBase();
|
||||
uint_t selectedData;
|
||||
if(DbgMemRead(selectedVa, (unsigned char*)&selectedData, sizeof(uint_t)))
|
||||
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
|
||||
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
|
||||
{
|
||||
QString addrText=QString("%1").arg(selectedData, sizeof(int_t)*2, 16, QChar('0')).toUpper();
|
||||
@ -292,9 +289,8 @@ void CPUStack::followDumpSlot()
|
||||
|
||||
void CPUStack::followStackSlot()
|
||||
{
|
||||
int_t selectedVa = getInitialSelection() + mMemPage->getBase();
|
||||
uint_t selectedData;
|
||||
if(DbgMemRead(selectedVa, (unsigned char*)&selectedData, sizeof(uint_t)))
|
||||
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
|
||||
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
|
||||
{
|
||||
QString addrText=QString("%1").arg(selectedData, sizeof(int_t)*2, 16, QChar('0')).toUpper();
|
||||
|
@ -9,9 +9,9 @@ MemoryPage::MemoryPage(uint_t parBase, uint_t parSize, QObject *parent) : QObjec
|
||||
}
|
||||
|
||||
|
||||
void MemoryPage::readOriginalMemory(byte_t* parDest, uint_t parRVA, uint_t parSize)
|
||||
bool MemoryPage::read(byte_t* parDest, uint_t parRVA, uint_t parSize)
|
||||
{
|
||||
DbgMemRead(mBase + parRVA, parDest, parSize);
|
||||
return DbgMemRead(mBase + parRVA, parDest, parSize);
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,10 @@ uint_t MemoryPage::getBase()
|
||||
return mBase;
|
||||
}
|
||||
|
||||
uint_t MemoryPage::va(int_t rva)
|
||||
{
|
||||
return mBase + rva;
|
||||
}
|
||||
|
||||
void MemoryPage::setAttributes(uint_t base, uint_t size)
|
||||
{
|
||||
|
@ -15,20 +15,15 @@ class MemoryPage : public QObject
|
||||
public:
|
||||
explicit MemoryPage(uint_t parBase, uint_t parSize, QObject *parent = 0);
|
||||
|
||||
void readOriginalMemory(byte_t* parDest, uint_t parRVA, uint_t parSize);
|
||||
bool read(byte_t* parDest, uint_t parRVA, uint_t parSize);
|
||||
uint_t getSize();
|
||||
uint_t getBase();
|
||||
uint_t va(int_t rva);
|
||||
void setAttributes(uint_t base, uint_t size);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
uint_t mBase;
|
||||
uint_t mSize;
|
||||
|
||||
|
||||
uint_t mSize;
|
||||
};
|
||||
|
||||
#endif // MEMORYPAGE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user