security/sandbox/win/src/named_pipe_dispatcher.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/named_pipe_dispatcher.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "sandbox/win/src/named_pipe_dispatcher.h"
     1.9 +
    1.10 +#include "base/basictypes.h"
    1.11 +
    1.12 +#include "sandbox/win/src/crosscall_client.h"
    1.13 +#include "sandbox/win/src/interception.h"
    1.14 +#include "sandbox/win/src/interceptors.h"
    1.15 +#include "sandbox/win/src/ipc_tags.h"
    1.16 +#include "sandbox/win/src/named_pipe_interception.h"
    1.17 +#include "sandbox/win/src/named_pipe_policy.h"
    1.18 +#include "sandbox/win/src/policy_broker.h"
    1.19 +#include "sandbox/win/src/policy_params.h"
    1.20 +#include "sandbox/win/src/sandbox.h"
    1.21 +
    1.22 +
    1.23 +namespace sandbox {
    1.24 +
    1.25 +NamedPipeDispatcher::NamedPipeDispatcher(PolicyBase* policy_base)
    1.26 +    : policy_base_(policy_base) {
    1.27 +  static const IPCCall create_params = {
    1.28 +    {IPC_CREATENAMEDPIPEW_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE, ULONG_TYPE,
    1.29 +     ULONG_TYPE, ULONG_TYPE, ULONG_TYPE},
    1.30 +    reinterpret_cast<CallbackGeneric>(&NamedPipeDispatcher::CreateNamedPipe)
    1.31 +  };
    1.32 +
    1.33 +  ipc_calls_.push_back(create_params);
    1.34 +}
    1.35 +
    1.36 +bool NamedPipeDispatcher::SetupService(InterceptionManager* manager,
    1.37 +                                       int service) {
    1.38 +  if (IPC_CREATENAMEDPIPEW_TAG == service)
    1.39 +    return INTERCEPT_EAT(manager, L"kernel32.dll", CreateNamedPipeW,
    1.40 +                         CREATE_NAMED_PIPE_ID, 36);
    1.41 +
    1.42 +  return false;
    1.43 +}
    1.44 +
    1.45 +bool NamedPipeDispatcher::CreateNamedPipe(
    1.46 +    IPCInfo* ipc, std::wstring* name, DWORD open_mode, DWORD pipe_mode,
    1.47 +    DWORD max_instances, DWORD out_buffer_size, DWORD in_buffer_size,
    1.48 +    DWORD default_timeout) {
    1.49 +  const wchar_t* pipe_name = name->c_str();
    1.50 +  CountedParameterSet<NameBased> params;
    1.51 +  params[NameBased::NAME] = ParamPickerMake(pipe_name);
    1.52 +
    1.53 +  EvalResult eval = policy_base_->EvalPolicy(IPC_CREATENAMEDPIPEW_TAG,
    1.54 +                                             params.GetBase());
    1.55 +
    1.56 +  HANDLE pipe;
    1.57 +  DWORD ret = NamedPipePolicy::CreateNamedPipeAction(eval, *ipc->client_info,
    1.58 +                                                     *name, open_mode,
    1.59 +                                                     pipe_mode, max_instances,
    1.60 +                                                     out_buffer_size,
    1.61 +                                                     in_buffer_size,
    1.62 +                                                     default_timeout, &pipe);
    1.63 +
    1.64 +  ipc->return_info.win32_result = ret;
    1.65 +  ipc->return_info.handle = pipe;
    1.66 +  return true;
    1.67 +}
    1.68 +
    1.69 +}  // namespace sandbox

mercurial