Skip to content

Commit f7602db

Browse files
committed
Merged mrexodia/x64_dbg into master
2 parents 9dcef6a + c2ebac0 commit f7602db

File tree

5 files changed

+83
-98
lines changed

5 files changed

+83
-98
lines changed

x64_dbg_dbg/debugger.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,8 +1684,6 @@ bool dbgsetpagerights(uint* addr, char* rights_string)
16841684
if(VirtualProtectEx(fdProcessInfo->hProcess, (void*)*addr, PAGE_SIZE, protect, & old_protect) == 0)
16851685
return false;
16861686

1687-
// ADD ME: CALL TO UPDATE MEMORY VIEW HERE :-)
1688-
16891687
return true;
16901688
}
16911689

x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp

Lines changed: 74 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -201,84 +201,87 @@ QString MemoryMapView::paintContent(QPainter* painter, int_t rowBase, int rowOff
201201
return StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
202202
}
203203

204-
void MemoryMapView::stateChangedSlot(DBGSTATE state)
204+
void MemoryMapView::refreshMap()
205205
{
206-
if(state == paused)
206+
MEMMAP wMemMapStruct;
207+
int wI;
208+
209+
memset(&wMemMapStruct, 0, sizeof(MEMMAP));
210+
211+
DbgMemMap(&wMemMapStruct);
212+
213+
setRowCount(wMemMapStruct.count);
214+
215+
for(wI = 0; wI < wMemMapStruct.count; wI++)
207216
{
208-
MEMMAP wMemMapStruct;
209-
int wI;
217+
QString wS;
218+
MEMORY_BASIC_INFORMATION wMbi = (wMemMapStruct.page)[wI].mbi;
210219

211-
memset(&wMemMapStruct, 0, sizeof(MEMMAP));
220+
// Base address
221+
wS = QString("%1").arg((uint_t)wMbi.BaseAddress, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
222+
setCellContent(wI, 0, wS);
212223

213-
DbgMemMap(&wMemMapStruct);
224+
// Size
225+
wS = QString("%1").arg((uint_t)wMbi.RegionSize, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
226+
setCellContent(wI, 1, wS);
214227

215-
setRowCount(wMemMapStruct.count);
228+
// Information
229+
wS = QString((wMemMapStruct.page)[wI].info);
230+
setCellContent(wI, 2, wS);
216231

217-
for(wI = 0; wI < wMemMapStruct.count; wI++)
232+
// State
233+
switch(wMbi.State)
218234
{
219-
QString wS;
220-
MEMORY_BASIC_INFORMATION wMbi = (wMemMapStruct.page)[wI].mbi;
221-
222-
// Base address
223-
wS = QString("%1").arg((uint_t)wMbi.BaseAddress, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
224-
setCellContent(wI, 0, wS);
225-
226-
// Size
227-
wS = QString("%1").arg((uint_t)wMbi.RegionSize, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
228-
setCellContent(wI, 1, wS);
229-
230-
// Information
231-
wS = QString((wMemMapStruct.page)[wI].info);
232-
setCellContent(wI, 2, wS);
233-
234-
// State
235-
switch(wMbi.State)
236-
{
237-
case MEM_FREE:
238-
wS = QString("FREE");
239-
break;
240-
case MEM_COMMIT:
241-
wS = QString("COMM");
242-
break;
243-
case MEM_RESERVE:
244-
wS = QString("RESV");
245-
break;
246-
default:
247-
wS = QString("????");
248-
}
249-
setCellContent(wI, 3, wS);
250-
251-
// Type
252-
switch(wMbi.Type)
253-
{
254-
case MEM_IMAGE:
255-
wS = QString("IMG");
256-
break;
257-
case MEM_MAPPED:
258-
wS = QString("MAP");
259-
break;
260-
case MEM_PRIVATE:
261-
wS = QString("PRV");
262-
break;
263-
default:
264-
wS = QString("N/A");
265-
break;
266-
}
267-
setCellContent(wI, 3, wS);
268-
269-
// current access protection
270-
wS = getProtectionString(wMbi.Protect);
271-
setCellContent(wI, 4, wS);
272-
273-
// allocation protection
274-
wS = getProtectionString(wMbi.AllocationProtect);
275-
setCellContent(wI, 5, wS);
235+
case MEM_FREE:
236+
wS = QString("FREE");
237+
break;
238+
case MEM_COMMIT:
239+
wS = QString("COMM");
240+
break;
241+
case MEM_RESERVE:
242+
wS = QString("RESV");
243+
break;
244+
default:
245+
wS = QString("????");
246+
}
247+
setCellContent(wI, 3, wS);
276248

249+
// Type
250+
switch(wMbi.Type)
251+
{
252+
case MEM_IMAGE:
253+
wS = QString("IMG");
254+
break;
255+
case MEM_MAPPED:
256+
wS = QString("MAP");
257+
break;
258+
case MEM_PRIVATE:
259+
wS = QString("PRV");
260+
break;
261+
default:
262+
wS = QString("N/A");
263+
break;
277264
}
278-
if(wMemMapStruct.page != 0)
279-
BridgeFree(wMemMapStruct.page);
280-
reloadData(); //refresh memory map
265+
setCellContent(wI, 3, wS);
266+
267+
// current access protection
268+
wS = getProtectionString(wMbi.Protect);
269+
setCellContent(wI, 4, wS);
270+
271+
// allocation protection
272+
wS = getProtectionString(wMbi.AllocationProtect);
273+
setCellContent(wI, 5, wS);
274+
281275
}
276+
if(wMemMapStruct.page != 0)
277+
BridgeFree(wMemMapStruct.page);
278+
reloadData(); //refresh memory map
279+
}
280+
281+
void MemoryMapView::stateChangedSlot(DBGSTATE state)
282+
{
283+
if(state == paused)
284+
refreshMap();
282285
}
283286

284287
void MemoryMapView::followDumpSlot()
@@ -353,21 +356,11 @@ void MemoryMapView::memoryExecuteSingleshootToggleSlot()
353356

354357
void MemoryMapView::pageMemoryRights()
355358
{
356-
PageMemoryRights* mPageMemoryRightsDialog = new PageMemoryRights(this);
357-
358-
#ifdef _WIN64
359+
PageMemoryRights PageMemoryRightsDialog(this);
360+
connect(&PageMemoryRightsDialog, SIGNAL(refreshMemoryMap()), this, SLOT(refreshMap()));
359361
uint_t addr = getCellContent(getInitialSelection(), 0).toULongLong(0, 16);
360-
#else //x86
361-
uint_t addr = getCellContent(getInitialSelection(), 0).toULong(0, 16);
362-
#endif //_WIN64
363-
364-
#ifdef _WIN64
365362
uint_t size = getCellContent(getInitialSelection(), 1).toULongLong(0, 16);
366-
#else //x86
367-
uint_t size = getCellContent(getInitialSelection(), 1).toULong(0, 16);
368-
#endif //_WIN64
369-
370-
mPageMemoryRightsDialog->RunAddrSize(addr, size, getCellContent(getInitialSelection(), 3));
363+
PageMemoryRightsDialog.RunAddrSize(addr, size, getCellContent(getInitialSelection(), 3));
371364
}
372365

373366
void MemoryMapView::switchView()

x64_dbg_gui/Project/Src/Gui/MemoryMapView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public slots:
3333
void contextMenuSlot(const QPoint & pos);
3434
void switchView();
3535
void pageMemoryRights();
36+
void refreshMap();
3637

3738
private:
3839
QString getProtectionString(DWORD Protect);

x64_dbg_gui/Project/Src/Gui/PageMemoryRights.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#include "PageMemoryRights.h"
22
#include "ui_PageMemoryRights.h"
3-
#include <string>
43

5-
PageMemoryRights::PageMemoryRights(QWidget* parent) :
6-
QDialog(parent),
7-
ui(new Ui::PageMemoryRights)
4+
PageMemoryRights::PageMemoryRights(QWidget* parent) : QDialog(parent), ui(new Ui::PageMemoryRights)
85
{
96
ui->setupUi(this);
107
//set window flags
@@ -25,11 +22,9 @@ void PageMemoryRights::RunAddrSize(uint_t addrin, uint_t sizein, QString pagetyp
2522

2623
QTableWidget* tableWidget = ui->pagetableWidget;
2724
tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
28-
2925
uint_t nr_pages = size / PAGE_SIZE;
3026
tableWidget->setColumnCount(2);
3127
tableWidget->setRowCount(nr_pages);
32-
3328
tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString("Address")));
3429
tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString("Rights")));
3530

@@ -44,7 +39,6 @@ void PageMemoryRights::RunAddrSize(uint_t addrin, uint_t sizein, QString pagetyp
4439
tableWidget->setItem(i, 1, new QTableWidgetItem(QString(rights)));
4540
}
4641

47-
4842
QModelIndex idx = (ui->pagetableWidget->model()->index(0, 0));
4943
ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
5044
idx = (ui->pagetableWidget->model()->index(0, 1));
@@ -53,11 +47,8 @@ void PageMemoryRights::RunAddrSize(uint_t addrin, uint_t sizein, QString pagetyp
5347
ui->radioFullaccess->setChecked(true);
5448
ui->chkPageguard->setCheckable(true);
5549
exec();
56-
5750
}
5851

59-
60-
6152
void PageMemoryRights::on_btnSelectall_clicked()
6253
{
6354
for(int i = 0; i < ui->pagetableWidget->rowCount(); i++)
@@ -117,16 +108,17 @@ void PageMemoryRights::on_btnSetrights_clicked()
117108
#else //x86
118109
actual_addr = ui->pagetableWidget->item(index.row(), 0)->text().toULong(0, 16);
119110
#endif //_WIN64
120-
121-
if(DbgFunctions()->SetPageRights(& actual_addr, (char*) rights.toStdString().c_str()))
111+
if(DbgFunctions()->SetPageRights(& actual_addr, (char*) rights.toUtf8().constData()))
122112
{
123113
one_right_changed = true;
124114
if(DbgFunctions()->GetPageRights(& actual_addr, newrights))
125115
ui->pagetableWidget->setItem(index.row(), 1, new QTableWidgetItem(QString(newrights)));
126116
}
127-
128117
}
129118

119+
DbgFunctions()->MemUpdateMap();
120+
emit refreshMemoryMap();
121+
130122
if(one_right_changed)
131123
ui->LnEdStatus->setText("Pages Rights Changed to: " + rights);
132124
else

x64_dbg_gui/Project/Src/Gui/PageMemoryRights.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ class PageMemoryRights : public QDialog
2323

2424
private slots:
2525
void on_btnSelectall_clicked();
26-
2726
void on_btnDeselectall_clicked();
28-
2927
void on_btnSetrights_clicked();
3028

29+
signals:
30+
void refreshMemoryMap();
31+
3132
private:
3233
Ui::PageMemoryRights* ui;
3334
uint_t addr;

0 commit comments

Comments
 (0)