diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/Main.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/Main.cpp index 313b5a26..d0d2c75e 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/Main.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/Main.cpp @@ -712,10 +712,6 @@ static void StatusCallback(void *) // update while we are running do { - DWORD result = WaitForSingleObject(s_shutdownDesiredEvent.Handle(), UPDATE_STATUSMSG_SECONDS * 1000); - if (result == WAIT_OBJECT_0) - break; - if(BuildTypeServerStatusPath()) { hSession = WinHttpOpen( @@ -746,6 +742,9 @@ static void StatusCallback(void *) WinHttpCloseHandle(hConnect); WinHttpCloseHandle(hSession); } + + if (s_shutdownDesiredEvent.Wait(UPDATE_STATUSMSG_SECONDS * 1000)) + break; } while (!s_shutdown); s_statusEvent.Signal(); diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp index 8b0721a7..06598dc6 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp @@ -300,7 +300,7 @@ UInt32 SelfPatcherStream::Write(UInt32 byteCount, const void* buffer) { SetBytesRemaining(0); SetTimeRemaining(0); } else { - SetBytesRemaining(totalBytes - byteCount); + SetBytesRemaining(totalBytes - progress); DWORD bytesPerSec = (progress) / max(TimeGetSecondsSince2001Utc() - startTime, 1); SetTimeRemaining((totalBytes - progress) / max(bytesPerSec, 1)); } @@ -434,6 +434,7 @@ void plSelfPatcher::ICheckAndRequest(PatcherWork*& wk) wk->fFlags |= kRequestNewPatcher; LogMsg(kLogDebug, L"plSelfPatcher::ICheckAndRequest: File '%s' needs to be downloaded.", wk->fEntry.clientName); + SelfPatcherStream::totalBytes += (wk->fEntry.zipSize != 0) ? wk->fEntry.zipSize : wk->fEntry.fileSize; wk->fType = kDownload; IEnqueueWork(wk, isPatcher); } @@ -457,7 +458,6 @@ void plSelfPatcher::IDownloadFile(PatcherWork*& wk) SetText("Downloading update..."); } - SelfPatcherStream::totalBytes += (wk->fEntry.zipSize != 0) ? wk->fEntry.zipSize : wk->fEntry.fileSize; SelfPatcherStream* s = NEWZERO(SelfPatcherStream); if (!s->Open(wk->fEntry.clientName, L"wb")) { LogMsg(kLogError, L"plSelfPatcher::IDownloadFile: Failed to create file: %s, errno: %u", wk->fEntry.clientName, errno); @@ -517,10 +517,6 @@ HANDLE plSelfPatcher::ICreateProcess(const wchar* path, const wchar* args, bool // launched by Windows (such as errors) to deadlock the UI quite horribly. Further, // ShellExecuteExW pops up that weird "do you want to run this file you downloaded from the internet?" // box, which we can't actually interact with due to the above. - - wchar exePath[MAX_PATH]; - PathGetCurrentDirectory(exePath, arrsize(exePath)); - PathAddFilename(exePath, exePath, path, arrsize(exePath)); if (!forceShell) { STARTUPINFOW si; PROCESS_INFORMATION pi; @@ -529,9 +525,8 @@ HANDLE plSelfPatcher::ICreateProcess(const wchar* path, const wchar* args, bool si.cb = sizeof(si); wchar cmdline[MAX_PATH]; - const wchar* exeFilename = PathFindFilename(path); - StrPrintf(cmdline, arrsize(cmdline), L"%s %s", exeFilename, args); - BOOL result = CreateProcessW(exePath, + StrPrintf(cmdline, arrsize(cmdline), L"%s %s", path, args); + BOOL result = CreateProcessW(path, cmdline, NULL, NULL, @@ -543,12 +538,11 @@ HANDLE plSelfPatcher::ICreateProcess(const wchar* path, const wchar* args, bool &pi); CloseHandle(pi.hThread); if (result != FALSE) { - free(exePath); return pi.hProcess; } else { wchar* error = FormatSystemError(); LogMsg(kLogError, L"plSelfPatcher::ICreateProcess: CreateProcessW failed for '%s': %u %s", - exePath, GetLastError(), error); + path, GetLastError(), error); LocalFree(error); // Purposefully falling through to ShellExecuteExW } @@ -560,16 +554,15 @@ HANDLE plSelfPatcher::ICreateProcess(const wchar* path, const wchar* args, bool info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI; info.hwnd = fLauncherInfo->dialog; // Not explicitly setting lpVerb to L"runas" because this seemingly breaks msiexec. - info.lpFile = exePath; + info.lpFile = path; info.lpParameters = args; if (ShellExecuteExW(&info) == FALSE) { wchar* error = FormatSystemError(); LogMsg(kLogError, L"plSelfPatcher::ICreateProcess: ShellExecuteExW failed for '%s': %u %s", - exePath, GetLastError(), error); + path, GetLastError(), error); LocalFree(error); } - free(exePath); return info.hProcess; }