Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: sandbox/src/sandbox_policy_base.h

Issue 10689170: Move the Windows sandbox to sandbox/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of tree (properly this time) Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/src/sandbox_policy.h ('k') | sandbox/src/sandbox_policy_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_SRC_SANDBOX_POLICY_BASE_H_
6 #define SANDBOX_SRC_SANDBOX_POLICY_BASE_H_
7
8 #include <windows.h>
9
10 #include <list>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "base/string16.h"
16 #include "sandbox/src/crosscall_server.h"
17 #include "sandbox/src/handle_closer.h"
18 #include "sandbox/src/ipc_tags.h"
19 #include "sandbox/src/policy_engine_opcodes.h"
20 #include "sandbox/src/policy_engine_params.h"
21 #include "sandbox/src/sandbox_policy.h"
22 #include "sandbox/src/win_utils.h"
23
24 namespace sandbox {
25
26 class LowLevelPolicy;
27 class TargetProcess;
28 struct PolicyGlobal;
29
30 // We act as a policy dispatcher, implementing the handler for the "ping" IPC,
31 // so we have to provide the appropriate handler on the OnMessageReady method.
32 // There is a static_cast for the handler, and the compiler only performs the
33 // cast if the first base class is Dispatcher.
34 class PolicyBase : public Dispatcher, public TargetPolicy {
35 public:
36 PolicyBase();
37
38 // TargetPolicy:
39 virtual void AddRef() OVERRIDE;
40 virtual void Release() OVERRIDE;
41 virtual ResultCode SetTokenLevel(TokenLevel initial,
42 TokenLevel lockdown) OVERRIDE;
43 virtual ResultCode SetJobLevel(JobLevel job_level,
44 uint32 ui_exceptions) OVERRIDE;
45 virtual ResultCode SetAlternateDesktop(bool alternate_winstation) OVERRIDE;
46 virtual std::wstring GetAlternateDesktop() const OVERRIDE;
47 virtual ResultCode CreateAlternateDesktop(bool alternate_winstation) OVERRIDE;
48 virtual void DestroyAlternateDesktop() OVERRIDE;
49 virtual ResultCode SetIntegrityLevel(IntegrityLevel integrity_level) OVERRIDE;
50 virtual ResultCode SetDelayedIntegrityLevel(
51 IntegrityLevel integrity_level) OVERRIDE;
52 virtual void SetStrictInterceptions() OVERRIDE;
53 virtual ResultCode AddRule(SubSystem subsystem, Semantics semantics,
54 const wchar_t* pattern) OVERRIDE;
55 virtual ResultCode AddDllToUnload(const wchar_t* dll_name);
56 virtual ResultCode AddKernelObjectToClose(const char16* handle_type,
57 const char16* handle_name) OVERRIDE;
58
59 // Dispatcher:
60 virtual Dispatcher* OnMessageReady(IPCParams* ipc,
61 CallbackGeneric* callback) OVERRIDE;
62 virtual bool SetupService(InterceptionManager* manager, int service) OVERRIDE;
63
64 // Creates a Job object with the level specified in a previous call to
65 // SetJobLevel(). Returns the standard windows of ::GetLastError().
66 DWORD MakeJobObject(HANDLE* job);
67
68 // Creates the two tokens with the levels specified in a previous call to
69 // SetTokenLevel(). Returns the standard windows of ::GetLastError().
70 DWORD MakeTokens(HANDLE* initial, HANDLE* lockdown);
71
72 // Adds a target process to the internal list of targets. Internally a
73 // call to TargetProcess::Init() is issued.
74 bool AddTarget(TargetProcess* target);
75
76 // Called when there are no more active processes in a Job.
77 // Removes a Job object associated with this policy and the target associated
78 // with the job.
79 bool OnJobEmpty(HANDLE job);
80
81 EvalResult EvalPolicy(int service, CountedParameterSetBase* params);
82
83 private:
84 ~PolicyBase();
85
86 // Test IPC providers.
87 bool Ping(IPCInfo* ipc, void* cookie);
88
89 // Returns a dispatcher from ipc_targets_.
90 Dispatcher* GetDispatcher(int ipc_tag);
91
92 // Sets up interceptions for a new target.
93 bool SetupAllInterceptions(TargetProcess* target);
94
95 // Sets up the handle closer for a new target.
96 bool SetupHandleCloser(TargetProcess* target);
97
98 // This lock synchronizes operations on the targets_ collection.
99 CRITICAL_SECTION lock_;
100 // Maintains the list of target process associated with this policy.
101 // The policy takes ownership of them.
102 typedef std::list<TargetProcess*> TargetSet;
103 TargetSet targets_;
104 // Standard object-lifetime reference counter.
105 volatile LONG ref_count;
106 // The user-defined global policy settings.
107 TokenLevel lockdown_level_;
108 TokenLevel initial_level_;
109 JobLevel job_level_;
110 uint32 ui_exceptions_;
111 bool use_alternate_desktop_;
112 bool use_alternate_winstation_;
113 // Helps the file system policy initialization.
114 bool file_system_init_;
115 bool relaxed_interceptions_;
116 IntegrityLevel integrity_level_;
117 IntegrityLevel delayed_integrity_level_;
118 // The array of objects that will answer IPC calls.
119 Dispatcher* ipc_targets_[IPC_LAST_TAG];
120 // Object in charge of generating the low level policy.
121 LowLevelPolicy* policy_maker_;
122 // Memory structure that stores the low level policy.
123 PolicyGlobal* policy_;
124 // The list of dlls to unload in the target process.
125 std::vector<std::wstring> blacklisted_dlls_;
126 // This is a map of handle-types to names that we need to close in the
127 // target process. A null set means we need to close all handles of the
128 // given type.
129 HandleCloser handle_closer_;
130
131 static HDESK alternate_desktop_handle_;
132 static HWINSTA alternate_winstation_handle_;
133
134 DISALLOW_COPY_AND_ASSIGN(PolicyBase);
135 };
136
137 } // namespace sandbox
138
139 #endif // SANDBOX_SRC_SANDBOX_POLICY_BASE_H_
OLDNEW
« no previous file with comments | « sandbox/src/sandbox_policy.h ('k') | sandbox/src/sandbox_policy_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698