banner_hook_lifecycle.cpp 755 B

1234567891011121314151617181920212223242526272829303132
  1. #include "banner_hook_lifecycle.h"
  2. #include <atomic>
  3. #include "banner_bind.h"
  4. namespace sunrise::client::hooks::banner {
  5. namespace {
  6. std::atomic_bool g_installed{false};
  7. } // namespace
  8. /** Attaches the banner identity bind. */
  9. bool install() noexcept {
  10. const bool bind = install_banner_bind();
  11. g_installed.store(bind, std::memory_order_release);
  12. return bind;
  13. }
  14. /** Detaches the banner chain, in the reverse order of install. */
  15. void uninstall() noexcept {
  16. uninstall_banner_bind();
  17. g_installed.store(false, std::memory_order_release);
  18. }
  19. /** @return True while the banner bind is attached. */
  20. bool is_installed() noexcept {
  21. return g_installed.load(std::memory_order_acquire);
  22. }
  23. } // namespace sunrise::client::hooks::banner