-----------
Usage
-----------

disasm module <Function> <-blf>

Where module is a Windows PE File (exe, dll, ocx, sys, scr, etc)

<Function> is an optional argument specifying a single function to show the disassembly of. If you don't provide a function name, the contents of all sections marked as code or executable is shown

-blf are options that modify the disassembly output
b: Adds the raw code bytes alongside the instruction that it makes up
l: Adds the line number of the source file alongside the assembly (requires private symbols)
f: Adds the file name of the source file alongside the assembly  (requires private symbols)


There is no seperate option for file output. All output is via stdout, so redirect that if you need a file.

DbgEng has disassemblers for more than just x86, x64 and ia-64, though those are the most mature. Those architectures that have IMAGE_FILE_MACHINE_ values in WinNt.h are the viable options, excepting the SH3/4/5 and MIPS ones. As long as you have a PE file, disasm turns on the disassembler corresponding to the machine type in IMAGE_NT_HEADERS.FileHeader.

This is the list of viable architectures from my version of winnt.h. I've tested with some old Alpha files from ftp.microsoft.com, some IA-64 patches from support.microsoft.com, and things compiled with the old embedded VC compilers targeting ARM/Thumb etc and the disassemblers do work. 

#define IMAGE_FILE_MACHINE_I386              0x014c  // Intel 386.
#define IMAGE_FILE_MACHINE_ALPHA             0x0184  // Alpha_AXP
#define IMAGE_FILE_MACHINE_ARM               0x01c0  // ARM Little-Endian
#define IMAGE_FILE_MACHINE_THUMB             0x01c2
#define IMAGE_FILE_MACHINE_AM33              0x01d3
#define IMAGE_FILE_MACHINE_POWERPC           0x01F0  // IBM PowerPC Little-Endian
#define IMAGE_FILE_MACHINE_POWERPCFP         0x01f1
#define IMAGE_FILE_MACHINE_IA64              0x0200  // Intel 64
#define IMAGE_FILE_MACHINE_ALPHA64           0x0284  // ALPHA64
#define IMAGE_FILE_MACHINE_TRICORE           0x0520  // Infineon
#define IMAGE_FILE_MACHINE_CEF               0x0CEF
#define IMAGE_FILE_MACHINE_EBC               0x0EBC  // EFI Byte Code
#define IMAGE_FILE_MACHINE_AMD64             0x8664  // AMD64 (K8)

If you have a program like SysInternals DebugView, you can set the SYMSRV_DBGOUT and DBGHELP_DBGOUT environment variables equal to 1 to see the debug spew from those dlls, including symbol path used and which symbols were being used, etc.

-----------
Known deficiencies
-----------
Unlike IDA and similar, which produce listings like these when dealing with strings:
push    offset aHolemenu ; "HOLEMENU"
 or 
dd offset aOlepro32_dll ; "OLEPRO32.DLL"

The disassembly provided from dbgeng will be:
push [module!`string' (0032d438)]
 or 
dd module!`string' (0032d438)
There's no mention of what the actual string is :-(

---

XP SP2 is the lowest supported system. This is due to XP SP0/1 having a bug in WriteProcessMemory which makes it only work with executable memory, which disasm doesn't use.

---

If the _NT_SYMBOL_PATH environment variable isn't set, DisAsm will set it to:
srv*%temp%*http://msdl.microsoft.com/download/symbols
This downloads module information for Microsoft modules from their servers to your temp directory. If you don't have the environment variable set (it won't be unless you did it) and don't want to use this default, use NoSymDisasm.cmd rather than disasm.exe on the command line

---

This only applies when searching for a symbol:
The actual size of functions cannot reliably be determined due to this information not always being present in the symbol files. The less information that is available to DisAsm means the more unnecessary output for your request, because the nearest addressable symbol (which DisAsm uses to guess the size) will be further away than when symbols are available.

------------
I've got a bone to pick with you...
------------
Send all comments, errors, and findings of the secret message to adeyblue@airesoft.co.uk. Bear in mind though that she's a bit sweary...