michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: michael@0: #include "client/windows/handler/exception_handler.h" michael@0: michael@0: using google_breakpad::ExceptionHandler; michael@0: using std::wstring; michael@0: michael@0: extern "C" BOOL WINAPI DummyEntryPoint(HINSTANCE instance, michael@0: DWORD reason, michael@0: void* reserved) michael@0: { michael@0: __debugbreak(); michael@0: michael@0: return FALSE; // We're being loaded remotely, this shouldn't happen! michael@0: } michael@0: michael@0: // support.microsoft.com/kb/94248 michael@0: extern "C" BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); michael@0: michael@0: extern "C" michael@0: __declspec(dllexport) DWORD Start(void* context) michael@0: { michael@0: // Because the remote DLL injector does not call DllMain, we have to michael@0: // initialize the CRT manually michael@0: _CRT_INIT(nullptr, DLL_PROCESS_ATTACH, nullptr); michael@0: michael@0: HANDLE hCrashPipe = reinterpret_cast(context); michael@0: michael@0: ExceptionHandler* e = new (std::nothrow) michael@0: ExceptionHandler(wstring(), nullptr, nullptr, nullptr, michael@0: ExceptionHandler::HANDLER_ALL, michael@0: MiniDumpNormal, hCrashPipe, nullptr); michael@0: if (e) michael@0: e->set_handle_debug_exceptions(true); michael@0: return 1; michael@0: }