From 347ac2b8b5f34a2583ae7844e0dfd79773657270 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Fri, 11 Jan 2019 01:39:05 -0600 Subject: Support for force loading libraries --- src/organizercore.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index c4029a6d..39cb4d13 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1199,10 +1199,15 @@ QStringList OrganizerCore::modsSortedByProfilePriority() const return res; } -void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, const QString &steamAppID, const QString &customOverwrite) +void OrganizerCore::spawnBinary(const QFileInfo &binary, + const QString &arguments, + const QDir ¤tDirectory, + const QString &steamAppID, + const QString &customOverwrite, + const QList &forcedLibraries) { DWORD processExitCode = 0; - HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID, customOverwrite, &processExitCode); + HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID, customOverwrite, forcedLibraries, &processExitCode); if (processHandle != INVALID_HANDLE_VALUE) { refreshDirectoryStructure(); // need to remove our stored load order because it may be outdated if a foreign tool changed the @@ -1227,9 +1232,10 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QDir ¤tDirectory, const QString &steamAppID, const QString &customOverwrite, + const QList &forcedLibraries, LPDWORD exitCode) { - HANDLE processHandle = spawnBinaryProcess(binary, arguments, profileName, currentDirectory, steamAppID, customOverwrite); + HANDLE processHandle = spawnBinaryProcess(binary, arguments, profileName, currentDirectory, steamAppID, customOverwrite, forcedLibraries); if (Settings::instance().lockGUI() && processHandle != INVALID_HANDLE_VALUE) { std::unique_ptr dlg; ILockedWaitingForProcess* uilock = nullptr; @@ -1264,7 +1270,8 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary, const QString &profileName, const QDir ¤tDirectory, const QString &steamAppID, - const QString &customOverwrite) + const QString &customOverwrite, + const QList &forcedLibraries) { prepareStart(); @@ -1324,6 +1331,8 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary, if (m_AboutToRun(binary.absoluteFilePath())) { try { m_USVFS.updateMapping(fileMapping(profileName, customOverwrite)); + m_USVFS.updateForcedLibraries(forcedLibraries); + } catch (const UsvfsConnectorException &e) { qDebug(e.what()); return INVALID_HANDLE_VALUE; @@ -1416,6 +1425,10 @@ HANDLE OrganizerCore::runShortcut(const MOShortcut& shortcut) .toLocal8Bit().constData()); Executable& exe = m_ExecutablesList.find(shortcut.executable()); + auto forcedLibaries = m_CurrentProfile->determineForcedLibraries(shortcut.executable()); + if (!m_CurrentProfile->forcedLibrariesEnabled(exe.m_BinaryInfo.fileName())) { + forcedLibaries.clear(); + } return spawnBinaryDirect( exe.m_BinaryInfo, exe.m_Arguments, @@ -1423,7 +1436,9 @@ HANDLE OrganizerCore::runShortcut(const MOShortcut& shortcut) exe.m_WorkingDirectory.length() != 0 ? exe.m_WorkingDirectory : exe.m_BinaryInfo.absolutePath(), - exe.m_SteamAppID, ""); + exe.m_SteamAppID, + "", + forcedLibaries); } HANDLE OrganizerCore::startApplication(const QString &executable, @@ -1444,6 +1459,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, } QString steamAppID; QString customOverwrite; + QList forcedLibraries; if (executable.contains('\\') || executable.contains('/')) { // file path @@ -1462,6 +1478,9 @@ HANDLE OrganizerCore::startApplication(const QString &executable, customOverwrite = m_CurrentProfile->setting("custom_overwrites", exe.m_Title) .toString(); + if (m_CurrentProfile->forcedLibrariesEnabled(exe.m_Title)) { + forcedLibraries = m_CurrentProfile->determineForcedLibraries(exe.m_Title); + } } catch (const std::runtime_error &) { // nop } @@ -1473,6 +1492,9 @@ HANDLE OrganizerCore::startApplication(const QString &executable, customOverwrite = m_CurrentProfile->setting("custom_overwrites", exe.m_Title) .toString(); + if (m_CurrentProfile->forcedLibrariesEnabled(exe.m_Title)) { + forcedLibraries = m_CurrentProfile->determineForcedLibraries(exe.m_Title); + } if (arguments == "") { arguments = exe.m_Arguments; } @@ -1487,7 +1509,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, } } - return spawnBinaryDirect(binary, arguments, profileName, currentDirectory, steamAppID, customOverwrite); + return spawnBinaryDirect(binary, arguments, profileName, currentDirectory, steamAppID, customOverwrite, forcedLibraries); } bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode) -- cgit v1.3.1