<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Joomla! 1.5 - Open Source Content Management" -->
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Thread: Common WinDbg Commands (Thematically Grouped)</title>
        <description>Thinking debugging? Think www.windbg.info.</description>
        <link>http://windbg.info/</link>
        <lastBuildDate>Wed, 11 Mar 2026 01:12:03 +0100</lastBuildDate>
        <generator>Joomla! 1.5 - Open Source Content Management</generator>
        <language>en-gb</language>
        <item>
            <title>Re: break on driver load - question from kam</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/52-re-break-on-driver-load-question-from-kam.html</link>
            <author>Robert Kuster</author>
            <description>Kam,&lt;br /&gt;
&lt;br /&gt;
In general you don&amp;#039;t need symbols to know the entry point of a PE image. The entry point is conveniently stored to the PE header and can be read from it. Further the OS loader loads an image into memory (be it an EXE, DLL, or kernel mode driver) and calls its entry point thereafter. In other words by the time DriverEntry is called the driver will always be loaded. If all you need is break into WinDbg after a driver is loaded but before its entry point is called the situation is simple. And if you want to break even before the image is loaded into memory the situation is still simple enough. I described both scenarios bellow.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;1) TODOs - break after driver load &amp;amp; before its entry point is called&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
1) Break into WinDbg -&amp;gt; Debug (menu) -&amp;gt; Event Filters&lt;br /&gt;
2) In the &amp;quot;Event Filters&amp;quot; select the &amp;quot;&lt;b&gt;Load module&lt;/b&gt;&amp;quot; event&lt;br /&gt;
   &amp;gt; select &lt;b&gt;Execution -&amp;gt; Enabled&lt;/b&gt;&lt;br /&gt;
   &amp;gt; click &lt;b&gt;Arguments&lt;/b&gt; and enter the name of the driver in question (&lt;b&gt;77fba431&lt;/b&gt; in our case)&lt;br /&gt;
&lt;br /&gt;
 &lt;a href='http://windbg.info/images/fbfiles/images/event_filters.PNG' rel=&quot;lightbox&quot;&gt;&lt;img src='http://windbg.info/images/fbfiles/images/event_filters.PNG' style='max-width:585px; ' alt='' /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
With this settings WinDbg will brake after loading any driver with the name 77fba431 and &lt;u&gt;before calling its entry point&lt;/u&gt;. Here is what happens:&lt;br /&gt;
&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; .lastevent&lt;/b&gt;&lt;br /&gt;
Last event: Load module &lt;b&gt;77fba431.sys&lt;/b&gt; at &lt;span style='color: #0000FF'&gt;ba644000&lt;/span&gt;&lt;br /&gt;
  debugger time: Wed Mar 31 21:12:56.937 2010 (GMT+2)&lt;br /&gt;
&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; lm vm 77fba431&lt;/b&gt;&lt;br /&gt;
start    end        module name&lt;br /&gt;
&lt;span style='color: #0000FF'&gt;ba644000&lt;/span&gt; ba645e00   77fba431   (deferred)             &lt;br /&gt;
    Image path: 77fba431.sys&lt;br /&gt;
    Image name: 77fba431.sys&lt;br /&gt;
    Timestamp:        Tue Mar 30 20:10:51 2010 (4BB23EAB)&lt;br /&gt;
    CheckSum:         0000AD61&lt;br /&gt;
    ImageSize:        00001E00&lt;br /&gt;
    Translations:     0000.04b0 0000.04e4 0409.0&lt;span style='color: #0000FF'&gt;&lt;/span&gt;4b0 0409.04e4&lt;br /&gt;
&lt;br /&gt;
;get ImageEntry (== DriverEntry)&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; ? $iment( &lt;span style='color: #0000FF'&gt;ba644000&lt;/span&gt;)&lt;/b&gt;&lt;br /&gt;
Evaluate expression: -1167828646 = &lt;span style='color: #FF4040'&gt;ba64595a&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
;now that we have the DriverEntry address we can conveniently set a breakpoint on it&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; bp &lt;span style='color: #FF4040'&gt;ba64595a&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
*** ERROR: Module load completed but symbols could not be loaded for 77fba431.sys&lt;br /&gt;
&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; bl&lt;/b&gt;&lt;br /&gt;
 0 e &lt;span style='color: #FF4040'&gt;ba64595a&lt;/span&gt;     0001 (0001) 77fba431+0x195a&lt;br /&gt;
&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; g&lt;/b&gt;&lt;br /&gt;
Breakpoint 0 hit&lt;br /&gt;
77fba431+0x195a:&lt;br /&gt;
&lt;span style='color: #FF4040'&gt;ba64595a&lt;/span&gt; 8bff            mov     edi,edi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;2) TODOs - break before our driver is loaded into memory (XP SP 3)&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Behind the scenes a driver is loaded by &lt;b&gt;nt!IopLoadDriver&lt;/b&gt;. Its pseudo-code looks like this: &lt;br /&gt;
&lt;pre class='brush:cpp; gutter:false; toolbar:false;'&gt;nt!IopLoadDriver(&amp;nbsp;hRegKeyOfDriver,&amp;nbsp;...)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;get&amp;nbsp;full&amp;nbsp;path&amp;nbsp;of&amp;nbsp;our&amp;nbsp;driver
&amp;nbsp;&amp;nbsp;&amp;nbsp;UNICODE_STRING&amp;nbsp;driverPath&amp;nbsp;=&amp;nbsp;call&amp;nbsp;nt!IopBuildFullDriverPath(...);

&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;load&amp;nbsp;driver&amp;nbsp;into&amp;nbsp;memory
&amp;nbsp;&amp;nbsp;&amp;nbsp;call&amp;nbsp;nt!MmLoadSystemImage(&amp;nbsp;driverPath&amp;nbsp;,&amp;nbsp;...)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;

&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;retrieve&amp;nbsp;drivers&amp;nbsp;entry&amp;nbsp;point&amp;nbsp;and&amp;nbsp;call&amp;nbsp;it
&amp;nbsp;&amp;nbsp;&amp;nbsp;call&amp;nbsp;nt!RtlImageNtHeader
&amp;nbsp;&amp;nbsp;&amp;nbsp;call&amp;nbsp;nt!IopPrepareDriverLoading&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;call&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dword&amp;nbsp;ptr&amp;nbsp;[edi+2Ch]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;call&amp;nbsp;DriverEntry
}&lt;/pre&gt;&lt;br /&gt;
With this on mind we can use the following conditional breakpoint. It will cause WinDbg to break if the driver being loaded contains the name &amp;quot;77fba431&amp;quot; and continue execution in any other cases:&lt;br /&gt;
&lt;br /&gt;
&lt;span style='color: #FF0000'&gt;&lt;b&gt;bu nt!IopLoadDriver&lt;/b&gt; &amp;quot;.block {as /c HandleOutput &lt;b&gt;!handle poi(@esp+4)&lt;/b&gt;};  .block {.if ( $spat( \&amp;quot;${HandleOutput}\&amp;quot;, \&amp;quot;*&lt;b&gt;77fba431&lt;/b&gt;*\&amp;quot; ) ) { .echo ***** Loading our driver *****; ad *; } .else { ad *; g;}};&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Explanation:&lt;ul&gt;&lt;li&gt;!handle poi(@esp+4)    ...... get handle information and registry path of hRegKeyOfDriver; store it into HandleOutput (string alias)&lt;/li&gt;&lt;li&gt;$spat( &amp;quot;${HandleOutput}&amp;quot;, &amp;quot;*77fba431*&amp;quot; ) .... is 77fba431 found in HandleOutput? If yes break. If not go (g)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
I peeked into &lt;b&gt;nt!IopLoadDriver&lt;/b&gt; on Windows XP SP3. It might bee slightly different on Windows Vista or Windows 7 installations. Nevertheless I think you got the idea and will be able to change the breakpoint if necessary. You could set a similar conditional breakpoint on &lt;b&gt;nt!MmLoadSystemImage&lt;/b&gt;. Note that its first parameter is the path of the driver:&lt;br /&gt;
&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; kb&lt;/b&gt;&lt;br /&gt;
ChildEBP RetAddr  Args to Child              &lt;br /&gt;
ba507c74 8058107b &lt;span style='color: #008000'&gt;&lt;b&gt;ba507cf8&lt;/b&gt;&lt;/span&gt; 00000000 00000000 &lt;b&gt;nt!MmLoadSystemImage&lt;/b&gt;&lt;br /&gt;
ba507d54 80581487 80000748 00000001 00000000 nt!IopLoadDriver+0x371&lt;br /&gt;
ba507d7c 80538789 80000748 00000000 8a8e8640 nt!IopLoadUnloadDriver+0x45&lt;br /&gt;
ba507dac 805cff72 ae22acb0 00000000 00000000 nt!ExpWorkerThread+0xef&lt;br /&gt;
ba507ddc 8054611e 8053869a 00000001 00000000 nt!PspSystemThreadStartup+0x34&lt;br /&gt;
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16&lt;br /&gt;
&lt;br /&gt;
0: kd&amp;gt;&lt;b&gt; dS &lt;span style='color: #008000'&gt;ba507cf8&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
e10e69b8  &amp;quot;\??\C:\CpDrv\77fba431.sys&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope this helps,&lt;br /&gt;
Robert</description>
            <pubDate>Fri, 02 Apr 2010 21:15:09 +0200</pubDate>
        </item>
        <item>
            <title>windbg question</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/46-windbg-question.html</link>
            <author>kam</author>
            <description>Hi,&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s say that the driver I want to debug doesn&amp;#039;t have symbols, so I can&amp;#039;t use DriverEntry.&lt;br /&gt;
&lt;br /&gt;
!lmi 77fba431 (same problem: address not found (so name is interpreted as hex))&lt;br /&gt;
Also, the problem is that I would like to set a breakpoint before the driver is loaded. So I would need something like &amp;quot;bu driver+rva_ep&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Your method to retrieve base_address and the set a &amp;quot;bp&amp;quot; means that driver needs to be already loaded, right? so why would I set a bp on entry point then...&lt;br /&gt;
&lt;br /&gt;
The only method that works that I&amp;#039;ve found so far, is &amp;quot;bp&amp;quot; on a driver with symbols, walking up the stack and find the address of driver loading function, just before it&amp;#039;s calling drivers&amp;#039; EP, and breakpoint there. The problem is that this method will break on every driver that is going to be loaded...</description>
            <pubDate>Fri, 19 Feb 2010 21:36:31 +0100</pubDate>
        </item>
        <item>
            <title>Re: windbg question from kam</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/45-re-windbg-question-from-kam.html</link>
            <author>Robert Kuster</author>
            <description>Kam, hi.&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s assume that the entry point of your driver is called &lt;b&gt;DriverEntry&lt;/b&gt;. In this case setting a breakpoint is simple:&lt;br /&gt;
&amp;gt; &lt;b&gt;bp 77fba431!DriverEntry&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
And if you prefer to work with offsets you can easily get the base address of your driver too:&lt;br /&gt;
&amp;gt; &lt;b&gt;!lmi 77fba431&lt;/b&gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;gt; &lt;b&gt;lm vm 77fba431&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Both commands will return the base/start address of your driver in memory. Then you would do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; &lt;b&gt;bp BaseAddress (retrieved in previous step) + rva_entrypoint&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I hope this helps,&lt;br /&gt;
Robert</description>
            <pubDate>Thu, 18 Feb 2010 18:02:56 +0100</pubDate>
        </item>
        <item>
            <title>windbg question</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/44-windbg-question.html</link>
            <author>kam</author>
            <description>Hi,&lt;br /&gt;
This article is very nice, I&amp;#039;m a beginner to windbg and this is helping me a lot.&lt;br /&gt;
Also, I have a question:&lt;br /&gt;
Could you tell me please, how do I set a bp on a driver entrypoint if driver name is hex convertible?&lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
driver name is 77fba431.sys&lt;br /&gt;
so, normally I would do something like &amp;quot;bp 77fba431+rva_entrypoint&amp;quot; (just like lets say &amp;quot;bp ntfs+rva&amp;quot;)&lt;br /&gt;
but of course 77fba431 is read as an address, so windbg will actually set a bp to address 77fba431+rva_entrypoint. So, how can I tell windbg that 77fba431 is actually a module name not an address ?&lt;br /&gt;
&lt;br /&gt;
Thank you!</description>
            <pubDate>Fri, 12 Feb 2010 18:28:34 +0100</pubDate>
        </item>
        <item>
            <title>Re: Pattern matching</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/43-re-pattern-matching.html</link>
            <author>Robert Kuster</author>
            <description>Hey hey Adrian,&lt;br /&gt;
&lt;br /&gt;
Thanks for your feedback. I encountered similar problems with this breakpoint command. It turns out that here and then the aliases get messed up by WinDbg. You can easily check what is going on by the &amp;quot;&lt;b&gt;al&lt;/b&gt;&amp;quot; (alias list) or &amp;quot;&lt;b&gt;bl&lt;/b&gt;&amp;quot; (breakpoint list) commands. If you see some unusual values the following will help:&lt;br /&gt;
&lt;br /&gt;
a) &amp;quot;&lt;b&gt;ad *&lt;/b&gt;&amp;quot; == deletes all aliases&lt;br /&gt;
b) &lt;b&gt;Reset the breakpoint in question&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll try to find a more stable version for this breakpoint command and publish it later this year with the next &amp;quot;WinDbg Commands&amp;quot; update.&lt;br /&gt;
&lt;br /&gt;
Kind Regards,&lt;br /&gt;
RK</description>
            <pubDate>Thu, 14 May 2009 03:05:21 +0200</pubDate>
        </item>
        <item>
            <title>Pattern matching</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/42-pattern-matching.html</link>
            <author>adrian hodos</author>
            <description>First thank you for compiling this document , it is very good. I have a small problem though with pattern matching and conditional breakpoints. I have tried setting a conditional breakpoint on LoadLibraryExW like the examples in this document. The name of the dll I&amp;#039;m trying to match is protection_engine.dll , the pattern I use is *protect*. I&amp;#039;ve set the breakpoint like this: bu kernel32!LoadLibraryExW &amp;quot;;as /mu ${/v:MyAlias} poi(@esp+4); .if ( $spat( @&amp;quot;${MyAlias}&amp;quot;, &amp;quot;*protect*&amp;quot; ) != 0 ) { .echo ok - dll loaded; kP; } .else { g }&amp;quot;. However it only stops when it&amp;#039;s loading comctl32.dll so there must be something wrong in the syntax. Do you have any ideas ? I&amp;#039;ve been staring at it for quite some time but I can&amp;#039;t figure out where I&amp;#039;m doing wrong.</description>
            <pubDate>Tue, 12 May 2009 18:17:18 +0200</pubDate>
        </item>
        <item>
            <title>Common WinDbg Commands (Thematically Grouped)</title>
            <link>http://windbg.info/forum/8-cat-article-discussions/41-common-windbg-commands-thematically-grouped.html</link>
            <author>Robert Kuster</author>
            <description>** This thread discusses the content article: &lt;a href='/doc/1-common-cmds.html' rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Common WinDbg Commands (Thematically Grouped)&lt;/a&gt; **</description>
            <pubDate>Sun, 01 Feb 2009 01:00:00 +0100</pubDate>
        </item>
    </channel>
</rss>
