Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsSetDllDirectory_h |
michael@0 | 7 | #define nsSetDllDirectory_h |
michael@0 | 8 | |
michael@0 | 9 | #ifndef XP_WIN |
michael@0 | 10 | #error This file only makes sense on Windows. |
michael@0 | 11 | #endif |
michael@0 | 12 | |
michael@0 | 13 | #include <windows.h> |
michael@0 | 14 | #include <nscore.h> |
michael@0 | 15 | #include <stdlib.h> |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | |
michael@0 | 19 | static void SanitizeEnvironmentVariables() |
michael@0 | 20 | { |
michael@0 | 21 | DWORD bufferSize = GetEnvironmentVariableW(L"PATH", nullptr, 0); |
michael@0 | 22 | if (bufferSize) { |
michael@0 | 23 | wchar_t* originalPath = new wchar_t[bufferSize]; |
michael@0 | 24 | if (bufferSize - 1 == GetEnvironmentVariableW(L"PATH", originalPath, bufferSize)) { |
michael@0 | 25 | bufferSize = ExpandEnvironmentStringsW(originalPath, nullptr, 0); |
michael@0 | 26 | if (bufferSize) { |
michael@0 | 27 | wchar_t* newPath = new wchar_t[bufferSize]; |
michael@0 | 28 | if (ExpandEnvironmentStringsW(originalPath, |
michael@0 | 29 | newPath, |
michael@0 | 30 | bufferSize)) { |
michael@0 | 31 | SetEnvironmentVariableW(L"PATH", newPath); |
michael@0 | 32 | } |
michael@0 | 33 | delete[] newPath; |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | delete[] originalPath; |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | #endif |