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