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/installer/util/advanced_firewall_manager_win.h" | 5 #include "chrome/installer/util/advanced_firewall_manager_win.h" |
6 | 6 |
| 7 #include <objbase.h> |
7 #include <stddef.h> | 8 #include <stddef.h> |
8 | 9 |
9 #include "base/guid.h" | 10 #include "base/guid.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/win/scoped_bstr.h" | 15 #include "base/win/scoped_bstr.h" |
15 #include "base/win/scoped_variant.h" | 16 #include "base/win/scoped_variant.h" |
16 | 17 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void AdvancedFirewallManager::GetAllRules( | 152 void AdvancedFirewallManager::GetAllRules( |
152 std::vector<base::win::ScopedComPtr<INetFwRule> >* rules) { | 153 std::vector<base::win::ScopedComPtr<INetFwRule> >* rules) { |
153 base::win::ScopedComPtr<IUnknown> rules_enum_unknown; | 154 base::win::ScopedComPtr<IUnknown> rules_enum_unknown; |
154 HRESULT hr = firewall_rules_->get__NewEnum(rules_enum_unknown.GetAddressOf()); | 155 HRESULT hr = firewall_rules_->get__NewEnum(rules_enum_unknown.GetAddressOf()); |
155 if (FAILED(hr)) { | 156 if (FAILED(hr)) { |
156 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 157 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
157 return; | 158 return; |
158 } | 159 } |
159 | 160 |
160 base::win::ScopedComPtr<IEnumVARIANT> rules_enum; | 161 base::win::ScopedComPtr<IEnumVARIANT> rules_enum; |
161 hr = rules_enum.QueryFrom(rules_enum_unknown.Get()); | 162 hr = rules_enum_unknown.CopyTo(rules_enum.GetAddressOf()); |
162 if (FAILED(hr)) { | 163 if (FAILED(hr)) { |
163 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 164 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
164 return; | 165 return; |
165 } | 166 } |
166 | 167 |
167 for (;;) { | 168 for (;;) { |
168 base::win::ScopedVariant rule_var; | 169 base::win::ScopedVariant rule_var; |
169 hr = rules_enum->Next(1, rule_var.Receive(), NULL); | 170 hr = rules_enum->Next(1, rule_var.Receive(), NULL); |
170 DLOG_IF(ERROR, FAILED(hr)) << logging::SystemErrorCodeToString(hr); | 171 DLOG_IF(ERROR, FAILED(hr)) << logging::SystemErrorCodeToString(hr); |
171 if (hr != S_OK) | 172 if (hr != S_OK) |
172 break; | 173 break; |
173 DCHECK_EQ(VT_DISPATCH, rule_var.type()); | 174 DCHECK_EQ(VT_DISPATCH, rule_var.type()); |
174 if (VT_DISPATCH != rule_var.type()) { | 175 if (VT_DISPATCH != rule_var.type()) { |
175 DLOG(ERROR) << "Unexpected type"; | 176 DLOG(ERROR) << "Unexpected type"; |
176 continue; | 177 continue; |
177 } | 178 } |
178 base::win::ScopedComPtr<INetFwRule> rule; | 179 base::win::ScopedComPtr<INetFwRule> rule; |
179 hr = rule.QueryFrom(V_DISPATCH(rule_var.ptr())); | 180 hr = V_DISPATCH(rule_var.ptr())->QueryInterface(IID_PPV_ARGS(&rule)); |
180 if (FAILED(hr)) { | 181 if (FAILED(hr)) { |
181 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 182 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
182 continue; | 183 continue; |
183 } | 184 } |
184 | 185 |
185 base::win::ScopedBstr path; | 186 base::win::ScopedBstr path; |
186 hr = rule->get_ApplicationName(path.Receive()); | 187 hr = rule->get_ApplicationName(path.Receive()); |
187 if (FAILED(hr)) { | 188 if (FAILED(hr)) { |
188 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 189 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
189 continue; | 190 continue; |
190 } | 191 } |
191 | 192 |
192 if (!path || | 193 if (!path || |
193 !base::FilePath::CompareEqualIgnoreCase(static_cast<BSTR>(path), | 194 !base::FilePath::CompareEqualIgnoreCase(static_cast<BSTR>(path), |
194 app_path_.value())) { | 195 app_path_.value())) { |
195 continue; | 196 continue; |
196 } | 197 } |
197 | 198 |
198 rules->push_back(rule); | 199 rules->push_back(rule); |
199 } | 200 } |
200 } | 201 } |
201 | 202 |
202 } // namespace installer | 203 } // namespace installer |
OLD | NEW |