diff --git a/rizin b/rizin index e7f2c2a4..6fad1318 160000 --- a/rizin +++ b/rizin @@ -1 +1 @@ -Subproject commit e7f2c2a4305ff75bc3d4682a29c58bd12e73ee2a +Subproject commit 6fad1318d24968673e4092f9536e3e967147d081 diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index dfc2d7dc..f96e9395 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -1592,6 +1592,33 @@ QVector CutterCore::getHeapChunks(RVA arena_addr) return chunks_vector; } +QVector CutterCore::getHeapBlocks() +{ + CORE_LOCK(); + QVector blocks_vector; + RzList *blocks = rz_heap_windows_blocks_list(core); + if (!blocks || !rz_list_length(blocks)) { + rz_list_free(blocks); + return blocks_vector; + } + + RzListIter *iter; + RzWindowsHeapBlock *data; + CutterRListForeach(blocks, iter, RzWindowsHeapBlock, data) + { + HeapBlock block; + block.headerAddress = data->headerAddress; + block.userAddress = data->userAddress; + block.granularity = data->granularity; + block.unusedBytes = data->unusedBytes; + block.size = data->size; + block.type = QString(data->type); + + blocks_vector.append(block); + } + return blocks_vector; +} + int CutterCore::getArchBits() { CORE_LOCK(); diff --git a/src/core/Cutter.h b/src/core/Cutter.h index c9245b74..a2536e82 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -432,6 +432,7 @@ public: * @return true if the write succeeded else false */ bool writeHeapChunk(RzHeapChunkSimple *chunkSimple); + QVector getHeapBlocks(); int getArchBits(); void startDebug(); void startEmulation(); diff --git a/src/core/CutterDescriptions.h b/src/core/CutterDescriptions.h index cf0a4e1c..39c5daf1 100644 --- a/src/core/CutterDescriptions.h +++ b/src/core/CutterDescriptions.h @@ -388,7 +388,8 @@ struct HeapBlock RVA headerAddress; RVA userAddress; RVA size; - RVA unused_bytes; + RVA unusedBytes; + RVA granularity; QString type; }; diff --git a/src/widgets/WindowsHeapWidget.cpp b/src/widgets/WindowsHeapWidget.cpp index d2b0fc2b..b3428c97 100644 --- a/src/widgets/WindowsHeapWidget.cpp +++ b/src/widgets/WindowsHeapWidget.cpp @@ -12,6 +12,12 @@ WindowsHeapWidget::WindowsHeapWidget(MainWindow *main, QWidget *parent) // change the scroll mode to ScrollPerPixel viewHeap->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); viewHeap->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + + connect(Core(), &CutterCore::refreshAll, this, &WindowsHeapWidget::updateContents); + connect(Core(), &CutterCore::debugTaskStateChanged, this, &WindowsHeapWidget::updateContents); + + refreshDeferrer = dynamic_cast(parent)->createRefreshDeferrer( + [this]() { updateContents(); }); } WindowsHeapWidget::~WindowsHeapWidget() @@ -21,6 +27,10 @@ WindowsHeapWidget::~WindowsHeapWidget() void WindowsHeapWidget::updateContents() { + if (!refreshDeferrer->attemptRefresh(nullptr) || Core()->isDebugTaskInProgress()) { + return; + } + modelHeap->reload(); viewHeap->resizeColumnsToContents(); } @@ -89,6 +99,6 @@ void WindowsHeapModel::reload() { beginResetModel(); values.clear(); - // Call cutter core here for data + values = Core()->getHeapBlocks(); endResetModel(); } \ No newline at end of file diff --git a/src/widgets/WindowsHeapWidget.h b/src/widgets/WindowsHeapWidget.h index d87051ec..c0118740 100644 --- a/src/widgets/WindowsHeapWidget.h +++ b/src/widgets/WindowsHeapWidget.h @@ -40,6 +40,7 @@ private: Ui::WindowsHeapWidget *ui; QTableView *viewHeap; WindowsHeapModel *modelHeap = new WindowsHeapModel(this); + RefreshDeferrer *refreshDeferrer {}; }; #endif // WINDOWSHEAPWIDGET_H