1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/injector/injector.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include <windows.h> 1.9 + 1.10 +#include "client/windows/handler/exception_handler.h" 1.11 + 1.12 +using google_breakpad::ExceptionHandler; 1.13 +using std::wstring; 1.14 + 1.15 +extern "C" BOOL WINAPI DummyEntryPoint(HINSTANCE instance, 1.16 + DWORD reason, 1.17 + void* reserved) 1.18 +{ 1.19 + __debugbreak(); 1.20 + 1.21 + return FALSE; // We're being loaded remotely, this shouldn't happen! 1.22 +} 1.23 + 1.24 +// support.microsoft.com/kb/94248 1.25 +extern "C" BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); 1.26 + 1.27 +extern "C" 1.28 +__declspec(dllexport) DWORD Start(void* context) 1.29 +{ 1.30 + // Because the remote DLL injector does not call DllMain, we have to 1.31 + // initialize the CRT manually 1.32 + _CRT_INIT(nullptr, DLL_PROCESS_ATTACH, nullptr); 1.33 + 1.34 + HANDLE hCrashPipe = reinterpret_cast<HANDLE>(context); 1.35 + 1.36 + ExceptionHandler* e = new (std::nothrow) 1.37 + ExceptionHandler(wstring(), nullptr, nullptr, nullptr, 1.38 + ExceptionHandler::HANDLER_ALL, 1.39 + MiniDumpNormal, hCrashPipe, nullptr); 1.40 + if (e) 1.41 + e->set_handle_debug_exceptions(true); 1.42 + return 1; 1.43 +}