Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 如何使用windbg调试子进程和父进程?_Debugging_Command_Windbg_Createprocess_Child Process - Fatal编程技术网

Debugging 如何使用windbg调试子进程和父进程?

Debugging 如何使用windbg调试子进程和父进程?,debugging,command,windbg,createprocess,child-process,Debugging,Command,Windbg,Createprocess,Child Process,我有一个程序使用CreateProcess函数创建子进程。调试时,我通过childdbg1进入子进程。但在执行子进程的整个步骤之后。它不会返回到父进程 当我使用.childdbg 1时 0:000>.childdbg 1 将调试由当前进程创建的进程 然后我用了2次g, 第一次,它加载了模块,并到达,位置下方 0:000>g . . . 1:002> 第二次,它再次加载了一些其他模块,并到达下面的位置 1:002>g . . . 2:005> 从这一点开始,我将开始调试我的子进程。它工作得

我有一个程序使用CreateProcess函数创建子进程。调试时,我通过childdbg1进入子进程。但在执行子进程的整个步骤之后。它不会返回到父进程

当我使用.childdbg 1时

0:000>.childdbg 1
将调试由当前进程创建的进程

然后我用了2次g, 第一次,它加载了模块,并到达,位置下方

0:000>g

.
.
.

1:002>

第二次,它再次加载了一些其他模块,并到达下面的位置

1:002>g

.
.
.

2:005>


从这一点开始,我将开始调试我的子进程。它工作得很好。运行子进程后,其直接执行父进程。那么,谁能给我一个调试命令,或者从第二个进程到第一个进程的命令。请,我需要调试级解决方案。不是来自我的代码。

您可以使用该命令验证当前附加到的进程。与在线程(~0s、~1s、~2s)之间切换类似,您可以使用etc在连接的进程之间切换。

。childdbg 1仅允许调试第一个子进程,而不允许调试孙子进程
在您的示例中,2.002是一个孙子
要调试它,然后返回到child,您需要在每一代上发出.childdbg 1

childdbg:\>dir /b
childdbg.cpp

childdbg:\>type childdbg.cpp
#include <stdio.h>
#include <windows.h>
int main (void)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
    if( !CreateProcess( NULL, "childdbg.exe", NULL, NULL, 
    FALSE,0,NULL,NULL,&si, &pi ) )
    {
        printf( "CreateProcess failed (%d).\n", GetLastError() );
        return 0;
    }
    WaitForSingleObject( pi.hProcess, INFINITE );
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    return 0;
}
childdbg:\>cl /Zi /nologo childdbg.cpp
childdbg.cpp

childdbg:\>dir /b *.exe
childdbg.exe

do not run the exe it will spawn zillion childs
use debugger and when done subvert flow to skip child creation


childdbg:\>cdb childdbg.exe

0:000> .childdbg 1
Processes created by the current process will be debugged
0:000> g

1:001> .childdbg 1
Processes created by the current process will be debugged
1:001> g

2:002> .childdbg 1
Processes created by the current process will be debugged
2:002> g

3:003> .childdbg 1
Processes created by the current process will be debugged
3:003> g

4:004> lsf childdbg.cpp
childdbg.cpp
4:004> bp childdbg!main
*** WARNING: Unable to verify checksum for childdbg.exe
4:004> g

Breakpoint 0 hit

childdbg!main:
00401010 55              push    ebp

4:004> ls 10
    10:     if( !CreateProcess( NULL, "childdbg.exe", NULL, NULL,
                FALSE,0,NULL,NULL,&si,&pi ) )
    11:     {
    12:         printf( "CreateProcess failed (%d).\n", GetLastError() );
    13:         return 0;
    14:     }
    15:     WaitForSingleObject( pi.hProcess, INFINITE );
    16:     CloseHandle( pi.hProcess );
    17:     CloseHandle( pi.hThread );
    18:     return 0;
    19: }
4:004> r eip = `:18`
WARNING: Line information loading disabled
4:004> .lines
Line number information will be loaded
4:004> r eip = `:18`
4:004> r
childdbg!main+0x8a:
0040109a 33c0            xor     eax,eax
4:004> g
4:004> g
3:003> g
2:002> g
1:001> g
0:000> g
       ^ No runnable debuggees error in 'g'
0:000> q
quit:
childdbg:\>
childdbg:\>dir/b
childdbg.cpp
childdbg:\>键入childdbg.cpp
#包括
#包括
内部主(空)
{
STARTUPINFO si;
处理信息;
零内存(&si,sizeof(si));
si.cb=sizeof(si);
零内存(&pi,sizeof(pi));
如果(!CreateProcess(NULL,“childdbg.exe”,NULL,NULL,
FALSE、0、NULL、NULL、si和pi))
{
printf(“CreateProcess失败(%d)。\n”,GetLastError());
返回0;
}
WaitForSingleObject(pi.hProcess,无限);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
返回0;
}
childdbg:\>cl/Zi/nologo childdbg.cpp
childdbg.cpp
childdbg:\>dir/b*.exe
childdbg.exe
不要运行exe,它将产生无数个孩子
使用调试器和Subversit流跳过子级创建
childdbg:\>cdb childdbg.exe
0:000>.childdbg 1
将调试由当前进程创建的进程
0:000>g
1:001>.childdbg 1
将调试由当前进程创建的进程
1:001>g
2:002>.childdbg 1
将调试由当前进程创建的进程
2:002>g
3:003>.childdbg 1
将调试由当前进程创建的进程
3:003>g
4:004>lsf childdbg.cpp
childdbg.cpp
4:004>bp childdbg!主要的
***警告:无法验证childdbg.exe的校验和
4:004>g
断点0命中
childdbg!主要内容:
00401010 55推式ebp
4:004>ls 10
10:如果(!CreateProcess(NULL,“childdbg.exe”,NULL,NULL,
FALSE、0、NULL、NULL、si和pi))
11:     {
12:printf(“CreateProcess失败(%d)。\n”,GetLastError());
13:返回0;
14:     }
15:WaitForSingleObject(pi.hProcess,无限);
16:CloseHandle(pi.hProcess);
17:CloseHandle(pi.hThread);
18:返回0;
19: }
4:004>r eip=`:18`
警告:线路信息加载已禁用
4:004>行
将加载行号信息
4:004>r eip=`:18`
4:004>r
childdbg!main+0x8a:
0040109a 33c0异或eax,eax
4:004>g
4:004>g
3:003>g
2:002>g
1:001>g
0:000>g
^“g”中没有可运行调试对象错误
0:000>q
退出:
childdbg:\>

Ok。它将进入父进程。在这里,我有一个疑问。若我从子进程切换到父进程,那个么子进程将完成其所有步骤,或者只是挂起该步骤?这救了我的命!如果可以的话,我想把这个答案投10票。