中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 06:56
47,811 topics / 349,897 posts / today 2 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » [Help]Problem with closing processes using ntsd?
Printable Version  2,291 / 19
Floor16 everest79 Posted 2008-10-29 11:46
金牌会员 Posts 1,127 Credits 2,564
The NTSD debugging program requires the user to specify a process to connect to when it starts. Using TLIST or PVIEWER, you can obtain the process ID of an existing process, and then type NTSD -p pid to debug this process. The NTSD command line uses the following syntax:

NTSD [options] imagefile

where imagefile is the name of the image to be debugged, and options is one of the following options:

Table 1. NTSD image file options

Option Description
-2 Open a new window for debugging a character-mode application
-d Redirect output to the debugging terminal
-g Make execution pass through the first breakpoint automatically
-G Make NTSD exit immediately when the subroutine terminates
o Enable debugging of multiple processes, the default is one process forked by the debugger
-p Specify the process to be debugged identified by the process ID
-v Generate detailed output


For example, suppose the process ID of inetinfo.exe is 104. Typing the following command connects the NTSD debugger to the inetinfo process (IIS).

NTSD -p 104

You can also use NTSD to start a new process for debugging. For example, NTSD notepad.exe will start a new notepad.exe process and establish a connection with it.

Once connected to a process, you can use various commands to view the stack, set breakpoints, dump memory, etc.

Table 2. Common commands

Command Meaning
~ Display a list of all threads
KB Display the stack trace of the current thread
~*KB Display the stack traces of all threads
R Display the register output of the current frame
U Disassemble the code and display the procedure name and offset
D[type][<range>] Dump memory
BP[#] <address> Set a breakpoint
BC[<bp>] Clear one or more breakpoints
BD[<bp>] Disable one or more breakpoints
BE[<bp>] Enable one or more breakpoints
BL[<bp>] List one or more breakpoints


Let's do an experiment.
For example, if the system process 1234 is notepad.exe, execute ntsd -p 1234 to open the debugging window.
Type q.
NTSD exits, and the associated process also exits.

The processes that NTSD cannot terminate are those that do not allow connection or discard such requests at all. Also, at least administrator is needed to have an 80% guarantee to end the process you selected. The system permission大概会有95%, heh heh.
NTSD is actually a debug program. Closing the process uses the fact that when NTSD exits, it will terminate the program associated with it.
Floor17 kgdetg1127 Posted 2008-10-29 15:22
初级用户 Posts 89 Credits 158
The batch processing uses the NTSD.EXE command. The problem is with the naming of your batch processing. It uses the "NTSD" word. Try naming it 1.bat.
Floor18 newsuper Posted 2008-10-29 19:47
新手上路 Posts 15 Credits 18
In order to be consistent with the owner of the post, I tested with the code on floor 6, just adding a statement to open Notepad. The result is the same as that of the HAT moderator.

Floor19 newsuper Posted 2008-10-29 19:50
新手上路 Posts 15 Credits 18
Originally posted by kgdetg1127 at 2008-10-29 15:22:
The batch file uses the NTSD.EXE command. The problem is with the name of your batch file. It contains the word "NTSD". Try naming it 1.bat.


I also have the same feeling about this problem. The other day I wrote a small thing with just one line: msg /w %username%. Hehe
Saved as msg.bat, but it couldn't run no matter what. Later, after changing the file name, it could run. Really need to pay attention.
Floor20 HAT Posted 2008-10-29 19:53
版主 Posts 5,017 Credits 9,023
To save forum space and speed up others' access, please do not use BMP format when uploading images. It is recommended to use PNG/JPG/GIF and other formats.
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023