OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/safe_browsing/environment_data_collection_win.h" | 5 #include "chrome/browser/safe_browsing/environment_data_collection_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/win/registry.h" | |
13 #include "chrome/browser/install_verification/win/module_info.h" | 14 #include "chrome/browser/install_verification/win/module_info.h" |
14 #include "chrome/browser/install_verification/win/module_verification_common.h" | 15 #include "chrome/browser/install_verification/win/module_verification_common.h" |
15 #include "chrome/browser/net/service_providers_win.h" | 16 #include "chrome/browser/net/service_providers_win.h" |
16 #include "chrome/browser/safe_browsing/path_sanitizer.h" | 17 #include "chrome/browser/safe_browsing/path_sanitizer.h" |
17 #include "chrome/common/safe_browsing/csd.pb.h" | 18 #include "chrome/common/safe_browsing/csd.pb.h" |
19 #include "chrome_elf/chrome_elf_constants.h" | |
18 | 20 |
19 namespace safe_browsing { | 21 namespace safe_browsing { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 // Helper function for expanding all environment variables in |path|. | 25 // Helper function for expanding all environment variables in |path|. |
24 base::string16 ExpandEnvironmentVariables(const base::string16& path) { | 26 base::string16 ExpandEnvironmentVariables(const base::string16& path) { |
25 static const DWORD kMaxBuffer = 32 * 1024; // Max according to MSDN. | 27 static const DWORD kMaxBuffer = 32 * 1024; // Max according to MSDN. |
26 base::string16 path_expanded; | 28 base::string16 path_expanded; |
27 DWORD path_len = MAX_PATH; | 29 DWORD path_len = MAX_PATH; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 83 |
82 // Look for a match between LSPs and loaded dlls. | 84 // Look for a match between LSPs and loaded dlls. |
83 for (int i = 0; i < process->dll_size(); ++i) { | 85 for (int i = 0; i < process->dll_size(); ++i) { |
84 if (lsp_paths.count(base::UTF8ToWide(process->dll(i).path()))) { | 86 if (lsp_paths.count(base::UTF8ToWide(process->dll(i).path()))) { |
85 process->mutable_dll(i) | 87 process->mutable_dll(i) |
86 ->add_feature(ClientIncidentReport_EnvironmentData_Process_Dll::LSP); | 88 ->add_feature(ClientIncidentReport_EnvironmentData_Process_Dll::LSP); |
87 } | 89 } |
88 } | 90 } |
89 } | 91 } |
90 | 92 |
93 void CollectDllBlacklistData( | |
94 ClientIncidentReport_EnvironmentData_Process* process) { | |
95 base::win::RegKey finch_blacklist_reigstry_key( | |
grt (UTC plus 2)
2014/06/19 20:06:59
i think this function can be simplified to:
{
Pa
krstnmnlsn
2014/06/19 22:13:15
wow, I didn't know that existed. that's much nicer
| |
96 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_QUERY_VALUE); | |
97 | |
98 if (!finch_blacklist_reigstry_key.Valid()) | |
99 return; | |
100 | |
101 std::wstring name; | |
102 std::wstring value; | |
103 PathSanitizer path_sanitizer; | |
104 int value_count = finch_blacklist_reigstry_key.GetValueCount(); | |
105 | |
106 for (int i = 0; i < value_count; ++i) { | |
107 finch_blacklist_reigstry_key.GetValueNameAt(i, &name); | |
108 finch_blacklist_reigstry_key.ReadValue(name.c_str(), &value); | |
109 | |
110 base::FilePath dll_name(value); | |
111 path_sanitizer.StripHomeDirectory(&dll_name); | |
112 process->add_blacklisted_dll(dll_name.AsUTF8Unsafe()); | |
113 } | |
114 } | |
115 | |
91 void CollectPlatformProcessData( | 116 void CollectPlatformProcessData( |
92 ClientIncidentReport_EnvironmentData_Process* process) { | 117 ClientIncidentReport_EnvironmentData_Process* process) { |
93 CollectDlls(process); | 118 CollectDlls(process); |
94 RecordLspFeature(process); | 119 RecordLspFeature(process); |
120 | |
grt (UTC plus 2)
2014/06/19 20:06:59
nit: remove newline
krstnmnlsn
2014/06/19 22:13:15
Done.
| |
121 CollectDllBlacklistData(process); | |
95 } | 122 } |
96 | 123 |
97 } // namespace safe_browsing | 124 } // namespace safe_browsing |
OLD | NEW |