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: #include michael@0: michael@0: // make sure we only ever spawn one thread michael@0: DWORD tid = -1; michael@0: michael@0: DWORD WINAPI CrashingThread( michael@0: LPVOID lpParameter michael@0: ) michael@0: { michael@0: // not a very friendly DLL michael@0: volatile int* x = (int *)0x0; michael@0: *x = 1; michael@0: return 0; michael@0: } michael@0: michael@0: BOOL WINAPI DllMain( michael@0: HANDLE hinstDLL, michael@0: DWORD dwReason, michael@0: LPVOID lpvReserved michael@0: ) michael@0: { michael@0: if (tid == -1) michael@0: // we have to crash on another thread because LoadLibrary() will michael@0: // catch memory access errors and return failure to the calling process michael@0: CreateThread( michael@0: nullptr, // default security attributes michael@0: 0, // use default stack size michael@0: CrashingThread, // thread function name michael@0: nullptr, // argument to thread function michael@0: 0, // use default creation flags michael@0: &tid); // returns the thread identifier michael@0: return TRUE; michael@0: }