vc core dump文件


#include <Dbghelp.h> extern int LocalAccessDBInit(LPCSTR strDBName,LPCSTR pszLocakBackDB); void CreateMiniDump( EXCEPTION_POINTERS* pep ); BOOL CALLBACK MyMiniDumpCallback( PVOID pParam, const PMINIDUMP_CALLBACK_INPUT pInput, PMINIDUMP_CALLBACK_OUTPUT pOutput ); /////////////////////////////////////////////////////////////////////////////// // Custom minidump callback // BOOL CALLBACK MyMiniDumpCallback( PVOID pParam, const PMINIDUMP_CALLBACK_INPUT pInput, PMINIDUMP_CALLBACK_OUTPUT pOutput ) { BOOL bRet = FALSE; // Check parameters if( pInput == 0 ) return FALSE; if( pOutput == 0 ) return FALSE; // Process the callbacks switch( pInput->CallbackType ) { case IncludeModuleCallback: { // Include the module into the dump bRet = TRUE; } break; case IncludeThreadCallback: { // Include the thread into the dump bRet = TRUE; } break; case ModuleCallback: { // Does the module have ModuleReferencedByMemory flag set ? if( !(pOutput->ModuleWriteFlags & ModuleReferencedByMemory) ) { // No, it does not - exclude it wprintf( L"Excluding module: %s \n", pInput->Module.FullPath ); pOutput->ModuleWriteFlags &= (~ModuleWriteModule); } bRet = TRUE; } break; case ThreadCallback: { // Include all thread information into the minidump bRet = TRUE; } break; case ThreadExCallback: { // Include this information bRet = TRUE; } break; case MemoryCallback: { // We do not include any information here -> return FALSE bRet = FALSE; } break; case CancelCallback: break; } return bRet; } void CreateMiniDump( EXCEPTION_POINTERS* pep ) { // Open the file HANDLE hFile = CreateFile( ("wth__MiniDump.dmp"), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) ) { // Create the minidump MINIDUMP_EXCEPTION_INFORMATION mdei; mdei.ThreadId = GetCurrentThreadId(); mdei.ExceptionPointers = pep; mdei.ClientPointers = FALSE; MINIDUMP_CALLBACK_INFORMATION mci; mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)MyMiniDumpCallback; mci.CallbackParam = 0; MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory); BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, mdt, (pep != 0) ? &mdei : 0, 0, &mci ); if( !rv ) ShowLog(0, 0, "MiniDumpWriteDump failed. Error: %u \n", GetLastError()); else ShowLog(0, 0, "Minidump created."); // Close the file CloseHandle( hFile ); } else { ShowLog(0, 0, "CreateFile failed. Error: %u \n", GetLastError()); } }

 

        int t = -10;
         __try
        {
            t = check_device_inform_param(handle, strSendData, len, pCallBack, dwUser);  
        }
        __except(CreateMiniDump(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER)
        {

        }

 

    *(int*)123=456;
    int a[1];
    a[2]=3;

 

 

 

 


2、

 

  

 

posted @ 2024-07-06 19:16  cnchengv  阅读(2)  评论(0编辑  收藏  举报