process_mitigations_win32k_dispatcher.cc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2014 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. #include "sandbox/win/src/process_mitigations_win32k_dispatcher.h"
  5. #include <algorithm>
  6. #include <string>
  7. #include "base/memory/platform_shared_memory_region.h"
  8. #include "base/memory/unsafe_shared_memory_region.h"
  9. #include "base/unguessable_token.h"
  10. #include "base/win/windows_version.h"
  11. #include "sandbox/win/src/interception.h"
  12. #include "sandbox/win/src/interceptors.h"
  13. #include "sandbox/win/src/ipc_tags.h"
  14. #include "sandbox/win/src/process_mitigations_win32k_interception.h"
  15. #include "sandbox/win/src/process_mitigations_win32k_policy.h"
  16. namespace sandbox {
  17. ProcessMitigationsWin32KDispatcher::ProcessMitigationsWin32KDispatcher(
  18. PolicyBase* policy_base)
  19. : policy_base_(policy_base) {
  20. }
  21. ProcessMitigationsWin32KDispatcher::~ProcessMitigationsWin32KDispatcher() {}
  22. bool ProcessMitigationsWin32KDispatcher::SetupService(
  23. InterceptionManager* manager,
  24. IpcTag service) {
  25. if (!(policy_base_->GetProcessMitigations() &
  26. sandbox::MITIGATION_WIN32K_DISABLE)) {
  27. return false;
  28. }
  29. switch (service) {
  30. case IpcTag::GDI_GDIDLLINITIALIZE: {
  31. if (!INTERCEPT_EAT(manager, L"gdi32.dll", GdiDllInitialize,
  32. GDIINITIALIZE_ID, 12)) {
  33. return false;
  34. }
  35. return true;
  36. }
  37. case IpcTag::GDI_GETSTOCKOBJECT: {
  38. if (!INTERCEPT_EAT(manager, L"gdi32.dll", GetStockObject,
  39. GETSTOCKOBJECT_ID, 8)) {
  40. return false;
  41. }
  42. return true;
  43. }
  44. case IpcTag::USER_REGISTERCLASSW: {
  45. if (!INTERCEPT_EAT(manager, L"user32.dll", RegisterClassW,
  46. REGISTERCLASSW_ID, 8)) {
  47. return false;
  48. }
  49. return true;
  50. }
  51. default:
  52. break;
  53. }
  54. return false;
  55. }
  56. } // namespace sandbox