示例#1
0
 def write_nvitem(self, item, data):
     rawdata = bytes(data)
     while len(rawdata) < 128:
         rawdata += b"\x00"
     status = 0x0000
     nvrequest = b"\x27" + write_object(nvitem_type, item, rawdata,
                                        status)['raw_data']
     res = self.send(nvrequest)
     if len(res) > 0:
         if res[0] == 0x27:
             res, nvitem = self.read_nvitem(item)
             if res == False:
                 print(f"Error while writing nvitem {hex(item)} data, %s" %
                       data)
             else:
                 if nvitem.data != data:
                     print(
                         f"Error while writing nvitem {hex(item)} data, verified data doesn't match"
                     )
                 else:
                     print(f"Successfully wrote nvitem {hex(item)}.")
                     return True
             return False
         else:
             print(f"Error while writing nvitem {hex(item)} data, %s" %
                   data)
示例#2
0
 def read_nvitem(self, item):
     rawdata = 128 * b'\x00'
     status = 0x0000
     nvrequest = b'\x26' + write_object(nvitem_type, item, rawdata,
                                        status)['raw_data']
     data = self.send(nvrequest)
     if len(data) == 0:
         data = self.send(nvrequest)
     if len(data) > 0:
         if data[0] == 0x26:
             res = read_object(data[1:], nvitem_type)
             name = ""
             if item in self.nvlist:
                 name = self.nvlist[item]
             data = bytearray()
             for byte in res["rawdata"]:
                 if byte == 0:
                     break
                 data.append(byte)
             res = nvitem(res["item"], data, res["status"], name)
             return [True, res]
         elif data[0] == 0x14:
             return [
                 False, f"Error 0x14 trying to read nvitem {hex(item)}."
             ]
         else:
             return [
                 False,
                 f"Error {hex(data[0])} trying to read nvitem {hex(item)}."
             ]
     return [False, f"Empty request for nvitem {hex(item)}"]
示例#3
0
    def write_nvitem(self, item, data):
        rawdata = bytes(data)
        if len(data) < 128:
            rawdata += b"\x00"
        status = 0x0000
        nvrequest = b"\x27" + write_object(nvitem_type, item, rawdata, status)
        res = self.send(nvrequest)
        # verify res status result here... todo

        res, nvitem = self.read_nvitem(item)
        if res == False:
            print(f"Error while writing nvitem {hex(item)} data, %s" % nvitem)
        else:
            if nvitem.data != data:
                print(
                    f"Error while writing nvitem {hex(item)} data, verified data doesn't match"
                )
            else:
                return True
        return False
示例#4
0
文件: diag.py 项目: kingsman-star/edl
 def read_nvitemsub(self, item, index):
     rawdata = 128 * b'\x00'
     status = 0x0000
     nvrequest = b'\x4B\x30\x01\x00' + write_object(subnvitem_type, item, index, rawdata, status)['raw_data']
     data = self.send(nvrequest)
     if len(data) == 0:
         data = self.send(nvrequest)
     if len(data) > 0:
         if data[0] == 0x4B:
             res = read_object(data[4:], subnvitem_type)
             name = ""
             if item in self.nvlist:
                 name = self.nvlist[item]
             data=self.unpackdata(res["rawdata"])
             res = nvitem(res["item"], index, data, res["status"], name)
             return [True, res]
         elif data[0] == 0x14:
             return [False, f"Error 0x14 trying to read nvitem {hex(item)}."]
         else:
             return [False, f"Error {hex(data[0])} trying to read nvitem {hex(item)}."]
     return [False, f"Empty request for nvitem {hex(item)}"]
示例#5
0
 def todata(self):
     data = write_object(self.magic1, self.magic2, self.fact_version,
                         self.version, self.block_size, self.page_size,
                         self.block_count, self.space_limit,
                         self.upper_data)
     return data
示例#6
0
 def todata(self):
     data = write_object(self.def_fs_factimage_read_info, self.stream_state,
                         self.info_cluster_sent, self.cluster_map_seqno,
                         self.cluster_data_seqno)
     return data