Other commands that display process information include !handle, which dumps the process handle table (which is described in more detail in the section Object Handles and the Process Handle Table in Chapter 3). Process and thread security structures are described in Chapter 6.

Note that the output gives you the address of the PEB, which you can use with the !peb command shown in the next experiment to see the PEB of an arbitrary process. However, because the PEB is in the user-mode address space, it is valid only within the context of its own process. To look at the PEB of another process, you must first switch WinDbg to that process. You can do this with the .process command, followed by the EPROCESS pointer.

The PEB lives in the user-mode address space of the process it describes. It contains information needed by the image loader, the heap manager, and other Windows components that need to access it from user mode. The EPROCESS and KPROCESS structures are accessible only from kernel mode. The important fields of the PEB are illustrated in Figure 5-3 and are explained in more detail later in this chapter.

Figure 5-3. Fields of the process environment block

EXPERIMENT: Examining the PEB

You can dump the PEB structure with the !peb command in the kernel debugger, which displays the PEB of the process that owns the currently running thread on CPU 0. By using the information in the previous experiment, you can also use the PEB pointer as an argument to the command.lkd> !peb 7ffd9000 PEB at 7ffd9000 InheritedAddressSpace: No ReadImageFileExecOptions: No BeingDebugged: No ImageBaseAddress: 002a0000 Ldr 77895d00 ... WindowTitle: 'C:\Users\Alex Ionescu\Desktop\WinDbg.lnk' ImageFile: 'C:\Program Files\Debugging Tools for Windows\windbg.exe' CommandLine: '"C:\Program Files\Debugging Tools for Windows\windbg.exe" ' DllPath: 'C:\Program Files\Debugging Tools for Windows;C:\Windows\ system32;C:\Windows\system;C:\Windows Environment: 001850a8 ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\Alex Ionescu\AppData\Roaming ...

The CSR_PROCESS structure contains information about processes that is specific to the Windows subsystem (Csrss). As such, only Windows applications have a CSR_PROCESS structure associated with them (for example, Smss does not). Additionally, because each session has its own instance of the Windows subsystem, the CSR_PROCESS structures are maintained by the Csrss process within each individual session. The basic structure of the CSR_PROCESS is illustrated in Figure 5-4 and is explained in more detail later in this chapter.

Figure 5-4. Fields of the CSR process structure

EXPERIMENT: Examining the CSR_PROCESS

You can dump the CSR_PROCESS structure with the !dp command in the user-mode debugger while attached to the Csrss process of the session you want to inspect. Use the File, Attach To A Process option to get a list of processes, and select the Csrss process for the correct session. (You can see the session of the process by expanding the tree item for it.) Make sure to select the Noninvasive check box to avoid freezing your system.

The !dp command takes as input the PID of the process whose CSR_PROCESS structure should be dumped. Alternatively, the structure pointer can be given directly as an argument. Because !dp already performs a dt command internally, there is no need to use dt on your own.0:000> !dp v 0x1c0aa8-8 PCSR_PROCESS @ 001c0aa0: +0x000 ClientId : _CLIENT_ID +0x008 ListLink : _LIST_ENTRY [ 0x1d8618 - 0x1b1b10 ] +0x010 ThreadList : _LIST_ENTRY [ 0x1c0b80 - 0x1c7638 ] +0x018 NtSession : 0x001c0bb8 _CSR_NT_SESSION ... +0x054 Luid : _LUID +0x05c ServerDllPerProcessData : [1] (null) Threads: Thread 001c0b78, Process 001c0aa0, ClientId 198.19c, Flags 0, Ref Count 1 Thread 001c0e78, Process 001c0aa0, ClientId 198.1cc, Flags 0, Ref Count 1 ...

The W32PROCESS structure is the final system data structure associated with processes that we’ll look at. It contains all the information that the Windows graphics and window management code in the kernel (Win32k) needs to maintain state information about GUI processes (which were defined earlier as processes that have done at least one USER/GDI system call). The basic structure of the W32PROCESS is illustrated in Figure 5-5 and is explained in more detail later in this chapter.

Figure 5-5. Fields of the Win32k Process structure

EXPERIMENT: Examining the W32PROCESS

Перейти на страницу:

Похожие книги