1 // Copyright (c) 2006-2008 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_SYNC_POLICY_H__
6 #define SANDBOX_SRC_SYNC_POLICY_H__
7 
8 #include <stdint.h>
9 
10 #include <string>
11 
12 #include "sandbox/win/src/crosscall_server.h"
13 #include "sandbox/win/src/nt_internals.h"
14 #include "sandbox/win/src/policy_low_level.h"
15 #include "sandbox/win/src/sandbox_policy.h"
16 
17 namespace sandbox {
18 
19 // This class centralizes most of the knowledge related to sync policy
20 class SyncPolicy {
21  public:
22   // Creates the required low-level policy rules to evaluate a high-level
23   // policy rule for sync calls, in particular open or create actions.
24   // name is the sync object name, semantics is the desired semantics for the
25   // open or create and policy is the policy generator to which the rules are
26   // going to be added.
27   static bool GenerateRules(const wchar_t* name,
28                             TargetPolicy::Semantics semantics,
29                             LowLevelPolicy* policy);
30 
31   // Performs the desired policy action on a request.
32   // client_info is the target process that is making the request and
33   // eval_result is the desired policy action to accomplish.
34   static NTSTATUS CreateEventAction(EvalResult eval_result,
35                                     const ClientInfo& client_info,
36                                     const std::wstring& event_name,
37                                     uint32_t event_type,
38                                     uint32_t initial_state,
39                                     HANDLE* handle);
40   static NTSTATUS OpenEventAction(EvalResult eval_result,
41                                   const ClientInfo& client_info,
42                                   const std::wstring& event_name,
43                                   uint32_t desired_access,
44                                   HANDLE* handle);
45 };
46 
47 }  // namespace sandbox
48 
49 #endif  // SANDBOX_SRC_SYNC_POLICY_H__
50