From c8cff6166d05e77c843bb727702607f970d3d030 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 24 Dec 2020 10:02:56 -0500 Subject: added version to dmp filename replaced QApplication calls so createVersionInfo() can be called without one, happens with dump_running_process.bat --- src/env.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'src/env.cpp') diff --git a/src/env.cpp b/src/env.cpp index 98d2e6ea..edd8cd6b 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -6,6 +6,7 @@ #include "envwindows.h" #include "envdump.h" #include "settings.h" +#include "shared/util.h" #include #include @@ -1009,7 +1010,7 @@ bool registryValueExists(const QString& keyName, const QString& valueName) // returns the filename of the given process or the current one // -std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE) +std::filesystem::path processPath(HANDLE process=INVALID_HANDLE_VALUE) { // double the buffer size 10 times const int MaxTries = 10; @@ -1045,7 +1046,7 @@ std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE) const std::wstring s(buffer.get(), writtenSize); const std::filesystem::path path(s); - return path.filename().native(); + return path; } } @@ -1062,6 +1063,21 @@ std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE) return {}; } +std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE) +{ + const auto p = processPath(process); + if (p.empty()) { + return {}; + } + + return p.filename().native(); +} + +std::filesystem::path thisProcessPath() +{ + return processPath(); +} + DWORD findOtherPid() { const std::wstring defaultName = L"ModOrganizer.exe"; @@ -1126,6 +1142,19 @@ std::wstring tempDir() return std::wstring(buffer, buffer + written); } +std::wstring safeVersion() +{ + try + { + // this can throw + return MOShared::createVersionInfo().displayString(3).toStdWString() + L"-"; + } + catch(...) + { + return {}; + } +} + HandlePtr tempFile(const std::wstring dir) { // maximum tries of incrementing the counter @@ -1139,7 +1168,7 @@ HandlePtr tempFile(const std::wstring dir) // i can go until MaxTries std::wostringstream oss; oss - << L"ModOrganizer-" + << L"ModOrganizer-" << safeVersion() << std::setw(4) << (1900 + tm->tm_year) << std::setw(2) << std::setfill(L'0') << (tm->tm_mon + 1) << std::setw(2) << std::setfill(L'0') << tm->tm_mday << "T" -- cgit v1.3.1 From 1b700785bb8b5a3891391f60b13c9fee4647b5dd Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 24 Dec 2020 11:22:24 -0500 Subject: don't log modules in winroot dashes to dots --- src/env.cpp | 4 +++- src/envmodule.cpp | 23 +++++++++++++++++++++++ src/envmodule.h | 4 ++++ src/moapplication.cpp | 5 ++++- src/settings.cpp | 14 +++++++------- 5 files changed, 41 insertions(+), 9 deletions(-) (limited to 'src/env.cpp') diff --git a/src/env.cpp b/src/env.cpp index edd8cd6b..76473dfb 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -345,7 +345,9 @@ void Environment::dump(const Settings& s) const log::debug("modules loaded in process:"); for (const auto& m : loadedModules()) { - log::debug(" . {}", m.toString()); + if (m.interesting()) { + log::debug(" . {}", m.toString()); + } } log::debug("displays:"); diff --git a/src/envmodule.cpp b/src/envmodule.cpp index 5f2a5f5a..81cbad8a 100644 --- a/src/envmodule.cpp +++ b/src/envmodule.cpp @@ -308,6 +308,29 @@ QDateTime Module::getTimestamp(const VS_FIXEDFILEINFO& fi) const QTime(utc.wHour, utc.wMinute, utc.wSecond, utc.wMilliseconds)); } +bool Module::interesting() const +{ + static const auto windir = []() -> QString { + try + { + return QDir::toNativeSeparators( + MOBase::getKnownFolder(FOLDERID_Windows).path()) + "\\"; + } + catch(...) + { + return "c:\\windows\\"; + } + }(); + + + if (m_path.startsWith(windir, Qt::CaseInsensitive)) { + return false; + } + + return true; +} + + QString Module::getMD5() const { static const std::set ignore = { diff --git a/src/envmodule.h b/src/envmodule.h index c2829b32..4b85d737 100644 --- a/src/envmodule.h +++ b/src/envmodule.h @@ -66,6 +66,10 @@ public: // QString timestampString() const; + // returns false for modules in the Windows root directory + // + bool interesting() const; + // returns a string with all the above information on one line // QString toString() const; diff --git a/src/moapplication.cpp b/src/moapplication.cpp index e7ac3926..88b5710f 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -254,7 +254,10 @@ int MOApplication::doOneRun(MOMultiProcess& multiProcess) sanity::checkEnvironment(env); const auto moduleNotification = env.onModuleLoaded(qApp, [](auto&& m) { - log::debug("loaded module {}", m.toString()); + if (m.interesting()) { + log::debug("loaded module {}", m.toString()); + } + sanity::checkIncompatibleModule(m); }); diff --git a/src/settings.cpp b/src/settings.cpp index 436cd42b..ebb4fabe 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1971,14 +1971,14 @@ void NexusSettings::dump() const log::debug("nxmhandler settings:"); QSettings handler("HKEY_CURRENT_USER\\Software\\Classes\\nxm\\", QSettings::NativeFormat); - log::debug(" - primary: {}", handler.value("shell/open/command/Default").toString()); + log::debug(" . primary: {}", handler.value("shell/open/command/Default").toString()); const auto noregister = getOptional(s, "General", "noregister"); if (noregister) { - log::debug(" - noregister: {}", *noregister); + log::debug(" . noregister: {}", *noregister); } else { - log::debug(" - noregister: (not found)"); + log::debug(" . noregister: (not found)"); } ScopedReadArray sra(s, "handlers"); @@ -1988,10 +1988,10 @@ void NexusSettings::dump() const const auto executable = sra.get("executable"); const auto arguments = sra.get("arguments"); - log::debug(" - handler:"); - log::debug(" - games: {}", games.toString()); - log::debug(" - executable: {}", executable.toString()); - log::debug(" - arguments: {}", arguments.toString()); + log::debug(" . handler:"); + log::debug(" . games: {}", games.toString()); + log::debug(" . executable: {}", executable.toString()); + log::debug(" . arguments: {}", arguments.toString()); }); } -- cgit v1.3.1