Project is archived and read-only.

Issue 1239 attachment: get_service_versions.py (1.1 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()