process_thread_policy.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #ifndef SANDBOX_WIN_SRC_PROCESS_THREAD_POLICY_H_
  5. #define SANDBOX_WIN_SRC_PROCESS_THREAD_POLICY_H_
  6. #include <stdint.h>
  7. #include "sandbox/win/src/crosscall_server.h"
  8. #include "sandbox/win/src/policy_low_level.h"
  9. #include "sandbox/win/src/sandbox_policy.h"
  10. namespace sandbox {
  11. // This class centralizes most of the knowledge related to process execution.
  12. class ProcessPolicy {
  13. public:
  14. // Opens a thread from the child process and returns the handle.
  15. // client_info contains the information about the child process,
  16. // desired_access is the access requested by the child and thread_id
  17. // is the thread_id to be opened.
  18. // The function returns the return value of NtOpenThread.
  19. static NTSTATUS OpenThreadAction(const ClientInfo& client_info,
  20. uint32_t desired_access,
  21. uint32_t thread_id,
  22. HANDLE* handle);
  23. // Opens the process id passed in and returns the duplicated handle to
  24. // the child. We only allow the child processes to open themselves. Any other
  25. // pid open is denied.
  26. static NTSTATUS OpenProcessAction(const ClientInfo& client_info,
  27. uint32_t desired_access,
  28. uint32_t process_id,
  29. HANDLE* handle);
  30. // Opens the token associated with the process and returns the duplicated
  31. // handle to the child. We only allow the child processes to open its own
  32. // token (using ::GetCurrentProcess()).
  33. static NTSTATUS OpenProcessTokenAction(const ClientInfo& client_info,
  34. HANDLE process,
  35. uint32_t desired_access,
  36. HANDLE* handle);
  37. // Opens the token associated with the process and returns the duplicated
  38. // handle to the child. We only allow the child processes to open its own
  39. // token (using ::GetCurrentProcess()).
  40. static NTSTATUS OpenProcessTokenExAction(const ClientInfo& client_info,
  41. HANDLE process,
  42. uint32_t desired_access,
  43. uint32_t attributes,
  44. HANDLE* handle);
  45. // Processes a 'CreateThread()' request from the target.
  46. // 'client_info' : the target process that is making the request.
  47. static DWORD CreateThreadAction(const ClientInfo& client_info,
  48. SIZE_T stack_size,
  49. LPTHREAD_START_ROUTINE start_address,
  50. PVOID parameter,
  51. DWORD creation_flags,
  52. LPDWORD thread_id,
  53. HANDLE* handle);
  54. };
  55. } // namespace sandbox
  56. #endif // SANDBOX_WIN_SRC_PROCESS_THREAD_POLICY_H_