diff options
| author | Tannin <devnull@localhost> | 2013-03-18 20:03:46 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-03-18 20:03:46 +0100 |
| commit | 8b31996525de06bcb0ff519be42a732c85f532c9 (patch) | |
| tree | ddf491f435d282c687376ba4c13e99e7cc5dd7b0 /src/spawn.cpp | |
| parent | b3d0fcb2083143dc21c751adafd2523c3555e5d2 (diff) | |
- 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
Diffstat (limited to 'src/spawn.cpp')
| -rw-r--r-- | src/spawn.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. #include "spawn.h" #include "report.h" #include "utility.h" +#include <boost/scoped_array.hpp> #include <gameinfo.h> #include <inject.h> #include <appconfig.h> @@ -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<TCHAR> 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<TCHAR> 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) { |
