【发布时间】:2012-03-13 15:43:51
【问题描述】:
任何帮助开始使用在C++/CLI Win32 debugger library for x86 找到的示例代码来监视进程异常。
我做的一些代码是:
使用系统; 使用调试库; 命名空间 DebugTeste01 { 课堂节目 { 静态无效主要(字符串 [] 参数) { DebugUtil.DebugActiveProcess(4932); DebugEvent de = new DebugEvent(); ThreadContext tc = new ThreadContext(); LDTEntry ldte = 新的 LDTEntry(); 做 { debug_evt = DebugUtil.WaitForDebugEvent(0xffffffff); de = (DebugEvent)debug_evt; 进程 proc = Process.GetProcessById(de.processId); 对象 meminfo = DebugUtil.GetMemoryInfo(proc.Handle); //... 对象 modinf = DebugUtil.GetModuleInfo(proc.Handle); //... 开关 (debug_evt.GetType().ToString()) { 案例“DebugLibrary.DebugEvent_CreateProcess”: { DebugEvent_CreateProcess decp = (DebugEvent_CreateProcess)debug_evt; //一些动作,日志记录等 } 休息; 案例“DebugLibrary.DebugEvent_LoadDll”: { DebugEvent_LoadDll 检测 = (DebugEvent_LoadDll)debug_evt; //一些动作,日志记录等 } 休息; 案例“DebugLibrary.DebugEvent_CreateThread”: { DebugEvent_CreateThread 检测 = (DebugEvent_CreateThread)debug_evt; //一些动作,日志记录等 } 休息; 案例“DebugLibrary.DebugEvent_ExitThread”: { DebugEvent_ExitThread 检测 = (DebugEvent_ExitThread)debug_evt; //一些动作,日志记录等 } 休息; 案例“DebugLibrary.DebugEvent_Exception”: { DebugEvent_Exception 检测 = (DebugEvent_Exception)debug_evt; 异常记录 exbp = dect.exceptionRecord; 开关 (exbp.GetType().ToString()) { 案例“断点”: { //一些动作,日志记录等 exbp = null; } 休息; 案例“访问违规”: { //一些动作,日志记录等 exbp = null; } 休息; //更多案例 } } 休息; 默认: { //一些动作,日志记录等 debug_evt = null; } 休息; } 尝试 { DebugUtil.ContinueDebugEvent(de.processId, de.threadId, false); } 抓住 { 休息; } } 而(真); } } }[编辑] 2012 年 3 月 14 日
好文章:Using the Windows Debugging API
[编辑] 2012 年 3 月 14 日
实施方面的改进。
现在,它具有最终应用程序的初始骨架构造。
【问题讨论】: