| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ | 5 #ifndef SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ |
| 6 #define SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ | 6 #define SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // We act as a policy dispatcher, implementing the handler for the "ping" IPC, | 31 // We act as a policy dispatcher, implementing the handler for the "ping" IPC, |
| 32 // so we have to provide the appropriate handler on the OnMessageReady method. | 32 // so we have to provide the appropriate handler on the OnMessageReady method. |
| 33 // There is a static_cast for the handler, and the compiler only performs the | 33 // There is a static_cast for the handler, and the compiler only performs the |
| 34 // cast if the first base class is Dispatcher. | 34 // cast if the first base class is Dispatcher. |
| 35 class PolicyBase : public Dispatcher, public TargetPolicy { | 35 class PolicyBase : public Dispatcher, public TargetPolicy { |
| 36 public: | 36 public: |
| 37 PolicyBase(); | 37 PolicyBase(); |
| 38 | 38 |
| 39 // TargetPolicy: | 39 // TargetPolicy: |
| 40 virtual void AddRef() override; | 40 void AddRef() override; |
| 41 virtual void Release() override; | 41 void Release() override; |
| 42 virtual ResultCode SetTokenLevel(TokenLevel initial, | 42 ResultCode SetTokenLevel(TokenLevel initial, |
| 43 TokenLevel lockdown) override; | 43 TokenLevel lockdown) override; |
| 44 virtual TokenLevel GetInitialTokenLevel() const override; | 44 TokenLevel GetInitialTokenLevel() const override; |
| 45 virtual TokenLevel GetLockdownTokenLevel() const override; | 45 TokenLevel GetLockdownTokenLevel() const override; |
| 46 virtual ResultCode SetJobLevel(JobLevel job_level, | 46 ResultCode SetJobLevel(JobLevel job_level, |
| 47 uint32 ui_exceptions) override; | 47 uint32 ui_exceptions) override; |
| 48 virtual ResultCode SetJobMemoryLimit(size_t memory_limit) override; | 48 ResultCode SetJobMemoryLimit(size_t memory_limit) override; |
| 49 virtual ResultCode SetAlternateDesktop(bool alternate_winstation) override; | 49 ResultCode SetAlternateDesktop(bool alternate_winstation) override; |
| 50 virtual base::string16 GetAlternateDesktop() const override; | 50 base::string16 GetAlternateDesktop() const override; |
| 51 virtual ResultCode CreateAlternateDesktop(bool alternate_winstation) override; | 51 ResultCode CreateAlternateDesktop(bool alternate_winstation) override; |
| 52 virtual void DestroyAlternateDesktop() override; | 52 void DestroyAlternateDesktop() override; |
| 53 virtual ResultCode SetIntegrityLevel(IntegrityLevel integrity_level) override; | 53 ResultCode SetIntegrityLevel(IntegrityLevel integrity_level) override; |
| 54 virtual IntegrityLevel GetIntegrityLevel() const override; | 54 IntegrityLevel GetIntegrityLevel() const override; |
| 55 virtual ResultCode SetDelayedIntegrityLevel( | 55 ResultCode SetDelayedIntegrityLevel( |
| 56 IntegrityLevel integrity_level) override; | 56 IntegrityLevel integrity_level) override; |
| 57 virtual ResultCode SetAppContainer(const wchar_t* sid) override; | 57 ResultCode SetAppContainer(const wchar_t* sid) override; |
| 58 virtual ResultCode SetCapability(const wchar_t* sid) override; | 58 ResultCode SetCapability(const wchar_t* sid) override; |
| 59 virtual ResultCode SetLowBox(const wchar_t* sid) override; | 59 ResultCode SetLowBox(const wchar_t* sid) override; |
| 60 virtual ResultCode SetProcessMitigations(MitigationFlags flags) override; | 60 ResultCode SetProcessMitigations(MitigationFlags flags) override; |
| 61 virtual MitigationFlags GetProcessMitigations() override; | 61 MitigationFlags GetProcessMitigations() override; |
| 62 virtual ResultCode SetDelayedProcessMitigations( | 62 ResultCode SetDelayedProcessMitigations( |
| 63 MitigationFlags flags) override; | 63 MitigationFlags flags) override; |
| 64 virtual MitigationFlags GetDelayedProcessMitigations() const override; | 64 MitigationFlags GetDelayedProcessMitigations() const override; |
| 65 virtual void SetStrictInterceptions() override; | 65 void SetStrictInterceptions() override; |
| 66 virtual ResultCode SetStdoutHandle(HANDLE handle) override; | 66 ResultCode SetStdoutHandle(HANDLE handle) override; |
| 67 virtual ResultCode SetStderrHandle(HANDLE handle) override; | 67 ResultCode SetStderrHandle(HANDLE handle) override; |
| 68 virtual ResultCode AddRule(SubSystem subsystem, Semantics semantics, | 68 ResultCode AddRule(SubSystem subsystem, Semantics semantics, |
| 69 const wchar_t* pattern) override; | 69 const wchar_t* pattern) override; |
| 70 virtual ResultCode AddDllToUnload(const wchar_t* dll_name) override; | 70 ResultCode AddDllToUnload(const wchar_t* dll_name) override; |
| 71 virtual ResultCode AddKernelObjectToClose( | 71 ResultCode AddKernelObjectToClose( |
| 72 const base::char16* handle_type, | 72 const base::char16* handle_type, |
| 73 const base::char16* handle_name) override; | 73 const base::char16* handle_name) override; |
| 74 | 74 |
| 75 // Dispatcher: | 75 // Dispatcher: |
| 76 virtual Dispatcher* OnMessageReady(IPCParams* ipc, | 76 Dispatcher* OnMessageReady(IPCParams* ipc, |
| 77 CallbackGeneric* callback) override; | 77 CallbackGeneric* callback) override; |
| 78 virtual bool SetupService(InterceptionManager* manager, int service) override; | 78 bool SetupService(InterceptionManager* manager, int service) override; |
| 79 | 79 |
| 80 // Creates a Job object with the level specified in a previous call to | 80 // Creates a Job object with the level specified in a previous call to |
| 81 // SetJobLevel(). | 81 // SetJobLevel(). |
| 82 ResultCode MakeJobObject(HANDLE* job); | 82 ResultCode MakeJobObject(HANDLE* job); |
| 83 | 83 |
| 84 // Creates the two tokens with the levels specified in a previous call to | 84 // Creates the two tokens with the levels specified in a previous call to |
| 85 // SetTokenLevel(). | 85 // SetTokenLevel(). |
| 86 ResultCode MakeTokens(HANDLE* initial, HANDLE* lockdown); | 86 ResultCode MakeTokens(HANDLE* initial, HANDLE* lockdown); |
| 87 | 87 |
| 88 const AppContainerAttributes* GetAppContainer() const; | 88 const AppContainerAttributes* GetAppContainer() const; |
| 89 | 89 |
| 90 const PSID GetLowBoxSid() const; | 90 const PSID GetLowBoxSid() const; |
| 91 | 91 |
| 92 // Adds a target process to the internal list of targets. Internally a | 92 // Adds a target process to the internal list of targets. Internally a |
| 93 // call to TargetProcess::Init() is issued. | 93 // call to TargetProcess::Init() is issued. |
| 94 bool AddTarget(TargetProcess* target); | 94 bool AddTarget(TargetProcess* target); |
| 95 | 95 |
| 96 // Called when there are no more active processes in a Job. | 96 // Called when there are no more active processes in a Job. |
| 97 // Removes a Job object associated with this policy and the target associated | 97 // Removes a Job object associated with this policy and the target associated |
| 98 // with the job. | 98 // with the job. |
| 99 bool OnJobEmpty(HANDLE job); | 99 bool OnJobEmpty(HANDLE job); |
| 100 | 100 |
| 101 EvalResult EvalPolicy(int service, CountedParameterSetBase* params); | 101 EvalResult EvalPolicy(int service, CountedParameterSetBase* params); |
| 102 | 102 |
| 103 HANDLE GetStdoutHandle(); | 103 HANDLE GetStdoutHandle(); |
| 104 HANDLE GetStderrHandle(); | 104 HANDLE GetStderrHandle(); |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 ~PolicyBase(); | 107 ~PolicyBase() override; |
| 108 | 108 |
| 109 // Test IPC providers. | 109 // Test IPC providers. |
| 110 bool Ping(IPCInfo* ipc, void* cookie); | 110 bool Ping(IPCInfo* ipc, void* cookie); |
| 111 | 111 |
| 112 // Returns a dispatcher from ipc_targets_. | 112 // Returns a dispatcher from ipc_targets_. |
| 113 Dispatcher* GetDispatcher(int ipc_tag); | 113 Dispatcher* GetDispatcher(int ipc_tag); |
| 114 | 114 |
| 115 // Sets up interceptions for a new target. | 115 // Sets up interceptions for a new target. |
| 116 bool SetupAllInterceptions(TargetProcess* target); | 116 bool SetupAllInterceptions(TargetProcess* target); |
| 117 | 117 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 static HDESK alternate_desktop_handle_; | 166 static HDESK alternate_desktop_handle_; |
| 167 static HWINSTA alternate_winstation_handle_; | 167 static HWINSTA alternate_winstation_handle_; |
| 168 static IntegrityLevel alternate_desktop_integrity_level_label_; | 168 static IntegrityLevel alternate_desktop_integrity_level_label_; |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(PolicyBase); | 170 DISALLOW_COPY_AND_ASSIGN(PolicyBase); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 } // namespace sandbox | 173 } // namespace sandbox |
| 174 | 174 |
| 175 #endif // SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ | 175 #endif // SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ |
| OLD | NEW |