WindowsDllMain.cpp (884B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include <libloaderapi.h> 8 9 BOOL WINAPI DllMain(HINSTANCE aInstDll, DWORD aReason, LPVOID) { 10 if (aReason == DLL_PROCESS_ATTACH) { 11 ::DisableThreadLibraryCalls(aInstDll); 12 13 // mozglue.dll imports RtlGenRandom from advapi32.dll as SystemFunction036, 14 // but the actual function is implemented in cryptbase.dll. To avoid 15 // loading a fake cryptbase.dll from the installation directory, we preload 16 // cryptbase.dll from the system directory. 17 ::LoadLibraryExW(L"cryptbase.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); 18 } 19 return TRUE; 20 }