Using SoftICE
Using SoftICE
So f t I CE Ver sio n 4 . 3 . 0
f or D r i ve r St ud io 3 . 0 an d
Sof t I CE D r i ve r Sui t e 3 . 0
Tech n ical support is available from our Tech n ical Support Hot lin e or via
our Fron t Lin e Support Web sit e.
Tech n ical Support Hot lin e:
1-800-538-7822
Fron t Lin e Support Web Sit e:
h t t p:/ / fron t lin e.compuware.com
Th is documen t an d t h e product referen ced in it are subject t o t h e
followin g legen ds:
Access is limit ed t o aut h orized users. Use of t h is product is subject t o t h e
t erms an d con dit ion s of t h e users Licen se Agreemen t wit h Compuware
Corporat ion .
2003 Compuware Corporat ion . All righ t s reserved. Un publish ed - righ t s
reserved un der t h e Copyrigh t Laws of t h e Un it ed St at es.
U.S. GOVERNMENT RIGHTS
Use, duplicat ion , or disclosure by t h e U.S. Govern men t is subject t o
rest rict ion s as set fort h in Compuware Corporat ion licen se agreemen t an d
as provided in DFARS 227.7202-1(a) an d 227.7202-3(a) (1995), DFARS
252.227-7013(c)(1)(ii)(OCT 1988), FAR 12.212(a) (1995), FAR 52.227-19,
or FAR 52.227-14 (ALT III), as applicable. Compuware Corporat ion .
Th is product con t ain s con fiden t ial in format ion an d t rade secret s of
Compuware Corporat ion . Use, disclosure, or reproduct ion is proh ibit ed
wit h out t h e prior express writ t en permission of Compuware Corporat ion .
DriverSt udio, Soft ICE Driver Suit e, DriverNet works, DriverWorks,
TrueCoverage, an d DriverWorkben ch are t rademarks of Compuware
Corporat ion . Boun dsCh ecker, Soft ICE, an d TrueTime are regist ered
t rademarks of Compuware Corporat ion .
Acrobat
9 x t o
r ef er t o t h e Wi n d o w s 9 5 , Wi n d o w s 9 8 , an d Wi n d o w s M i l l en n i u m
( Wi n d o w s M E) o p er at i n g syst em s ( t r eat ed as a g r o u p ) ; Wi n d o w s
N T
f am i l y or Wi n d o w s N T/ 2 0 0 0 / XP w i l l r ef er t o t h e Wi n d o w s
N T, Wi n d o w s 2 0 0 0 , an d Wi n d o w s XP o p er at i n g sy st em s. ( Al so ,
u n l ess st at ed o t h er w i se, ch ar act er i st i cs o f Wi n d o w s N T d escr i b ed i n
t h i s m an u al al so ap p l y t o Wi n d o w s 2 0 0 0 an d Wi n d o w s XP. )
Soft ICE
Win dows
in t erface an d wit h soft ware debuggin g con cept s.
x i i Usi n g Sof t I CE
What This Manual Covers
Th is man ual con t ain s t h e followin g ch apt ers an d appen dixes:
Th e Using SoftICE man ual is organ ized as follows:
Ch apt er 1, Ch oosin g Your Soft ICE Version
Explain s t h e differen ces bet ween Soft ICE an d it s compan ion
debugger, Visual Soft ICE.
Ch apt er 2, Welcome t o Soft ICE
Briefly describes Soft ICE compon en t s an d feat ures. Ch apt er 2 also
explain s h ow t o con t act t h e Compuware Tech n ical Support Cen t er.
Ch apt er 3, Soft ICE Tut orial
Provides a h an ds-on t ut orial t h at demon st rat es t h e basics for
debuggin g code. Topics in clude t racin g code, viewin g t h e con t en t s of
locals an d st ruct ures, set t in g a variet y of breakpoin t s, an d viewin g
t h e con t en t s of symbol t ables.
Ch apt er 4, Loadin g Code in t o Soft ICE
Explain s h ow t o use Soft ICE Symbol Loader t o load various t ypes of
code in t o Soft ICE.
Ch apt er 5, Navigat in g Th rough Soft ICE
Describes h ow t o use t h e in t erface t h at Soft ICE provides for code
debuggin g.
Ch apt er 6, Usin g Soft ICE
Provides in format ion about t rappin g fault s, address con t ext s, usin g
INT 0x41.DOT comman ds, an d t ran sit ion s from Rin g-3 t o Rin g-0.
Ch apt er 7, Usin g Breakpoin t s
Explain s h ow t o set breakpoin t s on program execut ion , on memory
locat ion reads an d writ es, on in t errupt s, an d on reads an d writ es t o
t h e I/ O port s.
Ch apt er 8, Usin g Expression s
Explain s h ow t o form expression s t o evaluat e breakpoin t s.
Ch apt er 9, Loadin g Symbols for Syst em Compon en t s
Explain s h ow t o load export symbols for DLLs an d EXEs an d h ow t o
use symbol files wit h Soft ICE.
Ch apt er 10, Remot e Debuggin g wit h Soft ICE
Explain s h ow t o est ablish a remot e con n ect ion t o operat e Soft ICE
from a remot e PC.
Pr ef a ce x i i i
Ch apt er 11, Cust omizin g Soft ICE
Explain s h ow t o use t h e Soft ICE con figurat ion set t in gs t o cust omize
your Soft ICE en viron men t , pre-load symbols an d export s, con figure
remot e debuggin g, modify keyboard mappin gs, creat e macro-
defin it ion s, an d set t roublesh oot in g opt ion s.
Ch apt er 12, Explorin g Win dows NT
Provides a quick overview of t h e Win dows NT operat in g syst em.
Appen dix A, Error Messages
Explain s t h e Soft ICE error messages.
Appen dix B, Support ed Display Adapt ers
List s t h e display adapt ers t h at Soft ICE support s.
Appen dix C, Troublesh oot in g Soft ICE
Explain s h ow t o solve problems you migh t en coun t er.
Appen dix D, Kern el Debugger Ext en sion s
Explain s h ow t o prepare a Kern el Debugger Ext en sion for use wit h
Soft ICE.
Glossary
In dex
Convent ions Used In This Manual
Th is book uses t h e followin g con ven t ion s t o presen t in format ion :
Co n v en t i o n D escr i p t i o n
En t er In d i cat es t h at y o u sh o u l d t y p e t ex t , t h en p r ess RETURN o r
cl i ck O K.
It al i cs In d i cat es v ar i ab l e i n f o r m at i o n . Fo r ex am p l e: l i b r a r y- n a m e.
M o n o sp aced t ex t Used w i t h i n i n st r u ct i o n s an d co d e ex am p l es t o i n d i cat e
ch ar act er s y o u t y p e o n y o u r key b o ar d .
Sm al l cap s In d i cat es a u ser - i n t er f ace el em en t , su ch as a b u t t o n o r
m en u .
UPPERCASE In d i cat es d i r ect o r y n am es, f i l e n am es, key w o r d s, an d
ac r o n y m s.
Bo l d t y p ef ace Scr een co m m an d s an d m en u n am es ap p ear i n b o ld
t yp ef ace. Fo r ex am p l e:
Ch o o se I t em Br o w ser f r o m t h e To ols m en u .
x i v Usi n g Sof t I CE
How t o Use This Manual
Th e followin g t able suggest s t h e best st art in g poin t for usin g t h is man ual
based on your level of experien ce debuggin g applicat ion s.
Ot her Useful Document at ion
In addit ion t o t h is man ual, Compuware provides t h e followin g
documen t at ion for Soft ICE:
Soft ICE Comman d Referen ce
Describes all t h e Soft ICE comman ds in alph abet ical order. Each
descript ion provides t h e appropriat e syn t ax an d out put for t h e
comman d as well as examples t h at h igh ligh t h ow t o use it .
Soft ICE on -lin e Help
Soft ICE provides con t ext -sen sit ive h elp for Symbol Loader an d a h elp
lin e for Soft ICE comman ds in t h e debugger.
Co m m an d s an d f i l e
n am es
Co m p u t er co m m an d s an d f i l e n am es ap p ear i n moroacc
l,cacc. Fo r ex am p l e:
Th e Usi n g Sof t I CE m an u al ( Using SoftICE.pdf)
d escr i b es. . .
Var i ab l es Var i ab l es w i t h i n co m p u t er co m m an d s an d f i l e n am es ( f o r
w h i ch y o u m u st su p p l y val u es ap p r o p r i at e f o r y o u r
i n st al l at i o n ) ap p ear i n italic monospace type. Fo r
ex am p l e:
En t er http://servername/cgi-win/itemview.dll i n
t h e D est i n at i o n f i el d .
Co n v en t i o n D escr i p t i o n
Ex p er i en ce Su g g est ed St ar t i n g Po i n t
N o ex p er i en ce u si n g d eb u g g er s Per f o r m t h e t u t o r i al i n Ch ap t er 3 .
Ex p er i en ce w i t h o t h er d eb u g g er s Read Ch ap t er 4 , Lo ad i n g Co d e i n t o So f t ICE.
Th en r ead Ch ap t er 5 , N av i g at i n g Th r o u g h
So f t ICE.
Ex p er i en ce u si n g a p r evi o u s
r el ease o f So f t ICE
Read Ch ap t er 1 , Pr o d u c t O v er v i ew , t o
l ear n ab o u t t h i s v er si o n o f So f t ICE.
Pr ef a ce x v
On -lin e documen t at ion
Bot h t h e Using SoftICE man ual an d t h e SoftICE Command Reference are
available on lin e. To access t h e on -lin e version of t h ese books, st art
Acrobat Reader an d open t h e Using SoftICE or t h e SoftICE Command
Reference PDF files.
Cust omer Assist ance
For N on- Techni ca l I ssues
Cust omer Service is available t o an swer an y quest ion s you migh t h ave
regardin g upgrades, serial n umbers an d ot h er order fulfillmen t n eeds.
Cust omer Service is available from 8:30am t o 5:30pm EST, Mon day
t h rough Friday. Call:
In t h e U.S. an d Can ada: 1-888-283-9896
In t ern at ion al: +1 603 578-8103
For Techni ca l I ssues
Tech n ical Support can assist you wit h all your t ech n ical problems, from
in st allat ion t o t roublesh oot in g. Before con t act in g Tech n ical Support ,
please read t h e relevan t sect ion s of t h e product documen t at ion as well as
t h e Readme files for t h is product . You can con t act Tech n ical Support by:
E-Mail: In clude your serial n umber an d sen d as man y det ails as
possible t o:
mailto:[email protected]
World Wide Web: Submit issues an d access addit ion al support
services at :
http://frontline.compuware.com/nashua/
Fax: In clude your serial n umber an d sen d as man y det ails as possible
t o:
1-603-578-8401
Telephone: Teleph on e support is available as a paid* Priorit y
Support Service from 8:30am t o 5:30pm EST, Mon day t h rough Friday.
Have product version an d serial n umber ready.
In t h e U.S. an d Can ada, call: 1-888-686-3427
In t ern at ion al cust omers, call: +1-603-578-8100
*Tech n ical Support h an dles in st allat ion an d set up issues free of ch arge.
x v i Usi n g Sof t I CE
Wh en con t act in g Tech n ical Support , please h ave t h e followin g
in format ion available:
Product / service pack n ame an d version .
Product serial n umber.
Your syst em con figurat ion : operat in g syst em, n et work con figurat ion ,
amoun t of RAM, en viron men t variables, an d pat h s.
Th e det ails of t h e problem: set t in gs, error messages, st ack dumps, an d
t h e con t en t s of an y diagn ost ic win dows.
Th e det ails of h ow t o reproduce t h e problem (if t h e problem is
repeat able).
Th e n ame an d version of your compiler an d lin ker an d t h e opt ion s
you used in compilin g an d lin kin g.
1
BETA REVI EW
Ch ap t er 1
Choosing Your Soft ICE Version
Sof t I CE o r Visual So f t I CE?
Sin g le M ach in e D eb ug g in g : So f t I CE
D ual M ach in e D e b ug g in g : Visual Sof t I CE
But W h ich O n e Sh ould I U se?
Soft ICE or Visual Soft ICE?
DriverSt udio
TM
3.0 an d Soft ICE Driver Suit e
TM
3.0 in clude t wo un ique
debuggers: Soft ICE, t h e powerh ouse sin gle-mach in e debugger, an d Visual
Soft ICE, a n ew GUI-based dual-mach in e debugger. Depen din g on t h e
debuggin g t ask you are facin g, it may or may n ot be obvious wh ich
debugger you sh ould use. Th is sect ion will h elp you decide wh ich t ool
best fit s your n eeds.
In some sit uat ion s, your ch oice will be simple: some processor arch it ec-
t ures an d operat in g syst ems are on ly support ed by on e of t h e t wo debug-
gers. Table 1-1 sh ows t h e plat forms support ed by Soft ICE an d Visual
Soft ICE.
Tab l e 1 - 1 : Su p p o r t ed Pl at f o r m s
Pr o cesso r O p er at i n g Sy st em So f t ICE Vi su al So f t ICE
In t el x86 an d
compat ibles
MS-DOS, Win dows 3.0/
3.1/ 3.11, Win dows 9x
Yes No
In t el x86 an d
compat ibles
Win dows NT 3.x,
Win dows NT 4.0
Yes
In t el x86 an d
compat ibles
Win dows 2000,
Win dows XP, Advan ced
Server, .Net Server
Yes Yes
In t el It an ium1
an d It an ium2
(IA64)
Win dows XP 64bit Ed.,
.Net Server 64bit Ed.
Yes
BETA REVI EW
2 Usi n g Sof t I CE
If youre debuggin g on DOS or t h e Win dows 9x family, Soft ICE is your
on ly ch oice. If youre workin g on a 64-bit arch it ect ure, on ly Visual
Soft ICE will do. If your t arget is Win dows NT/ 2K/ XP an d t h e x86 or
compat ible arch it ect ure, eit h er debugger will work. In t h at case, read on
for an overview of t h e differen ces bet ween t h ese t wo t ools.
Single Machine Debugging: Soft ICE
Soft ICE is a sin gle-mach in e debugger, mean in g simply t h at all of it s code
run s on t h e same mach in e as t h e code bein g debugged. Wh en run n in g,
Soft ICE h as t wo basic st at es: popped up, wh ere t h e Soft ICE win dow is
displayed, an d popped down , wh ere Soft ICE is in visible an d t h e mach in e
run s as n ormal. Wh en Soft ICE is popped up, all processes on t h e
mach in e are st opped, t h e operat in g syst em does n ot run , an d Soft ICEs
comman ds are available t o t h e user. Soft ICE can pop up in respon se t o
user in put (t h e CTRL-D h ot key), breakpoin t s, except ion s, or syst em
crash es. Soft ICE is popped down by issuin g on e of t h e go or exit
comman ds, at wh ich poin t t h e Soft ICE screen is erased an d all processes
in t h e syst em resume operat ion .
Th e fact t h at Soft ICE h alt s t h e operat in g syst em wh en it is popped up
mean s t h at it must operat e wit h out makin g use of an y of t h e OS services.
Th is h as a n umber of con sequen ces. For on e, t h e Soft ICE user in t erface
does n ot resemble t h at of a n ormal Win dows applicat ion . Alt h ough
Soft ICE support s keyboard an d mouse in put , it does n ot use Win dows
fon t s, n or does it s in t erface con t ain t h e en h an cemen t s common t o
Win dows applicat ion s. In addit ion , Soft ICE can n ot assume t h at it is safe
t o perform disk access wh en ever it is popped up, so loadin g or savin g
symbol in format ion an d Soft ICE dat a is don e t h rough compan ion
applicat ion s, such as Symbol Loader (Loader32.exe).
An ot h er con sequen ce of Soft ICEs sin gle mach in e arch it ect ure is t h at t h e
in t erface is ext remely fast . All t h e dat a in t h e mach in e is direct ly
accessible t o t h e debugger, so even t asks in volvin g large amoun t s of
memory access are complet ed wit h n o n ot iceable delay.
AMD Opt eron ,
Hammer (x86-64
/ K8)
Win dows XP 64bit Ed.,
.Net Server 64bit Ed.
Yes
Tab l e 1 - 1 : Su p p o r t ed Pl at f o r m s
Pr o cesso r O p er at i n g Sy st em So f t ICE Vi su al So f t ICE
Ch ap t er 1 Ch o o si n g Yo u r So f t ICE Ver si o n 3
BETA REVI EW
Because symbols an d source code must be loaded ah ead of t ime, Soft ICE
uses a packaged format for symbols called NMS files. Symbols, t ran slat ed
from t h e DBG or PDB files out put by t h e lin ker, can be combin ed wit h all
or some of t h e source files used t o build t h e module, an d loaded in t o
Soft ICE all at on ce usin g Symbol Loader or it s comman d-lin e equivalen t ,
NMSYM. In addit ion , t h e n ew Microsoft Symbol Servers can be accessed
usin g Symbol Ret riever ut ilit y, wh ich is also capable of t ran slat in g
symbols in t o NMS files an d loadin g t h em in t o Soft ICE. Th ese t ools make
t h e n ecessary man agemen t of symbols for Soft ICE as simple as possible.
Soft ICE support s a subset of t h e available KD Ext en sion s defin ed by
Microsoft . Because t h e operat in g syst em is st opped wh en t h e debugger is
popped up, Soft ICE does n ot support all t h e available KD Ext en sion s,
sin ce it is n ot able t o make syst em calls.
Th ere are cert ain sit uat ion s wh ere debuggin g on a sin gle mach in e is
impract ical. For in st an ce, if your project is a display driver t h at is n ot yet
workin g properly, Soft ICE may n ot be able t o display it s out put . Soft ICE
does in clude support for remot e debuggin g, wh ich can be used in man y
of t h ese sit uat ion s t o redirect Soft ICEs in put an d out put over a serial or
IP n et workin g lin k. Th e remot e applicat ion in t h is case is SIRemot e,
wh ich simply act s as a dumb t ermin al for Soft ICE. Th e operat ion of t h e
debugger is n ot ot h erwise ch an ged by run n in g remot ely.
Dual Machine Debugging: Visual Soft ICE
Visual Soft ICE, on t h e ot h er h an d, is a dual-mach in e debugger. Th e user
in t erface an d n early all of t h e in t erpret ive code run s on t h e mast er
mach in e; t h e code t o be debugged run s alon gside a small core of
debuggin g fun ct ion s on t h e t arget mach in e. Mast er an d t arget
mach in es are con n ect ed via a t ran sport , wh ich can be a serial cable, IP
n et work in t erface device, or IEEE 1394 con n ect ion .
Because t h e mast er mach in e is n ever st opped by t h e debugger, Visual
Soft ICEs user in t erface is free t o t ake advan t age of all of t h e usual
Win dows UI devices. Visual Soft ICEs user in t erface will be in st an t ly
familiar t o an yon e wh o h as used soph ist icat ed Win dows programs
before; in addit ion , t h e comman d set h as been duplicat ed (wit h a few
except ion s) from t h e origin al Soft ICE, so Soft ICE users sh ould fin d much
t h at is familiar about Visual Soft ICE as well.
Visual Soft ICE is also able t o load symbol in format ion on -t h e-fly at an y
t ime in cludin g ret rievin g symbols from a Symbol Server sit e so t h is
t ask is gen erally h an dled aut omat ically by t h e debugger. Th is frees t h e
BETA REVI EW
4 Usi n g Sof t I CE
user from t h e n ecessit y of man ually specifyin g symbol files t o be loaded
by t h e debugger, alt h ough t h at opt ion is st ill available in Visual Soft ICE.
Visual Soft ICE support s loadin g an d examin in g crash dump an d
min idump files direct ly, a feat ure n ot foun d in Soft ICE. (DriverSt udios
DriverWorkben ch Applicat ion also support s t h is).
Visual Soft ICE also provides complet e support for Microsoft s KD
Ext en sion s, in cludin g t h ose t h at will n ot run on Soft ICE for arch it ect ural
reason s.
But Which One Should I Use?
If your project falls in t o t h e wide overlap bet ween Soft ICE an d Visual
Soft ICE, an d youve n ever used Soft ICE before, youre probably st ill
won derin g wh ich debugger is best for you. Obviously, t h eres n ot always
a sin gle righ t an swer t o t h is quest ion , but in t h e remain der of t h is sect ion
well t ry t o cover some of t h e scen arios wh ere on e debugger migh t be
favored over t h e ot h er. Were down t o guidelin es h ere, t h ough ; devot ees
of eit h er debugger will be quick t o poin t out t h at t h eir favorit e st ill h as
advan t ages, even in cases wh ere t h e ot h er migh t appear t o be t h e bet t er
ch oice. We en courage you t o t ry t h em bot h , an d con sider t h em t wo
similar but dist in ct t ools in your debuggin g t oolbox.
If you prefer a full-feat ured Win dows GUI, youll probably wan t t o
use Visual Soft ICE. Soft ICEs in t erface is fast an d powerful, but it
doesn t h ave a Win dows GUI, an d it t akes some get t in g used t o.
If youre debuggin g a n et work driver, an d youre con cern ed t h at
Visual Soft ICEs IP t ran sport layer migh t affect t h e result s, use
Soft ICE. Con versely, if youre debuggin g a video drivers mode
in it ializat ion , or a Direct 3D or st reamin g app or driver, t ry Visual
Soft ICE or run Soft ICE remot ely.
If you wan t direct access t o Boun dsCh ecker
, an d Crash Dump
files, an d fin ally debug t h at mach in e wit h Soft ICE.
N o t e : In o r d er t o d eb u g t h e r em o t e m ach i n e t h r o u g h t h e D r i v er St u d i o
Rem o t e D at a ex t en si o n , y o u w i l l n eed t o h ave ei t h er t h e UN D o r t h e
Sp eci al i zed n et w o r k d r i v er s i n st al l ed .
Th e screen sh ot below sh ows a t ypical debuggin g en viron men t .
Fi g u r e 1 0 -1 . Ty p i cal D eb u g g i n g En v i r o n m en t Scr een
From t h is pict ure you can see t h at t h ere are four main t ypes of icon s:
Ch ap t er 1 0 Rem o t e D eb u g g i n g w i t h So f t ICE 1 4 9
BETA REVI EW
By righ t -clickin g on an icon , you can ch oose t o ch an ge t h e opt ion s, st art
Soft ICE, or reboot t h e mach in e. By default , t h e folder view con t ain s
st at ic in format ion from a sn apsh ot at a given poin t in t ime.
It is possible t o refresh t h e display man ually by ch oosin g View Refresh
or specify an in t erval of t ime. To set t h e t ime in t erval, first righ t -click on
t h e DriverSt udio Remot eDat a icon . Th en , ch oose Propert ies, an d select
your Refresh In t erval.
Th is icon mean s t h at DriverSt udio is run n in g an d you
can con figure, reboot , an d view t h e out put from t h e
ot h er DriverSt udio Tools, as well as st art Soft ICE.
Th is icon sign ifies t h at Soft ICE is run n in g wit h t h e
n et work en abled on t h is part icular mach in e. If a red
t it le bar is displayed, it sign ifies t h at someon e is already
con n ect ed t o t h e mach in e an d t h at an at t empt t o debug
t h at mach in e will fail. If t h ere is n o red t it le bar visible,
you can con n ect t o it by righ t -clickin g t h e folder an d
select in g Con n ect t o Soft ICE.
Th is icon sign ifies t h at Soft ICE is curren t ly popped-up
on t h is part icular mach in e. A red t it le bar on t h e icon
mean s t h at it is bein g debugged by someon e. If t h ere is
n o red t it le bar visible, you can con n ect t o it by righ t -
clickin g t h e folder an d select in g Con n ect t o Soft ICE.
Th is blue screen icon sign ifies t h e ban e of every
developer t h e dreaded blue screen of deat h . A red
border aroun d t h e blue screen icon mean s t h at
someon e is con n ect ed t o t h is mach in e an d is debuggin g
it . A gray border in dicat es t h at you can con n ect t o it by
righ t -clickin g t h e folder an d select in g Con n ect t o
Soft ICE.
BETA REVI EW
1 5 0 Usi n g Sof t I CE
Remot e Debugging Det ails
Each t ype of n et workin g h as cert ain requiremen t s an d may require
preparat ion st eps. Please be sure t o follow all direct ion s closely.
Speci a l i zed N et w or k Dr i ver s
D e scr ip t io n
Th e specialized n et work drivers offer t h e best in all-aroun d performan ce
wit h min imal in t rusion upon t h e syst em an d n et work st acks. However,
t h eir limit at ion s may preclude you from usin g t h em. Th e t wo main
limit at ion s are:
1 Th ey can n ot be used for early boot -mode debuggin g, an d
2 You must use on e of t h e t h ree support ed classes of n et work cards.
Th e specialized n et work drivers will run on all Win dows NT based
operat in g syst ems as well as t h e Win 9x based operat in g syst ems.
H ar d w ar e Req uir em en t s
A n et work card based on an y of t h e t h ree classes of n et work cards:
Novell NE2000 series of cards
3com 3c90x series of cards, in cludin g t h e 3C905, 3C900, 3C920,
3C921, an d all varian t s of t h ose cards
In t el E100 series of cards.
I n st allat ion
In st allat ion an d removal is st raigh t forward.
To in st all t h e specialized n et work drivers:
1 Go t o Control Panel.
2 Ch oose Networking and Dial-up Connections.
3 Righ t click on Local Area Connection.
4 Ch oose properties.
5 Click on Configure.
6 Click on Driver.
Ch ap t er 1 0 Rem o t e D eb u g g i n g w i t h So f t ICE 1 5 1
BETA REVI EW
7 Click on Update Driver.
8 Click on Next.
9 Ch oose Specify a location
1 0 Browse t o your \ program files\ compuware\ driverst udio\ soft ice\ n et -
work\ folder, an d ch oose t h e appropriat e subfolder. From h ere,
ch oose t h e appropriat e.in f file: i.e., n t 4, win 9x (oemxxxx.in f) or file-
n ame.in f (for Win 2K an d lat er plat forms).
If an y messages appear regardin g Driver Sign in g, t h ese messages
can be safely ign ored.
1 1 Aft er in st allat ion is complet e, reboot your comput er.
Est ab lish in g a Con n ect io n
Est ablish in g a con n ect ion for t h e specialized n et work drivers is iden t ical
t o t h at for t h e Un iversal Net work Driver. (See Un iversal Net work
Driver on page 151.)
Rem o val
Use t h e followin g procedure t o un in st all t h e specialized n et work drivers.
1 Go t o Control Panel.
2 Ch oose Networking and Dial-up Connections.
3 Righ t -click on Local Area Connection.
4 Ch oose properties.
5 Click on Configure.
6 Click on Driver.
7 Click on Update Driver.
8 Click on Next.
9 Ch oose Search for a suitable driver for my device. Follow t h e
prompt s from t h ere.
Uni ver sa l N et w or k Dr i ver
D e scr ip t io n
Th e Un iversal Net work Driver (UND) works on all PCI based n et work
cards for t h e Win dows 2000, Win dows XP (an d lat er) Operat in g Syst ems.
Two drivers are supplied wit h t h e UND. Th e first driver allows Soft ICE t o
BETA REVI EW
1 5 2 Usi n g Sof t I CE
in t eract wit h t h e n et workin g card. Th is driver preven t s n ormal n et work
t raffic, e-mail, web browsin g, or file sh arin g t o occur on t h at NIC card.
To get aroun d t h is limit at ion we suggest usin g a secon d n et work card
wh ich is dedicat ed t o Soft ICE. If t h is is impract ical, we provide an
addit ion al driver called t h e Soft ICE Virt ual NIC (SIVNIC). Th is driver
allows t h e NIC t o be sh ared bet ween Soft ICE an d n ormal Win dows
n et workin g.
N o t e : Yo u w i l l n o t i ce a d ecr ease i n Wi n d o w s n et w o r ki n g p er f o r m an ce
w h en u si n g t h e SIVN IC. As su ch , i t i s su g g est ed t h at y o u i n st al l a
seco n d n et w o r k car d t h at i s f o r t h e ex cl u si ve u se o f So f t ICE.
H ar d w ar e Req uir em en t s
Th e on ly h ardware requiremen t is a PCI-based Net work Card on t h e
target mach in e. Th e h ost can h ave an y t ype of n et work card (i.e., most
built -in lapt op NIC cards are PCI based).
N o t e : At t h i s t i m e t h er e i s n o su p p o r t f o r PCM CIA o r USB n et w o r k car d s.
I n st allat ion
SIDN Installation. In st allin g t h e SIDN driver (t h e base driver used by
Soft ICE for debuggin g) is don e t h rough t h e supplied UNDSETUP.EXE
applicat ion wh ich is locat ed in c:\ program files\ compuware\ driverst u-
dio\ soft ice\ n et work\ un d. Run t h is applicat ion an d ch oose t h e n et work
card t h at you wish t o at t ach t o t h e UND. Follow t h e prompt s an d reboot
your mach in e.
Ch ap t er 1 0 Rem o t e D eb u g g i n g w i t h So f t ICE 1 5 3
BETA REVI EW
Fi g u r e 1 0 -2 . N et w o r k Set u p Scr een
SIVNIC Installation. If Win dows n et workin g is required on t h e t arget
comput er (an d it is n ot pract ical t o in st all a secon d n et work card), you
will n eed t o in st all t h e SIVNIC.
1 Open t h e Con t rol Pan el an d select Add/ Remove Hardware.
2 Wh en t h e wizard open s, select Add/ Troubleshoot, click Next, select
Add a new device, t h en specify t h at you wan t t o select t h e device
from a list .
3 Wh en t h e list of h ardware t ypes appears, select Network adapter,
click Have disk, an d browse t o:
Program Files\Compuware\DriverStudio\SoftICE\Network\UND\VNIC
4 Select sivnic.inf from t h e list , an d con t in ue t h rough t h e remain in g
prompt s.
N o t e : If y o u r u n i n t o p r o b l em s w i t h t h e VN IC, p r ess Esc d u r i n g t h e b o o t
p r o c ess w h en t h e UN D d r i ver p r o m p t s y o u . Th i s w i l l ab o r t t h e
l o ad i n g o f t h e UN D , as w el l as t h e VN IC.
5 On ce t h e SIVNIC is in st alled, reboot your comput er.
BETA REVI EW
1 5 4 Usi n g Sof t I CE
Rem o val
To uninstall the SIVNIC, simply delet e it from t h e device list , or use t h e
Remove opt ion in t h e Hardware Wizard.
To uninstall the UND, rerun t h e UNDSETUP.EXE program an d ch oose
t h e Un in st all Opt ion .
Est ab lish in g a N et w o r k Con n ect io n
N o t e : Pr esen t ed h er e ar e t h e easi est m et h o d s o f set t i n g u p a co n n ect i o n
b et w een t h e h o st an d t ar g et co m p u t er s. Th er e ar e ad d i t i o n al
o p t i o n s su ch as p assw o r d p r o t ect i n g , IP l i m i t i n g , g at ew ay an d
su b n et m asks t h at can b e sp eci f i ed . Pl ease r ef er t o t h e Sof t I CE
Com m a n d Ref er en ce f o r f u l l d et ai l s. Al so , at t h e en d o f t h i s ch ap t er
ar e ad d i t i o n al d et ai l s o n t h e n et w o r ki n g co m m an d s u sed w i t h
So f t I CE.
TARGET SIDE: On t h e t arget comput er, you h ave several opt ion s for
st art in g Soft ICE n et workin g. You can :
1 Ch oose Enable Network Support from t h e Soft ICE Set t in gs-Net work
Debuggin g dialog. Th e easiest set up opt ion is t o accept all t h e
default s. Wh en Soft ICE is rest art ed, n et workin g will be en abled wit h
t h e opt ion s on t h is screen .
2 From t h e comman d lin e You can st art an d st op n et workin g from
t h e comman d lin e wit h in Soft ICE. Th e easiest way t o st art n et work-
in g is n et set up dh cp. To st op n et workin g, use n et st op an d t o
rest art it n et set up dh cp or n et st art .
3 From t h e in it st rin g You can specify t h e same comman d lin es as in
St ep 2 above.
HOST SIDE: On t h e h ost side, you h ave t wo ways t o con n ect .
To st art n et workin g on t h e t arget comput er wit h t h e default options:
1 Click on t h e DriverSt udio Remot e Dat a Namespace.
2 Righ t -click on t h e comput er you wish t o debug.
3 Ch oose Connect to SoftICE.
OR
1 Go t o a comman d prompt .
2 Run t h e comman d lin e equivalen t for con n ect in g t o a Soft ICE t arget .
3 Ch an ge t o t h e Soft ICE direct ory.
Ch ap t er 1 0 Rem o t e D eb u g g i n g w i t h So f t ICE 1 5 5
BETA REVI EW
4 If you st art ed Soft ICE debuggin g on t h e t arget wit h t h e default
opt ion s, you can con n ect t o t h e mach in e by t ypin g in t h e followin g
comman d:
siremote [machinename]
N o t e : If y o u d o n t kn o w t h e m ach i n e n am e, y o u can su p p l y t h e IP ad d r ess
o f t h e m ach i n e, i n st ead . To g et t h e IP ad d r ess f r o m t h e m ach i n e w i t h
So f t I CE, t y p e n et st at u s f r o m t h e So f t ICE co m m an d l i n e an d n o t e
t h e IP ad d r ess.
If you st art ed n et work debuggin g on t h e Soft ICE t arget wit h addit ion al
opt ion s such as password, or if you n eed t o specify a default gat eway or
subn et mask, you will n eed t o use t h e SIREMOTE comman d lin e ut ilit y
wit h t h e appropriat e opt ion s. (See The SIREMOTE Utility (Host Computer)
page 158, or t ype siremote /help on t h e comman d lin e.)
Ser i a l Connect i on
D e scr ip t io n
Serial con n ect ion offers t h e easiest of t h e remot e con n ect ion opt ion s. It s
performan ce is quit e good at a baud rat e of 57600 an d n ear sin gle-
mach in e performan ce rat e of 115200 baud.
H ar d w ar e Req uir em en t s
Th ere are t wo Serial Con n ect ion h ardware requiremen t s:
1 A serial port dedicat ed t o Soft ICE use on bot h t h e h ost an d t arget
comput ers.
2 A n ull modem cable.
N o t e : Th ese cab l es a r ead i l y av ai l ab l e at y o u r l o cal co m p u t er st o r e. If y o u
w i sh t o m ake o n e y o u r sel f , see t h e ap p en d i x f o r sp eci f i cs o n cr eat i n g
a n u l l m o d em cab l e.
I n st allat ion
To in st all a serial con n ect ion , perform t h e followin g t wo st eps:
1 Con n ect t h e cable bet ween t h e t wo mach in es. You may wan t t o con -
firm t h at t h e con n ect ion bet ween t h e t wo mach in es is valid by usin g
an y dumb t ermin al program. (HyperTerm sh ips wit h Win dows.)
2 Make sure t h at your con n ect ion opt ion s are set t o t h e appropriat e
set t in gs. If you are run n in g Win 2K or Win XP, you will n eed t o use
t h e Soft ICE Set t in gs ut ilit y t o ch oose wh ich comport you will be
BETA REVI EW
1 5 6 Usi n g Sof t I CE
usin g for debuggin g. For t h e followin g example, we will be remot e
debuggin g on COM1 at a speed of 115200 baud.
Rem o val
Th ere are n o special requiremen t s t o un in st all ot h er t h an removin g t h e
cable, if so desired. If you are run n in g Win 2K or Win XP (an d lat er), you
will wan t t o ch an ge Serial Con n ect ion in t h e Soft ICE Set t in gs dialog back
t o None.
Est ab lish in g a Con n ect io n
To est ablish a con n ect ion you must first t urn on t h e serial debuggin g
opt ion wit h in Soft ICE on t h e t arget comput er (as sh own in t h e followin g
figure).
Fi g u r e 1 0 -3 . Est ab l i sh i n g a Co n n ect i o n
Now, con n ect t o t h e t arget from t h e h ost comput er.
TARGET SIDE: En able serial debuggin g usin g on e of t h e followin g
met h ods:
Click on t h e Aut o Con n ect (via n ull modem) opt ion on t h e Serial
Debuggin g page of Soft ICE set t in gs. (You will n eed t o reboot your
mach in e for t h e ch an ges t o t ake effect .)
Ch ap t er 1 0 Rem o t e D eb u g g i n g w i t h So f t ICE 1 5 7
BETA REVI EW
OR
From t h e Soft ICE comman d lin e t ype in NET COMx baudrat e
(wh ere COMx is on e of four possible port s COM1, COM2, COM3, or
COM4 an d baudrate is on e of four speeds 19200, 38400, 57600, or
115200).
OR
Add t h e NET COMx baudrate t o t h e in it lin e on t h e Gen eral t ab.
HOST SIDE: En able serial debuggin g as follows:
1 From t h e t arget side, you will n eed t o open up a comman d prompt
an d n avigat e t o t h e Soft ICE direct ory.
2 Execut e t h e SIREMOTE COMx baudrat e (wh ere COMx is t h e comport
t o wh ich t h e cable is con n ect ed an d baudrate is your con n ect speed.)
M odem
D e scr ip t io n
You can operat e Soft ICE remot ely over a modem. Th is is part icularly
useful for debuggin g program fault s t h at occur at an en d-user sit e t h at
you can n ot reproduce locally.
Wh en you operat e Soft ICE over a modem, t h e local PC run s bot h Soft ICE
an d t h e applicat ion you are debuggin g. Th e remot e PC beh aves as a
dumb t ermin al t h at serves t o display t h e out put for your Soft ICE session
an d t o accept keyboard in put . Soft ICE does n ot provide mouse support
for t h e remot e comput er.
H ar d w ar e Req uir em en t s
Soft ICE h as t h e followin g h ardware requiremen t s for t h e modems you
use t o con n ect t h e local an d remot e syst ems:
Th e modem must accept t h e in dust ry-st an dard AT comman ds such
as ATZ an d ATDT, an d ret urn s st an dard result codes such as RING an d
CONNECT.
Th e modem must execut e a reliable error det ect in g an d correct in g
prot ocol such as V.42 or MNP5. Th is is import an t because t h e com-
mun icat ion prot ocol used by Soft ICE does not include error detec-
tion.
BETA REVI EW
1 5 8 Usi n g Sof t I CE
Est ab lish in g a Con n ect io n
Wh en usin g Soft ICE over a modem, eit h er t h e local or remot e part y can
dial t o in it iat e a con n ect ion .
Do t h e followin g t o est ablish a con n ect ion wh ere t h e local Soft ICE user
(you) dials t h e remot e user:
1 Have t h e remot e user run SIREMOTE.EXE.
2 In voke t h e DIAL comman d on your mach in e.
A con n ect ion is est ablish ed an d t h e remot e user is in con t rol of
Soft ICE.
Do t h e followin g t o est ablish a con n ect ion wh ere t h e remot e user dials
t h e local Soft ICE user:
1 Local Soft ICE user in vokes t h e ANSWER comman d t o prepare t o
an swer a call.
2 Remot e user dials out usin g SIREMOTE.EXE..
A con n ect ion is est ablish ed an d t h e remot e user is in con t rol of
Soft ICE.
Rem o val
Th ere are n o special requiremen t s t o un in st all t h e modem con n ect ion .
SIREMOTE Ut ilit y ( Host Comput er)
Th e support applicat ion , siremote.exe, is t h e fron t en d for all of Soft ICE
remot e debuggin g opt ion s. Wh en usin g t h e DriverSt udio Remot e Dat a
n amespace ext en sion t o con n ect t o Soft ICE on a remot e t arget , you are
essen t ially issuin g a blin d comman d of siremot e ipaddressoft arget .
Th e comman d lin e opt ion s for siremot e.exe vary based upon wh at t ype
of con n ect ion you are usin g.
Serial Con n ect ion Th e on ly opt ion s are COMport an d Baudrat e. For
example:
Siremote COM1 115200 Th is will con n ect t o a remot e t arget wit h
t h e h ost s com port of COM1 at a speed of 115200.
For n et work con n ect ion s, t h e comman ds are similar. For example:
Siremote cartman Th is will con n ect t o t h e remot e t arget n amed
cart man .
Ch ap t er 1 0 Rem o t e D eb u g g i n g w i t h So f t ICE 1 5 9
BETA REVI EW
Siremote 192.168.0.10 secret Th is will con n ect t o t h e t arget
mach in e wit h an IP address of 192.168.0.10 an d a password of
secret .
NET Command ( Target Comput er)
On t h e t arget comput er, as specified earlier, you can en able remot e
debuggin g eit h er t h rough t h e user in t erface, or from t h e comman d lin e
wit h in Soft ICE. Th e easiest met h od is t o use t h e Soft ICE Set t in gs con fig-
urat ion ut ilit y.
N o t e : An y ch an g es m ad e h er e w i l l t ake ef f ect t h e n ex t t i m e So f t ICE st ar t s.
Th i s m o st o f t en m ean s o n t h e n ex t r eb o o t .
On lin e Help can be viewed by issuin g t h e NET HELP comman d from
wit h in Soft ICE.
:net help
NET SETUP <IP address|DHCP> [MASK=<subn et mask>] [GATEWAY=<IP
address>] [ALLOW=<IP address| ANY>]
[PASSWORD=<password>]
NET START <IP address| DHCP> [MASK=<subn et mask>] [GATEWAY=<IP
address>]
NET COMx [baud-rat e]
NET ALLOW <IP address| ANY> [AUTO] [PASSWORD=<password>]
NET PING <IP address>
NET RESET - Reset t h e curren t con n ect ion
NET DISCONNECT - Reset t h e curren t con n ect ion
NET STOP - Close con n ect ion an d disable n et workin g
NET HELP
NET STATUS
BETA REVI EW
1 6 0 Usi n g Sof t I CE
1 6 1
BETA REVI EW
Ch ap t er 1 1
Cust omizing Soft ICE
M od if yin g Sof t I CE I n it ializ at io n Set t in g s
M od if yin g Gen er al Set t in g s
Pr e- load in g Sym b ols an d So urce Co d e
Pr e- load in g Exp o r t s
Co n f ig ur in g Rem ot e D eb ug g in g
M od if yin g Ke yb oar d M ap p in g s
W o r kin g w it h Per sist en t M acr o s
Se t t in g Tr oub lesh o ot in g O p t ion s
Modifying Soft ICE Init ializat ion Set t ings
Soft ICE provides a variet y of user-defin ed set t in gs t h at det ermin e your
debuggin g en viron men t at in it ializat ion . Th ese set t in gs are cat egorized as
follows:
Gen eral Provides a variet y of useful Soft ICE set t in gs, in cludin g an
in it ializat ion st rin g of comman ds t h at aut omat ically execut es wh en
you st art Soft ICE.
Symbols Specifies .NMS symbol files t o load at in it ializat ion for
debuggin g device drivers.
Export s Specifies DLLs an d EXEs from wh ich t o load export sym-
bols at in it ializat ion .
Remot e Debuggin g: In t ern et Con t rol Defin e paramet ers for in t er-
n et access remot e debuggin g over st an dard TCP/ IP et h ern et con n ec-
t ion .
Remot e Debuggin g: Dial up Con t rol Set s a default t eleph on e n um-
ber an d modem in it ializat ion st rin gs for remot e debuggin g over a
serial port .
BETA REVI EW
1 6 2 Usi n g Sof t I CE
Keyboard Mappin gs Assign s Soft ICE comman ds t o fun ct ion keys.
Macro Defin it ion s Defin es your own comman ds t o use wit h in
Soft ICE.
Troublesh oot in g Provides solut ion s t o pot en t ial problems.
To modify t h e Soft ICE in it ializat ion set t in gs, do t h e followin g:
1 St art Symbol Loader.
2 From wit h in Symbol Loader, ch oose SOFTICE INITIALIZATION SET-
TINGS... from t h e Edit men u.
Soft ICE displays t h e followin g Soft ICE In it ializat ion Set t in gs win dow.
Fi g u r e 1 1 -1 . So f t ICE In i t i al i zat i o n Set t i n g s
3 Select t h e t ab t h at represen t s t h e set t in gs you wan t t o modify.
4 Modify t h e set t in gs an d click OK.
N o t e : Th e f o l l o w i n g sec t i o n s d escr i b e t h ese set t i n g s.
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 6 3
BETA REVI EW
5 Reboot your comput er an d run Soft ICE t o apply your ch an ges.
Modifying General Set t ings
Modify t h e Gen eral Soft ICE in it ializat ion set t in gs as follows:
I ni t i a l i za t i on St r i ng
INITIALIZATION STRING execut es a series of comman ds wh en Soft ICE in it ial-
izes. By default , INITIALIZATION STRING con t ain s t h e X (exit ) comman d
delimit ed wit h a semi-colon , as follows:
X;
You migh t wan t t o add addit ion al comman ds t o INITIALIZATION STRING t o
ch an ge t h e Ct rl-D h ot key sequen ce t h at pops up t h e Soft ICE win dow, t o
ch an ge Soft ICE win dow sizes, t o in crease t h e n umber of lin es displayed
by Soft ICE, or t o use t h e Serial comman d for remot e debuggin g. If you
are debuggin g a device driver, you migh t wan t t o remove t h e X
comman d (or t h e semicolon t h at follows it ) t o preven t Soft ICE from
aut omat ically exit in g upon in it ializat ion .
To add comman ds t o INITIALIZATION STRING, t ype on e or more semicolon
delimit ed comman ds before t h e X (exit ) comman d. Comman ds are
processed in t h e order in wh ich you place t h em. Th us, placin g a
comman d aft er t h e X comman d, mean s t h e comman d does n ot execut e
un t il you pop up t h e Soft ICE win dow. If you t ype a comman d wit h out a
semicolon , Soft ICE loads t h e comman d in t o t h e Comman d win dow, but
does n ot execut e it .
Th e followin g in it ializat ion st rin g swit ch es Soft ICE t o 50-lin e mode,
ch an ges t h e h ot key sequen ce t o Alt -Z, t oggles t h e Regist er win dow on ,
an d exit s from Soft ICE:
LINES 50;ALTKEY ALT Z;WR;X;
N o t e : If y o u t y p e a st r i n g t h at ex ceed s t h e w i d t h o f t h e In i t i al i zat i o n f i el d ,
t h e f i el d au t o m at i cal l y scr o l l s h o r i zo n t al l y t o al l o w y o u t o v i ew t h e
i n f o r m at i o n as y o u en t er i t .
Hi st or y Buf f er Si ze
HISTORY BUFFER SIZE det ermin es t h e size of t h e Soft ICE h ist ory buffer. By
default , t h e Hist ory buffer size is 256KB.
Th e Soft ICE h ist ory buffer con t ain s all t h e in format ion displayed in t h e
Comman d win dow. Th us, savin g t h e Soft ICE h ist ory buffer t o a file is
BETA REVI EW
1 6 4 Usi n g Sof t I CE
useful for dumpin g large amoun t s of dat a, disassemblin g code, loggin g
breakpoin t s wit h t h e BPLOG comman d, an d list in g Win dows messages
logged by t h e BMSG comman d. Refer t o Saving the Command Window History
Buffer to a File on page 75.
Tr a ce Buf f er Si ze ( W i nd ow s 9 x Onl y)
Th is set t in g det ermin es t h e size of t h e t race buffer. Th e t race buffer can
main t ain back t race for t h e BPR an d BPRW comman ds. By default , TRACE
BUFFER SIZE is set t o 8 KB.
Tot a l RAM (W i ndow s 9 x Onl y)
Th is set t in g in dicat es t h e amoun t of ph ysical memory in st alled in your
syst em. Set TOTAL RAM t o a value equal t o or great er t h an t o t h e amoun t
of memory on your syst em.
Due t o subt le arch it ect ural differen ces bet ween syst ems, Soft ICE can n ot
det ect t h e amoun t of ph ysical memory in st alled in your comput er un der
Win dows 9x. To map t h e relat ion sh ip bet ween lin ear an d ph ysical
memory, Soft ICE uses a default value of 128 MB. Wh ile t h is value is
reason able for most curren t developmen t syst ems wit h 128 MB or less of
ph ysical memory, t h is does n ot work correct ly on syst ems wit h larger
ph ysical address spaces. Th is is due t o t h e fact t h at appropriat e dat a st ruc-
t ures for memory pages above 128 MB are n ot creat ed.
If your syst em con t ain s less t h an 128 MB of ph ysical memory, you can
save a small amoun t of memory by set t in g t h is field t o t h e righ t value.
Th e memory savin gs result because fewer dat a st ruct ures are n eeded t o
map ph ysical memory.
Di spl a y Di a gnost i c M essa ges
DISPLAY DIAGNOSTIC MESSAGES det ermin es wh et h er or n ot Soft ICE t urn s on
verbose mode t o display addit ion al in format ion , such as module loadin g
an d un loadin g, in t h e Comman d win dow. By default , DISPLAY DIAGNOSTIC
MESSAGES is t urn ed on .
Tr a p N M I
TRAP NMI det ermin es wh et h er Non -maskable in t errupt (NMI) t rappin g is
t urn ed on or off. By default , TRAP NMI is t urn ed on . NMI t rappin g is
useful if you h ave a mean s of gen erat in g an NMI, such as a breakout
swit ch . Gen erat in g an NMI allows you t o en t er Soft ICE even wh en all
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 6 5
BETA REVI EW
in t errupt s are disabled. Simple ISA-based breakout swit ch es are available.
Con t act Compuware for more in format ion .
Low erca se Di sa ssembl y
LOWERCASE DISASSEMBLY det ermin es wh et h er or n ot Soft ICE uses lower-
case let t ers for disassemblin g in st ruct ion s. By default , LOWERCASE DISAS-
SEMBLY is t urn ed off.
Pre-loading Symbols and Source Code
Use t h e Symbols in it ializat ion set t in gs in con jun ct ion wit h t h e Module
Tran slat ion set t in gs t o pre-load symbols an d source code wh en you st art
Soft ICE. Pre-loadin g symbols an d source code is useful for debuggin g
device drivers.
To pre-load symbols or source code, do t h e followin g:
1 In t h e Module Tran slat ion set t in gs, select SYMBOLS AND SOURCE CODE if
you wan t your source code loaded in addit ion t o t h e symbols.
2 Select PACKAGE SOURCE WITH SYMBOL TABLE.
3 In Symbol Loader, ch oose Tran slat e from t h e Module men u t o t ran s-
lat e t h e module t o a .NMS symbol file.
Ti p You ca n u se t h e
Sym b o l Lo a d er
co m m a n d - l i n e u t i l i t y,
N M SYM , t o sp eci f y t h e
ou t p u t f i l e n a m e.
4 Use t h e Symbols Soft ICE In it ializat ion set t in gs t o add your .NMS
symbol file t o t h e Symbols list . Th e followin g sect ion describes h ow
t o do t h is.
N o t e : N o r m al l y, y o u r . N M S sy m b o l f i l e h as t h e sam e b ase n am e as t h e f i l e
y o u t r an sl at ed . Wi t h Wi n d o w s 9 x , So f t ICE can n o t p r e- l o ad f i l es w i t h
l o n g f i l e n am es, b ecau se So f t I CE i s i n r eal - m o d e D O S w h en i t i n i t i al -
i zes. If y o u r m o d u l e i s a l o n g f i l e n am e, cr eat e t h e . N M S f i l e, r en am e
t h e . N M S f i l e t o an ei g h t - ch ar act er n am e w i t h t h e ex t en si o n . N M S,
an d sel ect t h e r en am ed . N M S f i l e w h en y o u ad d i t t o t h e sy m b o l s
l i st .
BETA REVI EW
1 6 6 Usi n g Sof t I CE
Addi ng Symbol Fi l es t o t he Symbol s Li st
Ti p W h en you sel ect
PACKAGE SO U RCE W I TH
SYM BO L TABLE, so u r ce
f i l es a r e p a r t o f t h e
. N M S sym b ol f i l e. Th u s,
t h er e a r e n o r est r i ct i on s
on sou rce f i l e n a m e
l en g t h s even w i t h i n
Wi n d ow s 9 x.
From t h e Symbols t ab in t h e Soft ICE In it ializat ion set t in gs, do t h e follow-
in g:
1 Click ADD.
Soft ICE displays a browse win dow for you t o locat e t h e .NMS files
t h at con t ain t h e symbols an d source code you wan t t o pre-load.
2 Select on e or more .NMS symbol files an d click OK.
3 Every t ime you modify your source code, ret ran slat e your module t o
creat e a n ew version of t h e .NMS symbol file.
Removi ng Symbol s a nd Source Code Pr e- Loa di ng
To preven t Soft ICE from pre-loadin g t h e symbols or source code associ-
at ed wit h a part icular file, select t h e file in t h e symbols list an d click
REMOVE.
Reser vi ng Symbol M emor y
SYMBOL BUFFER SIZE specifies, in kilobyt es, t h e amoun t of memory t o
reserve for st orin g cert ain t ypes of debug in format ion (for example, lin e
n umber in format ion ). Wit h Soft ICE for Win dows 9x, t h is memory region
also serves as a buffer for h oldin g .NMS images at boot t ime. By default ,
Soft ICE reserves 1024KB for Win dows 9x an d 512KB for Win dows NT/
2000/ XP.
Typically 512KB is adequat e. However, you may n eed t o in crease t h e
SYMBOL BUFFER SIZE un der t h e followin g circumst an ces:
If you are debuggin g large programs, use 1024KB or more.
If you are usin g Win dows 9x, an d you are loadin g symbols at boot
t ime, det ermin e t h e t ot al size of all t h e .NMS files t h at are loaded at
boot t ime an d set t h e SYMBOL BUFFER SIZE t o t h is n umber.
To det ermin e h ow much symbol memory is available, use t h e TABLE
comman d. Not e t h at most symbol in format ion is st ored in dyn amically-
allocat ed memory.
Pre-loading Export s
Use t h e Export in it ializat ion set t in gs t o select files from wh ich Soft ICE
can ext ract export in format ion upon Soft ICE in it ializat ion . Ext ract in g
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 6 7
BETA REVI EW
export in format ion is useful for debuggin g DLLs wh en n o debuggin g
in format ion is available.
Ext r act in g Exp o r t I n f o r m at ion
To select on e or more files from wh ich t o ext ract export in format ion , do
t h e followin g:
1 Click ADD. Soft ICE displays a browse win dow for you t o locat e t h e
files.
N o t e : If y o u ar e co n n ect ed t o a n et w o r k, y o u can cl i c k NETWORK t o d i sp l ay
t h e co n t en t s o f n et w o r ked d r i v es.
2 Select on e or more files from wh ich t o ext ract t h e in format ion an d
click OK.
3 Soft ICE places t h e files you select ed in t h e Export s list .
Rem o vin g Files f r om t h e Exp o r t s List
To remove a file from t h e Export s list , select t h e file an d click REMOVE.
Configuring Remot e Debugging
Remot e Soft ICE allows you t o use a st an dard in t ern et con n ect ion t o
remot ely con t rol Soft ICE. Th is allows great er flexibilit y an d easier access
for debuggin g fun ct ion s. Remot e Soft ICE is support ed by Win dows 9x
an d Win dows NT/ 2000/ XP.
Requi r ement s f or Remot e Sof t I CE Suppor t
Th e mach in e t h at run s Soft ICE is referred t o as t h e target mach in e.
Th e t arget mach in e requires a support ed et h ern et adapt er t h at is con -
n ect ed t o t h e local IP n et work.
Curren t ly support ed Et h ern et adapt ers are:
NE2000 an d compat ibles (use NE2000.SYS)
3Com 3C90X (use EL90X.SYS)
In t el E100 Series Net work Adapt er
Th e mach in e t h at con t rols t h e t arget mach in e is called t h e host
mach in e.
BETA REVI EW
1 6 8 Usi n g Sof t I CE
Th e h ost must be con n ect ed t o an IP n et work t h at is direct ly or in di-
rect ly con n ect ed t o t h e IP n et work of t h e t arget mach in e. Th e h ost
must also be run n in g Win dows 9x or Win dows NT/ 2000/ XP.
Set t i ng Up Sof t I CE f or Remot e Debuggi ng
Verify t h e t arget syst em is operat in g properly usin g a support ed adapt er
an d driver. Replace t h e adapt er driver file (for Win dows NT/ 2000/ XP, it s
in t h e \ WINNT\ SYSTEM32\ DRIVERS direct ory; for Win down s 9x, it s in
t h e \ WINDOWS\ SYSTEM direct ory) wit h t h e file of t h e same n ame from
t h e dist ribut ion . Ren ame t h e origin al driver file in case you n eed it again .
Aft er replacin g t h e driver file, you will n eed t o reboot t h e syst em in order
t o use Remot e Soft ICE.
N o t e : In f o r m at i o n f o r c o n f i g u r i n g So f t ICE f o r r em o t e d eb u g g i n g o ver a
ser i al cab l e can b e f o u n d i n t h e D r i ver St u d i o a n d So f t I CE D r i ver Su i t e
I n st a l l a t i on Gu i d e.
Ena bl i ng Remot e Debuggi ng f r om t he Ta r get Si de
On ce t h e correct adapt er an d driver is in st alled, Soft ICE will n ot allow
remot e debuggin g un t il it is en abled usin g t h e NET comman ds. Th e
followin g comman ds are available:
NET START
NET ALLOW
NET PING
NET RESET
NET STOP
NET HELP
NET STATUS
N ET START Co m m an d
Th e NET START comman d (NET START <IP address|DHCP>
[MASK=<subnet mask>] [GATEWAY=<IP address>]) en ables t h e IP
st ack wit h in Soft ICE. Th is comman d iden t ifies your IP paramet ers t o
Soft ICE (IP address, subn et mask, an d gat eway address). If your local
n et work support s DHCP (Dyn amic Host Con figurat ion Prot ocol), you
can t ell Soft ICE t o obt ain t h e IP paramet ers from your n et work DHCP
server. At t h is poin t , t h e IP st ack is run n in g but Soft ICE does n ot allow
remot e debuggin g un t il you get an IP address.
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 6 9
BETA REVI EW
N ET ALLO W Com m an d
Th e NET ALLOW comman d (NET ALLOW <IP address| ANY> [AUTO]
[PASSWORD=<password>]) defin es wh ich mach in es can be used t o
remot ely con t rol Soft ICE.
A remot e mach in e can be defin ed as a specific IP address, or ANY IP
address.
If t h e AUTO opt ion was specified on t h e NET ALLOW comman d,
t h en it is n ot n ecessary t o issue t h e NET ALLOW comman d t o en able
a n ew session aft er closin g t h e curren t session .
Access t o Soft ICE con t rol can also be qualified wit h a case-sen sit ive
password.
Wh en you begin a remot e debuggin g session , Soft ICE will pop up on t h e
t arget mach in e, n o mat t er wh at t h e curren t st at e of t h e mach in e.
N ET PI N G Com m an d
Th e NET PING comman d (NET PING <IP address>) allows you t o do a
basic n et work con n ect ivit y t est by sen din g an ICMP Ech o Request (PING)
packet t o an IP address. Soft ICE sen ds t h e request an d in dicat es if it
receives a respon se wit h in four secon ds.
N ET RESET Co m m an d
Th e NET RESET comman d t ermin at es an y act ive remot e debuggin g
session , or can cels t h e effect of t h e previous NET ALLOW comman d. Use
t h e NET ALLOW comman d t o re-en able remot e debuggin g.
N ET STO P Com m an d
Th e NET STOP comman d t ermin at es an y act ive remot e debuggin g
session , or can cels t h e effect of t h e previous NET ALLOW comman d. It
also disables t h e IP st ack an d t h e n et work adapt er.
N ET H ELP Com m an d
Th e NET HELP comman d sh ows a list of t h e available n et work
comman ds wit h t h eir respec-t ive syn t ax.
N ET STATU S Com m an d
Th e NET STATUS comman d sh ows t h e curren t st at us of t h e n et work
adapt er (if t h e NET START comman d h as been issued, t h is in cludes t h e
BETA REVI EW
1 7 0 Usi n g Sof t I CE
n ode address). It also displays t h e cur-ren t IP paramet ers (IP address,
subn et mask, an d gat eway) an d t h e st at us of t h e remot e debuggin g
con n ect ion .
St a r t i ng t he Remot e Debug gi ng Sessi on
On ce t h e t arget is set up for remot e debuggin g, t h e remot e mach in e can
issue t h e SIREMOTE comman d. Followin g is t h e syn t ax for t h e
SIREMOTE comman d.
SIREMOTE <target IP address> [<password>]
Th e t ar g et I P ad d r ess is t h e IP address assign ed t o t h e et h ern et adapt er in
t h e t arget mach in e. If t h e t arget mach in e uses a password, specify t h e
case-sen sit ive password on t h e comman d lin e.
SIREMOTE t ries t o creat e a con n ect ion t o t h e t arget mach in e. If t h e t arget
mach in e respon ds, SIREMOTE aut h en t icat es t h e remot e mach in e wit h
t h e specified password (blan k if n o password is bein g used). If t h e t arget
accept s t h e aut h en t icat ion of t h e remot e mach in e, Soft -ICE makes t h e
con n ect ion an d SIREMOTE obt ain s t h e curren t screen paramet ers of t h e
t arget mach in e. A con sole win dow emulat es t h e Soft ICE display, wh ich is
visible on bot h t h e t arget an d remot e mach in es.
All st an dard Soft ICE keys react wh et h er t h ey are en t ered from t h e remot e
or t arget keyboard. Th e on ly except ion is t h at t h e pop-up key on t h e
remot e mach in e is always Ct rl-D, even if it is redefin ed on t h e t arget
mach in e.
To t ermin at e t h e remot e Soft ICE session , press Ct rl-Break on t h e remot e
keyboard, or use t h e NET RESET comman d from t h e t arget mach in e.
Conf i gur i ng Remot e Debuggi ng w i t h a M od em
Th e Remot e Debuggin g set t in gs allow you t o defin e t h e t ype of serial
con n ect ion , an d preset a modem in it ializat ion st rin g an d ph on e n umber
for t h e DIAL an d ANSWER comman ds. Alt ern at ely, you can specify t h ese
paramet ers direct ly wh en usin g t h e comman ds. Refer t o your modem
documen t at ion for t h e exact comman ds for your part icular modem.
Te lep h o n e N um b e r
TELEPHONE NUMBER preset s a ph on e n umber for t h e DIAL comman d, for
example, 717-555-1212.
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 7 1
BETA REVI EW
Ser ial Con n ect ion ( W in d ow s 9 x O n ly)
If you are usin g Soft ICE for Win dows 9x, an d are debuggin g a remot e
syst em, ch oose t h e commun icat ion s port on t h e local syst em (COM1,
COM2, COM3, or COM4) t h at you are usin g for serial commun icat ion .
Wh en you are t h rough debuggin g t h e remot e syst em, ch an ge t h is set t in g
t o Non e. By default , SERIAL CONNECTION is set t o Non e.
N o t e : If y o u ar e u si n g So f t ICE f o r Wi n d o w s N T/ 2 0 0 0 / XP, So f t ICE au t o m at i -
cal l y d et er m i n es y o u r ser i al co n n ec t i o n .
D I AL I n it ializ at ion St r in g
DIAL INITIALIZATION STRING preset s t h e modem in it ializat ion st rin g for t h e
DIAL ccomman d, for example, ATX0.
AN SW ER I n it ializ at io n St r in g
ANSWER INITIALIZATION STRING preset s t h e modem in it ializat ion st rin g for
t h e ANSWER comman d, for example, ATX0.
Modifying Keyboard Mappings
Use Keyboard Mappin gs t o reassign comman ds t o Soft ICE fun ct ion keys
or t o specify n ew on es. You can assign Soft ICE comman ds t o an y of t h e
t welve fun ct ion keys or key combin at ion s in volvin g Sh ift , Ct rl, or Alt
an d a fun ct ion key.
N o t e : Key b o ar d m ap p i n g s assu m es t h at y o u ar e u si n g a Q WERTY key -
b o ar d l ay o u t . If y o u h ap p en t o b e u si n g a n o n - Q W ERTY l ay o u t key -
b o ar d , y o u w i l l n eed t o co p y t h e i n cl u d ed ke ym ap . exe u t i l i t y p r o -
g r am i n t o y o u r \ w i n n t \ sy st em 3 2 \ d r i ver s d i r ect o r y an d ex ecu t e
keym ap . If So f t ICE i s cu r r en t l y r u n n i n g , r eb o o t y o u r sy st em so t h e
ch an g es can t ake ef f ect . Ru n n i n g key m ap w i l l r em ap al l t h e key -
b o ar d sc an co d es t o t h e key b o ar d l ay o u t t h at i s cu r r en t l y b ei n g u sed
b y Wi n d o w s. Th e o n e key co m b i n at i o n t h at can n o t b e r em ap p ed i s
t h e p o p u p h o t key. Th e p o p u p h o t key w i l l al w ay s b e t h e t h i r d ch ar -
act er f r o m t h e l ef t o n t h e seco n d r o w ab o v e t h e sp ace b ar. To r eset
t h e key b o ar d scan co d es b ack t o t h ei r d ef au l t s, r u n ke ym ap / U SA. '
Comma nd Synt a x
Wh en modifyin g an d creat in g fun ct ion keys, you can use an y valid
Soft ICE comman d an d t h e ch aract ers; caret (^) an d semicolon (;). Place a
caret (^) at t h e begin n in g of a comman d t o in st ruct Soft ICE t o execut e
BETA REVI EW
1 7 2 Usi n g Sof t I CE
t h e comman d wit h out placin g it in t h e comman d lin e. Th e semicolon
beh aves like t h e En t er key an d in st ruct s Soft ICE t o execut e t h e
comman d. You can place on e or more semicolon s in t h e same st rin g.
M odi f yi ng Funct i on Keys
Soft ICE uses t h e followin g abbreviat ion s for t h e Fun ct ion , Alt , Ct rl, an d
Sh ift keys:
To modify t h e Soft ICE comman d assign ed t o a fun ct ion key, do t h e
followin g:
1 Select t h e fun ct ion key you wan t t o modify from t h e list of keyboard
mappin gs an d click ADD.
2 Ch an ge t h e comman d in t h e Comman d field an d click OK.
Cr ea t i ng Funct i on Keys
To assign a comman d t o a n ew fun ct ion key or fun ct ion key combin a-
t ion , do t h e followin g:
1 Det ermin e a fun ct ion key or fun ct ion key combin at ion t o wh ich n o
comman ds are assign ed.
2 Click ADD.
3 Select t h e fun ct ion key you wan t t o use from t h e Key list .
4 Select a modifier. To assign a comman d t o a fun ct ion key, click NONE.
To assign a comman d t o a fun ct ion key combin at ion , select SHIFT,
CTRL, or ALT.
5 Type a comman d in t h e Comman d field an d click OK.
Del et i ng Funct i on Keys
To delet e a fun ct ion key assign men t , ch oose t h e fun ct ion key an d click
REMOVE.
Tab l e 1 1 - 1 . Fu n ct i o n Key Ab b r ev i at i o n s
Ke y Ab b r eviat io n Exam p le
Fu n ct i o n F F1
Al t A AF1
Ct r l C CF1
Sh i f t S SF1
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 7 3
BETA REVI EW
Rest or i ng Funct i on Keys
Th e followin g t able list s t h e default fun ct ion key assign men t s.
You can modify in dividual fun ct ion key assign men t s or click RESTORE
DEFAULTS t o rest ore all t h e keys you edit ed or removed t o t h eir origin al
set t in gs. RESTORE DEFAULTS does n ot remove an y fun ct ion keys you
creat e.
Working wit h Persist ent Macros
Macros are user-defin ed comman ds t h at you can use in t h e same way as
built -in comman ds. Th e defin it ion , or body, of a macro con sist s of a
sequen ce of comman d in vocat ion s. Th e allowable set of comman ds
in cludes ot h er user-defin ed macros an d comman d-lin e argumen t s.
Th ere are t wo ways t o creat e macros. You can creat e run -t ime macros t h at
exist un t il you rest art Soft ICE or persist en t macros t h at are saved in t h e
in it ializat ion file an d aut omat ically loaded wit h Soft ICE. Th is sect ion
describes h ow t o creat e persist en t macros. Refer t o Using Run-time Macros
on page 73 for more in format ion about creat in g run -t ime Macros.
Tab l e 1 1 - 2 . D ef au l t Fu n ct i o n Key Assi g n m en t s
Ke y Assi g n m e n t Key Assig n m en t
F1 H; F12 ^P RET;
F2 ^WR; SF3 ^FORMAT;
F3 ^SRC; AF1 ^WR;
F4 ^RS; AF2 ^WD;
F5 ^X; AF3 ^WC;
F6 ^EC; AF4 ^WW;
F7 ^HERE; AF5 CLS;
F8 ^T; AF11 dd dataaddr->0;
F9 ^BPX; AF12 dd dataaddr->4;
F10 ^P; F12 ^P RET;
F11 ^G @SS:ESP; SF3 ^FORMAT;
BETA REVI EW
1 7 4 Usi n g Sof t I CE
Cr ea t i ng Per si st ent M a cr os
To creat e a persist en t macro, do t h e followin g:
1 Click ADD.
Th e Add Macro defin it ion win dow appears.
2 Type t h e n ame of t h e macro in t h e Name field.
Th e macro n ame may be from t h ree t o eigh t ch aract ers lon g an d may
con t ain an y alph a-n umeric ch aract er or un derscore (_). It must
in clude at least on e alph abet ic ch aract er. A macro-n ame can n ot
duplicat e an exist in g Soft ICE comman d.
3 Type t h e macro defin it ion in t h e Defin it ion field.
Th e defin it ion of a macro is a sequen ce of Soft ICE comman ds or
ot h er macros separat ed by semicolon s. You are n ot required t o t ermi-
n at e t h e fin al comman d wit h a semicolon . Comman d-lin e
argumen t s t o t h e macro can be referen ced an ywh ere in t h e macro
body wit h t h e syn t ax %<parameter#>, wh ere parameter# is a n umber
bet ween on e an d eigh t .
Example: The command MACRO asm = a %1 defines an alias for
the A (ASSEMBLE) command. The %1 is replaced with the first
argument following asm or simply removed if no argument is
supplied.
If you need to embed a literal quote character () or a
percent sign (%) within the macro body, precede the character
with a backslash character (\). To specify a literal backslash
character, use two consecutive backslashes (\\).
N o t e : Al t h o u g h i t i s p o ssi b l e f o r a m acr o t o cal l i t sel f r ecu r si v el y, i t i s n o t
p ar t i cu l ar l y u sef u l , b ecau se t h er e i s n o p r o g r am m at i c w ay t o t er m i -
n at e t h e m acr o . If t h e m acr o cal l s i t sel f as t h e l ast co m m an d o f t h e
m acr o ( t ai l r ecu r si o n ) , t h e m acr o ex ecu t es u n t i l y o u u se t h e ESC key
t o t er m i n at e i t . If t h e r ecu r si v e c al l i s n o t t h e l ast co m m an d i n t h e
m acr o , t h e m acr o ex ecu t es 3 2 t i m es ( t h e n est i n g l i m i t ) .
4 Click OK. Soft ICE places your persist en t macro in t h e Macro Defin i-
t ion s list .
M acr o D ef in it io n Exam p les
Th e followin g t able provides examples of legal macro comman ds.
Tab l e 1 1 - 3 . Leg al M acr o Co m m an d s
Le g al N am e Le g al D ef in i t i on Exam p le
Q ex p ad d r ex p l o r er ; Q u er y % 1 Q ex p
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 7 5
BETA REVI EW
Th e followin g t able provides examples of illegal macro comman ds:
St a r t i ng a nd St oppi ng Per si st ent M a cr os
Type t h e n ame of t h e persist en t macro t o execut e it . To st op t h e execu-
t ion of a persist en t macro, press t h e ESC key.
Set t in g t h e M acr o Lim it
Use MACRO LIMIT t o specify t h e maximum n umber of macros an d break-
poin t act ion s you can defin e durin g a Soft ICE session . Th is n umber
Q ex p 1 4 0 0 0 0
1 sh o t b p x % 1 d o \ b c b p i n d ex \ 1 sh o t ei p
o r
1 sh o t @esp
d d t d d t h r ead d d t
d d p d d p r o cess d d p
t h r t h r ead % 1 t i d t h r
o r
t h r - x
d m y f i l e m acr o m y f i l e = \ TABLE % 1 ; f i l e
\ % 1 \
d m y f i l e m y t ab l e
m y f i l e m y f i l e. c
Tab l e 1 1 - 4 . Il l eg al M acr o Co m m an d s
I lle g al N am e or
D ef in i t i on
Exp lan at ion
Name: DD
Definition: dd
dataaddr
Th i s m acr o u ses t h e n am e o f a So f t ICE co m m an d .
So f t ICE co m m an d s can n o t b e r ed ef i n ed .
Name: AA
Definition: addr %1
Th e m acr o co m m an d n am e i s t o o sh o r t . A m acr o
n am e m u st b e b et w een 3 an d 8 ch ar act er s l o n g .
Name: tag
Definition: ? *(%2-4)
Th e m acr o b o d y r ef er en ces p ar am et er % 2 w i t h o u t
r ef er en ci n g p ar am et er % 1 . Yo u can n o t r ef er en ce
p ar am et er % n + 1 w i t h o u t r ef er en ci n g p ar am et er
% n .
Tab l e 1 1 - 3 . Leg al M acr o Co m m an d s
Le g al N am e Le g al D ef in i t i on Exam p le
BETA REVI EW
1 7 6 Usi n g Sof t I CE
in cludes bot h run -t ime macros an d persist en t macros. Th e default value
of 32 is t h e min imum value. Th e maximum value is 256.
M od if yin g Per sist e n t M acr os
To modify a persist en t macro, do t h e followin g:
1 Select t h e persist en t macro you wan t t o modify an d click ADD.
2 In t h e Add macro defin it ion s win dow, modify t h e Name an d Defin i-
t ion fields as appropriat e, t h en click OK.
D elet in g Per sist en t M acr os
To delet e a persist en t macro, select t h e macro you wan t t o delet e an d
click REMOVE.
Set t ing Troubleshoot ing Opt ions
Ti p I f you w a n t t o
r et u r n a l l t h e
t r o u b l esh oot i n g
set t i n g s t o t h ei r or i g i n a l
st a t es, cl i ck RESTORE
DEFAULTS.
Th e followin g set t in gs let you t roublesh oot Soft ICE. Modify t h ese
set t in gs on ly wh en direct ed t o do so by Compuware Tech n ical Support or
t o remedy t h e specific sit uat ion s described wit h in t h is documen t at ion .
By default , t h e Troublesh oot in g set t in gs are all t urn ed off.
Di sa bl e M ouse Suppor t
If you are h avin g problems usin g your mouse in Soft ICE, select DISABLE
MOUSE SUPPORT.
Di sa bl e N um Lock a nd Ca ps Lock Pr ogr a mmi ng
Ti p I f you ve t u r n ed on
m or e t h a n on e
t r o u b l esh oot i n g set t i n g
a n d you w a n t t o t u r n
a l l t h e set t i n g s of f , u se
Rest o r e D ef a u l t s
i n st ea d of cl i cki n g ea ch
i n d i vi d u a l ch eck b o x.
If your keyboard locks or beh aves errat ically wh en you load Soft ICE,
select DISABLE NUM LOCK AND CAPS LOCK PROGRAMMING. If t h is does n ot
solve t h e problem an d you are usin g Win dows NT/ 2000/ XP, t ry t h e DO
NOT PATCH KEYBOARD DRIVER set t in g.
Ch ap t er 1 1 Cu st o m i zi n g So f t ICE 1 7 7
BETA REVI EW
Do N ot Pa t ch Keyboa r d Dr i ver (W i ndow s N T/ 2 0 0 0 / XP Onl y)
If your keyboard locks or beh aves errat ically wh en you load Soft ICE,
select t h is set t in g t o preven t Soft ICE from pat ch in g t h e keyboard driver.
Wh en you select t h is opt ion , Soft ICE uses an alt ern at e, t ypically less
robust , met h od for keyboard h an dlin g. If t h is does n ot solve t h e
problem, t ry t h e DISABLE NUM LOCK AND CAPS LOCK PROGRAMMING set t in g.
Di sa bl e M a ppi ng of N on- Pr esent Pa ges
Soft ICE at t empt s t o fin d a page in ph ysical memory even if t h e page t able
en t ry is marked as n ot presen t . Select DISABLE MAPPING OF NON-PRESENT
PAGES t o t urn off t h is feat ure.
Di sa bl e Pent i um Suppor t
Soft ICE aut omat ically det ect s wh et h er or n ot you are usin g a Pen t ium
processor. If you are usin g a n ew CPU wit h wh ich Soft ICE is un familiar
an d Soft ICE mist aken ly det ermin es t h at you are usin g a Pen t ium proces-
sor, select t h is set t in g t o t urn off Pen t ium support .
Di sa bl e Thr ea d- Speci f i c St eppi ng
Th e P (st ep over) comman d is t h read sen sit ive. Th e ret urn breakpoin t set
by t h e P comman d t riggers on ly for t h e t h read t h at was act ive wh en t h e
P comman d was issued. Not e t h at you would n ormally wan t t o be in t h e
same t h read you are debuggin g. To t urn off t h is feat ure, select DISABLE
THREAD-SPECIFIC STEPPING.
BETA REVI EW
1 7 8 Usi n g Sof t I CE
1 7 9
BETA REVI EW
Ch ap t er 1 2
Exploring Windows NT
O ve r vie w
I n sid e t h e W in d ow s N T Ke r n e l
W in 3 2 Sub syst em
Overview
Wit h out qualificat ion , t h e Win dows NT operat in g syst em family
(Win dows NT, Win dows 2000, an d Win dows XP) represen t s an in credible
feat of soft ware en gin eerin g an d syst em design . It is h ard t o imagin e a
design of such complexit y reach in g all of it s goals, in cludin g t h ree of t h e
most difficult : port abilit y, reliabilit y, an d ext en sibilit y, wit h out compro-
misin g eit h er in t erfaces or implemen t at ion . Yet , someh ow t h e syst em
en gin eers at MicroSoft wh o design an d develop t h e Win dows NT operat -
in g syst em family h ave man aged t o keep each an d every compon en t of
t h ese syst ems smoot h ly in t erlocked, n ot un like t h e precision gears of a
fin ely-made wat ch . If you are goin g t o writ e Win dows NT family applica-
t ion s, you sh ould explore wh at lies ben eat h your applicat ion code: t h e
operat in g syst em. Th e kn owledge you gain from t h e t ime you in vest t o
go ben eat h your applicat ion an d in t o t h e dept h s of t h e syst em, will
ben efit bot h you an d t h e applicat ion or driver t h at you are creat in g.
Th is ch apt er provides a quick overview of t h e more pert in en t an d in t er-
est in g aspect s of t h e basic Win dows NT Operat in g Syst em. By combin in g
t h is in format ion wit h available referen ce mat erial an d a lit t le pract ical
applicat ion usin g Soft ICE, you sh ould be able t o gain a basic un derst an d-
in g of h ow t h e compon en t s of Win dows NT fit t oget h er.
Resources f or Adva nced Debugg i ng
Microsoft provides several resources for advan ced Win dows NT debug-
gin g in cludin g: ch ecked build, t h e Win dows NT DDK, .DBG files, an d
Kern el Debugger Ext en sion s.
BETA REVI EW
1 8 0 Usi n g Sof t I CE
Ch ecked Build
If you are n ot curren t ly usin g t h e ch ecked build (t h at is, t h e debug
version ) of Win dows NT, you are missin g a lot of valuable in format ion
an d debuggin g support t h at t h e operat in g syst em provides. Th e ch ecked
build con t ain s a wealt h of in format ion t h at is absen t from t h e free build
(ret ail version ). Th is in cludes basic debug messages, special flags used by
t h e kern el compon en t s t h at allow you t o t race t h e syst ems operat ion ,
an d relat ively st rict san it y ch eckin g of most syst em API calls. Th e size
an d layout of syst em dat a st ruct ures as well as t h e implemen t at ion of
syst em APIs in t h e ch ecked build are n early iden t ical t o t h at of t h e free
build. Th is allows you t o learn an d explore usin g t h e more verbose
ch ecked build, but st ill feel complet ely comfort able if you en d up debug-
gin g un der t h e free build. All in all, if you wan t t o writ e more robust
applicat ion s an d drivers, use t h e ch ecked build.
W in d o w s N T D D K
Th e Win dows NT DDK con t ain s h eader files, sample code, on -lin e h elp,
an d special t ools t h at let you query various kern el compon en t s. Th e most
obvious an d useful resource is NTDDK.H. Alt h ough t h ere is quit e a bit of
in format ion missin g from t h is h eader file, en ough pert in en t in format ion
is available t o make it wort h st udyin g. Besides t h e basic dat a st ruct ures
n eeded for device driver developmen t , syst em dat a st ruct ures are
described (some complet ely, ot h ers briefly, man y n ot at all). Th ere are
also man y API prot ot ypes an d t ype en umerat ion s t h at are useful for bot h
explorat ion an d developmen t . Th ere are also useful commen t s about t h e
syst em design , as well as rest rict ion s an d limit at ion s. Most of t h e ot h er
h eader files in t h e DDK are specific t o t h e more esot eric aspect s of t h e
syst em, but NTDEF.H, BUGCODES.H, an d NTSTATUS.H are gen erally
useful.
Th e Win dows NT DDK in cludes a few ut ilit ies t h at are of gen eral in t erest .
For example, POOLMON.EXE allows you t o mon it or syst em pool usage,
an d OBJDIR.EXE provides in format ion on t h e Object Man ager h ierarch y
an d in format ion about a specific object wit h in t h e h ierarch y. Soft ICE for
Win dows NT provides similar fun ct ion alit y wit h t h e OBJDIR, DEVICE,
an d DRIVER comman ds. Th e ut ilit y DRIVERS.EXE, like t h e Soft ICE MOD
comman d, list s all drivers wit h in t h e syst em, in cludin g basic in format ion
about t h e driver. Some version s of t h e Win dows NT DDK in clude a sign if-
ican t ly more powerful version of t h e st an dard PSTAT.EXE ut ilit y. PSTAT is
a Win 32 con sole applicat ion t h at provides summary in format ion on
processes an d t h reads. In cluded wit h t h e Win 32 SDK an d t h e Visual C++
compiler, are t wo ut ilit ies wort h n ot in g: PVIEW an d SPY++. Bot h provide
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 8 1
BETA REVI EW
in format ion on processes an d t h reads, an d SPY++ provides HWND an d
CLASS in format ion .
Th e Win dows NT DDK also in cludes h elp files an d referen ce man uals for
device driver developmen t , as well as sample code. Th e sample code is
most useful, because it provides you wit h t h e in format ion n ecessary for
creat in g act ual Win dows NT device drivers. Simply fin d somet h in g in
your area of in t erest , build t h at sample, an d st ep t h rough it wit h Soft ICE.
. D BG File s
Ti p Usi n g . D BG f i l es i s
p r o b a b l y t h e m ost
i m p or t a n t a sp ect of
set t i n g u p you r
d evel o p m en t a n d
d eb u g g i n g
en vi r on m en t . Sel ect
t h ose com p o n en t s t h a t
a r e m ost r el eva n t t o
you r d evel op m en t
n eed s, f i n d t h e
co r r esp on d i n g . D BG f i l e
a n d u se Sym b o l Loa d er
t o cr ea t e a . N M S f i l e
t h a t So f t I CE ca n l o a d .
Microsoft provides a separat e DBG file for every dist ribut ed execut able
file wit h bot h t h e ch ecked an d free builds of t h e Win dows NT operat in g
syst em. Th is in cludes t h e syst ems compon en t s t h at make up t h e kern el
execut ive, device drivers, Win 32 syst em DLLs, sub-syst em processes,
con t rol pan el applet s, an d even accessories an d games. Th e .DBG files
con t ain basic debug in format ion similar t o t h e PUBLIC defin it ion s of a
.MAP file. Every API an d global variable, export ed or ot h erwise, h as a
basic defin it ion (for example, n ame, sect ion an d offset ). Advan ced t ype
in format ion such as st ruct ures an d locals is n ot provided, but h avin g
access t o a public defin it ion for each API makes debuggin g t h rough
syst em calls a lot easier.
Regardless of your specific area of in t erest , load symbols for t h e followin g
key syst em compon en t s. Th e most import an t compon en t s are list ed in
bold t ypeface.
Tab l e 1 2 - 1 . Key Sy st em Co m p o n en t Sy m b o l s
Com p o n e n t D escr i p t io n
N TO SKRN L. EX E Th e Wi n d o w s N T Ker n el . ( M o st o f t h e o p er at -
i n g sy st em r esi d es h er e. )
HAL. D LL Th e Har d w ar e Ab st r act i o n Lay er. Im p o r t an t
p r i m i t i v es f o r N TO SKRN L.
N TD LL. D LL Basi c i m p l em en t at i o n o f t h e Wi n 3 2 API, an d
f u n ct i o n al i t y t r ad i t i o n al l y at t r i b u t ed t o KER-
N EL. Al so t h e i n t er f ace b et w een USER an d
SYSTEM m o d e. Essen t i al l y r ep l aces
KERN EL3 2 . D LL.
CSRSS. EXE Th e Wi n 3 2 su b sy st em ser v er p r o cess. M o st
su b sy st em cal l s ar e r o u t ed t h r o u g h t h i s p r o -
cess.
W I N SRV. D LL Un d er Wi n d o w s N T 3 . 5 1 , t h e co r e i m p l em en -
t at i o n o f USER an d GD I f u n ct i o n al i t y. O n l y
l o ad ed i n t h e co n t ex t o f CSRSS.
BETA REVI EW
1 8 2 Usi n g Sof t I CE
Reso urces
Th e followin g resources provide ext en sive in format ion for developin g
drivers an d applicat ion s for Win dows NT:
Microsoft Developers Network (MSDN)
MSDN is publish ed quart erly, on CD-ROM, an d it con t ain s a wealt h
of in format ion an d art icles on all aspect s of programmin g Microsoft
operat in g syst ems. Th is is on e of t h e on ly places wh ere you can fin d
pract ical in format ion on writ in g Win dows NT device drivers.
Inside Windows NT - Helen Cust er, Microsoft Press
Inside Windows NT provides a h igh -level view of t h e design for t h e
Win dows NT operat in g syst em. Each of t h e major sub-syst ems is
t h orough ly discussed, an d man y block diagrams illumin at e in t ern al
dat a st ruct ures, policies, an d algorit h ms. Alt h ough t h e con t en t s of
t h is book may seem h igh ly abst ract ed from t h e act ual operat in g
syst em implemen t at ion , on ce you st ep in t o OS code wit h Soft ICE,
man y of t h e h igh er level relat ion sh ips become clear. Curren t ly, t h is is
t h e most valuable set of in format ion on Win dows NT operat in g
syst em in t ern als. You will gain t h e most ben efit from t h e in format ion
in t h is book if you use Soft ICE t o explore t h e act ual implemen t at ion
of t h e syst em design .
Advanced Windows - Jeffery Rich t er, Microsoft Press
Advanced Windows is an excellen t resource for t h e syst ems programmer
developin g Win 32 applicat ion s an d syst em code. Rich t er presen t s
ext en sive discussion s of processes, t h reads, memory man agemen t ,
an d syn ch ron izat ion object s. Relevan t sample code an d ut ilit ies are
also provided.
W I N 3 2 K. SYS A sy st em d evi ce d r i ver t h at r ep l aces W IN -
SRV. D LL an d m i n i m i zes i n t er - p r o cess co m m u -
n i cat i o n b et w een ap p l i cat i o n s an d CSRSS.
M ay n o t b e avai l ab l e f o r al l v er si o n s o f t h e O S.
USER3 2 . D LL Basi c i m p l em en t at i o n o f USER f u n ct i o n al i t y.
M o st l y st u b s t o W IN SRV. D LL ( v i a LPC t o
CSRSS) . M o r e r ecen t v er si o n s co n t ai n m o r e
i m p l em en t at i o n t o m i n i m i ze co n t ex t sw i t ch es.
KERN EL3 2 . D LL. So m e b asi c i m p l em en t at i o n o f t r ad i t i o n al KER-
N EL f u n ct i o n al i t y, b u t m o st l y st u b s t o
N TD LL. D LL.
Tab l e 1 2 - 1 . Key Sy st em Co m p o n en t Sy m b o l s
Com p o n e n t D escr i p t io n
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 8 3
BETA REVI EW
Inside t he Windows NT Kernel
To gain a basic un derst an din g of Win dows NT, look at t h e plat form from
man y differen t perspect ives. A gen eral kn owledge of h ow Win dows NT
works at differen t levels en ables you t o un derst an d t h e con st rain t s an d
assumpt ion s in volved in design in g ot h er aspect s of t h e operat in g syst em.
Th is sect ion explain s t h e most crit ical compon en t of t h e operat in g
syst em, t h e Win dows NT Kern el. It describes h ow Win dows NT con fig-
ures t h e core operat in g syst em dat a st ruct ures, such as t h e IDT an d TSS,
an d h ow t o use correspon din g Soft ICE comman ds t o illust rat e t h e
Win dows NT con figurat ion of t h e CPU. It also examin es a gen eral map of
t h e Win dows NT syst em memory area, describin g import an t syst em dat a
st ruct ures an d examin in g t h e crit ical role t h ey play wit h in t h e operat in g
syst em.
A majorit y of t h e in format ion in t h is sect ion is based on t h e implemen t a-
t ion det ails of t h e followin g t wo modules:
Hardware Abst ract ion Layer (HAL.DLL)
HAL is t h e Win dows NT h ardware abst ract ion layer. It s purpose is t o
isolat e as man y h ardware plat form depen den cies as possible in t o on e
module. Th is makes t h e Win dows NT kern el code h igh ly port able.
Various part s of t h e kern el use plat form depen den t code, but on ly for
performan ce con siderat ion s.
Th e primary respon sibilit y of t h e HAL is t o deal wit h very low-level
h ardware con t rol such as In t errupt con t roller programmin g,
h ardware I/ O, an d mult iprocessor in t er-commun icat ion . Man y of t h e
HAL rout in es are dedicat ed t o dealin g wit h specific bus t ypes (PCI,
EISA, ISA) an d bus adapt er cards. HAL also con t rols basic fault
h an dlin g an d in t errupt dispat ch .
Th e Kern el (NTOSKRNL.EXE)
Th e vast majorit y of t h e Win dows NT operat in g syst em resides in t h e
Win dows NT Kern el, or Kern el Execut ive. Th is is t h e kern el-level
fun ct ion alit y t h at all ot h er syst em compon en t s, such as t h e Win 32
subsyst em, are built upon . Th e Kern el Execut ive Services cover a
broad ran ge of fun ct ion alit y, in cludin g:
Memory Man agemen t
Object Man ager
Process an d Th read creat ion an d man ipulat ion
Process an d Th read sch edulin g
Local Procedure Call (LPC) facilit ies
Securit y Man agemen t
Except ion h an dlin g
BETA REVI EW
1 8 4 Usi n g Sof t I CE
VDM h ardware emulat ion
Syn ch ron izat ion primit ives, such as Semaph ores an d Mut an t s
Run Time Library
File Syst em
I/ O subsyst ems
M a na gi ng t he I nt el Archi t ect ur e
On e of t h e fun damen t al requiremen t s of st art in g a prot ect ed-mode
operat in g syst em is t h e set up of CPU arch it ect ure, policies, an d address
space t h at t h e operat in g syst em will use. Syst em in it ializat ion is coordi-
n at ed bet ween NTLDR, NTDETECT, NTOSKRNL, an d HAL. Use t h e
followin g Soft ICE comman ds t o obt ain a gen eral idea of h ow Win dows
NT uses t h e In t el arch it ect ure t o provide a secure an d robust en viron -
men t .
N o t e : Th e SoftICE Command Reference p r o v i d es d et ai l ed i n f o r m at i o n ab o u t
u si n g each co m m an d .
I D T ( I n t er r up t D escr ip t o r Tab le)
Win dows NT creat es an IDT for 255 in t errupt vect ors an d maps it in t o
t h e syst em lin ear address space. Th e first 48 in t errupt vect ors are gen er-
ally used by t h e kern el t o t rap except ion s, but cert ain vect ors provide
operat in g syst em services or ot h er special feat ures. Use t h e Soft ICE IDT
comman d t o view t h e Win dows NT In t errupt Descript or Table.
Tab l e 1 2 - 2 . So f t ICE Ar ch i t ect u r e Co m m an d s
Com m an d D escr ip t io n
ID T D i sp l ay i n f o r m at i o n o n t h e In t er r u p t D escr i p t o r Tab l e
TSS D i sp l ay i n f o r m at i o n ab o u t t h e Task St at e Seg m en t
GD T D i sp l ay i n f o r m at i o n o n t h e Gl o b al D escr i p t o r Tab l e
LD T D i sp l ay i n f o r m at i o n o n t h e Lo cal D escr i p t o r Tab l e
Tab l e 1 2 - 3 . In t er r u p t D escr i p t o r Tab l e
I n t e r r up t # Pur p ose
2 N M I. A Task g at e i s i n st al l ed h er e so t h e O S h as a cl ean set o f
r eg i st er s, p ag e- t ab l es, an d l ev el 0 st ack. Th i s en ab l es t h e o p er at -
i n g sy st em t o co n t i n u e p r o cessi n g l o n g en o u g h t o t h r o w a Blue
Screen.
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 8 5
BETA REVI EW
In t errupt vect ors 0x30 - 0x3F are mapped by t h e primary an d secon dary
in t errupt con t rollers, so h ardware in t errupt s for IRQ0 t h rough IRQ15 are
vect ored t h rough t h ese IDT en t ries. In man y cases, t h ese h ardware in t er-
rupt vect ors are n ot h ooked, so t h e syst em assign s default st ub rout in es
for each on e. As devices require t h e use of t h ese h ardware in t errupt s, t h e
device driver request s t o be con n ect ed. Wh en t h e in t errupt is n o lon ger
n eeded, t h e device driver request s t o be discon n ect ed.
Th e default st ubs are n amed KiUn expect edIn t errupt #, wh ere # represen t s
t h e un expect ed in t errupt . To det ermin e wh ich in t errupt vect or is
assign ed t o a part icular st ub, add 0x30 t o t h e Un expect edIn t errupt #. For
example, KiUn expect edIn t errupt 2 is act ually vect ored t h rough IDT
vect or 32 (0x30 + 2).
In t errupt s for Virt ual DOS mach in es (VDM), wh ich in clude t h e WOW
(16-bit Win dows on Win dow) subsyst em, do n ot vect or direct ly t h rough
t h e IDT. For a VDM, in t errupt s are emulat ed by t riggerin g a gen eral
prot ect ion fault t h at special VDM code wit h in NTOSKRNL h an dles. In
most cases, t h e in t errupt is even t ually reflect ed back t o t h e VDM for
servicin g. MS-DOS In t errupt 21 is h an dled as a special case (sin ce an
act ual IDT en t ry exist s). Th is could be for performan ce reason s, compat i-
bilit y issues, or bot h .
8 D o u b l e Fau l t . A Task g at e i s i n st al l ed h er e so t h e O S h as a cl ean
set o f r eg i st er s, p ag e- t ab l es, an d l ev el 0 st ack. Th i s en ab l es t h e
o p er at i n g sy st em t o co n t i n u e p r o cessi n g l o n g en o u g h t o t h r o w
a Blue Screen.
2 1 M S- D O S In t 2 1 t r ap . O n l y u sed f o r Vi r t u al D O S M ach i n es ( VM D )
an d W O W.
2 A Ser v i ce t o g et t h e cu r r en t t i ck co u n t .
2 B, 2 C D i r ect t h r ead sw i t ch ser v i ces.
2 D D eb u g ser vi ce.
2 E Ex ecu t e Sy st em Ser vi ce. Wi n d o w s N T t r an si t i o n s f r o m u ser
m o d e t o sy st em m o d e u si n g IN T 2 E. Fo r m o r e i n f o r m at i o n , r ef er
t o t h e N TCALL co m m an d i n t h e SoftICE Command Reference.
3 0 - 3 7 Pr i m ar y In t er r u p t Co n t r o l l er ( IRQ 0 - IRQ 7 ) .
3 0 - HAL cl o ck i n t er r u p t ( IRQ 0 ) .
3 8 - 3 F Seco n d ar y In t er r u p t Co n t r o l l er ( IRQ 8 - IRQ 1 5 ) .
Tab l e 1 2 - 3 . In t er r u p t D escr i p t o r Tab l e
I n t e r r up t # Pur p ose
BETA REVI EW
1 8 6 Usi n g Sof t I CE
Drivers may in st all an d un in st all in t errupt h an dlers as n ecessary, usin g
IoCon n ect In t errrupt an d IoDiscon n ect In t errupt . Th ese rout in es creat e
special t h un k object s, allocat ed from t h e Non -Pageable Pool, wh ich
con t ain dat a an d code t o man age simult an eous use of t h e same in t errupt
h an dler by on e or more drivers.
TSS ( Task St at e Se g m en t )
Th e purpose of t h e TSS is t o save t h e st at e of t h e processor durin g t ask or
con t ext swit ch es. For performan ce reason s, Win dows NT does n ot use
t h is arch it ect ural feat ure an d main t ain s on e base TSS t h at all processes
sh are. As n ot ed in t h e previous sect ion on t h e Win dows NT IDT, ot h er
TSS dat a t ypes exist , but are on ly used durin g except ion al con dit ion s t o
en sure t h at t h e syst em will n ot spon t an eously reboot before Win dows
NT can properly crash it self. Use t h e Soft ICE TSS comman d t o view t h e
curren t TSS.
Th e TSS con t ain s t h e offset from t h e base of t h e TSS t o t h e st art of t h e I/ O
bit map. Th e I/ O bit map det ermin es wh ich port s, if an y, t h e code execut -
in g at Rin g 3 can access direct ly. Un der Win dows NT 3.51, wh en execut -
in g in a VDM, t h e TSS con t ain s a valid offset t o a I/ O bit map t h at t raps
direct I/ O for subsequen t emulat ion by t h e operat in g syst em. Wh en
execut in g a Win 32 applicat ion , t h e TSS con t ain s an invalid offset (it
poin t s beyon d t h e segmen t limit of t h e TSS). Th is forces t h e operat in g
syst em t o t rap all direct I/ O.
In side t h e act ual TSS dat a st ruct ure, t h e on ly field of real in t erest is t h e
address of t h e Level 0 st ack. Th is is t h e st ack t h at is used wh en t h e CPU
t ran sit ion s from user mode t o syst em mode.
GD T ( G lob al D e scr ip t o r Tab le )
Win dows NT is a flat , 32-bit arch it ect ure. Th us wh ile it st ill n eeds t o use
select ors, it uses t h em min imally. Most Win 32 applicat ion s an d drivers
are complet ely un aware t h at select ors even exist . Th e followin g is abbre-
viat ed out put from t h e Soft ICE GDT comman d t h at sh ows t h e select ors
in t h e Global Descript or Table.
GD Tb ase= 8 0 0 3 6 0 0 0 Li m i t = 0 3 FF
0 0 0 8 Co d e3 2 Base= 0 0 0 0 0 0 0 0 Li m = FFFFFFFF D PL= 0 P RE
0 0 1 0 D at a3 2 Base= 0 0 0 0 0 0 0 0 Li m = FFFFFFFF D PL= 0 P RW
0 0 1 B Co d e3 2 Base= 0 0 0 0 0 0 0 0 Li m = FFFFFFFF D PL= 3 P RE
0 0 2 3 D at a3 2 Base= 0 0 0 0 0 0 0 0 Li m = FFFFFFFF D PL= 3 P RW
0 0 2 8 TSS3 2 Base= 8 0 0 0 B0 0 0 Li m = 0 0 0 0 2 0 AB D PL= 0 P B
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 8 7
BETA REVI EW
Not e t h at t h e first four select ors address t h e en t ire 4GB lin ear address
ran ge. Th ese are flat select ors t h at Win 32 applicat ion s an d drivers use.
Th e first t wo select ors h ave a DPL of zero an d are used by device drivers
an d syst em compon en t s t o map syst em code, dat a, an d st acks. Th e selec-
t ors 1B an d 23 are for Win 32 applicat ion s an d map user level code, dat a,
an d st acks. Th ese select ors are con st an t values an d t h e Win dows NT
syst em code makes frequen t referen ces t o t h em usin g t h eir lit eral values.
Th e select or value 30h addresses t h e Kern el Processor Con t rol Region an d
is always mapped at a base address of 0xFFDFF000. Wh en execut in g
syst em code, t h is select or is st ored in t h e FS segmen t regist er. Amon g it s
man y ot h er purposes, t h e Processor Con t rol Region main t ain s t h e
curren t kern el mode except ion frame at offset 0.
Similarly, t h e select or value 3Bh is a user-mode select or t h at maps t h e
curren t user t h read en viron men t block (UTEB). Th is select or value is
st ored in t h e FS segmen t regist er wh en execut in g user level code an d h as
t h e curren t user-mode except ion frame at offset 0. Th e base address of
t h is select or varies depen din g on wh ich user-mode t h read is run n in g.
Wh en a t h read swit ch occurs, t h e base address of t h is GDT select or en t ry
is updat ed t o reflect t h e curren t UTEB.
Select or value 48h is an LDT t ype select or an d is on ly used for VDM
processes. Win 32 applicat ion s an d drivers do n ot use LDT select ors.
Wh en a Win 32 process is act ive, t h e In t el CPUs LDT regist er is NULL. In
t h is case, t h e Soft ICE LDT comman d gives you a No LDT error message.
Wh en a VDM or 16-bit WOW process is act ive, a valid LDT select or is set ,
an d it comes from t h is GDT select or. Durin g a process con t ext swit ch ,
LDT select or in format ion wit h in t h e kern el process en viron men t block
(KPEB) is poked in t o t h is select or t o set t h e appropriat e base address an d
limit .
LD T ( Local D e scr ip t or Tab le )
Un der Win dows NT, Local Descript or Tables are per process dat a st ruc-
t ures an d are on ly used for Virt ual DOS Mach in es (VDM). Th e 16-bit
WOW box (Win dows On Win dows) is execut ed wit h in a NTVDM process
0 0 3 0 D at a3 2 Base= FFD FF0 0 0 Li m = 0 0 0 0 1 FFF D PL= 0 P RW
0 0 3 B D at a3 2 Base= 7 FFD E0 0 0 Li m = 0 0 0 0 0 FFF D PL= 3 P RW
0 0 4 3 D at a1 6 Base= 0 0 0 0 0 4 0 0 Li m = 0 0 0 0 FFFF D PL= 3 P RW
0 0 4 8 LD T Base=E1 5 6 C0 0 0 Li m =0 0 0 0 FFEF D PL=0 P
0 0 5 0 TSS3 2 Base= 8 0 1 4 3 FE0 Li m = 0 0 0 0 0 0 6 8 D PL= 0 P
0 0 5 8 TSS3 2 Base= 8 0 1 4 4 0 4 8 Li m = 0 0 0 0 0 0 6 8 D PL= 0 P
BETA REVI EW
1 8 8 Usi n g Sof t I CE
an d h as an LDT. Like Win dows 3.1, t h e LDT for a WOW con t ain s t h e
select ors for every 16-bit prot ect ed mode code an d dat a segmen t for each
16-bit applicat ion or DLL t h at is loaded. It also con t ain s t h e select ors for
each t ask dat abase, module dat abase, local h eaps, global allocat ion s, an d
all USER an d GDI object s t h at require t h e creat ion of a select or. Un der a
WOW, because t h e n umber of select ors n eeded can be quit e large, a full
LDT is creat ed wit h a majorit y of t h e en t ries in it ially reserved. Th ese
reserved select ors are allocat ed as n eeded. Un der a n on -WOW VDM, t h e
size of t h e LDT is sign ifican t ly smaller.
W i ndow s N T Syst em M emor y M a p
Win dows NT reserves t h e upper 2GB of t h e lin ear address space for
syst em use. Th e address ran ge 0x80000000 - 0xFFFFFFFF maps syst em
compon en t s such as device drivers, syst em t ables, syst em memory pools,
an d syst em dat a st ruct ures such as t h reads an d processes. Wh ile you
can n ot creat e an exact map of t h e Win dows NT syst em memory space,
you can cat egorize areas t h at are set aside for specific usage. Th e follow-
in g Syst em Memory Map diagram gives you a rough idea of wh ere
operat in g syst em in format ion is locat ed. Remember t h at a majorit y of
t h ese syst em areas could be mapped an ywh ere wit h in t h e syst em address
space, but are gen erally in t h e address ran ges sh own .
Syst em Code area
Boot drivers an d t h e NTOSKRNL an d HAL compon en t s are loaded in
t h e Syst em Code address space. Non -boot drivers are loaded in t h e
Non Paged syst em address space n ear t h e t op of t h e lin ear address
space. You can use t h e Soft ICE MOD an d MAP32 comman ds t o
examin e t h e base address an d ext en t s of boot drivers loaded in t h is
memory area. Th is is also wh ere t h e TSS, IDT, an d GDT syst em dat a
st ruct ures are mapped.
N o t e : LD T d at a st r u ct u r es ar e cr eat ed f r o m t h e Pag ed Po o l ar ea.
Syst em View area
Th e Syst em View address space is symbolically referen ced, but does
n ot ever seem t o be mapped un der Win dows NT 3.51. Un der n ewer
version s of Win dows NT, t h e Syst em View address space maps t h e
global t ables for GDI an d USER object s. You can use t h e Soft ICE
OBJTAB comman d t o view in format ion about t h e USER object t able.
Syst em Tables Area
Th is region of lin ear memory maps process page t ables an d relat ed
dat a st ruct ures. Th is is on e of t h e few areas of syst em memory t h at is
n ot t ruly global, in t h at each process h as un ique page t ables. Wh en
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 8 9
BETA REVI EW
Win dows NT execut es a process con t ext swit ch , t h e ph ysical address
of t h e process Page Direct ory is ext ract ed from t h e kern el process
en viron men t block (KPEB) an d loaded in t o t h e CR3 regist er. Th is
causes t h e process page t ables t o be mapped in t h is memory area.
Alt h ough t h e lin ear addresses remain t h e same, t h e ph ysical memory
used t o back t h is area con t ain s process-specific values. In Soft ICE
t ermin ology, t h e Page Direct ory is essen t ially an Address Con t ext .
Wh en you use t h e Soft ICE ADDR comman d t o ch an ge t o a specific
process con t ext , you are loading the Page Directory information for this
process.
To man age t h e mappin g of lin ear memory t o ph ysical memory,
Win dows NT reserves a 4MB region of t h e syst em lin ear address space
for Page Tables. Th is 4MB region represen t s t h e en t ire ran ge of
memory n ecessary t o fully defin e a Page Direct ory an d complet e set
of page t ables. Th e n eed for a 4MB region can be calculat ed given
t h at t h ere is on e Page Direct ory st ruct ure wh ich con t ain s en t ries for
1024 Page Tables. To map a 4GB lin ear address space, each Page Table
must map a 4MB region of lin ear address space (4GB / 1024). Each
Page Table is a mult iple of t h e CPU page size (wh ich is 4KB un der
Win dows NT), so mult iplyin g 1024 by 4096 (t h e page size) yields t h e
expect ed 4MB value. Th us an operat in g syst em t h at uses pagin g an d
a 4KB page size requires 4MB of memory t o map t h e en t ire address
space. Win dows NT, Win dows 95 an d Win dows 98 t ake t h e simple
an d efficien t approach of usin g a con t iguous region of lin ear memory
for t h is purpose.
Th e diagram on t h e n ext page sh ows t h e syst em memory map for
Win dows NT.
In t h is design , t h e Page Direct ory is act ually performin g t wo
fun ct ion s. In addit ion t o bein g t h e Page Direct ory, represen t in g 4GB,
it also serves as a page t able, represen t in g 4MB in t h e address ran ge
0xC0000000 - 0xC03FFFFF. Th e Page Direct ory maps t h e 4MB region
wh ere t h e process page t ables are mapped (0xC0000000-
0xC03FFFFF), so t h e Page Direct ory en t ry t h at maps t h is area must
poin t t o it self. If you use t h e Soft ICE PAGE comman d, t h e ph ysical
address of t h e Page Direct ory displayed at t h e t op of t h e comman d
out put mat ch es t h e ph ysical address for t h e en t ry t h at maps t h e
0xC0000000 - 0xC03FFFFF memory ran ge. If you use t h e Soft ICE
ADDR comman d t o obt ain t h e CR3 (t h e CR3 regist er con t ain s t h e
ph ysical address of t h e Page Direct ory) value for t h e curren t process
an d supply t h is value as in put t o t h e Soft ICE PHYS comman d, all t h e
lin ear addresses t h at are mapped t o t h e ph ysical address of t h e Page
Direct ory are displayed. On e of t h e addresses is 0xC0300000.
BETA REVI EW
1 9 0 Usi n g Sof t I CE
Fi g u r e 1 2 -1 . Wi n d o w s N T Sy st em M em o r y M ap
Th e followin g examples illust rat es h ow all t h ese values in t errelat e.
Import an t values are sh ow in bold t ypeface.
Use t h e ADDR comman d t o obt ain t h e physical address of t h e
Page Direct ory (CR3).
:addr
CR3 LDT Base:Limit KPEB Addr PID Name
00030000 FF116020 0002 System
0115A000 FF0AAA80 0051 RpcSs
0073B000 FF083020 004E nddeagnt
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 9 1
BETA REVI EW
Use t h e ph ysical address as in put t o t h e PHYS comman d t o
obt ain all lin ear addresses t h at map t o t h at ph ysical page (on e
ph ysical page may be mapped t o more t h an on e lin ear address,
an d on e lin ear address may be mapped t o more t h an on e page).
:phys 1F6E000
C0300000
Use t h e lin ear address (C0300000) an d run it t h rough t h e PAGE
comman d t o verify t h e ph ysical page for t h at lin ear address.
:page C0300000
Linear Physical Attributes
C0300000 01F6E000 P D A S RW
Use t h e PAGE comman d wit h out an y paramet ers t o view t h e
mappin g of t h e en t ire lin ear address ran ge. Th is is useful for
obt ain in g t h e ph ysical address of t h e Page Direct ory an d verify-
in g t h at t h e operat in g syst em page t ables are mapped at lin ear
address 0xC0000000. Th e out put for t h is comman d is abbrevi-
at ed.
00653000 E13BB000:0C3F FF080020 0061 ntvdm
00AEE000 FF07A600 0069 Explorer
01084000 FF06ECA0 0077 FINDFAST
010E9000 FF06CDE0 007B MSOFFICE
*01F6E000 FF088C60 006A WINWORD
01E0A000 FF09CCA0 008B 4NT
017D3000 E1541000:018F FF09C560 006D ntvdm
00030000 80140BA0 0000 Idle
:page
Page Directory Physical=01F6E000
Physical Attributes Linear Address Range
01358000 P A S RW A0000000 - A03FFFFF
017F0000 P A S RW A0400000 - A07FFFFF
01727000 P A S RW A0800000 - A0BFFFFF
:addr
BETA REVI EW
1 9 2 Usi n g Sof t I CE
Syst e m Pag e Tab le En t r ies an d Pr ot oPTEs
Th e acron ym, PTE, wh ich appears in various places on t h e syst em map,
st an ds for Page Table En t ry. A Page Table En t ry is on e of t h e 1024 en t ries
t h at is con t ain ed in a Page Table. Each PTE describes on e page of
memory, in cludin g it s ph ysical address an d at t ribut es. Because Win dows
NT also run s on n on -In t el plat forms, an d because t h e operat in g syst em
may n eed t o ext en d t h e t ypes of page-level prot ect ion beyon d wh at an y
part icular CPU may provide, Win dows NT virt ualizes t h e CPU PTE wit h
wh at is referred t o as a Prot oPTE. Th e Prot oPTE is similar t o t h e In t el
Arch it ect ure PTE, but in cludes at t ribut es t h at are n ot provided by t h e
In t el PTE. By overloadin g t h e mean in g of an at t ribut e bit wit h in an In t el
PTE, t h e operat in g syst em can gain con t rol on a page fault , an d examin e
t h e ext en ded at t ribut es of t h e correspon din g Prot oPTE t o det ermin e wh y
t h e operat in g syst em request ed t h at t h e fault occur. Th rough out NTOSK-
RNL, man ipulat ion s are performed on t h e Prot oPTE abst ract ion , an d
t ran slat ed t o t h e act ual CPU PTE t ype. Not e t h at t h e operat in g syst em
also compares t h e Prot oPTE t o it s correspon din g CPU PTE t o en sure t h eir
con sist en cy. Th is effect ively preven t s an applicat ion or device driver
from direct ly man ipulat in g t h e page t able en t ries.
Paged Pool Area: Th e Paged Pool syst em memory area is wh ere
n t oskrn l!ExAllocat ePool an d it s relat ed fun ct ion s allocat e memory
t h at can be paged t o disk. Th is is in direct con t rast t o t h e Non -Paged
pool area. Non -Paged pool allocat ion s are n ever paged t o disk an d are
design ed for rout in es such as In t errupt Han dlers t h at n eed h igh per-
forman ce or n eed a guaran t ee t h at a piece of in format ion is always
available for use.
Win dows NT makes ext en sive use of t h e Paged pools, as t h is is wh ere
most operat in g syst em object s are creat ed. Not e t h at t h e st art in g
address an d t h e size an d n umber of paged pools is det ermin ed
dyn amically durin g syst em in it ializat ion . On ly use t h e addresses
presen t ed h ere as a guidelin e. For t h e act ual addresses, load t h e
symbols for NTOSKRNL an d examin e t h e appropriat e variables t h at
describe t h e paged pool con figurat ion . (To see several of t h em, use
t h e Soft ICE SYM comman d wit h t h e Paramet er MmPaged*.)
01F6E000 P A S RW C0000000 - C03FFFFF
0066F000 P A S RW C0400000 - C07FFFFF
00041000 P A S RW C0C00000 - C0FFFFFF
00042000 P A S RW C1000000 - C13FFFFF
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 9 3
BETA REVI EW
Alt h ough t h ere is on e Paged Pool area, t h ere are mult iple paged
pools. Th e n umber is det ermin ed durin g syst em in it ializat ion . Paged
pool allocat ion s occur wit h relat ively h igh frequen cy an d t h ose
accesses must be t h read safe, so h avin g on e dat a st ruct ure wh ich
must be own ed exclusively by on e t h read durin g memory allocat ion
or deallocat ion creat es a bot t len eck. To avoid pot en t ial t raffic jams
an d reduced syst em performan ce, mult iple pool descript ors are
creat ed, each wit h it s own privat e dat a st ruct ures, in cludin g an
execut ive spin lock for t h read syn ch ron izat ion . Th us, t h e more paged
pools creat ed, t h e more t h reads t h at can perform paged pool alloca-
t ion s simult an eously, in creasin g t h e t h rough put of t h e syst em. An
import an t design n ot e, in case you plan on usin g similar t ech n iques
in your driver or applicat ion , is t h at t h e overh ead for a Paged Pool (or
Non -Paged Pool) descript or is very min imal. Th us it s pract ical for
four or five of t h em t o exist . However, det ermin e t h at an act ual
bot t len eck exist s before creat in g elaborat e sch emes t o solve a n on -
exist en t problem.
Non-Paged System Area: Th is lin ear region is in t en ded for syst em
compon en t s an d dat a st ruct ures t h at n eed t o be presen t in memory
at all t imes. Th is in cludes n on -boot drivers, kern el mode t h read
st acks, t wo Non -Paged memory pools, an d t h e Page Frame Dat abase.
Alt h ough it is con t radict ory t o say t h at it ems in t h e Non -Paged Sys-
t em area can become n ot presen t ; t h e t rut h is t h at t h ey can be. Spe-
cifically, kern el t h read st acks an d process address spaces can be made
n ot presen t , an d oft en are.
Th e Non -Paged pool is similar t o t h e Paged Pool wit h t h e except ion
t h at object s creat ed in t h e Non -Paged pool are n ot discarded from
memory for an y reason . Th e Non -Paged pool is used t o allocat e key
syst em dat a st ruct ures such as kern el process an d t h read en viron -
men t blocks. Th ere is a secon d Non -Paged pool used for memory
allocat ion s t h at must succeed. At syst em in it ializat ion , NTOSKRNL
reserves a small amoun t of ph ysical memory for crit ical allocat ion s,
an d saves t h is memory for use by t h e must succeed pool. Th e size of
an allocat ion from t h e must succeed pool must be less t h an on e page
(4KB). If t h e must succeed allocat ion can n ot be sat isfied, or t h e
request ed allocat ion size is larger t h an 4KB, t h e syst em t h rows a Blue
Screen.
Processor Control Region: At t h e h igh en d of t h e syst em memory
area is t h e Processor Con t rol Region . Here, Win dows NT main t ain s
Processor Con t rol Block (PCRB) dat a st ruct ures for each processor
wit h in t h e syst em an d a global dat a st ruct ure, t h e Processor Con t rol
Region t h at reflect s t h e curren t st at e of t h e syst em. Th e Processor
BETA REVI EW
1 9 4 Usi n g Sof t I CE
Con t rol Region (PCR) con t ain s key pieces of in format ion about t h e
curren t st at e of t h e syst em, such as t h e curren t ly run n in g kern el
t h read; t h e curren t in t errupt request level (IRQL); t h e curren t excep-
t ion frame; base addresses of t h e IDT, TSS, an d GDT; an d kern el
t h read st ack poin t ers. Small port ion s of t h e PCR an d PCRB dat a st ruc-
t ures are documen t ed in NTDDK.H.
In man y cases, device driver writ ers n eed t o kn ow t h e curren t IRQL at
wh ich t h ey are execut in g. Alt h ough you could look in side t h e PCR
dat a st ruct ure at offset 0x24, it is simpler t o use t h e Soft ICE in t rin sic
fun ct ion , IRQL, as follows:
? IRQL
00000002h
Th e most common piece of dat a accessed from t h e PCRB is t h e
curren t kern el t h read poin t er. Th is is at offset 4 wit h in t h e PCRB, but
is gen erally referen ced t h rough t h e PCR at offset 0x124. Th is works
because t h e PCRB is n est ed wit h in t h e PCR at offset 0x120. Code t h at
accesses t h e curren t t h read is usually of t h e form:
mov reg, FS:[124].
Remember t h at wh ile execut in g in syst em mode, t h e FS regist er is set
t o a GDT select or wh ose base address poin t s t o t h e begin n in g of t h e
PCR. Soft ICE makes it much easier t o get t h e curren t t h read poin t er
or t h read id by usin g t h e in t rin sic fun ct ion s thread or tid:
? thread
FF088E90h
? tid
71h
For more ext en sive in format ion on t h e curren t t h read use t h e follow-
in g comman ds:
Th e curren t process is n ot st ored as part of t h e PCR or PCRB.
Win dows NT referen ces t h e curren t process t h rough t h e curren t
:thread tid
TID Krnl TEB StackBtm StkTop StackPtr User TEB Process(Id)
0071 FF0889E0 FC42A000 FC430000 FC42FE5C 7FFDE000 WINWORD(6A)
:thread thread
TID Krnl TEB StackBtm StkTop StackPtr User TEB Process(Id)
0071 FF0889E0 FC42A000 FC430000 FC42FE5C 7FFDE000 WINWORD(6A)
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 9 5
BETA REVI EW
t h read. Code such as t h e followin g obt ain s t h e curren t process
poin t er:
Win32 Subsyst em
I nsi de CSRSS
Th e Win 32 subsyst em server process CSRSS implemen t s t h e Win 32 API.
Th e Win 32 API provides man y differen t t ypes of service, in cludin g
fun ct ion alit y t radit ion ally at t ribut ed t o t h e origin al Win dows compo-
n en t s KERNEL, USER, an d GDI. Alt h ough t h ese st an dard modules exist in
t h e form of 32-bit DLLs un der Win dows NT 3.51, an d t o a lesser degree
un der n ew version s of t h e operat in g syst em, most of t h e core fun ct ion al-
it y is act ually implemen t ed in WINSRV.DLL wit h in t h e CSRSS process.
Calls t h at are t radit ion ally associat ed wit h on e of t h e st an dard Win dows
compon en t s are t ypically implemen t ed as st ubs t h at call ot h er modules,
for example, NTDLL.DLL, or use in t er-process commun icat ion t o CSRSS
for servicin g.
Most USER an d GDI API calls are rout ed t h rough t h e appropriat e 32-bit
module in t h e process address space. Th ere, t h ey are packaged as Local
Procedure Call (LPC) messages an d rout ed t o CSRSS for processin g. As
you migh t imagin e, t h is LPC mech an ism, alt h ough much more
opt imized t h an a t rue Remot e Procedure Call (RPC), h as much more
overh ead t h an a simple fun ct ion call. It is surprisin g t o t h in k t h at every
t ime your applicat ion calls t h e IsWin dow fun ct ion in USER32.DLL, it
must be packaged for LPC an d sen t as a subsyst em message t o CSRSS. For
CSRSS t o be able t o process t h is message, a process swit ch must occur an d
a worker t h read must be awoken an d dispat ch ed. Th e specific service
must be det ermin ed, paramet ers must be validat ed, an d fin ally t h e
service must be execut ed. Wh en everyt h in g is complet e on t h e CSRSS
side, a LPC reply must be made t o t h e clien t (your applicat ion ), wh ich
in volves an ot h er process swit ch an d un packagin g of t h e LPC reply.
Wh ew! All t h at just t o det ermin e if a h an dle represen t s a valid win dow.
In t h eir design of a fort h comin g version of Win dows NT, Microsoft is
workin g t o remove as much of t h is overh ead as possible. First , t h ey are
movin g much of t h e fun ct ion alit y of WINSRV.DLL in t o t h e act ual
USER32 an d GDI32 modules t h at are loaded in t o your applicat ion s
mov eax, FS:[124] ; get the current thread (KTEB)
mov esi, [eax+40h] ; get the threads process pointer (KPEB)
BETA REVI EW
1 9 6 Usi n g Sof t I CE
address space. Th is allows t h e most common services t o execut e as simple
fun ct ion calls; n o LPC is n ecessary. Secon d, rat h er t h an makin g a con t ext
swit ch in t o CSRSS t o access fun ct ion alit y in WINSRV.DLL, a n ew syst em
driver, WIN32K.SYS allows USER an d GDI services t o execut e more
efficien t ly t h rough a simple t ran sit ion from user t o syst em mode. Havin g
WIN32K.SYS as a device driver t h at provides applicat ion services allows
Win dows NT t o main t ain a h igh level of en capsulat ion an d robust n ess,
wh ile providin g a much more efficien t pseudo clien t -server service arch i-
t ect ure.
Alt h ough CSRSS execut es as a separat e process, it st ill h as a big impact on
t h e address space of every Win 32 applicat ion . If you use t h e Soft ICE
HEAP32 comman d on your process, you will n ot ice at least t wo h eaps
t h at your applicat ion did n ot specifically creat e, but were creat ed on it s
beh alf. Th e first is t h e default process h eap t h at was creat ed durin g
process in it ializat ion . Th e secon d is a h eap specifically creat ed by CSRSS.
Th ere may be ot h er h eaps in your applicat ion address space t h at were n ot
creat ed by your process. Th ese h eaps are gen erally locat ed very h igh in
t h e user-mode address space an d appear if you use t h e Soft ICE QUERY
comman d, but do n ot appear in t h e out put of t h e HEAP32 comman d.
Th e reason for t h is is quit e simple: for each user-mode process, a list of
process h eaps is main t ain ed an d t h e Soft ICE HEAP32 comman d uses t h is
list t o en umerat e t h e h eaps for a process. If t h e h eap was n ot creat ed by
or on beh alf of your applicat ion , it does n ot appear in t h e process h eap
list . Th e Soft ICE QUERY comman d t raverses t h e user-mode address space
for your applicat ion , usin g t h e Soft ICE WHAT en gin e t o iden t ify region s
of memory t h at are mapped. Wh en t h e WHAT en gin e en coun t ers a
region wh ose base address is equivalen t t o a h eap t h at is list ed as part of
t h e process h eap list , it is iden t ified as a h eap. If t h e WHAT en gin e
can n ot iden t ify a region as a h eap in t h is man n er, it probes t h e dat a area
lookin g for key sign at ures t h at iden t ify t h e area as h eap or h eap segmen t .
Heaps t h at exist in t h e process address space, but t h at are n ot en umer-
at ed in t h e process h eap list , were mapped in t o t h e process address space
by an ot h er process. In most cases, t h is mappin g is don e by CSRSS.
Durin g subsyst em in it ializat ion , CSRSS creat es a h eap at a well-kn own
base address. Wh en n ew processes are creat ed, t h is h eap is mapped in t o
t h eir address spaces at t h e same well-kn own base address. Th eoret ically,
mappin g t h e h eap of on e process at t h e same base address of an ot h er
process allows bot h processes t o use t h at h eap. In pract ice, t h ere are
issues t h at migh t preven t t h is from workin g un der all circumst an ces
syn ch ron izat ion bein g on e such issue. Not e t h at un der n ewer version s of
Win dows NT, more t h an on e h eap may be mapped in t o t h e process
address space, an d t h ose h eaps may be mapped at differen t base
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 9 7
BETA REVI EW
addresses in differen t processes. Th e Soft ICE QUERY comman d n ot es t h is
con dit ion in it s out put . Also, n ew version s of t h e operat in g syst em use
h eaps t h at are creat ed in t h e syst em address space, an d t h ese h eaps are
somet imes mapped in t o t h e user address space. Win dows NT allows t h e
creat ion of h eaps wit h in t h e syst em address space usin g APIs export ed
from NTOSKRNL. Th ese APIs are similar t o t h e same APIs export ed from
t h e user-mode module, NTDLL.DLL.
USER a nd GDI Obj ect s
Un der Win dows NT 3.51, t h e prot ect ed Win 32 subsyst em process, CSRSS,
provides a majorit y of t h e t radit ion al USER fun ct ion alit y. APIs an d dat a
st ruct ures provided by t h e WINSRV.DLL module man age win dow classes,
an d win dow dat a st ruct ures, as well as man y ot h er USER dat a t ypes.
Un der Win dows NT 3.51, t h e followin g USER object t ypes exist . Object
t ype IDs are list ed in paren t h eses.
FREE ( 0 ) O b j ect En t r y i s u n u sed / i n v al i d .
H W N D ( 1 ) Wi n d o w O b j ect s.
M EN U ( 2 ) Wi n d o w s M EN U o b j ect .
I CO N / CU RSO R ( 3 ) Wi n d o w s ICO N o r CURSO R o b j ect .
D EFERW I N D O W PO S ( 4 ) O b j ect r et u r n ed b y t h e
Beg i n D ef er Wi n d o w Po si t i o n API.
H O O K ( 5 ) Wi n d o w s Ho o k t h u n k.
TH READ I N FO ( 6 ) CSRSS Cl i en t Th r ead In st an ce D at a.
Q U EU E ( 7 ) Wi n d o w s m essag e q u eu e.
CPD ( 8 ) Cal l Pr o ced u r e D at a t h u n k.
ACCELERATO R ( 9 ) Accel er at o r Tab l e O b j ect .
W I N D O W STATI O N ( 0 xA)
D ESKTO P ( 0 xB) O b j ect r ep r esen t i n g a d eskt o p w i n d o w
h i er arch y.
D D EO BJECT ( 0 xC) D D E O b j ect s su ch as st r i n g s.
BETA REVI EW
1 9 8 Usi n g Sof t I CE
Newer version s of Win dow NT add/ redefin e t h e followin g USER object
t ypes.
Rat h er t h an main t ain in g per-process dat a st ruct ures for USER an d GDI
object t ypes, CSRSS main t ain s a mast er h an dle t able for all processes. Th e
USER an d GDI object s are segregat ed in t o t wo differen t t ables t h at h ave
t h e same basic st ruct ure an d seman t ics. WINSRV provides dist in ct
Han dle Man ager APIs for man agin g t h e t wo differen t t ables. You can
iden t ify t h e h an dle man ager API n ames by t h e HM prefix in fron t of t h e
API n ame, an d t h e GDI specific rout in es by t h e g appen ded t o t h is
prefix. Th e rout in e HMAllocObject creat es USER object t ypes, wh ile
HmgAlloc is a GDI object t ype API t h at creat es GDI object t ypes.
Th e man agemen t of USER an d GDI h an dles is relat ively st raigh t forward,
an d it s design is a good example of h ow t o implemen t basic man agemen t
of abst ract object t ypes. Specifically, t h is API uses a simple, but robust ,
t ech n ique for creat in g un ique h an dles an d man agin g referen ce coun t s.
Th e design also provides for h an dle opaquen ess wh ich preven t s applica-
t ion s, in cludin g USER32 an d CSRSS, from direct ly man ipulat in g t h e
object s out side t h e h an dle man ager. Preven t in g clien t s, in cludin g it self,
from direct ly man ipulat in g t h e object dat a allows t h e h an dle man ager t o
en sure t h at referen ce coun t s an d syn ch ron izat ion issues are man aged
correct ly.
Th e mast er object t ables main t ain ed by t h e Han dle Man ager are
growable arrays of fixed size en t ries. Th e followin g t able list s t h e fields for
D ESKTO P ( - - - ) Th i s O b j ect t y p e h as b een r em o v ed . Th i s t y p e
i s n o w a ker n el o b j ect t h at i s m an ag ed b y t h e
Ker n el O b j ect M an ag er.
Q U EU E ( - - - ) Th i s O b j ect t y p e h as b een r em o v ed .
W I N D O W STATI O N ( 0 xD ) Ch an g ed O b j ect t y p e ID . Al so ex i st s as a
ker n el o b j ect .
D D EO BJECT ( 0 xA) Ch an g ed O b j ect t y p e ID .
KEYBO ARD LAYO U T ( 0 xE) N ew O b j ect t y p e. O b j ect t o d escr i b e a
key b o ar d l ay o u t .
CLI PBO ARD FO RM AT ( 7 ) N ew O b j ect t y p e. Reg i st er ed Cl i p b o ar d
Fo r m at s.
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 1 9 9
BETA REVI EW
an object t able. On ly column s wit h bold field h eaders are part of t h e
en t ry. Th e column s wit h italicized h eaders are for illust rat ion on ly.
Th e Object Poin t er field poin t s t o t h e act ual object dat a. Th is poin t er is
gen erally from on e of t h e CSRSS h eaps or t h e Paged Pool. Th e t ype field
is t h e en umerat ion for t h e object t ype. Th e In st an ce Coun t field creat es
un ique h an dles. Th e Flags field is used by t h e Han dle Man ager t o n ot e
special con dit ion s, such as wh en a t h read locks an object for exclusive
use.
H o w H an d le Values Ar e Cr eat ed
In it ially, all object t able In st an ce coun t s are set t o 1. Wh en a n ew Object
En t ry is allocat ed, t h e In st an ce Coun t is combin ed wit h t h e t able in dex
t o creat e a un ique h an dle value. Wh en referen ces are made t o an object ,
t h e t able en t ry port ion of t h e h an dle is ext ract ed an d used t o in dex in t o
t h e t able. As part of t h e h an dle validat ion , t h e in st an ce coun t is ext ract ed
from t h e t able en t ry an d compared t o t h e h an dle bein g validat ed. If t h e
in st an ce coun t does n ot mat ch t h e t able en t ry in st an ce coun t , t h e
h an dle is bogus. Th e followin g example illust rat es t h ese con cept s:
To creat e an object h an dle from an object t able en t ry:
Object Handle = Table Entry Index + (InstanceCount << 16);
To validat e an object h an dle:
ObjectTable [LOWORD(handle)]. InstanceCount ==
HIWORD(handle);
Wh en an object is dest royed, all fields are rein it ialized t o zero an d t h e
curren t In st an ce Coun t for t h at en t ry is in cremen t ed by on e. Th us, wh en
t h e object t able en t ry is reused, it gen erat es a differen t h an dle value for
t h e n ew object .
N o t e : Th e act u al o b j ect t y p e i s n o t p ar t o f t h e o b j ect h an d l e v al u e. Th i s
m ean s t h at g i ven an o b j ect h an d l e, an ap p l i cat i o n can n o t d i r ect l y
d et er m i n e i t s t y p e. I t i s n ecessar y t o d er ef er en ce t h e o b j ec t t ab l e
en t r y t o o b t ai n t h e o b j ect t y p e.
En t r y
O b je ct
Po in t e r
( D W O RD )
O w n e r
( D W O RD )
Typ e
( BYT E)
Fl ag s
( BYT E)
I n st a n ce
Co u n t
( W O RD )
H a n d l e Va l u e
0 N ULL N ULL FREE ( 0 ) 0 0 0 0 0 1 0 0 0 1 0 0 0 0
1 HEAP * HEAP * D ESKTO P ( 0 C) 0 0 0 0 0 1 0 0 0 1 0 0 0 1
2 HEAP * HEAP * HW N D ( 0 4 ) 0 1 0 0 0 3 0 0 0 3 0 0 0 2
BETA REVI EW
2 0 0 Usi n g Sof t I CE
Th is t ech n ique for creat in g un ique h an dle values is simple an d efficien t ,
an d makes validat ion t rivial. Imagin e t h e case wh ere a process creat es a
win dow an d obt ain s a h an dle t o t h at win dow. Durin g subsequen t
program execut ion , t h e process dest roys t h e win dow but ret ain s t h e
h an dle value. If t h e process uses t h e h an dle aft er t h e win dow is
dest royed, t h e h an dle value is in valid an d t h e t ype it poin t s t o h as an
object t ype of FREE. Th is con dit ion is caugh t , an d t h e program is n ot be
able t o use t h e h an dle successfully. In t h e mean t ime, if an ot h er process
creat es a n ew object , it is likely t h at t h e en t ry origin ally for t h e n ow
dest royed win dow will be reused. If t h e origin al program uses t h e in valid
win dow h an dle, t h e h an dle in st an ce coun t s n o lon ger mat ch , an d t h e
validat ion fails.
Object t ables are n ot process specific, so USER an d GDI object h an dles
values are n ot un ique t o a specific process. HWND h an dles are un ique
across t h e en t ire Win 32 subsyst em. On e process n ever h as an HWND
h an dle value t h at is duplicat ed in an y ot h er process.
U SER O b ject Tab le
Use t h e Soft ICE OBJTAB comman d t o display all t h e object en t ries wit h in
t h e USER object t able. Th e OBJTAB comman d is relat ively flexible, allow-
in g a h an dle or t able en t ry in dex t o be specified. It also support s t h e
display of object s by t ype usin g abbreviat ion s for t h e object t ype n ames.
To see a list of object t ype n ames t h at t h e OBJTAB comman d can use,
specify t h e -H opt ion on t h e OBJTAB comman d lin e.
Th e Object Poin t er field can referen ce t h e object specific dat a for an
object t able en t ry. All object s h ave a gen eric h eader t h at is main t ain ed by
t h e object man ager, wh ich in cludes t h e object h an dle value an d a t h read
referen ce coun t . Most object t ypes also con t ain a poin t er t o a deskt op
object an d/ or a poin t er t o it s own er.
Th e followin g example sh ows an object t able en t ry for a win dow h an dle
an d a dat a dump of t h e object h eader main t ain ed by t h e h an dle
man ager. Key in format ion from t h e comman d out put is list ed in bold.
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 0 1
BETA REVI EW
1 Use t h e Soft ICE OBJTAB comman d t o fin d an arbit rary win dow h an -
dle an d obt ain t h e object poin t er. In t h is example, t h e h an dle value is
0x1000C an d t h e own er field is 0xE12E7008:
2 Dumpin g 0x20 byt es of t h e object dat a reveals t h e followin g:
Th e value 0x1001C, at offset 0, is t h e object h an dle value. Th e field at
offset 4, wh ich con t ain s t h e value six (6), is t h e object referen ce
coun t . Th e value at offset 0x0C, of 0xFF0E45D8, is a poin t er t o t h e
win dows deskt op object .
3 Verify t h is usin g t h e Soft ICE WHAT comman d as follows:
:what ff0e45d8
The value FF0E45D8 is (a) Kernel Desktop object (handle=0068) for
winlogon(21)
Th e value at offset 0x14, of 0xE12E7008, is t h e same value t h at was
in t h e object en t ry own er field.
4 Dumpin g 0x20 byt es at t h e address of t h e own er dat a reveals t h e fol-
lowin g:
5 Th e value (0x1001B) at offset 0 of t h e own er dat a looks like an object
h an dle, but it is a t h read in format ion object . Th e followin g example
uses t h e OBJTAB comman d wit h 0x1001B as t h e paramet er t o sh ow
t h e t ype for t h e own er dat a.
: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
:dd e12e7008 l 20
0010:E12E7008 0001001B 00000000 00000000 E12E9C34
0010:E12E7018 E17DB714 00000000 00000000 00000000
:objtab 1001b
Object Type Id Handle Owner Flags
E12E7008 Thread Info 06 0001001B 00000000 00
BETA REVI EW
2 0 2 Usi n g Sof t I CE
M on it or in g U SER O b ject Cr eat io n
If you do a con siderable amoun t of Win 32 applicat ion developmen t , t h e
HMAllocObject API is a con ven ien t place t o mon it or creat ion of object
t ypes such as win dows. Use t h e Soft ICE MACRO comman d t o creat e a
breakpoin t t emplat e t h at can t rap creat ion of specific object t ypes as
follows:
:MACRO obx = bpx winsrv!HMAllocObject if (esp->c == %1)
Th e HMAllocObject API is implemen t ed in WINSRV.DLL an d t h e object
t ype bein g creat ed is t h e t h ird paramet er, wh ich t ran slat es t o Dword pt r
esp [ 0Ch ]. Th e syn t ax esp->c dereferen ces t h e request ed object t ype,
an d is equivalen t t o *(esp+c). Th e %1 port ion of t h e con dit ion al
expression is a place h older for argumen t replacemen t . Wh en you
execut e t h e OBX macro, t h e argumen t provided is in sert ed in t o t h e
macro st ream at t h e %1:
:OBX 1 -> bpx winsrv!HMAllocObject if (esp->c == 1)
Wh en t h is breakpoin t is in st an t iat ed, it t raps all calls t o HMAllocObject
t h at creat es win dow object t ypes.
Pr ocess Addr ess Spa ce
Th e address space for a user-mode process is mapped in t o t h e lower 2GB
of lin ear memory at addresses 0x00000000 - 0x7FFFFFFF. Th e upper 2GB
of lin ear memory is reserved for t h e operat in g syst em kern el an d device
drivers.
In gen eral, each Win 32 applicat ion s process address space h as t h e
followin g region s of lin ear memory mapped for t h e correspon din g
purpose.
Tab l e 1 2 - 4 . Pr o cess Ad d r ess Sp ac e
Li n e ar Ad d r ess Ran g e Pur p ose
0 x 0 0 0 0 0 0 0 0 - 0 x 0 0 0 0 FFFF Pr o t ect ed r eg i o n . Usef u l f o r d et ect i n g
N ULL p o i n t er w r i t es.
0 x 0 0 0 1 0 0 0 0 D ef au l t l o ad ad d r ess f o r Wi n 3 2 p r o cesses.
0 x 7 0 0 0 0 0 0 0 - 0 x 7 8 0 0 0 0 0 0 Ty p i cal r an g e f o r Wi n 3 2 su b sy st em D LLs
t o b e l o ad ed .
0 x 7 FFB0 0 0 0 - 0 x 7 FFD 3 FFF AN SI an d O EM co d e p ag es. Un i co d e
t r an sl at i o n t ab l e( s) .
0 x 7 FFD E0 0 0 - 0 x 7 FFD EFFF Pr i m ar y u ser - m o d e t h r ead en vi r o n m en t
b l o ck.
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 0 3
BETA REVI EW
Un der Win dows NT, t h e lowest an d h igh est 64KB region s in t h e user-
mode address space are reserved an d are n ever mapped t o ph ysical
memory. Th e 64KB at t h e bot t om of t h e lin ear address space is design ed
t o h elp cat ch writ es t h rough NULL poin t ers.
Th e default load address for processes un der Win dows NT is 0x10000.
Processes oft en ch an ge t h eir load address t o a differen t base address.
Applicat ion s t h at were design ed t o run on Win dows 95 an d Win dows 98
h ave a default load address of 0x400000. Use t h e lin ker or t h e REBASE
ut ilit y t o set t h e default load address of a DLL or EXE.
Th e lin ear ran ge at 0x70000000 is an approximat ion of t h e area wh ere
Win 32 subsyst em modules load. Use t h e Soft ICE MOD, MAP32, or
QUERY comman ds t o obt ain in format ion on modules loaded in t h is
ran ge.
Th e user process en viron men t block is always mapped at 0x7FFDF000,
wh ile t h e processs primary user-mode t h read en viron men t block is on e
page below t h at at 0x7FFDE000. As a process creat es ot h er worker
t h reads, t h ey are mapped on page boun daries at t h e curren t , h igh est
un used lin ear address.
Th e followin g use of t h e Soft ICE THREAD comman d sh ows h ow each
subsequen t t h read is placed on e page below t h e previous t h read:
To fin d out more about t h e user-mode address space of a process, use t h e
Soft ICE QUERY comman d. Th e QUERY comman d provides a h igh -level
view of t h e lin ear region s t h at were reserved an d/ or commit t ed. It uses
t h e Soft ICE WHAT en gin e t o iden t ify t h e con t en t s of a lin ear ran ge. From
0 x 7 FFD F0 0 0 - 0 x 7 FFD FFFF User - m o d e p r o cess en vi r o n m en t b l o ck
( UPEB) .
0 x 7 FFE0 0 0 0 - 0 x 7 FFE0 FFF M essag e q u eu e r eg i o n .
0 x 7 FFFF0 0 0 - 0 x 7 FFFFFFF Pr o t ect ed r eg i o n .
: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)
Tab l e 1 2 - 4 . Pr o cess Ad d r ess Sp ac e
Li n e ar Ad d r ess Ran g e Pur p ose
BETA REVI EW
2 0 4 Usi n g Sof t I CE
it s out put you see t h e process h eaps, modules, an d memory-mapped
files, as well as t h e t h read st acks an d t h read en viron men t blocks.
Hea p API
H eap Ar ch it ect ur e
Every user-mode applicat ion direct ly or in direct ly uses t h e Heap API
rout in es, wh ich are export ed from KERNEL32 an d NTDLL. Heaps are
design ed t o man age large areas of lin ear memory an d sub-allocat e
smaller memory blocks from wit h in t h is region . Th e core implemen t a-
t ion of t h e Heap API rout in e is con t ain ed wit h in NTDLL, but some of t h e
applicat ion in t erfaces such as HeapCreat e an d HeapValidat e are export ed
from KERNEL32. For some API rout in es, such as HeapFree, t h ere is n o
code implemen t at ion wit h in KERNEL32, so t h ey are fixed by t h e loader
t o poin t at t h e act ual implemen t at ion wit h in NTDLL.
N o t e : Th e t ech n i q u e o f f i x i n g an ex p o r t i n o n e m o d u l e t o t h e ex p o r t o f
an o t h er m o d u l e i s cal l ed Sn ap p i n g .
Alt h ough t h e Heap API rout in es used by applicat ion s are relat ively
st raigh t forward an d design ed for ease of use, t h e implemen t at ion an d
dat a st ruct ures un dern eat h are quit e soph ist icat ed. Th e man agemen t of
h eap memory h as come quit e a lon g way from t h e st an dard C run -t ime
library rout in es malloc() an d free(). Specifically, t h e Heap API h an dles
allocat ion s of large, n on -con t iguous region s of lin ear memory, wh ich are
used for sub-allocat ion an d t o opt imize coalescin g of adjacen t blocks of
free memory. Th e Heap API also performs fast look-ups of best -fit block
sizes t o sat isfy allocat ion request s, provides t h read-safe syn ch ron izat ion ,
an d supplies ext en sive h eap in format ion an d debuggin g support .
Th e primary h eap dat a st ruct ure is large, at approximat ely 1400 byt es, for
a free build an d t wice t h at for a ch ecked build. Th is does n ot in clude t h e
size of ot h er dat a st ruct ures t h at h elp man age lin ear address region s. A
vast majorit y of t h is overh ead is at t ribut ed t o 128 doubly-lin ked list
n odes t h at man age free block ch ain s. Small blocks, less t h an 1KB in size,
are st ored wit h ot h er blocks of t h e same size in doubly lin ked list s. Th is
makes fin din g a best -fit block very fast . Blocks larger t h an 1KB are st ored
in on e sort ed, doubly-lin ked list . Th is is an obvious example of a t ime
versus space t rade-off, wh ich could be import an t t o t h e performan ce of
your applicat ion .
To un derst an d t h e design an d implemen t at ion of t h e Heap API, it is
import an t t o realize t h at a Win 32 h eap is n ot n ecessarily composed of
on e sect ion of con t iguous lin ear memory. For growable h eaps, it migh t
be n ecessary t o allocat e man y lin ear region s, usin g Virt ualAlloc, wh ich
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 0 5
BETA REVI EW
will gen erally be n on -con t iguous. Special dat a st ruct ures t rack all t h e
lin ear address region s t h at comprise t h e h eap. Th ese dat a st ruct ures are
call Heap Segmen t s. An ot h er import an t aspect of t h e Heap API design is
t h e use of t h e t wo-st age process of reservin g an d commit t in g virt ual
memory t h at is provided by t h e Virt ualAlloc an d relat ed APIs. Man agin g
wh ich memory is reserved an d wh ich memory is commit t ed requires
special dat a st ruct ures kn own as Un commit t ed Ran ge Tables, or UCRs for
sh ort .
Th e Nt dll!Rt lCreat eHeap() API implemen t s h eap creat ion an d in it ializa-
t ion . Th is rout in e allocat es t h e in it ial virt ual region wh ere t h e h eap
resides an d builds t h e appropriat e dat a st ruct ures wit h in t h e h eap. Th e
h eap dat a st ruct ure an d Heap Segmen t #1 reside wit h in t h e in it ial 4KB
(on e page) of t h e virt ual memory t h at is in it ially allocat ed for t h e h eap.
Heap Segmen t #1 resides just beyon d t h e h eap h eader. Heap Segmen t #1
is in it ialized t o man age t h e in it ial virt ual memory allocat ed for t h e h eap.
An y commit t ed memory beyon d Heap Segmen t #1 is immediat ely avail-
able for allocat ion t h rough HeapAlloc(). If an y memory wit h in Heap
Segmen t #1is reserved, a UCR t able en t ry is used t o t rack t h e un commit -
t ed ran ge.
N o t e : Ker n el 3 2 ! Heap Al l o c( ) i s Sn ap p ed t o N t d l l ! Rt l Al l o cat eHeap .
Besides t h e 128 free list s men t ion ed above, t h e h eap h eader dat a st ruc-
t ure con t ain s 8 UCR t able en t ries, wh ich sh ould be sufficien t for small
h eaps, alt h ough as man y UCRs as are n ecessary can be creat ed. It also
con t ain s a t able for sixt een (16) Heap Segmen t poin t ers. A h eap can
n ever h ave more t h an sixt een segmen t s, as n o provision is made for
allocat in g ext ra segmen t s en t ries. If t h e h eap requires t h read syn ch ron i-
zat ion , t h e h eap h eader appen ds a crit ical sect ion dat a st ruct ure t o t h e
en d of t h e fixed size port ion of t h e h eap h eader precedin g Heap Segmen t
#1.
Th e diagram on t h e n ext page is a h igh -level illust rat ion of h ow a t ypical
h eap is con st ruct ed, an d h ow t h e most import an t pieces relat e t o each
ot h er.
Th e left side of t h e diagram represen t s a region of virt ual memory t h at is
allocat ed for t h e h eap. Th e h eap h eader appears at t h e begin n in g of t h e
allocat ed memory an d is followed by Heap Segmen t #1. Th e first en t ry
wit h in t h e h eaps segmen t t able poin t s t o t h is dat a st ruct ure. Commit t ed
memory immediat ely follows Heap Segmen t #1. Th is memory is in it ially
marked as a free block. Wh en an allocat ion request is made, assumin g
t h is block of memory is large en ough , a port ion is used t o sat isfy t h e
allocat ion an d t h e remain der con t in ues t o be marked as a free block.
Beyon d t h e commit t ed region is an area of memory t h at is reserved for
BETA REVI EW
2 0 6 Usi n g Sof t I CE
Fi g u r e 1 2 -2 . Ty p i cal Heap Co n st r u ct i o n
fut ure use. Wh en an allocat ion request requires more memory t h an is
curren t ly commit t ed, a port ion of t h is area is commit t ed t o sat isfy t h e
request .
Heap Segmen t #1 t racks t h e virt ual memory region in it ially allocat ed for
t h e h eap. Th e st art in g address for t h e h eap segmen t equals t o t h e base
address of t h e h eap an d t h e en d ran ge poin t s t o t h e en d of t h e allocat ed
memory. A port ion of t h e h eap in t h e diagram is in a reserved st at e, t h at
is, it h as n ot been commit t ed, so t h e h eap segmen t uses an available UCR
en t ry t o t rack t h e area. Wh en memory must be commit t ed t o sat isfy an
allocat ion request , all UCR en t ries main t ain ed by a part icular segmen t
are examin ed t o det ermin e if t h e size of t h e un commit t ed ran ge is large
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 0 7
BETA REVI EW
en ough t o sat isfy t h e allocat ion . To in crease performan ce, t h e h eap
segmen t t racks t h e largest available UCR ran ge an d t h e t ot al n umber of
un commit t ed pages wit h in t h e virt ual memory region of t h e h eap
segmen t .
On t h e righ t side of t h e diagram, a secon d area of virt ual memory was
allocat ed an d is man aged by Heap Segmen t #2. Addit ion al h eap segmen t s
are creat ed wh en an allocat ion request exceeds t h e size of t h e largest
un commit t ed ran ge wit h in t h e exist in g segmen t . Th is is on ly t rue if t h e
size of t h e request ed allocat ion is less t h an t h e h eaps VMt h resh old.
Wh en t h e request ed allocat ion size exceeds t h e VMTh resh old, t h e h eap
block is direct ly allocat ed t h rough Virt ualAlloc an d a n ew h eap segmen t
is n ot creat ed.
As men t ion ed previously, a small n umber of UCR en t ries are provided
wit h in t h e h eap h eader. For illust rat ion purposes, t h is diagram sh ows a
UCR TABLE en t ry t h at was allocat ed specifically t o in crease t h e n umber
of UCR en t ries t h at are available. Th e n eed t o creat e an ext ra UCR t able is
gen erally rare, an d is usually a sign t h at a large n umber of segmen t s were
creat ed or t h at t h e h eap segmen t s are fragmen t ed.
Fragmen t at ion of virt ual memory can occur wh en t h e Heap API begin s
decommit t in g memory durin g t h e coalescin g of free blocks. Decommit -
t in g memory is t h e t erm used t o describe revert in g memory from a
commit t ed st at e t o a reserved or un commit t ed st at e. Wh en a free block
span s more t h an on e ph ysical page (4k), t h at page becomes a can didat e
for bein g decommit t ed. If cert ain decommit t h resh old values are sat is-
fied, t h e Heap man ager begin s decommit t in g free pages. Wh en t h ose
pages are n ot con t iguous wit h an exist in g un commit t ed ran ge, a n ew
UCR en t ry must be used t o t rack t h e ran ge.
Th e followin g examples use t h e Soft ICE HEAP32 comman d t o examin e
t h e default h eap for t h e Explorer process.
1 Use t h e -S opt ion of t h e HEAP32 comman d t o display segmen t in for-
mat ion for t h e default h eap:
2 Use t h e -X opt ion of t h e HEAP32 comman d t o display ext en ded
in format ion about t h e default h eap:
BETA REVI EW
2 0 8 Usi n g Sof t I CE
:heap32 -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 segment memory range
Largest UCR
Heap segment count
:heap32 -x 140000
Ext en ded Heap Summary for h eap 00140000 in Explorer
Heap Base: 140000 Heap Id: 1 Process: Explorer
Total Free: 6238 Alignment: 8 Log Mask: 10000
Seg Reserve: 100000 Seg Commit: 2000
Committed: 112k Present: 96k Reserved: 912k
Flags: GROWABLE
DeCommit: 1000 Total DeC: 10000 VM Alloc: 7F000
Default size for commits VM threshold Default size of a heap segment
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 0 9
BETA REVI EW
3 Use t h e -B opt ion of t h e HEAP32 comman d t o display t h e base
addresses of h eap blocks wit h in t h e default h eap:
In t h e above out put , you can see h ow t h e h eap h eader is followed by
Heap Segmen t #1 an d t h at t h e first allocat ed block is just beyon d t h e
Heap Segmen t dat a st ruct ure.
M an ag in g H e ap Blo cks
As discussed in t h e precedin g sect ion , t h e Heap API uses t h e Win 32
Virt ual Memory API rout in es t o allocat e large region s of t h e lin ear
address space an d uses h eap segmen t s t o man age commit t ed an d un com-
mit t ed ran ges. Th e act ual sub-allocat ion en gin e t h at man ages t h e alloca-
t ion an d deallocat ion of t h e memory blocks used by your applicat ion is
built on t op of t h is fun ct ion alit y. To t rack allocat ed an d free blocks, t h e
Heap API creat es a h eader for each block.
Th e diagram on t h e n ext page illust rat es h ow t h e h eap man ager t racks
blocks of contiguous memory. Th e h eap man ager also t racks n on -con t igu-
ous free blocks in doubly-lin ked list s, but t h e n ode poin t ers for t h e n ext
an d previous lin ks are n ot st ored in t h e block h eader. In st ead, t h e h eap
man ager uses t h e first t wo Dwords wit h in t h e h eap block memory area.
.As sh own in t h e diagram, each block st ores it s un it size as well as t h e
un it size of t h e previous block. Th e un it size represen t s t h e n umber of
h eap un it s occupied by t h e h eap block. Th e previous un it size is t h e
n umber of h eap un it s occupied by t h e previous h eap block. Usin g t h ese
t wo values, t h e h eap man ager is able t o walk con t iguous h eap blocks.
Heap un it s represen t t h e base gran ularit y of allocat ion s made from a
h eap. Th e size of an allocat ion request is roun ded upwards as n ecessary,
so t h at it is an even mult iple of t h is gran ularit y. Rat h er t h an usin g a
gran ularit y of 1 byt e, t h e h eap man ager uses a gran ularit y of 8 byt es. Th is
mean s t h at all allocat ion s are an even mult iple of 8 byt es, an d t h at
allocat ion sizes can be con vert ed t o un it s by roun d up an d dividin g by 8.
For example, if a process request s an allocat ion of 32 byt es, t h e n umber
of un it s is 32 / 8 = 4. If t h e allocat ion request was 34 byt es, t h e allocat ion
size is roun ded upward t o an even mult iple of 8. In t h is example, t h e 34
:heap32 -b 140000
Base Type Size Seg# Flags
00140000 HEAP 580 01
00140580 SEGMENT 38 01
001405B8 ALLOC 30 01
BETA REVI EW
2 1 0 Usi n g Sof t I CE
Fi g u r e 1 2 -3 . Co n t i g u o u s M em o r y Tr acki n g
byt es request ed would be roun ded t o an allocat ion of 40 byt es, or 5 un it s.
Th e process request in g t h e allocat ion is un aware of an y roun din g t o
sat isfy un it gran ularit y an d proceeds as if t h e allocat ion request of 34
byt es was act ually 34 byt es.
By usin g a un it size of 8, t h e t ypes of allocat ion made by most applica-
t ion s can be recorded usin g on e word value wit h t h e rest rict ion t h at t h e
maximum size of a h eap block, in un it s, is t h e largest un sign ed sh ort or
0xFFFF. Th is makes t h e t h eoret ical maximum size of a h eap block in
byt es, 0xFFFF * 8, or 524,280 byt es. (Th is limit at ion is documen t ed in t h e
Win 32 HeapAlloc API documen t at ion .) Does t h at mean t h at a program
can n ot allocat e a h eap block great er t h an 512k? Well, yes an d n o. A h eap
block larger t h an 512k can n ot be allocat ed, but t h ere is n ot h in g t o
preven t t h e Heap API from usin g Virt ualAlloc t o allocat e a region of
lin ear memory t o sat isfy t h e request . Th is is exact ly wh at t h e h eap
man ager does if t h e size of t h e request ed allocat ion exceeds t h e h eaps
VMTh resh old. Th e value of VMTh resh old is st ored in t h e h eap h eader
an d by default is 520,192 byt es (or 0xFE000 un it s). Wh en t h e h eap
man ager allocat es a large h eap block usin g Virt ualAlloc, t h e result in g
st ruct ure is referred t o as a Virt ually Allocat ed Block (VAB).
Th e h eap man ager walks con t iguous h eap blocks by con vert in g t h e
curren t h eap blocks un it size in t o byt es an d addin g t h at t o t h e h eap
blocks base address. Th e address of t h e previous h eap block is calculat ed
in a similar man n er, con vert in g t h e un it size of t h e previous block t o
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 1 1
BETA REVI EW
byt es an d subt ract in g it from t h e h eap blocks base address. Th e h eap
man ager walks con t iguous h eap blocks durin g coalescin g free blocks,
sub-allocat in g a smaller block from a larger free block, an d wh en validat -
in g a h eap or h eap en t ry.
Un it sizes are import an t for free block list man agemen t as t h e array of
128 doubly-lin ked list s in side t h e h eap h eader t rack free blocks by un it
size. Free blocks t h at h ave a un it size in t h e ran ge from 1 t o 127 are
st ored in t h e free list at t h e correspon din g array in dex. Th us, all free
blocks of un it size 32 are st ored in Heap->FreeList s[32]. Because it is n ot
possible t o h ave a h eap block t h at is 0 un it s, t h e free list at array in dex
zero st ores all h eap blocks t h at are larger t h an 127 un it s; t h ese en t ries are
sort ed by size in ascen din g order. Because a majorit y of allocat ion s made
by a process are less t h an 128 un it s (1024 byt es or 1K), t h is is a fast way
t o fin d an exact or best fit block t o sat isfy an allocat ion . Blocks of 128
un it s or great er are allocat ed much less frequen t ly, so t h e overh ead of
doin g a lin ear search of on e free list does n ot h ave a large impact on t h e
overall performan ce of most applicat ion s.
Th e flags field wit h in t h e h eap block h eader den ot es special at t ribut es of
t h e block. On e bit is used t o mark a block as allocat ed versus free.
An ot h er is used if it is a VAB. An ot h er is used t o mark t h e last block
wit h in a commit t ed region . Th e last block wit h in a commit t ed region is
referred t o as a sen t in el block, an d in dicat es t h at n o more con t iguous
blocks follow. Usin g t h is flag is much fast er t h an det ermin in g if a h eap
block address is valid by walkin g t h e h eap segmen t s UCR ch ain . An ot h er
flag is used t o mark a block for free or busy-t ail ch eckin g. Wh en a process
is debugged, t h e h eap man ager marks t h e block in cert ain ways. Th us,
wh en an allocat ed block is released or a free block is reallocat ed, t h e h eap
man ager can det ermin e if t h e h eap block was overwrit t en in an y way.
Th e ext ra in fo fields of t h e h eap block h eader h ave differen t usage
depen din g on wh et h er t h e block is allocat ed or free. In an allocat ed
block, t h e first field records t h e n umber of ext ra byt es t h at were allocat ed
t o sat isfy gran ularit y or align men t requiremen t s. Th e secon d field is a
pseudo-t ag. Heap t ags an d pseudo t ags are beyon d t h e scope of t h is
discussion .
For a free block, t h e ext ra in fo fields h old byt e an d bit -mask values t h at
access a free-list -in -use bit -field main t ain ed wit h in t h e h eap h eader. Th is
bit -field provides quicker lookups wh en a small block n eeds t o be
allocat ed. Each bit wit h in t h e bit -field represen t s on e of t h e 127 small
block free list s, an d if t h e correspon din g bit is set , t h at free list con t ain s
on e or more free en t ries. A zero bit mean s t h at a free en t ry of t h at size is
n ot available an d a larger block will n eed t o be sub-allocat ed from. Th e
first ext ra in fo field h olds t h e byt e in dex in t o t h e bit -field array. Th e
BETA REVI EW
2 1 2 Usi n g Sof t I CE
secon d ext ra in fo field h olds t h e in vert ed mask of t h e bit posit ion wit h in
t h e bit -field. Not e t h at t h is applies t o Win dows NT 3.51 on ly. Newer
version s of Win dows NT st ill use t h e free list bit -field, but do n ot st ore
t h e byt e in dex or bit -mask values. Th e h eap block memory array is also
differen t depen din g on t h e allocat ed st at e of t h e free block. For allocat ed
blocks, t h is is t h e act ual memory used by your applicat ion . For free
blocks, t h e first t wo Dwords (1 un it ) are used as n ext an d previous poin t -
ers t h at lin k free blocks t oget h er in a doubly-lin ked list . If t h e process
t h at allocat ed t h e h eap block is bein g debugged, an allocat ed h eap block
also con t ain s a busy-t ail sign at ure at t h e en d of t h e block. Free blocks are
marked wit h a special t ag t h at can det ect if a st ray poin t er writ es in t o t h e
h eap memory area, or t h e process con t in ues t o use t h e block aft er it was
deallocat ed.
Th e followin g diagram sh ows t h e basic arch it ect ure of an allocat ed h eap
block.
Fi g u r e 1 2 -4 . Basi c Arc h i t ect u r e o f an Al l o cat ed Heap Bl o ck
Th e port ion labeled Extra Bytes is memory t h at was n eeded t o sat isfy t h e
h eap un it size or h eap align men t requiremen t s. Th is memory area sh ould
n ot be used by t h e allocat in g process, but t h e h eap man ager does n ot
direct ly prot ect t h is area from bein g overwrit t en . Th e busy-t ail sign at ure
appears just beyon d t h e en d of t h e memory allocat ed for use by t h e
process. If an applicat ion writ es beyon d t h e size of t h e area request ed,
t h is sign at ure is dest royed an d t h e h eap man ager sign als t h e debugger
wit h a debug message an d an INT 3. It is possible for a process t o writ e
in t o t h e ext ra byt es area wit h out dist urbin g t h e busy-t ail sign at ure. In
t h is case, t h e overwrit e is n ot caugh t . Th e Heap API provides an opt ion
for in it ializin g h eap memory t o zero upon allocat ion . If t h is opt ion is n ot
specified wh en debuggin g, t h e h eap man ager fills t h e allocat ed memory
block wit h a special sign at ure. You can use t h is sign at ure t o det ermin e if
t h e memory block was properly in it ialized in your code.
Th e followin g diagram sh ows t h e basic arch it ect ure of a free h eap block.
Fi g u r e 1 2 -5 . Basi c Arc h i t ect u r e o f a Fr ee Heap Bl o ck
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 1 3
BETA REVI EW
Wh en a block is deallocat ed an d t h e process is bein g debugged, t h e h eap
man ager writ es a special sign at ure in t o t h e h eap memory area. Wh en t h e
block is allocat ed at some poin t in t h e fut ure, t h e h eap man ager ch ecks
t h at t h e t ag byt es are in t act . If an y of t h e byt es was ch an ged, t h e h eap
man ger out put s a debug message an d execut es an INT 3 in st ruct ion . Th is
is a good t h in g if t h e debugger you are usin g t raps t h e INT 3, but most
debuggers ign ore t h is debug-break because it was n ot set by t h e debugger.
As an aside, h avin g t h e Free List Node poin t ers at t h e begin n in g of t h e
memory block is somewh at flawed, because a program t h at con t in ues t o
use a free block is more likely t o overwrit e dat a at t h e begin n in g of t h e
block t h an dat a at t h e en d. Because t h ese poin t ers are crucial t o n avigat -
in g t h e h eap, an in valid poin t er even t ually causes an except ion . Wh en
t h is except ion occurs, it can be quit e difficult t o t rack t h is overwrit e back
t o t h e origin al free block.
Th e followin g t wo examples sh ow h ow t o use t h e Soft ICE HEAP32
comman d t o aid in mon it orin g an d debuggin g Win 32 h eap issues.
Th e first example uses t h e HEAP32 comman d t o walk all t h e en t ries for
t h e h eap based at 0x140000. Th e -B opt ion of t h e HEAP32 comman d
causes t h e base address an d size in format ion t o display as t h e h eap
man ager would view t h e in format ion . Wit h out t h e -B opt ion , t h e
HEAP32 comman d sh ows base addresses an d sizes as viewed by t h e appli-
cat ion t h at allocat ed t h e memory. Th e out put is abbreviat ed for clarit y
an d t h e t wo h eap blocks t h at appear in bold t ype are used t o examin e t h e
h eap block h eader in t h e secon d example.
To examin e t h e con t en t s of an allocat ed h eap block an d a free block, t h e
secon d example dumps memory at t h e base address of t h e h eap block at
0x143FE0. En ough memory is dumped t o sh ow t h e subsequen t block,
wh ich is a free block at address 0x144008.
Th e h eap block h eader fields from t h e memory dump at address
0x143FE0 are iden t ified wit h call-out s. Th is h eap block is 5 un it s in size
:HEAP32 -b 140000
Base Type Size Seg# Flags
00140000 HEAP 580 01
00140580 SEGMENT 38 01 TAGGED | BUSYTAIL
001405B8 ALLOC 40 01
. . .
00143FE0 ALLOC 28 01 TAGGED | BUSYTAIL
00144008 FREE FF8 01 FREECHECK | SENTINEL
BETA REVI EW
2 1 4 Usi n g Sof t I CE
(40 byt es) an d 0x1C byt es of t h at size is overh ead for t h e h eap block
h eader (1 un it ), busy-t ail (1 un it ), un it align men t (1 Dword), an d an ext ra
un it left over from a previous allocat ion .
Th e h eap block immediat ely followin g t h is is a free block t h at begin s at
address 0x144008. Th is block is 0x1FF un it s an d t h e size of t h e previous
block is 5 un it s. For free blocks 1KB or larger (80+ un it s), t h e Free List
byt e posit ion an d bit -mask values are n ot used an d are zero. Th e flag for
t h is h eap block in dicat es t h at it is a sen t in el (bit 4, or 0x10). Immediat ely
followin g t h e h eap h eader is t h e locat ion wh ere t h e h eap man ager h as
placed a doubly-lin ked list n ode for t rackin g free blocks. Th e poin t er
values for t h e n ext an d previous fields of t h e n ode are bot h 0x1400B8.
Aft er t h e free list n ode, t h e h eap man ager t agged all t h e blocks memory
wit h a special sign at ure t h at is validat ed t h e n ext t ime t h e block is
allocat ed, coalesced wit h an ot h er block, or a h eap validat ion is
performed.
0010:00143FE0 0005 0006 00 07 1C 00
0010:00143FE8 00000000 00000000 60A25F52
0010:00143FF4 ABABABAB ABABABAB
0010:00143FFC FEEEFEEE 00000000 00000000
Unit size
Previous unit size
Unused bytes Busy tail signature
Heap memory area
Segment number Flags
Extra bytes
Tag
Ch ap t er 1 2 Ex p l o r i n g Wi n d o w s N T 2 1 5
BETA REVI EW
0010:00144008 01FF 0005 00 14 00 00
0010:00144010 001400B8 001400B8
0010:00144018 FEEEFEEE FEEEFEEE FEEEFEEE FEEEFEEE
0010:00144028 FEEEFEEE FEEEFEEE FEEEFEEE FEEEFEEE
0010:00144038 FEEEFEEE FEEEFEEE FEEEFEEE FEEEFEEE
0010:00144048 FEEEFEEE FEEEFEEE FEEEFEEE FEEEFEEE
Unit size
Previous unit size
Doubly linked free list node
Free check signature
Segment number Flags
Free list byte position
Free list bit mask
BETA REVI EW
2 1 6 Usi n g Sof t I CE
2 1 7
BETA REVI EW
Ap p en d i x A
Error Messages
All b r e ak r e g ist e r s use d , use in RAM o n ly
You were t ryin g t o set a BPX breakpoin t in ROM an d all t h e debug
regist ers were already used. BPX will st ill work in RAM, because it uses
t h e INT 3 met h od. You must clear on e of t h e BPM-st yle breakpoin t s
before t h is will work.
At t a ch t o se r i al d e vi ce h a s FAI LED
Th e in it ial serial h an dsh akin g sequen ce failed. Th is migh t h appen if t h e
wron g serial port is select ed, t h e t arget mach in e is n ot run n in g
SERIAL.EXE, or t h e serial cable is fault y.
BPM b r e akp o in t li m it e xce e d e d
On ly four BPM-st yle breakpoin t s are allowed due t o rest rict ion s of x86
processors. You must clear on e of t h e BPM-st yle breakpoin t s before t h is
will work.
BPM D ad d r e ss m ust b e o n D W o r d b o un d ar y
Th e address specified in BPMD did n ot st art on a Dword boun dary. A
Dword boun dary must h ave t h e t wo least sign ifican t bit s of t h e address
equal 0.
BPM W ad d r ess m ust b e o n W o r d b o u n d a r y
Th e address specified in BPMW did n ot st art on a Word boun dary. A
Word boun dary must h ave t h e least sign ifican t bit of t h e address equal 0.
Br e akp o i n t s n o t al lo w e d w i t h in So f t I CE
You can n ot set breakpoin t s in Soft ICE code.
Can n ot i n t e r r up t t o a le ss p r i vil e g e d le ve l
You can n ot use t h e GENINT comman d t o go from a lower level t o a
h igh er privilege level. Th is is a rest rict ion of t h e x86 processor.
BETA REVI EW
2 1 8 Usi n g Sof t I CE
D e b ug r e g ist e r is alr e a d y b e in g use d
Debug-regist er specified in BPM comman d was already used in a previous
BPM comman d.
D up licat e b r e a kp o in t
Th e specified breakpoin t already exist s.
Exp e ct in g value, n o t ad d r ess
Th e expression evaluat or broadly classifies operan ds as addresses an d
values. Addresses h ave a select or/ segmen t an d offset compon en t even if
t h e address is flat . Cert ain operat ors such as * an d / expect on ly plain
values, n ot addresses, an d an at t empt t o use t h em on addresses produces
t h is message. In some cases usin g t h e in direct ion operat ors produces an
address; refer t o Supported Operators on page 124 for det ails.
Exp r e ssio n ?? W h at e xp r e ssio n ?
Th e expression evaluat or did n ot fin d an yt h in g t o evaluat e. Not e t h at in
some older version s of Soft ICE t h e ? comman d could be used t o get h elp.
Th is is n o lon ger t h e case; use t h e H comman d (F1).
I n t 0 D f a ult i n So f t I CE at ad d r e ss X X X X X o f f se t X X X X X
Fault Co d e = X X X X
(or the following message)
I n t 0 E Fa ult i n So f t I CE at ad d r e ss X X X X X o f f se t X X X X X
Fault Co d e = X X X X
Th ese t wo messages are in t ern al Soft ICE errors. Th e code wit h in Soft ICE
caused eit h er a gen eral prot ect ion fault (0D) or a page fault (0E). Th e
offset is t h e offset wit h in t h e code t h at caused t h e fault . Please writ e
down t h e in format ion con t ain ed in t h e message an d e-mail or call us.
Th ese messages also display t h e values in t h e regist ers. Be sure t o writ e
down t h ese values also.
I n valid D e b ug r e g ist e r
A BPM debug-regist er great er t h an 3 was specified. Valid debug regist ers
are DR0, DR1, DR2, an d DR3.
N o co d e at t h is lin e n um b e r
Th e lin e n umber specified in t h e comman d h as n o code associat ed wit h
it .
N o cur r e n t so ur ce f i le
You en t ered t h e SS comman d an d t h ere was n o source file curren t ly on
t h e screen .
Ap p en d i x A Er r o r M essag es 2 1 9
BETA REVI EW
N o em b ed d ed I N T 1 o r I N T 3
Th e ZAP comman d did n ot fin d an embedded in t errupt 1 or in t errupt 3
in t h e code. Th e ZAP comman d on ly works if t h e INT 1 or INT 3
in st ruct ion is t h e on e before t h e curren t CS:EIP.
N o f il e s f o un d
Th e curren t symbol t able does n ot h ave an y source files loaded for it .
N o LD T
Th is message displays wh en you use cert ain 16-bit Win dows in format ion
comman ds (HEAP, LHEAP, LDT, an d TASK) an d t h e curren t con t ext is n ot
set t o t h e proper NTVDM process.
N o Lo cal H e ap
Th e LHEAP comman d specified a select or t h at h as n o local h eap.
N o m o r e W at ch var i ab l e s al lo w e d
A maximum of eigh t wat ch variables are allowed.
N o se a r ch in p r o g r e ss
You specified t h e S comman d wit h out paramet ers an d n o search was in
progress. You must first specify S wit h an address an d a dat a-list for
paramet ers. To search for subsequen t occurren ces of t h e dat a-list , use t h e
S comman d wit h n o paramet ers.
N O _SI Z E
Durin g an A comman d, t h e assembler can n ot det ermin e wh et h er you
wan t ed t o use byt e, word, or double word.
N o sym b o l t ab l e
You en t ered t h e SYM, SS, or FILE comman d an d t h ere are n o symbols
curren t ly presen t .
N o TSS
You en t ered t h e TSS comman d wh ile t h ere was n o valid t ask st at e
segmen t in t h e syst em.
O n ly val id in so u r ce m o d e
You can n ot use t h e SS comman d in mixed mode or code mode.
Pa g e n o t p r e se n t
Th e specified address was marked n ot presen t in t h e page t ables. Wh en
Soft ICE was t ryin g t o access in format ion , it accessed memory t h at was in
a page marked n ot presen t .
BETA REVI EW
2 2 0 Usi n g Sof t I CE
Pa r a m et e r i s w r o n g si z e
On e of t h e paramet ers you en t ered in t h e comman d was t h e wron g size.
For example, if you use t h e EB or BPMB comman ds wit h a word value
in st ead of a byt e value.
Pa t t er n n o t f o un d
Th e S comman d did n ot fin d a mat ch in it s search for t h e dat a-list .
Pr e ss C t o co n t in ue , an d R t o r e t ur n t o So f t I CE
Soft ICE popped up due t o a fault (06, 0C, 0D, 0E). Press R t o ret urn
con t rol t o Soft ICE. Press C t o pass t h e fault on t o t h e Win dows fault
h an dler.
So f t I CE is n o t act i ve
Th is message displays on t h e h elp lin e on mon och rome an d serial
displays wh en Soft ICE is n o lon ger act ive.
Sp e ci f ie d n a m e n o t f oun d
You t yped TABLE wit h an in valid t able-n ame. Type TABLE wit h n o
paramet ers t o see a list of valid t able n ames.
Sym b o l n o t d e f in e d ( m ysym b o l)
You referred t o a n on -exist en t symbol. Use t h e SYM comman d t o get a
list of symbols for t h e curren t symbol t able.
2 2 1
BETA REVI EW
Ap p en d i x B
Support ed Display Adapt ers
Th e followin g t able list s t h e display adapt ors Soft ICE support ed wh en t h e
product most recen t ly sh ipped. However, Compuware regularly adds n ew
display adapt or support t o en h an ce Soft ICE. You can down load t h e lat est
support files from t h e Compuware FTP or BBS sit es. Refer t o Installing
SoftICE in Getting Stared with DriverStudio for more in format ion about
down loadin g support files.
Sup p or t e d D i sp lay Ad ap t or s
St an dard Display Adapt er
(VGA)
Act ix Graph icsEn gin e 32I VL Act ix Graph icsEn gin e 32VL
Plus
Act ix Graph icsEn gin e 64 Act ix Graph icsEn gin e Ult ra
64
Act ix Graph icsEn gin e Ult ra
Plus
Act ix Graph icsEn gin e Ult ra
VL Plus
Act ix ProSTAR Act ix ProSTAR 64
ATI 8514-Ult ra ATI Graph ics Pro Turbo ATI Graph ics Pro Turbo PCI
ATI Graph ics Ult ra ATI Graph ics Ult ra Pro ATI Graph ics Ult ra Pro EISA
ATI Graph ics Ult ra Pro PCI ATI Graph ics Van t age ATI Graph ics Won der
ATI Graph ics Xpression ATI 3d Xpression PCI ATI VGA Won der
ATI Video Xpression PCI ATI Win Turbo Boca SuperVGA
Boca SuperX Boca Voyager Cardin al VIDEOcolor
Cardin al VIDEOspect rum Ch ips & Tech n ologies 64310
PCI
Ch ips & Tech n ologies
65545 PCI
Ch ips & Tech n ologies 65548
PCI
Ch ips & Tech n ologies
Accelerat or
Ch ips & Tech n ologies Super
VGA
Cirrus Logic Cirrus Logic 5420 Cirrus Logic 5430 PCI
Cirrus Logic New Cirrus Logic PCI Cirrus Logic RevC
Cirrus Logic 7542 PCI Cirrus Logic 7543 PCI Compaq Qvision 2000
DEC PC76H-EA DEC PC76H-EB DEC PC76H-EC
DEC PCXAG-AJ DEC PCXAG-AK DEC PCXAG-AN
BETA REVI EW
2 2 2 Usi n g Sof t I CE
DFI WG-1000 DFI WG-1000VL Plus DFI WG-1000VL/ 4 Plus
DFI WG-3000P DFI WG-5000 DFI WG-6000VL
Diamon d Edge 3D 2200XL Diamon d Edge 3D 3200XL Diamon d Edge 3D 3400XL
Diamon d SpeedSt ar Diamon d SpeedSt ar 24 Diamon d SpeedSt ar 24X
Diamon d SpeedSt ar 64 Diamon d SpeedSt ar Pro Diamon d SpeedSt ar Pro SE
Diamon d St ealt h 3D 2000 Diamon d St ealt h 24 Diamon d St ealt h 32
Diamon d St ealt h 64 2001 Diamon d St ealt h 64 (S3 964) Diamon d St ealt h 64 (S3
968)
Diamon d St ealt h 64 Video Diamon d St ealt h Pro Diamon d St ealt h SE
Diamon d Viper OAK Diamon d Viper PCI Diamon d Viper VLB
Diamon d St ealt h VRAM ELSA WINNER 1000AVI ELSA WINNER 1000PRO
ELSA WINNER 1000Trio ELSA WINNER 1000 VL ELSA WINNER 1280
ELSA WINNER 2000PRO ELSA WINNER 2000 VL ELSA WINNER/ 2-1280
Gen oa Digit al Video Wizard
1000
Gen oa Ph an t om 32I Gen oa Ph an t om 64
Gen oa Win dowsVGA 24
Turbo
Gen oa Win dowsVGA 64
Turbo
Hercules Dyn amit e
Hercules Dyn amit e Pro Hercules Graph it e 64 Hercules Graph it e
Termin at or 64
Hercules Graph it e
Termin at or Pro
IBM 8514 IBM Th in kPad 755CX
IBM Th in k Pad 365XD Mat rox MGA Impression Lit e Mat rox MGA Impression
Plus
Mat rox MGA Impression
Plus 220
Mat rox MGA Ult ima Plus Mat rox MGA Ult ima Plus
200
Mat rox MGA Millen n ium Number Nin e GXE Number Nin e GXE64
Number Nin e GXE64 Pro Number Nin e 9FX Vision 330 Number Nin e 9FX Mot ion
531
Number Nin e 9FX Mot ion
771
Number Nin e Flash Poin t 32 Number Nin e Flash Poin t 64
Number Nin e Imagin e 128 Number Nin e Realit y 332 Nvidia NVI Media
Con t roller
Oak Tech n ology 087 Oak Tech n ology Super VGA Orch id Fah ren h eit 1280
Plus
Orch id Fah ren h eit Pro 64 Orch id Fah ren h eit VA Orch id Kelvin 64
Orch id Kelvin EZ Orch id ProDesign er II Paradise Accelerat or Port s
OCall
Paradise Accelerat or VL Plus Paradise Bah amas Paradise Barbados 64
Sup p or t ed D isp lay Ad ap t or s
Ap p en d i x B Su p p o r t ed D i sp l ay Ad ap t er s 2 2 3
BETA REVI EW
Paradise Super VGA S3 805 S3 911/ 924
S3 928 PCI S3 Trio32/ 64 PCI S3 ViRGE PCI
S3 Vision 864/ 964 PCI S3 Vision 868/ 968 PCI Spider 32 VLB
Spider 32Plus VLB Spider 64 Spider Taran t ula 64
STB Ergo MCX STB Horizon STB Horizon Plus
STB Ligh t Speed STB MVP-2X STB MVP-4X
STB Nit ro STB Pegasus STB PowerGraph Pro
STB PowerGraph VL-24 Triden t 9420 PCI Triden t Cyber 93XX
Triden t Super VGA Tsen g Labs Tsen g Labs ET4000
Tsen g Labs ET4000/ W32 Tsen g Labs ET6000 Video Logic 928Movie
Video Seven VRAM/ VRAM
II/ 1024i
West ern Digit al West ern Digit al (512K)
Weit ek Power 9000 Weit ek Power 9100
Sup p or t ed D isp lay Ad ap t or s
BETA REVI EW
2 2 4 Usi n g Sof t I CE
2 2 5
BETA REVI EW
Ap p en d i x C
Troubleshoot ing Soft ICE
If you en coun t er an y of t h e followin g problems, t ry t h e correspon din g
solut ion . If you en coun t er furt h er difficult ies, t ech n ical support is avail-
able from our Tech n ical Support Hot lin e or via our Fron t Lin e Support
Web sit e.
Tech n ical Support Hot lin e: 1-800-538-7822
Fron t Lin e Support Web Sit e: h t t p:/ / fron t lin e.compuware.com.
Pr ob le m So lut ion
Th e So f t ICE scr een i s b l ack o r
u n r ead ab l e.
Ei t h er y o u r d i sp l ay ad ap t o r d o es n o t m at ch t h e
d i sp l ay ad ap t o r set at i n st al l at i o n o r So f t ICE d o es
n o t su p p o r t y o u r d i sp l ay ad ap t o r. Ref er t o
Appendix B: o n p ag e 2 2 1 .
Th e PC cr ash es w h en y o u r u n
So f t ICE an d y o u ar e n o t u si n g a
Pen t i u m o r Pen t i u m - Pr o p r o ces-
so r.
So f t ICE i n co r r ect l y d et er m i n ed t h at y o u r sy st em
i s u si n g a Pen t i u m p r o cesso r. M o d i f y t h e So f t ICE
In i t i al i zat i o n Set t i n g s t o d i sab l e Pen t i u m su p p o r t .
Ref er t o Setting Troubleshooting Options o n
p ag e 1 7 6 .
Th e PC cr ash es w h en y o u r u n
So f t ICE f o r Wi n d o w s 9 x .
So f t ICE d o es n o t su p p o r t t h e sh u t d o w n o p t i o n
RESTART THE COMPUTER IN MS-DOS MODE?.
If y o u r el o ad So f t ICE af t er ch o o si n g t h i s o p t i o n ,
So f t ICE ev en t u al l y cr ash es.
In st ead , ch an g e t h e st at em en t Bo o t GUI= 1 t o
Bo o t GUI= 0 w i t h i n t h e Wi n d o w s 9 5 an d Wi n d o w s
9 8 h i d d en f i l e M SD O S. SYS. Th en , ch o o se SHUT
DOWN THE COMPUTER? t o ex i t t o D O S.
Yo u h av e d i f f i cu l t y est ab l i sh i n g a
m o d em co n n ect i o n .
Th e m o d em i s r et u r n i n g r esu l t co d es So f t ICE
d o es n o t ex p ect . So f t ICE l o o ks f o r t h e co d es O K,
CO M N ECT, an d RIN G. Pl ace ATXO i n t h e i n i t i al -
i zat i o n st r i n g .
BETA REVI EW
2 2 6 Usi n g Sof t I CE
Th e m o u se b eh aves er r at i cal l y
w i t h i n So f t ICE.
Pr ess Ct r l - M .
Wi n d o w s N T o n l y : t h e m o u se
p o i n t er b eh av es er r at i cal l y i n t h e
So f t ICE sc r een .
M o vi n g t h e m o u se w h i l e t h e So f t ICE scr een p o p s
u p , can cau se Wi n d o w s N T an d t h e m o u se h ar d -
w ar e t o b eco m e o u t o f sy n ch r o n i zat i o n . Sw i t ch
t o a f u l l scr een D O S b o x .
Yo u r key b o ar d l o cks o r b eh av es
er r at i cal l y w h en y o u l o ad So f t ICE.
M o d i f y t h e So f t ICE In i t i al i zat i o n Set t i n g s t o d i s-
ab l e n u m l o ck an d c ap s l o ck p r o g r am m i n g . If t h i s
d o es n o t w o r k an d y o u ar e u si n g Wi n d o w s N T,
i n st r u ct So f t ICE n o t t o p at ch t h e key b o ar d d r i v er.
Ref er t o Setting Troubleshooting Options o n
p ag e 1 7 6 .
Wi n d o w s 9 x cr ash es w h en
at t em p t i n g t o scan f o r ser i al p o r t s.
If y o u p l ac ed t h e SERIAL co m m an d i n t h e In i t i al -
i zat i o n st r i n g , So f t ICE est ab l i sh es a co n n ect i o n t o
t h e p o r t b ef o r e Wi n d o w s 9 x i n i t i al i zes. W h en
Wi n d o w s 9 x i n i t i al i ze, i t m i g h t scr am b l e t h e co n -
n ect i o n . D i sab l e t h e p o r t sel ect ed i n t h e D evi ce
M an ag er. Th e D ev i ce M an ag er i s l o cat ed w i t h i n
t h e Sy st em Pr o p er t i es i n y o u r Co n t r o l Pan el .
Pr o b le m Sol ut i on
2 2 7
BETA REVI EW
Ap p en d i x D
Kernel Debugger Ext ensions
Soft ICE for Win dows NT/ 2000/ XP support s Kern el Debugger (KD)
Ext en sion s writ t en for Win DBG. Soft ICE will t ake a Win DBG ext en sion ,
con vert it t o a Kern el mode driver, an d allow t h e user t o execut e
in format ion al comman ds. Users can also writ e t h eir own ext en sion s
followin g t h e Win DBG in t erface (as foun d in Wdbgext s.h ), an d con vert
t h em for use in Soft ICE.
To prepare a KD Ext en sion for use wit h Soft ICE:
1 Use t h e KD2SYS or KD2SYSXLAT program t o con vert t h e DLL t o a
syst em driver. Th is program:
a Copies t h e DLL t o t h e \ SYSTEMROOT\ SYSTEM32\ DRIVERS
direct ory an d gives it an ext en sion of .SYS
b Modifies t h e file t o t ell t h e syst em t h at t h e file can be loaded as a
syst em driver an d redirect man y API calls t o Soft ICE
c Creat es t h e n ecessary keys in t h e syst em regist ry t o iden t ify t h e
n ew file as a syst em driver
2 Reboot t h e syst em. Wh en an y syst em drivers (services) are added or
removed from your syst em, it must be reboot ed. Th is allows t h e
service con t rol man ager t o refresh t h e list of services in t h e syst em.
3 If you are st art in g Soft ICE man ually, you will n eed t o st art t h e
ext en sion , in t h is case by usin g t h e NET START <KDExt en sion
n ame> comman d from t h e comman d prompt t o load t h e ext en sion
in t o Soft ICE.
If you are usin g ot h er st art modes, t h e ext en sion will be st art ed
aut omat ically at t h e appropriat e t ime. Furt h er, wh en you ch an ge t h e
BETA REVI EW
2 2 8 Usi n g Sof t I CE
st art mode of Soft ICE usin g t h e St art up Mode Set up sh ort cut , all
ext en sion s will be ch an ged t o st art wit h Soft ICE.
4 Aft er t h e service is st art ed, press Ct rl-D t o open t h e Soft ICE win dow.
Type !? or !h elp t o get a list of t h e comman ds an d a sh ort
explan at ion of each on e.
Th e requiremen t s for usin g Kern el Debugger Ext en sion s are list ed below:
1 You must h ave t h e curren t NTOSKRNL.n ms loaded. Tran slat e t h e
.dbg file an d use Loader32 t o aut omat ically load t h e file wh en
Soft ICE st art s.
2 No file IO is allowed in a KD Ext en sion . Th e DLL will be con vert ed,
but an y at t empt t o call a file IO fun ct ion will result in t h e comman d
t h at issued t h e request bein g t ermin at ed.
3 Do n ot use except ion h an dlin g in a KD Ext en sion . Again , t h e
ext en sion will con vert , but an y comman d t h at at t empt s t o execut e
an except ion h an dler will be t ermin at ed.
4 A default st ack of 32k an d a default h eap of 8k are allocat ed wh en
Soft ICE st art s. Th ese values can be in creased or decreased via t h e
regist ry keys: KDHeapSize an d KDSt ackSize
(HKey_LocalMach in e\ Curren t Con t rolSet \ Services\ NTICE).
If you ch an ge t h e values usin g t h e regist ry keys, a reboot will be
n ecessary t o refresh t h e values.
2 2 9
Glossary
In t er r u p t D escr i p t o r
Tab l e ( ID T)
Table poin t ed t o by t h e IDTR regist er, wh ich defin es t h e in t errupt /
except ion h an dlers. Use t h e IDT comman d t o display t h e t able.
M AP f i l e Human -readable file con t ain in g debug dat a, in cludin g global symbols
an d usually lin e n umber in format ion.
M M X Mult imedia ext en sion s t o t h e In t el Pen t ium an d Pen t ium-Pro processors.
O b j ect Represen t s an y h ardware or soft ware resource t h at n eeds t o be sh ared as
an object . Also, t h e t erm sect ion is somet imes called an object . Refer t o
section.
O n e- Sh o t Br eakp o i n t Breakpoin t t h at on ly goes off on ce. It is cleared aft er t h e first t ime it goes
off or t h e n ext t ime Soft ICE pops up for an y reason .
O r d i n al Fo r m Wh en a symbol t able is n ot relocat ed, it is said t o be in it s ordin al form;
in t h is st at e, t h e select ors are sect ion n umbers or segmen t n umbers (for
16 bit ).
Po i n t -an d - Sh o o t
Br eakp o i n t
Breakpoin t you set by movin g t h e cursor in t o t h e code win dow usin g t h e
BPX or HERE comman d.
Rel o c at e Adjust program addresses t o accoun t for t h e programs act ual load
address.
Sect i o n In t h e PE file format , a ch un k of code or dat a sh arin g various at t ribut es.
Each sect ion h as a n ame an d an ordin al n umber.
St i cky Br eakp o i n t Breakpoin t t h at remain s un t il you remove it . It remain s even t h rough
un loadin g an d reloadin g of your program.
SYM Fi l e File con t ain in g debug dat a, in cludin g global symbols an d usually lin e
n umber in format ion . Th e SYM file is usually derived from a MAP file.
Sy m b o l Tab l e Soft ICE-in t ern al represen t at ion of t h e debuggin g in format ion , for
example, symbols an d lin e n umbers associat ed wit h a specific module.
2 3 0 Usi n g Sof t I CE
Vi r t u al Br eakp o i n t Breakpoin t t h at can be set on a symbol or a source lin e t h at is n ot yet
loaded in memory.
2 3 1
BETA REVI EW
Index
Symbols
+ (plus sign ), 82, 84
. (dot ) comman d, 80
A
A comman d, 80
ADDR comman d, 189, 190
Address
space, 202
t ype, 133
Alt -C, 76
Alt -D, 87
ALTKEY comman d, 59
Alt -L, 21, 81
Alt -R, 85
Alt -W, 83
ANSWER comman d, 158
ANSWER in it ializat ion st rin g, 171
Applicat ion s
buildin g, 34
debuggin g, 32
Arrays
collapsin g, 20
expan din g, 20
Assign in g expression s, 90
B
baudrat e, 157
BC comman d, 29, 122
BD comman d, 29, 122
BE comman d, 122
BH comman d, 122
Bit wise operat ors, 124
BL comman d, 22, 28, 122
BMSG comman d, 104, 109
Borlan d compiler, 34
BPCOUNT fun ct ion , 114
BPE comman d, 27, 122
BPINDEX expression fun ct ion , 116
BPINT comman d, 104, 107
BPIO comman d, 104, 109
BPLOG expression fun ct ion , 116
BPM comman d, 104, 106
BPMD comman d, 28
BPMISS expression fun ct ion , 115
BPT comman d, 122
BPTOTAL expression fun ct ion , 116
BPX
breakpoin t , 26
comman d, 22, 80, 104, 106
Breakpoin t act ion , 105
set t in g, 112
Breakpoin t in dex, 121, 122
Breakpoin t s
BPCOUNT fun ct ion , 114
BPINDEX, 116
BPLOG fun ct ion , 116
BPMISS fun ct ion , 115
BPTOTAL fun ct ion , 116
BPX, 26
clearin g, 29
con dit ion al, 25, 112
con dit ion al expression , 105
con t ext , 111
crit eria t o t rigger, 111
disablin g, 29
duplicat e, 120
2 3 2 Usi n g Sof t I CE
BETA REVI EW
elapsed t ime, 121
embedded, 122
execut ion , 104, 105
expression s, 121
I/ O, 104, 108
INT 1 an d INT 3, 122
in t errupt , 104, 107
man ipulat in g, 121
memory, 28, 104, 106
on e-sh ot , 21
poin t -an d-sh oot , 22
st at ist ics, 121
st icky, 22, 103
t ypes, 104
usin g, 103
virt ual, 111
win dow message, 104, 109
BSTAT comman d, 116, 117, 121
Buildin g
applicat ion s, 34
debug in format ion , 16
Built -in fun ct ion s, 129
C
ch an ge regist ry en t ry, 146
Ch aract er con st an t s, 127
Ch ecked build, 180
CLASS comman d, 23
Clearin g
breakpoin t s, 29
Closin g
Code win dow, 76
Dat a win dow, 87
FPU St ack win dow, 93
Locals win dow, 81
Regist er win dow, 85
Soft ICE win dows, 62
Wat ch win dow, 83
Code mode, 78
Code win dow, 17, 60, 76
closin g, 76
disassembled in st ruct ion , 78
en t erin g comman ds, 80
JUMP, 79
modes, 77
movin g t h e cursor t o, 63, 76
NO JUMP, 79
open in g, 76
resizin g, 76
scrollin g, 76
st rin gs, 79
Collapsin g
arrays, 20
st acks, 82
st rin gs, 20
st ruct ures, 20
t yped expression s, 84
Comman d h ist ory
recallin g, 73
Comman d lin e argumen t s
passin g, 38
comman d prompt , 157
Comman d win dow, 60, 69
associat ed comman ds, 76
h ist ory buffer, 75
scrollin g, 70
Comman ds
. (dot ), 80
A, 80
ALTKEY, 59
ANSWER, 158
BC, 29, 122
BD, 29, 122
BE, 122
BH, 122
BL, 22, 28, 122
BMSG, 104, 109
BPE, 27, 122
BPINT, 104, 107
BPIO, 104, 109
BPM, 104
BPMD, 28
BPX, 22, 80, 104, 106
BSTAT, 121
CLASS, 23
CR, 87
D, 87, 90, 91
DATA, 87
I n d ex 2 3 3
BETA REVI EW
DEX, 90, 91
DIAL, 158
E, 91
edit in g, 72
en t erin g, 68, 70
FILE, 18, 80
FORMAT, 87, 90
G, 21, 28, 85, 87
H, 23, 69
HERE, 21, 80, 106
HWND, 26, 110
IDT, 107
in format ional, 23
LINES, 61
LOADER32, 44, 45
LOCALS, 82
MACRO, 74
P, 20, 85, 87, 177
recallin g, 73
S, 91
SET, 70, 76, 80
SRC, 20, 80
SS, 80
SYM, 25
syn t ax, 70
T, 87
TABLE, 24
TABS, 80
TYPES, 82
U, 19, 21, 80
WATCH, 83
WC, 76
WD, 87
WF, 93
WL, 81
WR, 85
WS, 91
WW, 83
WX, 92
X, 28
Comman ds T, 85
comman ds, Un iversal Video Driver, 58
Compiler opt ion s
32-bit , 34
Compilers
Borlan d, 34
Delph i, 34
MASM, 35
Microsoft Visual C++, 35
Syman t ec C++, 35
Wat com C++, 35
Con dit ion al breakpoin t s, 112
coun t fun ct ion s, 114
performan ce, 120
set t in g, 25
Con dit ion al expression
breakpoin t s, 105
con n ect ion ben efit s/ disadvan t ages, 146
Con t rollin g Soft ICE win dows, 61
Copyin g dat a, 67
Coun t fun ct ion s
con dit ion al expression s, 114
CPU flags, 85
CR comman d, 87
Creat in g
Persist en t Macros, 173
CSRSS, 195
Ct rl-D, 59
Cursor
movin g amon g win dows, 63
Cust omizin g Soft ICE, 161
Cyclin g Dat a win dows, 87
D
D comman d, 87, 90, 91
Dat a
copyin g, 67
past in g, 67
DATA comman d, 87
Dat a win dow, 60, 87
assign in g expression s, 90
associat ed comman ds, 91
closin g, 87
cyclin g t h rough , 87
fields, 89
format , 87
movin g t h e cursor t o, 63, 87
open in g, 87
2 3 4 Usi n g Sof t I CE
BETA REVI EW
resizin g, 87
scrollin g, 88
viewin g addresses, 87
DBG files, 181
Debug in format ion
buildin g, 16
Debuggin g
applicat ion s, 32
device drivers, 32
feat ures, 7
gen erat in g in format ion , 34
preparin g t o, 141
resources, 179
Delet in g
symbol t ables, 42
wat ch , 84
Delph i compiler, 34
DEVICE comman d, 180
Device drivers
debuggin g, 32
DEX comman d, 90, 91
DIAL comman d, 158
DIAL in it ializat ion st rin g, 171
Dial-up Modem, 145
dial-up modem, 146
Direct Null Modem con n ect ion , 145
Disable mappin g of n on -presen t pages, 177
Disable mouse support , 176
Disable Num Lock an d Caps Lock program-
min g, 176
Disable Pen t ium support , 177
Disable t h read-specific st eppin g, 177
Disablin g
breakpoin t s, 29
Soft ICE, 59
Disassembled in st ruct ion
Code win dow, 78
Display adapt ers
support ed, 221
Display comman d, 68
Display diagn ost ic messages, 164
Displayin g regist ers, 94
DLL export s, 141
Do n ot pat ch keyboard driver, 177
DRIVER comman d, 180
DriverSt udio Remot e Dat a (DSR) n amespace
ext en sion , 147
DSR Namespace Ext en sion , 147
Duplicat e breakpoin t s, 120
E
E comman d, 91
Eaddr fun ct ion , 131
EBP regist er, 119
Edit in g
comman ds, 72
flags, 86
memory, 90
regist ers, 86
Effect ive address, 85
Embedded breakpoin t s, 122
En ablin g serial debuggin g, h ost , 157
En ablin g serial debuggin g, t arget , 156
En t erin g comman ds, 68, 70
syn t ax, 70
En t ry poin t s, 142
un n amed, 142
Error messages, 217, 227
ESP regist er, 119
est ablish a serial con n ect ion , 156
Est ablish in g a con n ect ion , specialized n et work
drivers, 151
Est ablish in g a Modem Con n ect ion , 158
Evalue fun ct ion , 132
Execut ion breakpoin t s, 104, 105
Expan din g
arrays, 20
st acks, 82
st rin gs, 20
st ruct ures, 20
t yped expression s, 84
Export In format ion , 167
Export n ames
expression s, 142
Export s, 161
DLL, 141
Expression evaluat or, 123
built -in fun ct ion s, 129
I n d ex 2 3 5
BETA REVI EW
ch aract er con st an t s, 127
expression values, 132
formin g expression s, 126
in direct ion operat ors, 135
n umbers, 127
operan ds, 135
operat ors, 124
regist ers, 128
symbols, 128
Expression t ypes, 132
Expression values
address-t ype, 132
lit eral-t ype, 132
regist er-t ype, 132
symbol-t ype, 132
Expression s, 123
assign in g, 90
breakpoin t s, 121
export n ames, 142
formin g, 126
wat ch in g, 83
F
Fault t rappin g, 95
Fault s
t rappin g, 95
Fields
Dat a win dow, 89
FILE comman d, 18, 80
Flags, 85
edit in g, 86
FORMAT comman d, 87, 90
Format t in g
Dat a win dow, 87
Formin g expression s, 126
FPU St ack win dow, 60, 93
closin g, 93
displayin g regist ers, 94
movin g t h e cursor t o, 63
open in g, 93
Fun ct ion keys, 71, 171
modifyin g, 171
Fun ct ion s
built -in , 129
expression evaluat or, 129
G
G comman d, 21, 28, 85, 87
GDI object s, 197
GDIDEMO applicat ion , 14
GDT comman d, 186
Gen eral set t in gs, 161
modifyin g, 163
Global Descript or Table, 184, 186
H
H comman d, 23, 69
Han dle values, 199
Hardware Requiremen t s, Specialized Net work
Drivers, 150
Headless Mode, 146
Heap
API, 204
arch it ect ure, 204
blocks, 209
HEAP32 comman d, 196, 207
Help
for Soft ICE, xiv, 68
for Symbol Loader, xiv
Help lin e, 18, 60, 68
HERE comman d, 21, 80, 106
Hist ory buffer, 75
Hist ory buffer size, 163
h ost comput er, 146
HWND comman d, 26, 110
I
I/ O breakpoin t s, 104, 108
IDT comman d, 107, 184
In direct ion operat ors, 124, 135
In format ion
2 3 6 Usi n g Sof t I CE
BETA REVI EW
Help lin e, 68
In format ion al comman ds, 23
In it ializat ion file, 161
In it ializat ion set t in gs
Remot e Debuggin g, 161
In it ializat ion st rin g, 163
In it ializat ion st rin gs
modem, 170
in st allat ion , specialized n et work drivers, 150
in st allin g a serial con n ect ion , 155
INT 1 in st ruct ion
breakpoin t s, 122
INT 3 in st ruct ion
breakpoin t s, 122
In t el arch it ect ure, 184
In t ern et paramet ers
Remot e Debuggin g, 161
In t errupt
breakpoin t s, 104, 107
Descript or Table, 184
J
JUMP st rin g, 79
K
Kern el
Win dows NT, 183
Keyboard Mappin gs, 162
modifyin g, 171
L
LDT comman d, 187
LINES comman d, 61
LOADER32, 44, 45
LOADER32.EXE, 43
Loadin g
modules, 35
Soft ICE, 14, 33
source, 35
symbols, 24
Loadin g Export s Dyn amically, 143
Local Descript or Table, 184, 187
local n et work (LAN) debuggin g, 146
LOCALS comman d, 82
Locals win dow, 60, 81
associat ed comman ds, 82
closin g, 81
movin g t h e cursor t o, 63, 81
open in g, 81
resizin g, 81
scrollin g, 81
Logical operat ors, 125
Lowercase disassembly, 165
M
MACRO comman d, 74, 202
Macro Defin it ion s, 162
Macro limit , 175
Macros
defin it ion s, 173
recusion , 74, 174
Run -t ime, 73
Man ipulat in g breakpoin t s, 121
MAP32 comman d, 188, 203
MASM compiler, 35
Mat h operat ors, 124
MAXIMIZE, 58
Memory
breakpoin t s, 28, 104, 106
edit in g, 90
map of syst em memory, 188
Messages
error, 217, 227
Microsoft Visual C++ compiler, 35
Mixed mode, 78
MMX regist ers, 93
MOD comman d, 180, 203
Modem, 157
con n ect ion , 145, 157
h ardware requiremen t s, 157
in it ializat ion st rin gs, 170
I n d ex 2 3 7
BETA REVI EW
modem, 157
Modem Hardware Requiremen t s, 157
Modes
Code, 77
Code win dow, 77
Mixed, 77
Source, 77
Modifyin g
fun ction keys, 171
Gen eral set t in gs, 163
Keyboard Mappin gs, 171
Soft ICE In it ializat ion set t in gs, 161, 162
Modules
loadin g, 35
t ran slat in g, 35
Mouse comman ds
Display, 68
Previous, 68
Un -Assemble, 68
Wh at , 68
Movin g t h e cursor, 63
Movin g t h e Soft ICE Win dow, 61
N
Navigat in g
Soft ICE, 57, 95
Nest in g limit, 74
NET ALLOW, 159
NET comman d, 159
NET COMx, 159
NET DISCONNECT, 159
NET HELP, 169
NET HELP comman d, 159
NET PING, 159
NET RESET, 159, 169
NET SETUP, 159
NET START, 159
NET STATUS, 169
NET STOP, 159, 169
n et work, 146
Net work In t erface Card (NIC) in t erface, 145
NMAKE comman d, 16
NMS file, 36
NMSYM.EXE, 45
NO JUMP st rin g, 79
Non Paged Syst em area, 193
NTCALL comman d, 185
NTOSKRNL.EXE, 183
n ull modem cable, 155
O
OBJDIR comman d, 180
OBJTAB comman d, 188, 200
On e-sh ot breakpoin t s, 21
Open in g
Code win dow, 76
Dat a win dow, 87
FPU St ack win dow, 93
Locals win dow, 81
Regist er win dow, 85
Soft ICE win dows, 62
Wat ch win dow, 83
Operan d sizes, 135
Operat ors
bit wise, 124
expression evaluat or, 124
in direct ion , 124, 135
logical, 125
mat h , 124
preceden ce, 125
special, 125
P
P comman d, 20, 22, 85, 87, 177
Packagin g source files, 40
PAGE comman d, 189
Page Table En t ry, 192
Paged Pool Syst em area, 192
Passin g comman d lin e argumen t s, 38
Past in g dat a, 67
Persist en t Macros, 173
PHYS comman d, 189
Preceden ce operat ors, 125
2 3 8 Usi n g Sof t I CE
BETA REVI EW
Pre-loadin g
source, 165
symbols, 165
Preparin g t o debug, 141
Previous comman d, 68
Process address space, 202
Processor Con t rol Region , 193
Prot oPTEs, 192
PTE, 192
Q
QUERY comman d, 196, 203
R
Recallin g
comman d h ist ory, 73
refresh t h e display man ually, 149
Regist er win dow, 60, 85
associat ed comman ds, 87
closin g, 85
CPU flags, 85
movin g t h e cursor t o, 63, 85
open in g, 85
Regist ers, 85
edit in g, 86
Remot e Debuggin g, 161, 170
Remot e Debuggin g Det ails, 150
Remot e Debuggin g, NET comman ds, 168
Remot e Debuggin g, st art session , 170
remot e locat ion , 146
removin g a serial con n ect ion , 156
Removin g t h e modem con n ect ion , 158
Requiremen t s, Remot e Debuggin g, 167
Reservin g
symbol memory, 166
Resizin g
Code win dow, 76
Dat a win dow, 87
Locals win dow, 81
Soft ICE screen , 61
Soft ICE win dows, 62
Wat ch win dow, 83
Run -t ime macros, 73
S
S comman d, 91
Scrollin g
Code win dow, 76
Comman d win dow, 70
Dat a win dow, 88
Locals win dow, 81
Wat ch win dow, 83
win dows, 63
Serial
con n ect ion , 171
Serial Con n ect ion , 155
Serial con n ect ion , 155
Serial Con n ect ion h ardware requiremen t s, 155
serial debuggin g, 146
serial port , 155
SERIAL.EXE, 158
SET comman d, 70, 76, 80
Set t in g
breakpoin t act ion s, 112
breakpoin t s, 21, 22
con dit ion al breakpoin t s, 25, 112
execut ion breakpoin t s, 105
I/ O breakpoin t s, 108
in t errupt breakpoin t s, 107
memory breakpoin t s, 28, 106
source file search pat h , 38
win dow message breakpoin t s, 109
Set t in g Video Memory size, 59
SIREMOTE, 157
SIREMOTE n et work con n ect ion s, 158
SIREMOTE Serial Con n ect ion , 158
SIREMOTE support applicat ion , 158
SIREMOTE, con n ect in g t o a remot e t arget , 158
SIVNIC In st allat ion , 153
Soft ICE
cust omizin g, 161
disablin g, 59
feat ures, 7
I n d ex 2 3 9
BETA REVI EW
in format ion al comman ds, 23
in it ializat ion file, 161
loadin g, 14, 33
modem con n ect ion , 145, 157
n avigat in g t h rough , 57, 95
overview, 7
product overview, 7
user in t erface, 9, 60
Soft ICE In it ializat ion set t in gs
Export s, 161
Gen eral, 161
Keyboard Mappin gs, 162
Macro Defin it ion s, 162
modifyin g, 161, 162
Symbols, 161
Troublesh oot in g, 162
Soft ICE screen , 60, 146
resizin g, 61
Soft ICE win dows
closin g, 62
Code, 60, 76
Comman d, 60, 69
con t rollin g, 61
Dat a, 60, 87
FPU St ack, 60, 93
Locals, 60
open in g, 62
Regist er, 60, 85
resizin g, 62
Wat ch , 60, 82
Sort in g symbol t ables, 42
Source
loadin g, 35
mode, 77
packagin g, 40
pre-loadin g, 165
specifying, 42
t ran slat in g, 35
Special operat ors, 125
Specialized Net work Driver, 150
Specialized n et work drivers, 148
specialized n et work drivers, 150
Specifyin g Source Files, 42
SRC
comman d, 20, 78, 80
file, 42
SS comman d, 80
St ack frame, 20, 119
St acks
collapsin g, 82
expan din g, 82
St icky breakpoin t s, 22, 103
St rin gs
Code win dow, 79
collapsin g, 20
expan din g, 20
St ruct ures
collapsin g, 20
expan din g, 20
SYM comman d, 25, 192
Syman t ec C++ compiler, 35
Symbol buffer size, 166
Symbol Loader, 11, 17, 35, 162
comman d lin e in t erface, 43
comman d-lin e ut ilit y, 45
Symbol t ables
delet in g, 42
sort in g, 42
Symbols, 128, 161
pre-loadin g, 165
reservin g memory, 166
t ables, 24
t ype, 133
Syst em
Code area, 188
memory map, 188
Tables Syst em area, 188
View Syst em area, 188
Syst em Page Table En t ries, 192
T
T comman d, 85, 87
TABLE comman d, 24
Tables, 24
TABS comman d, 80
Tail recursion , 74
t arget comput er, 146
t arget mach in e, 146
2 4 0 Usi n g Sof t I CE
BETA REVI EW
Task St at e Segmen t , 184, 186
t ech n ical support , 225
Teleph on e n umber, 170
THREAD comman d, 203
Time st amp coun t er, 120
Tot al RAM, 164
Trace buffer size, 164
Tran slat in g
modules, 35
source, 35
Trap NMI, 164
Triggerin g
breakpoin t s, 111
Troublesh oot in g, 162
error messages, 217, 227
Soft ICE, 225
Troublesh oot in g Opt ion s, 176
TSS comman d, 186
t ype of remot e con n ect ion , 146
Typed expression s
collapsin g, 84
expan din g, 84
TYPES comman d, 82
t ypes of debuggin g icon s, 148
t ypical debuggin g en viron men t , 148
U
U comman d, 19, 21, 80
Un -Assemble comman d, 68
UND, 151
UND (Un iversal Net work Driver), 148
UND Hardware Requiremen t s, 152
UND In st allat ion , 152
UND Removal, 154
UND, Est ablish in g a Net work Con n ect ion , 154
un in st allin g specialized n et work drivers, 151
Un iversal Net work Driver, 151
Un iversal Video Driver, 58
USER
object creat ion , 202
Object Table, 200
object s, 197
User-defin ed
comman ds, 173
set t in gs, 161
V
Viewin g
addresses, 87
Virt ual breakpoin t s, 111
W
Wat ch
delet in g, 84
WATCH comman d, 83
Wat ch win dow, 60, 82
associat ed comman ds, 84
closin g, 83
fields, 84
movin g t h e cursor t o, 63, 83
open in g, 83
resizin g, 83
scrollin g, 83
Wat ch in g
expression s, 83
Wat com C++ compiler, 35
WC comman d, 76
WD comman d, 87
WF comman d, 93
WHAT comman d, 201
Wh at comman d, 68
Win 32 subsyst em, 195
Win dow message breakpoin t s, 104, 109
Win dows
Code, 17, 60, 76
Comman d, 60
compon en t s, 195
Dat a, 60, 87
FPU St ack, 60, 93
Locals, 60, 81
movin g t h e cursor amon g, 63
Regist er, 60, 85
scrollin g, 63
I n d ex 2 4 1
BETA REVI EW
Wat ch , 60, 82
Win dows NT
DDK, 180
explorin g, 179
kern el, 183
referen ces, 182
syst em memory map, 188
WL comman d, 81
WR comman d, 85
WS comman d, 91
WW comman d, 83
WX comman d, 92
X, Y, Z
X comman d, 28
2 4 2 Usi n g Sof t I CE
BETA REVI EW