handle_closer_agent.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2011 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_HANDLE_CLOSER_AGENT_H_
  5. #define SANDBOX_WIN_SRC_HANDLE_CLOSER_AGENT_H_
  6. #include <string>
  7. #include "base/win/scoped_handle.h"
  8. #include "sandbox/win/src/handle_closer.h"
  9. #include "sandbox/win/src/sandbox_types.h"
  10. #include "sandbox/win/src/target_services.h"
  11. namespace sandbox {
  12. // Target process code to close the handle list copied over from the broker.
  13. class HandleCloserAgent {
  14. public:
  15. HandleCloserAgent();
  16. HandleCloserAgent(const HandleCloserAgent&) = delete;
  17. HandleCloserAgent& operator=(const HandleCloserAgent&) = delete;
  18. ~HandleCloserAgent();
  19. // Reads the serialized list from the broker and creates the lookup map.
  20. // Updates is_csrss_connected based on type of handles closed.
  21. void InitializeHandlesToClose(bool* is_csrss_connected);
  22. // Closes any handles matching those in the lookup map.
  23. bool CloseHandles();
  24. // True if we have handles waiting to be closed.
  25. static bool NeedsHandlesClosed();
  26. private:
  27. // Attempt to stuff a closed handle with a dummy Event.
  28. bool AttemptToStuffHandleSlot(HANDLE closed_handle, const std::wstring& type);
  29. HandleMap handles_to_close_;
  30. base::win::ScopedHandle dummy_handle_;
  31. };
  32. } // namespace sandbox
  33. #endif // SANDBOX_WIN_SRC_HANDLE_CLOSER_AGENT_H_