freemyipod r107 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r106‎ | r107 | r108 >
Date:11:57, 12 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
fix libembios.py
Modified paths:
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/libembios.py
@@ -498,7 +498,7 @@
499499 response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
500500 self.__checkstatus(response)
501501
502 - readbytes, buffersize, bytesleft = struct.unpack("<III", response[4:])
 502+ readbytes, buffersize, bytesleft = struct.unpack("<III", response[4:16])
503503 out_data += response[0x10:0x10+readbytes]
504504 size -= blocklen
505505
@@ -565,7 +565,7 @@
566566 response = self.__getbulk(self.handle, self.__cinep, 0x10)
567567 self.__checkstatus(response)
568568
569 - sendbytes = struct.unpack("<I", response[4:])[0]
 569+ sendbytes = struct.unpack("<I", response[4:8])[0]
570570 if sendbytes < blocklen: # not everything has been written, need to resent some stuff but wait a bit before doing so
571571 time.sleep(0.1)
572572 timeoutcounter += 1
@@ -617,7 +617,7 @@
618618 response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
619619 self.__checkstatus(response)
620620
621 - readbytes = struct.unpack("<III", response[4:])[0]
 621+ readbytes = struct.unpack("<III", response[4:8])[0]
622622 out_data += response[0x10:0x10+readbytes]
623623 size -= blocklen
624624
@@ -770,39 +770,39 @@
771771 while ptr < len(processinfo):
772772 retval.append({})
773773
774 - retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:])
 774+ retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:ptr+64])
775775 ptr += 16 * 0x4
776 - retval[process_n]['cpsr'] = struct.unpack("<I", processinfo[ptr:])[0]
 776+ retval[process_n]['cpsr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
777777 ptr += 1 * 0x4
778 - retval[process_n]['state'] = struct.unpack("<I", processinfo[ptr:])[0]
 778+ retval[process_n]['state'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
779779 ptr += 1 * 0x4
780 - retval[process_n]['name_ptr'] = struct.unpack("<I", processinfo[ptr:])[0]
 780+ retval[process_n]['name_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
781781 ptr += 1 * 0x4
782 - retval[process_n]['cputime_current'] = struct.unpack("<I", processinfo[ptr:])[0]
 782+ retval[process_n]['cputime_current'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
783783 ptr += 1 * 0x4
784 - retval[process_n]['cputime_total'] = struct.unpack("<Q", processinfo[ptr:])[0]
 784+ retval[process_n]['cputime_total'] = struct.unpack("<Q", processinfo[ptr:ptr+8])[0]
785785 ptr += 1 * 0x8
786 - retval[process_n]['startusec'] = struct.unpack("<I", processinfo[ptr:])[0]
 786+ retval[process_n]['startusec'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
787787 ptr += 1 * 0x4
788 - retval[process_n]['queue_next_ptr'] = struct.unpack("<I", processinfo[ptr:])[0]
 788+ retval[process_n]['queue_next_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
789789 ptr += 1 * 0x4
790 - retval[process_n]['timeout'] = struct.unpack("<I", processinfo[ptr:])[0]
 790+ retval[process_n]['timeout'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
791791 ptr += 1 * 0x4
792 - retval[process_n]['blocked_since'] = struct.unpack("<I", processinfo[ptr:])[0]
 792+ retval[process_n]['blocked_since'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
793793 ptr += 1 * 0x4
794 - retval[process_n]['blocked_by_ptr'] = struct.unpack("<I", processinfo[ptr:])[0]
 794+ retval[process_n]['blocked_by_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
795795 ptr += 1 * 0x4
796 - retval[process_n]['stack_ptr'] = struct.unpack("<I", processinfo[ptr:])[0]
 796+ retval[process_n]['stack_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
797797 ptr += 1 * 0x4
798 - retval[process_n]['err_no'] = struct.unpack("<I", processinfo[ptr:])[0]
 798+ retval[process_n]['err_no'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
799799 ptr += 1 * 0x4
800 - retval[process_n]['block_type'] = struct.unpack("<B", processinfo[ptr:])[0]
 800+ retval[process_n]['block_type'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
801801 ptr += 1 * 0x1
802 - retval[process_n]['thread_type'] = struct.unpack("<B", processinfo[ptr:])[0]
 802+ retval[process_n]['thread_type'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
803803 ptr += 1 * 0x1
804 - retval[process_n]['priority'] = struct.unpack("<B", processinfo[ptr:])[0]
 804+ retval[process_n]['priority'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
805805 ptr += 1 * 0x1
806 - retval[process_n]['cpuload'] = struct.unpack("<B", processinfo[ptr:])[0]
 806+ retval[process_n]['cpuload'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
807807 ptr += 1 * 0x1
808808
809809 process_n += 1
@@ -864,12 +864,12 @@
865865 response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
866866 self.__checkstatus(response)
867867
868 - size = struct.unpack("<I", response[8:])[0]
 868+ size = struct.unpack("<I", response[8:12])[0]
869869
870870 if size <= offset + blocklen:
871871 procinfo += response[0x10:0x10 + size]
872 - structversion = struct.unpack("<I", response[4:])[0]
873 - tablesize = struct.unpack("<I", response[8:])[0]
 872+ structversion = struct.unpack("<I", response[4:8])[0]
 873+ tablesize = struct.unpack("<I", response[8:12])[0]
874874 break
875875 else:
876876 procinfo += response[0x10:0x10 + blocklen]
@@ -901,9 +901,9 @@
902902 response = self.__getbulk(self.handle, self.__cinep, 0x10)
903903 self.__checkstatus(response)
904904
905 - self.__myprint(" done\n execimage() return code: 0x%08x\n" % struct.unpack("<I", response[4:])[0], silent)
 905+ self.__myprint(" done\n execimage() return code: 0x%08x\n" % struct.unpack("<I", response[4:8])[0], silent)
906906
907 - return struct.unpack("<I", response[4:])[0]
 907+ return struct.unpack("<I", response[4:8])[0]
908908
909909
910910 #=====================================================================================