mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
[CrashReporting] Name the files and processes behind a failed installer purge (#7590)
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
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
* [CrashReporting] Log which files and processes blocked the installer purge A purge that fails aborts the upgrade with a message that can only guess at the cause, and the log only listed which DLLs survived. Record what Windows reports for each survivor and which processes still have the install directory mapped, then repeat the holder list in the abort message. The diagnostics are additive and run only on the abort path: they open each survivor for DELETE access and close it again without deleting, so a failed upgrade can never end up half-removed. The purge itself is unchanged. * [CrashReporting] Name the holders of a failed purge with Restart Manager The process-and-module scan could only name a holder whose image lives in the install directory or that loaded one of its DLLs, so the case this diagnostic exists for - an antivirus scanner holding a plain handle - was reported as "no holder named, only a code". Reaching the Restart Manager from the NSIS script would have meant marshalling RM_PROCESS_INFO through System::Call as a table of hand-computed offsets, which cannot be checked without a Windows toolchain, and that is why it was dropped when this diagnostics was written. Move the call into tools/installer-holder-probe: a small executable the same Windows build compiles, linking nothing from this project so it still starts when the installed runtime is what the purge could not replace. It rides inside the installer and is extracted to $PLUGINSDIR only when the purge has already failed, so the successful path is unchanged and nothing new is installed. .ci/compile.sh runs it against a file held with FileShare.None on the Windows runners, so the lookup is exercised on real Windows instead of only compiled. * [CrashReporting] Fix the holder probe check and cap the holder line The probe block ran after the package steps, where the working directory is already the build dir, so its $BUILD_DIR-prefixed paths named build/build and the PowerShell file could not be written. Move it ahead of install/package, where the build dir is still the cwd, and name both files relative to it. Guard it on MAKE_NO_CLIENT, since the probe is only built with the client. Cap the rendered holder line at HOLDER_LINE_CHAR_MAX: the count limit alone does not keep long service names inside the NSIS string that also carries the abort text and the log path. Whole entries are kept and the rest counted, with the first holder always shown. Also run cmake-format on the probe's CMakeLists so the lint job accepts it. * [CrashReporting] Report a read-only purge survivor and bound the probe check --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
ad4320cd7b
commit
bbc6003f0a
12 changed files with 793 additions and 1 deletions
21
tools/installer-holder-probe/CMakeLists.txt
Normal file
21
tools/installer-holder-probe/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Windows-only. The installer runs this on the abort path of a failed purge to name the
|
||||
# applications and services holding the install directory open (Restart Manager); see
|
||||
# the LogProcessesUsingInstallDir function in cmake/NSIS.template.in. It ships inside
|
||||
# the installer and is extracted to $PLUGINSDIR there, never installed, so it links
|
||||
# nothing from this project: no Qt, and a static C runtime because the installed runtime
|
||||
# is exactly what the purge may have failed to replace.
|
||||
add_executable(installer-holder-probe holder_line.cpp main.cpp restart_manager_holders.cpp)
|
||||
|
||||
target_link_libraries(installer-holder-probe PRIVATE rstrtmgr)
|
||||
|
||||
# The NSIS template embeds the built file by the same relative path that resolves
|
||||
# NSIS.definitions.nsh, and that path points at the build root.
|
||||
set_target_properties(
|
||||
installer-holder-probe
|
||||
PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}"
|
||||
)
|
||||
64
tools/installer-holder-probe/holder_line.cpp
Normal file
64
tools/installer-holder-probe/holder_line.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include "holder_line.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::wstring displayNameOf(const Holder &holder)
|
||||
{
|
||||
// A service's application name is its long name, which is what the user can
|
||||
// search for; its image name is usually a shared host process (svchost.exe) and
|
||||
// would name the wrong thing.
|
||||
if (holder.isService && !holder.appName.empty()) {
|
||||
return holder.appName;
|
||||
}
|
||||
if (!holder.imageName.empty()) {
|
||||
return holder.imageName;
|
||||
}
|
||||
if (!holder.appName.empty()) {
|
||||
return holder.appName;
|
||||
}
|
||||
return L"an unnamed process";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::wstring formatHolder(const Holder &holder)
|
||||
{
|
||||
std::wstring line = displayNameOf(holder);
|
||||
line += L" (pid ";
|
||||
line += std::to_wstring(holder.processId);
|
||||
if (holder.isService) {
|
||||
line += L", service ";
|
||||
line += holder.serviceShortName.empty() ? L"without a short name" : holder.serviceShortName;
|
||||
} else {
|
||||
line += L", running";
|
||||
}
|
||||
line += L")";
|
||||
return line;
|
||||
}
|
||||
|
||||
std::wstring formatHolders(const std::vector<Holder> &holders)
|
||||
{
|
||||
const std::size_t wanted = std::min(holders.size(), HOLDER_LINE_MAX);
|
||||
std::wstring line;
|
||||
std::size_t listed = 0;
|
||||
for (; listed < wanted; ++listed) {
|
||||
const std::wstring entry = formatHolder(holders[listed]);
|
||||
const std::size_t separator = line.empty() ? 0 : 2;
|
||||
// The first holder is always named, however long its name: it is the answer the
|
||||
// dialog exists to show, and Windows bounds one entry below the whole budget.
|
||||
if (!line.empty() && line.size() + separator + entry.size() > HOLDER_LINE_CHAR_MAX) {
|
||||
break;
|
||||
}
|
||||
if (!line.empty()) {
|
||||
line += L"; ";
|
||||
}
|
||||
line += entry;
|
||||
}
|
||||
if (holders.size() > listed) {
|
||||
line += L"; and ";
|
||||
line += std::to_wstring(holders.size() - listed);
|
||||
line += L" more";
|
||||
}
|
||||
return line;
|
||||
}
|
||||
59
tools/installer-holder-probe/holder_line.h
Normal file
59
tools/installer-holder-probe/holder_line.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#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: the abort dialog puts it after a fixed paragraph and
|
||||
* before the path of the installer log, inside an NSIS string of 1024 characters. Windows
|
||||
* caps one application or service name well below this budget, so it bounds the list
|
||||
* without ever cutting a single holder short.
|
||||
*/
|
||||
inline constexpr std::size_t HOLDER_LINE_CHAR_MAX = 400;
|
||||
|
||||
/**
|
||||
* @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
|
||||
78
tools/installer-holder-probe/main.cpp
Normal file
78
tools/installer-holder-probe/main.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#include "holder_line.h"
|
||||
#include "restart_manager_holders.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
/// The installer sets this, the same variable the running-instance guard uses, instead
|
||||
/// of passing the directory on the command line: a path with spaces, quotes or a
|
||||
/// trailing backslash then never has to survive NSIS quoting or a command line.
|
||||
constexpr wchar_t INSTALL_DIR_VARIABLE[] = L"COCKATRICE_GUARD_DIR";
|
||||
|
||||
/// Exit codes the installer reads. "Something was found" is deliberately not 0, so an
|
||||
/// answer of "nothing holds the files" stays distinguishable from a probe that failed.
|
||||
enum ExitCode
|
||||
{
|
||||
EXIT_NO_HOLDERS = 0,
|
||||
EXIT_HOLDERS_FOUND = 1,
|
||||
EXIT_NOT_CONFIGURED = 2,
|
||||
EXIT_PROBE_FAILED = 3,
|
||||
};
|
||||
|
||||
/// Writes one line to the pipe nsExec reads. Narrowed to ASCII on purpose: the bytes
|
||||
/// come back to the installer as an ANSI string, so a non-ASCII process name would be
|
||||
/// mojibake in the log; a '?' at least stays honest. Control characters are dropped
|
||||
/// too, so a name can never forge a second log line.
|
||||
void writeLine(const std::wstring &text)
|
||||
{
|
||||
std::string narrow;
|
||||
narrow.reserve(text.size() + 2);
|
||||
for (const wchar_t character : text) {
|
||||
narrow.push_back(character >= 0x20 && character < 0x7F ? static_cast<char>(character) : '?');
|
||||
}
|
||||
narrow += "\r\n";
|
||||
DWORD written = 0;
|
||||
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), narrow.data(), static_cast<DWORD>(narrow.size()), &written, nullptr);
|
||||
}
|
||||
|
||||
std::wstring installDirFromEnvironment()
|
||||
{
|
||||
for (DWORD size = MAX_PATH; size <= 32768U; size *= 2) {
|
||||
std::vector<wchar_t> buffer(size);
|
||||
const DWORD length = GetEnvironmentVariableW(INSTALL_DIR_VARIABLE, buffer.data(), size);
|
||||
if (length == 0) {
|
||||
return {};
|
||||
}
|
||||
if (length < size) {
|
||||
return std::wstring(buffer.data(), length);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::wstring installDir = installDirFromEnvironment();
|
||||
if (installDir.empty()) {
|
||||
writeLine(L"the probe was not given the install directory");
|
||||
return EXIT_NOT_CONFIGURED;
|
||||
}
|
||||
|
||||
std::vector<Holder> holders;
|
||||
const unsigned long error = findProcessesUsingFiles(collectProbeFiles(installDir), holders);
|
||||
if (error != ERROR_SUCCESS) {
|
||||
writeLine(L"the Restart Manager lookup failed with win32 error " + std::to_wstring(error));
|
||||
return EXIT_PROBE_FAILED;
|
||||
}
|
||||
if (holders.empty()) {
|
||||
// No output: the installer words the "nothing is holding them" case, and it
|
||||
// owns the message either way.
|
||||
return EXIT_NO_HOLDERS;
|
||||
}
|
||||
writeLine(formatHolders(holders));
|
||||
return EXIT_HOLDERS_FOUND;
|
||||
}
|
||||
160
tools/installer-holder-probe/restart_manager_holders.cpp
Normal file
160
tools/installer-holder-probe/restart_manager_holders.cpp
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
#include "restart_manager_holders.h"
|
||||
|
||||
// clang-format off
|
||||
// restartmanager.h uses the types from windows.h without including it, so the order
|
||||
// here is a requirement; Regroup would sort them the other way round.
|
||||
#include <windows.h>
|
||||
#include <restartmanager.h>
|
||||
// clang-format on
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
namespace
|
||||
{
|
||||
/// Stop registering after this many files. The install directory carries around 150
|
||||
/// files in practice; the cap only exists so a directory someone has filled with files
|
||||
/// cannot turn the abort path into a long Restart Manager call.
|
||||
constexpr std::size_t MAX_PROBED_FILES = 2000;
|
||||
|
||||
/// How deep the Plugins walk goes. Its real shape is Plugins\<category>\<plugin>.dll.
|
||||
constexpr int MAX_PLUGIN_DEPTH = 4;
|
||||
|
||||
void collectFilesOf(const std::wstring &directory, int depth, int maxDepth, std::vector<std::wstring> &files)
|
||||
{
|
||||
if (files.size() >= MAX_PROBED_FILES) {
|
||||
return;
|
||||
}
|
||||
WIN32_FIND_DATAW entry{};
|
||||
const HANDLE find = FindFirstFileW((directory + L"\\*").c_str(), &entry);
|
||||
if (find == INVALID_HANDLE_VALUE) {
|
||||
return;
|
||||
}
|
||||
do {
|
||||
if (files.size() >= MAX_PROBED_FILES) {
|
||||
break;
|
||||
}
|
||||
const std::wstring name = entry.cFileName;
|
||||
if (name == L"." || name == L".." || (entry.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
|
||||
continue;
|
||||
}
|
||||
const std::wstring path = directory + L"\\" + name;
|
||||
if ((entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
if (depth < maxDepth) {
|
||||
collectFilesOf(path, depth + 1, maxDepth, files);
|
||||
}
|
||||
} else {
|
||||
files.push_back(path);
|
||||
}
|
||||
} while (FindNextFileW(find, &entry) != 0);
|
||||
FindClose(find);
|
||||
}
|
||||
|
||||
std::wstring imagePathOf(unsigned long processId)
|
||||
{
|
||||
// PROCESS_QUERY_LIMITED_INFORMATION is the right to ask, not to debug: it reads the
|
||||
// path of a process this one does not own, which is what keeps a SYSTEM-owned holder
|
||||
// from turning the whole list into an error. One that refuses even this is still
|
||||
// named, by whatever Restart Manager called it.
|
||||
const HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);
|
||||
if (process == nullptr) {
|
||||
return {};
|
||||
}
|
||||
wchar_t path[MAX_PATH * 2] = {};
|
||||
DWORD length = static_cast<DWORD>(std::size(path));
|
||||
std::wstring imagePath;
|
||||
if (QueryFullProcessImageNameW(process, 0, path, &length) != 0) {
|
||||
imagePath.assign(path, length);
|
||||
}
|
||||
CloseHandle(process);
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
std::wstring fileNameOf(const std::wstring &path)
|
||||
{
|
||||
const std::size_t separator = path.find_last_of(L"\\/");
|
||||
return separator == std::wstring::npos ? path : path.substr(separator + 1);
|
||||
}
|
||||
|
||||
/// Copies a fixed-size, NUL-terminated WCHAR array the API filled in.
|
||||
template <std::size_t N> std::wstring fixedString(const wchar_t (&text)[N])
|
||||
{
|
||||
return std::wstring(text, std::find(text, text + N, L'\0'));
|
||||
}
|
||||
|
||||
Holder holderOf(const RM_PROCESS_INFO &info)
|
||||
{
|
||||
Holder holder;
|
||||
holder.processId = info.Process.dwProcessId;
|
||||
holder.isService = info.ApplicationType == RmService;
|
||||
holder.appName = fixedString(info.strAppName);
|
||||
if (holder.isService) {
|
||||
holder.serviceShortName = fixedString(info.strServiceShortName);
|
||||
}
|
||||
holder.imageName = fileNameOf(imagePathOf(holder.processId));
|
||||
return holder;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<std::wstring> collectProbeFiles(const std::wstring &installDir)
|
||||
{
|
||||
std::vector<std::wstring> files;
|
||||
// depth 0, maxDepth 0: the install root's files and nothing below it. Its data
|
||||
// directory holds downloaded pictures, which the purge does not touch and which
|
||||
// would turn this into a walk over thousands of files.
|
||||
collectFilesOf(installDir, 0, 0, files);
|
||||
if (files.size() < MAX_PROBED_FILES) {
|
||||
collectFilesOf(installDir + L"\\Plugins", 0, MAX_PLUGIN_DEPTH, files);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
unsigned long findProcessesUsingFiles(const std::vector<std::wstring> &files, std::vector<Holder> &holders)
|
||||
{
|
||||
holders.clear();
|
||||
if (files.empty()) {
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
DWORD session = 0;
|
||||
wchar_t sessionKey[CCH_RM_SESSION_KEY + 1] = {};
|
||||
DWORD error = RmStartSession(&session, 0, sessionKey);
|
||||
if (error != ERROR_SUCCESS) {
|
||||
return error;
|
||||
}
|
||||
|
||||
// One call for the whole set, as the API asks: RmRegisterResources does registry
|
||||
// work per file and is documented as too expensive to call once per file.
|
||||
std::vector<LPCWSTR> names;
|
||||
names.reserve(files.size());
|
||||
for (const std::wstring &file : files) {
|
||||
names.push_back(file.c_str());
|
||||
}
|
||||
error = RmRegisterResources(session, static_cast<UINT>(names.size()), names.data(), 0, nullptr, 0, nullptr);
|
||||
|
||||
if (error == ERROR_SUCCESS) {
|
||||
UINT needed = 0;
|
||||
UINT count = 0;
|
||||
DWORD rebootReasons = 0;
|
||||
// The first call asks how large the answer is; Restart Manager reports
|
||||
// ERROR_MORE_DATA rather than truncating a list that does not fit.
|
||||
error = RmGetList(session, &needed, &count, nullptr, &rebootReasons);
|
||||
// Bounded: each retry more than covers the list growing between the two calls,
|
||||
// and an abort path cannot chase a process that keeps opening files. Giving up
|
||||
// reports the code, which is a truthful answer instead of a truncated list.
|
||||
for (int attempt = 0; attempt < 3 && error == ERROR_MORE_DATA; ++attempt) {
|
||||
count = needed;
|
||||
std::vector<RM_PROCESS_INFO> infos(count);
|
||||
error = RmGetList(session, &needed, &count, infos.data(), &rebootReasons);
|
||||
if (error == ERROR_SUCCESS) {
|
||||
holders.reserve(count);
|
||||
for (UINT index = 0; index < count; ++index) {
|
||||
holders.push_back(holderOf(infos[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RmEndSession(session);
|
||||
return error;
|
||||
}
|
||||
35
tools/installer-holder-probe/restart_manager_holders.h
Normal file
35
tools/installer-holder-probe/restart_manager_holders.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef RESTART_MANAGER_HOLDERS_H
|
||||
#define RESTART_MANAGER_HOLDERS_H
|
||||
|
||||
#include "holder_line.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief Lists the files a failed purge can be holding up, as full paths.
|
||||
*
|
||||
* Everything directly in @p installDir plus everything below its Plugins directory:
|
||||
* those are the two things the purge removes, so they are the two sets of files a
|
||||
* holder can be holding. Restart Manager refuses a directory with ERROR_ACCESS_DENIED,
|
||||
* which is why the probe registers files and this has to name them first.
|
||||
*
|
||||
* Missing or unreadable directories are skipped rather than reported, and the list is
|
||||
* capped: this runs on the abort path and must not walk a tree of downloaded pictures.
|
||||
*/
|
||||
std::vector<std::wstring> collectProbeFiles(const std::wstring &installDir);
|
||||
|
||||
/**
|
||||
* @brief Names the applications and services that have one of @p files open or mapped.
|
||||
*
|
||||
* Restart Manager reports both a process that loaded one of the files as a module and
|
||||
* one that merely holds a handle to it, and it reports services, which is the whole
|
||||
* reason it is used instead of walking every process's module list.
|
||||
*
|
||||
* @param holders replaced with one entry per holder, in the order Windows reported them.
|
||||
* @return 0 when the lookup ran, even if nothing is holding the files; otherwise the
|
||||
* Win32 code of the Restart Manager call that failed.
|
||||
*/
|
||||
unsigned long findProcessesUsingFiles(const std::vector<std::wstring> &files, std::vector<Holder> &holders);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue