security/sandbox/win/src/sandbox.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/sandbox.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +// Copyright (c) 2006-2008 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 <stdio.h>
     1.9 +#include <windows.h>
    1.10 +#include "sandbox/win/src/sandbox.h"
    1.11 +#include "sandbox/win/src/sandbox_factory.h"
    1.12 +#include "sandbox/win/src/broker_services.h"
    1.13 +#include "sandbox/win/src/target_services.h"
    1.14 +
    1.15 +namespace sandbox {
    1.16 +// The section for IPC and policy.
    1.17 +SANDBOX_INTERCEPT HANDLE  g_shared_section = NULL;
    1.18 +
    1.19 +static bool               s_is_broker =  false;
    1.20 +
    1.21 +// GetBrokerServices: the current implementation relies on a shared section
    1.22 +// that is created by the broker and opened by the target.
    1.23 +BrokerServices* SandboxFactory::GetBrokerServices() {
    1.24 +  // Can't be the broker if the shared section is open.
    1.25 +  if (NULL != g_shared_section) {
    1.26 +    return NULL;
    1.27 +  }
    1.28 +  // If the shared section does not exist we are the broker, then create
    1.29 +  // the broker object.
    1.30 +  s_is_broker = true;
    1.31 +  return BrokerServicesBase::GetInstance();
    1.32 +}
    1.33 +
    1.34 +// GetTargetServices implementation must follow the same technique as the
    1.35 +// GetBrokerServices, but in this case the logic is the opposite.
    1.36 +TargetServices* SandboxFactory::GetTargetServices() {
    1.37 +  // Can't be the target if the section handle is not valid.
    1.38 +  if (NULL == g_shared_section) {
    1.39 +    return NULL;
    1.40 +  }
    1.41 +  // We are the target
    1.42 +  s_is_broker = false;
    1.43 +  // Creates and returns the target services implementation.
    1.44 +  return TargetServicesBase::GetInstance();
    1.45 +}
    1.46 +
    1.47 +}  // namespace sandbox

mercurial