Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for new USVFS function scheme. #2044

Merged
merged 4 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ jobs:
qt-modules: qtpositioning qtwebchannel qtwebengine qtwebsockets
mo2-third-parties:
7z zlib gtest libbsarch libloot openssl bzip2 python lz4 spdlog
boost boost-di sip pyqt pybind11 ss licenses explorerpp usvfs
mo2-dependencies: cmake_common uibase githubpp bsatk esptk archive lootcli game_gamebryo
boost boost-di sip pyqt pybind11 ss licenses explorerpp
mo2-dependencies: usvfs cmake_common uibase githubpp bsatk esptk archive lootcli game_gamebryo
23 changes: 1 addition & 22 deletions src/shared/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<USVFSVersionStringType*>(
::GetProcAddress(m, "USVFSVersionString"));

if (f) {
s = f();
}

::FreeLibrary(m);
}

QString s = usvfsVersionString();
if (s.isEmpty()) {
s = "?";
}

return s;
}

Expand Down
6 changes: 3 additions & 3 deletions src/spawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wchar_t*>(wcommandLine.c_str()),
nullptr, nullptr, inheritHandles, flags, nullptr,
wcwd.c_str(), &si, &pi);
success = ::usvfsCreateProcessHooked(
nullptr, const_cast<wchar_t*>(wcommandLine.c_str()), nullptr, nullptr,
inheritHandles, flags, nullptr, wcwd.c_str(), &si, &pi);
} else {
success = ::CreateProcess(nullptr, const_cast<wchar_t*>(wcommandLine.c_str()),
nullptr, nullptr, inheritHandles, flags, nullptr,
Expand Down
34 changes: 17 additions & 17 deletions src/usvfsconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"
Expand All @@ -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);

Expand All @@ -172,7 +172,7 @@ UsvfsConnector::UsvfsConnector()

UsvfsConnector::~UsvfsConnector()
{
DisconnectVFS();
usvfsDisconnectVFS();
m_LogWorker.exit();
m_WorkerThread.quit();
m_WorkerThread.wait();
Expand All @@ -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++);
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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<MOBase::ExecutableForcedLoadSetting>& 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());
}
}
}
Expand All @@ -269,7 +269,7 @@ std::vector<HANDLE> 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 {};
}
Expand Down
Loading