Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #ifndef SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ |
michael@0 | 6 | #define SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ |
michael@0 | 7 | |
michael@0 | 8 | #include <string> |
michael@0 | 9 | |
michael@0 | 10 | #include "sandbox/win/src/policy_low_level.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "base/basictypes.h" |
michael@0 | 13 | #include "sandbox/win/src/crosscall_server.h" |
michael@0 | 14 | #include "sandbox/win/src/sandbox_policy.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace sandbox { |
michael@0 | 17 | |
michael@0 | 18 | enum EvalResult; |
michael@0 | 19 | |
michael@0 | 20 | // This class centralizes most of the knowledge related to process execution. |
michael@0 | 21 | class ProcessPolicy { |
michael@0 | 22 | public: |
michael@0 | 23 | // Creates the required low-level policy rules to evaluate a high-level. |
michael@0 | 24 | // policy rule for process creation |
michael@0 | 25 | // 'name' is the executable to be spawn. |
michael@0 | 26 | // 'semantics' is the desired semantics. |
michael@0 | 27 | // 'policy' is the policy generator to which the rules are going to be added. |
michael@0 | 28 | static bool GenerateRules(const wchar_t* name, |
michael@0 | 29 | TargetPolicy::Semantics semantics, |
michael@0 | 30 | LowLevelPolicy* policy); |
michael@0 | 31 | |
michael@0 | 32 | // Opens a thread from the child process and returns the handle. |
michael@0 | 33 | // client_info contains the information about the child process, |
michael@0 | 34 | // desired_access is the access requested by the child and thread_id |
michael@0 | 35 | // is the thread_id to be opened. |
michael@0 | 36 | // The function returns the return value of NtOpenThread. |
michael@0 | 37 | static NTSTATUS OpenThreadAction(const ClientInfo& client_info, |
michael@0 | 38 | uint32 desired_access, |
michael@0 | 39 | uint32 thread_id, |
michael@0 | 40 | HANDLE* handle); |
michael@0 | 41 | |
michael@0 | 42 | // Opens the process id passed in and returns the duplicated handle to |
michael@0 | 43 | // the child. We only allow the child processes to open themselves. Any other |
michael@0 | 44 | // pid open is denied. |
michael@0 | 45 | static NTSTATUS OpenProcessAction(const ClientInfo& client_info, |
michael@0 | 46 | uint32 desired_access, |
michael@0 | 47 | uint32 process_id, |
michael@0 | 48 | HANDLE* handle); |
michael@0 | 49 | |
michael@0 | 50 | // Opens the token associated with the process and returns the duplicated |
michael@0 | 51 | // handle to the child. We only allow the child processes to open his own |
michael@0 | 52 | // token (using ::GetCurrentProcess()). |
michael@0 | 53 | static NTSTATUS OpenProcessTokenAction(const ClientInfo& client_info, |
michael@0 | 54 | HANDLE process, |
michael@0 | 55 | uint32 desired_access, |
michael@0 | 56 | HANDLE* handle); |
michael@0 | 57 | |
michael@0 | 58 | // Opens the token associated with the process and returns the duplicated |
michael@0 | 59 | // handle to the child. We only allow the child processes to open his own |
michael@0 | 60 | // token (using ::GetCurrentProcess()). |
michael@0 | 61 | static NTSTATUS OpenProcessTokenExAction(const ClientInfo& client_info, |
michael@0 | 62 | HANDLE process, |
michael@0 | 63 | uint32 desired_access, |
michael@0 | 64 | uint32 attributes, |
michael@0 | 65 | HANDLE* handle); |
michael@0 | 66 | |
michael@0 | 67 | // Processes a 'CreateProcessW()' request from the target. |
michael@0 | 68 | // 'client_info' : the target process that is making the request. |
michael@0 | 69 | // 'eval_result' : The desired policy action to accomplish. |
michael@0 | 70 | // 'app_name' : The full path of the process to be created. |
michael@0 | 71 | // 'command_line' : The command line passed to the created process. |
michael@0 | 72 | static DWORD CreateProcessWAction(EvalResult eval_result, |
michael@0 | 73 | const ClientInfo& client_info, |
michael@0 | 74 | const std::wstring &app_name, |
michael@0 | 75 | const std::wstring &command_line, |
michael@0 | 76 | PROCESS_INFORMATION* process_info); |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | } // namespace sandbox |
michael@0 | 80 | |
michael@0 | 81 | |
michael@0 | 82 | #endif // SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ |