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/app/close_handle_hook_win.h" | 5 #include "chrome/app/close_handle_hook_win.h" |
6 | 6 |
7 #include <Windows.h> | 7 #include <Windows.h> |
8 #include <psapi.h> | 8 #include <psapi.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 135 |
136 if (!(*old_function)) | 136 if (!(*old_function)) |
137 *old_function = pe.RVAToAddr(*eat_entry); | 137 *old_function = pe.RVAToAddr(*eat_entry); |
138 | 138 |
139 AutoProtectMemory memory; | 139 AutoProtectMemory memory; |
140 if (!memory.ChangeProtection(eat_entry, sizeof(DWORD))) | 140 if (!memory.ChangeProtection(eat_entry, sizeof(DWORD))) |
141 return; | 141 return; |
142 | 142 |
143 // Perform the patch. | 143 // Perform the patch. |
144 #pragma warning(push) | 144 #pragma warning(push) |
145 #pragma warning(disable: 4311) | 145 #pragma warning(disable : 4311 4302) |
146 // These casts generate warnings because they are 32 bit specific. | 146 // These casts generate truncation warnings because they are 32 bit specific. |
147 *eat_entry = reinterpret_cast<DWORD>(new_function) - | 147 *eat_entry = reinterpret_cast<DWORD>(new_function) - |
148 reinterpret_cast<DWORD>(module); | 148 reinterpret_cast<DWORD>(module); |
Nico
2015/11/18 02:02:35
I guess we don't run this code in 64-bit?
brucedawson
2015/11/18 02:06:04
Correct. UseHooks (line 234) unconditionally retur
Will Harris
2015/11/18 02:08:17
looks like these should look more like the EAT hoo
Nico
2015/11/18 02:09:39
Yeah, if this isn't called on 64-bit then it shoul
| |
149 #pragma warning(pop) | 149 #pragma warning(pop) |
150 } | 150 } |
151 | 151 |
152 // Performs an IAT interception. | 152 // Performs an IAT interception. |
153 base::win::IATPatchFunction* IATPatch(HMODULE module, const char* function_name, | 153 base::win::IATPatchFunction* IATPatch(HMODULE module, const char* function_name, |
154 void* new_function, void** old_function) { | 154 void* new_function, void** old_function) { |
155 if (!module) | 155 if (!module) |
156 return NULL; | 156 return NULL; |
157 | 157 |
158 base::win::IATPatchFunction* patch = new base::win::IATPatchFunction; | 158 base::win::IATPatchFunction* patch = new base::win::IATPatchFunction; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 PatchLoadedModules(hooks); | 275 PatchLoadedModules(hooks); |
276 } else { | 276 } else { |
277 base::win::DisableHandleVerifier(); | 277 base::win::DisableHandleVerifier(); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 void RemoveHandleHooks() { | 281 void RemoveHandleHooks() { |
282 // We are partching all loaded modules without forcing them to stay in memory, | 282 // We are partching all loaded modules without forcing them to stay in memory, |
283 // removing patches is not safe. | 283 // removing patches is not safe. |
284 } | 284 } |
OLD | NEW |