import sys, os, struct
|
|
def main():
|
if len(sys.argv) != 2:
|
print "USAGE: %s <TRUSTLET_DIRECTORY>" % sys.argv[0]
|
return
|
trustlet_dir = sys.argv[1]
|
|
version_map = {}
|
|
for root, dirs, files in os.walk(trustlet_dir):
|
for name in files:
|
if not (name.endswith(".tlbin") or name.endswith(".drbin") or name.endswith(".tabin")):
|
continue
|
|
#Reading the length fields from the header
|
trustlet = open(os.path.join(root, name), "rb").read()
|
service_version = struct.unpack("<I", trustlet[0x48:0x4c])[0]
|
|
#Adding the trustlet to the version map
|
if name not in version_map:
|
version_map[name] = []
|
version_map[name].append((root, service_version))
|
|
#Dumping the version map
|
for trustlet in version_map:
|
print "-------------------------------------"
|
print "trustlet: %s" % trustlet
|
for (root, service_version) in version_map[trustlet]:
|
print root
|
print "%X" % service_version
|
print
|
|
|
if __name__ == "__main__":
|
main()
|