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 #include "sandbox/wow_helper/target_code.h" | 5 #include "sandbox/win/wow_helper/target_code.h" |
6 | 6 |
7 namespace sandbox { | 7 namespace sandbox { |
8 | 8 |
9 // Hooks NtMapViewOfSection to detect the load of dlls. | 9 // Hooks NtMapViewOfSection to detect the load of dlls. |
10 NTSTATUS WINAPI TargetNtMapViewOfSection( | 10 NTSTATUS WINAPI TargetNtMapViewOfSection( |
11 PatchInfo *patch_info, HANDLE process, PVOID *base, ULONG_PTR zero_bits, | 11 PatchInfo *patch_info, HANDLE process, PVOID *base, ULONG_PTR zero_bits, |
12 SIZE_T commit_size, PLARGE_INTEGER offset, PSIZE_T view_size, | 12 SIZE_T commit_size, PLARGE_INTEGER offset, PSIZE_T view_size, |
13 SECTION_INHERIT inherit, ULONG allocation_type, ULONG protect) { | 13 SECTION_INHERIT inherit, ULONG allocation_type, ULONG protect) { |
14 NTSTATUS ret = patch_info->orig_MapViewOfSection(patch_info->section, process, | 14 NTSTATUS ret = patch_info->orig_MapViewOfSection(patch_info->section, process, |
15 base, zero_bits, commit_size, | 15 base, zero_bits, commit_size, |
16 offset, view_size, inherit, | 16 offset, view_size, inherit, |
17 allocation_type, protect); | 17 allocation_type, protect); |
18 | 18 |
19 LARGE_INTEGER timeout; | 19 LARGE_INTEGER timeout; |
20 timeout.QuadPart = -(5 * 10000000); // 5 seconds. | 20 timeout.QuadPart = -(5 * 10000000); // 5 seconds. |
21 | 21 |
22 // The wait is alertable. | 22 // The wait is alertable. |
23 patch_info->signal_and_wait(patch_info->dll_load, patch_info->continue_load, | 23 patch_info->signal_and_wait(patch_info->dll_load, patch_info->continue_load, |
24 TRUE, &timeout); | 24 TRUE, &timeout); |
25 | 25 |
26 return ret; | 26 return ret; |
27 } | 27 } |
28 | 28 |
29 // Marks the end of the code to copy to the target process. | 29 // Marks the end of the code to copy to the target process. |
30 NTSTATUS WINAPI TargetEnd() { | 30 NTSTATUS WINAPI TargetEnd() { |
31 return STATUS_SUCCESS; | 31 return STATUS_SUCCESS; |
32 } | 32 } |
33 | 33 |
34 } // namespace sandbox | 34 } // namespace sandbox |
OLD | NEW |