//用下面的代码来创建被调试程序,目标文件命名为a.exe
int main(int argc, char* argv[])
{
__asm
{
PUSHAD ;
INT 3 ;
PUSHAD ;
}
return 0;
}
//下面的代码来创建调试程序
#include "stdio.h"
#include "windows.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char szCommandLine[] = "a";
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = TRUE;
BOOL breturn= ::CreateProcess (
NULL,
szCommandLine,
NULL,
NULL,
FALSE,
DEBUG_ONLY_THIS_PROCESS||CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
if(!breturn)
{
::MessageBox(NULL,"CREATE ERROR","",0);
::ExitProcess(-1);
}
DEBUG_EVENT DE;
int i=0;
do
{
::WaitForDebugEvent(&DE,INFINITE);
switch(DE.dwDebugEventCode)
{
case EXCEPTION_DEBUG_EVENT:
switch(DE.u.Exception.ExceptionRecord.ExceptionCode)
{
case EXCEPTION_BREAKPOINT:
i++;
if(i==2)
::MessageBox(NULL,"EXCEPTION","",0);
break;
}
break;
case EXIT_PROCESS_DEBUG_EVENT:
::MessageBox(NULL,"EXIT","",0);
::ExitProcess(-1);
case CREATE_PROCESS_DEBUG_EVENT:
::MessageBox(NULL,"CREATED","",0);
break;
}
::ContinueDebugEvent(
pi.dwProcessId,
pi.dwThreadId,
DBG_EXCEPTION_NOT_HANDLED);
}
while(1);
return 0;
}
可是不知为什么总是会出现下面的提示
再就是我CreateProcess创建的进程为什么总是不显示控制台
路过的朋友帮我看看,先谢了
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)