| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Copyright (c) 2008 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 6 | 5 |
| 7 """This will retrieve an image's "fingerprint". This is used when retrieving | 6 """Retrieves an image's "fingerprint". |
| 8 the image from the symbol server. The .dll (or cab compressed .dl_) or .exe | 7 |
| 9 is expected at a path like: | 8 This is used when retrieving the image from the symbol server. The .dll (or cab |
| 10 foo.dll/FINGERPRINT/foo.dll""" | 9 compressed .dl_) or .exe is expected at a path like: |
| 10 foo.dll/FINGERPRINT/foo.dll |
| 11 """ |
| 11 | 12 |
| 12 import sys | 13 import sys |
| 13 import pefile | 14 import pefile |
| 14 | 15 |
| 16 |
| 15 def GetImgFingerprint(filename): | 17 def GetImgFingerprint(filename): |
| 16 """Returns the fingerprint for an image file""" | 18 """Returns the fingerprint for an image file""" |
| 17 | |
| 18 pe = pefile.PE(filename) | 19 pe = pefile.PE(filename) |
| 19 return "%08X%06x" % ( | 20 return "%08X%06x" % ( |
| 20 pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage) | 21 pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage) |
| 21 | 22 |
| 22 | 23 |
| 23 if __name__ == '__main__': | 24 def main(): |
| 24 if len(sys.argv) != 2: | 25 if len(sys.argv) != 2: |
| 25 print "usage: file.dll" | 26 print "usage: file.dll" |
| 26 sys.exit(1) | 27 return 1 |
| 27 | 28 |
| 28 print GetImgFingerprint(sys.argv[1]) | 29 print GetImgFingerprint(sys.argv[1]) |
| 30 return 0 |
| 31 |
| 32 |
| 33 if __name__ == '__main__': |
| 34 sys.exit(main()) |
| OLD | NEW |