From 8b31996525de06bcb0ff519be42a732c85f532c9 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 18 Mar 2013 20:03:46 +0100 Subject: - bugfix: invalid ini file name when creating profile for oblivion from default settings - bugfix: archives.txt file was potentially not generated if there were no bsas - bugfix: static __declspec(thread) declaration causes crashes in windows versions before vista - logger class in hook.dll now tries alternative names for the log file if it can't access the regular file - path-environment variable for mo-spawned processes now contains the path to MO, in case the hook.dll needs to find the msvc-dlls - stack-search in ini-limit hack now starts searching on local stack. This should find the right stack position for the hack more reliable --- src/spawn.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/spawn.cpp') diff --git a/src/spawn.cpp b/src/spawn.cpp index 39bd2af9..e83c8e21 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -20,6 +20,7 @@ along with Mod Organizer. If not, see . #include "spawn.h" #include "report.h" #include "utility.h" +#include #include #include #include @@ -31,6 +32,8 @@ using namespace MOBase; using namespace MOShared; +static const int BUFSIZE = 4096; + bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool suspended, HANDLE& processHandle, HANDLE& threadHandle) { STARTUPINFO si; @@ -44,7 +47,25 @@ bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool sus } else { commandLine = new wchar_t[length]; _snwprintf(commandLine, length, L"\"%ls\"", binary); + } + QString moPath = QCoreApplication::applicationDirPath(); + + boost::scoped_array oldPath(new TCHAR[BUFSIZE]); + DWORD offset = ::GetEnvironmentVariable(TEXT("PATH"), oldPath.get(), BUFSIZE); + if (offset > BUFSIZE) { + oldPath.reset(new TCHAR[offset]); + ::GetEnvironmentVariable(TEXT("PATH"), oldPath.get(), offset); + } + + { + boost::scoped_array newPath(new TCHAR[offset + moPath.length() + 2]); + _tcsncpy(newPath.get(), oldPath.get(), offset - 1); + newPath.get()[offset - 1] = L'\0'; + _tcsncat(newPath.get(), TEXT(";"), 1); + _tcsncat(newPath.get(), ToWString(QDir::toNativeSeparators(moPath)).c_str(), moPath.length()); + + ::SetEnvironmentVariable(TEXT("PATH"), newPath.get()); } PROCESS_INFORMATION pi; @@ -58,6 +79,8 @@ bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool sus &si, &pi // startup and process information ); + ::SetEnvironmentVariable(TEXT("PATH"), oldPath.get()); + delete [] commandLine; if (!success) { -- cgit v1.3.1