diff options
author | jln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-18 00:59:15 +0000 |
---|---|---|
committer | jln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-18 00:59:15 +0000 |
commit | 18149178646e45f3d7dde865efbeabbab431799a (patch) | |
tree | cc19ce0fc5cc1927695c789212fab93a195b9d9f /sandbox/win/src/target_services.h | |
parent | 4633cdb53427b31197d3c6f991f07bee2a04e0df (diff) | |
download | chromium_src-18149178646e45f3d7dde865efbeabbab431799a.zip chromium_src-18149178646e45f3d7dde865efbeabbab431799a.tar.gz chromium_src-18149178646e45f3d7dde865efbeabbab431799a.tar.bz2 |
Move the Windows sandbox to sandbox/win
This is a rather large refactor to move the Windows sandbox to the right place.
BUG=
TEST=
NOTRY=true
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10689170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/win/src/target_services.h')
-rw-r--r-- | sandbox/win/src/target_services.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/sandbox/win/src/target_services.h b/sandbox/win/src/target_services.h new file mode 100644 index 0000000..70f173b --- /dev/null +++ b/sandbox/win/src/target_services.h @@ -0,0 +1,71 @@ +// Copyright (c) 2012 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. + +#ifndef SANDBOX_SRC_TARGET_SERVICES_H__ +#define SANDBOX_SRC_TARGET_SERVICES_H__ + +#include "base/basictypes.h" +#include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/win_utils.h" + +namespace sandbox { + +class ProcessState { + public: + ProcessState() : process_state_(0) {} + + // Returns true if kernel32.dll has been loaded. + bool IsKernel32Loaded(); + + // Returns true if main has been called. + bool InitCalled(); + + // Returns true if LowerToken has been called. + bool RevertedToSelf(); + + // Set the current state. + void SetKernel32Loaded(); + void SetInitCalled(); + void SetRevertedToSelf(); + + public: + int process_state_; + DISALLOW_COPY_AND_ASSIGN(ProcessState); +}; + +// This class is an implementation of the TargetServices. +// Look in the documentation of sandbox::TargetServices for more info. +// Do NOT add a destructor to this class without changing the implementation of +// the factory method. +class TargetServicesBase : public TargetServices { + public: + TargetServicesBase(); + + // Public interface of TargetServices. + virtual ResultCode Init(); + virtual void LowerToken(); + virtual ProcessState* GetState(); + virtual ResultCode DuplicateHandle(HANDLE source_handle, + DWORD target_process_id, + HANDLE* target_handle, + DWORD desired_access, + DWORD options); + + // Factory method. + static TargetServicesBase* GetInstance(); + + // Sends a simple IPC Message that has a well-known answer. Returns true + // if the IPC was successful and false otherwise. There are 2 versions of + // this test: 1 and 2. The first one send a simple message while the + // second one send a message with an in/out param. + bool TestIPCPing(int version); + + private: + ProcessState process_state_; + DISALLOW_COPY_AND_ASSIGN(TargetServicesBase); +}; + +} // namespace sandbox + +#endif // SANDBOX_SRC_TARGET_SERVICES_H__ |