{"id":88,"date":"2006-11-17T07:00:00","date_gmt":"2006-11-17T12:00:00","guid":{"rendered":"http:\/\/www.nynaeve.net\/?p=88"},"modified":"2019-12-13T17:39:47","modified_gmt":"2019-12-13T22:39:47","slug":"you-can-open-a-pe-image-as-a-dump-file-with-windbg","status":"publish","type":"post","link":"http:\/\/www.nynaeve.net\/?p=88","title":{"rendered":"You can open a PE image as a dump file with WinDbg"},"content":{"rendered":"<p>There is a little known feature of WinDbg, ntsd, cdb, kd, and anything else that uses DbgEng to open dump files.<\/p>\n<p>It turns out that with anything powered by DbgEng, anywhere where you could open a dump file (user dump, kernel dump, etc), you can instead open a PE image (.exe\/.dll\/.sys\/etc) and have the debugger treat it as a dump containing just the contents of the selected PE image.<\/p>\n<p>This is actually a relatively useful feature.  When you open a PE image as a dump file, the debugger maps it as an image as if it were loaded in-memory as executable code (though it doesn&#8217;t actually run any code, just maps it as if it were an executable and not a data file).  This gets you an in-memory representation of your exe\/dll\/sys\/other PE file as if you were debugging a live process (or a dump) that had the image in question loaded.<\/p>\n<p>Like a dump debugging session, this is essentially a read-only session; you can&#8217;t really modify anything, as there is no target to control.  Additionally, there is no real register context either (or stack or heap), although things like initialized and zero filled global variables and executable code belonging to the module will be in-memory.  (The preferred image base for the module is used in this situation for basing the requested PE module in the virtual address space constructed for the debugging session.)<\/p>\n<p>After you have loaded the target, you can do anything that you would normally do with a dump for the most part, as far as examining symbols and disassembling the target go.  If you need a disassembler with symbol support and can&#8217;t start a process or whatnot to contain a PE image, this particular trick is a great quick-n-dirty replacement for a more full-featured disassembler program.<\/p>\n<p>Note that a side effect of opening a PE image in dump mode is that <a title=\"Checking if a binary exists on a symbol repository\" href=\"?p=22\">the symbol server is used to retrieve the binary<\/a> (which might seem a bit strange, until you consider that for dump files, the normal case is that you don&#8217;t have the entire binary saved in memory; just enough header information to retrieve the binary from the symbol server).  Therefore, make sure that your symbol path is setup correctly before trying this particular trick.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a little known feature of WinDbg, ntsd, cdb, kd, and anything else that uses DbgEng to open dump files. It turns out that with anything powered by DbgEng, anywhere where you could open a dump file (user dump, kernel dump, etc), you can instead open a PE image (.exe\/.dll\/.sys\/etc) and have the debugger [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=\/wp\/v2\/posts\/88"}],"collection":[{"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":1,"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":634,"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions\/634"}],"wp:attachment":[{"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nynaeve.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}