diff options
| author | Fuwn <[email protected]> | 2022-02-03 13:04:54 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-02-03 13:04:54 -0800 |
| commit | 4da071e556e8ffbe19fe5d13e2733519dc03ad91 (patch) | |
| tree | aa4c21713b2ffd5760e110d25af1aae8c0d5f97f | |
| parent | fmt: preprocessor statements (diff) | |
| download | soyuz-4da071e556e8ffbe19fe5d13e2733519dc03ad91.tar.xz soyuz-4da071e556e8ffbe19fe5d13e2733519dc03ad91.zip | |
fix(#1): delete_handle generating junk data when lunar is closed after first pid check
Soyuz does an initial PID check after launching to make sure that Lunar Client is open, which takes care of most errors, at least I thought. However, within my limited testing I guess it never crossed my mind to check what would happen if I closed Lunar Client **after** Soyuz had been initialized...
Turns out it just generates seemingly infinite errors logs as it has no valid PID to operate on.
This commit patches the aforementioned bug by introducing another PID check before every iteration that the delete_handle function should run, as well as a timeout.
Thanks to @LorenzoHanssens for filling a bug report! (#1)
| -rw-r--r-- | soyuz/soyuz.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/soyuz/soyuz.cc b/soyuz/soyuz.cc index be181fc..871d093 100644 --- a/soyuz/soyuz.cc +++ b/soyuz/soyuz.cc @@ -26,8 +26,8 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) { MSG messages; WNDCLASSEX wincl; - WM_TASKBAR = RegisterWindowMessageA("TaskbarCreated"); + WM_TASKBAR = RegisterWindowMessageA("TaskbarCreated"); wincl.hInstance = instance; wincl.lpszClassName = class_name; wincl.lpfnWndProc = WindowProcedure; @@ -72,6 +72,13 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) { soyuz::log("hooked lunar client"); soyuz::log("you may now close this window"); while (!stop.stop_requested()) { + pid = soyuz::find_lunar(); + + if (pid == 0 || pid == 3435973836) { + soyuz::log("could not locate lunar client, waiting 10 seconds"); + std::this_thread::sleep_for(std::chrono::seconds(10)); + } + if (soyuz::delete_handle(pid) == 1) { soyuz::log("unable to close lunar client's discord ipc named pipe"); } |