⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crasher.cpp

📁 CExceptionLogger
💻 CPP
字号:
#include "stdafx.h"
#include <stdio.h>
#include <ole2.h>
#include <tlhelp32.h>

#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "oleaut32.lib")

class CCrash
{
public:
  CCrash(int nValue) 
  { 
    int* pValue = NULL; 
    *pValue = nValue; 
  };
};

void bar(int n)
{
  CCrash crash(n);  
}

void Foo(int n)
{
  bar(n+1);
}

DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
  CoInitialize(NULL);

  UINT nUnsignedValue = 1;
  int nSignedValue = 2;
  void* pPointerValue = (void*) 3;
  char charValue = 'A';
  char charValue2[] = "Little Miss Muffett";
  wchar_t wcharValue = 5;
  wchar_t wcharValue2[] = L"Mary had a little lamb";
  float floatValue = 6.0;
  double doubleValue = 7.0;
  BOOL boolValue = TRUE;
  long longValue = 9;
  unsigned long ulongvalue = 10;
  CURRENCY cy;
  cy.Lo = 10;
  cy.Hi = 11;
  DATE date = 5.875;
  VARIANT variant;
  variant.vt = VT_I4;
  variant.lVal = 11;
  BSTR bstrVal = SysAllocString(L"Jack and Kill");
  HRESULT hr = E_FAIL;

  BSTR bstrNullVal = NULL;

  int nIntArray[12];
  for (int i=0; i<12;i++)
    nIntArray[i] = i;

  unsigned int unIntArray[12];
  for (i=0; i<12;i++)
    unIntArray[i] = i;

  float floatArray[3];
  for (i=0; i<3; i++)
    floatArray[i] = (float) i;

  double doubleArray[3];
  for (i=0; i<3; i++)
    doubleArray[i] = (double) i;

  void* voidArray[3];
  for (i=0; i<3; i++)
    voidArray[i] = (void*) i;

  long longArray[3];
  for (i=0; i<3; i++)
    longArray[i] = i;

  unsigned long ulongArray[3];
  for (i=0; i<3; i++)
    ulongArray[i] = i;

  unsigned short ushortArray[3];
  for (i=0; i<3; i++)
    ushortArray[i] = i;
  
  short shortArray[3];
  for (i=0; i<3; i++)
    shortArray[i] = i;


  SYSTEMTIME st;
  GetLocalTime(&st);

  //Wait for 3 seconds in a tight loop before we crash
  DWORD dwStartTick = GetTickCount();
  while ((GetTickCount() - dwStartTick) < 3000);

  const int TimeOfDay = 44;

  GetSystemTime(&st);

  CCrash crash(13);

  return 0;
}


void main()
{
  CoInitialize(NULL);

  //Install our crash handler
  HMODULE hCrashDLL = LoadLibrary("XCPTHLR.DLL");
  if (hCrashDLL == NULL)
  {
    printf("Failed to load XCPTHLR DLL, Error:%d\n", GetLastError());
    return;
  }

  //Create a thread just to get more than 1 thread listed in the crash log
  DWORD dwThreadId;
  CreateThread(NULL, 0, ThreadProc, NULL, 0, &dwThreadId);

  //just wait for the other thread to keep over
  Sleep(INFINITE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -