tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

crashinjectdll.cpp (1063B)


      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 // make sure we only ever spawn one thread
      8 DWORD tid = -1;
      9 
     10 DWORD WINAPI CrashingThread(LPVOID lpParameter) {
     11  // not a very friendly DLL
     12  volatile int* x = (int*)0x0;
     13  *x = 1;
     14  return 0;
     15 }
     16 
     17 BOOL WINAPI DllMain(HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved) {
     18  if (tid == (DWORD)-1)
     19    // we have to crash on another thread because LoadLibrary() will
     20    // catch memory access errors and return failure to the calling process
     21    CreateThread(nullptr,         // default security attributes
     22                 0,               // use default stack size
     23                 CrashingThread,  // thread function name
     24                 nullptr,         // argument to thread function
     25                 0,               // use default creation flags
     26                 &tid);           // returns the thread identifier
     27  return TRUE;
     28 }