亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? customizedwer.cpp

?? Windows via C/C++, Fifth Edition圖書源代碼
?? CPP
字號:
/******************************************************************************
Module:  CustomizedWER.cpp
Notices: Copyright (c) 2008 Jeffrey Richter & Christophe Nasarre
******************************************************************************/


#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#include <stdlib.h>  // for _countof definition
#include "..\CommonFiles\CmnHdr.h"     /* See Appendix A. */
#include <Windows.h>
#include <Windowsx.h>
#include <WerAPI.h>

#include <tchar.h>
#include <StrSafe.h>

#include "CustomizedWER.h"

// Required library for Windows Error Reporting
#pragma comment(lib, "wer")


///////////////////////////////////////////////////////////////////////////////
// Global variable used during problem reporting
typedef struct _MORE_INFO {
   DWORD dwCode;
   DWORD dwValue;
} MORE_INFO;

// Don't use stack or heap allocation to avoid corruption
MORE_INFO s_moreInfo1 = {0, 0};
MORE_INFO s_moreInfo2 = {0, 0};

// Store user choices related to shutdown options
BOOL s_bCustom = TRUE;
BOOL s_bAllowJITDebug = TRUE;
BOOL s_bGenerateReport = TRUE;


///////////////////////////////////////////////////////////////////////////////


void EnableAutomaticJITDebug(BOOL bAutomaticDebug) {

   // Create the subkey if necessary
   const LPCTSTR szKeyName = TEXT("Software\\Microsoft\\Windows\\Windows Error \
Reporting\\DebugApplications");
   HKEY hKey = NULL;
   DWORD dwDisposition = 0;
   LSTATUS lResult = ERROR_SUCCESS;
   lResult = RegCreateKeyEx(HKEY_CURRENT_USER, szKeyName, 0, NULL,
       REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisposition);
   if (lResult != ERROR_SUCCESS) {
      MessageBox(NULL, TEXT("RegCreateKeyEx failed"), 
         TEXT("EnableAutomaticJITDebug"), MB_OK | MB_ICONHAND);
      return;
   }
      
   // Give the right value to the Registry entry
   DWORD dwValue = bAutomaticDebug ? 1 : 0;
   TCHAR szFullpathName[MAX_PATH];
   GetModuleFileName(NULL, szFullpathName, _countof(szFullpathName));
   LPTSTR pszExeName = _tcsrchr(szFullpathName, TEXT('\\'));
   if (pszExeName != NULL) {
      // Skip the '\'
      pszExeName++;
      
      // Set the value
      lResult = RegSetValueEx(hKey, pszExeName, 0, REG_DWORD, 
         (const BYTE*)&dwValue, sizeof(dwValue));
      if (lResult != ERROR_SUCCESS) {
         MessageBox(NULL, TEXT("RegSetValueEx failed"), 
            TEXT("EnableAutomaticJITDebug"), MB_OK | MB_ICONHAND);
         return;
      }
   }
}


///////////////////////////////////////////////////////////////////////////////


LONG GenerateWerReport(struct _EXCEPTION_POINTERS* pExceptionInfo) {

   // Default return value
   LONG lResult = EXCEPTION_CONTINUE_SEARCH;

   // Avoid stack problem because wri is a big structure
   static WER_REPORT_INFORMATION wri = { sizeof(wri) };

   // Set the report details
   StringCchCopyW(wri.wzFriendlyEventName, _countof(wri.wzFriendlyEventName),
       L"Unexpected Error - 0x12345678");
   StringCchCopyW(wri.wzApplicationName, _countof(wri.wzApplicationName), 
      L"Wintellect Applications Suite");
   GetModuleFileNameW(NULL, (WCHAR*)&(wri.wzApplicationPath), 
      _countof(wri.wzApplicationPath));
   StringCchCopyW(wri.wzDescription, _countof(wri.wzDescription), 
      L"This problem report is generated for testing purpose");

   HREPORT hReport = NULL;
   
   // Create a report and set additional information
   __try {                        // V-- instead of the default APPCRASH_EVENT
      HRESULT hr = WerReportCreate(L"Unexpected Error", 
         WerReportApplicationCrash, &wri, &hReport);   

      if (FAILED(hr)) {
         MessageBox(NULL, TEXT("WerReportCreate failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }
      if (hReport == NULL) {
         MessageBox(NULL, TEXT("WerReportCreate failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }

      // Set more details important to help fix the problem
      WerReportSetParameter(hReport, WER_P0, 
         L"Application Name", L"26-CustomizedWER.exe");
      WerReportSetParameter(hReport, WER_P1, 
         L"Application Version", L"5.0.0.0");
      WerReportSetParameter(hReport, WER_P2, 
         L"Last Action", L"Server Request #12");
      WerReportSetParameter(hReport, WER_P3, 
         L"Last Connected Server", L"http://www.wintellect.com");

      // Add a dump file corresponding to the exception information
      WER_EXCEPTION_INFORMATION wei;
      wei.bClientPointers = FALSE;              // We are in the process where
      wei.pExceptionPointers = pExceptionInfo;  // pExceptionInfo is valid
      hr = WerReportAddDump(
         hReport, GetCurrentProcess(), GetCurrentThread(), 
         WerDumpTypeHeapDump, &wei, NULL, 0);
      if (FAILED(hr)) {
         MessageBox(NULL, TEXT("WerReportAddDump failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }

      // Let memory blocks be visible from a mini-dump
      s_moreInfo1.dwCode = 0x1;
      s_moreInfo1.dwValue = 0xDEADBEEF;
      s_moreInfo2.dwCode = 0x2;
      s_moreInfo2.dwValue = 0x0BADBEEF;
      hr = WerRegisterMemoryBlock(&s_moreInfo1, sizeof(s_moreInfo1));
      if (hr != S_OK) { // Don't want S_FALSE
         MessageBox(NULL, TEXT("First WerRegisterMemoryBlock failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }
      hr = WerRegisterMemoryBlock(&s_moreInfo2, sizeof(s_moreInfo2));
      if (hr != S_OK) { // Don't want S_FALSE
         MessageBox(NULL, TEXT("Second WerRegisterMemoryBlock failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }

      // Add more files to this particular report
      wchar_t wszFilename[] = L"MoreData.txt";
      char textData[] = "Contains more information about the execution \r\n\
context when the problem occurred. The goal is to \r\n\
help figure out the root cause of the issue.";
      // Note that error checking is removed for readability
      HANDLE hFile = CreateFileW(wszFilename, GENERIC_WRITE, 0, NULL, 
         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
      DWORD dwByteWritten = 0;
      WriteFile(hFile, (BYTE*)textData, sizeof(textData), &dwByteWritten, 
         NULL);
      CloseHandle(hFile);
      hr = WerReportAddFile(hReport, wszFilename, WerFileTypeOther, 
         WER_FILE_ANONYMOUS_DATA);
      if (FAILED(hr)) {
         MessageBox(NULL, TEXT("WerReportAddFile failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }

      // It is also possible to use WerRegisterFile 
      char textRegisteredData[] = "Contains more information about the \
execution \r\ncontext when the problem occurred. The goal is to \r\n\
help figure out the root cause of the issue.";
      // Note that error checking is removed for readability
      hFile = CreateFileW(L"RegisteredData1.txt", GENERIC_WRITE, 0, NULL, 
         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
      dwByteWritten = 0;
      WriteFile(hFile, (BYTE*)textRegisteredData, sizeof(textRegisteredData),
         &dwByteWritten, NULL);
      CloseHandle(hFile);
      hr = WerRegisterFile(L"RegisteredData1.txt", WerRegFileTypeOther, 
         WER_FILE_ANONYMOUS_DATA);
      if (FAILED(hr)) {
         MessageBox(NULL, TEXT("First WerRegisterFile failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }
      hFile = CreateFileW(L"RegisteredData2.txt", GENERIC_WRITE, 0, NULL, 
         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
      dwByteWritten = 0;
      WriteFile(hFile, (BYTE*)textRegisteredData, sizeof(textRegisteredData),
         &dwByteWritten, NULL);
      CloseHandle(hFile);
      hr = WerRegisterFile(L"RegisteredData2.txt", WerRegFileTypeOther, 
         WER_FILE_DELETE_WHEN_DONE);   // File is deleted after WerReportSubmit
      if (FAILED(hr)) {
         MessageBox(NULL, TEXT("Second WerRegisterFile failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }
      
      // Submit the report 
      WER_SUBMIT_RESULT wsr;
      DWORD submitOptions = 
         WER_SUBMIT_QUEUE |
         WER_SUBMIT_OUTOFPROCESS |
         WER_SUBMIT_NO_CLOSE_UI;  // Don't show any UI
      hr = WerReportSubmit(hReport, WerConsentApproved, submitOptions, &wsr); 
      if (FAILED(hr)) {
         MessageBox(NULL, TEXT("WerReportSubmit failed"), 
            TEXT("GenerateWerReport"), MB_OK | MB_ICONHAND);
         return(EXCEPTION_CONTINUE_SEARCH);
      }
      
      // The submission was successful, but we might need to check the result 
      switch(wsr)
      {
         case WerReportQueued:
         case WerReportUploaded: // To exit the process
            lResult = EXCEPTION_EXECUTE_HANDLER;   
            break;
         
         case WerReportDebug: // To end up in the debugger
            lResult = EXCEPTION_CONTINUE_SEARCH;   
            break;
         
         default: // Let the OS handle the exception
            lResult = EXCEPTION_CONTINUE_SEARCH;   
            break;
      }
      
      // In our case, we always exit the process after the report generation
      lResult = EXCEPTION_EXECUTE_HANDLER;
   }
   __finally {
      // Don't forget to close the report handle
      if (hReport != NULL) {
         WerReportCloseHandle(hReport);
         hReport = NULL;
      }
   }

   return(lResult);
}


///////////////////////////////////////////////////////////////////////////////


static BOOL s_bFirstTime = TRUE;

LONG WINAPI CustomUnhandledExceptionFilter(
   struct _EXCEPTION_POINTERS* pExceptionInfo) {

   // When the debugger gets attached and you stop the debugging session,
   // the execution resumes here...
   // So this case is detected and the application exits silently 
   if (s_bFirstTime)
      s_bFirstTime = FALSE;
   else
      ExitProcess(pExceptionInfo->ExceptionRecord->ExceptionCode);

   // Check shutdown options
   if (!s_bCustom)
      // Let Windows treat the exception 
      return(UnhandledExceptionFilter(pExceptionInfo));

   // Allow global unwind by default
   LONG lReturn = EXCEPTION_EXECUTE_HANDLER;

   // Let the user choose between Debug or Close application
   // except if JIT-debugging was disabled in the options
   int iChoice = IDCANCEL;
   if (s_bAllowJITDebug) {
      iChoice = MessageBox(NULL, 
         TEXT("Click RETRY if you want to debug\nClick CANCEL to quit"), 
         TEXT("The application must stop"), MB_RETRYCANCEL | MB_ICONHAND);
   }

   if (iChoice == IDRETRY) {
      // Force JIT-debugging for this application
      EnableAutomaticJITDebug(TRUE);

      // Ask Windows to JIT-attach the default debugger
      lReturn = EXCEPTION_CONTINUE_SEARCH;
   } else {
      // The application will be terminated
      lReturn = EXCEPTION_EXECUTE_HANDLER;

      // But check if we need to generate a problem report first
      if (s_bGenerateReport)
         GenerateWerReport(pExceptionInfo);
   }
   
   return(lReturn);   
}


///////////////////////////////////////////////////////////////////////////////


void TriggerException() {

   // Trigger an exception wrapped by a finally block
   // that is only executed if a global unwind occurs
   __try {
      TCHAR* p = NULL;
      *p = TEXT('a');
   }
   __finally {
      MessageBox(NULL, TEXT("Finally block is executed"), NULL, MB_OK);
   }
}




///////////////////////////////////////////////////////////////////////////////


BOOL Dlg_OnInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) {

   // Set dialog icon
   chSETDLGICONS(hWnd, IDI_MAINDLG);

   // Choose custom options
   Button_SetCheck(GetDlgItem(hWnd, IDR_CUSTOM), TRUE);
   Button_SetCheck(GetDlgItem(hWnd, IDC_ALLOW_DEBUG), TRUE);
   Button_SetCheck(GetDlgItem(hWnd, IDC_GENERATE_REPORT), TRUE);

   // Change the default focused control
   SetFocus(GetDlgItem(hWnd, IDR_CUSTOM));
   return(FALSE);
}


///////////////////////////////////////////////////////////////////////////////


void Dlg_OnCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) {

   switch (id) {
      case IDR_DEFAULT:
         // Disable custom options
         EnableWindow(GetDlgItem(hWnd, IDC_ALLOW_DEBUG), FALSE);
         EnableWindow(GetDlgItem(hWnd, IDC_GENERATE_REPORT), FALSE);
         break;

      case IDR_CUSTOM:
         // Enable custom options
         EnableWindow(GetDlgItem(hWnd, IDC_ALLOW_DEBUG), TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_GENERATE_REPORT), TRUE);
         break;

      case IDOK:
         // Keep track of the user choices about shutdown behavior
         s_bCustom = 
            (Button_GetCheck(GetDlgItem(hWnd, IDR_CUSTOM)) == BST_CHECKED);
         s_bAllowJITDebug = 
            (Button_GetCheck(GetDlgItem(hWnd, IDC_ALLOW_DEBUG)) 
            == BST_CHECKED);
         s_bGenerateReport = 
            (Button_GetCheck(GetDlgItem(hWnd, IDC_GENERATE_REPORT)) 
            == BST_CHECKED);

         TriggerException();
         break;

      case IDCANCEL:
         EndDialog(hWnd, id);
         break;
   }
}


///////////////////////////////////////////////////////////////////////////////


INT_PTR WINAPI Dlg_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {

   switch (uMsg) {
      chHANDLE_DLGMSG(hWnd, WM_INITDIALOG, Dlg_OnInitDialog);
      chHANDLE_DLGMSG(hWnd, WM_COMMAND,    Dlg_OnCommand);
   }
   return(FALSE);
}


///////////////////////////////////////////////////////////////////////////////


int APIENTRY _tWinMain(HINSTANCE hInstExe, HINSTANCE, LPTSTR, int) {

   int iReturn = 0;

   // Disable the automatic JIT-debugger attachment
   // that could have been enabled in CustomUnhandledExceptionFilter
   // in a prior execution of the same application
   EnableAutomaticJITDebug(FALSE);

   // Protect the code with our own exception filter
   __try {
      DialogBox(hInstExe, MAKEINTRESOURCE(IDD_MAINDLG), NULL, Dlg_Proc);
   }
   __except(CustomUnhandledExceptionFilter(GetExceptionInformation())) {
      MessageBox(NULL, TEXT("Bye bye"), NULL, MB_OK);
      ExitProcess(GetExceptionCode());
   }

   return(iReturn);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
7777精品伊人久久久大香线蕉超级流畅 | 国产欧美日韩在线视频| 免费成人在线观看| 精品国产成人在线影院| 精品一区二区久久久| 精品久久久久久久一区二区蜜臀| 麻豆精品视频在线| 国产亚洲欧洲一区高清在线观看| 粉嫩av一区二区三区粉嫩| 中文字幕日本不卡| 欧美写真视频网站| 精品中文字幕一区二区小辣椒| 久久综合色婷婷| 9人人澡人人爽人人精品| 亚洲一区二区三区免费视频| 日韩一区二区三区在线视频| 丰满放荡岳乱妇91ww| 亚洲黄色尤物视频| 精品国产网站在线观看| 91蜜桃视频在线| 爽爽淫人综合网网站| 久久精品人人做| 欧美在线|欧美| 国内外精品视频| 有坂深雪av一区二区精品| 欧美成人三级在线| eeuss鲁片一区二区三区| 亚洲成人一区在线| 中文字幕精品综合| 3d成人h动漫网站入口| 成人晚上爱看视频| 日韩成人免费在线| 亚洲欧洲国产日韩| 精品国产青草久久久久福利| 99re视频精品| 国产一二精品视频| 亚洲福利视频一区| 国产精品欧美久久久久无广告 | 欧美国产精品一区二区| 欧美中文字幕一二三区视频| 国产综合久久久久久久久久久久| 一区二区三区在线视频观看 | 蜜臀91精品一区二区三区 | 另类欧美日韩国产在线| 亚洲欧美日本在线| 国产欧美一区二区精品久导航 | 日本乱人伦一区| 国产成人鲁色资源国产91色综| 香蕉成人啪国产精品视频综合网 | 色诱亚洲精品久久久久久| 狠狠色综合播放一区二区| 亚洲成人av在线电影| 《视频一区视频二区| 2023国产精品自拍| 日韩亚洲欧美在线观看| 在线看日韩精品电影| 91丝袜高跟美女视频| 成人午夜电影网站| 高清beeg欧美| 国产福利一区二区三区在线视频| 日韩av一二三| 日韩影院在线观看| 日韩激情视频在线观看| 亚洲综合色在线| 亚洲自拍偷拍综合| 亚洲精品ww久久久久久p站| 亚洲欧美日韩国产手机在线 | 亚洲国产日日夜夜| 亚洲精品国产一区二区三区四区在线| 国产欧美精品一区二区三区四区| 久久影院午夜论| 久久久久一区二区三区四区| 精品国产制服丝袜高跟| 欧美xxxx在线观看| 欧美成人精品福利| 精品福利在线导航| 国产亚洲短视频| 国产女主播视频一区二区| 国产日韩欧美激情| 国产精品污网站| 亚洲欧美电影一区二区| 亚洲宅男天堂在线观看无病毒| 亚洲一区国产视频| 日韩国产欧美在线观看| 欧美aaaaa成人免费观看视频| 日本中文字幕一区二区视频| 免费人成黄页网站在线一区二区| 久久99精品国产.久久久久久| 国产一区二区看久久| 国产精品888| 91网站视频在线观看| 精品视频色一区| 日韩一区二区高清| 国产亚洲制服色| 一区二区三区美女视频| 丝袜美腿亚洲色图| 国产成人av资源| 99精品久久免费看蜜臀剧情介绍| 色综合久久久久久久久| 91精品国产综合久久蜜臀| 久久午夜电影网| 国产精品无码永久免费888| 一区二区三区四区乱视频| 国产精品一二三四五| 亚洲女厕所小便bbb| 亚洲国产视频a| 精品亚洲aⅴ乱码一区二区三区| 国产一区二区三区四区五区入口| 粉嫩嫩av羞羞动漫久久久| 欧美日韩国产一级二级| 久久精品在线免费观看| 樱花草国产18久久久久| 麻豆国产精品视频| 一本久久综合亚洲鲁鲁五月天| 日韩一区二区精品葵司在线| 国产精品成人午夜| 免费看日韩a级影片| a亚洲天堂av| 精品国精品国产| 亚洲一区二区三区激情| 懂色av一区二区三区蜜臀| 欧美日韩一区中文字幕| 国产精品久久看| 蜜桃av一区二区在线观看| 色婷婷综合在线| 久久网这里都是精品| 五月激情综合网| 不卡的av在线| 精品国产乱码久久久久久图片| 亚洲午夜电影网| 成人免费毛片高清视频| 精品久久久久久亚洲综合网| 亚洲二区在线观看| av不卡一区二区三区| 久久久久久久免费视频了| 午夜电影网一区| 色综合久久久久网| 国产精品国产三级国产普通话三级| 美美哒免费高清在线观看视频一区二区| 99国产精品久久久久久久久久 | 丝瓜av网站精品一区二区| 97精品国产露脸对白| 久久九九影视网| 久久超碰97中文字幕| 欧美性淫爽ww久久久久无| 中文字幕一区二区三区色视频| 国产一区美女在线| 精品国产亚洲在线| 麻豆精品一区二区| 日韩一卡二卡三卡国产欧美| 婷婷综合在线观看| 欧美日韩一区精品| 亚洲一区在线观看网站| 色综合天天综合色综合av| 国产精品午夜免费| 成人高清免费观看| 国产精品天天看| eeuss鲁片一区二区三区在线看| 国产婷婷色一区二区三区| 国产精品一品视频| 久久久.com| va亚洲va日韩不卡在线观看| 国产欧美日韩在线| www.视频一区| 综合在线观看色| 91网站在线观看视频| 亚洲精品视频在线观看免费| 一本一本大道香蕉久在线精品 | 日本强好片久久久久久aaa| 欧美喷潮久久久xxxxx| 一区二区三区中文字幕精品精品| 一本久久a久久精品亚洲| 亚洲综合一区二区| 欧美日韩中文字幕精品| 蜜臀av性久久久久蜜臀aⅴ | 日韩一区和二区| 精品无码三级在线观看视频| 久久美女高清视频| 成人一区二区三区视频| 1区2区3区国产精品| 色婷婷激情久久| 天天综合色天天综合色h| 日韩精品一区二区三区中文精品| 国产乱子轮精品视频| 国产精品美女久久福利网站| 91小视频免费观看| 麻豆精品新av中文字幕| 国产91精品久久久久久久网曝门 | 日韩欧美国产高清| 国产美女av一区二区三区| 国产精品色噜噜| 在线观看免费一区| 免费国产亚洲视频| 国产婷婷色一区二区三区 | 亚洲国产婷婷综合在线精品| 日韩午夜在线观看| www.久久久久久久久| 日韩国产一区二| 国产精品福利av| 制服丝袜一区二区三区|