运行不定长时间,有时候是几天,有时候几小时,程序就无响应了,我自己做的日志也没有任何输出。在金字塔的策略中,有3个类似MID的入口,我都加了__try __except,但是没有任何的输出的。有一次我修改了参数,结果读取参数的时候越界了,就发现日志中有记录的。
我程序的代码片段:
__declspec(dllexport) int WINAPI MID(CALCINFO *calc)
{
int ret;
__try
{
ret = __mid(calc);
}
__except(except_handler(GetExceptionInformation()))
{
}
return ret;
}
int except_handler(LPEXCEPTION_POINTERS excep)
{
int i;
PCONTEXT context;
unsigned long *esp;
context = excep->ContextRecord;
syslog("ebp %x, eip %x, esp %x, esi %x, edi %x, eax %x, ebx %x, ecx %x\n",
context->Ebp, context->Eip, context->Esp, context->Esi,
context->Edi, context->Eax, context->Ebx, context->Ecx);
fflush(fp_syslog);
return EXCEPTION_EXECUTE_HANDLER;
}