mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-23 21:35:28 +00:00
convert to api for aoj
This commit is contained in:
parent
5f376f55db
commit
3d39cf625f
2
rizin
2
rizin
@ -1 +1 @@
|
|||||||
Subproject commit be48ddcd9f0c2023d0e64750426c0476a13d8589
|
Subproject commit a1c2ed18d762d3641e6690e0cb6b58b45f1c3609
|
@ -746,12 +746,32 @@ void CutterCore::delFlag(const QString &name)
|
|||||||
|
|
||||||
QString CutterCore::getInstructionBytes(RVA addr)
|
QString CutterCore::getInstructionBytes(RVA addr)
|
||||||
{
|
{
|
||||||
return cmdj("aoj @ " + RzAddressString(addr)).first()[RJsonKey::bytes].toString();
|
auto ret = (char *)Core()->returnAtSeek(
|
||||||
|
[&]() {
|
||||||
|
CORE_LOCK();
|
||||||
|
RzPVector *vec = rz_core_analysis_bytes(core, core->block, (int)core->blocksize, 1);
|
||||||
|
auto *ab = static_cast<RzAnalysisBytes *>(rz_pvector_head(vec));
|
||||||
|
char *str = strdup(ab->bytes);
|
||||||
|
rz_pvector_free(vec);
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
addr);
|
||||||
|
return fromOwnedCharPtr(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::getInstructionOpcode(RVA addr)
|
QString CutterCore::getInstructionOpcode(RVA addr)
|
||||||
{
|
{
|
||||||
return cmdj("aoj @ " + RzAddressString(addr)).first()[RJsonKey::opcode].toString();
|
auto ret = (char *)Core()->returnAtSeek(
|
||||||
|
[&]() {
|
||||||
|
CORE_LOCK();
|
||||||
|
RzPVector *vec = rz_core_analysis_bytes(core, core->block, (int)core->blocksize, 1);
|
||||||
|
auto *ab = static_cast<RzAnalysisBytes *>(rz_pvector_head(vec));
|
||||||
|
char *str = strdup(ab->opcode);
|
||||||
|
rz_pvector_free(vec);
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
addr);
|
||||||
|
return fromOwnedCharPtr(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::editInstruction(RVA addr, const QString &inst)
|
void CutterCore::editInstruction(RVA addr, const QString &inst)
|
||||||
@ -1358,7 +1378,19 @@ CutterJson CutterCore::getRegistersInfo()
|
|||||||
|
|
||||||
RVA CutterCore::getOffsetJump(RVA addr)
|
RVA CutterCore::getOffsetJump(RVA addr)
|
||||||
{
|
{
|
||||||
return cmdj("aoj @" + QString::number(addr)).first().toRVA();
|
auto rva = (RVA *)Core()->returnAtSeek(
|
||||||
|
[&]() {
|
||||||
|
CORE_LOCK();
|
||||||
|
RzPVector *vec = rz_core_analysis_bytes(core, core->block, (int)core->blocksize, 1);
|
||||||
|
auto *ab = static_cast<RzAnalysisBytes *>(rz_pvector_head(vec));
|
||||||
|
RVA *rva = new RVA(ab->op->jump);
|
||||||
|
rz_pvector_free(vec);
|
||||||
|
return rva;
|
||||||
|
},
|
||||||
|
addr);
|
||||||
|
RVA ret = *rva;
|
||||||
|
delete rva;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Decompiler *> CutterCore::getDecompilers()
|
QList<Decompiler *> CutterCore::getDecompilers()
|
||||||
|
@ -482,8 +482,15 @@ void DisassemblyContextMenu::setupRenaming()
|
|||||||
void DisassemblyContextMenu::aboutToShowSlot()
|
void DisassemblyContextMenu::aboutToShowSlot()
|
||||||
{
|
{
|
||||||
// check if set immediate base menu makes sense
|
// check if set immediate base menu makes sense
|
||||||
CutterJson instObject = Core()->cmdj("aoj @ " + QString::number(offset)).first();
|
RzPVector *vec = (RzPVector *)Core()->returnAtSeek(
|
||||||
bool immBase = instObject["val"].valid() || instObject["ptr"].valid();
|
[&]() {
|
||||||
|
RzCoreLocked core(Core());
|
||||||
|
return rz_core_analysis_bytes(core, core->block, (int)core->blocksize, 1);
|
||||||
|
},
|
||||||
|
offset);
|
||||||
|
auto *ab = static_cast<RzAnalysisBytes *>(rz_pvector_head(vec));
|
||||||
|
|
||||||
|
bool immBase = ab && ab->op && (ab->op->val || ab->op->ptr);
|
||||||
setBaseMenu->menuAction()->setVisible(immBase);
|
setBaseMenu->menuAction()->setVisible(immBase);
|
||||||
setBitsMenu->menuAction()->setVisible(true);
|
setBitsMenu->menuAction()->setVisible(true);
|
||||||
|
|
||||||
@ -491,8 +498,12 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
QString memBaseReg; // Base register
|
QString memBaseReg; // Base register
|
||||||
st64 memDisp = 0; // Displacement
|
st64 memDisp = 0; // Displacement
|
||||||
|
|
||||||
|
if (ab && ab->op) {
|
||||||
|
const char *opexstr = RZ_STRBUF_SAFEGET(&ab->op->opex);
|
||||||
|
CutterJson operands = Core()->parseJson(strdup(opexstr), nullptr);
|
||||||
|
|
||||||
// Loop through both the operands of the instruction
|
// Loop through both the operands of the instruction
|
||||||
for (const CutterJson operand : instObject["opex"]["operands"]) {
|
for (const CutterJson operand : operands) {
|
||||||
if (operand["type"].toString() == "mem" && !operand["base"].toString().contains("bp")
|
if (operand["type"].toString() == "mem" && !operand["base"].toString().contains("bp")
|
||||||
&& operand["disp"].toSt64() > 0) {
|
&& operand["disp"].toSt64() > 0) {
|
||||||
|
|
||||||
@ -502,6 +513,9 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
rz_pvector_free(vec);
|
||||||
|
|
||||||
if (memBaseReg.isEmpty()) {
|
if (memBaseReg.isEmpty()) {
|
||||||
// hide structure offset menu
|
// hide structure offset menu
|
||||||
structureOffsetMenu->menuAction()->setVisible(false);
|
structureOffsetMenu->menuAction()->setVisible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user