|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include <windows.h> |
|
6 |
|
7 #include "client/windows/handler/exception_handler.h" |
|
8 |
|
9 using google_breakpad::ExceptionHandler; |
|
10 using std::wstring; |
|
11 |
|
12 extern "C" BOOL WINAPI DummyEntryPoint(HINSTANCE instance, |
|
13 DWORD reason, |
|
14 void* reserved) |
|
15 { |
|
16 __debugbreak(); |
|
17 |
|
18 return FALSE; // We're being loaded remotely, this shouldn't happen! |
|
19 } |
|
20 |
|
21 // support.microsoft.com/kb/94248 |
|
22 extern "C" BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); |
|
23 |
|
24 extern "C" |
|
25 __declspec(dllexport) DWORD Start(void* context) |
|
26 { |
|
27 // Because the remote DLL injector does not call DllMain, we have to |
|
28 // initialize the CRT manually |
|
29 _CRT_INIT(nullptr, DLL_PROCESS_ATTACH, nullptr); |
|
30 |
|
31 HANDLE hCrashPipe = reinterpret_cast<HANDLE>(context); |
|
32 |
|
33 ExceptionHandler* e = new (std::nothrow) |
|
34 ExceptionHandler(wstring(), nullptr, nullptr, nullptr, |
|
35 ExceptionHandler::HANDLER_ALL, |
|
36 MiniDumpNormal, hCrashPipe, nullptr); |
|
37 if (e) |
|
38 e->set_handle_debug_exceptions(true); |
|
39 return 1; |
|
40 } |