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 <algorithm> | 10 #include <algorithm> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 if (!(*old_function)) | 137 if (!(*old_function)) |
138 *old_function = pe.RVAToAddr(*eat_entry); | 138 *old_function = pe.RVAToAddr(*eat_entry); |
139 | 139 |
140 AutoProtectMemory memory; | 140 AutoProtectMemory memory; |
141 if (!memory.ChangeProtection(eat_entry, sizeof(DWORD))) | 141 if (!memory.ChangeProtection(eat_entry, sizeof(DWORD))) |
142 return; | 142 return; |
143 | 143 |
144 // Perform the patch. | 144 // Perform the patch. |
145 #pragma warning(push) | 145 #pragma warning(push) |
146 #pragma warning(disable: 4311) | 146 #pragma warning(disable : 4311 4302) |
147 // These casts generate warnings because they are 32 bit specific. | 147 // These casts generate truncation warnings because they are 32 bit specific. |
148 *eat_entry = reinterpret_cast<DWORD>(new_function) - | 148 *eat_entry = reinterpret_cast<DWORD>(new_function) - |
149 reinterpret_cast<DWORD>(module); | 149 reinterpret_cast<DWORD>(module); |
150 #pragma warning(pop) | 150 #pragma warning(pop) |
151 } | 151 } |
152 | 152 |
153 // Performs an IAT interception. | 153 // Performs an IAT interception. |
154 base::win::IATPatchFunction* IATPatch(HMODULE module, const char* function_name, | 154 base::win::IATPatchFunction* IATPatch(HMODULE module, const char* function_name, |
155 void* new_function, void** old_function) { | 155 void* new_function, void** old_function) { |
156 if (!module) | 156 if (!module) |
157 return NULL; | 157 return NULL; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 PatchLoadedModules(hooks); | 276 PatchLoadedModules(hooks); |
277 } else { | 277 } else { |
278 base::win::DisableHandleVerifier(); | 278 base::win::DisableHandleVerifier(); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 void RemoveHandleHooks() { | 282 void RemoveHandleHooks() { |
283 // We are partching all loaded modules without forcing them to stay in memory, | 283 // We are partching all loaded modules without forcing them to stay in memory, |
284 // removing patches is not safe. | 284 // removing patches is not safe. |
285 } | 285 } |
OLD | NEW |