mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / Prune caches (push) Waiting to run
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
* [Installer] Request quit for hidden Cockatrice instances and record holders in abort telemetry * [Installer] Fix compiler warnings in holder probe and installer quit handler * [VisualDeckStorage] Order the includes the way clang-format wants them * [Installer] Ask a hidden instance to close, then offer to end it once The previous attempt had the client answer a registered window message, which cannot work for the update it was reported on: the instance being replaced is a client from before that message exists, so it never answers, and the user is left with "Cockatrice is still running" exactly as reported. Every step that can free the files has to be the installer's, so the client side is reverted. The probe now posts WM_CLOSE to the instance's own window whether that window is on screen or only in the notification area: the request does not need a visible window, an instance in the tray is the one this update has no other way to reach, and the confirmation Cockatrice answers with is a window Qt shows itself, so it is painted - unlike one restored from outside. A visible window is brought forward first, and Qt's bookkeeping windows stay excluded, because a close to the notification-area one terminates the instance without its confirmation. A question of the instance's own no longer suppresses the close. Withholding it protected nobody: the installer asked the user to close a program it had never asked, and a current client refuses the close while its confirmation is pending anyway, leaving the question where it is. The launcher mode keeps the visible-only rule, because a launcher without a window has already answered its own close and the wait ends it after a grace instead of asking a user who is not there. The guard asked the same question until the user gave up: after the automatic close failed it offered to end the programs, then re-ran the probe and showed the same dialog word for word when the answer was No, which is how an abort was reported three times over. It now asks once - Yes ends the Cockatrice, Oracle and Servatrice programs the payload installs and says what that costs, No cancels - and what survives an end is named in the abort instead of being put to the user as the same question again. The uninstaller's guard and the recovery path after a failed purge follow the same shape. Kept: the abort telemetry that records the holders, the close result and the end result as event data. --------- Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com> Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
62 lines
2.6 KiB
C++
62 lines
2.6 KiB
C++
#ifndef HOLDER_LINE_H
|
|
#define HOLDER_LINE_H
|
|
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
/**
|
|
* @brief One application or service that has an installer file open or mapped.
|
|
*
|
|
* Deliberately free of Windows types: the wording is what the abort dialog shows,
|
|
* and it is the only part of the probe that can be exercised off Windows.
|
|
*/
|
|
struct Holder
|
|
{
|
|
std::wstring imageName; ///< "cockatrice.exe", empty when the image could not be read
|
|
std::wstring appName; ///< Restart Manager's name for the application or service
|
|
std::wstring serviceShortName; ///< service short name, empty when this is not a service
|
|
unsigned long processId = 0;
|
|
bool isService = false;
|
|
};
|
|
|
|
/// How many holders the single-line summary names before it says how many were left out.
|
|
inline constexpr std::size_t HOLDER_LINE_MAX = 5;
|
|
|
|
/**
|
|
* @brief How many characters the summary may spend on the holders it names.
|
|
*
|
|
* The line is not the whole string: every prompt puts it after a fixed paragraph and before
|
|
* the answers, and one NSIS string holds 1024 characters. Those paragraphs grew when the
|
|
* guard started spelling out what ending the programs costs and what is left to do by hand,
|
|
* so this budget is what keeps the longest message - the one with the longest listing, plus
|
|
* the "; and N more" the summary appends after the budget - complete, including the sentence
|
|
* that offers the other answer at its end. Windows caps one application or service name well
|
|
* below this, so it bounds the list without ever cutting a single holder short.
|
|
*/
|
|
inline constexpr std::size_t HOLDER_LINE_CHAR_MAX = 320;
|
|
|
|
/**
|
|
* @brief Renders one holder the way the user has to recognise it, e.g.
|
|
* "cockatrice.exe (pid 24340, running)".
|
|
*
|
|
* The image name is preferred over the application name because it is what Task
|
|
* Manager shows, and the application name is what remains for a process whose
|
|
* image cannot be opened (another account, a protected process). A service is
|
|
* named by Restart Manager's long name and identified by its short name, because
|
|
* both are how the user finds it again in services.msc.
|
|
*/
|
|
std::wstring formatHolder(const Holder &holder);
|
|
|
|
/**
|
|
* @brief Renders every holder as a single "; "-joined line.
|
|
*
|
|
* One line because it is written to the installer log as one and repeated in a
|
|
* message box, where nsExec hands the text back as one string. Only the first
|
|
* HOLDER_LINE_MAX are named, and only while they fit in HOLDER_LINE_CHAR_MAX
|
|
* characters; the rest are counted, so a machine with a dozen open handles cannot
|
|
* push the real answer off the dialog.
|
|
*/
|
|
std::wstring formatHolders(const std::vector<Holder> &holders);
|
|
|
|
#endif
|