freemyipod r102 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r101‎ | r102 | r103 >
Date:23:11, 11 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
fix some libembios.py/embios.py stuff
Modified paths:
  • /embios/trunk/tools/embios.py (modified) (history)
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/embios.py
@@ -26,6 +26,7 @@
2727 import sys
2828 import time
2929 import libembios
 30+import struct
3031
3132
3233 def usage():
@@ -135,10 +136,8 @@
136137 print " <bitmask>: the bitmask of the consoles to be flushed"
137138 print ""
138139 print ""
139 - print " getprocessinformation <offset> <size> / getprocinfo <offset> <size>"
 140+ print " getprocessinformation / getprocinfo"
140141 print " Fetches data on the currently running processes"
141 - print " <offset> the offset in the data field"
142 - print " <size> the number of bytes to be fetched"
143142 print " ATTENTION: this function will be print the information to the console window."
144143 print " If several threads are running this might overflow the window,"
145144 print " causing not everything to be shown."
@@ -326,8 +325,8 @@
327326
328327
329328 elif argv[1] == "getprocessinformation" or argv[1] == "getprocinfo":
330 - if len(argv) != 4: usage()
331 - dev.getprocinfo(int(argv[2], 16), int(argv[3], 16))
 329+ if len(argv) != 2: usage()
 330+ dev.getprocinfo()
332331
333332 elif argv[1] == "lockscheduler":
334333 if len(argv) != 2: usage()
Index: embios/trunk/tools/libembios.py
@@ -762,51 +762,7 @@
763763 <silent> = 1: nothing
764764 """
765765
766 -
767 - self.__myprint("Retrieving process information...", silent)
768 -
769 - offset = 0
770 - blocklen = size = self.cin_maxsize - 0x10
771 - procinfo = ""
772 - structversion = 0
773 - tablesize = 0
774 -
775 - # reading loop
776 - while (offset < size):
777 - self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 15, offset, size, 0))
778 - response = self.__getbulk(self.handle, self.__cinep, size + 0x10)
779 - self.__checkstatus(response)
780 -
781 - size = struct.unpack("<I", response[8:12])[0]
782 -
783 - if size <= offset + blocklen:
784 - procinfo += response[0x10:0x10 + size]
785 - structversion = struct.unpack("<I", response[4:])
786 - tablesize = struct.unpack("<I", response[8:])
787 - break
788 - else:
789 - procinfo += response[0x10:0x10 + blocklen]
790 -
791 - size -= blocklen
792 - offset += blocklen
793 -
794 - blocklen = self.cin_maxsize - 0x10
795 - if blocklen > size:
796 - blocklen = size
797 -
798 -
799 - out = (structversion, tablesize, procinfotolist(procinfo, structversion))
800 -
801 - self.__myprint(" done\n\
802 - Process information struct version: 0x%08x\n\
803 - Total size of process information table: 0x%08x\n\
804 - %s\n\n"
805 - % (out[0], out[1], procinfotostring(out[2], structversion))
806 - , silent)
807 -
808 - return out
809 -
810 - def procinfotolist(self, processinfo, structver):
 766+ def procinfotolist(processinfo, structver):
811767 if (structver == 1): # Process information struct version == 1
812768 ptr = 0x10
813769 process_n = 0
@@ -853,9 +809,8 @@
854810
855811 return retval
856812
857 -
858813
859 - def procinfotostring(self, procinfolist, structver):
 814+ def procinfotostring(procinfolist, structver):
860815 processinfoprint = ""
861816 ptr = 0
862817 while structver == 1 and ptr < len(procinfolist): # Process information struct version == 1
@@ -893,10 +848,52 @@
894849 processinfoprint += "--------------------------------------------------------------------------------"
895850
896851 return processinfoprint
 852+
 853+
 854+ self.__myprint("Retrieving process information...", silent)
897855
 856+ offset = 0
 857+ blocklen = size = self.cin_maxsize - 0x10
 858+ procinfo = ""
 859+ structversion = 0
 860+ tablesize = 0
898861
 862+ # reading loop
 863+ while (offset < size):
 864+ self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 15, offset, size, 0))
 865+ response = self.__getbulk(self.handle, self.__cinep, size + 0x10)
 866+ self.__checkstatus(response)
 867+
 868+ size = struct.unpack("<I", response[8:12])[0]
 869+
 870+ if size <= offset + blocklen:
 871+ procinfo += response[0x10:0x10 + size]
 872+ structversion = struct.unpack("<I", response[4:])[0]
 873+ tablesize = struct.unpack("<I", response[8:])[0]
 874+ break
 875+ else:
 876+ procinfo += response[0x10:0x10 + blocklen]
 877+
 878+ size -= blocklen
 879+ offset += blocklen
 880+
 881+ blocklen = self.cin_maxsize - 0x10
 882+ if blocklen > size:
 883+ blocklen = size
899884
900885
 886+ out = (structversion, tablesize, procinfotolist(procinfo, structversion))
 887+
 888+ self.__myprint(" done\n\
 889+ Process information struct version: 0x%08x\n\
 890+ Total size of process information table: 0x%08x\n\
 891+ %s\n\n"
 892+ % (out[0], out[1], procinfotostring(out[2], structversion))
 893+ , silent)
 894+
 895+ return out
 896+
 897+
901898 def execimage(self, offset, silent = 0):
902899 self.__myprint("Executing emBIOS executable image at 0x%08x..." % offset, silent)
903900