OLD | NEW |
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 #include "chrome_frame/buggy_bho_handling.h" | 5 #include "chrome_frame/buggy_bho_handling.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/process_util.h" |
8 #include "base/win/scoped_comptr.h" | 9 #include "base/win/scoped_comptr.h" |
9 | 10 |
10 #include "chrome_frame/exception_barrier.h" | 11 #include "chrome_frame/exception_barrier.h" |
11 #include "chrome_frame/function_stub.h" | 12 #include "chrome_frame/function_stub.h" |
12 #include "chrome_frame/utils.h" | 13 #include "chrome_frame/utils.h" |
13 #include "chrome_frame/vtable_patch_manager.h" | 14 #include "chrome_frame/vtable_patch_manager.h" |
14 | 15 |
15 namespace buggy_bho { | 16 namespace buggy_bho { |
16 | 17 |
17 base::ThreadLocalPointer<BuggyBhoTls> BuggyBhoTls::s_bad_object_tls_; | 18 base::ThreadLocalPointer<BuggyBhoTls> BuggyBhoTls::s_bad_object_tls_; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 149 } |
149 } | 150 } |
150 patched_ = true; | 151 patched_ = true; |
151 web_browser2_ = browser; | 152 web_browser2_ = browser; |
152 return hr; | 153 return hr; |
153 } | 154 } |
154 | 155 |
155 bool BuggyBhoTls::PatchIfBuggy(IUnknown* unk, const IID& diid) { | 156 bool BuggyBhoTls::PatchIfBuggy(IUnknown* unk, const IID& diid) { |
156 DCHECK(unk); | 157 DCHECK(unk); |
157 PROC* methods = *reinterpret_cast<PROC**>(unk); | 158 PROC* methods = *reinterpret_cast<PROC**>(unk); |
158 HMODULE mod = GetModuleFromAddress(methods[0]); | 159 HMODULE mod = base::GetModuleFromAddress(methods[0]); |
159 if (!IsBuggyBho(mod)) | 160 if (!IsBuggyBho(mod)) |
160 return false; | 161 return false; |
161 | 162 |
162 base::win::ScopedComPtr<IDispatch> disp; | 163 base::win::ScopedComPtr<IDispatch> disp; |
163 HRESULT hr = unk->QueryInterface(diid, | 164 HRESULT hr = unk->QueryInterface(diid, |
164 reinterpret_cast<void**>(disp.Receive())); | 165 reinterpret_cast<void**>(disp.Receive())); |
165 if (FAILED(hr)) // Sometimes only IDispatch QI is supported | 166 if (FAILED(hr)) // Sometimes only IDispatch QI is supported |
166 hr = disp.QueryFrom(unk); | 167 hr = disp.QueryFrom(unk); |
167 DCHECK(SUCCEEDED(hr)); | 168 DCHECK(SUCCEEDED(hr)); |
168 | 169 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } else { | 226 } else { |
226 PinModule(); // No backing out now. | 227 PinModule(); // No backing out now. |
227 ::FlushInstructionCache(::GetCurrentProcess(), invoke, sizeof(PROC)); | 228 ::FlushInstructionCache(::GetCurrentProcess(), invoke, sizeof(PROC)); |
228 } | 229 } |
229 } | 230 } |
230 ::VirtualProtect(invoke, sizeof(PROC), flags, &flags); | 231 ::VirtualProtect(invoke, sizeof(PROC), flags, &flags); |
231 return hr; | 232 return hr; |
232 } | 233 } |
233 | 234 |
234 } // end namespace buggy_bho | 235 } // end namespace buggy_bho |
OLD | NEW |