1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/win/src/target_services.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +// Copyright (c) 2012 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 +#ifndef SANDBOX_SRC_TARGET_SERVICES_H__ 1.9 +#define SANDBOX_SRC_TARGET_SERVICES_H__ 1.10 + 1.11 +#include "base/basictypes.h" 1.12 +#include "sandbox/win/src/sandbox.h" 1.13 +#include "sandbox/win/src/win_utils.h" 1.14 + 1.15 +namespace sandbox { 1.16 + 1.17 +class ProcessState { 1.18 + public: 1.19 + ProcessState() : process_state_(0) {} 1.20 + 1.21 + // Returns true if kernel32.dll has been loaded. 1.22 + bool IsKernel32Loaded(); 1.23 + 1.24 + // Returns true if main has been called. 1.25 + bool InitCalled(); 1.26 + 1.27 + // Returns true if LowerToken has been called. 1.28 + bool RevertedToSelf(); 1.29 + 1.30 + // Set the current state. 1.31 + void SetKernel32Loaded(); 1.32 + void SetInitCalled(); 1.33 + void SetRevertedToSelf(); 1.34 + 1.35 + public: 1.36 + int process_state_; 1.37 + DISALLOW_COPY_AND_ASSIGN(ProcessState); 1.38 +}; 1.39 + 1.40 +// This class is an implementation of the TargetServices. 1.41 +// Look in the documentation of sandbox::TargetServices for more info. 1.42 +// Do NOT add a destructor to this class without changing the implementation of 1.43 +// the factory method. 1.44 +class TargetServicesBase : public TargetServices { 1.45 + public: 1.46 + TargetServicesBase(); 1.47 + 1.48 + // Public interface of TargetServices. 1.49 + virtual ResultCode Init(); 1.50 + virtual void LowerToken(); 1.51 + virtual ProcessState* GetState(); 1.52 + virtual ResultCode DuplicateHandle(HANDLE source_handle, 1.53 + DWORD target_process_id, 1.54 + HANDLE* target_handle, 1.55 + DWORD desired_access, 1.56 + DWORD options); 1.57 + 1.58 + // Factory method. 1.59 + static TargetServicesBase* GetInstance(); 1.60 + 1.61 + // Sends a simple IPC Message that has a well-known answer. Returns true 1.62 + // if the IPC was successful and false otherwise. There are 2 versions of 1.63 + // this test: 1 and 2. The first one send a simple message while the 1.64 + // second one send a message with an in/out param. 1.65 + bool TestIPCPing(int version); 1.66 + 1.67 + private: 1.68 + ProcessState process_state_; 1.69 + DISALLOW_COPY_AND_ASSIGN(TargetServicesBase); 1.70 +}; 1.71 + 1.72 +} // namespace sandbox 1.73 + 1.74 +#endif // SANDBOX_SRC_TARGET_SERVICES_H__