@@ -189,6 +189,47 @@ static void MakeCodeHelper(BinaryView* view, BNAddressRange selection)
189189 view->UpdateAnalysis ();
190190}
191191
192+ void GlobalDebuggerUI::GetAddressRange (const UIActionContext& ctxt, uint64_t & startAddr, uint64_t & endAddr)
193+ {
194+ if (ctxt.view && ctxt.view ->getSelectionOffsets ().start != ctxt.view ->getSelectionOffsets ().end )
195+ {
196+ // Use selection range
197+ auto selection = ctxt.view ->getSelectionOffsets ();
198+ startAddr = selection.start ;
199+ endAddr = selection.end ;
200+ }
201+ else
202+ {
203+ // Use current address, default to 4 bytes
204+ startAddr = ctxt.address ;
205+ endAddr = ctxt.address + 4 ;
206+ }
207+ }
208+
209+ void GlobalDebuggerUI::QueryTTDMemoryAccess (const UIActionContext& ctxt, uint64_t startAddr, uint64_t endAddr, BNDebuggerTTDMemoryAccessType accessType)
210+ {
211+ // Focus the TTD Memory sidebar widget
212+ auto mainWindow = ctxt.context ->mainWindow ();
213+ if (mainWindow)
214+ {
215+ auto sidebar = mainWindow->sidebar ();
216+ if (sidebar)
217+ {
218+ sidebar->activateWidget (" TTD Memory" );
219+ }
220+ }
221+
222+ // Get the TTD Memory widget and perform the query
223+ auto controller = DebuggerController::GetController (ctxt.binaryView );
224+ if (!controller)
225+ return ;
226+
227+ // Find the TTD Memory widget instance and trigger a query
228+ // This is a simplified approach - in a complete implementation,
229+ // we would need to access the widget and set its parameters
230+ LogInfo (" TTD Memory Access query: 0x%llx-0x%llx, access type: %d" , startAddr, endAddr, accessType);
231+ }
232+
192233
193234void GlobalDebuggerUI::SetupMenu (UIContext* context)
194235{
@@ -249,6 +290,18 @@ void GlobalDebuggerUI::SetupMenu(UIContext* context)
249290 return controller->IsConnected () && (!controller->IsRunning ()) && controller->IsTTD ();
250291 };
251292
293+ auto connectedToTTD = [=](const UIActionContext& ctxt) {
294+ if (!ctxt.binaryView )
295+ return false ;
296+ if (!DebuggerController::ControllerExists (ctxt.binaryView ))
297+ return false ;
298+ auto controller = DebuggerController::GetController (ctxt.binaryView );
299+ if (!controller)
300+ return false ;
301+
302+ return controller->IsConnected () && controller->IsTTD ();
303+ };
304+
252305 auto connectedAndRunning = [=](const UIActionContext& ctxt) {
253306 if (!ctxt.binaryView )
254307 return false ;
@@ -894,6 +947,97 @@ void GlobalDebuggerUI::SetupMenu(UIContext* context)
894947 UIAction (
895948 [=](const UIActionContext& ctxt) { installTTD (ctxt); }));
896949 debuggerMenu->addAction (" Install WinDbg/TTD" , " TTD" );
950+
951+ // TTD Memory Access context menu items
952+ UIAction::registerAction (" TTD Memory Access\\ Read" );
953+ context->globalActions ()->bindAction (" TTD Memory Access\\ Read" ,
954+ UIAction (
955+ [=](const UIActionContext& ctxt) {
956+ if (!ctxt.binaryView )
957+ return ;
958+
959+ auto controller = DebuggerController::GetController (ctxt.binaryView );
960+ if (!controller || !controller->IsConnected ())
961+ return ;
962+
963+ uint64_t startAddr, endAddr;
964+ GetAddressRange (ctxt, startAddr, endAddr);
965+ QueryTTDMemoryAccess (ctxt, startAddr, endAddr, BNDebuggerTTDMemoryRead);
966+ },
967+ connectedToTTD));
968+ debuggerMenu->addAction (" TTD Memory Access\\ Read" , " TTD" );
969+
970+ UIAction::registerAction (" TTD Memory Access\\ Write" );
971+ context->globalActions ()->bindAction (" TTD Memory Access\\ Write" ,
972+ UIAction (
973+ [=](const UIActionContext& ctxt) {
974+ if (!ctxt.binaryView )
975+ return ;
976+
977+ auto controller = DebuggerController::GetController (ctxt.binaryView );
978+ if (!controller || !controller->IsConnected ())
979+ return ;
980+
981+ uint64_t startAddr, endAddr;
982+ GetAddressRange (ctxt, startAddr, endAddr);
983+ QueryTTDMemoryAccess (ctxt, startAddr, endAddr, BNDebuggerTTDMemoryWrite);
984+ },
985+ connectedToTTD));
986+ debuggerMenu->addAction (" TTD Memory Access\\ Write" , " TTD" );
987+
988+ UIAction::registerAction (" TTD Memory Access\\ Read/Write" );
989+ context->globalActions ()->bindAction (" TTD Memory Access\\ Read/Write" ,
990+ UIAction (
991+ [=](const UIActionContext& ctxt) {
992+ if (!ctxt.binaryView )
993+ return ;
994+
995+ auto controller = DebuggerController::GetController (ctxt.binaryView );
996+ if (!controller || !controller->IsConnected ())
997+ return ;
998+
999+ uint64_t startAddr, endAddr;
1000+ GetAddressRange (ctxt, startAddr, endAddr);
1001+ QueryTTDMemoryAccess (ctxt, startAddr, endAddr, static_cast <BNDebuggerTTDMemoryAccessType>(BNDebuggerTTDMemoryRead | BNDebuggerTTDMemoryWrite));
1002+ },
1003+ connectedToTTD));
1004+ debuggerMenu->addAction (" TTD Memory Access\\ Read/Write" , " TTD" );
1005+
1006+ UIAction::registerAction (" TTD Memory Access\\ Execute" );
1007+ context->globalActions ()->bindAction (" TTD Memory Access\\ Execute" ,
1008+ UIAction (
1009+ [=](const UIActionContext& ctxt) {
1010+ if (!ctxt.binaryView )
1011+ return ;
1012+
1013+ auto controller = DebuggerController::GetController (ctxt.binaryView );
1014+ if (!controller || !controller->IsConnected ())
1015+ return ;
1016+
1017+ uint64_t startAddr, endAddr;
1018+ GetAddressRange (ctxt, startAddr, endAddr);
1019+ QueryTTDMemoryAccess (ctxt, startAddr, endAddr, BNDebuggerTTDMemoryExecute);
1020+ },
1021+ connectedToTTD));
1022+ debuggerMenu->addAction (" TTD Memory Access\\ Execute" , " TTD" );
1023+
1024+ UIAction::registerAction (" TTD Memory Access\\ Read/Write/Execute" );
1025+ context->globalActions ()->bindAction (" TTD Memory Access\\ Read/Write/Execute" ,
1026+ UIAction (
1027+ [=](const UIActionContext& ctxt) {
1028+ if (!ctxt.binaryView )
1029+ return ;
1030+
1031+ auto controller = DebuggerController::GetController (ctxt.binaryView );
1032+ if (!controller || !controller->IsConnected ())
1033+ return ;
1034+
1035+ uint64_t startAddr, endAddr;
1036+ GetAddressRange (ctxt, startAddr, endAddr);
1037+ QueryTTDMemoryAccess (ctxt, startAddr, endAddr, static_cast <BNDebuggerTTDMemoryAccessType>(BNDebuggerTTDMemoryRead | BNDebuggerTTDMemoryWrite | BNDebuggerTTDMemoryExecute));
1038+ },
1039+ connectedToTTD));
1040+ debuggerMenu->addAction (" TTD Memory Access\\ Read/Write/Execute" , " TTD" );
8971041#endif
8981042}
8991043
0 commit comments