| Index: embios/trunk/tools/embios.py |
| — | — | @@ -26,6 +26,7 @@ |
| 27 | 27 | import sys
|
| 28 | 28 | import time
|
| 29 | 29 | import libembios
|
| | 30 | +import struct
|
| 30 | 31 |
|
| 31 | 32 |
|
| 32 | 33 | def usage():
|
| — | — | @@ -135,10 +136,8 @@ |
| 136 | 137 | print " <bitmask>: the bitmask of the consoles to be flushed"
|
| 137 | 138 | print ""
|
| 138 | 139 | print ""
|
| 139 | | - print " getprocessinformation <offset> <size> / getprocinfo <offset> <size>"
|
| | 140 | + print " getprocessinformation / getprocinfo"
|
| 140 | 141 | 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"
|
| 143 | 142 | print " ATTENTION: this function will be print the information to the console window."
|
| 144 | 143 | print " If several threads are running this might overflow the window,"
|
| 145 | 144 | print " causing not everything to be shown."
|
| — | — | @@ -326,8 +325,8 @@ |
| 327 | 326 |
|
| 328 | 327 |
|
| 329 | 328 | 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()
|
| 332 | 331 |
|
| 333 | 332 | elif argv[1] == "lockscheduler":
|
| 334 | 333 | if len(argv) != 2: usage()
|
| Index: embios/trunk/tools/libembios.py |
| — | — | @@ -762,51 +762,7 @@ |
| 763 | 763 | <silent> = 1: nothing
|
| 764 | 764 | """
|
| 765 | 765 |
|
| 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):
|
| 811 | 767 | if (structver == 1): # Process information struct version == 1
|
| 812 | 768 | ptr = 0x10
|
| 813 | 769 | process_n = 0
|
| — | — | @@ -853,9 +809,8 @@ |
| 854 | 810 |
|
| 855 | 811 | return retval
|
| 856 | 812 |
|
| 857 | | -
|
| 858 | 813 |
|
| 859 | | - def procinfotostring(self, procinfolist, structver):
|
| | 814 | + def procinfotostring(procinfolist, structver):
|
| 860 | 815 | processinfoprint = ""
|
| 861 | 816 | ptr = 0
|
| 862 | 817 | while structver == 1 and ptr < len(procinfolist): # Process information struct version == 1
|
| — | — | @@ -893,10 +848,52 @@ |
| 894 | 849 | processinfoprint += "--------------------------------------------------------------------------------"
|
| 895 | 850 |
|
| 896 | 851 | return processinfoprint
|
| | 852 | +
|
| | 853 | +
|
| | 854 | + self.__myprint("Retrieving process information...", silent)
|
| 897 | 855 |
|
| | 856 | + offset = 0
|
| | 857 | + blocklen = size = self.cin_maxsize - 0x10
|
| | 858 | + procinfo = ""
|
| | 859 | + structversion = 0
|
| | 860 | + tablesize = 0
|
| 898 | 861 |
|
| | 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
|
| 899 | 884 |
|
| 900 | 885 |
|
| | 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 | +
|
| 901 | 898 | def execimage(self, offset, silent = 0):
|
| 902 | 899 | self.__myprint("Executing emBIOS executable image at 0x%08x..." % offset, silent)
|
| 903 | 900 |
|