MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / GetInstructionText

Method GetInstructionText

arch/powerpc/arch_ppc.cpp:519–644  ·  view source on GitHub ↗

populate the vector result with InstructionTextToken */

Source from the content-addressed store, hash-verified

517
518 */
519 virtual bool GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len, vector<InstructionTextToken>& result) override
520 {
521 bool rc = false;
522 bool capstoneWorkaround = false;
523 char buf[32];
524 size_t strlenMnem;
525 struct decomp_result res;
526 struct cs_insn *insn = &(res.insn);
527 struct cs_detail *detail = &(res.detail);
528 struct cs_ppc *ppc = &(detail->ppc);
529
530 //MYLOG("%s()\n", __func__);
531
532 if (len < 4) {
533 MYLOG("ERROR: need at least 4 bytes\n");
534 goto cleanup;
535 }
536
537 if (DoesQualifyForLocalDisassembly(data, endian == BigEndian))
538 {
539 // PerformLocalDisassembly(data, addr, len, &res, endian == BigEndian);
540 return PrintLocalDisassembly(data, addr, len, result, &res);
541 }
542 if(powerpc_decompose(data, 4, addr, endian == LittleEndian, &res, GetAddressSize() == 8, cs_mode_local)) {
543 MYLOG("ERROR: powerpc_decompose()\n");
544 goto cleanup;
545 }
546
547 switch (insn->id)
548 {
549 case PPC_INS_CRAND:
550 case PPC_INS_CRANDC:
551 case PPC_INS_CRNAND:
552 case PPC_INS_CROR:
553 case PPC_INS_CRORC:
554 case PPC_INS_CRNOR:
555 case PPC_INS_CREQV:
556 case PPC_INS_CRXOR:
557 case PPC_INS_CRSET:
558 case PPC_INS_CRCLR:
559 case PPC_INS_CRNOT:
560 case PPC_INS_CRMOVE:
561 capstoneWorkaround = true;
562 }
563
564 /* mnemonic */
565 result.emplace_back(InstructionToken, insn->mnemonic);
566
567 /* padding between mnemonic and operands */
568 memset(buf, ' ', 8);
569 strlenMnem = strlen(insn->mnemonic);
570 if(strlenMnem < 8)
571 buf[8-strlenMnem] = '\0';
572 else
573 buf[1] = '\0';
574 result.emplace_back(TextToken, buf);
575
576 /* operands */

Callers

nothing calls this directly

Calls 2

powerpc_decomposeFunction · 0.85

Tested by

no test coverage detected