Search code examples
systemwindbg

Switching the system does not work


I had the following situation: I'm in a live user mode debugging session and I wanted to show the win32k!_W32Process structure. Unfortunately, win32k is a kernel mode SYS file, so the symbols are not available in the user mode session.

I know that I can always load a DLL, EXE or SYS as a dump file and then inspect the symbols. Usually I would do that via File/Open Crash Dump.

This time, I wanted to show the participants of a debugging workshop that it's possible to debug multiple systems at the same time, so I opened the Win32K.sys via WinDbg's command prompt:

0:003> |
.  0    id: 10fc    attach  name: [...]\NetHeaps.exe

0:003> .opendump C:\Windows\winsxs\[...]\win32k.sys
Loading Dump File [C:\Windows\winsxs\[...]\win32k.sys]
Opened 'C:\Windows\winsxs\[...]\win32k.sys'

||0:0:003>

As we can now see, we have 2 systems and I'm currently on the live debugging system:

||0:0:003> ||
.  0 Live user mode: <Local>
   1 Image file: C:\Windows\winsxs\[...]\win32k.sys

I thought I could switch to the other system now, but that does not work:

||0:0:003> ||1s
              ^ Illegal debuggee error in '||1s'

I would not have worried too much, but it can't find the symbols of win32k in this case:

||0:0:003> .reload
Reloading current modules
...........................
||0:0:003> dt win32k!_W32Process
Symbol win32k!_W32Process not found.

Solution

  • The problem is not in the || command, it's in the .opendump command.

    The help says:

    After you use the .opendump command, you must use the g (Go) command to finish loading the dump file.

    Be aware that this will also run your live process. Therefore, freeze the threads first (~*f) and unfreeze later (~*u).

    After that you can switch the system and display the type:

    ||1:1:004> ||
       0 Live user mode: <Local>
    .  1 Image file: C:\Windows\winsxs\[...]\win32k.sys
    
    ||1:1:004> dt _W32Process
    win32k!_W32PROCESS
       +0x000 Process          : Ptr64 _EPROCESS
       +0x008 RefCount         : Uint4B
       +0x00c W32PF_Flags      : Uint4B
    [...]