| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // For information about interceptions as a whole see | 5 // For information about interceptions as a whole see |
| 6 // http://dev.chromium.org/developers/design-documents/sandbox . | 6 // http://dev.chromium.org/developers/design-documents/sandbox . |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "sandbox/src/interception.h" | 10 #include "sandbox/src/interception.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 DllInterceptionData dll_data; | 368 DllInterceptionData dll_data; |
| 369 dll_data.data_bytes = thunk_bytes; | 369 dll_data.data_bytes = thunk_bytes; |
| 370 dll_data.num_thunks = 0; | 370 dll_data.num_thunks = 0; |
| 371 dll_data.used_bytes = offsetof(DllInterceptionData, thunks); | 371 dll_data.used_bytes = offsetof(DllInterceptionData, thunks); |
| 372 | 372 |
| 373 // this should write all the individual thunks to the child's memory | 373 // this should write all the individual thunks to the child's memory |
| 374 if (!PatchClientFunctions(thunks, thunk_bytes, &dll_data)) | 374 if (!PatchClientFunctions(thunks, thunk_bytes, &dll_data)) |
| 375 return false; | 375 return false; |
| 376 | 376 |
| 377 // and now write the first part of the table to the child's memory | 377 // and now write the first part of the table to the child's memory |
| 378 DWORD written; | 378 SIZE_T written; |
| 379 bool ok = FALSE != ::WriteProcessMemory(child, thunks, &dll_data, | 379 bool ok = FALSE != ::WriteProcessMemory(child, thunks, &dll_data, |
| 380 offsetof(DllInterceptionData, thunks), | 380 offsetof(DllInterceptionData, thunks), |
| 381 &written); | 381 &written); |
| 382 | 382 |
| 383 if (!ok || (offsetof(DllInterceptionData, thunks) != written)) | 383 if (!ok || (offsetof(DllInterceptionData, thunks) != written)) |
| 384 return false; | 384 return false; |
| 385 | 385 |
| 386 // Attempt to protect all the thunks, but ignore failure | 386 // Attempt to protect all the thunks, but ignore failure |
| 387 DWORD old_protection; | 387 DWORD old_protection; |
| 388 ::VirtualProtectEx(child, thunks, thunk_bytes, | 388 ::VirtualProtectEx(child, thunks, thunk_bytes, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 ::FreeLibrary(local_interceptor); | 479 ::FreeLibrary(local_interceptor); |
| 480 #endif | 480 #endif |
| 481 | 481 |
| 482 if (it != interceptions_.end()) | 482 if (it != interceptions_.end()) |
| 483 return false; | 483 return false; |
| 484 | 484 |
| 485 return true; | 485 return true; |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace sandbox | 488 } // namespace sandbox |
| OLD | NEW |