| Index: base/win/iat_patch_function.cc
|
| diff --git a/base/win/iat_patch_function.cc b/base/win/iat_patch_function.cc
|
| index a4a89028b870f34aa089951009ce06c6ac6f426c..923dc040d3fd400446ad8d1e3129e0fae707e9ba 100644
|
| --- a/base/win/iat_patch_function.cc
|
| +++ b/base/win/iat_patch_function.cc
|
| @@ -56,11 +56,23 @@ DWORD ModifyCode(void* old_code, void* new_code, int length) {
|
| }
|
|
|
| // Change the page protection so that we can write.
|
| + MEMORY_BASIC_INFORMATION memory_info;
|
| DWORD error = NO_ERROR;
|
| DWORD old_page_protection = 0;
|
| +
|
| + if (!VirtualQuery(old_code, &memory_info, sizeof(memory_info))) {
|
| + error = GetLastError();
|
| + return error;
|
| + }
|
| +
|
| + DWORD is_executable = (PAGE_EXECUTE | PAGE_EXECUTE_READ |
|
| + PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY) &
|
| + memory_info.Protect;
|
| +
|
| if (VirtualProtect(old_code,
|
| length,
|
| - PAGE_READWRITE,
|
| + is_executable ? PAGE_EXECUTE_READWRITE :
|
| + PAGE_READWRITE,
|
| &old_page_protection)) {
|
|
|
| // Write the data.
|
| @@ -74,7 +86,6 @@ DWORD ModifyCode(void* old_code, void* new_code, int length) {
|
| &old_page_protection);
|
| } else {
|
| error = GetLastError();
|
| - NOTREACHED();
|
| }
|
|
|
| return error;
|
|
|