ch10
ch10
Command-Line Commands
Reading from Memory
• dx addressToRead
• x can be
– da Displays as ASCII text
– du Displays as Unicode text
– dd Displays as 32-bit double words
• da 0x401020
– Shows the ASCII text starting at 0x401020
Editing Memory
• ex addressToWrite dataToWrite
• x can be
– ea Writes as ASCII text
– eu Writes as Unicode text
– ed Writes as 32-bit double words
Using Arithmetic Operators
• Usual arithmetic operators + - / *
• dwo reveals the value at a 32-bit location
pointer
• du dwo (esp+4)
– Shows the first argument for a function, as a wide
character string
Setting Breakpoints
• bp sets breakpoints
• You can specify an action to be performed
when the breakpoint is hit
• g tells it to resume running after the action
• bp GetProcAddress "da dwo(esp+8); g"
– Breaks when GetProcAddress is called, prints out
the second argument, and then continues
– The second argument is the function name
Listing Modules
• lm
– Lists all modules loaded into a process
• Including EXEs and DLLs in user space
• And the kernel drivers in kernel mode
– As close as WinDbg gets to a memory map
Microsoft Symbols
Symbols are Labels
• Including symbols lets you use
– MmCreateProcessAddressSpace
• instead of
– 0x8050f1a2
Searching for Symbols
• moduleName!symbolName
– Can be used anywhere an address is expected
• moduleName
– The EXE, DLL, or SYS filename (without extension)
• symbolName
– Name associated with the address
• ntoskrnl.exe is an exception, and is named nt
– Ex: u nt!NtCreateProcess
• Unassembles that function (disassembly)
Deferred Breakpoints
• bu newModule!exportedFunction
– Will set a breakpoint on exportedFunction as soon
as a module named newModule is loaded
• $iment
– Function that finds the entry point of a module
• bu $iment(driverName)
– Breaks on the entry point of the driver before any
of the driver's code runs
Searching with x
• You can search for functions or symbols using
wildcards
• x nt!*CreateProcess*
– Displays exported functions & internal functions
Listing Closest Symbol with ln
• Helps in figuring out where a call goes
• ln address
– First lines show two closest matches
– Last line shows exact match
Viewing Structure Information with
dt
• Link Ch 10a
Kernel Debugging in Practice
Kernel Mode and User Mode
Functions
• We'll examine a program that writes to files
from kernel space
– Kernel mode programs cannot call user-mode
functions like CreateFile and WriteFile
– Must use NtCreateFile and NtWriteFile
User-Space Code