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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/lpc_interception.cc
diff --git a/sandbox/win/src/lpc_interception.cc b/sandbox/win/src/lpc_interception.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8399b48bb76770cf45499c89efef3b62f39830c
--- /dev/null
+++ b/sandbox/win/src/lpc_interception.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sandbox/win/src/lpc_interception.h"
+
+#include "sandbox/win/src/crosscall_client.h"
+#include "sandbox/win/src/ipc_tags.h"
+#include "sandbox/win/src/policy_params.h"
+#include "sandbox/win/src/policy_target.h"
+#include "sandbox/win/src/sandbox_factory.h"
+#include "sandbox/win/src/sandbox_nt_util.h"
+#include "sandbox/win/src/sharedmem_ipc_client.h"
+#include "sandbox/win/src/target_services.h"
+
+namespace sandbox {
+
+NTSTATUS WINAPI TargetNtAlpcConnectPort(
+ NtAlpcConnectPortFunction orig_AlpcConnectPort,
+ PHANDLE port_handle,
+ PUNICODE_STRING port_name,
+ POBJECT_ATTRIBUTES object_attributes,
+ PALPC_PORT_ATTRIBUTES port_attributes,
+ ULONG flags,
+ void* sid,
+ void* connection_message,
+ ULONG* buffer_length,
+ void* out_message_attributes,
+ void* in_message_attributes,
+ PLARGE_INTEGER timeout) {
+ NTSTATUS status = orig_AlpcConnectPort(port_handle, port_name,
+ object_attributes, port_attributes, flags, sid, connection_message,
+ buffer_length, out_message_attributes, in_message_attributes, timeout);
+ if (status != STATUS_ACCESS_DENIED || !port_name || object_attributes)
+ return status;
+
+ // We don't trust that the IPC can work this early.
+ if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled())
+ return status;
+
+ do {
+ if (!ValidParameter(port_handle, sizeof(HANDLE), WRITE))
+ break;
+
+ void* memory = GetGlobalIPCMemory();
+ if (memory == NULL)
+ break;
+
+ wchar_t* name = NULL;
+
+ NTSTATUS ret = AllocAndCopyUnicodeString(port_name, &name);
+ if (!NT_SUCCESS(ret) || name == NULL)
+ break;
+
+ ALPC_PORT_ATTRIBUTES copied_port_attributes = {0};
+ if (port_attributes)
+ copied_port_attributes = *port_attributes;
+
+ CrossCallReturn answer = {0};
+ answer.nt_status = status;
+ CountedParameterSet<NameBased> params;
+ params[NameBased::NAME] = ParamPickerMake(name);
+
+ if (0 && !QueryBroker(IPC_NTCONNECTALPCPORT_TAG, params.GetBase()))
+ return SBOX_ERROR_GENERIC;
+
+ SharedMemIPCClient ipc(memory);
+ ResultCode code = CrossCall(ipc, IPC_NTCONNECTALPCPORT_TAG, name, &answer);
+ operator delete(name, NT_ALLOC);
+
+ if (code != SBOX_ALL_OK) {
+ status = answer.nt_status;
+ break;
+ }
+ __try {
+ *port_handle = answer.handle;
+ status = STATUS_SUCCESS;
+ } __except(EXCEPTION_EXECUTE_HANDLER) {
+ break;
+ }
+ } while (false);
+
+ return status;
+}
+
+} // namespace sandbox
« 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