Commit graph

42 commits

Author SHA1 Message Date
BruebachL
28d684f8aa
[Windows] Close running instances and purge stale runtime DLLs during update (#7308)
* [Windows] Close running instances and purge stale runtime DLLs during update

* [Windows] Scope running-instance handling to install dir and fix NSIS build

- Drop !include nsExec.nsh: nsExec is a plugin DLL, not a header, so
  makensis aborts before NSIS can build the installer.
- Match processes by image name and executable path under $INSTDIR via
  PowerShell, then close (WM_CLOSE) and force-stop only those PIDs, so an
  unrelated oracle.exe (Oracle DB) is never killed on a silent /R update.
- Gate the stale-runtime-DLL purge on $INSTDIR\cockatrice.exe existing, so
  a first-time install can't recursively delete an unrelated Plugins
  directory.

* [Windows] Make process detection rely on an explicit PowerShell exit code

* [Windows] Fix exit-code detection in the uninstaller process check

* [Windows] Pass the install dir to PowerShell without quoting pitfalls

* [Windows] Fail closed when a process path is unreadable

* [Windows] Only pre-check running instances for /R updates

* [Windows] Wait on a wall-clock 60 s deadline instead of a loop counter

* [Windows] Verify the force close and abort if the process survived

* [Windows] Defer silent updates instead of force-killing the client

* [Windows] Purge OpenSSL 3 DLLs on portable upgrades and broaden the stale-DLL guard

* [Windows] Replace the GetTickCount macro with a direct System::Call

* [Windows] Only close running instances whose path is readable

CloseMatchingApps reused the fail-closed detection filter, which counts a
process whose Path cannot be read (Access denied) as a match. The installer
runs elevated, so CloseMainWindow() would then be delivered to an unrelated
oracle.exe / servatrice.exe belonging to some other program, silently closing
a third party application during a Cockatrice update.

The set of processes we act on now has to be the strict one: a readable path
under $INSTDIR. Unreadable paths are simply not ours.

* [Windows] Match running instances by a readable path under the install dir

The Path read in the Where-Object filter raises "Access is denied" for
processes the installer cannot open, and both branches of the try/catch
turned that into a match. Together with mapping every non-zero nsExec result
to "running" this made the guard a hard stop rather than a fail-closed one: a
machine with an Oracle database service (or a servatrice service) running as
SYSTEM always has a process named oracle / servatrice whose path cannot be
read, so every silent update aborted after 60 s and every interactive install
re-asked for Retry indefinitely.

A process whose path cannot be read is not one of ours - the updater is
launched by the application it updates and therefore runs in the same user
session, and an interactive install is elevated and can read the paths of the
user's own processes. Both the detection and the close path now require a
readable path under $INSTDIR, which is what the comment above the helpers
already claimed.

* [Windows] Distinguish "could not determine" from "definitely running"

Mapping every non-zero nsExec result to "running" folds nsExec's "error"
return (powershell.exe could not be started at all - removed, blocked by
policy, refused by antivirus) into "Cockatrice is running". That state can
never clear: closing applications does not help, so silent installs aborted
after the full 60 s wait and interactive installs could not get past the
Retry/Cancel prompt.

IsAppRunning now reports three states (0 not running, 1 running, 2 could not
determine) and a new IsProcessLookupAvailable preflight checks that
powershell.exe can run at all. A broken PowerShell is reported to the user
once - with a message box, since a silent install would otherwise show
nothing - and the install continues instead of being blocked forever. Only a
definite "running" is now waited for.

* [Windows] Force-stop the console applications after the grace period

Servatrice and Oracle are console applications, so CloseMainWindow()
returns false and does nothing for them. Every silent update therefore
waited the full 60 s and then aborted, and every interactive install looped
on the Retry prompt, for any user running Servatrice out of the install
directory.

They now get a second shutdown path: once the grace period is over they are
force-stopped by PID with the same strict install-dir filter, since they hold
no unsaved user data. Cockatrice keeps the graceful-only treatment - a
force-kill there could destroy an unsaved deck - and still aborts instead.

* [Windows] Tell the user when a silent install or uninstall is aborted

On the /R path the installer runs with SetSilent and SetAutoClose, so the
DetailPrint before Abort went nowhere: the user clicks Help -> Check for
Client Updates, the download finishes, Cockatrice closes its window, and
nothing else happens - no update and no error, because the client launches the
installer detached and never looks at its exit code.

Every silent abort path now shows a message box telling the user which
application is still open and that they should close it and run the
installer again. The same applies to the silent uninstall, where the only
output is a log file nobody reads.

* [Windows] Treat leftover runtime files as an install marker for the purge

The guard on the stale-DLL purge only looked for the three executables and
uninstall.exe, so it skipped precisely the case the purge exists for: a
previous failed update whose uninstaller removed what it could and silently
skipped the Qt DLLs that a running instance had locked. None of the four
markers is left in that directory, and the stale DLLs then survive into the
new install.

A leftover Qt6Core.dll (what we ship today) or the qt.conf written by a
portable install now count as an install marker as well.

* [Windows] Run the section instance check before any file is deleted

Call EnsureAppsNotRunning sat after the portable-upgrade block, which had
already deleted the old cockatrice.exe, Qt*.dll and plugins directory. An
interactive install ("Portable mode" pointing at an existing portable folder)
has $ReinstallMode = 0, so the .onInit guard is skipped and locked files were
silently skipped - exactly the mixed-Qt-DLL state this change is about.

The check now runs right after SetOutPath, before the first Delete/RMDir in
the section.

* [Windows] Guard the old install before the old uninstaller deletes files

The interactive upgrade path removes the previous installation long before the
install section: componentsPagePre runs the old UninstallString on the
components page, i.e. before the directory page and before any call of ours
can check anything. Every uninstaller shipped before this change has no
un.EnsureAppsNotRunning, so for exactly the versions affected by #1576 the old
files were deleted while cockatrice.exe was still running and the new
installer had no say in it.

componentsPagePre now runs the same check before both ExecWait calls. At that
point $INSTDIR is still only the default, not the directory the old install
lives in, so the new EnsureOldInstallNotRunning guards the location recorded
in the registry instead. The helpers now work on a $GuardDir the caller
picks; the normal entry points keep seeding it with $INSTDIR.

* [Windows] Do not abort the section check past the point of no return

"nothing has been replaced yet, so aborting just defers the update" only holds
for the guard in .onInit. On the /R path AutoUninstallIfNeeded has already run
the old uninstaller, which RMDir /r's the whole install directory, and the
purge below it deletes the runtime files - so an Abort from the section would
leave the user with the old version uninstalled and the new one not installed
at all, which is strictly worse than the bug this change fixes.

The ordering now guarantees the check already passed: .onInit guards the /R
path before the uninstall, so the section only repeats it where that is not
already true, i.e. for interactive installs, where nothing of this installer
has been deleted yet and an Abort is the correct outcome.

As a safety net for whatever the purge could not remove (a still locked file,
or a check that could not run at all), HasStaleRuntimeFiles reports surviving
runtime files with a message box - also on a silent update, where there is no
other way to let the user know the install came out incomplete.

* [Windows] Only block the in-app updater with a message box

The message box on the silent abort would also fire for a plain /S install,
which is exactly the unattended case: a package manager (or a CI job) running
the installer with a leftover Cockatrice process would now hang forever on a
dialog nobody can see instead of aborting.

The box is therefore limited to /R, the path the in-app updater takes, where
the user just clicked Help -> Check for Client Updates, the client launches
the installer detached and never inspects its exit code, and the window is
about to disappear - without a message, the update would silently not happen.
Every silent abort also sets an error level now, so an unattended caller can
see that the run failed instead of having to read the log.

The silent uninstaller reports through log and exit code for the same reason:
it is run unattended by the /R updater itself (QuietUninstallString) and by
package managers. The installer that invoked it tells the user about the
incomplete result itself.

* [Windows] Treat an unset guard directory as undeterminable

$GuardDir is set by the three entry points into the check, but it is now what
decides whether a process counts as one of ours, and an empty string would
match every process that merely shares an image name - the same false positive
the strict path filter exists to avoid. Report it as "could not determine"
instead of running the check, so a future caller that forgets to set it warns
the user rather than closing or killing a third party process.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-09-27 20:05:41 +02:00
BruebachL
329a6ba94c
[Installer] Restore cockatrice:// and .cod registration in the Windows NSIS installer (#7355)
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 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (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 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
Co-authored-by: user.email <Bruebach.Lukas@bdosecurity.de>
2026-09-24 20:50:34 +02:00
BruebachL
a5e94d8a4f
[Build] Keep Windows installs free of build-tree artifacts (#7316)
* [Build] Keep Windows installs free of build-tree artifacts

Several Windows packaging gaps could leak Visual Studio CMake build
output into the installed application or the NSIS installer:

- The per-app DLL sweep used
  ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}, which is
  empty on multi-config generators, collapsing the recursive
  DIRECTORY install into the whole build tree (containing *.dir,
  *_autogen, .qt, .qsb, x64, ...). Point it at the real per-config
  output with $<TARGET_FILE_DIR:...> and exclude build artifacts.
- install(FILES ${OPENSSL_INCLUDE_DIRS} ...) tried to install OpenSSL
  include directories as files. CMake refuses this
  ("install FILES given directory"); it only slipped through CI
  because the vcpkg OpenSSL config leaves the variable empty. Remove it;
  fixup_bundle already ships the OpenSSL runtime DLLs.
- The NSIS uninstaller only deleted *.exe/*.dll and a few known files,
  so build-tree leftovers survived an uninstall/reinstall cycle. Wipe
  the whole directory tree instead.
- Add a Windows CI gate that lists the packaged installer with 7-Zip
  and fails the build if any build-tree artifact path is found.

* Update .ci/compile.sh

Co-authored-by: tooomm <tooomm@users.noreply.github.com>

* [Build] Rework Windows installer artifact exclusions per review

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: tooomm <tooomm@users.noreply.github.com>
2026-09-20 20:21:52 +02:00
BruebachL
c4316c40e9
[CI] Remove Qt5 (#7071)
* [CI] Remove Qt5

Took 10 minutes

Took 9 minutes

* Revert CI failure and fix up comments

Took 4 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-08-08 22:04:50 +02:00
BruebachL
59d90db3c7
Define Cockatrice as an editor/handler for .cod files and cockatrice:// protocol on all platforms (#6775)
* [Application] Add single instance guard and mime types.

Took 2 hours 39 minutes

Took 18 minutes

Took 5 minutes

Took 12 seconds


Took 11 seconds

* Rework

Took 30 minutes


Took 50 seconds

* Only enforce single instance if launched with arguments.

Took 5 minutes

* Prototype intents

Took 53 minutes

Took 6 seconds

* Connect/disconnect and join game/room intents.

Took 3 hours 14 minutes

Took 2 seconds

Took 15 seconds

* Fix include.

Took 1 minute


Took 23 seconds

Took 2 seconds

* Mac handling.

Took 10 minutes

Took 12 seconds

Took 3 minutes

* Lint.

Took 3 minutes

* Rebase.

Took 3 minutes

Took 17 seconds

* Implement UrlSchemeEventFilter

Took 10 minutes

Took 7 seconds

* Qt Moc

Took 3 minutes

* Modern PList.

Took 21 minutes

Took 1 minute

* Debug output.

Took 6 minutes

Took 19 minutes

* Watch file:// prefix.

Took 15 minutes

Took 7 seconds

* Better handler.

Took 6 minutes

* Don't store reference in member

Took 5 minutes

* Move impl to cpp, fix lifetime issues.

Took 11 minutes

Took 2 minutes

* Better single-instance handoff, url intent harded

copy game link context-menu
Polish for installers

Took 35 minutes

Took 8 seconds

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-08-08 19:02:19 +02:00
BruebachL
dfbe944c31
[App][Windows][NSIS] Use QProcess::setNativeArguments on Windows, properly order portable detection (#6989)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-06-15 15:23:18 +02:00
BruebachL
682ac4ed0c
Add -R option in Windows NSIS script for silent upgrade (#6818)
* Add -R option in Windows NSIS script

Took 23 minutes

* Small fix.

Took 3 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-04-19 01:07:38 +02:00
tooomm
14f1925edc
Add icon to exe (#6655) 2026-03-06 01:50:15 +01:00
BruebachL
7f1d891e26
[Deprecation] Remove DBConverter from sources. (#6431)
Took 10 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2025-12-20 15:25:13 +01:00
Zach H
d3a1538af3
Fix Windows Crash Reporter (#5493)
* Fix Windows Crash Reporter

* Fix NSIS template
2025-01-18 02:23:05 +00:00
Zach H
2ff99f12d8
Require Admin Permissions to install Cockatrice Windows (#5383)
Fix #5382
2024-12-29 16:22:39 +00:00
Zach H
2bd06ff0fd
Add CrashDump support for Windows OS (#5282) 2024-12-21 18:52:07 +00:00
tooomm
872c92a244
CI: Use windows-2022 image with Visual Studio 17 2022 (#4999)
Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
2024-05-13 17:41:50 -04:00
tooomm
03e109ef12 wait > sleep (#3806) 2019-09-05 15:44:14 +02:00
ctrlaltca
ada13f6578 Card Database converter (#3694)
* Database converter

* Fix win compilation and NSIS installer

* Maybe fix windows again

* Re-fix windows
2019-05-31 11:48:30 -04:00
ctrlaltca
638ee1af4a
This should fix appveyor compilation (#3434) 2018-11-12 18:50:38 +01:00
tooomm
c12c3c071f
NSIS: Show hint when user installs 32bit Cockatrice on 64bit Windows (#3331)
* hint for 32bit

* final wording
2018-07-17 07:40:45 +02:00
tooomm
d37d73017f
nsis: add sleep timer to ensure unlocking of vc_redist (#3325)
* add 3s sleep + log hint
2018-07-14 15:49:41 +02:00
ctrlaltca
b61c07a205
Check for both 32 and 64bit cockatrice when uninstalling (#3323) 2018-07-12 23:58:56 +02:00
ctrlaltca
dc727cb620
NSIS: misc fixes [wip] (#3300)
NSIS: misc fixes
2018-06-25 18:34:58 +02:00
tooomm
42d15c39a0 change vcredist install option from "/quiet" to "/passive" (#3175) 2018-04-07 12:32:20 -04:00
ctrlaltca
3a11aebb21
windows/appveyor compilation updates (#3020) 2018-01-17 18:20:05 +01:00
tooomm
04d84f9d9a repo cleanup (#2826) 2017-08-11 21:42:45 -04:00
ctrlaltca
1366e5970e Portable mode for windows (#2794)
* Portable mode for windows

* fix start menu in portable mode

* Make gcc an happy puppy

* Clean old installation if we are installing over an old portable mode installation

* Default to Desktop\CockatricePortable

* Settings dialog fixes

* wording
2017-07-08 11:22:29 +02:00
ctrlaltca
3356b2ede7 Change version in about window and installer name (#2570)
* Change version in about window and installer name

* Change version in about window and installer name

* Cmake get version updates

* dev snapshot format changed

* alignment changes
2017-04-20 13:41:18 +02:00
Fabio Bas
1e3fb6c6e1 Rework "paths" settings loading and card database loading
* main.cpp: removed path checking and db loading
 * card database: merge card loading methods into a single one
 * settings cache: take care of returning safe paths for decks,
replays, etc..
 * main window: if db loading fails (eg. first run), propose to run
oracle

NSIS: propose to run cockatrice instead of oracle

Rework card database loading

 * Move carddatabase-related method out of deckeditor tab
 * Load cards in another thread and render them progressively
 * Optimize database reload after enabled sets change

Fix deck editor column width

 * removed the noCard hack.
 * getCard() no more creates cards instead of just returning existing
ones
 * Fix the “edit tokens” dialog.
 * PictureLoader: avoid trying to download twice the same card
 * PictureLoader: correct return of card background
 * AbstractCardItem: avoid recalculating card color at every paint

Use a different file to save custom tokens

Misc required improvements

 * Use nullptr;
 * Refactor CardInfoWidget to use CardInfoPicture and CardInfoText
instead of duplicating code;
 * Added CardInfo::getColorChar()
 * Fixed some potential crashes
 * removed dead code related to CardInfoWidget
 * Don't require a restart after adding a new custom sets file
 * Bump CMake requirements to 3.1
2016-03-15 22:27:55 +01:00
Fabio Bas
74fef04a57 NSIS: Add components sections on uninstall. 2015-06-25 17:43:33 +02:00
Fabio Bas
76422854a4 NSIS: default to INSTDIR\sounds directory 2015-05-14 15:36:29 +02:00
Fabio Bas
da5677080b NSIS installer improvements; refs #876
* uninstaller: delete zlib1.dll (first issue in #876)
 * require the user to uninstall the old version before installing the
new one
 * use project-version as branding name (fourth issue in #876)
2015-05-07 22:29:39 +02:00
woogerboy21
1b09b76eee Remove --debug-ouput on start menu shortcut
Remove argument that if added by default with out having the proper configuration defined during compiling would cause cockatrice to not open properly.
2015-04-20 23:28:10 -04:00
woogerboy21
40610997c2 Corrected NSIS template quoting
There are extra quotes introduced into line #19 that causes the NSIS installer creation to fail.
2015-02-04 15:30:38 -05:00
tooomm
de336384cd add oracle name at the end of installer 2015-01-29 22:34:53 +01:00
Gavin Bisesi
8dbb2d8e6f Merge pull request #364 from ctrlaltca/win32_openssl_cmake
Deploy openssl libraries under win32
2014-10-14 14:03:32 -04:00
Fabio Bas
ea622a7302 NSIS: uninstall openssl libraries 2014-10-10 17:22:39 +02:00
woogerboy21
692910f9f3 Servatrice Icon For Windows
Servatrice icon now gets created in windows start menu.
2014-10-09 15:25:06 -04:00
Fabio Bas
85a4a94ba3 win32: Avoid wiping server.log on upgrade 2014-10-02 23:26:25 +02:00
Fabio Bas
8b32e51cab win32 NSIS installer: uninstall servatrice*
just avoid deleting servatrice.ini, if the user manually made one from
the servatrice.ini.example
2014-10-02 22:46:46 +02:00
Fabio Bas
98e5211ad5 Fix oracle under windows 2014-09-15 16:15:27 +02:00
Fabio Bas
23b0a6c0df Windows + CPack: fix packaging
Package the correct cpack’s temporary directory
2014-07-12 01:38:00 +02:00
Fabio Bas
3509df76b7 Remove old version parsing from nsis script 2014-06-28 19:48:51 +02:00
Fabio Bas
fc5a193e0d NSIS: remove additional files on uninstall 2014-06-28 19:39:47 +02:00
Fabio Bas
fc24ffdec2 Cmake reorganization
* Move all cmake-related files in a new “cmake” folder
* move nsis files in there, too, since they are templates parsed by cake
* retrieve git version once when cmake is run, and use it for both
creating version_string.h/cpp and for package naming
2014-06-28 19:39:26 +02:00
Renamed from nsis/NSIS.template.in (Browse further)