bootflow_hook_lifecycle.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "bootflow_hook_lifecycle.h"
  2. #include <atomic>
  3. #include "internal.h"
  4. namespace sunrise::client::hooks::bootflow {
  5. namespace {
  6. std::atomic_bool g_installed{false};
  7. } // namespace
  8. /**
  9. * Attaches the boot-step fixes that carry sign-in through to orbit.
  10. * Each fix stands alone at one site, so a miss on one is reported and the others still attach.
  11. * @return True when every fix attached.
  12. */
  13. bool install() noexcept {
  14. const bool hold = install_character_select_hold();
  15. const bool sliceSet = install_orbit_slice_set();
  16. const bool skip = install_profile_setup_skip();
  17. const bool composition = install_composition_check();
  18. const bool handoff = install_orbit_handoff();
  19. const bool ownerSlot = install_owner_activity_slot();
  20. const bool regionPrivate = install_region_private();
  21. const bool worldStep = install_world_step();
  22. const bool spawn = install_spawn_hold();
  23. const bool fade = install_fade_release();
  24. const bool anyFix = hold || sliceSet || skip || composition || handoff || ownerSlot
  25. || regionPrivate || worldStep || spawn || fade;
  26. g_installed.store(anyFix, std::memory_order_release);
  27. return hold && sliceSet && skip && composition && handoff && ownerSlot && regionPrivate
  28. && worldStep && spawn && fade;
  29. }
  30. /** Detaches every boot-step fix, in the reverse order of install. */
  31. void uninstall() noexcept {
  32. uninstall_fade_release();
  33. uninstall_spawn_hold();
  34. uninstall_world_step();
  35. uninstall_region_private();
  36. uninstall_owner_activity_slot();
  37. uninstall_orbit_handoff();
  38. uninstall_composition_check();
  39. uninstall_profile_setup_skip();
  40. uninstall_orbit_slice_set();
  41. uninstall_character_select_hold();
  42. g_installed.store(false, std::memory_order_release);
  43. }
  44. /** @return True while at least one boot-step fix is attached. */
  45. bool is_installed() noexcept {
  46. return g_installed.load(std::memory_order_acquire);
  47. }
  48. } // namespace sunrise::client::hooks::bootflow