The program I maintain in work auto terminate without any error information, I can confrim that the problem is in one of DLLs loaded, but there are tens of dll in problem, which one crash is hard to find.
I create a test program in VC6 to emulates the situation. The error codes list below:
char pTest[2] = {0};
strcpy(pTest, "hello world!ccccccccccccccccccccccccc");
if the code in a console program like fllowing codes, the error can be detected by CrashRpt.
#include "stdafx.h"
#include <windows.h>
typedef BOOL ( CALLBACK *ENUMSIGNALPROC )( int, float, LPVOID );
typedef BOOL (*PQUERY)(HANDLE, int, ENUMSIGNALPROC, LPVOID);
#include "./crashrpt/include/crashrpt.h"
#pragma comment(lib, "./crashrpt/lib/crashrpt")
int main(int argc, char* argv[])
{
LPVOID m_lpvState;
m_lpvState = CrashHandle_Install(NULL,NULL, NULL);
CrashHandle_SetIsInteractive(m_lpvState,false);
CrashHandle_SetIsKillProcess(m_lpvState,false);
printf("Hello World!\n");
char pTest[2] = {0};
strcpy(pTest, "hello world!ccccccccccccccccccccccccc");
printf("222222222222222222222222\n");
return 0;
}
but if the error codes in dll, the error will not be catch by CrashRpt. codes below:
int main(int argc, char* argv[])
{
LPVOID m_lpvState;
m_lpvState = CrashHandle_Install(NULL,NULL, NULL);
CrashHandle_SetIsInteractive(m_lpvState,false);
CrashHandle_SetIsKillProcess(m_lpvState,false);
printf("Hello World!\n");
HMODULE hMod = LoadLibrary("COM1_cu06h.DLL");
if (hMod != NULL)
{
PQUERY p = (PQUERY)GetProcAddress(hMod, "Query");
if (p != NULL)
{
for(int i=0; i<30; i++)
{
p(0, 0, NULL, 0);
printf("--------\n");
}
}
}
printf("222222222222222222222222\n");
return 0;
}
the DLL code lists below:
int g_nSampleCnt = 0;
DLLExport BOOL Query(HANDLE hCom, int nNo, ENUMSIGNALPROC proc, LPVOID lp)
{
char pTest[2] = {0};
try
{
g_nSampleCnt++;
if(g_nSampleCnt == 3)
{
strcpy(pTest, "hello world!ccccccccccccccccccccccccc");
}
}
catch( ... )
{
OutputError( ErrLog_FILE, "\r\n .DLL Error\r\n" );
}
g_nSampleCnt = g_nSampleCnt%30;
return TRUE;
}
I used the try...catch(...) and __try...__except and SEH method, its can catches the exceptions like devision by zero, but the codes like this will not be catched.
char pTest[2] = {0};
strcpy(pTest, "hello world!ccccccccccccccccccccccccc");
Any solutions or tools recommended will be appreciate.