binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

For loop not recognized

Open joelreymont opened this issue 1 year ago • 0 comments

Version and Platform (required):

  • Binary Ninja Version: 4.1.5260-dev, 7f6bb9ee
  • OS: macos
  • OS Version: 14.4
  • CPU Architecture: arm64

Internal binary major dine favor.

IDA Pro

    DjiCommand_LinkerListInit(*mgr);
    for ( i = 0; LOWORD(links->n_channels) > i; ++i )
    {
      DjiLogger_Output(
        "linker",
        3LL,
        "[%s:%d) config list channel id:%d",
        "DjiCommand_Init",
        158LL,
        *(unsigned __int8 *)(*(_QWORD *)&links->field_0 + 0x34LL * i + 0x30));// link->protocol_id
      v11 = DjiLinker_Init((struct Link *)(*(_QWORD *)&links->field_0 + 0x34LL * i), &(*mgr)->linkers[i]);
      if ( v11 )
      {
        DjiLogger_Output("linker", 0LL, "[%s:%d) init linker error:0x%08llX", "DjiCommand_Init", 161LL, v11);
        return v11;
      }
      DjiCommand_AddLinkerNode(*mgr, &(*mgr)->linkers[i]);
      DjiLogger_Output(
        "linker",
        3LL,
        "[%s:%d) add linker node count:%d",
        "DjiCommand_Init",
        167LL,
        (unsigned __int16)(*mgr)->linker_node_count);
    }
    v11 = osal->GetRandomNum((uint16_t *)&seqnum);

BN output is much worse

00062218                              DjiCommand_LinkerListInit(cmd: *mgr)
0006221c                              int32_t ix = 0
000623bc                              while (true)
000623bc                                  if (zx.d(links->n_channels.w) s<= ix)
000623cc                                      uint64_t err_2 = osal->GetRandomNum(randomNum: &randomNum)
000623dc                                      if (err_2 != 0)
0006240c                                          DjiLogger_UserLogOutput(level: "linker", fmt: nullptr, "[%s:%d) Get random num failed, e…", "DjiCommand_Init", 0xac, err_2)
00062410                                          err = err_2
000623dc                                      else
00062424                                          *(*mgr + 0xd88) = randomNum
0006244c                                          if (CBK_OSAL->MutexCreate(mutex: &(*mgr)->mutex_2) != 0)
00062478                                              DjiLogger_UserLogOutput(level: "linker", fmt: nullptr, "[%s:%d) mutex create error", "DjiCommand_Init", 0xb4)
0006247c                                              err = 0xec
0006244c                                          else
00062488                                              (*mgr)->mem_3ff = CBK_OSAL->Malloc(size: 0x3ff)
000624b8                                              if ((*mgr)->mem_3ff == 0)
000624e4                                                  DjiLogger_UserLogOutput(level: "linker", fmt: nullptr, "[%s:%d) malloc error", "DjiCommand_Init", 0xba)
000624e8                                                  err = 0xec
000624b8                                              else
000624f4                                                  (*mgr)->field_a40 = 0
00062500                                                  (*mgr)->task.name = "commandTask"
00062514                                                  (*mgr)->task.callback = DjiCommand_RecvWork
00062530                                                  uint64_t x1_22
00062530                                                  x1_22.d = *mgr
00062530                                                  x1_22:4.d = *(mgr + 4)
00062528                                                  (*mgr)->task.ctx = x1_22
00062554                                                  int64_t err_3 = DjiWork_AddNode(root: &ROOT_TASK_LIST, child: &(*mgr)->task)
00062564                                                  if (err_3 == 0)
000625a0                                                      err = 0
00062564                                                  else
00062594                                                      DjiLogger_UserLogOutput(level: "linker", fmt: nullptr, "[%s:%d) create command task erro…", "DjiCommand_Init", 0xc6, err_3)
00062598                                                      err = err_3
000623d8                                      break
00062228                                  void* x2_1
00062228                                  x2_1.d = links->field_0
00062228                                  x2_1:4.d = links->channel_id
00062280                                  DjiLogger_UserLogOutput(level: "linker", fmt: &(*nullptr->ident.signature)[3], "[%s:%d) config list channel id:%…", "DjiCommand_Init", 0x9e, zx.q(*(x2_1 + sx.q(ix) * 0x34 + 0x30)))
00062288                                  void* x2_2
00062288                                  x2_2.d = links->field_0
00062288                                  x2_2:4.d = links->channel_id
000622d8                                  T_DjiReturnCode err_1 = DjiLinker_Init(link: x2_2 + sx.q(ix) * 0x34, linker: &(*mgr)->linkers[sx.q(ix)])
000622e8                                  if (err_1 != 0)
00062318                                      DjiLogger_UserLogOutput(level: "linker", fmt: nullptr, "[%s:%d) init linker error:0x%08l…", "DjiCommand_Init", 0xa1, err_1)
0006231c                                      err = err_1
00062320                                      break
00062358                                  DjiCommand_AddLinkerNode(cmd: *mgr, node: &(*mgr)->linkers[sx.q(ix)])
00062398                                  DjiLogger_UserLogOutput(level: "linker", fmt: &(*nullptr->ident.signature)[3], "[%s:%d) add linker node count:%d", "DjiCommand_Init", 0xa7, zx.q((*mgr)->linker_node_count))
000623a4                                  ix += 1

joelreymont avatar May 10 '24 08:05 joelreymont