Skip to content

Commit

Permalink
temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
torusrxxx committed Jul 23, 2023
1 parent be6565b commit 8d6f503
Show file tree
Hide file tree
Showing 13 changed files with 1,798 additions and 96 deletions.
7 changes: 5 additions & 2 deletions src/gui/Src/BasicView/HexDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static int dwordStringMaxLength(HexDump::DwordViewMode mode);
static int qwordStringMaxLength(HexDump::QwordViewMode mode);
static int twordStringMaxLength(HexDump::TwordViewMode mode);

HexDump::HexDump(QWidget* parent)
HexDump::HexDump(QWidget* parent, MemoryPage* memPage)
: AbstractTableView(parent)
{
memset(&mSelection, 0, sizeof(SelectionData));
Expand All @@ -22,7 +22,10 @@ HexDump::HexDump(QWidget* parent)

setRowCount(0);

mMemPage = new MemoryPage(0, 0);
if(!memPage)
mMemPage = new MemoryPage(0, 0, this);
else
mMemPage = memPage;
mForceColumn = -1;

clearDescriptors();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Src/BasicView/HexDump.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class HexDump : public AbstractTableView
std::function<void()> columnSwitch;
};

explicit HexDump(QWidget* parent = 0);
explicit HexDump(QWidget* parent = 0, MemoryPage* memPage = 0);
~HexDump() override;

// Configuration
Expand Down
6 changes: 3 additions & 3 deletions src/gui/Src/Memory/MemoryPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class MemoryPage : public QObject
public:
explicit MemoryPage(duint parBase, duint parSize, QObject* parent = 0);

bool read(void* parDest, dsint parRVA, duint parSize) const;
bool write(const void* parDest, dsint parRVA, duint parSize);
virtual bool read(void* parDest, dsint parRVA, duint parSize) const;
virtual bool write(const void* parDest, dsint parRVA, duint parSize);
duint getSize() const;
duint getBase() const;
duint va(dsint rva) const;
void setAttributes(duint base, duint size);
bool inRange(duint va) const;

private:
protected:
duint mBase;
duint mSize;
};
1,472 changes: 1,472 additions & 0 deletions src/gui/Src/Tracer/TraceDump.cpp

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions src/gui/Src/Tracer/TraceDump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#pragma once

#include "HexDump.h"
#include "TraceFileDump.h"

//forward declaration
//class CPUMultiDump;
class TraceBrowser;
class GotoDialog;
class CommonActions;

class TraceDump : public HexDump
{
Q_OBJECT
public:
explicit TraceDump(TraceBrowser* disas, TraceFileDumpMemoryPage* memoryPage, QWidget* parent);
void getColumnRichText(int col, dsint rva, RichTextPainter::List & richText) override;
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
void setupContextMenu();
void getAttention();
void contextMenuEvent(QContextMenuEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);

signals:
void displayReferencesWidget();
void showDisassemblyTab(duint selectionStart, duint selectionEnd, duint firstAddress);

public slots:
void gotoExpressionSlot();
void gotoFileOffsetSlot();
void gotoStartSlot();
void gotoEndSlot();
//void gotoPreviousReferenceSlot();
//void gotoNextReferenceSlot();

void hexAsciiSlot();
void hexUnicodeSlot();
void hexCodepageSlot();
void hexLastCodepageSlot();

void textAsciiSlot();
void textUnicodeSlot();
void textCodepageSlot();
void textLastCodepageSlot();

void integerSignedByteSlot();
void integerSignedShortSlot();
void integerSignedLongSlot();
void integerSignedLongLongSlot();
void integerUnsignedByteSlot();
void integerUnsignedShortSlot();
void integerUnsignedLongSlot();
void integerUnsignedLongLongSlot();
void integerHexShortSlot();
void integerHexLongSlot();
void integerHexLongLongSlot();

void floatFloatSlot();
void floatDoubleSlot();
void floatLongDoubleSlot();

void addressUnicodeSlot();
void addressAsciiSlot();
void disassemblySlot();

void selectionGet(SELECTIONDATA* selection);
void selectionSet(const SELECTIONDATA* selection);

void binaryEditSlot();
void binaryCopySlot();
void binarySaveToFileSlot();
void findPattern();
void copyFileOffsetSlot();
void findReferencesSlot();

void selectionUpdatedSlot();
void syncWithExpressionSlot();

void headerButtonReleasedSlot(int colIndex);

private:
TraceFileDumpMemoryPage* mMemoryPage;
MenuBuilder* mMenuBuilder;
CommonActions* mCommonActions;

//QMenu* mPluginMenu;
//QMenu* mFollowInDumpMenu;
QList<QAction*> mFollowInDumpActions;

GotoDialog* mGoto = nullptr;
GotoDialog* mGotoOffset = nullptr;
TraceBrowser* mDisas;
//CPUMultiDump* mMultiDump;
int mAsciiSeparator = 0;

enum ViewEnum_t
{
ViewHexAscii = 0,
ViewHexUnicode,
ViewTextAscii,
ViewTextUnicode,
ViewIntegerSignedShort,
ViewIntegerSignedLong,
ViewIntegerSignedLongLong,
ViewIntegerUnsignedShort,
ViewIntegerUnsignedLong,
ViewIntegerUnsignedLongLong,
ViewIntegerHexShort,
ViewIntegerHexLong,
ViewIntegerHexLongLong,
ViewFloatFloat,
ViewFloatDouble,
ViewFloatLongDouble,
ViewAddress,
ViewIntegerSignedByte,
ViewIntegerUnsignedByte,
ViewAddressAscii,
ViewAddressUnicode,
ViewHexCodepage,
ViewTextCodepage
};

void setView(ViewEnum_t view);
};
45 changes: 44 additions & 1 deletion src/gui/Src/Tracer/TraceFileDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TraceFileDump::~TraceFileDump()

void TraceFileDump::clear()
{
maxIndex = 0;
maxIndex = 0ull;
dump.clear();
}

Expand Down Expand Up @@ -150,3 +150,46 @@ void TraceFileDump::findMemAreas()
}
while(true);
}

// TraceFileDumpMemoryPage
TraceFileDumpMemoryPage::TraceFileDumpMemoryPage(QObject* parent) : MemoryPage(0, 0, parent)
{
dump = nullptr;
}

void TraceFileDumpMemoryPage::setSelectedIndex(unsigned long long index)
{
if(dump)
selectedIndex = std::min(index, dump->getMaxIndex());
else
selectedIndex = 0ull;
}

void TraceFileDumpMemoryPage::setDumpObject(TraceFileDump* dump)
{
this->dump = dump;
}

bool TraceFileDumpMemoryPage::isAvailable() const
{
return !!this->dump;
}

unsigned long long TraceFileDumpMemoryPage::getSelectedIndex() const
{
return selectedIndex;
}

bool TraceFileDumpMemoryPage::read(void* parDest, dsint parRVA, duint parSize) const
{
if(!dump)
return false;
auto buffer = dump->getBytes(mBase + parRVA, parSize, selectedIndex);
memcpy(parDest, buffer.data(), parSize);
return true;
}

bool TraceFileDumpMemoryPage::write(const void* parDest, dsint parRVA, duint parSize)
{
return false; // write is not supported
}
17 changes: 17 additions & 0 deletions src/gui/Src/Tracer/TraceFileDump.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Imports.h"
#include <map>
#include "MemoryPage.h"

class TraceFileDump
{
Expand Down Expand Up @@ -49,3 +50,19 @@ class TraceFileDump
std::map<Key, DumpRecord> dump;
unsigned long long maxIndex;
};

class TraceFileDumpMemoryPage : public MemoryPage
{
Q_OBJECT
public:
TraceFileDumpMemoryPage(QObject* parent = 0);
virtual bool read(void* parDest, dsint parRVA, duint parSize) const override;
virtual bool write(const void* parDest, dsint parRVA, duint parSize) override;
void setSelectedIndex(unsigned long long index);
unsigned long long getSelectedIndex() const;
void setDumpObject(TraceFileDump* dump);
bool isAvailable() const;
private:
TraceFileDump* dump;
unsigned long long selectedIndex = 0ull;
};
5 changes: 5 additions & 0 deletions src/gui/Src/Tracer/TraceFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ unsigned long long TraceFileReader::Length() const
return length;
}

TraceFileDump* TraceFileReader::getDump()
{
return &dump;
}

QString TraceFileReader::getIndexText(unsigned long long index) const
{
QString indexString;
Expand Down
1 change: 1 addition & 0 deletions src/gui/Src/Tracer/TraceFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TraceFileReader : public QObject
void buildDumpTo(unsigned long long index);
std::vector<unsigned long long> getReferences(duint startAddr, duint endAddr) const;
void debugdump(unsigned long long index);
TraceFileDump* getDump();

signals:
void parseFinished();
Expand Down
14 changes: 13 additions & 1 deletion src/gui/Src/Tracer/TraceWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui_TraceWidget.h"
#include "TraceBrowser.h"
#include "TraceInfoBox.h"
#include "TraceDump.h"
#include "TraceFileReader.h"
#include "TraceRegisters.h"
#include "StdTable.h"
Expand All @@ -16,6 +17,8 @@ TraceWidget::TraceWidget(QWidget* parent) :
mTraceWidget = new TraceBrowser(this);
mOverview = new StdTable(this);
mInfo = new TraceInfoBox(this);
mMemoryPage = new TraceFileDumpMemoryPage(this);
mDump = new TraceDump(mTraceWidget, mMemoryPage, this);
mGeneralRegs = new TraceRegisters(this);
//disasm
ui->mTopLeftUpperRightFrameLayout->addWidget(mTraceWidget);
Expand Down Expand Up @@ -44,7 +47,12 @@ TraceWidget::TraceWidget(QWidget* parent) :
ui->mTopHSplitter->setCollapsible(1, true); // allow collapsing the RegisterView

//info
ui->mTopLeftLowerFrameLayout->addWidget(mInfo);
//ui->mTopLeftLowerFrameLayout->addWidget(mInfo);
ui->mTopLeftUpperRightFrameLayout->addWidget(mInfo);

//dump
ui->mTopLeftLowerFrameLayout->addWidget(mDump);

int height = (mInfo->getRowHeight() + 1) * 4;
ui->mTopLeftLowerFrame->setMinimumHeight(height + 2);
ui->mTopHSplitter->setSizes(QList<int>({1000, 1}));
Expand Down Expand Up @@ -80,10 +88,14 @@ void TraceWidget::traceSelectionChanged(unsigned long long selection)
{
registers = traceFile->Registers(selection);
mInfo->update(selection, traceFile, registers);
traceFile->buildDumpTo(selection);
mMemoryPage->setDumpObject(traceFile->getDump());
}
else
memset(&registers, 0, sizeof(registers));
}
else
mMemoryPage->setDumpObject(nullptr);
mGeneralRegs->setRegisters(&registers);
}

Expand Down
4 changes: 4 additions & 0 deletions src/gui/Src/Tracer/TraceWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class CPUWidget;
class TraceRegisters;
class TraceBrowser;
class TraceFileReader;
class TraceFileDumpMemoryPage;
class TraceInfoBox;
class TraceDump;
class StdTable;

namespace Ui
Expand All @@ -33,7 +35,9 @@ protected slots:
protected:
TraceBrowser* mTraceWidget;
TraceInfoBox* mInfo;
TraceDump* mDump;
TraceRegisters* mGeneralRegs;
TraceFileDumpMemoryPage* mMemoryPage;
StdTable* mOverview;

private:
Expand Down

0 comments on commit 8d6f503

Please sign in to comment.