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

Side by Side Diff: sandbox/win/src/lpc_interception.cc

Issue 1296223005: Continuing changes for lpc proxy Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « sandbox/win/src/lpc_interception.h ('k') | sandbox/win/src/lpc_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/win/src/lpc_interception.h"
6
7 #include "sandbox/win/src/crosscall_client.h"
8 #include "sandbox/win/src/ipc_tags.h"
9 #include "sandbox/win/src/policy_params.h"
10 #include "sandbox/win/src/policy_target.h"
11 #include "sandbox/win/src/sandbox_factory.h"
12 #include "sandbox/win/src/sandbox_nt_util.h"
13 #include "sandbox/win/src/sharedmem_ipc_client.h"
14 #include "sandbox/win/src/target_services.h"
15
16 namespace sandbox {
17
18 NTSTATUS WINAPI TargetNtAlpcConnectPort(
19 NtAlpcConnectPortFunction orig_AlpcConnectPort,
20 PHANDLE port_handle,
21 PUNICODE_STRING port_name,
22 POBJECT_ATTRIBUTES object_attributes,
23 PALPC_PORT_ATTRIBUTES port_attributes,
24 ULONG flags,
25 void* sid,
26 void* connection_message,
27 ULONG* buffer_length,
28 void* out_message_attributes,
29 void* in_message_attributes,
30 PLARGE_INTEGER timeout) {
31 NTSTATUS status = orig_AlpcConnectPort(port_handle, port_name,
32 object_attributes, port_attributes, flags, sid, connection_message,
33 buffer_length, out_message_attributes, in_message_attributes, timeout);
34 if (status != STATUS_ACCESS_DENIED || !port_name || object_attributes)
35 return status;
36
37 // We don't trust that the IPC can work this early.
38 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled())
39 return status;
40
41 do {
42 if (!ValidParameter(port_handle, sizeof(HANDLE), WRITE))
43 break;
44
45 void* memory = GetGlobalIPCMemory();
46 if (memory == NULL)
47 break;
48
49 wchar_t* name = NULL;
50
51 NTSTATUS ret = AllocAndCopyUnicodeString(port_name, &name);
52 if (!NT_SUCCESS(ret) || name == NULL)
53 break;
54
55 ALPC_PORT_ATTRIBUTES copied_port_attributes = {0};
56 if (port_attributes)
57 copied_port_attributes = *port_attributes;
58
59 CrossCallReturn answer = {0};
60 answer.nt_status = status;
61 CountedParameterSet<NameBased> params;
62 params[NameBased::NAME] = ParamPickerMake(name);
63
64 if (0 && !QueryBroker(IPC_NTCONNECTALPCPORT_TAG, params.GetBase()))
65 return SBOX_ERROR_GENERIC;
66
67 SharedMemIPCClient ipc(memory);
68 ResultCode code = CrossCall(ipc, IPC_NTCONNECTALPCPORT_TAG, name, &answer);
69 operator delete(name, NT_ALLOC);
70
71 if (code != SBOX_ALL_OK) {
72 status = answer.nt_status;
73 break;
74 }
75 __try {
76 *port_handle = answer.handle;
77 status = STATUS_SUCCESS;
78 } __except(EXCEPTION_EXECUTE_HANDLER) {
79 break;
80 }
81 } while (false);
82
83 return status;
84 }
85
86 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/lpc_interception.h ('k') | sandbox/win/src/lpc_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698