phrank icon indicating copy to clipboard operation
phrank copied to clipboard

IDA version compatibility

Open klefo0 opened this issue 11 months ago • 3 comments

I have two version IDA, 7.6 and 8.3 I tried to use the plugin in both versions, nothing happen when i used hotkey (Shift-A) like in this script

void __fastcall game_matrix_render(__int64 a1)
{
  int v2; // eax
  float v3; // xmm2_4
  __int64 v4; // rdx
  float v5; // xmm4_4
  __int128 v6; // xmm1
  float v7; // xmm3_4
  __int64 v8; // rcx
  __int64 v9; // rax
  __int128 v10; // xmm0
  __int64 v11; // r8
  int v12; // ecx
  int v13; // er9
  int v14; // er9
  windowSize *window_size; // rcx

  (*(*a1 + 80i64))(a1, (right_axis * bottom_axis));
  v2 = right_axis;
  v3 = 0.0;
  if ( right_axis > 0.0 )
  {
    v4 = 0i64;
    v5 = bottom_axis;
    do
    {
      v6 = 0i64;
      if ( v5 > 0.0 )
      {
        v7 = v3 + 1.0;
        v8 = 48 * v4;
        do
        {
          v9 = *(a1 + 120);
          v10 = v6;
          *&v10 = *&v6 + 1.0;
          ++v4;
          *(v8 + v9 + 4) = v6;
          *(v8 + v9 + 12) = v6;
          *(v8 + v9 + 36) = v6;
          v6 = v10;
          *(v8 + v9 + 20) = v10;
          *(v8 + v9 + 28) = v10;
          *(v8 + v9 + 44) = v10;
          *(v8 + v9) = v3;
          *(v8 + v9 + 8) = v7;
          *(v8 + v9 + 16) = v3;
          *(v8 + v9 + 24) = v3;
          *(v8 + v9 + 32) = v7;
          *(v8 + v9 + 40) = v7;
          v8 += 48i64;
          v5 = bottom_axis;
        }
        while ( bottom_axis > *&v10 );
        v2 = right_axis;
      }
      v3 = v3 + 1.0;
    }
    while ( v2 > v3 );
  }
  glEnableClientState(GL_COLOR_ARRAY);
  if ( *(a1 + 152) + *(a1 + 156) || CURSE <= 0 || (*init & 2) == 0 )
  {
    window_size = *(a1 + 104);
    *(a1 + 176) = window_size->width;
    *(a1 + 180) = window_size->height;
    *(a1 + 168) = 0i64;
  }
  else
  {
    v11 = *(a1 + 104);
    v12 = right_axis * *(a1 + 112);
    v13 = *(a1 + 116);
    *(a1 + 176) = v12;
    v14 = bottom_axis * v13;
    *(a1 + 180) = v14;
    *(a1 + 168) = (*(v11 + 16) - v12) / 2;
    *(a1 + 172) = (*(v11 + 20) - v14) / 2;
  }
  glViewport(*(a1 + 168), *(a1 + 172), *(a1 + 176), *(a1 + 180));
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(0.0, right_axis, bottom_axis, 0.0);
}

The a1 variable should have a struct for it, but the plugin not doing anything. Can you show me how to use it in detail, or is it plugin work from the older version?

klefo0 avatar Mar 17 '24 00:03 klefo0

README is a bit outdated, sorry about that... There is no longer default hotkey assigned, one should assign it themselves in Options->shortcuts. Hotkeys' names are phrank::item_analyzer (shift-A in README) and phrank::tfg_printer

Mizari avatar Mar 19 '24 03:03 Mizari

Thanks, I have set the hotkey, the plugin worked. Now it throws errors

Traceback (most recent call last):
  File "$(IDA_DIR)\python\3\pyphrank\ida_plugin.py", line 61, in activate
    self.plugin.type_analyzer.get_tfg(func_ea, nocache=True)
  File "$(IDA_DIR)\python\3\pyphrank\type_analyzer.py", line 81, in get_tfg
    aa = self.func_manager.get_tfg(func_ea)
  File "$(IDA_DIR)\python\3\pyphrank\function_manager.py", line 25, in get_tfg
    cfunc = self.get_cfunc(func_ea)
  File "$(IDA_DIR)\python\3\pyphrank\function_manager.py", line 34, in get_cfunc
    return self.func_factory.get_cfunc(func_ea)
  File "$(IDA_DIR)\python\3\pyphrank\cfunction_factory.py", line 35, in get_cfunc
    if cfunc == -1:
  File " $(IDA_DIR)\python\3\ida_hexrays.py", line 26011, in <lambda>
    cfuncptr_t.__eq__ = lambda self, other: self.__ptrval__() == other.__ptrval__()
AttributeError: 'int' object has no attribute '__ptrval__'

Do you have any idea?

klefo0 avatar Mar 19 '24 06:03 klefo0

I think that hexrays assumes that all objects compared with cfunc are cfunc too, which is false in this case. Did you try it in 8.3? I didn't test phrank there... I fixed this bug, please check if it works now.

Mizari avatar Mar 20 '24 01:03 Mizari