Using VSI
Using VSI
Visual SoftICE
TM
Release 1.3.0
Windows NT®
Windows® 2000
Windows® XP
Technical support is available from our Technical Support Hotline or via
our FrontLine Support Web site.
This document and the product referenced in it are subject to the following
legends:
Doc. 11581
May 19, 2003
Table of Contents
Preface
Purpose of This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Organization of This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
How to Use This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Other Useful Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Customer Assistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
For Non-Technical Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
For Technical Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Chapter 1
Choosing Your SoftICE Version
SoftICE or Visual SoftICE? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Single Machine Debugging: SoftICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Dual Machine Debugging: Visual SoftICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Which One Should I Use? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Visual SoftICE Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
About Visual SoftICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Chapter 2
Visual SoftICE Target Transport Configuration
Visual SoftICE Target Transport Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Serial Target Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Requirements and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Dedicated PCI Ethernet Network Interface Card (NIC) . . . . . . . . . . . . . . . . . . . . . . . 9
Requirements and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
iii
Universal PCI Ethernet NIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Requirements and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
OHCI/UHCI USB Host Controller and USB NIC . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Requirements and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Virtual NIC Driver (optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Requirements and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1394 (Firewire) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Requirements and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Chapter 3
Overview of the Visual SoftICE User Interface
The Visual SoftICE User Interface Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Visual SoftICE Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
About the Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
About the Context Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Page Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
User Interface Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Global Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Per-Workspace Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Keyboard Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Toolbars & Status Bar Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Fonts & Colors Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Other User Interface Attributes and Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Workspace Save and Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Special Command Page Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Cut, Copy, and Paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Drag and Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Saving Contents to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Print and Print Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Script Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Chapter 4
The Visual SoftICE User Interface Pages
The Command Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Concepts and Associated Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Page Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
The Stack Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Concepts and Associated Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Page Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
The Registers Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Concepts and Associated Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Chapter 5
Visual SoftICE Symbol Management
Visual SoftICE Symbol Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Where to Put the Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
What Symbols are Supported . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Images — Why you need access to them . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Local Copies of Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Tables – Active Table, Loading, and Unloading Commands . . . . . . . . . . . . . 109
Automatic, On-Demand Loading and Unloading . . . . . . . . . . . . . . . . . . . . . . 111
Pre-Loading/Persistent Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Table of Contents v
Integrated MS Symbol Server Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Using Exports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Symbols — Getting Setup in Visual SoftICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Setting Up General Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Setting Up Visual SoftICE Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Settings Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Per-Workspace Settings Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Toolbars & Status Bar Settings Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Chapter 6
Using Breakpoints
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Types of Breakpoints Supported by Visual SoftICE . . . . . . . . . . . . . . . . . . . . . . . . 118
Breakpoint Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Execution Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Memory Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Interrupt Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
I/O Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Image Load Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Window Message Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Understanding Breakpoint Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Image-Relative Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Fixed Address Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Virtual Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Setting a Breakpoint Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Conditional Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Conditional Breakpoint Count Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Using Local Variables in Conditional Expressions . . . . . . . . . . . . . . . . . . . . . 129
Referencing the Stack in Conditional Breakpoints . . . . . . . . . . . . . . . . . . . . . 130
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Duplicate Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Elapsed Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Breakpoint Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Referring to Breakpoints in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Manipulating Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Using Embedded Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Chapter 8
Exploring Windows NT
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Resources for Advanced Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Inside the Windows Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Managing the Intel x86 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Windows NT System Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Win32 Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Inside CSRSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
USER and GDI Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Process Address Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Heap API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Appendix A
Troubleshooting Visual SoftICE
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Audience
This manual is intended for programmers who want to use Visual SoftICE
to debug code for Windows NT/2000/XP platforms running on either 32-
or 64-bit processors.
ix
Organization of This Manual
The Using Visual SoftICE manual is organized as follows:
⽧ Chapter 1, “Choosing Your Visual SoftICE Version”
Helps you decide which version of Visual SoftICE, Visual SoftICE or
Classic Visual SoftICE, is best suited for a given debugging scenerio. It
also gives an overview of the Visual SoftICE product, and highlights
the many new and useful features.
⽧ Chapter 2, “Visual SoftICE Target Transport Configuration”
Provides an overview of the many available transports, and compares
the benefits of each.
⽧ Chapter 3, “Overview of the Visual SoftICE User Interface”
Explains the GUI for Visual SoftICE, including the meaning of
various icons and available menu options. This chapter also discusses
how to use the Visual SoftICE configuration settings to customize
your environment, pre-load symbols and exports, connect to a target,
modify keyboard mappings, create macro-definitions, and set
troubleshooting options.
⽧ Chapter 4, “The Visual SoftICE User Interface Pages”
Explains the GUI pages available for Visual SoftICE, including the
functionality and related commands for each.
⽧ Chapter 5, “Visual SoftICE Symbol Management”
Explains how to manage symbols in Visual SoftICE, including
dynamically and persistently loaded symbols, MS Symbol Server
setup, and path configuration.
⽧ Chapter 6, “Using Breakpoints”
Explains how to set breakpoints on program execution, on memory
location reads and writes, on interrupts, and on reads and writes to
the I/O ports.
⽧ Chapter 7, “Using Expressions”
Explains how to form expressions to evaluate breakpoints. This
concept differs between Visual SoftICE versions, so pay particular
attention to this chapter if you are not familiar with Visual SoftICE.
⽧ Chapter 8, “Exploring Windows NT and XP”
Provides a quick overview of the Windows NT/2000/XP operating
systems.
⽧ Appendix A, “Troubleshooting Visual SoftICE”
Explains how to solve typical problems you might encounter.
Typographical Conventions
The following conventions are used consistently throughout this manual
to identify certain types of information:
Convention Description
Enter Indicates that you should type text, then press RETURN or
click OK.
italics Indicates variable information. For example: library-name.
monospaced text Used within instructions and code examples to indicate char-
acters you type on your keyboard. Also indicates directory
names, and file names.
small caps Indicates a user-interface element, such as a button or menu.
UPPERCASE Indicates key words and acronyms.
Preface xi
Other Useful Documentation
In addition to this manual, Compuware provides the following
documentation for Visual SoftICE:
⽧ Visual SoftICE Command Reference
Describes all the Visual SoftICE commands in alphabetical order.
Each description provides the appropriate syntax and output for the
command as well as examples that highlight how to use it.
⽧ Visual SoftICE on-line Help
Visual SoftICE provides context-sensitive and topic-oriented HTML
help as well as command line help for Visual SoftICE commands in
the Command page.
⽧ On-line documentation
Both the Using Visual SoftICE manual and the Visual SoftICE
Command Reference are available as PDF. To access the PDF version of
these books, start Acrobat Reader and open the Using Visual SoftICE or
the Visual SoftICE Command Reference PDF files.
Customer Assistance
Preface xiii
xiv Using Visual SoftICE
Chapter 1
Choosing Your SoftICE Version
1
Table 1-1. Supported Platforms (Continued)
7
Figure 2-1. Transport Overview
For more information and tips on configuring your transports, refer to
the Transport Configuration help.
Figure 2-4. Universal PCI Ethernet NIC and Optional Virtual NIC
1394 (Firewire)
We use IP over 1394 as a protocol between the master and a target, thus
the target machine appears to be on the IP network. This debug transport
solution is not shared, and once you install our driver for the 1394 host
controller you cannot use it for additional 1394 devices.
15
Visual SoftICE Icons
Visual SoftICE makes use of many different icons within the GUI to
identify such things as breakpoints (type and state), target state, and
current context (target IP and UI context). The following sections will
help you identify the various icons and their meanings.
Breakpoints
The following icons are used within various pages to indicate the
different breakpoint types and states.
Table 3-1. Breakpoint Icons
Icon Description
This icon represents a Fixed Address breakpoint that has been hit.
This icon represents a Fixed Address breakpoint that has not been hit.
This icon represents an Image Relative breakpoint that has been hit.
This icon represents an Image Relative breakpoint that has not been
hit.
This icon represents an I/O breakpoint that has not been hit.
Icon Description
Icon Description
This icon indicates the line you are on when you do a Goto in the
Source or Disassembly page.
This icon indicates the Current Target IP location, and that the next
step will move it downward (forward or increasing) into memory.
This icon indicates the Current Target IP location, and that the next
step will move it downward into memory, at the time when a
Snapshot of the information was taken.
This icon indicates the Current Target IP location, and that the next
step will move it upward (backward or decreasing) into memory.
This icon indicates the Current Target IP location, and that the next
step will move it upward into memory, at the time when a Snapshot
of the information was taken.
This icon indicates the line where the Current IP will be upon
executing the next instruction. Displayed when the Current IP and
the next IP locations are available in the same screen (Source or
Disassembly pages).
Icon Description
This icon indicates that searching for symbols via symbol servers is
enabled (See SET SYMSRVSEARCH in the Visual SoftICE Command
Reference).
This icon indicates that searching for symbols via symbol servers is
disabled (See SET SYMSRVSEARCH in the Visual SoftICE Command
Reference).
This icon indicates that all tables loaded without warnings (See
TABLE in the Visual SoftICE Command Reference).
This icon indicates that at least one table loaded with a warning
condition (See TABLE in the Visual SoftICE Command Reference).
This icon indicates that at least one table was not loaded (See TABLE
in the Visual SoftICE Command Reference).
Icon Description
This icon indicates that symbols are loaded for the indicated image,
and that the source file is part of that image and has line information
available.
This icon indicates that symbols are loaded for the indicated image,
and that the source file is part of that image, but there is no line
information available.
This icon indicates that the source file is not part of any image in the
current/active process.
Cursor Types
The following icons are used to indicate various states of the cursor.
Table 3-6. Cursor Icons
Icon Description
This icon indicates you have selected a single item and are dragging
it from a page.
This icon indicates you have selected multiple items and are
dragging them from a page.
This icon indicates the cursor is over a window that does not allow
dropping of the data you are dragging.
This icon indicates the cursor is over a window that allows dropping
the single item being dragged into it.
This icon indicates the cursor is over a window that allows dropping
the multiple items being dragged into it.
Icon Description
This icon indicates the cursor is over the breakpoint column, on the
Source or Disassembly page.
Control Description
Process Displays the Process ID and Name. You can use this control to select a new process from
the drop-down list of available processes. This is equivalent to changing the current
process from the Process List page or via the ADDR command.
Thread Displays the Thread ID. You can use this control to select a new thread from the drop-
down list of available threads, if the current process is multi-threaded. This control is the
most convenient way to change threads within a multi-threaded process.
Context Displays the current Stack Frame, including any symbolic representation of the frame
instruction pointer. You can use this control to select a new stack frame from the drop-
down list of available stack frames. This control is the most convenient way to change the
current stack frame.
Reset to Stopped Switches you back to the context that was current when you stopped the target. This
Context Button button is located on the main context bar, and becomes active when you stop the target,
and switch contexts. Clicking the button does not restart the target.
Page Modes
Mode Description
Live Events from the target cause the page to refresh automatically.
Manual You decide when the page should be refreshed (menu(s) > Refresh).
SnapShot The page is protecting its current contents from over-write. You must
elect to destroy the data. Changes to the data, and actions against the
target, are not allowed in this mode.
Some pages do not support all the modes, as is appropriate for their
function, (for example the Command Page only supports Live mode).
Global Settings
Global Settings are global to the executable, and do not change with
different workspaces.
Per-Workspace Settings
Per-Workspace settings are provided for users who wish to use different
workspaces for different debugging conditions, targets, or target types.
The properties you set here are specific to the current workspace.
Available per-workspace settings fall into two categories: Paths and
Scripts.
Paths
The Paths element in the Per-Workspace Settings tab allows you to define
specific paths to prepend or override the global path settings. These
paths, along with the global settings they prepend or replace, define the
Visual SoftICE configuration. The current configuration can be seen by
issuing the SET commmand.
Move Entry
Path Type Up Button
Move Entry
Down Button
Path List
Scripts
The Scripts element in the Per-Workspace Settings tab allows you to
associate scripts with certain events in Visual SoftICE. If you click on a
script type, a description of that event association and any other rules on
data entry (if applicable) are displayed in the Setting Explanation
window below the list.
Keyboard Settings
DriverStudio allows you to create custom keyboard definitions, or edit
existing keyboard definitions, and save them in your workspace file.
DriverStudio components that work within the DriverWorkbench
environment provide default keyboard definitions on a workspace level
and sometimes on a page component level. You cannot edit default
definitions; however, you can override them by adding your own custom
keyboard definitions for the same keystroke. Table 3-10 on page 31
provides the definitions that are global to the DriverWorkbench
environment, which you cannot override.
Keystroke Description
Customizing Toolbars
You can configure which of the toolbars or page-access icons you want to
display, and you can add further options to the user-defined area of the
Pages toolbar. The Toolbars & Status Bar tab is composed of a left-side
Toolbars Shown column displaying a list of available toolbar types, a
central Pages Toolbar column displaying a list of available page icons,
and a right-side column for customizing the status bar. At the bottom of
the central column is a User Defined Buttons button that opens the
Customize Page Plugin Toolbar utility.
Setting Description
Query to save workspace changes? This option causes DriverStudio to ask you if
you want to save the workspace, as a
reminder, if you have made changes.
Command Comments
The input dialects support a line comment style (as opposed to block
style comments). Each dialect can have its own syntax; but, to date, all
supported command dialects use the C++ form:
// This entire line is a comment – useful in scripts
proc // Command displays all currently running processes
Page Name
Script Execution
You can configure Visual SoftICE to use scripts you have written upon
the triggering of certain events, such as opening a workspace or
connecting to a target. You configure scripts via the Scripts item in the
Per-Workspace Settings tab under Preferences.
To configure Visual SoftICE to use a script, you need to define the path
and script file name in the field corresponding to the trigger event for the
script, and activate the event by checking its check-box. You can define
scripts for the trigger events listed in Table 3-13.
Table 3-13. Script Trigger Events
Auto Copy Script Execute a script when the target boots and requests file
updates.
45
Figure 4-1. Visual SoftICE Command Page
Redirecting Output
The command page supports command redirection of its output either
automatically or explicitly to a particular page.
⽧ Automatic Redirection - allows you to toggle the automatic
redirection of the command output to other pages, whether they are
Command pages or other page types.
⽧ Explicit Redirection - allows you to redirect the output of a
particular command to the specified page or page type.
Message Output
The Command page supports displaying event messages from the target.
If the Message Level setting is set to on or verbose, then messages from
the target will be displayed in the output window. For more information
on controlling the display of messages in Visual SoftICE, refer to the SET
MSGLEVEL command.
Output Formatting
You can configure the Command page output format by modifying the
following attributes:
⽧ Modify the radix of data for input and output by using the SET
RADIX command.
⽧ Modify the uppercase hex disassembly output by using the SET
UPPERCASE command.
⽧ Modify the way Visual SoftICE displays 64-bit addresses by using the
SET ADDRESSFORMAT command.
⽧ Modify the mnemonics used for register names by using the SET
REGNAME command.
⽧ Enable or disable the formatting of FP registers by using the SET
FLOATREGFORMAT command.
⽧ Modify the format of the PACKET command by using the SET
PACKETFORMAT command.
Page Features
Finding Text
The Command page provides a way for you to search for a text string
value within the page.
⽧ You can search by trying to match the whole word only, or by finding
the best match for a partial string.
⽧ You can search by trying to match the case of the specified search
string.
Print
The page supports printing, and print-previewing of its contents.
Context
Bar
Current IP
Breakpoint
Frames
The stack page displays a list of items called frames. The frames are listed
from the current frame to starting frame of the thread when data is
available. The stack page will display the following information for each
frame: frame number, current context, instruction address, stack address,
and frame address.
⽧ Frame numbers are listed from the current frame to top-most frame
of the thread. Each time a new function is called, Visual SoftICE
renumbers the frame accordingly.
⽧ Current context displays the function name plus the byte offset from
the start of the function of to the instruction address for that frame.
If no symbols are available for the frame’s function address, then the
field will be blank. Refer to the SET SYMPATH command for more
information on finding symbols.
Page Features
Context Bar
The Stack page has a page-specific context bar allowing you to select the
context (process and thread) for which the Stack page displays stack
frames. This page-specific context bar overrides the main context bar and
allows the Stack page to track an independent context.
You can switch to a different context to display its stack frames. Use the
Process drop-down list to select the process, and the Thread drop-down
list to select a specific thread for that process (if the process is multi-
threaded).
View Memory At
The stack page supports displaying a Memory page for a selected
instruction, stack, or frame address. To display a Memory page, right-
click on an address and select View Memory At.
Breakpoints
The stack page supports the setting, enabling, disabling, or clearing of
breakpoints at the instruction address for the selected stack frame. To
complete any of these breakpoint operations from the Stack page, right-
click on a frame, select Breakpoint and then the desired operation (Set,
Enable, Disable, or Clear).
⽧ You can set a breakpoint for an instruction address of a frame by
issuing the BPX command and the address at the command line.
⽧ You can enable, disable, or clear a breakpoint for an instruction
address of a frame from the command line by issuing a BL command
to get the breakpoint index, and using the BE, BD, or BC command
along with that index.
Copy
The page only supports the Copy function to retrieve its data. You can
select any cell (intersection of a row and column) and copy its text to the
clipboard.
Note: Select a cell by by placing the mouse cursor on the cell and then
right-clicking on the element you wish to copy.
Print
The page supports printing, and print-previewing of its contents.
Register Name
Register List
Types
Different processors contain different registers and register types.
Registers are always bit containers, but can be interpreted as bytes,
integers, a collection of flags, or floating point values meeting various
standard representations and precisions.
Descriptions
Registers all have additional description information, primarily drawn
from details provided by the processor manufacturer, and in some cases
as commonly used by operating systems.
⽧ You can view descriptions for any register in the details status bar at
the bottom of the page (if the register does not currently map to a
symbol).
⽧ You can display register descriptions from the command line by
issuing the R command with the -d switch.
Symbols
Registers can contain data that currently maps to a known symbol in the
current context.
⽧ If a symbol is available for the current register contents, the symbol is
displayed in the details status bar at the bottom of the page.
⽧ You can display symbols for registers from the command line by
issuing the R command with the -s switch.
Allowed Operations
Some registers are read-only, except by the processor itself. Some registers
are not available, based on the state of the processor. Modifying some
registers can be a dangerous action. As a level of protection, registers are
marked in Visual SoftICE as being read-write, or read-only, and can have
associated warnings on write operations.
For more information on controlling the display of warnings in Visual
SoftICE, refer to the SET WARNLEVEL command.
Page Features
Process
Names
Active
Process
Current IP
Current Context
You can use the Process List page to make a process the “current” one.
You can ALWAYS make a process current, and that becomes the current
context for Visual SoftICE. Refer to “About the Context Bar” on page 22
for more information on the main context bar, and page-specific
contexts.
Images
You can use the Process List page to view the images for a selected
process. This works the same as the IMAGE command. To view the
images for a process, right-click on the process, and select Images from
the pop-up menu.
Page Features
Print
The page supports printing, and print-previewing of its contents.
Address Types
You can access memory on the target machine via its physical location
(the location on the memory bus where the memory unit of interest is
located), or via virtual address per process (as implemented by the OS).
Access to memory on the target can fail if one of the following situations
is true:
⽧ The virtual address requested is paged out
⽧ The virtual address is unmapped (invalid) in the current process
⽧ The memory is inaccessible based on processor state
Virtual memory access is the most common form of memory access, and
is connected with static and dynamic allocations for a given process or
the kernel itself.
Physical memory access is useful for looking at I/O registers, video
memory, or other regions physically mapped (memory mapped) by the
processor. This means the memory of these devices appears to be part of
the standard address space of the processor.
Symbols
All addresses may have a symbolic representation. Visual SoftICE
automatically updates and displays the symbolic representation on the
current address title bar as you move the caret through various memory
locations. You can disable symbolic lookup (for performance
improvements) for all memory pages via the global setting (Symbolic
Address Lookup) under the Memory page preferences
(File > Preferences > Global Settings > Memory Page).
Page Features
Edit Memory
This page provides several ways of editing memory data, both in scalar
and custom formatting.
⽧ In scalar modes, you can double-click or select a unit of memory and
press Enter, or the Backspace key, to get an in-place edit control. You
can cancel editing by pressing the Esc key, or you can apply any
changes by pressing Enter. If your edit fails to be accepted, the
Memory page displays an error message. If accepted, the Memory
page updates all panes displaying that memory location, using the
modified color to highlight the change.
WL
The WL command opens the Locals page. If a Locals page is already
open, WL activates that page.
Page Features
Select a Context
Visual SoftICE allows you to select a different stack frame, or context,
whose variables you wish to display. To switch contexts for the current
thread, click the Context combo-box to access the drop-down list of
available stack frames for the current thread, and select the stack frame
you want to change to. Visual SoftICE displays the variables for the
selected context.
Select a Thread
Visual SoftICE allows you to select a different thread whose variables you
wish to display. To select a different thread, click the Thread combo-box
to access the drop-down list of available threads for the current process,
and select the thread you want to change to. Visual SoftICE
automatically updates the stack frames for the selected thread, and
displays the latest variables for the first stack frame.
Print
The page supports printing, and print-previewing of its contents.
WATCH
Use the WATCH command to display the results of expressions.
Page Features
Save Expressions
When you have a workspace file opened, Visual SoftICE will store all the
expressions on the Watch page in your workspace file, when saved.
Modify Expressions
Visual SoftICE allows you to modify expressions directly on the Watch
page. Visual SoftICE re-evaluates the expressions and displays the new
result types and values in each column. To modify an expression, double-
click the Name column of the expression you want to modify, and enter
the new expression name in the Name field. Press <Enter> or click
anyplace on the Watch page to save the value.
Print
The page supports printing, and print-previewing of its contents.
Breakpoint Types
Visual SoftICE supports the following types of breakpoints:
⽧ Code Execution
⽧ Interrupt
⽧ Memory Location Access
⽧ I/O
⽧ Memory Range Access
⽧ Image Load
⽧ HWND and OS Application Message
⽧ Deferred or Virtual
Use the New Breakpoint utility to set any of the breakpoints.
Global Break
You can configure Visual SoftICE to break upon loading image files by
using the SET GLOBALBREAK command.
Page Features
Print
The page supports printing, and print-previewing of its contents.
Filtering Messages
The Debug Message page supports the filtering of messages output to the
page. Message filtering is controlled by the Debug Message Filter utility,
which is available by right clicking on the page and selecting Configure
Filtering from the pop-up menu.
Copy
The page only supports copy command to retrieve its data.
⽧ You can select any text within the page and copy it to the clipboard.
⽧ You can use Select All from the pop-up menu to highlight all the
lines on the page before copying them to the clipboard.
Print
The page supports printing, and print-previewing of its contents.
Page Features
Configuring Filtering
The Event page supports the filtering of events output to the page. Event
filtering is controlled by the Target Event Display Filter utility, which is
available by right clicking on the page and selecting Configure Filtering
from the pop-up menu.
Print
The page supports printing, and print-previewing of its contents.
Command Redirection
The page supports command redirection from a command page. This
allows output (such as from a kd extension, or a script file) to be captured
and saved. Refer to Command Redirection in the main help file for more
information.
Page Features
Find Text
The Text Scratch page provides a utility for finding a text string value
within the page.
⽧ You can search by attempting to match the whole word, only or
partial string.
⽧ You can further narrow a search by attempting to match the case of
the specified search string.
Go To a Specific Line
You can right-click on the Text Scratch page and select Go To Line from
the pop-up menu to advance the cursor to any line of text currently
contained in the Text Scratch page.
Append a File
You can right-click on the Text Scratch page and select File Append from
the pop-up menu to append the contents of any text file to the Text
Scratch page contents.
View Bookmarks
You can right-click on the Text Scratch page and select View Bookmarks
from the pop-up menu to display the bookmarks that may be set for the
lines of text currently contained in the Text Scratch page.
Print
The page supports printing, and print-previewing of its contents.
Associated Commands
T
The T command steps one instruction when the target is stopped. Visual
SoftICE searches through the symbols to locate a file containing the
current instruction pointer (IP). If it finds the file, and a source page for
that file is already available, Visual SoftICE updates the existing source
page. If it finds the file and no source page for that file is open, Visual
SoftICE creates a new source page.
If Visual SoftICE does not find a source file containing the current IP, and
a live disassembly page for the current IP is available, it updates that
page. If no live disassembly page is available, Visual SoftICE opens a new
disassembly page.
Page Features
Mode Selection
Page modes have some specific affects to the Disassembly page:
⽧ Live Mode - If the target is connected and stopped, it automatically
updates the display to include the disassembly line for current IP
upon target events. Instruction stepping can be performed.
⽧ Manual Mode - The display is not updated upon target events. You
can choose to display a chunk of disassembly lines for a specific
target address. Instruction stepping is not allowed.
⽧ Snapshot Mode - The page is only used to view the current chunk of
disassembly lines. It will not update the contents upon target events.
Instruction stepping is not allowed.
For more detailed information on Page Modes and how they work in
Visual SoftICE, refer to “Page Modes” on page 23.
Instruction Stepping
When the master is connected to a target that is stopped at an address,
the disassembly line of the current IP is highlighted. You can choose to
step-over, step-into, or step-out of the current instruction. Use the
options under the Debug group of the pop-up menu for the page, the
function keys as defined in the Preference settings, or the stepping
buttons on the main toolbar, to perform your stepping functions.
If the current instruction has a jump-to address to branch to, the yellow
arrow on the left of the highlighted line changes its direction to up or
down, depending on the branch address location, indicating that the
next instruction will be at a specific address. To view the jump-to line,
you can click the arrow, press <Ctrl><J>, or select Go To Jump from the
pop-up menu for the page. Visual SoftICE highlights the jump-to line
when it displays it.
You can always view the current IP line by pressing <Ctrl><I>, or by
selecting Go To Current IP from the pop-up menu for the page.
Bookmarks
You can set bookmarks at any viewable disassembly line, but only if the
target is connected. Bookmarks in the disassembly page are represented
by a target address. To set a bookmark:
⽧ Right-click on the line and select Set Bookmark from the pop-up
menu for the page
⽧ Right-click in first column to the left of the code and select Set
Bookmark from the pop-up menu
To remove bookmarks:
⽧ You must have focus on a line with a bookmark on it. You can then
remove the bookmark for the line, or all bookmarks in the file, by
right-clicking and selecting the applicable option from the page's
pop-up menu.
⽧ You can locate the cursor in the first column to the left of the code
and right-click to access the Bookmark pop-up menu.
You can view the bookmark list in the Go To dialog. From that dialog you
can view or run-to the specified bookmark via the Go To and Run To
buttons.
Visual SoftICE automatically removes all bookmarks when the target is
disconnected.
Go To
You can use the Go To dialog to:
⽧ View or run-to a disassembly line using its target address or function
name
⽧ View a line containing the current IP
⽧ View or run-to a selected bookmarked line
Go To Current IP
You can right-click on the page and select Go To Current IP from the
pop-up menu to view the line containing the current IP.
Run To Here
You can right-click on the page and select Run To Here from the pop-up
menu, and Visual SoftICE will run from the current IP to the line that
currently contains the cursor.
Find
You can use the Find dialog to search for a string in the current
disassembly page.
Copy
The page only supports copy command to retrieve its data.
⽧ You can select any text within the page and copy it to the clipboard.
⽧ You can use Select All from the pop-up menu to highlight all the
lines on the page before copying them to the clipboard.
Print
The page supports printing, and print-previewing of its contents.
Associated Commands
FILE
The FILE command is often useful when setting a breakpoint on a line
that has no associated symbol. For information on using FILE to set a
breakpoint refer to the Command Reference.
⽧ If you specify a file name, that file becomes the current file and
Visual SoftICE creates a new source page for it.
⽧ If you do not specify a file name, Visual SoftICE opens a source page
for the file that contains current IP. If no source file for the current IP
is available, Visual SoftICE displays a message stating that no file can
be opened for the current IP.
⽧ If you specify the * (asterisk), Visual SoftICE displays all the files in
the current symbol table.
LOAD
The LOAD command loads symbols for a specified image-name. If you
specify the * wildcard in place of image-name, Visual SoftICE opens the
Symbol Files utility.
T
The T command steps one instruction when the target is stopped. Visual
SoftICE searches through the symbols to locate a file containing the
current instruction pointer (IP). If it finds the file, and a source page for
that file is already available, Visual SoftICE updates the existing source
page. If it finds the file and no source page for that file is open, Visual
SoftICE creates a new source page.
If Visual SoftICE does not find a source file containing the current IP, and
a live disassembly page for the current IP is available, it updates that
page. If no live disassembly page is available, Visual SoftICE opens a new
disassembly page.
WC
When you type WC [address], Visual SoftICE searches through the
symbols to locate the source file containing the specified address. If
Visual SoftICE finds the source file, and a source page for the file is
already open, it brings the opened page forward. If the source file is not
already open, Visual SoftICE creates a new source page for the file and
brings it forward.
If the address is not contained in any source file, Visual SoftICE creates a
disassembly page and brings it forward.
Page Features
Breakpoints
With symbol information available, you can set breakpoints at a source
line containing actual code via one of the following methods:
⽧ Selecting Set Breakpoint under the Breakpoint group on the pop-up
menu for the page
⽧ Pressing the F9 function key
⽧ Clicking the Breakpoint button on the main toolbar
⽧ Locating the cursor in the second column to the left of the code, and
right-clicking to access the Breakpoint pop-up menu.
If you attempt to set a breakpoint on a line that does not contain actual
code, Visual SoftICE sets the breakpoint at the next line containing code.
If a line is in the source/disassembly mixed mode, you can set the
breakpoint at any of the visible disassembly lines.
Once you set a breakpoint, you can disable or remove it via one of the
following methods:
⽧ Selecting the applicable options from the breakpoint pop-up menu
⽧ Using the function keys
⽧ Using the buttons on the main toolbar
Any breakpoint changes made elsewhere in the system are
synchronously updated on the source page.
Bookmarks
In the source page, you can set a bookmark at any line in the source file,
but you cannot set bookmarks at the disassembly lines in mixed mode.
Bookmarks in the source page are represented by line numbers. You can
view or hide line numbers by toggling the Show Line Numbers option
on and off from the pop-up menu for the page, or by using <Ctrl><L> to
toggle the selection.
To remove bookmarks:
⽧ You must have focus on a line with a bookmark on it. You can then
remove the bookmark for the line, or all bookmarks in the file, by
right-clicking and selecting the applicable option from the page's
pop-up menu.
⽧ You can locate the cursor in the first column to the left of the code
and right-click to access the Bookmark pop-up menu.
You can view the bookmark list in the Go To dialog. From that dialog you
can view or run-to the specified bookmark via the Go To and Run To
buttons.
Go To
You can use the Go To dialog to:
⽧ View or run-to a source line using its target address or function name
⽧ View or run-to a line using its line number
⽧ View a line containing the current IP
⽧ View or run-to a selected bookmarked line
Go To Current IP
You can right-click on the page and select Go To Current IP from the
pop-up menu to view the line containing the current IP.
Run To Here
You can right-click on the page and select Run To Here from the pop-up
menu, and Visual SoftICE will run from the current IP to the line that
currently contains the cursor.
Find
You can use the Find dialog to search for a string in the current source
page.
Copy
The page only supports copy command to retrieve its data.
⽧ You can select any text within the page and copy it to the clipboard.
⽧ You can use Select All from the pop-up menu to highlight all the
lines on the page before copying them to the clipboard.
Print
The page supports printing, and print-previewing of its contents.
107
What Symbols are Supported
Visual SoftICE supports PDB files (version 5 or later), and DBG files, for
each target platform and OS it supports. This includes support and
identification of images that have been optimized (usually kernel
components), support for DDK compiler/linker generated symbols, and
application generated symbols. Modern compilers and linkers support
features like incremental compilation, incremental linking, and “edit and
continue”. These useful rapid application development enhancements
complicate symbol file information, and sometimes can generate files
with missing data, or data that is out of date.
Visual SoftICE also supports user-defined symbols, of address or value
type. These are considered global in nature, are always accessible, and
always loaded. To learn more about user-defined symbols, refer to the
NAME command in the Visual SoftICE Command Reference.
Active Table
Many symbol commands will restrict their search to the active table for
performance reasons, unless user input specifically references another
table, or indicates a request to search all known tables (refer to the
following commands in the Visual SoftICE Command Reference: FILE,
SYM, TYPES).
The active or current table will automatically change as the user changes
the current UI context, either through the context bar, or the ADDR
command.
The active table can be directly changed by entering the TABLE
command with the name of one of the loaded tables.
Matching
Tables that are loaded (dynamically, or persistently) have matching
criteria to images in the operating system. The match between a given
symbol file and an image is achieved differently depending on the image,
the type of symbol file loaded, and by user image match settings.
Images have a name, extension, target architecture type (64,32,16bit),
signature type (PDB6, PDB7, etc…), timestamp, and in some cases, age
and/or GUID data for reference to symbol files. The image data will be
retrieved and compared to the symbol file to be loaded, using the
IMAGEMATCH setting, to conclude if the symbol file meets the
minimum criteria of a match.
Differences in target architecture are not allowed:
⽧ 32bit symbols that match a 64bit image of the same name will not be
loaded.
⽧ Symbols for a 64bit Itanium of the same name of that for a 64bit x86-
64 platform will not be loaded.
The IMAGEMATCH setting (refer to SET IMAGEMATCH in the Visual
SoftICE Command Reference) can be BEST (default), or EXACT.
⽧ When this setting is BEST, symbols that are out of date, mismatched
on timestamp, GUID, signature, or only partially match the image
name and extension, are still allowed. This supports having symbols
that are “close” but not exact, which is sometimes good enough for
debugging.
⽧ When BEST is not good enough, (or confusing), EXACT mode is
available, which means that image name, extension, signature, and
version (age, GUID, timestamp) must match exactly, or the table will
not load. This is useful to ensure you absolutely have the right
symbols for a given situation.
Automatic Loading
Visual SoftICE loads only the tables on-demand that are necessary.
⽧ Tables are loaded for “current” images (images referenced in the
current process, and/or referenced in the current stack). As the OS
loads images, and those images are part of the current context, the
Symbol Engine will automatically load them.
⽧ As debugger commands are issued that reference other tables, these
are loaded on-demand as well.
⽧ All known images are tracked, and those not currently loaded yet are
considered in a “Deferred” state. Once loaded, the table remains
loaded until the image itself unloads, or the user forces it to unload
(refer to the UNLOAD command in the Visual SoftICE Command
Reference).
⽧ Automatic, dynamic loading presumes that the path information has
been setup so it can retrieve symbols in local (or accessible)
directories, or from any configured MS Symbol Server, and that it
may find local exports and images as well.
Automatic Unloading
When the OS unloads an image, if the Symbol Engine has a matching
table, that table is dynamically unloaded as well.
Controls
To disable or enable automatic symbol table loading, use the SET
SYMTABLEAUTOLOAD on/off command. Automatic loading is enabled
by default.
Commands
⽧ To load persistent symbols, use the ADDSYM command.
⽧ To unload persistent symbols, use the DELSYM command.
GUI Configuration
You can configure the MS Symbol Server Access and the server and local
directory information from the Paths element under Global Settings in
the Preferences dialog.
⽧ To set the server and local directory Visual SoftICE will bring files
into, configure the MS Symbol Server Paths element.
⽧ To enable symbol server retrieval (disabled by default), configure the
MS Symbol Server(s) Enabled element.
Using Exports
It is often useful to have exports in the absence of, or in addition to, full
or partial symbolic data for images. Visual SoftICE supports a means to
use exports, when available, in addition to any symbol files.
⽧ A path to the top of an exports tree is specified (refer to the SET
EXPORTPATH command in the Visual SoftICE Command Reference),
and exports can then be extracted on demand from the connected
target (refer to the GETEXP command in the Visual SoftICE
Command Reference).
⽧ Exports are stored with as much matching information as is available
in the image on the target, in a local directory structure similar to the
storage mechanism MS Symbol Servers uses for symbols
⽧ You can specify a wildcard “*” in the GETEXP command, getting
exports for everything in the specified directory. You can also specify
the flag (-s) to walk subdirectories in the retrieval. Please note that
retrieving exports for every image file on a target can be a very
lengthy process (but is possible).
Settings Notes
Path Settings
Path settings come in two types, a path list (which is an ordered list of
paths to search, each one semicolon separated) and a single path entry.
All path types for Visual SoftICE accept the ellipses (…) syntax at the end
of a directory name to indicate Visual SoftICE should search all
directories below the one specified.
Thus to get the source search path to include all your projects and source
code, the following example might be useful:
SET SRCPATH c:\development\driver_projects\…
In this case, Visual SoftICE searches all the files in
c:\development\driver_projects, and any subdirectories underneath
that directory, for a matching source file.
⽧ Introduction
⽧ Types of Breakpoints Supported by Visual SoftICE
⽧ Understanding Breakpoint Contexts
⽧ Virtual Breakpoints
⽧ Setting a Breakpoint Action
⽧ Conditional Breakpoints
⽧ Elapsed Time
⽧ Breakpoint Statistics
⽧ Referring to Breakpoints in Expressions
⽧ Manipulating Breakpoints
⽧ Using Embedded Breakpoints
Introduction
You can use Visual SoftICE to set breakpoints on program execution,
memory location reads and writes, interrupts, and reads and writes to I/O
ports. Visual SoftICE assigns a breakpoint index to each breakpoint. You
can use this breakpoint index to identify breakpoints when you delete,
disable, enable, or reference them.
All Visual SoftICE breakpoints are sticky, which means that Visual
SoftICE tracks and maintains a breakpoint until you intentionally clear
or disable it using the BC or the BD command. Breakpoints on a target
machine are removed when you disconnect, or the connection times out.
117
The number of breakpoints you can set on memory location (BPMs) and
I/O ports (BPIOs) is limited by the number of debug registers the target
processor supports (e.g. x86 supports 4).
Where symbol information is available, you can set breakpoints using
function names. When in a disassembly, source, or stack page, you can
set breakpoints via popup context menus, or at anytime from the
breakpoint page, or the debug main menu. A valuable feature is that you
can set breakpoints in an image before it is loaded.
Execution Breakpoints
An execution breakpoint traps executing code such as a function call or
language statement. This is the most frequently used type of breakpoint.
By replacing an existing instruction with an architecture appropriate
break instruction, Visual SoftICE takes control when execution reaches
the breakpoint.
Visual SoftICE provides many ways for setting execution breakpoints:
using the BPX command, the breakpoint page, the main debug menu,
and off numerous context menus on other pages. The following section
describes how to use the commands for setting breakpoints.
Memory Breakpoints
A memory breakpoint uses the debug registers found on the target
processor to monitor access to a certain memory location. This type of
breakpoint is extremely useful for finding out when and where a program
variable is modified, and for setting an execution breakpoint in read-only
memory. You are limited by the number of processor debug registers to
how many breakpoints may be set at one time.
Use the BPM command to set memory breakpoints on scalar data type
sized memory blocks:
BPM[size] [-l] address [ R | W | RW | X ] [IF conditional-
expression][DO “command1;command2;…”]
Interrupt Breakpoints
Sets an execution breakpoint on an interrupt handler, proivided by either
the OS or Driver.
Use the BPINT command to set interrupt breakpoints:
BPINT [-l] interrupt-number [service-address] [IF conditional-
expression] [DO “command1;command2;…”]
Visual SoftICE will stop either on the OS fault handler, or the entry point
to the driver provided Interrupt Service Routine. You can list all
interrupts and their handlers by using the IT/IDT command.
I/O Breakpoints
An I/O breakpoint monitors reads and writes to a port address. The
breakpoint traps when an IN or OUT instruction accesses the port.
Use the BPIO command to set I/O breakpoints:
BPIO [-l] port [R|W|RW] [IF conditional-expression] [IF
expression] [DO “command1;command2;…”]
When specifying a message or a message range, you can use the symbolic
name, for example, WM_NCPAINT. Use the WMSG command to get a list
of the window messages that Visual SoftICE understands. If no message
or message range is specified, any message will trigger the breakpoint.
To set a window message breakpoint for the window handle 1001E, use
the following command:
BMSG 1001E WM_NCPAINT
Visual SoftICE is smart enough to take into account the address context
of the process that owns the window, so it does not matter what address
context you are in when you use BMSG.
Image-Relative Breakpoints
Image-Relative breakpoints are the most common, and most useful type
— where the address is understood to be in the context of a given image
(even if that image has not loaded, or the its memory been paged in).
Any image-relative breakpoint will trigger in any instance of the image
that loads, regardless of its address or process (e.g. a breakpoint set in an
OS image like KERNEL32.DLL breaks in every process context that has the
image loaded, regardless of what context the breakpoint was initially set
in). Image relative breakpoints require accurate symbols to be available in
order to set them. These types of breakpoints appear as green throughout
the GUI.
Virtual Breakpoints
In Visual SoftICE, you can set breakpoints in images before they load,
and it is not necessary for a page to be present in physical memory for a
breakpoint to be set. In such cases, the breakpoint is virtual; it will be
automatically planted when the image loads or the page becomes
present. Virtual breakpoints can only be set when symbols are available.
Conditional Breakpoints
Conditional breakpoints provide a fast and easy way to isolate a specific
condition or state within the system (or application) you are debugging.
By setting a breakpoint on an instruction or memory address and
supplying a conditional expression, Visual SoftICE will only trigger if the
breakpoint evaluates to non-zero (TRUE). Because the Visual SoftICE
expression evaluator handles complex expressions easily, conditional
expressions take you right to the problem or situation you want to debug
with ease.
Most Visual SoftICE breakpoint commands accept conditional
expressions using the following syntax:
breakpoint-command [breakpoint options] [IF conditional
expression][DO “commands”]
BPCOUNT
The value for the BPCOUNT function is the current number of times that
the breakpoint has been evaluated as TRUE.
Use this function to control the point at which a triggered breakpoint
causes a popup to occur. Each time the breakpoint is triggered, the
conditional expression associated with the breakpoint is evaluated. If the
condition evaluates to TRUE, the breakpoint instance count (BPCOUNT)
increments by one. If the conditional evaluates to FALSE, the breakpoint
miss instance count (BPMISS) increments by one.
BPMISS
The value for the BPMISS expression function is the current number of
times that the breakpoint was evaluated as FALSE.
The expression function is similar to the BPCOUNT function. Use it to
specify that Visual SoftICE stop in situations where the breakpoint is
continually evaluating to FALSE. The value of BPMISS will always be one
less than you expect, because it is not updated until the conditional
expression is evaluated. You can use the (>=) operator to correct this
delayed update condition.
BPX myaddr if (eax==43) || (bpmiss>=5)
Due to the early-out algorithm employed by the expression evaluator, if
the expression eax==43 is ever TRUE, the conditional evaluates to TRUE
and Visual SoftICE stops. Otherwise, BPMISS is updated each time the
conditional evaluates to FALSE. After five consecutive failures, the
expression evaluates to TRUE and Visual SoftICE stops.
BPINDEX
Use the BPINDEX expression function to obtain the breakpoint index to
use with breakpoint actions.
This expression function returns the index of the breakpoint that caused
Visual SoftICE to stop. This index is the same index used by the BL, BC,
BD, BE, BPE, BPT, and BSTAT commands. You can use this value as a
parameter to any command that is being executed as an action.
The following example of a breakpoint action causes the BSTAT
command to be executed with the breakpoint that caused the action to
be executed as its parameter:
BPX myaddr do “bstat bpindex”
This example shows a breakpoint that uses an action to create another
breakpoint:
BPX myaddr do “t;bpx @esp if(tid==_tid) do \“bc bpindex\”;g”
BPINDEX is intended to be used with breakpoint actions, and causes an
error if it is used within a conditional expression. Its use outside of
actions is allowed, but the result is unspecified and you should not rely
on it.
Foobar Function
1:DWORD foobar ( DWORD foo )
2:{
3:DWORDfooTmp=0;
4:
5:if(foo)
6:{
7:fooTmp=foo*2;
8:}else{
9:fooTmp=1;
10:}
11:
12:return fooTmp;
13:}
Source code lines 1 and 2 are outside the function body. These lines
execute the prologue code. If you use a local variable at this point, you
receive the following symbol error:
>BPX foobar if(foo==1)
error: Undefined Symbol (foo)
Set the conditional on the source code line 3, where the local variable
fooTmp is declared.
⽧ Use either the ESP or EBP register to address parameters. Using the
EBP register is not valid until the PUSH EBP and MOV EBP, ESP
instructions are executed. Also note that once space for local
variables is created (SUB ESP, size) the position of the parameters
relative to ESP needs to be adjusted by the size of the local variables
and any saved registers.
⽧ Typically you set a breakpoint on the function address, for example:
BPX IsWindow
LOCALS+0
⇐ Stack pointer after prologue
(SUB ESP, size (locals))
Duplicate Breakpoints
Once a breakpoint is set on an address, you cannot set another
breakpoint on the same address. With conditional expressions, however,
you can create a compound expression using the logical operators (&&)
or (||) to test more than one condition at the same address.
Elapsed Time
Visual SoftICE supports using the target processor time stamp counter.
Every time Visual SoftICE stops due to a breakpoint, the elapsed time
displays since the last time Visual SoftICE stopped. The time displays
after the break reason in seconds, milliseconds, or microseconds, and this
can be seen in the command page, or breakpoint page history log.
Most processor time stamp counters are highly accurate, but you must
keep the following issues in mind:
⽧ There is overhead involved in stopping Visual SoftICE, which may
impact the results very slightly.
⽧ If a hardware interrupt occurs before the breakpoint goes off, all the
interrupt processing time is included.
⽧ Certain processors will vary the clock rate dynamically, for power
management reasons.
Manipulating Breakpoints
Visual SoftICE provides a variety of commands for manipulating
breakpoints such as listing, modifying, deleting, enabling, and disabling
breakpoints. Breakpoints are identified by breakpoint index numbers,
which are uniquely assigned. Table describes the breakpoint
manipulation commands.
Table 6-1. Visual SoftICE Breakpoint Manipulation Commands
Command Description
BD Disable a breakpoint.
BE Enable a breakpoint.
Note: Refer to the Visual SoftICE Command Reference for more information
on each of these commands.
⽧ Expression Values
⽧ Supported Operators
⽧ Forming Expressions
⽧ Expression Evaluator Type System
Expression Values
The Visual SoftICE expression evaluator determines the values of
expressions used with Visual SoftICE commands and conditional
breakpoints. It provides full operator precedence; support for standard C
language arithmetic, bit-wise, and logical operators; predefined macros,
functions, and casts for data type conversion; and access to common
Visual SoftICE and operating system values.
The Visual SoftICE expression evaluator parses and evaluates expressions
similarly to the way a C or C++ language compiler translates expressions.
If you are comfortable with either language, you are already familiar with
the grammar and syntax of Visual SoftICE expressions.
There are no limitations on the complexity of an expression. You can
combine multiple operators, operands, and expressions to create
compound expressions for conditional breakpoints or expression
evaluation.
This example uses a compound expression to trigger a breakpoint if the
first parameter (ESP+4) passed to the IsWindow( ) API function is an
HWND with the value of 0x10022 or 0x1001E. If either of the two
expressions is TRUE, the conditional expression is TRUE, and the
breakpoint triggers:
BPX IsWindow if (esp+4 == 10022) || (esp+4 == 1001E)
135
Supported Operators
The Visual SoftICE expression evaluator supports the following operators
sorted by type:
Note: Use the SET EE_IMPL_DEREF command to control the expression
evaluator's behavior regarding dereferencing. If you have set
EE_IMPL_DEREF to on, and the expression evaluator encounters an
expression containing a symbol that is a pointer, it will use the value
it points to for evaluation. If you have set EE_IMPL_DEREF to off, and
the expression evaluator encounters an expression containing a
symbol that is a pointer, it will use the address of the pointer for
evaluation.
Table 7-1. Visual SoftICE Indirection Operators
+ eax + 1
- ebp - 4
* ebx * 4
/ Symbol / 2
% (modulo) eax % 3
<< (logical shift left) bl << 1 (result is bl shifted left
by 1)
>> (logical shift right) eax >> 2 (result is eax shifted
right by 2)
Operator Precedence
Operator precedence within the Visual SoftICE expression evaluator is
equivalent to the C language operator precedence. Operator precedence
plays a crucial part in evaluating expressions, so the order in which you
input expression operators can have a dramatic result on the final result
of the expression. To override the default operator precedence to produce
a desired result, use parentheses to force the order of evaluation.
Forming Expressions
Tip: Use the ? or EVAL The Visual SoftICE expression evaluator accepts a variety of operands,
(evaluate expression) such as symbols, register names, user-defined symbols, and numbers,
command to display the that you can combine with any Visual SoftICE operator. Visual SoftICE
result of any expression.
places an emphasis on providing flexibility of expression, so input is as
natural as possible.
Chapter 7⽧Using Expressions 137
Numbers
The Visual SoftICE expression evaluator accepts the following numeric
inputs.
Table 7-5. Visual SoftICE Expression Inputs
Input Description
Hexadecimal The default radix for input and output is controlled by the SET
RADIX command. The valid character set for hexadecimal num-
bers is [0-9, A-F]. Hexadecimal input can be optionally preceded
by the standard C language radix identifier: 0x. Examples of valid
hexadecimal numbers include:
FF, ABC, 0x123, 0xFFFF0000
The symbolic form of a valid hexadecimal number could conflict
with a symbol name. For example, ABC. Use the 0x form to ensure
that the number is not misinterpreted as a symbol name.
Prefixing 0x to input forces it to be evaluated as hexadecimal
input regardless of the default radix.
You can also use the HEX(n) and DEC(n) functions to force inter-
pretation to a given radix.
Registers
Visual SoftICE supports multiple names for the target register sets. You
control the target register set name using the SET REGNAME command.
A register name or alias might conflict with a symbol. To force input to be
evaluated as a register name, use the REG(n) function.
Symbols
Symbol names are the symbolic representation of an address or value.
They are defined in symbol tables, export tables, or via Visual SoftICE's
NAME command, during debugging.
Symbol names in Visual SoftICE differ from symbols defined in C or C++
programs. All compilers add some form of decoration to the names
defined in a program, and this decoration often includes characters
which are not valid in C/C++ symbol names. Visual SoftICE therefore
accepts a wider range of characters in symbol names than a compiler.
Table 7-6 shows the characters which may be found in a legal symbol
name. Symbols must begin with one of the characters marked valid as
first symbol characters in the table.
0..9 No
The scope operator (::) is allowed in symbols. However, note that the
"operator" is in this context simply part of the symbol name, and is not
functioning as a true operator. Any number of scope operators are
allowed in a symbol name, so namespaces and nested classes will
function properly.
Each symbol file loaded into Visual SoftICE is placed in a separate table,
and only one symbol table can be "active" at a time. (Refer to the TABLE
command in the Visual SoftICE Command Reference for more
information on changing the active table.)
To specify a symbol from an inactive symbol table in an expression, you
may precede the symbol with the table name, followed by an
exclamation point, followed by the symbol name. For example:
table-name!symbol-name
Symbols that are defined by the NAME command are always active,
because Visual SoftICE treats these symbol sources as global.
Type Example
In most cases, you can ignore the distinction between types as it is only
important to Visual SoftICE. In the cases of symbol-type and address-
type, however, there are important semantics or restrictions.
Symbol Type
The symbol-type is used for symbol names that are in export or symbol
tables. In general, the type represents the linear address of a symbol
within a code or data segment. The symbol type also represents the
contents of memory at that linear address. This is similar to the use of a
variable in a C program, but because Visual SoftICE is a debugger and not
a compiler, there are a few semantic differences. Visual SoftICE
determines whether you mean contents-ofor address-of based on the
context of how you use the symbol/variable in an expression. In general,
the way Visual SoftICE treats a symbol seems completely natural, not
unlike that of the C compiler; but, in cases where you are not sure how
Visual SoftICE interprets the symbol, you can explicitly state:
address-of (&Symbol) or contents-of (*Symbol)
Note: Refer also to the SET EE_IMPL_DEREF command.
When symbol-types are used in expressions, Visual SoftICE will, in most
cases, present the result of the expression in the correct type. For
example, given an array of integers declared like this:
int TinyArray[] = { 1, 2, 3, 4 };
Address Type
Visual SoftICE treats a symbol as an address-type if you use it in an
expression where an address-type is legal and it makes sense to use an
address. Otherwise, Visual SoftICE automatically indirects the symbol,
taking the contents of the memory the symbol represents. You can also
control this behavior with the SET EE_IMPL_DEREF command.
There are many operations that are illegal or do not make sense for
address-types such as multiplication and division, so a majority of the
operators used with the symbol-type act like a C compiler and
automatically take the contents-of at the address for the symbol.
Evaluating Symbols
When data type information is available, using the ? (evaluate
expression) command with a symbol yields the contents of the symbol
rather than the address of the symbol. For example, MyVariable is an
integer variable containing the value 5, so you get the following:
? MyVariable
int=0x5,"\0\0\0\x05"
To get the address of MyVariable, use the following:
? &MyVariable
If you use a symbol in conjunction with a command other than ‘?,’ be
sure to add the address of the ‘&’ operator where needed. For example,
the data display command (D) takes an address as a parameter, so to
display the contents of a symbol, you should add the ‘&’ operator:
dd &MyVariable
⽧ Overview
⽧ Inside the Windows Kernel
⽧ Win32 Subsystem
Overview
If you are going to write Windows NT family applications, you should
explore what lies beneath your application code: the operating system.
The knowledge you gain from the time you invest to go beneath your
application and into the depths of the system will benefit both you and
the application or driver that you are creating.
This chapter provides a quick overview of the more pertinent and
interesting aspects of the basic Windows NT Operating System. By
combining this information with available reference material and a little
practical application using Visual SoftICE, you should be able to gain a
basic understanding of how the components of Windows NT fit together.
145
Windows DDK
The Windows DDK contains header files, sample code, on-line help, and
special tools that let you query various kernel components. The most
obvious and useful resource is NTDDK.H. Although there is quite a bit of
information missing from this header file, enough pertinent information
is available to make it worth studying. Besides the basic data structures
needed for device driver development, system data structures are
described (some completely, others briefly, many not at all). There are
many API prototypes and type enumerations that are useful for both
exploration and development. There are also useful comments about the
system design, as well as restrictions and limitations. Most of the other
header files in the DDK are specific to the more esoteric aspects of the
system, but NTDEF.H, BUGCODES.H, and NTSTATUS.H are generally
useful.
The Windows DDK includes a few utilities that are of general interest. For
example, POOLMON.EXE allows you to monitor system pool usage, and
OBJDIR.EXE provides information on the Object Manager hierarchy and
information about a specific object within the hierarchy. Visual SoftICE
provides similar functionality with the OBJDIR, DEVICE, and DRIVER
commands. The utility DRIVERS.EXE, like the Visual SoftICE DRIVER
command, lists all drivers within the system, including basic information
about the driver. Some versions of the Windows DDK include a
significantly more powerful version of the standard PSTAT.EXE utility.
PSTAT is a Win32 console application that provides summary
information on processes and threads. Included with the Win32 SDK and
the Visual C++ compiler, are two utilities worth noting: PVIEW and
SPY++. Both provide information on processes and threads, and SPY++
provides HWND and CLASS information.
The Windows DDK also includes help files and reference manuals for
device driver development, as well as sample code. The sample code is
most useful, because it provides you with the information necessary for
creating actual Windows device drivers. Simply find something in your
area of interest, build that sample, and step through it with Visual
SoftICE.
Component Description
Component Description
Resources
The following resources provide extensive information for developing
drivers and applications for Windows NT:
⽧ Microsoft Developers Network (MSDN)
MSDN is published quarterly, on CD-ROM, and it contains a wealth
of information and articles on all aspects of programming Microsoft
operating systems. This is one of the only places where you can find
practical information on writing Windows NT device drivers.
⽧ Inside Windows NT - Helen Custer, Microsoft Press
Inside Windows NT provides a high-level view of the design for the
Windows NT operating system. Each of the major sub-systems is
thoroughly discussed, and many block diagrams illuminate internal
data structures, policies, and algorithms. Although the contents of
this book may seem highly abstracted from the actual operating
system implementation, once you step into OS code with Visual
SoftICE, many of the higher level relationships become clear.
Currently, this is the most valuable set of information on Windows
NT operating system internals. You will gain the most benefit from
the information in this book if you use Visual SoftICE to explore the
actual implementation of the system design.
⽧ Advanced Windows - Jeffery Richter, Microsoft Press
Advanced Windows is an excellent resource for the systems programmer
developing Win32 applications and system code. Richter presents
extensive discussions of processes, threads, memory management,
and synchronization objects. Relevant sample code and utilities are
also provided.
⽧ I/O subsystems
Command Description
Interrupt # Purpose
8 Double Fault. A Task gate is installed here so the OS has a clean set
of registers, page-tables, and level 0 stack. This enables the
operating system to continue processing long enough to throw a
Blue Screen.
2D Debug service.
Non-APIC only: Interrupt vectors 0x30 - 0x3F are mapped by the primary
and secondary interrupt controllers, so hardware interrupts for IRQ0
through IRQ15 are vectored through these IDT entries. In many cases,
these hardware interrupt vectors are not hooked, so the system assigns
default stub routines for each one. As devices require the use of these
hardware interrupts, the device driver requests to be connected. When
the interrupt is no longer needed, the device driver requests to be
disconnected.
Note that the first four selectors address the entire 4GB linear address
range. These are flat selectors that Win32 applications and drivers use.
The first two selectors have a DPL of zero and are used by device drivers
and system components to map system code, data, and stacks. The
selectors 1B and 23 are for Win32 applications and map user level code,
data, and stacks. These selectors are constant values and the Windows NT
system code makes frequent references to them using their literal values.
The selector value 30h addresses the Kernel Processor Control Region and
is always mapped at a base address of 0xFFDFF000. When executing
system code, this selector is stored in the FS segment register. Among its
many other purposes, the Processor Control Region maintains the
current kernel mode exception frame at offset 0.
:addr
Page Dir KPEB Addr PID Name
00030000 FF116020 0002 System
0115A000 FF0AAA80 0051 RpcSs
0073B000 FF083020 004E nddeagnt
00653000 FF080020 0061 ntvdm
00AEE000 FF07A600 0069 Explorer
01084000 FF06ECA0 0077 FINDFAST
010E9000 FF06CDE0 007B MSOFFICE
*01F6E000 FF088C60 006A WINWORD
01E0A000 FF09CCA0 008B 4NT
017D3000 FF09C560 006D ntvdm
00030000 80140BA0 0000 Idle
2 Use the physical address as input to the PHYS command to obtain all
linear addresses that map to that physical page. (One physical page
may be mapped to more than one linear address, and one linear
address may be mapped to more than one page.)
:phys 1F6E000
C0300000
3 Use the linear address (C0300000) and run it through the PAGE
command to verify the physical page for that linear address.
:page C0300000
Linear Physical Attributes
C0300000 01F6E000 P D A S RW
The Non-Paged pool is similar to the Paged Pool with the exception
that objects created in the Non-Paged pool are not discarded from
memory for any reason. The Non-Paged pool is used to allocate key
system data structures such as kernel process and thread
environment blocks. There is a second Non-Paged pool used for
memory allocations that must succeed. At system initialization,
NTOSKRNL reserves a small amount of physical memory for critical
allocations, and saves this memory for use by the must succeed pool.
The size of an allocation from the must succeed pool must be less
than one page (4KB). If the must succeed allocation cannot be
satisfied, or the requested allocation size is larger than 4KB, the
system throws a Blue Screen.
In many cases, device driver writers need to know the current IRQL at
which they are executing. Although you could look inside the PCR
data structure at offset 0x24, it is simpler to look at the status bar or
use the Visual SoftICE intrinsic function, IRQL, as follows:
? IRQL
00000002h
The most common piece of data accessed from the PCRB is the
current kernel thread pointer. This is at offset 4 within the PCRB, but
is generally referenced through the PCR at offset 0x124. This works
because the PCRB is nested within the PCR at offset 0x120. Code that
accesses the current thread is usually of the form:
mov reg, FS:[124].
Remember that while executing in system mode, the FS register is set
to a GDT selector whose base address points to the beginning of the
PCR. Visual SoftICE makes it much easier to get the current thread
pointer or thread id by viewing the context bar, or using the intrinsic
functions thread or tid:
? thread
FF088E90h
? tid
71h
:thread tid
:thread thread
Note: All this information is available in the Visual SoftICE context bar.
Win32 Subsystem
Inside CSRSS
The Win32 subsystem server process CSRSS implements the Win32 API.
The Win32 API provides many different types of service, including
functionality traditionally attributed to the original Windows
components KERNEL, USER, and GDI. Although these standard modules
exist in the form of 32-bit DLLs under Windows NT 3.51, and to a lesser
degree under new versions of the operating system, most of the core
functionality is actually implemented in WINSRV.DLL within the CSRSS
process. Calls that are traditionally associated with one of the standard
Windows components are typically implemented as stubs that call other
modules, for example, NTDLL.DLL, or use inter-process communication
to CSRSS for servicing.
The Object Pointer field points to the actual object data. This pointer is
generally from one of the CSRSS heaps or the Paged Pool. The type field
is the enumeration for the object type. The Instance Count field creates
unique handles. The Flags field is used by the Handle Manager to note
special conditions, such as when a thread locks an object for exclusive
use.
When an object is destroyed, all fields are reinitialized to zero and the
current Instance Count for that entry is incremented by one. Thus, when
the object table entry is reused, it generates a different handle value for
the new object.
Note: The actual object type is not part of the object handle value. This
means that given an object handle, an application cannot directly
determine its type. It is necessary to dereference the object table
entry to obtain the object type.
This technique for creating unique handle values is simple and efficient,
and makes validation trivial. Imagine the case where a process creates a
window and obtains a handle to that window. During subsequent
program execution, the process destroys the window but retains the
handle value. If the process uses the handle after the window is
destroyed, the handle value is invalid and the type it points to has an
object type of FREE. This condition is caught, and the program is not be
able to use the handle successfully. In the meantime, if another process
creates a new object, it is likely that the entry originally for the now
destroyed window will be reused. If the original program uses the invalid
window handle, the handle instance counts no longer match, and the
validation fails.
Object tables are not process specific, so USER and GDI object handles
values are not unique to a specific process. HWND handles are unique
across the entire Win32 subsystem. One process never has an HWND
handle value that is duplicated in any other process.
:objtab hwnd
Object Type Id Handle Owner Flags
E12E9EA8 Hwnd 01 0001001C E12E7008 00
:dd e12e9ea8 l 20
0010:E12E9EA8 0001001C 00000006 00000000 FF0E45D8
0010:E12E9EB8 00000000 E12E7008 00000000 00000000
The value 0x1001C, at offset 0, is the object handle value. The field at
offset 4, which contains the value six (6), is the object reference
count. The value at offset 0x0C, of 0xFF0E45D8, is a pointer to the
window’s desktop object.
4 Dumping 0x20 bytes at the address of the owner data reveals the
following:
:dd e12e7008 l 20
0010:E12E7008 0001001B 00000000 00000000 E12E9C34
0010:E12E7018 E17DB714 00000000 00000000 00000000
5 The value (0x1001B) at offset 0 of the owner data looks like an object
handle, but it is a thread information object. The following example
uses the OBJTAB command with 0x1001B as the parameter to show
the type for the owner data.
:objtab 1001b
Object Type Id Handle Owner Flags
E12E7008 Thread Info 06 0001001B 00000000 00
Under Windows, the lowest and highest 64KB regions in the user-mode
address space are reserved and are never mapped to physical memory.
The 64KB at the bottom of the linear address space is designed to help
catch writes through NULL pointers.
:thread winword
TID Krnl TEB StackBtm StkTop StackPtr User TEB Process(Id)
006B FFA7FDA0 FEAD7000 FEADB000 FEADAE64 7FFDE000 WINWORD(83)
007C FF0A0AE0 FEC2A000 FEC2D000 FEC2CE18 7FFDD000 WINWORD(83)
009C FF04E4E0 FC8F9000 FC8FC000 FC8FBE18 7FFDC000 WINWORD(83)
To find out more about the user-mode address space of a process, use the
Visual SoftICE QUERY command. The QUERY command provides a high-
level view of the linear regions that were reserved and/or committed. It
uses the Visual SoftICE WHAT engine to identify the contents of a linear
range. From its output you see the process heaps, modules, and memory-
mapped files, as well as the thread stacks and thread environment blocks.
Heap API
Heap Architecture
Every user-mode application directly or indirectly uses the Heap API
routines, which are exported from KERNEL32 and NTDLL. Heaps are
designed to manage large areas of linear memory and sub-allocate
smaller memory blocks from within this region. The core
implementation of the Heap API routine is contained within NTDLL, but
some of the application interfaces such as HeapCreate and HeapValidate
are exported from KERNEL32. For some API routines, such as HeapFree,
there is no code implementation within KERNEL32, so they are fixed by
the loader to point at the actual implementation within NTDLL.
Note: The technique of fixing an export in one module to the export of
another module is called ‘Snapping’.
:heap -s 140000
Base Id Cmmt/Psnt/Rsvd Segments Flags Process
00140000 01 001C/0018/00E4 1 00000002 Explorer
01 00140000-00240000 001C/0018/00E4 E4000
:heap -x 140000
Flags: GROWABLE
:heap -b 140000
00140580 SEGMENT 38 01
001405B8 ALLOC 30 01
In the above output, you can see how the heap header is followed by
Heap Segment #1 and that the first allocated block is just beyond the
Heap Segment data structure.
:HEAP -b explorer.exe
Count:11
Base Heap Base Id Committed Present Reserved SegmentCount Flags Mapped
------------------------------------------------------------------------------------------------------------
-------------------------------------
explorer.exe 00080000 1 9b 85 100 1 00000002 no
explorer.exe 00180000 2 6 4 10 1 00001002 no
explorer.exe 00190000 3 1 0 10 1 00008000 no
explorer.exe 00260000 4 d b 10 1 00001002 no
explorer.exe 00460000 5 10 c 10 1 00001002 no
explorer.exe 01240000 6 3 1 10 1 00001002 no
explorer.exe 01250000 7 3 1 40 1 00001002 no
explorer.exe 012a0000 8 4 3 10 1 00001002 no
explorer.exe 00a10000 9 3 1 100 1 00000002 no
explorer.exe 00b10000 a c 8 10 1 00001002 no
explorer.exe 00b60000 b 3 2 10 1 00001002 no
To examine the contents of an allocated heap block and a free block, the
second example dumps memory at the base address of the heap block at
0x143FE0. Enough memory is dumped to show the subsequent block,
which is a free block at address 0x144008.
The heap block header fields from the memory dump at address
0x143FE0 are identified with call-outs. This heap block is five units in
size (40 bytes) and 0x1C bytes of that size is overhead for the heap block
header (1 unit), busy-tail (1 unit), unit alignment (1 Dword), and an extra
unit left over from a previous allocation.
The heap block immediately following this is a free block that begins at
address 0x144008. This block is 0x1FF units and the size of the previous
block is five units. For free blocks 1KB or larger (80+ units), the Free List
byte position and bit-mask values are not used and are zero. The flag for
this heap block indicates that it is a sentinel (bit 4, or 0x10). Immediately
following the heap header is the location where the heap manager has
placed a doubly-linked list node for tracking free blocks. The pointer
values for the next and previous fields of the node are both 0x1400B8.
After the free list node, the heap manager tagged all the blocks memory
with a special signature that is validated the next time the block is
allocated, coalesced with another block, or a heap validation is
performed.
Previous unit Segment Free list byte Doubly linked free list
Unit size Flags Free list bit node
Free check
Troubleshooting
If you encounter the following problems, try the corresponding
solutions. If you encounter further difficulties, contact the Technical
Support Center.
183
Problem Solution
In Visual SoftICE, I want to connect to the There may be several reasons for this. First, you may
target machine but I do not see it in the list of not have installed the target portion of Visual SoftICE
network target machines. on that target machine.
If you are confident that you have properly installed
the Visual SoftICE target components on the target
machine, then go to the configuration tool and make
certain that you have properly configured a
connection.
If you have a properly configured connection on that
target machine, and it is active, then you will need to
do more extensive troubleshooting. Contact the
Technical Support Center with all applicable details.
I want to set a break point on something in my This is because the source is not mapped where
source, but when I open the source code and Visual SoftICE can determine the location of the
attempt to set the break point, it fails to set. image file to break on.
To fix this, you can either pre-load symbols into Visual
SoftICE using the ADDSYM command, or you can set
the breakpoint on the loading of that module (using
the BPLOAD command) and have them found
automatically. Once the module is in memory, you
can set breakpoints on other locations.
I am noticing that the values in the Command Most values returned in the Command page are
page do not appear to be correct. For displayed in hexadecimal format by default. Try
example, I entered the CPU command and converting the value you receive to decimal, and
Visual SoftICE returned the value for my reinterpret the results. The 585 processor speed in
processor speed as 585. your example would actually be 1400 decimal.
Use the SET RADIX command to configure the
displayed and input radix to whatever format you are
expecting to see.
After installing Visual SoftICE on my target Try connecting with the master and check the status
machine, it will no longer boot. It reaches a of the target to see if it has reached a breakpoint. A
specific part of the boot sequence and then major cause of this behavior is the “stop on boot”
goes no further. setting. Once the target is up and running, use
DSConfig to check the “stop on boot” setting for the
target.
187
The extension DLLs that you are using must match the operating system
of the target computer. The extension DLLs that ship with WinDbg are
each placed in a different subdirectory of the installation directory
according to the OS version and target mode (Release version or Debug
version). For example, nt4fre, w2kchk, and winxp. You must make sure
you use the right version, and you must set the right KD extension search
path (using either the path definitions in the Settings dialog, or via the
SET KDEXTPATH command at the command line).
You should be as specific as possible when setting the KD extension
search path, such as using C:\Program Files\Debugging Tools for
Windows\winxp instead of C:\Program Files\Debugging Tools for
Windows, otherwise Visual SoftICE will look for the first name-matched
KD Extension DLL and load it.
Note: If you write your own debugger extensions, you should place them
in a new directory and add that directory to the debugger extension
path.
Required: The module name should not be followed with the .dll file name
extension.
If the module has not already been loaded, it will be loaded into the
debugger using a call to LoadLibrary(module). After the debugger has
loaded the extension library, it calls the GetProcAddress function to
locate the extension name in the extension module. The extension name
is case-sensitive and must be entered exactly as it appears in the
extension module's .def file. If the extension address is found, the
extension is called.
If the module name is not specified, the debugger will search the loaded
extension modules for this export. The latest loaded DLL is searched first.
When an extension module is unloaded, it is removed from the search
order. When an extension module is loaded, it is added to the beginning
of the search order.
Datum Artificial data elements contrived to make the user’s life easier. For
example, BPID, and _TID (current thread ID). Datums are time and target
context sensitive.
Interrupt Descriptor Table pointed to by the IDTR register, which defines the interrupt/
Table (IDT) exception handlers. Use the IDT command to display the table.
MAP file Human-readable file containing debug data, including global symbols
and usually line number information.
MMX Multimedia extensions to the Intel Pentium and Pentium-Pro processors.
Object Represents any hardware or software resource that needs to be shared as
an object. Also, the term section is sometimes called an object. Refer to
Section.
One-Shot Breakpoint Breakpoint that only goes off once. It is cleared after the first time it goes
off or the next time Visual SoftICE pops up for any reason.
Ordinal Form When a symbol table is not relocated, it is said to be in its ordinal form;
in this state, the selectors are section numbers or segment numbers (for
16 bit).
Relocate Adjust program addresses to account for the program’s actual load
address.
Section In the PE file format, a chunk of code or data sharing various attributes.
Each section has a name and an ordinal number.
Sticky Breakpoint Breakpoint that remains until you remove it. It remains even through
unloading and reloading of your program.
SYM File File containing debug data, including global symbols and usually line
number information. The SYM file is usually derived from a MAP file.
Symbol Table Visual SoftICE-internal representation of the debugging information, for
example, symbols and line numbers associated with a specific module.
191
Virtual Breakpoint Breakpoint that can be set on a symbol or a source line that is not yet
loaded in memory.
Symbols Breakpoints 16
.PDB Files 147 duplicate 132
embedded 134
expressions 133
Numerics INT 1 and INT 3 134
1394 7, 12 manipulating 133
statistics 133
A types 118
About using 117
the context bar 22 virtual 124
the status bar 21 BSTAT command 133
Accessing Images 108 Built-in functions 139
Active Table 109
ADDR command 155, 157 C
Address Character constants 138
space 169 Choosing Your Version 1
type 142 Command
Audience ix comments 37
Automatic syntax output redirection 37
changes in mode state 24 Command Page 45
loading 111 features 37
output redirection 39 Commands
unloading 111 BC 133
BD 133
B BE 133
BC command 133 BL 133
BD command 133 BSTAT 133
BE command 133 Conditional Breakpoints 125
Bitwise operators 137 referencing the stack 130
BL command 133 Conditional breakpoints
Breakpoint count functions 126
action, setting 125 Context Bar Controls 23
options 119 Copy 40
page 78 CSRSS 161
statistics 133 Current Context 18
Cursor Types 20
Customer Assistance xii
193
Customizing F
the status bar 33 Filtering Messages 83
toolbars 32 Firewire 7, 12
Cut 40 Fixed Address Breakpoints 124
Fonts & Colors Settings 34
D Forming expressions 137
Data Item Drag and Drop 41 Functions
DBG files 147 built-in 139
Debug Message Page 82 expression evaluator 141
Debugging
features 6 G
resources 145 GDI objects 164
Dedicated PCI Ethernet 7, 9 GDT command 152
NIC 9 General Global Settings 25
DEVICE command 146 Global
Disassembly Page 91 descriptor table 150, 152
Drag and Drop 40 settings 25
DRIVER command 146
Dual Machine Debugging 3
Duplicate Breakpoints 132 H
Handle values 166
Heap
E API 170
Eaddr function 142 architecture 170
EBP register 130 blocks 175
Elapsed Time 132 HEAP command 163, 174
Embedded breakpoints 134
ESP register 130
Event Page 84 I
Execution Breakpoints 119 I/O Breakpoints 121
Export 114 IDT command 151
Expression Image Search 114
evaluator 135 Image-Relative Breakpoints 124
built-in functions 139 Indirection operators 136
expression values 142 INT 1 instruction breakpoints 134
INT 3 instruction breakpoints 134
forming expressions 137
Integrated MS Symbol Server Access 112
numbers 138
Intel architecture 150
operators 136 Interrupt
registers 138 breakpoints 121
symbols 138 Descriptor Table 150, 151
types 142
values 135
address-type 142 K
KD Extension
literal-type 142
DLLs 187
register-type 142
Overview 187
symbol-type 142 KD Extension Paths 114
Expressions KD Extensions 187
breakpoints 133 Kernel Debugger Extensions 187
forming 137 Keyboard Settings 30
Index 195
Status Bar User
examples 21 interface overview 15
settings 32 symbol search path 114
notes 115 Using Exports 113
Supported Symbols 108
SYM command 158 V
Symbol
Virtual breakpoints 124
location 107
Virtual NIC Driver 7, 12
management 107
Visual SoftICE 1, 3
table state 19
features 6
Symbol Handling, On Demand 6
global settings 26
Symbol Management 107
icons 16
Symbols 138
overview 5
in Visual SoftICE 113
symbol table status 116
type 142
UI overview 15
System
user interface 45
Code area 154
overview 15
memory map 154
Visual SoftICE User Interface
page table entries 158
Overview 15
Tables System area 155
VSI
View System area 154
symbol table status 116
system activity messages 115
T
Table Loading Controls 111
Target
W
Watch Page 75
state 17
Win32 subsystem 161
transport overview 7
Window Message Breakpoints 123
Task State Segment 152
Windows Components 161
Text Scratch Page 87
Windows NT
THREAD command 170
DDK 146
Toolbar
exploring 145
settings 32
kernel 149
notes 115
references 148
Troubleshooting 183
system memory map 154
Visual SoftICE 183
Workspace Save and Load 36
Typographical Conventions xi
U
UHCI 7, 11
Understanding Breakpoint Contexts 124
Universal PCI Ethernet 7, 10
Unloading Tables 109
USB
host controller 7, 11
NIC 7, 11
Useful Documentation xii
USER
object
creation 168
table 167
objects 164