void MemoryViewWidget::OnContextMenu() { auto* menu = new QMenu(this); menu->addAction(tr("Copy Address"), this, &MemoryViewWidget::OnCopyAddress); auto* copy_hex = menu->addAction(tr("Copy Hex"), this, &MemoryViewWidget::OnCopyHex); copy_hex->setEnabled(Core::GetState() != Core::State::Uninitialized && PowerPC::HostIsRAMAddress(GetContextAddress())); menu->addSeparator(); menu->addAction(tr("Show in code"), this, [this] { emit ShowCode(GetContextAddress()); }); menu->addSeparator(); menu->addAction(tr("Toggle Breakpoint"), this, &MemoryViewWidget::ToggleBreakpoint); menu->exec(QCursor::pos()); }
//--------------------------------------------------------------------------- void __fastcall TFMain_11011981::lbUnitItemsDblClick(TObject *Sender) { int idx = -1, len, size, refCnt; WORD* uses; DWORD adr; char *tmpBuf; PInfoRec recN; MTypeInfo tInfo; String str; char tkName[32], typeName[1024]; if (lbUnitItems->ItemIndex == -1) return; String item = lbUnitItems->Items->Strings[lbUnitItems->ItemIndex]; //Xrefs? if (item[11] == '<' || item[11] == '?') sscanf(item.c_str() + 1, "%lX%s%s", &adr, tkName, typeName); else sscanf(item.c_str() + 1, "%lX%d%s%s", &adr, &refCnt, tkName, typeName); String name = String(tkName); if (SameText(name, "????")) { //Find end of unexplored Data int bytes = 1024, pos = Adr2Pos(adr); //Get first byte (use later for filtering code?data) BYTE db = *(Code + pos); FExplorer_11011981->tsCode->TabVisible = true; FExplorer_11011981->ShowCode(adr, bytes); FExplorer_11011981->tsData->TabVisible = true; FExplorer_11011981->ShowData(adr, bytes); FExplorer_11011981->tsString->TabVisible = true; FExplorer_11011981->ShowString(adr, 1024); FExplorer_11011981->tsText->TabVisible = false; FExplorer_11011981->WAlign = 0; FExplorer_11011981->btnDefCode->Enabled = true; if (IsFlagSet(cfCode, pos)) FExplorer_11011981->btnDefCode->Enabled = false; FExplorer_11011981->btnUndefCode->Enabled = false; if (IsFlagSet(cfCode | cfData, pos)) FExplorer_11011981->btnUndefCode->Enabled = true; if (IsValidCode(adr) != -1 && db >= 0xF) FExplorer_11011981->pc1->ActivePage = FExplorer_11011981->tsCode; else FExplorer_11011981->pc1->ActivePage = FExplorer_11011981->tsData; if (FExplorer_11011981->ShowModal() == mrOk) { switch (FExplorer_11011981->DefineAs) { case DEFINE_AS_CODE: recN = GetInfoRec(adr); if (!recN) recN = new InfoRec(pos, ikRefine); else if (recN->kind < ikRefine || recN->kind > ikFunc) { delete recN; recN = new InfoRec(pos, ikRefine); } //AnalyzeProcInitial(adr); AnalyzeProc1(adr, 0, 0, 0, false); AnalyzeProc2(adr, true, true); AnalyzeArguments(adr); AnalyzeProc2(adr, true, true); if (!ContainsUnexplored(GetUnit(adr))) ShowUnits(true); ShowUnitItems(GetUnit(adr), lbUnitItems->TopIndex, lbUnitItems->ItemIndex); ShowCode(adr, 0, -1, -1); break; case DEFINE_AS_STRING: break; } } return; } if (SameText(name, "<VMT>") && tsClassView->TabVisible) { ShowClassViewer(adr); return; } if (SameText(name, "<ResString>")) { FStringInfo_11011981->memStringInfo->Clear(); FStringInfo_11011981->Caption = "ResString"; recN = GetInfoRec(adr); FStringInfo_11011981->memStringInfo->Lines->Add(recN->rsInfo->value); FStringInfo_11011981->ShowModal(); return; } if (SameText(name, "<ShortString>") || SameText(name, "<AnsiString>") || SameText(name, "<WideString>") || SameText(name, "<PAnsiChar>") || SameText(name, "<PWideChar>")) { FStringInfo_11011981->memStringInfo->Clear(); FStringInfo_11011981->Caption = "String"; recN = GetInfoRec(adr); FStringInfo_11011981->memStringInfo->Lines->Add(recN->GetName()); FStringInfo_11011981->ShowModal(); return; } if (SameText(name, "<UString>")) { FStringInfo_11011981->memStringInfo->Clear(); FStringInfo_11011981->Caption = "String"; recN = GetInfoRec(adr); len = wcslen((wchar_t*)(Code + Adr2Pos(adr))); size = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)(Code + Adr2Pos(adr)), len, 0, 0, 0, 0); if (size) { tmpBuf = new char[size + 1]; WideCharToMultiByte(CP_ACP, 0, (wchar_t*)(Code + Adr2Pos(adr)), len, tmpBuf, len, 0, 0); FStringInfo_11011981->memStringInfo->Lines->Add(String(tmpBuf, len)); delete[] tmpBuf; FStringInfo_11011981->ShowModal(); } return; } if (SameText(name, "<Integer>") || SameText(name, "<Char>") || SameText(name, "<Enumeration>") || SameText(name, "<Float>") || SameText(name, "<Set>") || SameText(name, "<Class>") || SameText(name, "<Method>") || SameText(name, "<WChar>") || SameText(name, "<Array>") || SameText(name, "<Record>") || SameText(name, "<Interface>") || SameText(name, "<Int64>") || SameText(name, "<DynArray>") || SameText(name, "<ClassRef>") || SameText(name, "<Pointer>") || SameText(name, "<Procedure>")) { uses = KnowledgeBase.GetTypeUses(typeName); idx = KnowledgeBase.GetTypeIdxByModuleIds(uses, typeName); if (uses) delete[] uses; if (idx != -1) { idx = KnowledgeBase.TypeOffsets[idx].NamId; if (KnowledgeBase.GetTypeInfo(idx, INFO_FIELDS | INFO_PROPS | INFO_METHODS, &tInfo)) { FTypeInfo_11011981->ShowKbInfo(&tInfo); //as delete tInfo; } } else { FTypeInfo_11011981->ShowRTTI(adr); } return; } if (SameText(name, "<Proc>") || SameText(name, "<Func>") || SameText(name, "<Constructor>") || SameText(name, "<Destructor>") || SameText(name, "<EmbProc>") || SameText(name, "<EmbFunc>") || SameText(name, "<Emb?>") || SameText(name, "<ImpProc>") || SameText(name, "<ExpProc>") || SameText(name, "<ImpFunc>") || SameText(name, "<ExpFunc>") || SameText(name, "<Imp?>") || SameText(name, "<Exp?>") || SameText(name, "<?>")) { PROCHISTORYREC rec; rec.adr = CurProcAdr; rec.itemIdx = lbCode->ItemIndex; rec.xrefIdx = lbCXrefs->ItemIndex; rec.topIdx = lbCode->TopIndex; ShowCode(adr, 0, -1, -1); CodeHistoryPush(&rec); pcWorkArea->ActivePage = tsCodeView; } }