Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ | 5 #ifndef CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ |
| 6 #define CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ | 6 #define CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/conflicts/module_info_util_win.h" | 11 #include "chrome/browser/conflicts/module_info_util_win.h" |
| 10 | 12 |
| 11 // ModuleInfoKey and ModuleInfoData are used in pair by the ModuleDatabase to | 13 // ModuleInfoKey and ModuleInfoData are used in pair by the ModuleDatabase to |
| 12 // maintain information about a module, usually in a std::map. | 14 // maintain information about a module, usually in a std::map. |
| 13 | 15 |
| 14 // Used by the ModuleDatabase as a unique identifier for a module. | 16 // Used by the ModuleDatabase as a unique identifier for a module. |
| 15 using ModuleId = int; | 17 using ModuleId = int; |
| 16 | 18 |
| 17 // This is the constant portion of the module information, and is used to | 19 // This is the constant portion of the module information, and is used to |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 36 // TimeDateStamp from the module's IMAGE_FILE_HEADER. | 38 // TimeDateStamp from the module's IMAGE_FILE_HEADER. |
| 37 uint32_t module_time_date_stamp; | 39 uint32_t module_time_date_stamp; |
| 38 | 40 |
| 39 // The ID of this module. This is a strictly incrementing value, and is used | 41 // The ID of this module. This is a strictly incrementing value, and is used |
| 40 // by the ModuleDatabase to tie a module to the list of running processes in | 42 // by the ModuleDatabase to tie a module to the list of running processes in |
| 41 // which it is found. It is not part of the key for the module, but it is | 43 // which it is found. It is not part of the key for the module, but it is |
| 42 // immutable. This is simply the index of the module in the insertion order. | 44 // immutable. This is simply the index of the module in the insertion order. |
| 43 ModuleId module_id; | 45 ModuleId module_id; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 // Holds more detailed information about a given module. Because most of this | 48 // Holds more detailed information about a given module. Because all of this |
| 47 // information is expensive to gather and require disk access, it should be | 49 // information is expensive to gather and require disk access, it should be |
|
chrisha
2017/03/04 15:54:17
requires*
Patrick Monette
2017/03/06 16:39:48
Done.
| |
| 48 // collected on a task runner that allow blocking. | 50 // collected via InspectModule() on a task runner that allow blocking. |
| 49 struct ModuleInfoData { | 51 struct ModuleInspectionResult { |
| 50 ModuleInfoData(); | 52 ModuleInspectionResult(); |
| 51 ModuleInfoData(const ModuleInfoData& others); | 53 ~ModuleInspectionResult(); |
| 52 ~ModuleInfoData(); | |
| 53 | |
| 54 // Set of all process types in which this module has been seen (may not be | |
| 55 // currently present in a process of that type). This is a conversion of | |
| 56 // ProcessType enumeration to a bitfield. See "ProcessTypeToBit" and | |
| 57 // "BitIndexToProcessType" for details. | |
| 58 uint32_t process_types; | |
| 59 | |
| 60 // The following pieces of information are determined via a detailed | |
| 61 // inspection of the module. | |
| 62 | 54 |
| 63 // The module path, not including the basename. This is cleaned and normalized | 55 // The module path, not including the basename. This is cleaned and normalized |
| 64 // so that common paths are converted to their environment variable mappings | 56 // so that common paths are converted to their environment variable mappings |
| 65 // (ie, %systemroot%). This makes i18n localized paths easily comparable. | 57 // (ie, %systemroot%). This makes i18n localized paths easily comparable. |
| 66 base::string16 location; | 58 base::string16 location; |
| 67 | 59 |
| 68 // The basename of the module. | 60 // The basename of the module. |
| 69 base::string16 basename; | 61 base::string16 basename; |
| 70 | 62 |
| 71 // The name of the product the module belongs to. | 63 // The name of the product the module belongs to. |
| 72 base::string16 product_name; | 64 base::string16 product_name; |
| 73 | 65 |
| 74 // The module file description. | 66 // The module file description. |
| 75 base::string16 description; | 67 base::string16 description; |
| 76 | 68 |
| 77 // The module version. This is usually in the form a.b.c.d (where a, b, c and | 69 // The module version. This is usually in the form a.b.c.d (where a, b, c and |
| 78 // d are integers), but may also have fewer than 4 components. | 70 // d are integers), but may also have fewer than 4 components. |
| 79 base::string16 version; | 71 base::string16 version; |
| 80 | 72 |
| 81 // The certificate info for the module. | 73 // The certificate info for the module. |
| 82 CertificateInfo certificate_info; | 74 CertificateInfo certificate_info; |
| 83 }; | 75 }; |
| 84 | 76 |
| 77 // Contains the inspection result of a module and additional information that is | |
| 78 // useful to the ModuleDatabase. | |
| 79 struct ModuleInfoData { | |
| 80 ModuleInfoData(); | |
| 81 ~ModuleInfoData(); | |
| 82 | |
| 83 // Set of all process types in which this module has been seen (may not be | |
| 84 // currently present in a process of that type). This is a conversion of | |
| 85 // ProcessType enumeration to a bitfield. See "ProcessTypeToBit" and | |
| 86 // "BitIndexToProcessType" for details. | |
| 87 uint32_t process_types; | |
| 88 | |
| 89 // The inspection result obtained via InspectModule(). | |
| 90 std::unique_ptr<ModuleInspectionResult> inspection_result; | |
| 91 }; | |
| 92 | |
| 93 // Given a module identified by |module_key|, returns a populated | |
| 94 // ModuleInspectionResult that contains detailed information about the module on | |
| 95 // disk. This is a blocking task that requires access to disk. | |
| 96 std::unique_ptr<ModuleInspectionResult> InspectModule( | |
| 97 const StringMapping& env_variable_mapping, | |
| 98 const ModuleInfoKey& module_key); | |
| 99 | |
| 100 namespace internal { | |
| 101 | |
| 102 // Normalizes the information already contained in |inspection_result|. In | |
| 103 // particular, | |
|
chrisha
2017/03/04 15:54:17
particular:
Patrick Monette
2017/03/06 16:39:47
Done.
| |
| 104 // - The path is split in 2 parts: The basename and the location. | |
| 105 // - If it uses commas, the version string is modified to use periods. | |
| 106 // - If there is one, the version string suffix is removed. | |
| 107 // - If there is one, the trailing null character in the subject string of the | |
| 108 // certificate info is removed. | |
| 109 // | |
| 110 // Exposed for testing. | |
| 111 void NormalizeInspectionResult(ModuleInspectionResult* inspection_result); | |
| 112 | |
| 113 } // namespace internal | |
| 114 | |
| 85 #endif // CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ | 115 #endif // CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ |
| OLD | NEW |