From c43535f5bcf1043c3b9c00c77967267cf1acf60f Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 9 Jun 2024 11:00:13 +0200 Subject: Update for new USVFS function scheme. (#2044) * Update for new USVFS function scheme. * Fix call to usvfsVersionString(). * Move USVFS to mo2 dependencies instead of third party in CI. --- src/shared/util.cpp | 23 +---------------------- src/spawn.cpp | 6 +++--- src/usvfsconnector.cpp | 34 +++++++++++++++++----------------- 3 files changed, 21 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/shared/util.cpp b/src/shared/util.cpp index c3b4d7aa..55a76c23 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -246,31 +246,10 @@ VersionInfo createVersionInfo() QString getUsvfsDLLVersion() { - // once 2.2.2 is released, this can be changed to call USVFSVersionString() - // directly; until then, using GetProcAddress() allows for mixing up devbuilds - // and usvfs dlls - - using USVFSVersionStringType = const char* WINAPI(); - - QString s; - - const auto m = ::LoadLibraryW(L"usvfs_x64.dll"); - - if (m) { - auto* f = reinterpret_cast( - ::GetProcAddress(m, "USVFSVersionString")); - - if (f) { - s = f(); - } - - ::FreeLibrary(m); - } - + QString s = usvfsVersionString(); if (s.isEmpty()) { s = "?"; } - return s; } diff --git a/src/spawn.cpp b/src/spawn.cpp index ae5c86ee..83ac720e 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -457,9 +457,9 @@ DWORD spawn(const SpawnParameters& sp, HANDLE& processHandle) const DWORD flags = CREATE_BREAKAWAY_FROM_JOB; if (sp.hooked) { - success = ::CreateProcessHooked(nullptr, const_cast(wcommandLine.c_str()), - nullptr, nullptr, inheritHandles, flags, nullptr, - wcwd.c_str(), &si, &pi); + success = ::usvfsCreateProcessHooked( + nullptr, const_cast(wcommandLine.c_str()), nullptr, nullptr, + inheritHandles, flags, nullptr, wcwd.c_str(), &si, &pi); } else { success = ::CreateProcess(nullptr, const_cast(wcommandLine.c_str()), nullptr, nullptr, inheritHandles, flags, nullptr, diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp index 940d0942..4a54f9fd 100644 --- a/src/usvfsconnector.cpp +++ b/src/usvfsconnector.cpp @@ -70,7 +70,7 @@ void LogWorker::process() int noLogCycles = 0; while (!m_QuitRequested) { - if (GetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) { + if (usvfsGetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) { m_LogFile.write(m_Buffer.c_str()); m_LogFile.write("\n"); m_LogFile.flush(); @@ -142,7 +142,7 @@ UsvfsConnector::UsvfsConnector() usvfsSetCrashDumpPath(params, dumpPath.c_str()); usvfsSetProcessDelay(params, delay.count()); - InitLogging(false); + usvfsInitLogging(false); log::debug("initializing usvfs:\n" " . instance: {}\n" @@ -154,13 +154,13 @@ UsvfsConnector::UsvfsConnector() usvfsCreateVFS(params); usvfsFreeParameters(params); - ClearExecutableBlacklist(); + usvfsClearExecutableBlacklist(); for (auto exec : s.executablesBlacklist().split(";")) { std::wstring buf = exec.toStdWString(); - BlacklistExecutable(buf.data()); + usvfsBlacklistExecutable(buf.data()); } - ClearLibraryForceLoads(); + usvfsClearLibraryForceLoads(); m_LogWorker.moveToThread(&m_WorkerThread); @@ -172,7 +172,7 @@ UsvfsConnector::UsvfsConnector() UsvfsConnector::~UsvfsConnector() { - DisconnectVFS(); + usvfsDisconnectVFS(); m_LogWorker.exit(); m_WorkerThread.quit(); m_WorkerThread.wait(); @@ -193,11 +193,11 @@ void UsvfsConnector::updateMapping(const MappingType& mapping) log::debug("Updating VFS mappings..."); - ClearVirtualMappings(); + usvfsClearVirtualMappings(); for (auto map : mapping) { if (progress.wasCanceled()) { - ClearVirtualMappings(); + usvfsClearVirtualMappings(); throw UsvfsConnectorException("VFS mapping canceled by user"); } progress.setValue(value++); @@ -206,13 +206,13 @@ void UsvfsConnector::updateMapping(const MappingType& mapping) } if (map.isDirectory) { - VirtualLinkDirectoryStatic( + usvfsVirtualLinkDirectoryStatic( map.source.toStdWString().c_str(), map.destination.toStdWString().c_str(), (map.createTarget ? LINKFLAG_CREATETARGET : 0) | LINKFLAG_RECURSIVE); ++dirs; } else { - VirtualLinkFile(map.source.toStdWString().c_str(), - map.destination.toStdWString().c_str(), 0); + usvfsVirtualLinkFile(map.source.toStdWString().c_str(), + map.destination.toStdWString().c_str(), 0); ++files; } } @@ -243,21 +243,21 @@ void UsvfsConnector::updateParams(MOBase::log::Levels logLevel, usvfsUpdateParameters(p); usvfsFreeParameters(p); - ClearExecutableBlacklist(); + usvfsClearExecutableBlacklist(); for (auto exec : executableBlacklist.split(";")) { std::wstring buf = exec.toStdWString(); - BlacklistExecutable(buf.data()); + usvfsBlacklistExecutable(buf.data()); } } void UsvfsConnector::updateForcedLibraries( const QList& forcedLibraries) { - ClearLibraryForceLoads(); + usvfsClearLibraryForceLoads(); for (auto setting : forcedLibraries) { if (setting.enabled()) { - ForceLoadLibrary(setting.process().toStdWString().data(), - setting.library().toStdWString().data()); + usvfsForceLoadLibrary(setting.process().toStdWString().data(), + setting.library().toStdWString().data()); } } } @@ -269,7 +269,7 @@ std::vector getRunningUSVFSProcesses() { size_t count = 0; DWORD* buffer = nullptr; - if (!::GetVFSProcessList2(&count, &buffer)) { + if (!::usvfsGetVFSProcessList2(&count, &buffer)) { log::error("failed to get usvfs process list"); return {}; } -- cgit v1.3.1