Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; 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 file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include <windows.h> |
michael@0 | 7 | |
michael@0 | 8 | // Delayed load libraries are loaded when the first symbol is used. |
michael@0 | 9 | // The following ensures that we load the delayed loaded libraries from the |
michael@0 | 10 | // system directory. |
michael@0 | 11 | struct AutoLoadSystemDependencies |
michael@0 | 12 | { |
michael@0 | 13 | AutoLoadSystemDependencies() |
michael@0 | 14 | { |
michael@0 | 15 | // Remove the current directory from the search path for dynamically loaded |
michael@0 | 16 | // DLLs as a precaution. This call has no effect for delay load DLLs. |
michael@0 | 17 | SetDllDirectory(L""); |
michael@0 | 18 | |
michael@0 | 19 | // The order that these are loaded matter, for example if we load something |
michael@0 | 20 | // that tries to load profapi.dll first, then profapi.dll would be loaded |
michael@0 | 21 | // wrongly from the current directory. |
michael@0 | 22 | static LPCWSTR delayDLLs[] = { L"profapi.dll", L"wsock32.dll", |
michael@0 | 23 | L"crypt32.dll", L"cryptsp.dll", |
michael@0 | 24 | L"cryptbase.dll", L"msasn1.dll", |
michael@0 | 25 | L"userenv.dll", L"secur32.dll", |
michael@0 | 26 | L"ws2_32.dll", L"ws2help.dll", |
michael@0 | 27 | L"apphelp.dll", L"bcryptprimitives.dll" }; |
michael@0 | 28 | |
michael@0 | 29 | WCHAR systemDirectory[MAX_PATH + 1] = { L'\0' }; |
michael@0 | 30 | // If GetSystemDirectory fails we accept that we'll load the DLLs from the |
michael@0 | 31 | // normal search path. |
michael@0 | 32 | GetSystemDirectory(systemDirectory, MAX_PATH + 1); |
michael@0 | 33 | size_t systemDirLen = wcslen(systemDirectory); |
michael@0 | 34 | |
michael@0 | 35 | // Make the system directory path terminate with a slash |
michael@0 | 36 | if (systemDirectory[systemDirLen - 1] != L'\\' && systemDirLen) { |
michael@0 | 37 | systemDirectory[systemDirLen] = L'\\'; |
michael@0 | 38 | ++systemDirLen; |
michael@0 | 39 | // No need to re-null terminate |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | // For each known DLL ensure it is loaded from the system32 directory |
michael@0 | 43 | for (size_t i = 0; i < sizeof(delayDLLs) / sizeof(delayDLLs[0]); ++i) { |
michael@0 | 44 | size_t fileLen = wcslen(delayDLLs[i]); |
michael@0 | 45 | wcsncpy(systemDirectory + systemDirLen, delayDLLs[i], |
michael@0 | 46 | MAX_PATH - systemDirLen); |
michael@0 | 47 | if (systemDirLen + fileLen <= MAX_PATH) { |
michael@0 | 48 | systemDirectory[systemDirLen + fileLen] = L'\0'; |
michael@0 | 49 | } else { |
michael@0 | 50 | systemDirectory[MAX_PATH] = L'\0'; |
michael@0 | 51 | } |
michael@0 | 52 | LPCWSTR fullModulePath = systemDirectory; // just for code readability |
michael@0 | 53 | LoadLibraryW(fullModulePath); |
michael@0 | 54 | } |
michael@0 | 55 | } |
michael@0 | 56 | } loadDLLs; |