Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Side by Side Diff: sandbox/src/sync_interception.cc

Issue 10689170: Move the Windows sandbox to sandbox/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of tree (properly this time) Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/src/sync_interception.h ('k') | sandbox/src/sync_policy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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/src/sync_interception.h"
6
7 #include "sandbox/src/crosscall_client.h"
8 #include "sandbox/src/ipc_tags.h"
9 #include "sandbox/src/policy_params.h"
10 #include "sandbox/src/policy_target.h"
11 #include "sandbox/src/sandbox_factory.h"
12 #include "sandbox/src/sandbox_nt_util.h"
13 #include "sandbox/src/sharedmem_ipc_client.h"
14 #include "sandbox/src/target_services.h"
15
16 namespace sandbox {
17
18 HANDLE WINAPI TargetCreateEventW(CreateEventWFunction orig_CreateEvent,
19 LPSECURITY_ATTRIBUTES security_attributes,
20 BOOL manual_reset, BOOL initial_state,
21 LPCWSTR name) {
22 // Check if the process can create it first.
23 HANDLE handle = orig_CreateEvent(security_attributes, manual_reset,
24 initial_state, name);
25 DWORD original_error = ::GetLastError();
26 if (NULL != handle)
27 return handle;
28
29 // We don't trust that the IPC can work this early.
30 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled())
31 return NULL;
32
33 do {
34 if (security_attributes)
35 break;
36
37 void* memory = GetGlobalIPCMemory();
38 if (NULL == memory)
39 break;
40
41 CountedParameterSet<NameBased> params;
42 params[NameBased::NAME] = ParamPickerMake(name);
43
44 if (!QueryBroker(IPC_CREATEEVENT_TAG, params.GetBase()))
45 break;
46
47 SharedMemIPCClient ipc(memory);
48 CrossCallReturn answer = {0};
49 ResultCode code = CrossCall(ipc, IPC_CREATEEVENT_TAG, name, manual_reset,
50 initial_state, &answer);
51
52 if (SBOX_ALL_OK != code)
53 break;
54
55 ::SetLastError(answer.win32_result);
56 return answer.handle;
57 } while (false);
58
59 ::SetLastError(original_error);
60 return NULL;
61 }
62
63 // Interception of OpenEventW on the child process.
64 // It should never be called directly
65 HANDLE WINAPI TargetOpenEventW(OpenEventWFunction orig_OpenEvent,
66 ACCESS_MASK desired_access, BOOL inherit_handle,
67 LPCWSTR name) {
68 // Check if the process can open it first.
69 HANDLE handle = orig_OpenEvent(desired_access, inherit_handle, name);
70 DWORD original_error = ::GetLastError();
71 if (NULL != handle)
72 return handle;
73
74 // We don't trust that the IPC can work this early.
75 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled())
76 return NULL;
77
78 do {
79 void* memory = GetGlobalIPCMemory();
80 if (NULL == memory)
81 break;
82
83 uint32 inherit_handle_ipc = inherit_handle;
84 CountedParameterSet<OpenEventParams> params;
85 params[OpenEventParams::NAME] = ParamPickerMake(name);
86 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access);
87
88 if (!QueryBroker(IPC_OPENEVENT_TAG, params.GetBase()))
89 break;
90
91 SharedMemIPCClient ipc(memory);
92 CrossCallReturn answer = {0};
93 ResultCode code = CrossCall(ipc, IPC_OPENEVENT_TAG, name, desired_access,
94 inherit_handle_ipc, &answer);
95
96 if (SBOX_ALL_OK != code)
97 break;
98
99 ::SetLastError(answer.win32_result);
100 return answer.handle;
101 } while (false);
102
103 ::SetLastError(original_error);
104 return NULL;
105 }
106
107 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/src/sync_interception.h ('k') | sandbox/src/sync_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698