Skip to content

Commit e7715db

Browse files
committed
WIP
1 parent dcbe4e1 commit e7715db

File tree

5 files changed

+69
-26
lines changed

5 files changed

+69
-26
lines changed

src/gui/Src/BasicView/Disassembly.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,10 +1436,12 @@ void Disassembly::expandSelectionUpTo(dsint to)
14361436
if(to < mSelection.firstSelectedIndex)
14371437
{
14381438
mSelection.fromIndex = to;
1439+
emit selectionChanged(mSelection.fromIndex);
14391440
}
14401441
else if(to > mSelection.firstSelectedIndex)
14411442
{
14421443
mSelection.toIndex = to;
1444+
emit selectionChanged(mSelection.fromIndex);
14431445
}
14441446
else if(to == mSelection.firstSelectedIndex)
14451447
{
@@ -1484,6 +1486,11 @@ void Disassembly::selectionChangedSlot(dsint Va)
14841486
}
14851487
if(DbgIsDebugging())
14861488
DbgXrefGet(Va, &mXrefInfo);
1489+
1490+
SELECTIONDATA sel;
1491+
sel.start = rvaToVa(mSelection.fromIndex);
1492+
sel.end = rvaToVa(mSelection.toIndex);
1493+
Bridge::getBridge()->selectionSet(GUI_DISASSEMBLY, sel);
14871494
}
14881495

14891496
void Disassembly::selectNext(bool expand)

src/gui/Src/Bridge/Bridge.cpp

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ static Bridge* mBridge;
1818
Bridge::Bridge(QObject* parent) : QObject(parent)
1919
{
2020
InitializeCriticalSection(&csBridge);
21+
InitializeCriticalSection(&csSelection);
2122
hResultEvent = CreateEventW(nullptr, true, true, nullptr);;
2223
dwMainThreadId = GetCurrentThreadId();
2324
}
2425

2526
Bridge::~Bridge()
2627
{
2728
CloseHandle(hResultEvent);
29+
EnterCriticalSection(&csSelection);
30+
DeleteCriticalSection(&csSelection);
2831
EnterCriticalSection(&csBridge);
2932
DeleteCriticalSection(&csBridge);
3033
}
@@ -83,6 +86,26 @@ void Bridge::setDbgStopped()
8386
dbgStopped = true;
8487
}
8588

89+
void Bridge::selectionSet(int window, const SELECTIONDATA & data)
90+
{
91+
if(window >= 0 && window < _countof(mSelections))
92+
{
93+
EnterCriticalSection(&csSelection);
94+
memcpy(&mSelections[window], &data, sizeof(SELECTIONDATA));
95+
LeaveCriticalSection(&csSelection);
96+
}
97+
}
98+
99+
void Bridge::selectionGet(int window, SELECTIONDATA & data)
100+
{
101+
if(window >= 0 && window < _countof(mSelections))
102+
{
103+
EnterCriticalSection(&csSelection);
104+
memcpy(&data, &mSelections[window], sizeof(SELECTIONDATA));
105+
LeaveCriticalSection(&csSelection);
106+
}
107+
}
108+
86109
/************************************************************************************
87110
Message processing
88111
************************************************************************************/
@@ -375,31 +398,38 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
375398
SELECTIONDATA* selection = (SELECTIONDATA*)param2;
376399
if(!DbgIsDebugging())
377400
return (void*)false;
378-
BridgeResult result;
379-
switch(hWindow)
401+
if(hWindow == GUI_DISASSEMBLY)
380402
{
381-
case GUI_DISASSEMBLY:
382-
emit selectionDisasmGet(selection);
383-
break;
384-
case GUI_DUMP:
385-
emit selectionDumpGet(selection);
386-
break;
387-
case GUI_STACK:
388-
emit selectionStackGet(selection);
389-
break;
390-
case GUI_GRAPH:
391-
emit selectionGraphGet(selection);
392-
break;
393-
case GUI_MEMMAP:
394-
emit selectionMemmapGet(selection);
395-
break;
396-
case GUI_SYMMOD:
397-
emit selectionSymmodGet(selection);
398-
break;
399-
default:
400-
return (void*)false;
403+
selectionGet(hWindow, *selection);
404+
}
405+
else
406+
{
407+
BridgeResult result;
408+
switch(hWindow)
409+
{
410+
case GUI_DISASSEMBLY:
411+
emit selectionDisasmGet(selection);
412+
break;
413+
case GUI_DUMP:
414+
emit selectionDumpGet(selection);
415+
break;
416+
case GUI_STACK:
417+
emit selectionStackGet(selection);
418+
break;
419+
case GUI_GRAPH:
420+
emit selectionGraphGet(selection);
421+
break;
422+
case GUI_MEMMAP:
423+
emit selectionMemmapGet(selection);
424+
break;
425+
case GUI_SYMMOD:
426+
emit selectionSymmodGet(selection);
427+
break;
428+
default:
429+
return (void*)false;
430+
}
431+
result.Wait();
401432
}
402-
result.Wait();
403433
if(selection->start > selection->end) //swap start and end
404434
{
405435
dsint temp = selection->end;

src/gui/Src/Bridge/Bridge.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class Bridge : public QObject
4747
duint mLastCip = 0;
4848
SymbolView* symbolView = nullptr;
4949

50+
//Selection helpers
51+
void selectionSet(int window, const SELECTIONDATA & data);
52+
void selectionGet(int window, SELECTIONDATA & data);
53+
5054
signals:
5155
void disassembleAt(dsint va, dsint eip);
5256
void updateDisassembly();
@@ -169,6 +173,8 @@ class Bridge : public QObject
169173
DWORD dwMainThreadId = 0;
170174
dsint bridgeResult = 0;
171175
volatile bool dbgStopped = false;
176+
CRITICAL_SECTION csSelection;
177+
SELECTIONDATA mSelections[GUI_SYMMOD + 1];
172178
};
173179

174180
void DbgCmdExec(const QString & cmd);

src/gui/Src/Gui/CPUDisassembly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ CPUDisassembly::CPUDisassembly(CPUWidget* parent) : Disassembly(parent)
4141
connect(Bridge::getBridge(), SIGNAL(disassembleAt(dsint, dsint)), this, SLOT(disassembleAt(dsint, dsint)));
4242
connect(Bridge::getBridge(), SIGNAL(selectionDisasmGet(SELECTIONDATA*)), this, SLOT(selectionGetSlot(SELECTIONDATA*)));
4343
connect(Bridge::getBridge(), SIGNAL(selectionDisasmSet(const SELECTIONDATA*)), this, SLOT(selectionSetSlot(const SELECTIONDATA*)));
44-
connect(this, SIGNAL(selectionExpanded()), this, SLOT(selectionUpdatedSlot()));
44+
connect(this, SIGNAL(selectionExpanded()), this, SLOT(selectionExpandedSlot()));
4545
connect(Bridge::getBridge(), SIGNAL(displayWarning(QString, QString)), this, SLOT(displayWarningSlot(QString, QString)));
4646
connect(Bridge::getBridge(), SIGNAL(focusDisasm()), this, SLOT(setFocus()));
4747

@@ -1297,7 +1297,7 @@ void CPUDisassembly::selectionSetSlot(const SELECTIONDATA* selection)
12971297
Bridge::getBridge()->setResult(1);
12981298
}
12991299

1300-
void CPUDisassembly::selectionUpdatedSlot()
1300+
void CPUDisassembly::selectionExpandedSlot()
13011301
{
13021302
QString selStart = ToPtrString(rvaToVa(getSelectionStart()));
13031303
QString selEnd = ToPtrString(rvaToVa(getSelectionEnd()));

src/gui/Src/Gui/CPUDisassembly.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public slots:
6868
void findNamesSlot();
6969
void selectionGetSlot(SELECTIONDATA* selection);
7070
void selectionSetSlot(const SELECTIONDATA* selection);
71-
void selectionUpdatedSlot();
71+
void selectionExpandedSlot();
7272
void enableHighlightingModeSlot();
7373
void binaryEditSlot();
7474
void binaryFillSlot();

0 commit comments

Comments
 (0)