| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2010 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_PROCESS_THREAD_POLICY_H_ | |
| 6 #define SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "sandbox/win/src/policy_low_level.h" | |
| 13 | |
| 14 #include "base/strings/string16.h" | |
| 15 #include "sandbox/win/src/crosscall_server.h" | |
| 16 #include "sandbox/win/src/sandbox_policy.h" | |
| 17 | |
| 18 namespace sandbox { | |
| 19 | |
| 20 enum EvalResult; | |
| 21 | |
| 22 // This class centralizes most of the knowledge related to process execution. | |
| 23 class ProcessPolicy { | |
| 24 public: | |
| 25 // Creates the required low-level policy rules to evaluate a high-level. | |
| 26 // policy rule for process creation | |
| 27 // 'name' is the executable to be spawn. | |
| 28 // 'semantics' is the desired semantics. | |
| 29 // 'policy' is the policy generator to which the rules are going to be added. | |
| 30 static bool GenerateRules(const wchar_t* name, | |
| 31 TargetPolicy::Semantics semantics, | |
| 32 LowLevelPolicy* policy); | |
| 33 | |
| 34 // Opens a thread from the child process and returns the handle. | |
| 35 // client_info contains the information about the child process, | |
| 36 // desired_access is the access requested by the child and thread_id | |
| 37 // is the thread_id to be opened. | |
| 38 // The function returns the return value of NtOpenThread. | |
| 39 static NTSTATUS OpenThreadAction(const ClientInfo& client_info, | |
| 40 uint32_t desired_access, | |
| 41 uint32_t thread_id, | |
| 42 HANDLE* handle); | |
| 43 | |
| 44 // Opens the process id passed in and returns the duplicated handle to | |
| 45 // the child. We only allow the child processes to open themselves. Any other | |
| 46 // pid open is denied. | |
| 47 static NTSTATUS OpenProcessAction(const ClientInfo& client_info, | |
| 48 uint32_t desired_access, | |
| 49 uint32_t process_id, | |
| 50 HANDLE* handle); | |
| 51 | |
| 52 // Opens the token associated with the process and returns the duplicated | |
| 53 // handle to the child. We only allow the child processes to open his own | |
| 54 // token (using ::GetCurrentProcess()). | |
| 55 static NTSTATUS OpenProcessTokenAction(const ClientInfo& client_info, | |
| 56 HANDLE process, | |
| 57 uint32_t desired_access, | |
| 58 HANDLE* handle); | |
| 59 | |
| 60 // Opens the token associated with the process and returns the duplicated | |
| 61 // handle to the child. We only allow the child processes to open his own | |
| 62 // token (using ::GetCurrentProcess()). | |
| 63 static NTSTATUS OpenProcessTokenExAction(const ClientInfo& client_info, | |
| 64 HANDLE process, | |
| 65 uint32_t desired_access, | |
| 66 uint32_t attributes, | |
| 67 HANDLE* handle); | |
| 68 | |
| 69 // Processes a 'CreateProcessW()' request from the target. | |
| 70 // 'client_info' : the target process that is making the request. | |
| 71 // 'eval_result' : The desired policy action to accomplish. | |
| 72 // 'app_name' : The full path of the process to be created. | |
| 73 // 'command_line' : The command line passed to the created process. | |
| 74 static DWORD CreateProcessWAction(EvalResult eval_result, | |
| 75 const ClientInfo& client_info, | |
| 76 const base::string16 &app_name, | |
| 77 const base::string16 &command_line, | |
| 78 PROCESS_INFORMATION* process_info); | |
| 79 | |
| 80 // Processes a 'CreateThread()' request from the target. | |
| 81 // 'client_info' : the target process that is making the request. | |
| 82 static DWORD CreateThreadAction(const ClientInfo& client_info, | |
| 83 SIZE_T stack_size, | |
| 84 LPTHREAD_START_ROUTINE start_address, | |
| 85 PVOID parameter, | |
| 86 DWORD creation_flags, | |
| 87 LPDWORD thread_id, | |
| 88 HANDLE* handle); | |
| 89 }; | |
| 90 | |
| 91 } // namespace sandbox | |
| 92 | |
| 93 | |
| 94 #endif // SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ | |
| OLD | NEW |