Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: tools/symsrc/img_fingerprint.py

Issue 726313006: Fix GetImgFingerprint for small files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # 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
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Retrieves an image's "fingerprint". 6 """Retrieves an image's "fingerprint".
7 7
8 This is used when retrieving the image from the symbol server. The .dll (or cab 8 This is used when retrieving the image from the symbol server. The .dll (or cab
9 compressed .dl_) or .exe is expected at a path like: 9 compressed .dl_) or .exe is expected at a path like:
10 foo.dll/FINGERPRINT/foo.dll 10 foo.dll/FINGERPRINT/foo.dll
11 """ 11 """
12 12
13 import sys 13 import sys
14 import pefile 14 import pefile
15 15
16 16
17 def GetImgFingerprint(filename): 17 def GetImgFingerprint(filename):
18 """Returns the fingerprint for an image file""" 18 """Returns the fingerprint for an image file"""
19 pe = pefile.PE(filename) 19 pe = pefile.PE(filename)
20 return "%08X%06x" % ( 20 return "%08X%x" % (
21 pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage) 21 pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage)
22 22
23 23
24 def main(): 24 def main():
25 if len(sys.argv) != 2: 25 if len(sys.argv) != 2:
26 print "usage: file.dll" 26 print "usage: file.dll"
27 return 1 27 return 1
28 28
29 print GetImgFingerprint(sys.argv[1]) 29 print GetImgFingerprint(sys.argv[1])
30 return 0 30 return 0
31 31
32 32
33 if __name__ == '__main__': 33 if __name__ == '__main__':
34 sys.exit(main()) 34 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698