bongtrop/hbctool

List index out of range: version 84

Puyodead1 opened this issue · 2 comments

I get the following error when trying to disassemble an android bundle using hermes bytecode version 84:

[*] Disassemble 'index.android.bundle' to 'out' path
[*] Hermes Bytecode [ Source Hash: d47dd92ea0ad2ab0ad46438a7f6f4a2ee383dbf5, HBC Version: 84 ]
Traceback (most recent call last):
  File "hbctool\.venv\Scripts\\hbctool", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "hbctool\hbctool\__init__.py", line 61, in main
    disasm(args['<HBC_FILE>'], args['<HASM_PATH>'])
  File "hbctool\hbctool\__init__.py", line 41, in disasm
    hasm.dump(hbco, hasmpath)
  File "hbctool\hbctool\hasm.py", line 67, in dump
    write_func(f, hbc.getFunction(i), i, hbc)
                  ^^^^^^^^^^^^^^^^^^
  File "hbctool\hbctool\hbc\hbc84\__init__.py", line 59, in getFunction
    insts = disassemble(bc)
            ^^^^^^^^^^^^^^^
  File "hbctool\hbctool\hbc\hbc84\translator.py", line 33, in disassemble
    opcode = opcode_mapper[bc[i]]
             ~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range

Same problem here - To add a bit of debugging info:
IndexError: list index out of range form line 33 in hbc/hbc84/translator.py.
with:
bc[i] -> 271 and len(opcode_mapper) -> 201

I'm not sure if the opcode integer is parsed wrong when being read from the binary, or if the 84'er version has many more opcodes, that als are missing.

related to #31, thank to @hexpwn. this issue have closed.