简单调试器框架
来源:互联网 发布:登机牌制作图片软件 编辑:程序博客网 时间:2024/06/10 05:14
// silent.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
char temp[100];
ZeroMemory(temp,100);
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if (argc<2)
return 1;
for ( int i=1;i<argc;i++)
{
strcat(temp,argv[i]);
strcat(temp," ");
}
printf("argv is %s/n",temp);
CreateProcess(NULL,temp,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
DWORD x=GetLastError();
DEBUG_EVENT DebugEv; // debugging event information
DWORD dwContinueStatus = DBG_CONTINUE; // exception continuation
// WaitForSingleObject(pi.hProcess,INFINITE);
Sleep(5000);
DebugActiveProcess(pi.dwProcessId);
#if 1
for(;;)
{
// Wait for a debugging event to occur. The second parameter indicates
// that the function does not return until a debugging event occurs.
WaitForDebugEvent(&DebugEv, INFINITE);
dwContinueStatus = DBG_CONTINUE;
// Process the debugging event code.
switch (DebugEv.dwDebugEventCode)
{
case EXCEPTION_DEBUG_EVENT:
// Process the exception code. When handling
// exceptions, remember to set the continuation
// status parameter (dwContinueStatus). This value
// is used by the ContinueDebugEvent function.
switch (DebugEv.u.Exception.ExceptionRecord.ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
// First chance: Pass this on to the system.
// Last chance: Display an appropriate error.
// printf("%d 0x%x Access Violation!/n",DebugEv.u.Exception.ExceptionRecord.ExceptionInformation[0],DebugEv.u.Exception.ExceptionRecord.ExceptionInformation[1]);
//这里行为????????
dwContinueStatus=DBG_EXCEPTION_NOT_HANDLED;
if(DebugEv.u.Exception.dwFirstChance==0 )
{
printf("%d 0x%x Access Violation!/n",DebugEv.u.Exception.ExceptionRecord.ExceptionInformation[0],DebugEv.u.Exception.ExceptionRecord.ExceptionInformation[1]);
exit(0);
}
break;
case EXCEPTION_BREAKPOINT:
// First chance: Display the current
// instruction and register values.
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
// First chance: Pass this on to the system.
// Last chance: Display an appropriate error.
break;
case EXCEPTION_SINGLE_STEP:
// First chance: Update the display of the
// current instruction and register values.
break;
case DBG_CONTROL_C:
// First chance: Pass this on to the system.
// Last chance: Display an appropriate error.
break;
default:
// Handle other exceptions.
break;
}
case CREATE_THREAD_DEBUG_EVENT:
// As needed, examine or change the thread's registers
// with the GetThreadContext and SetThreadContext functions;
// and suspend and resume thread execution with the
// SuspendThread and ResumeThread functions.
break;
case CREATE_PROCESS_DEBUG_EVENT:
// As needed, examine or change the registers of the
// process's initial thread with the GetThreadContext and
// SetThreadContext functions; read from and write to the
// process's virtual memory with the ReadProcessMemory and
// WriteProcessMemory functions; and suspend and resume
// thread execution with the SuspendThread and ResumeThread
// functions. Be sure to close the handle to the process image
// file with CloseHandle.
break;
case EXIT_THREAD_DEBUG_EVENT:
// Display the thread's exit code.
break;
case EXIT_PROCESS_DEBUG_EVENT:
// Display the process's exit code.
exit(0);
break;
case LOAD_DLL_DEBUG_EVENT:
// Read the debugging information included in the newly
// loaded DLL. Be sure to close the handle to the loaded DLL
// with CloseHandle.
break;
case UNLOAD_DLL_DEBUG_EVENT:
// Display a message that the DLL has been unloaded.
break;
case OUTPUT_DEBUG_STRING_EVENT:
// Display the output debugging string.
break;
}
// Resume executing the thread that reported the debugging event.
ContinueDebugEvent(DebugEv.dwProcessId, DebugEv.dwThreadId, dwContinueStatus);
}
#endif
return 0;
}
- 简单调试器框架
- 基本的调试器框架
- Python的调试框架bdb及调试器Pdb
- linux调试器的实现---主要框架
- gdb调试器打补丁的简单介绍
- 嵌入式调试器GDB简单功能介绍
- 嵌入式调试器GDB简单功能介绍
- GDB调试器的简单使用
- 框架已经调试OK
- 调试js框架
- Windows用户级调试器(debugger)编写框架
- 简单的调试代码
- 简单内存调试技术
- ollydbg简单调试体验
- 简单调试 python 程序
- 简单调试打印函数
- GDB调试简单例子
- GDB简单调试方法
- Kmdtut 10---注册表
- 美女登场
- Kmdtut 11---目录与文件
- SEH:结构化异常处理
- struts2学习笔记3-----输入校验
- 简单调试器框架
- 我还是与他分手
- 永远埋藏我的故事
- linux 安装
- 2008装B指南
- 纠缠在回忆里的感伤
- 关于启动U盘制作
- ORACLE跨数据库查询的方法
- Moblin开发者大会日程安排