首页
社区
课程
招聘
[求助]自写veh+硬件断电崩溃,ce的veh功能没有问题
发表于: 2016-5-9 19:55 4290

[求助]自写veh+硬件断电崩溃,ce的veh功能没有问题

2016-5-9 19:55
4290
收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 3272
活跃值: (4409)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
ce开源的 自己看看不就知道了
2016-5-9 19:57
0
雪    币: 96
活跃值: (64)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
unction InternalHandler(ExceptionInfo: PEXCEPTION_POINTERS; threadid: dword): LONG;
var i: integer;
  eventhandles: array [0..1] of THandle;
  wr: dword;
  contextsize: integer;
begin
   HandlerCS.enter; //block any other thread that has an single step exception untill this is handles

   //fill in the exception and context structures
   {$ifdef cpu64}
   VEHSharedMem.Exception64.ExceptionCode:=ExceptionInfo.ExceptionRecord.ExceptionCode;
   VEHSharedMem.Exception64.ExceptionFlags:=ExceptionInfo.ExceptionRecord.ExceptionFlags;
   VEHSharedMem.Exception64.ExceptionRecord:=DWORD64(ExceptionInfo.ExceptionRecord.ExceptionRecord);
   VEHSharedMem.Exception64.NumberParameters:=ExceptionInfo.ExceptionRecord.NumberParameters;
   for i:=0 to ExceptionInfo.ExceptionRecord.NumberParameters-1 do
     VEHSharedMem.Exception64.ExceptionInformation[i]:=ExceptionInfo.ExceptionRecord.ExceptionInformation[i];
   {$else}
   VEHSharedMem.Exception32.ExceptionCode:=ExceptionInfo.ExceptionRecord.ExceptionCode;
   VEHSharedMem.Exception32.ExceptionFlags:=ExceptionInfo.ExceptionRecord.ExceptionFlags;
   VEHSharedMem.Exception32.ExceptionRecord:=DWORD(ExceptionInfo.ExceptionRecord.ExceptionRecord);
   VEHSharedMem.Exception32.NumberParameters:=ExceptionInfo.ExceptionRecord.NumberParameters;
   for i:=0 to ExceptionInfo.ExceptionRecord.NumberParameters-1 do
     VEHSharedMem.Exception32.ExceptionInformation[i]:=ExceptionInfo.ExceptionRecord.ExceptionInformation[i];
   {$endif}

   //setup the context
   if ExceptionInfo.ContextRecord<>nil then
   begin
     contextsize:=sizeof(TContext);
     {$ifdef cpu32}
       //32-bit
       if (ExceptionInfo.ContextRecord.ContextFlags and CONTEXT_EXTENDED)=CONTEXT_EXTENDED then
         contextsize:=sizeof(TEContext);
     {$endif}

    // messagebox(0,pchar('Copying context:'+inttohex(ptruint(ExceptionInfo.ContextRecord),8)+':'+inttostr(contextsize)), 'InternalHandler', 0);

     CopyMemory(@VEHSharedMem.CurrentContext[0],ExceptionInfo.ContextRecord,contextsize);
   end
   else
     zeromemory(@VEHSharedMem.CurrentContext[0], sizeof(TEContext));

   VEHSharedMem.ProcessID:=GetCurrentProcessId;
   VEHSharedMem.ThreadID:=threadid;

   if SetEvent(VEHSharedMem.HasDebugEvent) then
   begin
     eventhandles[0]:=VEHSharedMem.HasHandledDebugEvent;
     eventhandles[1]:=emergency;

     wr:=WaitForMultipleObjects(2, @eventhandles, false, INFINITE);

     i:=wr -WAIT_OBJECT_0;
     if i=0 then //hashandleddebugevent has been set.  After ce is done with it use the new context
     begin
       if ExceptionInfo.ContextRecord<>nil then
       begin
         CopyMemory(ExceptionInfo.ContextRecord,@VEHSharedMem.CurrentContext[0],contextsize);

         if VEHSharedMem.ContinueMethod=DBG_CONTINUE then  //it got handled, set the debug registers (else don't touch them. DR6 might be needed)
         begin
           PContext(@VEHSharedMem.CurrentContext[0])^.ContextFlags:=CONTEXT_DEBUG_REGISTERS;  //only debug regs
           SetThreadContext(GetCurrentThread, PContext(@VEHSharedMem.CurrentContext[0])^);
         end;

       end;
     end
     else
     begin
       //MessageBox(0,'WaitForMultipleObjects failed', 'VEH Debug Error', MB_OK);
       result:=EXCEPTION_CONTINUE_EXECUTION; //something went wrong VEHSharedmem might even be broken
       HandlerCS.Leave;
       exit;
     end;

     //depending on user options either return EXCEPTION_CONTINUE_SEARCH or EXCEPTION_CONTINUE_EXECUTION
     if VEHSharedMem.ContinueMethod=DBG_CONTINUE then
       result:=EXCEPTION_CONTINUE_EXECUTION
     else
       result:=EXCEPTION_CONTINUE_SEARCH;

   end;
   //else
    // MessageBox(0,'SetEvent failed', 'VEH Debug Error', MB_OK);

   HandlerCS.Leave;

end;

是WaitForMultipleObjects?
2016-5-9 20:13
0
游客
登录 | 注册 方可回帖
返回
//