def dump_bin(bin):
    d = []
    pc = 0
    while pc < len(bin):
        op = bin[pc]
        print('---------------------------->', pc, op)

        # 获取函数地址reg_method_0,通过bin[pc]查找
        # print('reg_method_0 = func[%d]' % (op))
        # 获取函数地址reg_method_1,通过bin[pc] | 0x100 查找
        #调用reg_method_1获得返回值
        print('method_1_ret = call func[%d]' % (op | 0x100))
        if (op | 0x100) == 256 :
            print("batteryInfo.batterySOC:",end="")
        elif (op | 0x100) == 257 :
            print("batteryInfo.chargingStatus:",end="")
        elif (op | 0x100) == 258 :
            print("batteryInfo.healthStatus:",end="")
        elif (op | 0x100) == 259 :
            print("batteryInfo.pluggedType:",end="")
        elif (op | 0x100) == 260 :
            print("batteryInfo.voltage:",end="")
        elif (op | 0x100) == 261 :
            print("batteryInfo.technology:",end="")
        elif (op | 0x100) == 262 :
            print("batteryInfo.batteryTemperature:",end="")
        elif (op | 0x100) == 263 :
            print("batteryInfo.isBatteryPresent:",end="")
        elif (op | 0x100) == 264 :
            print("batteryInfo.batteryCapacityLevel",end="")
        #获取操作类型
        type = bin[pc + 1]
        if type == 0 :
            print(bin[pc + 3])
            print('method_0_ret = call func[%d](%d)' % (op, bin[pc + 3]))
            key = bin[pc + 3]
            pc += 4   
        elif type == 1:
            #获取bin中字符串的长度
            size = bin[pc + 2]
            s = bin[pc + 3: pc + 3 + size]
            print(repr(s))
            print('method_0_ret = call func[%d](%s)' % (op, repr(s)))
            pc += 3 + size         
        elif type == 2 :
            print(bin[pc + 3])
            print('method_0_ret = call func[%d](%d)' % (op, bin[pc + 3]))
            key = bin[pc + 3]
            pc += 4
        else:
            pc += 3
            assert False
        d.append((op, key))
    return d
with open(r'.\bin', 'rb') as file:
    encrypted_data = file.read()

print(dump_bin(encrypted_data))