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

Side by Side Diff: base/file_version_info.h

Issue 1852143002: win: Remove GetModuleFromAddress, deduplicate __ImageBase code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_FILE_VERSION_INFO_H_ 5 #ifndef BASE_FILE_VERSION_INFO_H_
6 #define BASE_FILE_VERSION_INFO_H_ 6 #define BASE_FILE_VERSION_INFO_H_
7 7
8 #include <string>
9
8 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "base/base_export.h"
12 #include "base/strings/string16.h"
9 13
10 #if defined(OS_WIN) 14 #if defined(OS_WIN)
11 #include <windows.h> 15 #include <windows.h>
12 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 16 #endif
13 extern "C" IMAGE_DOS_HEADER __ImageBase;
14 #endif // OS_WIN
15
16 #include <string>
17
18 #include "base/base_export.h"
19 #include "base/strings/string16.h"
20 17
21 namespace base { 18 namespace base {
22 class FilePath; 19 class FilePath;
23 } 20 }
24 21
25 // Provides an interface for accessing the version information for a file. This 22 // Provides an interface for accessing the version information for a file. This
26 // is the information you access when you select a file in the Windows Explorer, 23 // is the information you access when you select a file in the Windows Explorer,
27 // right-click select Properties, then click the Version tab, and on the Mac 24 // right-click select Properties, then click the Version tab, and on the Mac
28 // when you select a file in the Finder and do a Get Info. 25 // when you select a file in the Finder and do a Get Info.
29 // 26 //
30 // This list of properties is straight out of Win32's VerQueryValue 27 // This list of properties is straight out of Win32's VerQueryValue
31 // <http://msdn.microsoft.com/en-us/library/ms647464.aspx> and the Mac 28 // <http://msdn.microsoft.com/en-us/library/ms647464.aspx> and the Mac
32 // version returns values from the Info.plist as appropriate. TODO(avi): make 29 // version returns values from the Info.plist as appropriate. TODO(avi): make
33 // this a less-obvious Windows-ism. 30 // this a less-obvious Windows-ism.
34 31
35 #if defined(OS_WIN)
36 // Creates a FileVersionInfo for the current module. Returns NULL in case of
37 // error. The returned object should be deleted when you are done with it. This
38 // is done as a macro to force inlining of __ImageBase. It used to be inside of
39 // a method labeled with __forceinline, but inlining through __forceinline
40 // stopped working for Debug builds in VS2013 (http://crbug.com/516359).
41 #define CREATE_FILE_VERSION_INFO_FOR_CURRENT_MODULE() \
42 FileVersionInfo::CreateFileVersionInfoForModule( \
43 reinterpret_cast<HMODULE>(&__ImageBase))
44 #endif
45
46 class BASE_EXPORT FileVersionInfo { 32 class BASE_EXPORT FileVersionInfo {
47 public: 33 public:
48 virtual ~FileVersionInfo() {} 34 virtual ~FileVersionInfo() {}
49 #if defined(OS_WIN) || defined(OS_MACOSX) 35 #if defined(OS_WIN) || defined(OS_MACOSX)
50 // Creates a FileVersionInfo for the specified path. Returns NULL if something 36 // Creates a FileVersionInfo for the specified path. Returns NULL if something
51 // goes wrong (typically the file does not exit or cannot be opened). The 37 // goes wrong (typically the file does not exit or cannot be opened). The
52 // returned object should be deleted when you are done with it. 38 // returned object should be deleted when you are done with it.
53 static FileVersionInfo* CreateFileVersionInfo( 39 static FileVersionInfo* CreateFileVersionInfo(
54 const base::FilePath& file_path); 40 const base::FilePath& file_path);
55 #endif // OS_WIN || OS_MACOSX 41 #endif // OS_WIN || OS_MACOSX
56 42
57 #if defined(OS_WIN) 43 #if defined(OS_WIN)
58 // Creates a FileVersionInfo for the specified module. Returns NULL in case 44 // Creates a FileVersionInfo for the specified module. Returns NULL in case
59 // of error. The returned object should be deleted when you are done with it. 45 // of error. The returned object should be deleted when you are done with it.
60 // See CREATE_FILE_VERSION_INFO_FOR_CURRENT_MODULE() helper above for a
61 // CreateFileVersionInfoForCurrentModule() alternative for Windows.
62 static FileVersionInfo* CreateFileVersionInfoForModule(HMODULE module); 46 static FileVersionInfo* CreateFileVersionInfoForModule(HMODULE module);
63 #else 47 #else
64 // Creates a FileVersionInfo for the current module. Returns NULL in case 48 // Creates a FileVersionInfo for the current module. Returns NULL in case
65 // of error. The returned object should be deleted when you are done with it. 49 // of error. The returned object should be deleted when you are done with it.
66 static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); 50 static FileVersionInfo* CreateFileVersionInfoForCurrentModule();
67 #endif // OS_WIN 51 #endif // OS_WIN
68 52
69 // Accessors to the different version properties. 53 // Accessors to the different version properties.
70 // Returns an empty string if the property is not found. 54 // Returns an empty string if the property is not found.
71 virtual base::string16 company_name() = 0; 55 virtual base::string16 company_name() = 0;
72 virtual base::string16 company_short_name() = 0; 56 virtual base::string16 company_short_name() = 0;
73 virtual base::string16 product_name() = 0; 57 virtual base::string16 product_name() = 0;
74 virtual base::string16 product_short_name() = 0; 58 virtual base::string16 product_short_name() = 0;
75 virtual base::string16 internal_name() = 0; 59 virtual base::string16 internal_name() = 0;
76 virtual base::string16 product_version() = 0; 60 virtual base::string16 product_version() = 0;
77 virtual base::string16 private_build() = 0; 61 virtual base::string16 private_build() = 0;
78 virtual base::string16 special_build() = 0; 62 virtual base::string16 special_build() = 0;
79 virtual base::string16 comments() = 0; 63 virtual base::string16 comments() = 0;
80 virtual base::string16 original_filename() = 0; 64 virtual base::string16 original_filename() = 0;
81 virtual base::string16 file_description() = 0; 65 virtual base::string16 file_description() = 0;
82 virtual base::string16 file_version() = 0; 66 virtual base::string16 file_version() = 0;
83 virtual base::string16 legal_copyright() = 0; 67 virtual base::string16 legal_copyright() = 0;
84 virtual base::string16 legal_trademarks() = 0; 68 virtual base::string16 legal_trademarks() = 0;
85 virtual base::string16 last_change() = 0; 69 virtual base::string16 last_change() = 0;
86 virtual bool is_official_build() = 0; 70 virtual bool is_official_build() = 0;
87 }; 71 };
88 72
89 #endif // BASE_FILE_VERSION_INFO_H_ 73 #endif // BASE_FILE_VERSION_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698