michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef SANDBOX_SRC_TARGET_SERVICES_H__ michael@0: #define SANDBOX_SRC_TARGET_SERVICES_H__ michael@0: michael@0: #include "base/basictypes.h" michael@0: #include "sandbox/win/src/sandbox.h" michael@0: #include "sandbox/win/src/win_utils.h" michael@0: michael@0: namespace sandbox { michael@0: michael@0: class ProcessState { michael@0: public: michael@0: ProcessState() : process_state_(0) {} michael@0: michael@0: // Returns true if kernel32.dll has been loaded. michael@0: bool IsKernel32Loaded(); michael@0: michael@0: // Returns true if main has been called. michael@0: bool InitCalled(); michael@0: michael@0: // Returns true if LowerToken has been called. michael@0: bool RevertedToSelf(); michael@0: michael@0: // Set the current state. michael@0: void SetKernel32Loaded(); michael@0: void SetInitCalled(); michael@0: void SetRevertedToSelf(); michael@0: michael@0: public: michael@0: int process_state_; michael@0: DISALLOW_COPY_AND_ASSIGN(ProcessState); michael@0: }; michael@0: michael@0: // This class is an implementation of the TargetServices. michael@0: // Look in the documentation of sandbox::TargetServices for more info. michael@0: // Do NOT add a destructor to this class without changing the implementation of michael@0: // the factory method. michael@0: class TargetServicesBase : public TargetServices { michael@0: public: michael@0: TargetServicesBase(); michael@0: michael@0: // Public interface of TargetServices. michael@0: virtual ResultCode Init(); michael@0: virtual void LowerToken(); michael@0: virtual ProcessState* GetState(); michael@0: virtual ResultCode DuplicateHandle(HANDLE source_handle, michael@0: DWORD target_process_id, michael@0: HANDLE* target_handle, michael@0: DWORD desired_access, michael@0: DWORD options); michael@0: michael@0: // Factory method. michael@0: static TargetServicesBase* GetInstance(); michael@0: michael@0: // Sends a simple IPC Message that has a well-known answer. Returns true michael@0: // if the IPC was successful and false otherwise. There are 2 versions of michael@0: // this test: 1 and 2. The first one send a simple message while the michael@0: // second one send a message with an in/out param. michael@0: bool TestIPCPing(int version); michael@0: michael@0: private: michael@0: ProcessState process_state_; michael@0: DISALLOW_COPY_AND_ASSIGN(TargetServicesBase); michael@0: }; michael@0: michael@0: } // namespace sandbox michael@0: michael@0: #endif // SANDBOX_SRC_TARGET_SERVICES_H__