Вы находитесь на странице: 1из 541

244260235.

doc 1 od 541
The IL Disassembler .

This book explains the internal workings of a disassembler. The programs
given in the book produces an output similar to the one written by Microsoft
i.e. ildasm. The only diference is that the source code of ildasm is not
available. Our main objective in this book is to write innumerable programs,
which ultimately focus on understanding the disassembler in a simplistic
form. The nal program has been tested against !""" .net les.

#ithout getting into any more discussions, lets start with the disassembler
right away. The output produced by our program will be tested with that of
ildasm simultaneously. This is more to verify the results and keep us on the
right track.

a.cs
public class $$$
%
public static void Main&'
%
(
(

)ildasm *all *out+a.txt a.exe

,rogram a.cs is the smallest -. program which on compiling gives the
smallest ./et executable, a.exe. 0f you fail to understand the above -.
program or have forgotten how to compile a -. program, we re1uest you to
stop reading this book now. This book assumes that you know nothing about
a disassembler but you must have a basic understanding of the -.
programming language.

Once the executable is created, proceed further to write the rst program in
the series of the disassembler.

,rogram2.csc
using 3ystem4
using 3ystem.0O4
public class $$$
%
int 56 datadirectoryrva4
int 56 datadirectorysi$e4
int subsystem4
int stackreserve 4
int stackcommit4
int datad4
int sectiona4
int lea4
int entrypoint4
int 0mage7ase4
244260235.doc 2 od 541
8ile3tream mlestream 4
7inary9eader mbinaryreader 4
long sectionofset4
short sections 4
string lename4
int 56 3:irtual;ddress 4
int 56 33i$eOf9aw<ata4
int 56 3,ointerTo9aw<ata 4
public static void Main &string 56 args'
%
try
%
$$$ a = new $$$&'4
a.abc&args'4
(
catch & >xception e'
%
-onsole.#rite?ine&e.To3tring&''4
(
(
public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
(
public void 9ead,>3tructures&string 56 args'
%
lename = args5"64
mlestream = new 8ile3tream&lename ,8ileMode.Open'4
mbinaryreader = new 7inary9eader &mlestream'4
mlestream.3eek&@", 3eekOrigin.7egin'4
int startofpeheader = mbinaryreader.9ead0ntAB&'4
mlestream.3eek&startofpeheader, 3eekOrigin.7egin'4
byte sig2,sigB,sigA,sigC4
sig2 = mbinaryreader.9ead7yte&'4
sigB = mbinaryreader.9ead7yte&'4
sigA = mbinaryreader.9ead7yte&'4
sigC = mbinaryreader.9ead7yte&'4
**8irst 3tructure
short machine = mbinaryreader.9ead0nt2@&'4
sections = mbinaryreader.9ead0nt2@&'4
int time = mbinaryreader.9ead0ntAB&'4
int pointer = mbinaryreader.9ead0ntAB&'4
int symbols = mbinaryreader.9ead0ntAB&'4
int headersi$e= mbinaryreader.9ead0nt2@&'4
int characteristics = mbinaryreader.9ead0nt2@&'4
sectionofset = mlestream.,osition D headersi$e4
**3econd 3tructure
int magic = mbinaryreader.9ead0nt2@&'4
int major = mbinaryreader.9ead7yte&'4
244260235.doc 3 od 541
int minor = mbinaryreader.9ead7yte&'4
int si$eofcode = mbinaryreader.9ead0ntAB&'4
int si$eofdata = mbinaryreader.9ead0ntAB&'4
int si$eofudata = mbinaryreader.9ead0ntAB&'4
entrypoint = mbinaryreader.9ead0ntAB&'4
int baseofcode = mbinaryreader.9ead0ntAB&'4
int baseofdata = mbinaryreader.9ead0ntAB&'4
0mage7ase = mbinaryreader.9ead0ntAB&'4
sectiona= mbinaryreader.9ead0ntAB&'4
lea = mbinaryreader.9ead0ntAB&'4
int majoros = mbinaryreader.9ead0nt2@&'4
int minoros = mbinaryreader.9ead0nt2@&'4
int majorimage = mbinaryreader.9ead0nt2@&'4
int minorimage = mbinaryreader.9ead0nt2@&'4
int majorsubsystem= mbinaryreader.9ead0nt2@&'4
int minorsubsystem = mbinaryreader.9ead0nt2@&'4
int verison = mbinaryreader.9ead0ntAB&'4
int imagesi$e = mbinaryreader.9ead0ntAB&'4
int si$eofheaders= mbinaryreader.9ead0ntAB&'4
int checksum = mbinaryreader.9ead0ntAB&'4
subsystem = mbinaryreader.9ead0nt2@&'4
int dllEags = mbinaryreader.9ead0nt2@&'4
stackreserve = mbinaryreader.9ead0ntAB&'4
stackcommit = mbinaryreader.9ead0ntAB&'4
int heapreserve = mbinaryreader.9ead0ntAB&'4
int heapcommit = mbinaryreader.9ead0ntAB&'4
int loader = mbinaryreader.9ead0ntAB&'4
datad = mbinaryreader.9ead0ntAB&'4
datadirectoryrva = new int52@64
datadirectorysi$e = new int52@64
for & int i = " 4 i F=2! 4 iDD'
%
datadirectoryrva5i6 = mbinaryreader.9ead0ntAB&'4
datadirectorysi$e5i6 = mbinaryreader.9ead0ntAB&'4
(
if & datadirectorysi$e52C6 == "'
throw new 3ystem.>xception&G/ot a valid -?9 leG'4
mlestream.,osition = sectionofset 4
3:irtual;ddress = new int5sections 64
33i$eOf9aw<ata = new int5sections 64
3,ointerTo9aw<ata = new int5sections 64
for & int i = " 4 i F sections 4 iDD'
%
mbinaryreader.9ead7ytes&2B'4
3:irtual;ddress5i6 = mbinaryreader.9ead0ntAB&'4
33i$eOf9aw<ata5i6 = mbinaryreader.9ead0ntAB&'4
3,ointerTo9aw<ata5i6 = mbinaryreader.9ead0ntAB&'4
mbinaryreader.9ead7ytes&2@'4
(
(
244260235.doc 4 od 541
public void <isplay,>3tructures&'
%
-onsole.#rite?ine&'4
-onsole.#rite?ine&G** Microsoft &9' ./>T 8ramework 0? <isassembler. :ersion
2.".AABH.CG'4
-onsole.#rite?ine&G** -opyright &-' Microsoft -orporation 2IIHJB""2. ;ll
rights reserved.G'4
-onsole.#rite?ine&'4
-onsole.#rite?ine&G** ,> Keader+G'4
-onsole.#rite?ine&G** 3ubsystem+
%"(G,subsystem.To3tring&GxHG''4
-onsole.#rite?ine&G** /ative entry point address+
%"(G,entrypoint.To3tring&GxHG''4
-onsole.#rite?ine&G** 0mage base+
%"(G,0mage7ase.To3tring&GxHG''4
-onsole.#rite?ine&G** 3ection alignment+
%"(G,sectiona.To3tring&GxHG''4
-onsole.#rite?ine&G** 8ile alignment+ %"(G,lea.To3tring&GxHG''4
-onsole.#rite?ine&G** 3tack reserve si$e+
%"(G,stackreserve.To3tring&GxHG''4
-onsole.#rite?ine&G** 3tack commit si$e+
%"(G,stackcommit.To3tring&GxHG''4
-onsole.#rite?ine&G** <irectories+ %"(G,datad.To3tring&GxHG''4
<isplay<ata<irectory&datadirectoryrva5"6 , datadirectorysi$e5"6 , G>xport
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva526 , datadirectorysi$e526 , G0mport
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva5B6 , datadirectorysi$e5B6 , G9esource
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva5A6 , datadirectorysi$e5A6 , G>xception
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva5C6 , datadirectorysi$e5C6 , G3ecurity
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva5!6 , datadirectorysi$e5!6 , G7ase
9elocation TableG'4
<isplay<ata<irectory&datadirectoryrva5@6 , datadirectorysi$e5@6 , G<ebug
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva5L6 , datadirectorysi$e5L6 ,
G;rchitecture 3pecicG'4
<isplay<ata<irectory&datadirectoryrva5H6 , datadirectorysi$e5H6 , GMlobal
,ointerG'4
<isplay<ata<irectory&datadirectoryrva5I6 , datadirectorysi$e5I6 , GT?3
<irectoryG'4
<isplay<ata<irectory&datadirectoryrva52"6 , datadirectorysi$e52"6 , G?oad
-ong <irectoryG'4
<isplay<ata<irectory&datadirectoryrva5226 , datadirectorysi$e5226 , G7ound
0mport <irectoryG'4
<isplay<ata<irectory&datadirectoryrva52B6 , datadirectorysi$e52B6 , G0mport
;ddress TableG'4
244260235.doc 5 od 541
<isplay<ata<irectory&datadirectoryrva52A6 , datadirectorysi$e52A6 , G<elay
?oad 0;TG'4
<isplay<ata<irectory&datadirectoryrva52C6 , datadirectorysi$e52C6 , G-?9
KeaderG'4
-onsole.#rite?ine&'4
(
public void <isplay<ata<irectory&int rva, int si$e , string ss'
%
string snal = GG4
snal = 3tring.8ormat&G** %"+x(G , rva'4
snal = snal.,ad9ight&2B'4
snal = snal D 3tring.8ormat&G5%"+x(G , si$e'4
snal = snal.,ad9ight&B2'4
snal = snal D 3tring.8ormat&G6 address 5si$e6 of %"(+G , ss'4
if &ss == G-?9 KeaderG'
snal = snal.,ad9ight&@L'4
else
snal = snal.,ad9ight&@H'4
-onsole.#rite?ine&snal'4
(
(

On compiling the above program, program2.exe is generated. /ow run the
executable as

),rogram2 a.exe

This command gives the following output.

Output
** Microsoft &9' ./>T 8ramework 0? <isassembler. :ersion 2.".AABH.C
** -opyright &-' Microsoft -orporation 2IIHJB""2. ;ll rights reserved.

** ,> Keader+
** 3ubsystem+ """""""A
** /ative entry point address+ """"BBLe
** 0mage base+ ""C"""""
** 3ection alignment+ """"B"""
** 8ile alignment+ """""B""
** 3tack reserve si$e+ ""2"""""
** 3tack commit si$e+ """"2"""
** <irectories+ """"""2"
** " 5" 6 address 5si$e6 of >xport <irectory+
** BBBH 5!A 6 address 5si$e6 of 0mport <irectory+
** C""" 5A2H 6 address 5si$e6 of 9esource <irectory+
** " 5" 6 address 5si$e6 of >xception <irectory+
** " 5" 6 address 5si$e6 of 3ecurity <irectory+
** @""" 5c 6 address 5si$e6 of 7ase 9elocation Table+
** " 5" 6 address 5si$e6 of <ebug <irectory+
** " 5" 6 address 5si$e6 of ;rchitecture 3pecic+
244260235.doc 6 od 541
** " 5" 6 address 5si$e6 of Mlobal ,ointer+
** " 5" 6 address 5si$e6 of T?3 <irectory+
** " 5" 6 address 5si$e6 of ?oad -ong <irectory+
** " 5" 6 address 5si$e6 of 7ound 0mport <irectory+
** B""" 5H 6 address 5si$e6 of 0mport ;ddress Table+
** " 5" 6 address 5si$e6 of <elay ?oad 0;T+
** B""H 5CH 6 address 5si$e6 of -?9 Keader+

3ince time immemorial, the rst function to be called is Main. 0n this function,
to begin with, an instance of class $$$ is created and then a nonJ static
function abc is called from it. The only reason for placing the bulk of our code
in the abc function is that the Main function is static. 0t cannot access
instance variables till an instance of its class is not created.

#e promise that it is for the rst and the last time in this book that we will
use names like $$$ and a. Kenceforth we will abide by big meaningful names
for variables*objects. ;nother simple rule that we have adhered to is that if a
variable is to be used by another function, then it is made a global or an
instance variable. Mlobal in the -. world is a noJno but in the -DD world is
allowed. Therefore at times, the names may sound legally wrong but they are
morally right.

The abc function is given an array of strings that hold the arguments
assigned to the program. 0n our case, it is the name of the ./et executable
that is to be disassembled. #hile writing code, there are possibilities of
making errors. ; dialog box pops up each time an error is encountered which
at times get extremely irritating. 8or this purpose, the code in Main is
enshrined within a try catch to simply display the exceptions.

/ow to understand the functioning of abc.
The array variable args5"6 contains the name of the le to be disassembled
which is saved in an instance variable, lename.

The ./et world has a million classes to handle les of which we have
presently used only two. The rst one is the 8ile3tream class. The constructor
of this class simply takes two parameters, the lename and an enum
8ileMode. The enum species how the le should be opened. This enum takes
three values which decide whether the le is to be opened, created or
overwritten. 0n the good old days of -, numbers or strings were used for
discreet values, however the modern world of today prefers the enums
instead. 0f you honestly ask us, we would prefer the old days anytime, but we
all have to move ahead with time, embrace the new and forget the old ways.

3ince the le is to be opened, the value of Open in the enum is used. ;n
exception is thrown if the le does not exist. The handle to the le is stored in
an instance variable suitably named mlestream. The only problem with the
8ile3tream class is that other than opening a le, it does nothing. 0t has a few
rudimentary functions that enable reading a byte from a le. Kowever they
are of no use to us since our interest lies in reading a short or an int or a
string from the le. Therefore, another class 7inary9eader, which permits
244260235.doc 7 od 541
reading primitive objects like shorts, ints and longs from the le is used. The
constructor of this class re1uires the mlestream handle. 0t is the
7inary9eader class that will be used and not the 8ile3tream class in order to
access the le.

The le format used by any #indows application is called the ,> or ,ortable
>xecutable le format. 7efore #indows evolved to become the big daddy of
operating systems, the earlier king of the hill was <O3. >ach and every
executable le started with the two bytes of M and N. This is how the <O3
operating system would recogni$e an executable le. The advent of windows
did not in any sense change the mindset of people thus they did not
acknowledge the diference between the two operating systems. :ery often a
a windows program was executed in the <O3 environment.

<O3 being a primitive operating system normally checks the rst two bytes
and on not seeing the magic numbers M and N, it displays a confusing
message O7ad -ommand or 8ile /ameP. This led to some confusion, thus as a
conscious decision, the makers of the ,> le format mandated that every ,>
le would start with a valid <O3 header. This header was then followed up
with a program that printed a valid error message if the program was to be
executed in the <O3 environment. The <O3 box of windows is a simulation of
the original <O3.

The actual ,> header of the le starts at bytes @". This location takes an int
thus the rst four bytes are clubbed up together and indicate the start of the
,> header. This ofset is not a xed value as diferent compilers decide on the
error messages for the <O3 program and thus change the length of the
message. Qsing the 3eek method of the 8ile3tream class, the le pointer is
positioned to the @"
th
byte in the le. The second parameter of the 3eek
function is an enum that takes three values. These values decide whether the
number specied in the rst parameter is an absolute ofset from the
beginning or end of the le or a relative ofset to the le pointer.

The le pointer is an imaginary construct that points to the current or the
next byte to be read. The ofset is stored in a variable startofpeheader and its
value normally is 2BH. ;s mentioned earlier this value can vary depending
upon the compilers used. The 3eek method is used again to jump to the start
of the ,> header. The 9ead7yte method is then implemented from the
7inary9eader class to read each byte. The magic number for a ,> header is ,
and > followed by two $eroes i.e. O,>""P.

This magic number is followed by a structure called the standard -O88
header. -O88 is the -ommon Object 8ile 8ormat. The rst two bytes or short
is the machine or better still the -,Q type that this executable or image le
can run on. ;n executable can either run on the specied machine or a
system that emulates it. The ,> specications are available on the Microsoft
site which species all possible values that the various structures can have,
hence we will not irk you with these details.

244260235.doc 8 od 541
0n our case, the hex value displayed is "x2Cc which stands for an 0ntel AB bit
machine. This value has not been displayed in the output for the simple
reason that ildasm does not display the value and we have decided to follow
the ildasm program to the T. This value is stored in a local variable called
machine, it is not an instance variable. The method 9ead0nt2@ is used to read
a short or two bytes from a le. This method from the 7inary9eader class is
used to fetch bytes from the le. Thus using the 7inary9eader class saves us
the hassle of reading bytes and then doing their multiplications.

The second eld is the number of sections in the ,> le. ; ,> le contains
diferent types of entities like code, data, resources etc. >ach entity or section
needs to be stored in a diferent part of the ,> le, therefore structures are
used to keep track of all them. The next short gives the number of sections
and the value received for the le is three. 3ome time later, the sections will
have to saved in structures and hence the variable sections is an instance.
This is followed by the date time stamp which gives information when this le
was created. The method 9ead0ntAB is used to extract this C byte value.

This is followed by a C byte entity that is a pointer or ofset to the symbol
table. The next int is the number of symbols available. The value of the
pointer to symbol table is $ero, which means an absence of the symbol table.
3ymbol tables are present only in obj or object les. 0n the good old days the
compilers created an obj le and linkers created exe le from obj les. 0n
the .net world the obj le are obsolete and hence these two intPs are always
$ero.

;fter the rst header, is another header called the image optional header.
This header is never seen in obj les and its si$e can also vary but so far its
been a constant value at BBC bytes.

Then comes a eld called characteristics, which species the attributes of the
le. The value received is "x2"e.

7it diagram

0ndividual bits in a byte carry diferent bits of information. The value of "xe
or 2C has a bit pattern wherein the B, A and C
th
bits are on.

7it <iagram

This signies that the le is a valid executable & bit B', there are no -O88 line
number present in the le or have been stripped of & bit A' and the symbol
table entries are also absent& bit C'. ; value of "x2"" signies that the
machine running the executable is based on a AB bit architecture. This value,
which is the last member of the structure, is not displayed by the ildasm
utility.

The section table begins immediately after the image optional header, i.e.
thus it is after the start of the optional header plus the si$e of the optional
244260235.doc 9 od 541
header. The variable sectionofset has been used to store this value, thus it
can be used to jump to the section table as and when re1uired.

The optional header has the rst eld of a short type, which represents the
magic number. This can take any of the two values, "x2"b if it follows the ,>
format which presently is the case. The other value is "xB"b when the header
is of a ,>ABD format. This value is generally seen when les use @C bit
addresses.

0n the optional header, the information is divided into three distinct parts. The
rst BH bytes is part of the standard ,> header, the next @H bytes applies to
the windows operating system only and the nal bytes are for the data
directories. The second and third eld of the standard header are the major
and minor linker verison numbers which presently have a value of @ and ".
This is followed by the si$e of the code block in the exe le. The si$e of
initiali$ed and uninitiali$ed data follows next.

The displayed value of "xBBLe is for the next eld called entrypoint. This
value is relative to where the program is loaded in memory or image base. 0n
our case, since the le is an exe le, the instruction at this value becomes the
rst memory location that gets executed by the Operating 3ystem. 0n case of
a device driver, there is no such specic function to be called, and hence it is
the address of the initiali$ation function. ; <?? does not have to have an
entry point and thus may have a value of ".

The base of code and base of data are similar to the entrypoint eld, which
reveal the code or data area when loaded in memory, all relative to the
image base. The 0mage7ase eld is a logical address that points to the area
where the Operating 3ystem loads the exe le.

3imilar to our likes and dislikes, the O3 prefers a value "x""C""""" as an
address for executables, for a <?? it is "x2""""""" and for #indows -> it is
"x"""2"""". These starting addresses can be changed by supplying an
option to the linker ant it must be a multiple of @C R. /evertheless, it is not
advisable experimenting with diferent values.

The next value of B"CH is the section alignment. The above value signies
that even when a section has a si$e of 2"" bytes, the O3 will allocate a
minimum of B"CH bytes for it. The rest of the bytes in the memory area
allocated remain unused. This section alignment is normally the page si$e of
the machine and is used for purposes of eSciency. 3imilar to the 3ection
alignment is the le alignment eld that applies to the le stored on disk. The
le alignment is displayed as !2B bytes, which implies that each section
when stored on diske takes up at least !2B bytes on disk, on disk !2B bytes
make up one sector.

The next elds are the major and minor numbers of the Operating 3ystem,
the image and the subsystem. The next eld called verison is reserved. The
following eld is a si$e of all the code plus headers, followed by a eld that
only stores the si$e of all the headers including section headers. The next
244260235.doc 10 od 541
eld called checksum helps the Operating 3ystem detect whether the le has
been damaged or tampered before it can be loaded into memory.

The next eld of subsystem displayed by ildasm informs the Operating
3ystem of the minimum subsystem re1uired of it by the exe le. ; value of A
in our case means a console subsystem, therefore no Mraphical Qser
0nterface please4 whereas a value of B would mean a Mraphical Qser 0nterface
system. The eld dllEags applies to <??Ps as the name signies.

8ollowing the eld dllEags are two elds that deal with the stack. The stack is
an area in memory, which is used to pass parameters to functions and create
local variables. The stack memory is reused at the end of a function call and
hence it is shortJterm memory whereas the heap area is for long duration.
The second eld called stackcommit is the amount of memory that is
allocated to the stack. The value seen is "x2""" bytes which is the stack
reserve memory given to the application. Thus initially stack commit is
allocated and once this gets used, one page at time is allocated dynamically,
till the stack reserve is used. The two elds after the stack eld are not
displayed as they deal with the heap area in memory. The documentation is
pretty candid that the loader eld is obsolete.

The last eld of the optional header gives the number of data directories
following. 3o far only a value of 2@ is seen. ?ets now understand the concept
of a data directory.

; data directory is nothing but two elds, the rst eld is a location or what is
technically called an 9:; &9elative :irtual ;ddress' that gives information as
to where some data starts in memory. The second eld is si$e in bytes of the
entity. These are stored back to back.

Two arrays of si$e 2@ and data type int are created to store the 9:;Ps and
si$es of each data directory entry. 0f the 2Cth data directory entry has a si$e
of $ero, then it is conclusive of the fact that the executable le is not created
by a ./et compiler. 0n such a case, there is no reason to continue further, so
the program is made to throw an exception and then gracefully 1uit out. The
reasoning will be catered to a couple of paragraphs down the road.

The section headers start immediately after the data directories. Kowever,
we take no chances and use the ,osition property of the 8ile3tream class, to
give the current position of the imaginary le pointer. The ,osition property is
read*write thus it not only gives the details about the imaginary le pointer
but also sets it to a new position if need be.

The 3eek method can be used again, like before to jump to a part of the le,
but as variety is the spice of life, we set the ,osition property instead. The
world of computer programming lets us skin a cat multiple ways. ;ll the
elds of the section headers are not important except three of them, so we
create three arrays of ints to store the three elds.

244260235.doc 11 od 541
The rst eld is the virtual address or 9:; of the section in memory &#e
remember our promise to explain it', this is followed by the si$e of the section
and nally the location on disk where the section is located. The si$e of a
section header is C" bytes. The three elds of our interest start 2B bytes from
the start of the header, so using the 9ead7ytes function, the rst 2B bytes
are skipped. Then, the next three elds are read into the array variables.
3ince the remaining 2@ bytes too have no signicance, the last 2@ bytes are
skipped. #e could have used the 3eek function to jump over the BC bytes
that we are not interested in. Then again, we decided to use a method that is
easiest to explain to you. The data directory and the section headers are now
saved in arrays.

The next function <isplay,>3tructures nally displays these values on the
console. The only stumbling block here is that the output should match that
of ildasm and just to remind you ildasm displays its output in a formatted
manner. #hat we have is the 3hared 3ource code, which comes with the
source code of a disassembler and not the actual code of ildasm. The code
when executed in no sense displays the output similar to that of ildasm. Thus
we had no choice but to spend a lot of time guring out how many spaces
need to be placed at diferent points in the line.

; byte by byte comparison with the output generated by the original ildasm
program can surely indicate our follies. Thus we decided to take this
approach as otherwise there is no other way of knowing whether the code we
have written works or not. To pursue it further, we wrote our own le
compare program to check whether the output generated by our
disassembler and that of ildasm is the same, however you have an option of
choosing any le compare program to suit your needs.

;fter displaying a new line, the version number of the disassembler is
displayed. 0n our case the version is 2.".AABH.C, however yours could be
larger or smaller, so please make the appropriate changes. Then the values
of L variables vi$, subsystem, image base, sectiona, lea, the stack variables
and the number of data directories are displayed

0nitially, we have entered the spaces manually for alignment purpose wherein
numeric variables by default are displayed in decimal and using the To3tring
function present in the object class. There are a myriad of formats that can
be put to use. The small x is used for the hexadecimal numbering system
with the alpha characters displayed in small and not caps. The number H right
justies the number and lls up the rest with $eroes.

The sixteen data directories are displayed using a function
<isplay<ata<irectory. This function takes the rva and si$e of the element in
the array alongwith a string to denote the name of the data directory. The
prime objective of this function is to format the output and display it in a
certain manner.

244260235.doc 12 od 541
The string snal does not have to be initiali$ed to a null string. Kowever, we
do the same out of habit since -. does not permit using an uninititali$ed
variable on the right hand side of the e1ual to sign or as a return value.

Thereafter, using the static 8ormat function from the 3tring class, the rva of
the data directory is displayed. The curly braces is a format option used by
the #rite?ine function and the " is the placeholder for the rst parameter.
The colon following is used to specify the formatting. The small x is for a
hexadecimal output.

The open s1uare 5 brackets must be placed 2B spaces away, and hence the
,ad9ight function is used to pad 2B spaces to the string. The entire line to be
displayed is then nally stored in the string snal and then given to the
#rite?ine function to display it in one go. Then using the 8ormat function the
si$e of the data directory is emitted out but after having considered B2
spaces, to synchroni$e with the ildasm output. Thereafter, the name of the
data directory is displayed. /ow for some 1uirks. 8or some reason the last
data directory is not displayed, the second last is the -?9 header.

8or this data directory, ildasm places @L spaces before displaying it whereas
for the others, after displaying them, @L spaces are inserted till the end of the
line. 8or this purpose, an if statement that checks the name of the data
directory is introduced which decides on the spaces that are to be padded to
the string before writing it out. To verify every byte displayed is similar to the
output displayed by ildasm, we had to cater to ever space seen also. Thus we
had no choice but to spend lots of time getting the spaces right. /ow that the
rst program is over, the output can be compared with that of the
disassembler and to check that it matches it to a T.

>ven though the ./et documentation very clearly species that the M3T<O3
stub should be exactly 2BH bytes large, not all ./et compilers follow the
documentation. This documentation also species the values that most elds
must have.

0n the standard ,> header the Machine eld must always be "x2Cc. The <ate
Time eld is the number of seconds since 2
st
Uan 2IL" i.e ""+""+"" and the
,ointer to 3ymbol table and number of symbols must always be ". The nal
eld -haracteristics has the following bits "xB, "xC, "xH, "x2"" set and the
rest ". The bit "xB""" is set for a dll and cleared for an exe le.

The ,> standard header elds are now set as follows. The Magic number is
"x2"b. The Major and Minor version numbers are @ and ". The -ode and <ata
si$es have the same meanings as explained earlier. The 9:; must point to
bytes "xf "xB! followed by a 9:; of "xC"""""" or " for a <??. The section
that it falls in must have the attributes execute and read. The 7ase of -ode is
"x""C""""" and " for a <?? and the base of <ata is the data section.

>very exe le has a starting memory location that contains the rst
executable instruction which is called the entry point. #indows IH for
example does not understand a native ./et executable and hence it is called
244260235.doc 13 od 541
a nonJ-?0 platform. The words -?0 will be repeated a trillion times and its full
form is -ommon ?anguage 0nfrastructure.

8or an exe le, the rst function to be called is -or>xeMain and for a dll it is
T-or<llMain, the code of which resides in the library mscoree.dll. 0t is this
function that understands a ./et executable, thus we believe that in future
this function will reside in the operating system. 0t is this function that
understands concepts like 0? and metadata which we will explain in course of
time.

The #indowsJspecic elds have the following values. The image base as
mentioned earlier is "xC""""", the section and le alignment are "xB""" and
"xB"" respectively. The O3 Major version is C and Minor version is ". The Qser
Major and Minor versions are ". The 3ubJ3ystem Major version is C and Minor
version ". The 9eserved eld is always ". The 0mage 3i$e is a si$e in bytes of
all headers plus padding and it has to be a multiple of 3ection ;lignment.
The Keader 3i$e is the si$e of three headers, <O3, ,> header and optional ,>
header. This also includes padding and must be a multiple of the 8ile
;lignment value. The -hecksum and <?? Eags must be $ero and the
3ubsystem can take a value of B or A only. The 3tack reserve has a value of
2Mb and stack commit is CR. The heap 9eserve and -ommit have the same
values also. The ?oader Eags are " and the /umber of <ata <irectories are
2@.

Most of the data directories have an 9:; value but with a si$e of ". These are
the 0mport, 9esource, >xception -erticate, <ebug, -opyright , Mlobal ,tr,
T?3 Table, ?oad -ong, 7ound 0mport, <elay 0mport table and the last that is
reserved. The four directories that may have some si$e are the 0mport, 7ase
9elocation , 0;T and nally the -?0 Keader.

The section headers immediately follow the optional headers since there is no
entry in the ,> headers that point to the section headers. The name of the
section is what the section headers start with and it is H bytes large.
Therefore there is no terminating null when the length of the section name is
H characters. /ormally section names start with a dot, for example, the
section containing code is called .text and that containing data is called .data.
The second eld is called :irtual 3i$e and it is a multiple of the section
alignment. The eld stores the si$e of the section when the section is loaded
in memory. The fourth eld is the 3i$eOf9aw<ata. 0f this eld is greater than
the fourth, the section is $ero padded.

The third eld :irtual;ddress is an 9:; and thus relative to the image base. 0t
determines where the section is loaded in memory. The si$e of 9aw <ata is
the fourth eld and it is the si$e of the initiali$ed data on disk, thus a multiple
of the le alignment. ;s this eld is rounded to the le alignment and not
section alignment like the virtual si$e, it cannot be greater than the :irtual
3i$e eld. 0f the section contains only initiali$ed data then the value stored in
this eld is ". The ,ointerTo9aw<ata eld is a 9:; to the rst page within the
,> le and thus is a multiple of 8ile ;lignment.

244260235.doc 14 od 541
The next eld is the ,ointer to 9elocations that is the rva of the relocation
section or .reloc. The ,ointer to ?ine /umbers that follows is $ero and the
/umber of 9elocations is the actual count number of relocations. The second
last eld is the /umber of ?ine numbers that is obviously $ero. 8inally there is
the characteristics that determines one of six possible attributes of the
sections. These attributes decide whether the section carries executable
code, initiali$ed data, uninitiali$ed data, is executable or read or write.

To stress test our disassembler, we have looked at other languages also.
Thus, if you are conversant with only one language, you may nd it a little
diScult to stressJtest your program. The ones who are learned about the -DD
programming language can attempt the next program in se1uence. ;bout the
software, fear not, cause if you have installed :isual 3tudio.net the -DD
compiler called cl also get installed.

a.cpp
main&'
%
(

a.cpp is a -DD program that simply contains one function called main. There
are two dissimilarities between this cpp program and the smallest -.
program. 8irstly, in -DD, all functions need not be in a class hence they are
made global. This is one sensible thing in -DD that was amended in -. and
Uava, mainy due to political reasons. The second diference is that the m of
main is small and not caps as in -.. This is done after consulting a do$en
numerologists.

-ompile the above cpp le to an exe le by running the following command.

-l *clr a.cpp

The *clr option creates a ./et executable. 0f for some reason you cannot get
the above program compiler, worry not as we have gone the -DD way to get
some more output and some more executables.

Our disassembler nally will have beyond 2",""" lines of code. There is no
way in heaven or hell, the entire program can be explained in one go. >ven
Mod and ourselves would nd it diScult to understand what we are saying. 3o
please follow instructions to the letter T.

,rogramB.csc
public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
(
public void 9eadand<isplay0mport;dressTable&'
%
244260235.doc 15 od 541
long stratomports = -onvert9:;&datadirectoryrva526'4
mlestream.,osition = stratomports4
-onsole.#rite?ine&G** 0mport ;ddress TableG'4
int outercount = "4
while &true'
%
int rvaimportlookuptable = mbinaryreader.9ead0ntAB&'4
if & rvaimportlookuptable == "'
break4
int datetimestamp = mbinaryreader.9ead0ntAB&'4
int forwarderchain = mbinaryreader.9ead0ntAB&'4
int name = mbinaryreader.9ead0ntAB&'4
int rvaiat = mbinaryreader.9ead0ntAB&'4
mlestream.,osition = -onvert9:; &name'4
-onsole.#rite&G** G'4
<isplay3tring8rom8ile &'4
-onsole.#rite?ine&G** %"( 0mport ;ddress TableG ,
rvaiat.To3tring&GxHG''4
-onsole.#rite?ine&G** %"( 0mport /ame TableG , name.To3tring&GxHG''4
-onsole.#rite?ine&G** %"( time date stampG , datetimestamp'4
-onsole.#rite?ine&G** %"( 0ndex of rst forwarder referenceG ,
forwarderchain'4
-onsole.#rite?ine&G**G'4
long importtable = -onvert9:;&rvaimportlookuptable ' 4
mlestream.,osition = importtable4
int nexttable = mbinaryreader.9ead0ntAB&'4
if & nexttable F " '
%
-onsole.#rite?ine&G** 8ailed to read import data.G'4
-onsole.#rite?ine&'4
outercountDD4
mlestream.,osition = stratomports D outercount V B"4
continue4
(
int innercount = "4
while & true '
%
long pos" = -onvert9:;&rvaimportlookuptable' D innercount V C4
mlestream.,osition = pos" 4
int pos2 = mbinaryreader.9ead0ntAB&'4
if & pos2 == "'
break4
long posB = -onvert9:;&pos2'4
mlestream.,osition = posB 4
short hint = mbinaryreader.9ead0nt2@&'4
-onsole.#rite&G** G'4
if & hint.To3tring&GWG'.?ength == 2'
-onsole.#rite&G %"(G , hint.To3tring&GxG''4
if & hint.To3tring&GWG'.?ength == B'
-onsole.#rite&G %"(G , hint.To3tring&GxG''4
244260235.doc 16 od 541
if & hint.To3tring&GWG'.?ength == A'
-onsole.#rite&G%"(G , hint.To3tring&GxG''4
-onsole.#rite&G G'4
<isplay3tring8rom8ile&'4
innercountDD4
(
-onsole.#rite?ine&'4
outercountDD4
mlestream.,osition = stratomports D outercount V B"4
(
-onsole.#rite?ine&G**<elay ?oad 0mport ;ddress TableG'4
if &datadirectoryrva52A6 == "'
-onsole.#rite?ine&G** /o data.G'4
(
public long -onvert9:; &long rva'
%
int i4
for & i = " 4 i F sections 4 iDD'
%
if & rva )= 3:irtual;ddress 5i6 XX & rva F 3:irtual;ddress5i6 D
33i$eOf9aw<ata 5i6 ''
break 4
(
return 3,ointerTo9aw<ata 5i6 D & rva J 3:irtual;ddress5i6 '4
(
(
public void <isplay3tring8rom8ile&'
%
while & true '
%
byte lebyte = &byte 'mlestream.9ead7yte&'4
if & lebyte == "'
break4
-onsole.#rite&G%"(G , &char'lebyte'4
(
-onsole.#rite?ine&'4
(

** 0mport ;ddress Table
** R>9/>?AB.dll
** """"@""" 0mport ;ddress Table
** """"LIbc 0mport /ame Table
** " time date stamp
** " 0ndex of rst forwarder reference
**
** 2@L MetModuleKandle;
** fd Met-ommand?ine;
** 2aH Met3ystem0nfo
** A!d :irtualYuery

244260235.doc 17 od 541
** mscoree.dll
** """"@"eC 0mport ;ddress Table
** """"LIdH 0mport /ame Table
** " time date stamp
** " 0ndex of rst forwarder reference
**
** !a T-or>xeMain

** <elay ?oad 0mport ;ddress Table
** /o data.

The program programB.csc is not shown in full. Only those functions that are
new or changed are displayed. ;ny instance variables added will also be
shown. 8or example in the above since we have introduced a function call to
a new function 9eadand<isplay0mport;dressTable in the abc function, the abc
function is displayed again. The 9ead,>3tructures function undergoes no
change and hence is not shown at all.

Our disassembler also does not aim at winning any pri$es in any competition
on speed and eSciency. The main objective of the program is to help you
understand the workings of a disassembler. Once this objective is achieved,
then modications can be made for it to work faster. #e have scaried speed
at the altar of understanding.

This program displays the import table. 0n the programming world we share,
share and share. Thus other programmers write code that is placed functions
in dllPs and we mortals call those functions in our code.

Microsoft #indows comes with 2""Ps of such dllPs that contain code and
expect the programmers to use these functions while coding. These dllPs have
names like userAB.dll, kernelAB.dll etc. >very -. program eventually calls
code in these dllPs.
7esides, Microsoft also allows programmers to create their own dll with their
set of functions and have other coders call them. #hen the linker creates an
exe le it list out all the dllPs that the exe le is calling code from.
3imultaneously, within these dllPs, there is a list that enlists the functions that
are being called. Thus, before executing any program in memory, the
operating system needs to also load the dllPs mentioned in the import table in
memory and check for the function in the executable with its corresponding
entry in the dll.

0n order to display the contents of the import directory, rva and the si$e are
re1uired. The second data directory gives the rva and si$e of the import
directory. The function 9eadand<isplay0mport;dressTable then gures out the
<ll names and displays them as prescribed by the ildasm program.

The 9:; or a relative virtual address is a number that represents some entity
in the memory. This location is where the runtime loader will place the entity
in memory. The le addresses are not signicant because the ,> le format is
244260235.doc 18 od 541
optimi$ed for memory. Thus using the 9:;, it is pertinent to gure out where
on disk the import directory begins.

8unction -onvert9:; comes to aid as it will convert an 9:; into a physical
address. 0n the last program, three section header details were stored in
three diferent arrays alongwith the number of sections in a variable called
sections. This function -onvert9:; is passed a memory location as a long
that is to be converted into a disk based address. ;s arrays start from ", the
for loop begins from " and ends when it reaches the number of sections
minus 2. 0n the loop, the parameter passed i.e. rva is checked to be greater
than the value of the array member 3:irtual;ddress and at the same time
less than the same value plus the second array 33i$eOf9aw<ata.

The check is performed because the array 3:irtual;ddress stores the starting
rva that this section is associated with and 33i$eOf9aw<ata is the si$e of the
data of this section. Thus, the section headers report the memory occupied
by each header. The third member is the 3pointerTo9aw<ata, which is also
the address of the start of the section, but on disk. This approach helps in
deciphering the rva the section belongs to and once an e1ual match is
attained, the loop is abruptly terminated. The 3,ointerTo9aw<ata value
cannot be the return value as it is the starting position of the section on disk,
therefore the rva parameter is subtracted from the 3:irtual;ddress or
starting rva in memory. This ofset is then added to the 33i$eOf9aw<ata
value. 7ear in mind that this works on the assumpution that a valid rva is
given and hence no error checks are performed.

Thus in short, the above workings are as follows. The starting rvaPs of each
section and the length of the data of the section is available. 0n the for loop,
the rva passed is checked to be in the range of each section. 0f so, the
diference is added to the disk location where this section starts. 0n other
words, an 9:; is the address of an entity after the loader loads it in memory.
Obviously the address where the image is loaded in memory or 0mage 7ase is
subtracted from the 9:;. This is because the image can be theoretically
loaded anywhere in memory.

The method adopted for locating the physical le location, given a 9:;, is
taken from the documentation that comes with the Tool <evelopers Muide.

The wrongly spelt variable stratomports tells is where on disk the import
table begins. This value is given to the ,osition property. 0n this case, the
variable in not needed but hey nobody is charging us for an extra variable.

Two loops have been given to display the import table since there are two
diferent entities to display. The outer loop applies to selecting each and
every dll, one at a time and the inner loop is to display the names of the
functions from the chosen dll. The variable outercount is initiali$ed to " and it
will be used later in the program.

>very dll has a structure called the 0mport <irectory Table that represents the
details of the functions that are being imported and its si$e is B" bytes wide.
244260235.doc 19 od 541
The B" bytes are well categori$ed in ! elds. The rst eld is the address of
the 0mport ?ookup Table that gives the name of the function that is being
imported from each dll.

0f this value is $ero, then it signies that the 0mport <irectory table has ended
and the outer loop is to be terminated. The second eld is for the date time
stamp and is always $ero. #hen the exe le is loaded into memory, the
loader sets this eld to the data time stamp of the <ll. The third eld is the
index of the rst forwarder reference and its value is also $ero. The fourth
eld is the name of the <ll and the address is an 9:; and hence the
-onvert9:; function is used which convert the address into a physical
memory location. The ,osition property is directly set to this value directly
and then the function <isplay3tring8rom8ile is used to display the <?? name
which is stored in ;3-00 format. The last eld is an 9:; of the 0mport ;ddress
Table. This table is similar in content to the 0mport ?ookup Table and only
changes after the image is loaded into memory or bound. This value may be
the last eld of the structure but displayed rst.

?ets rst move to the function <isplay3tring8rom8ile. The function starts with
an indenite while loop and simply fetches one byte at a time from the le.
This function assumes that the le pointer is placed on the rst byte and does
not attempt to save the le position.

0t then uses the #rite function to display the byte as a character by using the
char cast. 0f the byte picked up is $ero, it means that the end of the dll names
has been reached and the loop is then terminated. 7efore we 1uit out of the
function, we have ended with a new line. #e could have instead returned a
string but chose not to for no particular reason.

The values of the structure members like the 0mport ;ddress Table, the
0mport /ame Table and the <ate Time stamp and the forwarder are then
displayed. Then using the loop construct, the names of the functions from the
dllPs are displayed. The variable rvaimportlookuptable gives the rva of the
0mport ?ookup Table and using the -onvert9:; function this rva is converted
into a physical location on disk.

;s the innercount variable value is ", the multiplication yields a $ero. The
position property is set to this value thereby having the le pointer positioned
at the start of the table. The 0mport ?ookup Table is a set of intPs, one for each
function being imported. The value of the int being $ero is an indication that
the table is over, thus we 1uit out of the inner loop.

The A2
st
bit is the most crucial and if it is set, i.e. has a value of 2, then the
importing is by ordinal values or number, and if it is not set then the
importing is by name. Our hypothesis is that we are importing by name and
hence the int read is taken to be an 9:; to a Kint /ame table, otherwise it is
a simple ordinal number.

One more reason as to why the A2
st
bit is not checked for is that till date we
have not encountered a single ./et executable that imports functions from a
244260235.doc 20 od 541
<?? by its ordinal value. Thus writing code that checks for imports by ordinal
value is baseless since it can never be veried for its accuracy. ;lso, the ./et
world unlike the good old -*-DD world does detest playing around with the
internals of sections.

The int picked up is converted into a physical location of the Kint /ame Table.
This table is of variable length with the rst short as the Kint eld. The
second eld is the name of the function stored as an ;3-00 string.

;fter attaining the si$e of the hint, the spacing is determined. #e could have
done the formatting using inbuilt functions but chose the brute force method
just to tell you that as long as it works, use it. Kowever if the options get to
many, then the above method gets to tedious. Then the string class and
To3tring function ofers a more elegant solution than our clumsy way.

Once the name of the function is displayed, the innercount variable is
increased by 2.

On returning to the start of the loop, the next task is to display the second
function name and hint. 7ut, the problem is that the le pointer is currently
positioned at the end of the name of the rst function, hence it is not on the
right byte. Therefore, there is no alternate approach but to jump to the start
of the 0mport ?ookup Table and then determine the rva of second function.

The -onvert9:; function moves to the start of the table and as innercount is
one and the si$e of each eld is C, the rva is now of the second function. #e
are very much aware that the above is not an elegant way, but it works. #e
could have stored the original le pointer position before moving the le
pointer around.

;n enter key is emitted after moving out of the inner while loop. Then the
variable outercount is increased by 2. This variable keeps a count of the dllPs
that have been scrutini$ed.

7ear in mind that before looping back to the outer for loop, the le pointer
must be positioned at the start of the appropriate 0mport <irectory Table.
Thus, the same procedure is adopted again where using the variable
stratomports we move to the start of the 0mport <irectory Table structures.
3ince each structure is B" bytes long, we multiply the number of dllPs already
completed with the number that is stored in the outercount variable. 0n this
manner, the 0mport table is then completely displayed.

The second table that ildasm displays is the <elay ?oad 0mport ;ddress. The
9:; and si$e for these are stored in the 2C <ata <irectory. ;fter examining
around !""" ./et executables, we reali$ed that not one of them had this
table. The reason being that in the ./et world it is not acceptable to write and
create our own sections and hence this table does not get created. The linker
is endowed the responsibility to create this table.

244260235.doc 21 od 541
Zou may be a bit surprised to see the if statement checking the value of the
variable nexttable. There is one le system.enterpriseservices.thunk.dll that
gives an error with the dll oleautAB.dll while displaying the imports. The error
check is to print the error and continue with the program.

;fter having determined the start of the import table, the rva of the hint
name table is picked up. 0f this rva for some reason is less than ", we display
an error message and then go back to the start of the next dll. ;n rva
represents a memory location and therefore cannot be negative. This error
occurs only with one dll and one dll within it.

8or the import address table, the <ate Time stamp and the 8orwarder -hain
elds are $ero as per the specication. 9emember a $ero denotes the end of
the table. The hint eld should also be $ero. ; point to be noted is that the
name of the function is case sensitive. The names T-or>xeMain and
T-or<llMain are decided by the specications.

JJJ
,rogramA.csc
int metadatarva4
int corEags4
int entrypointtoken4
int vtablerva4
int vtablesi$e4
int exportaddressrva4
int exportaddresssi$e4

public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
(

public void 9eadand<isplay-?9Keader&'
%
-onsole.#rite?ine&G** -?9 Keader+G'4
mlestream.,osition = -onvert9:;&datadirectoryrva52C6'4
int si$e = mbinaryreader.9ead0ntAB&'4
int majorruntimeversion = mbinaryreader.9ead0nt2@&'4
int minorruntimeversion = mbinaryreader.9ead0nt2@&'4
metadatarva = mbinaryreader.9ead0ntAB&'4
int metadatasi$e = mbinaryreader.9ead0ntAB&'4
corEags = mbinaryreader.9ead0ntAB&'4
entrypointtoken = mbinaryreader.9ead0ntAB&'4
int resourcesrva = mbinaryreader.9ead0ntAB&'4
int resourcessi$e = mbinaryreader.9ead0ntAB&'4
int strongnamesigrva = mbinaryreader.9ead0ntAB&'4
int strongnamesigsi$e = mbinaryreader.9ead0ntAB&'4
244260235.doc 22 od 541
int codemanagerrva = mbinaryreader.9ead0ntAB&'4
int codemanagersi$e = mbinaryreader.9ead0ntAB&'4
vtablerva = mbinaryreader.9ead0ntAB&'4
vtablesi$e = mbinaryreader.9ead0ntAB&'4
exportaddressrva = mbinaryreader.9ead0ntAB&'4
exportaddresssi$e = mbinaryreader.9ead0ntAB&'4
int managednativeheaderrva = mbinaryreader.9ead0ntAB&'4
int managednativeheadersi$e = mbinaryreader.9ead0ntAB&'4
if & si$e )= 2""'
-onsole.#rite?ine&G** %"( Keader 3i$eG, si$e'4
else
-onsole.#rite?ine&G** %"( Keader 3i$eG, si$e'4
-onsole.#rite?ine&G** %"( Major 9untime :ersionG, majorruntimeversion'4
-onsole.#rite?ine&G** %"( Minor 9untime :ersionG, minorruntimeversion'4
-onsole.#rite?ine&G** %"( 8lagsG, corEags.To3tring&GxG''4
string dummy = G** G D entrypointtoken.To3tring&GxG'4
dummy = dummy.,ad9ight&2B' D G>ntrypoint TokenG4
-onsole.#rite?ine&dummy'4
<isplay<ata<irectory&metadatarva , metadatasi$e , GMetadata <irectoryG'4
<isplay<ata<irectory&resourcesrva, resourcessi$e, G9esources <irectoryG'4
<isplay<ata<irectory&strongnamesigrva, strongnamesigsi$e, G3trong /ame
3ignatureG'4
<isplay<ata<irectory&codemanagerrva, codemanagersi$e, G-odeManager
TableG'4
<isplay<ata<irectory&vtablerva, vtablesi$e, G:Table8ixups <irectoryG'4
<isplay<ata<irectory&exportaddressrva, exportaddresssi$e , G>xport ;ddress
TableG'4
<isplay<ata<irectory&managednativeheaderrva, managednativeheadersi$e,
G,recompile KeaderG'4
-onsole.#rite?ine&G** -ode Manager Table+G'4
if & codemanagerrva == "'
-onsole.#rite?ine&G** defaultG'4
(
(

** -?9 Keader+
** LB Keader 3i$e
** B Major 9untime :ersion
** " Minor 9untime :ersion
** 2 8lags
** @"""""2 >ntrypoint Token
** B"LC 52bC 6 address 5si$e6 of Metadata <irectory+
** " 5" 6 address 5si$e6 of 9esources <irectory+
** " 5" 6 address 5si$e6 of 3trong /ame 3ignature+
** " 5" 6 address 5si$e6 of -odeManager Table+
** " 5" 6 address 5si$e6 of :Table8ixups <irectory+
** " 5" 6 address 5si$e6 of >xport ;ddress Table+
** " 5" 6 address 5si$e6 of ,recompile Keader+
** -ode Manager Table+
** default
244260235.doc 23 od 541

The focus of this program is to simply display the -?9 header. 0n the
computer world, it is extremely diScult to incorporate any changes in the
program, as existing code needs to run parallely with new code.
-onse1uently, the le format for the ./et world is a strict extension of the
existing ,> le format. The operating system however, has to identify with
some methods to diferentiate between a conventional ,> le and a ./et
executable.

Qp to now, all our programs have worked with the conventional ,> le format.
Kenceforth, we will concentrate on the new entities the ./et world brings in.

The -?0 header is the starting point of all the entities that make up the ./et
world. This header is readJonly and hence it is placed in the readJonly section.
0t is the second last section that resolves the 9:; and si$e of the -?0 header.

0t should suSce to say that metadata is the pillar on which the ./et world
rests on. 0f the ./et world were to get renowned, it would be due to the
concepts of metadata.

The program has seven instance variables freshly created. 0n addition, a
function named 9eadand<isplay-?9Keader has been added in the abc
function. This newly introduced function will now display the -?0 header.

The data in the 2C
th
directory entry is used to position the le pointer at the
start of the -?0 header on disk. The header begins with the si$e of the -?0
header in its very rst eld, the value shown is LB and it is in bytes. The
second and third refer to the version of the runtime that is re1uired to run the
program. The major version normally comes rst, presently having the value
of B and the minor version is ". The fourth eld is the 9:; of the meta data.
This is then followed up with the Eags eld that describes the image. The Eag
eld is used by the loader.

8lag diagram
JJJ
The rst Eag when it is set is is indicative of the fact that the image is an 0?
only image. The second Eag decides whether we can run an image of @C bit
native integers in a AB bit address space. The fourth Eag informs of a strong
name signature. Thereafter comes the entry point token or details of the rst
function, this will be explained later in greater detail.

; series of data directory entries for the 9esources, 3trong/ame3ignature,
-ode Manager table, :table 8ixupPs, the >xport ;ddress Table Uumps and
nally the Managed /ative Keader follow up next. The -ode Manager table
and >xport ;ddress Uumps and Managed /ative Keaders are always $ero.

0n the program, a check is perform on the si$e to be greater than 2"". This
consideration helps in formatting the output since an extra space is to be
added. ;s mentioned earlier the -ode Manager table always has a value of
$ero.
244260235.doc 24 od 541

,rogramC.csc
int 56 rows4
string 56 tablenames = new 3tring56%GModuleG , GType9efG ,
GType<efG ,G8ield,trG,G8ieldG, GMethod,trG,GMethodG,G,aram,trG ,
G,aramG, G0nterface0mplG, GMember9efG, G-onstantG, G-ustom;ttributeG,
G8ieldMarshalG, G<ecl3ecurityG, G-lass?ayoutG, G8ield?ayoutG,
G3tand;lone3igG , G>ventMapG,G>vent,trG, G>ventG, G,ropertyMapG,
G,roperty,trG,
G,ropertiesG,GMethod3emanticsG,GMethod0mplG,GModule9efG,GType3pecG,G0mpl
MapG,G8ield9:;G,G>/-?ogG,G>/-MapG,G;ssemblyG,G;ssembly,rocessorG,G;sse
mblyO3G,G;ssembly9efG,G;ssembly9ef,rocessorG,G;ssembly9efO3G,G8ileG,G>xp
ortedTypeG,GManifest9esourceG,G/ested-lassG,GTypeTy,arG,GMethodTy,arG(4
long valid 4
byte 56 metadata4
bool debug = true4
int tableofset 4
int ofsetstring = B4
int ofsetblob = B4
int ofsetguid = B4
byte 56 blob4
byte 56 us4
byte 56 guid4
string 56 streamnames4
byte 56 strings4
int 56 ssi$e 4
int 56 ofset4
byte 5656 names4
long startofmetadata4

public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
(
public void 9ead3treams<ata&'
%
startofmetadata = -onvert9:;&metadatarva'4
if & debug '
-onsole.#rite?ine&G3tart of Metadata %"( rva=%2(G , metadatarva ,
startofmetadata '4
mlestream.,osition = startofmetadata 4
mlestream.3eek&C D B D B D C , 3eekOrigin.-urrent'4
int lengthofstring = mbinaryreader.9ead0ntAB&'4
if & debug '
-onsole.#rite?ine&G?ength of 3tring %"(G , lengthofstring '4
mlestream.3eek&lengthofstring , 3eekOrigin.-urrent'4
244260235.doc 25 od 541
long padding = mlestream.,osition [ C 4
if & debug '
-onsole.#rite?ine&G,adding %"(G , padding '4
mlestream.3eek&B , 3eekOrigin.-urrent'4
int streams = mbinaryreader.9ead0nt2@&'4
if & debug '
-onsole.#rite?ine&G/o of streams %"( ,osition=%2(G , streams ,
mlestream.,osition'4
streamnames = new string5!64
ofset = new int5!64
ssi$e = new int5!64
names = new byte5!6564
names5"6 = new byte52"64
names526 = new byte52"64
names5B6 = new byte52"64
names5A6 = new byte52"64
names5C6 = new byte52"64
int j 4
for & int i = " 4 i F streams 4 iDD'
%
if &debug'
-onsole.#rite?ine&G;t 3tart ,osition=%"( %2(G , mlestream.,osition ,
mlestream.,osition [ C'4
ofset5i6 = mbinaryreader.9ead0ntAB&'4
ssi$e5i6 = mbinaryreader.9ead0ntAB&'4
if &debug'
-onsole.#rite?ine&Gofset=%"( si$e=%2( ,osition=%B(G , ofset5i6 , ssi$e5i6 ,
mlestream.,osition'4
j = "4
byte bb 4
while & true '
%
bb = mbinaryreader.9ead7yte&'4
if & bb == "'
break4
names5i65j6 = bb4
jDD4
(
names5i65j6 = bb4
streamnames5i6 = Met3tream/ames &names5i6'4

*V
To entertain the processor, we have to now write extra code. ;s the stream
names vary in si$e, we have to skip bytes until we reach a four byte
boundary. The best way to do it is check the value of the ,osition property. 0f
it is divisible by C, then break out of the loop.
V*
while & true '
%
if & mlestream.,osition [ C == " '
244260235.doc 26 od 541
break4
byte b = mbinaryreader.9ead7yte&'4
(
if &debug'
-onsole.#rite?ine&G;t >nd ,osition=%"( %2(G , mlestream.,osition ,
mlestream.,osition [ C'4
(
for & int i = " 4 i F streams 4 iDD'
%
if & streamnames5i6 == G.\G ]] streamnames5i6 == G.JG '
%
metadata = new byte5ssi$e5i664
mlestream.3eek&startofmetadata D ofset5i6 , 3eekOrigin.7egin'4
for & int k = " 4 k F ssi$e5i6 4 k DD'
metadata5k6 = mbinaryreader.9ead7yte&'4
(
if & streamnames5i6 == G.3tringsG '
%
strings = new byte5ssi$e5i664
mlestream.3eek&startofmetadata D ofset5i6 , 3eekOrigin.7egin'4
for & int k = " 4 k F ssi$e5i6 4 k DD'
strings5k6 = mbinaryreader.9ead7yte&'4
(
if & streamnames5i6 == G.Q3G '
%
us = new byte5ssi$e5i664
mlestream.3eek&startofmetadata D ofset5i6 , 3eekOrigin.7egin'4
for & int k = " 4 k F ssi$e5i6 4 k DD'
us5k6 = mbinaryreader.9ead7yte&'4
(
if & streamnames5i6 == G.MQ0<G '
%
guid = new byte5ssi$e5i664
mlestream.3eek&startofmetadata D ofset5i6 , 3eekOrigin.7egin'4
for & int k = " 4 k F ssi$e5i6 4 k DD'
guid5k6 = mbinaryreader.9ead7yte&'4
(
if & streamnames5i6 == G.7lobG '
%
blob = new byte5ssi$e5i664
mlestream.3eek&startofmetadata D ofset5i6 , 3eekOrigin.7egin'4
for & int k = " 4 k F ssi$e5i6 4 k DD'
blob5k6 = mbinaryreader.9ead7yte&'4
(
(
if & debug '
%
for & int i = " 4 i F streams 4 iDD'
%
244260235.doc 27 od 541
-onsole.#rite?ine&G%"( ofset %2( si$e %B(G , streamnames5i6 , ofset5i6 ,
ssi$e5i6'4
if & streamnames5i6 == G.\G ]] streamnames5i6 == G.JG '
%
for & int ii = " 4 ii F= I 4 iiDD'
-onsole.#rite&G%"( G , metadata5ii6.To3tring&GWG''4
-onsole.#rite?ine&'4
(
if & streamnames5i6 == G.3tringsG'
%
for & int ii = " 4 ii F= I 4 iiDD'
-onsole.#rite&G%"( G , strings5ii6.To3tring&GWG''4
-onsole.#rite?ine&'4
(
if & streamnames5i6 == G.Q3G'
%
for & int ii = " 4 ii F= I 4 iiDD'
-onsole.#rite&G%"( G , us5ii6.To3tring&GWG''4
-onsole.#rite?ine&'4
(
if & streamnames5i6 == G.MQ0<G'
%
for & int ii = " 4 ii F= I 4 iiDD'
-onsole.#rite&G%"( G , guid5ii6.To3tring&GWG''4
-onsole.#rite?ine&'4
(
if & streamnames5i6 == G.7lobG'
%
for & int ii = " 4 ii F= I 4 iiDD'
-onsole.#rite&G%"( G , blob5ii6.To3tring&GWG''4
-onsole.#rite?ine&'4
(
(
(
int heapsi$es = metadata5@64
if & &heapsi$es X "x"2' == "x"2'
ofsetstring = C4
if & &heapsi$es X "x"B' == "x"B'
ofsetguid = C4
if & &heapsi$es X "x"C' == "x"C'
ofsetblob = C4
valid = 7it-onverter.To0nt@C &metadata, H'4
tableofset = BC4
rows = new int5@C64
;rray.-lear &rows, ", rows.?ength'4
for & int k = " 4 k F= @A 4 kDD'
%
int tablepresent = &int'&valid )) k ' X 24
if & tablepresent == 2'
%
244260235.doc 28 od 541
rows5k6 = 7it-onverter.To0ntAB&metadata , tableofset'4
tableofset D= C4
(
(
if & debug '
%
for & int k = @B 4 k )= " 4 kJJ'
%
int tablepresent = &int'&valid )) k ' X 24
if & tablepresent == 2'
%
-onsole.#rite?ine&G%"( %2(G , tablenames5k6 , rows5k6'4
(
(
(
(
public string Met3tream/ames&byte 56 b'
%
int i = "4
while &b5i6 ^= " '
%
iDD4
(
3ystem.Text.>ncoding e = 3ystem.Text.>ncoding.QT8H4
string dummy = e.Met3tring&b , " , i '4
return dummy4
(
(

Output
3tart of Metadata HA"H rva=@BH
?ength of 3tring 2B
,adding "
/o of streams C ,osition=@@"
;t 3tart ,osition=@@" "
ofset=I@ si$e=2I@ ,osition=@@H
;t >nd ,osition=@LB "
;t 3tart ,osition=@LB "
ofset=BIB si$e=I@ ,osition=@H"
;t >nd ,osition=@IB "
;t 3tart ,osition=@IB "
ofset=AHH si$e=2@ ,osition=L""
;t >nd ,osition=L"H "
;t 3tart ,osition=L"H "
ofset=C"C si$e=AB ,osition=L2@
;t >nd ,osition=LBC "
.\ ofset I@ si$e 2I@
" " " " 2 " " 2 CL 2C
.3trings ofset BIB si$e I@
" A- C< @8 @C L! @- @! A> "
244260235.doc 29 od 541
.MQ0< ofset AHH si$e 2@
@8 >I !@ <- CI -A 82 C> ;@ I
.7lob ofset C"C si$e AB
" H 7L L; !- !@ 2I AC >" HI
;ssembly9ef 2
;ssembly 2
-ustom;ttribute 2
Member9ef B
Method B
Type<ef B
Type9ef B
Module 2

#e start as before by creating a series of instance variables and calling a
function called 9ead3treams<ata. This function is the one that delves into the
innards of the ./et world. The -?0 header has member that holds the starting
position or the 9:; of the metadata. The -onvert9:; method positions the
le pointer to this start of metadata on the disk.
Meta<ata is the crux of ./et world. #e will come to a formal denition in
some time.

The variable startofmetadata is used in the program at a later stage to
position at the start of this structure. The point to be noted here is that most
ofsets in the ./et world are relative to the metadata root since the internal
./et structures commence at this point.

The value stored in variable metadatarva may*may not be displayed since
the ildasm utility does not display its value unless it is executed in debug
mode. Therefore the variable is enclosed in an if statement, which will be
displayed only when the value of the variable debug is set to true. The
#rite?ine function dutifully displays the value stored in the variable.

Thus, all output that ildasm does not display, but is re1uired for debugging
purposes is placed within an if statement. The if statement checks on the
value of the debug variable to display these statements. The data following
the starting position of metadata can be easily placed in a structure. 0t begins
with a magic number which can be referred to as a signature, vi$,
"xCBC;!ACB or 7U37.

The team that developed the ./et internals comprised of four of the most
brilliant individuals who ever worked at Microsoft. This will be proved only
after you have nished reading this book. 7U37 are the initials of the four
heroes who designed the internals of the ./et world.

8ollowing the signature is the Major version number, 2 and then the minor
verison number, ". These two elds are of short type and can be easily
ignored while scrutini$ing the internals. The next four bytes are reserved and
will always have a value of $ero. Thus, the next step is to skip these 2B bytes
from the start, as the four elds are irrelevant. The 3eek function comes
244260235.doc 30 od 541
handy, with the second parameter as 2B followed by the enum -urrent &not
7egin'.

The fth eld is the length of an ;3-00 or QT8H string which is due to follow.
This string represents the version number, vi$ v2.".AABH of the ./et
8ramework installed on the machine. This number can be further veried with
the output displayed by the -. compiler, csc but with no options. The length
of the string is 2B bytes.

The 3eek function is used to proceed further, with the variable lengthofstring
as the rst parameter since it holds the lengh of the string.

; ABJbit processor works best when elds begin at a CJbyte boundary. 0t is for
this reason that the next eld starts at a location divisible by C.
The mod operator [ is implemented to discern the padding length,
whereupon the bytes are eventually skipped within the le. /evertheless, the
length of the version string is completely divisible by C, therefore the padding
is $ero, thus leaving no bytes for the padding. ;n additional seek function too
could have served in skipping the padding bytes too.

The padding is followed by the Eags eld, which is a short and for the
moment reserved and has a value of ".

;ll ./et entities stored on disk are in form of streams. 0t is the second last
eld that unravels the total count of streams in the le. The topnotch number
is ve, but in our le, it is one less i.e. C.

Thereafter comes the the 3tream Keader, one for each stream present in the
le. >ven though there are C streams in the le, just to be a lot careful, a
maximum of ve streams are considered while writing the program, thus an
array of ve strings called streamnames is created.

The stream headers also gives the si$e and ofset of each stream in the le.
Therefore, int arrays of ofset and ssi$e have been introduced to store these
values. The names of the streams are stored in the stream header as a series
of bytes. Thus while read these bytes in memory, a two dimensional array of
bytes called names has been introduced.

The bigger dimension is ve large as in all there are ve streams, which the
new accomplishes. Then each of these ve byte arrays are given a si$e. 3ince
the name of each stream does not exceed 2" characters, the individual
arrays names5"6 onwards are initiali$ed to an array 2" large.

#hile reading each stream header, the #rite?ine function is used which gives
details on the position in the le. 0n the next program, the debug variable will
be set to false as the output is not in sync with that of ildasm as mentioned
before.

The stream headers gives three bits of data. 0t starts with two intPs that give
us an ofset from the start of the metadata root where the data for this
244260235.doc 31 od 541
streams begins. The second int is the si$e of the stream in bytes, always a
multiple of C. ;s mentioned earlier, a location divisible by C is the most
preferred option. ?astly, the nal eld is the name of the stream, always null
terminated.

8or reasons such as, the stream name is diferent thus it varies, the stream
header is not xed in si$e. >ven then, the next stream header will begin at a
C byte boundary. ;fter storing the ofset and si$e in an array, an innite while
loop is placed to read the name of the stream stored in bytes into the array
called names.

The variable i i.e. the loop variable decides the outer array dimension and the
variable j the inner dimension. 0f the byte read is $ero, we exit of the string,
thus terminating the loop. ; null character is added to the names array
thereafter, and hence the last array member is initiali$ed to the value of bb, a
null.


The function Met3tream/ames that comes next converts a byte array ending
with a null to a string. The job of this function is to scan through the byte
array until it reaches the terminating null and increment the variable i. Thus
at the end of the loop, variable i stores the number of bytes that make up the
steam name minus the null.

The Met3tring function then, given a byte array and a starting point and
length, converts the byte array into a string. The string is stored in a variable
called dummy, which is then returned and stored in the array streamnames.
Thus, the stream names as well as their ofsets and si$es are now stored
together in the array. The next hurdle is reading from a disk, which is a very
slow process. Thus it is not a good idea to read the entire stream data into
array.

The for loop is brought in again but now with the if statements that check the
names of the streams. 0f the stream has a certain name, say .\, then an
array called metadata is created with the length e1uivalent to the value held
in corresponding ssi$e array member. The corresponding ofset member is
then used to jump to the start of the data for the .\ named stream. <o take
into account that the ofset is relative to the start of the metadata root,
whose value is stored in the variable startofmetadata. Thereafter using a
simple for loop and the 9ead7yte function the entire stream contents are
read, one byte at a time.

0n a similar fashion, if the name of the stream is .3trings, the contents are
read in the strings array. 3o also, if it is .Q3, then us array is used and for
.Muid, the guid array. 8inally the .7lob stream is also stored into the blob
array.

0n this manner, the contents of the entire stream are read into corresponding
arrays, thus avoiding disk accesses completely.

244260235.doc 32 od 541
To verify our acts, the debug variable can be put to use which will display the
rst 2" bytes of the ve streams using the arrays that have been just lled.
The si$e and the ofset of each stream is also displayed.

0gnoring the initial bytes for the time being, we directly jump to the L byte of
the metadata stream, or the stream called .\. The L
th
byte is examined
bitwise, where the 2
st
, B
nd
and C
th
bit of the byte are examined. 0f it is on, i.e.
2, the variable ofsetstring or ofsetguid or ofsetblob is set to C from its
predetermined value of B.

The 1uestion like what do these variables do will be explain in just a second.
The stream called .3trings is made up of all the strings entered in the
program. 7ut, these strings are not the text strings which are given as
parameters to functions like #rite?ine. 8or the text based strings, there is a
separate stream called .Q3.

/ames like 3ystem, -onsole, #rite?ine etc used in the program need to be
stored in some location. This location is the stream called .3trings.

Thus the .3trings stream is a series of null terminated strings, wherein each
string begins at a certain or xed ofset from the onset of the stream. The
word 3ystem will be replaced with an ofset from the start of the streams
data. Kowever, the 1uestion that now arises is whether this ofset should be
taken as B bytes or C bytes.

This matters a lot from the viewpoint of eSciency since a namespace name
like 3ystem which is referred to around 2""" times in a program, may get
completely misaligned. ; wrong byte choice could lose large number bytes.

The designers considered the alternative of B bytes and C because in B bytes
a stream larger than @Ck large could not be accommodated. ;lso a defult use
of C bytes could lead to immense wastage when the si$e is small. 8or this
reason, the @
th
bit is made extremely signicate since it states the stream
si$e.. 0f the bit is on, the stream is larger than @Ck and hence the variable is
set to C from the default value of B. #e could have also use the si$e array to
gure out the byte si$e, but reserving a bit for it is a more elegant option. 0t is
only the streams of .3tring, .Muid and .7lob that have a si$e. The string
.Qs is restricted to a si$e of @Ck whereas the most important stream .\ has
no such restriction as it is not referred to, on the contrary, the .\ refers to
the other streams.

The next task, to read the H bytes that are stored from the @
th
array position
is performed by using the static function To0nt@C from the class 7it-onverter.
This function read bytes from a byte array and converts them into a short or a
int or a long. The rst parameter is the name of the array, just to jog your
memory, in case you have forgotten, the entire stream .\ has been read
into the metadata array earlier. The second parameter is an ofset into the
array. ;s a result, the variable valid now gives the long stored at the H
th
byte
position. The variable tableofset is set to BC and then an array rows that is of
si$e @C is created.
244260235.doc 33 od 541

0t is a good idea to initiali$e everything including the variables newly create,
therefore the -lear static function of the array class is used which sets all the
@C members passed in the third parameter to a value ", the value passed as
the second parameter. This is however not mandatory as instance variables
get initiali$ed to $ero, but why take chances. #hat if the programmer writing
the above code was sleeping at the wheel.

?ets us now look at the concept of metadata that we have been threatening
to unfold for a very long time.

?ets take a simple class having three methods. The names of the three
methods as well as the name of the class have to be stored somewhere. This
somewhere is called a table as there will be multiple occurrences of the
above entities. The guys who designed the ./et world assumed that the
maximum number of such table will be @C and thus they gave each table a
number.

8or eg, the Table " keeps track of all the modules the userJwritten program
contains. ;lso, each .net image comprises of one and only one module. Table
2 is for the types referred to in the program and Table B is for all the userJ
created types.

The re1uirement of the ./et framwork was to enclose an eScient way of
representing the tables present in the current image and storing their
information. ; long datatype was considered most suitable as it is
represented as @C bits wheren each bit would signify whether a certain table
was present or not. Thus if bit " is set, it implied that the Module table is
present, whereas when " then it is missing . 0n a similar manner, a userJ
dened type is createad in the program, bit B of the long will be initiali$ed or
set. This approach thus is a highly eScient and elegant way of keeping track
of whether @C entities are present or not.

The next H bytes are a eld called sorted which has not been used followed
by a a series of intPs that state the number of records present in each present
table.

Thus if bytes ",B and A are on, the rst int tells starting from byte BC tells us
the number of records of table ", the next int the number of records in table B
as table one has its bit of and thus no present. The next int will tell us the
number of records of table A and so on. ?ets convert this into code and ll up
the rows array with the number of rows that each table has.

9emember the rows array has been initiali$ed to $ero. #e start with a loop
where the variable k doubles up as the loop variable as well as table number.
#e rst need to know whether the table has the bit set or not. #e right shift
the valid member by k thus throwing of all the earlier bits and also making
the k th bit the rst bit.

244260235.doc 34 od 541
#e bit wise and with 2 and thus tablepresent is either " or 2. Thus to take a
concrete example, if the we want to know the status of the 2" table, we right
shift all the bits by 2". This ensures that the rst bit is what used to be the
2"
th
. #e then bit wise and with 2, $eroing out all the bits but the rst.

0f the answer is one, this means that the table is present, we read the int
stored from tableofset that is given a value of BC as this is where the number
of rows begin. #e are using the function To0ntAB to read an int. The
corresponding rows array member is set to the number of rows in the table as
the variable is the table number.

#e then increase the tableofset by C as the si$e of an int is C and we need
tableofset to point to the next int that stands for the rows of the next present
table. ?ets us now look at the concept of metadata that we have been
threatening to do for a very long time. ?ets take a simple class with three
methods.

#e would need to store the names of the three methods someone as well as
the name of the class. This somewhere is called a table as there will be
multiple occurrences of the above entities. The guys who designed the ./et
world assumed that the maximum number of such table will be @C and they
gave each table a number.

Thus table " keeps track of all the modules our program contains and each
.net image is comprised of one and only one module. Table 2 is all the types
we refer to and table B all the types we create ourselves. /ow the ./et world
wanted a eScient way of representing which tables are present in the current
image.

They needed a eScient way of storing this information. ; long has @C bits
and thus each bit tells us whether a certain table is present or not. Thus if bit
" is set, this means that the Module table is present, if " then it is not.

3imilarly if we have created a type in our program, bit B will be set. This is a
highly eScient and elegant way of keeping track of whether @C entities are
present or not. The next H bytes are a eld called sorted which we do not use
and then we have a series of intPs that tell us the number of records present
in each present table.

Thus if bytes ",B and A are on, the rst int starting from byte BC stands for
the number of records of table ", the next int stands for the number of
records in table B since table one has its bit of thus having no records. The
next int holds the number of records for table A and so on.

JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJVJVJVJ
?ets convert this into code and ll up the rows array with the number of rows
that each table has. 9emember the rows array has been initiali$ed to $ero.
#e start with a loop where the variable k doubles up as the loop variable as
well as table number. #e rst need to know whether the table has the bit set
or not.
244260235.doc 35 od 541

#e right shift the valid member by k thus throwing of all the earlier bits and
also making the k th bit the rst bit. #e bit wise and with 2 and thus
tablepresent is either " or 2. Thus to take a concrete example, if the we want
to know the status of the 2" table, we right shift all the bits by 2".

This ensures that the rst bit is what used to be the 2"
th
. #e then bit wise
and with 2, $eroing out all the bits but the rst. 0f the answer is one, this
means that the table is present, we read the int stored from tableofset that is
given a value of BC as this is where the number of rows begin.

#e are using the function To0ntAB to read an int. The corresponding rows
array member is set to the number of rows in the table as the variable is the
table number. #e then increase the tableofset by C as the si$e of an int is C
and we need tableofset to point to the next int that stands for the rows of
the next present table.

?ets now understand the concepts of metadata in greater detail. The physical
and logical representation of metadata is the same. 3ome elds that can be
ignored while reading. >verything that represents metadata is stored in
streams. The .3trings stream stores identier strings and is also called the
string heap.

The .7lob heap is the most complex of them all as function signatures are
stored here in a extremely compressed form. The best way to get a headache
is to understand the 7lob string. The reason why it is called a blob is because
it has no structure at all and every byte stands by itself.

The other streams have a form and structure. The other important stream is
the .\ as this is what contains the actual metadata or physical tables. The
documentation tells us very clearly that some compilers do not call the
stream .\ but .J. This is a uncompressed, non optimi$ed representation of
the metadata tables.

0t also uses some extra tables to store pointer values. #e will not go into
details other than tell you the good news, this stream is not part of the >-M;
standard. The documentation is very clear that the streams will appear only
once and we cannot have two .7lob streams for example.

;ll the streams do have to be present but normally they are. 0n our case we
have no strings passed as parameters and hence the .Q3 stream is not
there. #e have not come across a single .net executable that did not have at
least four streams at the bare minimum.

The .3trings stream contains a series of null terminated strings that are
accessed from the .\ stream. The rst entry is always ". The .3trings
stream may contain garbage but those ofsets are not addressable from
tables. Those that are accessible are always valid null terminated ;3-00 or
QT8H strings.

244260235.doc 36 od 541
The rst byte of the blob heap is always a si$e byte that tells us how many
bytes follow. This is not strictly true as otherwise the si$e of the blob data
would always be less than B!! bytes. Thus data in the blob heap is
compressed including the si$e byte. ;ll this will be explained later on in the
book.

This is re1uired as the blob heap has no null marker. The rst entry is again ".
The .MQ0< stream contains 2BH bit Muids which are nothing but large
numbers to uni1uely identify something like our image. The .\ stream is the
only stream that has its own structure, parts of what we have touched upon
earlier.

The rst four bytes are always " as they are reserved. The next two bytes are
the pesky version numbers of the table data schemata that will be 2 for the
major version and " for the minor version. The fourth eld is the heapsi$es
that we did earlier and the fth eld is 2 and its value is reserved.

3ome reserved elds have a value of 2 and some ", place your thinking cap
on to gure out why, we tried and failed. The next H bytes are called valid as
we explained before, followed by H bytes of a eld called sorted and then the
number of rows per table. ;fter this is the actual data for the tables.

The valid eld is called the bitvector as each bit denotes whether a table is
present or not. ;s of now there are only CA or "xBb tables dened and hence
all bits larger than these will be set to ". The actual data for the tables
depends on the structure for each table.

Thus if a certain table si$e is B" bytes and if it has B" rows, B"" bytes will be
the data for the table. Once these B"" bytes get over, the data for the next
table will start.


,rogram!.csc
int 56 si$es4

public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
8illTable3i$es&'4
(
public void 8illTable3i$es&'
%
int modulesi$e = B D ofsetstring D ofsetguid D ofsetguid D ofsetguid 4
int typerefsi$e = Met-oded0ndex3i$e &G9esolution3copeG' D ofsetstring D
ofsetstring 4
244260235.doc 37 od 541
int typedefsi$e = C D ofsetstring D ofsetstring D
Met-oded0ndex3i$e&GType<efOr9efG' D MetTable3i$e&GMethodG' D
MetTable3i$e&G8ieldG'4
int eldsi$e = B D ofsetstring D ofsetblob 4
int methodsi$e = C D B D B D ofsetstring D ofsetblob D
MetTable3i$e&G,aramG'4
int paramsi$e = B D B D ofsetstring4
int interfaceimplsi$e = MetTable3i$e&GType<efG' D
Met-oded0ndex3i$e&GType<efOr9efG'4
int memberrefsi$e = Met-oded0ndex3i$e&GMember9ef,arentG' D ofsetstring
D ofsetblob 4
int constantsi$e = B D Met-oded0ndex3i$e&GKas-onstG' D ofsetblob4
int customattributesi$e = Met-oded0ndex3i$e&GKas-ustom;ttributeG' D
Met-oded0ndex3i$e&GKas-ustom;ttributeTypeG' D ofsetblob4
int eldmarshallsi$e = Met-oded0ndex3i$e&GKas8ieldMarshalG' D ofsetblob4
int declsecuritysi$e = B D Met-oded0ndex3i$e&GKas<ecl3ecurityG' D
ofsetblob4
int classlayoutsi$e = B D C D MetTable3i$e&GType<efG'4
int eldlayoutsi$e = C D MetTable3i$e&G8ieldG'4
int stanalonssigsi$e = ofsetblob4
int eventmapsi$e = MetTable3i$e&GType<efG' D MetTable3i$e&G>ventG'4
int eventsi$e = B D ofsetstring D Met-oded0ndex3i$e&GType<efOr9efG'4
int propertymapsi$e = MetTable3i$e&G,ropertiesG' D MetTable3i$e&GType<efG' 4
int propertysi$e = B D ofsetstring D ofsetblob4
int methodsemantics = B D MetTable3i$e&GMethodG' D
Met-oded0ndex3i$e&GKas3emanticsG'4
int methodimplsi$e = MetTable3i$e&GType<efG' D
Met-oded0ndex3i$e&GMethod<efOr9efG' D
Met-oded0ndex3i$e&GMethod<efOr9efG'4
int modulerefsi$e = ofsetstring4
int typespecsi$e = ofsetblob4
int implmapsi$e = B D Met-oded0ndex3i$e&GMember8orwardedG' D
ofsetstring D MetTable3i$e&GModule9efG'4
int eldrvasi$e = C D MetTable3i$e&G8ieldG'4
int assemblysi$e = C D B D B D B D B D C D ofsetblob D ofsetstring D
ofsetstring 4
int assemblyrefsi$e = B D B D B D B D C D ofsetblob D ofsetstring D
ofsetstring D ofsetblob4
int lesi$e = C D ofsetstring D ofsetblob4
int exportedtype = C D C D ofsetstring D ofsetstring D
Met-oded0ndex3i$e&G0mplementationG'4
int manifestresourcesi$e = C D C D ofsetstring D
Met-oded0ndex3i$e&G0mplementationG'4
int nestedclasssi$e = MetTable3i$e&GType<efG' D MetTable3i$e&GType<efG' 4
si$es = new int56% modulesi$e, typerefsi$e , typedefsi$e ,B, eldsi$e ,
B,methodsi$e ,B,paramsi$e ,interfaceimplsi$e,memberrefsi$e ,constantsi$e
,customattributesi$e ,eldmarshallsi$e ,declsecuritysi$e ,classlayoutsi$e
,eldlayoutsi$e,stanalonssigsi$e ,eventmapsi$e ,B,eventsi$e ,propertymapsi$e
,B,propertysi$e ,methodsemantics ,methodimplsi$e ,modulerefsi$e
,typespecsi$e ,implmapsi$e ,eldrvasi$e ,B , B , assemblysi$e ,
244260235.doc 38 od 541
C,2B,assemblyrefsi$e ,@,2C,lesi$e ,exportedtype ,manifestresourcesi$e
,nestedclasssi$e (4
(
public int Met-oded0ndex3i$e&string nameoftable'
%
if & nameoftable == G0mplementationG'
%
if & rows5"xB@6 )= 2@AHC ]] rows5"xBA6 )= 2@AHC ]] rows5"xBL6 )= 2@AHC '
return C4
else
return B4
(
else if & nameoftable == GMember8orwardedG'
%
if & rows5"x"C6 )= ABL@H ]] rows5"x"@6 )= ABL@H'
return C4
else
return B4
(
else if & nameoftable == GMethod<efOr9efG'
%
if & rows5"x"@6 )= ABL@H ]] rows5"x";6 )= ABL@H'
return C4
else
return B4
(
else if & nameoftable == GKas3emanticsG'
%
if & rows5"x2C6 )= ABL@H ]] rows5"x2L6 )= ABL@H'
return C4
else
return B4
(
else if & nameoftable == GKas<ecl3ecurityG'
%
if & rows5"x"B6 )= 2@AHC ]] rows5"x"@6 )= 2@AHC ]] rows5"xB"6 )= 2@AHC'
return C4
else
return B4
(
else if & nameoftable == GKas8ieldMarshalG'
%
if & rows5"x"C6 )= ABL@H]] rows5"x"H6 )= ABL@H'
return C4
else
return B4
(
else if & nameoftable == GType<efOr9efG'
%
244260235.doc 39 od 541
if & rows5"x"B6 )= 2@AHC ]] rows5"x"26 )= 2@AHC ]] rows5"x276 )=
2@AHC '
return C4
else
return B4
(
else if & nameoftable == G9esolution3copeG'
%
if & rows5"x""6 )= 2@AHC ]] rows5"x2a6 )= 2@AHC ]] rows5"xBA6 )= 2@AHC ]]
rows5"x"26 )= 2@AHC '
return C4
else
return B4
(
else if & nameoftable == GKas-onstG'
%
if & rows5C6 )= 2@AHC ]] rows5H6 )= 2@AHC ]] rows5"x2L6 )= 2@AHC '
return C4
else
return B4
(
else if & nameoftable == GMember9ef,arentG'
%
if & rows5"x"H6 )= H2IB ]] rows5"x"C6 )= H2IB ]] rows5"x2L6 )= H2IB '
return C4
else
return B4
(
else if & nameoftable == GKas-ustom;ttributeG'
%
if & rows5"x"@6 )= B"CH ]] rows5"x"C6 )= B"CH ]] rows5"x"26 )= B"CH ]]
rows5"x"B6 )= B"CH ]] rows5"x"H6 )= B"CH ]] rows5"x"I6 )= B"CH ]]
rows5"x"a6 )= B"CH ]] rows5"x""6 )= B"CH ]] rows5"x"e6 )= B"CH ]]
rows5"x2L6 )= B"CH ]] rows5"x2C6 )= B"CH ]] rows5"x226 )= B"CH ]]
rows5"x2a6 )= B"CH ]] rows5"x2b6 )= B"CH ]] rows5"xB"6 )= B"CH ]]
rows5"xBA6 )= B"CH ]] rows5"xB@6 )= B"CH ]] rows5"xBL6 )= B"CH ]]
rows5"xBH6 )= B"CH '
return C4
else
return B4
(
else if & nameoftable == GKas-ustom;ttributeTypeG'
%
if & rows5B6 )= H2IB ]] rows526 )= H2IB ]] rows5@6 )= H2IB ]] rows5"x"a6 )=
H2IB '
return C4
else
return B4
(
else
244260235.doc 40 od 541
return B4
(
public int MetTable3i$e&string tablename'
%
int ii4
for & ii = " 4 ii F tablenames.?ength 4 iiDD'
%
if & tablename == tablenames5ii6 '
break4
(
if & rows5ii6 )=@!!A!'
return C4
else
return B4
(
(

The above example is one of the most diScult examples to understand and
you may want to read the explanation n number of times where n can at
times exceed innity. Or better still, skip this program and read the next one
and then maybe come back to it once again. #e have only created one array
of ints called si$es.

The abc function has one more function call 8illTable3i$es. ;ll that we have
done in this function is initiali$e variables like modulesi$e, typerefsi$e etc and
while creating the array si$es, used these variables to initiali$e the array
called si$es.

Thus the $eroth member of the si$es array is lled up by the modulesi$e
variable, the rst member by typerefsi$e etc. 0f you remember the module
table is known by a number ", the typeref table by number 2 and so on. The
problem is that the metadata documentation does not tell us the si$e of any
table.

0f we do not know the si$e of a table, how do we read the metadata present in
the .\ stream. The only reason that the docs do not specify the si$e of a
table is for reasons of eSciency. The si$e of the data decides the si$e of the
table.

3maller the table si$e, lesser the space it occupies and the faster the speed
to access data associated with the table. ?ets look at the module table and
gure out its si$e. The rst eld is called the Meneration and is reserved and
is always B bytes.

#e will come across lots of elds like the one above that have a xed si$e
come heaven or hell. The second eld of the module table is the name of the
module that is an ofset into the strings stream. This is where we have a
problem as the specications cannot tell us whether the index should be B or
C bytes long.

244260235.doc 41 od 541
This is decided by the si$e of the stream .3trings. This is where we use our
variable ofsetstring to gure out whether the si$e is B or C bytes. 0n the same
vein, the next two elds are an ofset into the guid stream and therefore we
use the ofsetguid variable.

Thus the value of the variable modulesi$e cannot be gured out in advance
and it depends upon the si$es of the two streams 3trings and Muid. This is
how we dynamically determine the si$e of each table and place that value in
the si$es array. The second table Type9ef creates a bigger problem.

Thus lets skip that for a moment and move on to the third table Type<ef. The
last eld of this table is an ofset into the 8ield table. #e cannot assume a
si$e of B for this eld as then we are restricting the eld table to @!!A@
records.

Thus we use a function called MetTable3i$e to gure out whether the index
should be B or C bytes. #e rst need to convert the table name into its
number and we scan through the tablenames array and break out when we
meet a match. ;t this time the variable ii is the table number.

#e then check the corresponding member of the rows array which if you
remember contains the number of rows present in each table. 0f the rows
member is greater than @!!A! we return C, else we return B. /ormally tables
do not have so many records and we could get away with assuming a index
si$e of B.

?ets look at the fourth eld of the Type<ef table. This is also an ofset into a
table, but with a slight twist. The ofset can be to on of three tables, Type<ef,
Type9ef or Type3pec. This is a very common construct in the metadata world
where a eld can refer to one of many tables and it is called a coded index.

Thus we leave B bits to store the table that it belongs to. 0n this specic case
a value of the rst two bits being " makes the remaining 2C bits point to the a
record in the Type<ef table, 2 signies the Type9ef table and B, the Type3pec
table. #e can codify C tables within B bits.

Thus we have as mentioned before, 2C bits to store the record number. Thus
if any of the three tables has a record count larger than 2@AHC, then the si$e
of the eld is C bytes. The key point is any of the three tables has a row count
larger than 2@AHC.

Two of the three tables may have " rows, but as one of them is larger than
2@AHC, the index si$e is C. There are a do$en such coded indexes and the
function Met-oded0ndex3i$e rst checks the name of the coded index passed
as a parameter.

0t then checks if any of the tables exceed the number of rows that is decided
by the number of bits used to code the tables. This function nally returns B
or C. Thus at the end of the day all that we do is simply initiali$e the si$es
array with the actual lengths of each table.
244260235.doc 42 od 541

,rogram@.csc
public struct 8ield,trTable
%
public int index4
(
public struct Method,trTable
%
public int index4
(
public struct >xportedTypeTable
%
public int Eags 4
public int typedendex 4
public int name 4
public int nspace 4
public int coded 4
(
public struct /ested-lassTable
%
public int nestedclass4
public int enclosingclass4
(
public struct Method0mpTable
%
public int classindex4
public int codedbody4
public int codeddef4
(
public struct -lass?ayoutTable
%
public short packingsi$e 4
public int classsi$e 4
public int parent 4
(
public struct Manifest9esourceTable
%
public int ofset4
public int Eags4
public int name4
public int coded4
(
public struct Module9efTable
%
public int name4
(
public struct 8ileTable
%
public int Eags4
public int name4
244260235.doc 43 od 541
public int index4
(
public struct >ventTable
%
public short attr4
public int name4
public int coded4
(
public struct >ventMapTable
%
public int index4
public int eindex4
(
public struct Method3emanticsTable
%
public short methodsemanticsattributes4
public int methodindex4
public int association4
(
public struct ,ropertyMapTable
%
public int parent4
public int propertylist4
(
public struct ,ropertyTable
%
public int Eags4
public int name4
public int type4
(
public struct -onstantsTable
%
public short dtype4
public int parent4
public int value 4
(
public struct 8ield?ayoutTable
%
public int ofset4
public int eldindex4
(
public struct 8ield9:;Table
%
public int rva 4
public int eldi4
(
public struct 8ieldMarshalTable
%
public int coded4
public int index4
244260235.doc 44 od 541
(
public struct 8ieldTable
%
public int Eags4
public int name4
public int sig4
(
public struct ,aramTable
%
public short pattr4
public int se1uence4
public int name4
(
public struct Type3pecTable
%
public int signature4
(
public struct Member9efTable
%
public int clas4
public int name4
public int sig4
(
public struct 3tand;lone3igTable
%
public int index4
(
public struct 0nterface0mplTable
%
public int classindex4
public int interfaceindex4
(
public struct Type<efTable
%
public int Eags4
public int name4
public int nspace4
public int cindex4
public int ndex4
public int mindex4
(
public struct -ustom;ttributeTable
%
public int parent4
public int type4
public int value4
(
public struct ;ssembly9efTable
%
public short major,minor,build,revision4
244260235.doc 45 od 541
public int Eags 4
public int publickey 4
public int name 4
public int culture 4
public int hashvalue 4
(
public struct ;ssemblyTable
%
public int Kash;lg0d4
public int major, minor,build,revision 4
public int Eags 4
public int publickey 4
public int name 4
public int culture 4
(
public struct ModuleTable
%
public int Meneration4
public int /ame4
public int Mvid4
public int >nc0d4
public int >nc7ase0d4
(
public struct Type9efTable
%
public int resolutionscope4
public int name4
public int nspace4
(
public struct MethodTable
%
public int rva4
public int impEags4
public int Eags4
public int name4
public int signature4
public int param4
(
public struct <ecl3ecurityTable
%
public int action4
public int coded4
public int bindex4
(
public struct 0mplMapTable
%
public short attr4
public int cindex4
public int name4
public int scope4
244260235.doc 46 od 541
(

public ;ssemblyTable 56 ;ssembly3truct4
public ;ssembly9efTable 56 ;ssembly9ef3truct 4
public -ustom;ttributeTable 56 -ustom;ttribute3truct4
public ModuleTable56 Module3truct4
public Type<efTable 56 Type<ef3truct4
public Type9efTable 56 Type9ef3truct4
public 0nterface0mplTable 56 0nterface0mpl3truct4
public 8ield,trTable 56 8ield,tr3truct4
public Method,trTable 56 Method,tr3truct4
public MethodTable 56 Method3truct4
public 3tand;lone3igTable 56 3tand;lone3ig3truct4
public Member9efTable 56 Member9ef3truct4
public Type3pecTable 56 Type3pec3truct4
public ,aramTable 56 ,aram3truct4
public 8ieldTable 56 8ield3truct4
public 8ieldMarshalTable 56 8ieldMarshal3truct4
public 8ield9:;Table 56 8ield9:;3truct4
public 8ield?ayoutTable 56 8ield?ayout3truct4
public -onstantsTable 56 -onstants3truct4
public ,ropertyMapTable 56 ,ropertyMap3truct4
public ,ropertyTable 56 ,roperty3truct4
public Method3emanticsTable 56 Method3emantics3truct4
public >ventTable 56 >vent3truct4
public >ventMapTable 56 >ventMap3truct4
public 8ileTable 56 8ile3truct4
public Module9efTable 56 Module9ef3truct4
public Manifest9esourceTable 56 Manifest9esource3truct4
public -lass?ayoutTable 56 -lass?ayout3truct4
public Method0mpTable 56 Method0mp3truct4
public /ested-lassTable 56 /ested-lass3truct4
public >xportedTypeTable 56 >xportedType3truct4
public <ecl3ecurityTable 56 <ecl3ecurity3truct4
public 0mplMapTable 56 0mplMap3truct4


public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
8illTable3i$es&'4
9eadTables0nto3tructures&'4
<isplayTables8or<ebugging&'4
(

public void 9eadTables0nto3tructures&'
244260235.doc 47 od 541
%
**Module
int old = tableofset4
bool tablehasrows = tablepresent&"'4
int ofs = tableofset4
if & debug '
-onsole.#rite?ine&GModule Table Ofset %"( 3i$e %2(G , ofs , si$es5"6'4
tableofset = old4
if & tablehasrows '
%
Module3truct = new ModuleTable5rows5"6 D 264
for & int k = 2 4 k F= rows5"6 4 kDD'
%
Module3truct5k6.Meneration = 7it-onverter.ToQ0nt2@ &metadata, ofs'4
ofs D= B4
Module3truct5k6./ame = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
Module3truct5k6.Mvid = 9eadMuid0ndex&metadata, ofs'4
ofs D= ofsetguid4
Module3truct5k6.>nc0d = 9eadMuid0ndex&metadata, ofs'4
ofs D= ofsetguid4
Module3truct5k6.>nc7ase0d = 9eadMuid0ndex&metadata, ofs'4
ofs D= ofsetguid4
(
(
**Type9ef
old = tableofset4
tablehasrows = tablepresent&2'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GType9ef Table Ofset %"( 3i$e %2(G , ofs , si$es526'4
tableofset = old4
if & tablehasrows '
%
Type9ef3truct = new Type9efTable5rows526 D 264
for & int k = 2 4 k F=rows526 4 kDD'
%
Type9ef3truct5k6.resolutionscope = 9ead-oded0ndex&metadata , ofs ,
G9esolution3copeG'4
ofs = ofs D Met-oded0ndex3i$e&G9esolution3copeG'4
Type9ef3truct5k6.name = 9ead3tring0ndex&metadata , ofs'4
ofs = ofs D ofsetstring4
Type9ef3truct5k6.nspace = 9ead3tring0ndex&metadata , ofs'4
ofs = ofs D ofsetstring4
(
(
**Type<ef
old = tableofset4
tablehasrows = tablepresent&B'4
ofs = tableofset4
244260235.doc 48 od 541
if & debug '
-onsole.#rite?ine&GType<ef Table Ofset %"( 3i$e %2(G , ofs , si$es5B6'4
tableofset = old4
if & tablehasrows '
%
Type<ef3truct = new Type<efTable5rows5B6 D 264
for & int k = 2 4 k F= rows5B6 4 kDD'
%
Type<ef3truct5k6.Eags = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
Type<ef3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
Type<ef3truct5k6.nspace = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
Type<ef3truct5k6.cindex = 9ead-oded0ndex &metadata , ofs ,
GType<efOr9efG'4
ofs D= Met-oded0ndex3i$e&GType<efOr9efG'4
Type<ef3truct5k6.ndex = 9eadTable0ndex&metadata, ofs , G8ieldG'4
ofs D= MetTable3i$e&G8ieldG'4
Type<ef3truct5k6.mindex = 9eadTable0ndex&metadata, ofs , GMethodG'4
ofs D= MetTable3i$e&GMethodG'4
(
(
**8ield,tr
old = tableofset4
tablehasrows = tablepresent&A'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G8ield,tr Table Ofset %"( 3i$e %2(G , ofs , si$es5A6'4
tableofset = old4
if & tablehasrows '
%
8ield,tr3truct = new 8ield,trTable5rows5A6 D 264
for & int k = 2 4 k F= rows5A6 4 kDD'
%
8ield,tr3truct5k6.index = 7it-onverter.To0nt2@&metadata, ofs'4
ofs D= B4
(
(
**8ield
old = tableofset4
tablehasrows = tablepresent&C'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G8ield Table Ofset %"( 3i$e %2(G , ofs , si$es5C6'4
tableofset = old4
if & tablehasrows '
%
8ield3truct = new 8ieldTable5rows5C6 D 264
for & int k = 2 4 k F= rows5C6 4 kDD'
244260235.doc 49 od 541
%
8ield3truct5k6.Eags = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
8ield3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
8ield3truct5k6.sig = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**Method,tr
old = tableofset4
tablehasrows = tablepresent&!'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GMethod Table Ofset %"( 3i$e %2(G , ofs , si$es5!6'4
tableofset = old4
if & tablehasrows '
%
Method,tr3truct = new Method,trTable5rows5!6 D 264
for & int k = 2 4 k F= rows5!6 4 kDD'
%
Method,tr3truct5k6.index = 7it-onverter.To0nt2@&metadata, ofs'4
ofs D= B4
(
(
**Method
old = tableofset4
tablehasrows = tablepresent&@'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GMethod Table Ofset %"( 3i$e %2(G , ofs , si$es5@6'4
tableofset = old4
if & tablehasrows '
%
Method3truct = new MethodTable5rows5@6 D 264
for & int k = 2 4 k F= rows5@6 4 kDD'
%
Method3truct5k6.rva = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
Method3truct5k6.impEags = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
Method3truct5k6.Eags = &int'7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
Method3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
Method3truct5k6.signature = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
Method3truct5k6.param = 9eadTable0ndex&metadata, ofs , G,aramG'4
ofs D= MetTable3i$e&G,aramG'4
(
244260235.doc 50 od 541
(
**,aram
old = tableofset4
tablehasrows = tablepresent&H'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G,aram Table Ofset %"( 3i$e %2(G , ofs , si$es5H6'4
tableofset = old4
if & tablehasrows '
%
,aram3truct = new ,aramTable5rows5H6 D 264
for & int k = 2 4 k F= rows5H6 4 kDD'
%
,aram3truct5k6.pattr = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
,aram3truct5k6.se1uence = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
,aram3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
(
(
**0nterface0mpl
old = tableofset4
tablehasrows = tablepresent&I'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G0nterface0mpl Table Ofset %"( 3i$e %2(G , ofs , si$es5I6'4
tableofset = old4
if & tablehasrows '
%
0nterface0mpl3truct = new 0nterface0mplTable5rows5I6 D 264
for & int k = 2 4 k F= rows5I6 4 kDD'
%
0nterface0mpl3truct5k6.classindex = 9ead-oded0ndex&metadata , ofs ,
GType<efOr9efG'4
ofs D= Met-oded0ndex3i$e&GType<efOr9efG'4
0nterface0mpl3truct5k6.interfaceindex = 9eadTable0ndex&metadata, ofs ,
GType<efG'4
ofs D= MetTable3i$e&GType<efG'4
(
(
**Member9ef
old = tableofset4
tablehasrows = tablepresent&2"'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GMember9ef Table Ofset %"( 3i$e %2(G , ofs, si$es52"6'4
tableofset = old4
if & tablehasrows '
%
244260235.doc 51 od 541
Member9ef3truct = new Member9efTable5rows52"6 D 264
for & int k = 2 4 k F= rows52"6 4 kDD'
%
Member9ef3truct5k6.clas = 9ead-oded0ndex&metadata , ofs ,
GMember9ef,arentG'4
ofs D= Met-oded0ndex3i$e&GMember9ef,arentG'4
Member9ef3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
Member9ef3truct5k6.sig = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**-onstants
old = tableofset4
tablehasrows = tablepresent&22'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G-onstant Table Ofset %"( 3i$e %2(G , ofs, si$es5226'4
tableofset = old4
if & tablehasrows '
%
-onstants3truct = new -onstantsTable5rows5226 D 264
for & int k = 2 4 k F= rows5226 4 kDD'
%
-onstants3truct5k6.dtype = metadata5ofs64
ofs D= B4
-onstants3truct5k6.parent = 9ead-oded0ndex&metadata , ofs , GKas-onstG'4
ofs D= Met-oded0ndex3i$e&GKas-onstG'4
-onstants3truct5k6.value = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**-ustom;ttribute
old = tableofset4
tablehasrows = tablepresent&2B'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G-ustom;ttribute Table Ofset %"( 3i$e %2(G , ofs ,
si$es52B6'4
tableofset = old4
if & tablehasrows '
%
-ustom;ttribute3truct = new -ustom;ttributeTable5rows52B6 D 264
for & int k = 2 4 k F= rows52B6 4 kDD'
%
-ustom;ttribute3truct5k6.parent = 9ead-oded0ndex&metadata , ofs ,
GKas-ustom;ttributeG'4
ofs D= Met-oded0ndex3i$e&GKas-ustom;ttributeG'4
-ustom;ttribute3truct5k6.type = 9ead-oded0ndex&metadata , ofs ,
GKas-ustom;ttributeTypeG'4
244260235.doc 52 od 541
ofs D= Met-oded0ndex3i$e&GKas-ustom;ttributeTypeG'4
-ustom;ttribute3truct5k6.value = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**8ieldMarshal
old = tableofset4
tablehasrows = tablepresent&2A'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G8ieldMarshal Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
8ieldMarshal3truct = new 8ieldMarshalTable5rows52A6 D 264
for & int k = 2 4 k F= rows52A6 4 kDD'
%
8ieldMarshal3truct5k6.coded = 9ead-oded0ndex&metadata , ofs ,
GKas8ieldMarshalG'4
ofs D= Met-oded0ndex3i$e&GKas8ieldMarshalG'4
8ieldMarshal3truct5k6.index = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**<ecl3ecurity
old = tableofset4
tablehasrows = tablepresent&2C'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G<ecl3ecurity Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
<ecl3ecurity3truct = new <ecl3ecurityTable5rows52C6 D 264
for & int k = 2 4 k F= rows52C6 4 kDD'
%
<ecl3ecurity3truct5k6.action = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
<ecl3ecurity3truct5k6.coded = 9ead-oded0ndex&metadata , ofs ,
GKas<ecl3ecurityG'4
ofs D= Met-oded0ndex3i$e&GKas<ecl3ecurityG'4
<ecl3ecurity3truct5k6.bindex = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**-lass?ayout
old = tableofset4
tablehasrows = tablepresent&2!'4
ofs = tableofset4
if & debug '
244260235.doc 53 od 541
-onsole.#rite?ine&G-lass?ayout Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
-lass?ayout3truct = new -lass?ayoutTable5rows52!6 D 264
for & int k = 2 4 k F= rows52!6 4 kDD'
%
-lass?ayout3truct5k6.packingsi$e = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
-lass?ayout3truct5k6.classsi$e = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
-lass?ayout3truct5k6.parent = 9eadTable0ndex&metadata, ofs , GType<efG'4
ofs D= MetTable3i$e&GType<efG'4
(
(
**8ield?ayout
old = tableofset4
tablehasrows = tablepresent&2@'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G8ield?ayout Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
8ield?ayout3truct = new 8ield?ayoutTable5rows52@6 D 264
for & int k = 2 4 k F= rows52@6 4 kDD'
%
8ield?ayout3truct5k6.ofset = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
8ield?ayout3truct5k6.eldindex = 9eadTable0ndex&metadata, ofs , G8ieldG'4
ofs D= MetTable3i$e&G8ieldG'4
(
(
**3tand;lone3ig
old = tableofset4
tablehasrows = tablepresent&2L'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G3tand;lone3ig Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
3tand;lone3ig3truct = new 3tand;lone3igTable5rows52L6 D 264
for & int k = 2 4 k F= rows52L6 4 kDD'
%
3tand;lone3ig3truct5k6.index = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**>ventMap
244260235.doc 54 od 541
old = tableofset 4
tablehasrows = tablepresent&2H'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G>ventMap Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
>ventMap3truct = new >ventMapTable 5rows52H6 D 264
for & int k = 2 4 k F= rows52H6 4 kDD'
%
>ventMap3truct5k6.index = 9eadTable0ndex&metadata, ofs , GType<efG'4
ofs D= MetTable3i$e&GType<efG'4
>ventMap3truct5k6.eindex = 9eadTable0ndex&metadata, ofs , G>ventG'4
ofs D= MetTable3i$e&G>ventG'4
(
(
**>vent
old = tableofset4
tablehasrows = tablepresent&B"'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G>vent Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
>vent3truct = new >ventTable5rows5B"6 D 264
for & int k = 2 4 k F= rows5B"6 4 kDD'
%
>vent3truct5k6.attr = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
>vent3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
>vent3truct5k6.coded = 9ead-oded0ndex&metadata , ofs , GType<efOr9efG'4
ofs D= Met-oded0ndex3i$e&GType<efOr9efG'4
(
(
**,ropertyMap
old = tableofset4
tablehasrows = tablepresent&B2'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G,ropertyMap Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
,ropertyMap3truct = new ,ropertyMapTable5rows5B26 D 264
for & int k = 2 4 k F= rows5B26 4 kDD'
%
,ropertyMap3truct5k6.parent = 9eadTable0ndex&metadata, ofs , GType<efG'4
244260235.doc 55 od 541
ofs D= MetTable3i$e&GType<efG'4
,ropertyMap3truct5k6.propertylist = 9eadTable0ndex&metadata, ofs ,
G,ropertiesG'4
ofs D= MetTable3i$e&G,ropertiesG'4
(
(
**,roperty
old = tableofset4
tablehasrows = tablepresent&BA'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G,roperty Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
,roperty3truct = new ,ropertyTable5rows5BA6 D 264
for & int k = 2 4 k F= rows5BA6 4 kDD'
%
,roperty3truct5k6.Eags = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
,roperty3truct5k6.name= 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
,roperty3truct5k6.type = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**Method3emantics
old = tableofset 4
tablehasrows = tablepresent&BC'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GMethod3emantics Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
Method3emantics3truct = new Method3emanticsTable5rows5BC6 D 264
for & int k = 2 4 k F= rows5BC6 4 kDD'
%
Method3emantics3truct5k6.methodsemanticsattributes =
7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
Method3emantics3truct5k6.methodindex = 9eadTable0ndex&metadata, ofs ,
GMethodG'4
ofs D= MetTable3i$e&GMethodG'4
Method3emantics3truct5k6.association = 9ead-oded0ndex&metadata , ofs ,
GKas3emanticsG'4
ofs D= Met-oded0ndex3i$e&GKas3emanticsG'4
(
(
**Method0mpl
244260235.doc 56 od 541
old = tableofset4
tablehasrows = tablepresent&B!'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GMethod0mpl Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
Method0mp3truct = new Method0mpTable5rows5B!6 D 264
for & int k = 2 4 k F= rows5B!6 4 kDD'
%
Method0mp3truct5k6.classindex = 9eadTable0ndex&metadata, ofs , GType<efG'4
ofs D= MetTable3i$e&GType<efG'4
Method0mp3truct5k6.codedbody = 9ead-oded0ndex&metadata , ofs ,
GMethod<efOr9efG'4
ofs D= Met-oded0ndex3i$e&GMethod<efOr9efG'4
Method0mp3truct5k6.codeddef = 9ead-oded0ndex&metadata , ofs ,
GMethod<efOr9efG'4
ofs D= Met-oded0ndex3i$e&GMethod<efOr9efG'4
(
(
**Module9ef
old = tableofset4
tablehasrows = tablepresent&B@'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GModule9ef Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
Module9ef3truct = new Module9efTable5rows5B@6 D 264
for & int k = 2 4 k F= rows5B@6 4 kDD'
%
Module9ef3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
(
(
**Type3pec
old = tableofset4
tablehasrows = tablepresent&BL'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GType3pec Table Ofset %"( si$e=%2(G , ofs , rows5BL6'4
tableofset = old4
if & tablehasrows '
%
Type3pec3truct = new Type3pecTable5rows5BL6 D 264
for & int k = 2 4 k F= rows5BL6 4 kDD'
%
**if & debug '
244260235.doc 57 od 541
**-onsole.#rite?ine&GType3pec Table Ofset ofs=%"( k=%2( ?ength=%B(G ,
ofs , k , metadata.?ength'4
Type3pec3truct5k6.signature = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**0mplMap
old = tableofset4
tablehasrows = tablepresent&BH'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G0mplMap Table Ofset ofs=%"( rows=%2( len=%B(G , ofs ,
rows5BH6 , metadata.?ength'4
tableofset = old4
if & tablehasrows '
%
0mplMap3truct = new 0mplMapTable5rows5BH6 D 264
for & int k = 2 4 k F= rows5BH6 4 kDD'
%
0mplMap3truct5k6.attr = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
0mplMap3truct5k6.cindex = 9ead-oded0ndex&metadata , ofs ,
GMember8orwardedG'4
ofs D= Met-oded0ndex3i$e&GMember8orwardedG'4
0mplMap3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
0mplMap3truct5k6.scope = 9eadTable0ndex&metadata, ofs , GModule9efG'4
ofs D= MetTable3i$e&GModule9efG'4
(
(
**8ield9:;
old = tableofset4
tablehasrows = tablepresent&BI'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G8ield9:; Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
8ield9:;3truct = new 8ield9:;Table5rows5BI6 D 264
for & int k = 2 4 k F= rows5BI6 4 kDD'
%
8ield9:;3truct5k6.rva = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
8ield9:;3truct5k6.eldi = 9eadTable0ndex&metadata, ofs , G8ieldG'4
ofs D= MetTable3i$e&G8ieldG'4
(
(
**;ssembley
old = tableofset4
244260235.doc 58 od 541
tablehasrows = tablepresent&AB'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G;ssembly Table Ofset %"(G , ofs'4
tableofset = old4
;ssembly3truct = new ;ssemblyTable5rows5AB6 D 264
if & tablehasrows '
%
for & int k = 2 4 k F= rows5AB6 4 kDD'
%
;ssembly3truct5k6.Kash;lg0d = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
;ssembly3truct5k6.major = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly3truct5k6.minor = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly3truct5k6.build= 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly3truct5k6.revision = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly3truct5k6.Eags = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
;ssembly3truct5k6.publickey = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
;ssembly3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
;ssembly3truct5k6.culture = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
(
(
**;ssembly9ef
old = tableofset4
tablehasrows = tablepresent&A!'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G;ssembley9ef Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
;ssembly9ef3truct = new ;ssembly9efTable5rows5A!6 D 264
for & int k = 2 4 k F= rows5A!64 kDD'
%
;ssembly9ef3truct5k6.major = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly9ef3truct5k6.minor = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly9ef3truct5k6.build= 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
;ssembly9ef3truct5k6.revision = 7it-onverter.To0nt2@ &metadata, ofs'4
ofs D= B4
244260235.doc 59 od 541
;ssembly9ef3truct5k6.Eags = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
;ssembly9ef3truct5k6.publickey = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
;ssembly9ef3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
;ssembly9ef3truct5k6.culture = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
;ssembly9ef3truct5k6.hashvalue = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**8ile
old = tableofset4
tablehasrows = tablepresent&AH'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G8ile Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
8ile3truct = new 8ileTable5rows5AH6 D 264
for & int k = 2 4 k F= rows5AH6 4 kDD'
%
8ile3truct5k6.Eags = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
8ile3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
8ile3truct5k6.index = 9ead7lob0ndex&metadata, ofs'4
ofs D= ofsetblob4
(
(
**>xportedType
old = tableofset4
tablehasrows = tablepresent&AI'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G>xportedType Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
>xportedType3truct = new >xportedTypeTable5rows5AI6 D 264
for & int k = 2 4 k F= rows5AI6 4 kDD'
%
>xportedType3truct5k6.Eags = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
>xportedType3truct5k6.typedendex = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
>xportedType3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
244260235.doc 60 od 541
>xportedType3truct5k6.nspace = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
>xportedType3truct5k6.coded = 9ead-oded0ndex & metadata, ofs ,
G0mplementationG'4
ofs D= Met-oded0ndex3i$e&G0mplementationG'4
(
(
**Manifest9esource
old = tableofset4
tablehasrows = tablepresent&C"'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&GManifest9esource Table Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
Manifest9esource3truct = new Manifest9esourceTable5rows5C"6 D 264
for & int k = 2 4 k F= rows5C"6 4 kDD'
%
Manifest9esource3truct5k6.ofset = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
Manifest9esource3truct5k6.Eags = 7it-onverter.To0ntAB &metadata, ofs'4
ofs D= C4
Manifest9esource3truct5k6.name = 9ead3tring0ndex&metadata, ofs'4
ofs D= ofsetstring4
Manifest9esource3truct5k6.coded = 9ead-oded0ndex&metadata , ofs ,
G0mplementationG'4
ofs D= Met-oded0ndex3i$e&GG'4
(
(
**/ested -lasses
old = tableofset4
tablehasrows = tablepresent&C2'4
ofs = tableofset4
if & debug '
-onsole.#rite?ine&G/ested -lasses Ofset %"(G , ofs'4
tableofset = old4
if & tablehasrows '
%
/ested-lass3truct = new /ested-lassTable5rows5C26 D 264
for & int k = 2 4 k F= rows5C26 4 kDD'
%
/ested-lass3truct5k6.nestedclass= 9eadTable0ndex&metadata, ofs ,
GType<efG'4
ofs D= MetTable3i$e&GType<efG'4
/ested-lass3truct5k6.enclosingclass= 9eadTable0ndex&metadata, ofs ,
GType<efG'4
ofs D= MetTable3i$e&GType<efG'4
(
(
244260235.doc 61 od 541
(
public bool tablepresent&byte tableindex'
%
int tablebit = &int'&valid )) tableindex' X 24
for & int j = " 4 j F tableindex 4 jDD'
%
int o = si$es5j6 V rows5j64
tableofset = tableofset D o4
(
if & tablebit == 2'
return true4
else
return false4
(
public int 9ead-oded0ndex&byte 56 metadataarray , int ofset , string
nameoftable'
%
int returnindex = "4
int codedindexsi$e = Met-oded0ndex3i$e&nameoftable'4
if & codedindexsi$e == B'
returnindex = 7it-onverter.ToQ0nt2@ &metadataarray , ofset '4
if & codedindexsi$e == C'
returnindex = &int'7it-onverter.ToQ0ntAB &metadataarray , ofset '4
return returnindex4
(

public int 9eadTable0ndex&byte 56 metadataarray , int arrayofset , string
tablename'
%
int returnindex = "4
int tablesi$e = MetTable3i$e&tablename'4
if & tablesi$e == B'
returnindex = 7it-onverter.ToQ0nt2@ &metadataarray , arrayofset '4
if & tablesi$e == C'
returnindex = &int'7it-onverter.ToQ0ntAB &metadataarray , arrayofset '4
return returnindex4
(
public int 9ead3tring0ndex&byte 56 metadataarray , int arrayofset'
%
int returnindex = "4
if & ofsetstring == B'
returnindex = 7it-onverter.ToQ0nt2@ &metadataarray , arrayofset '4
if & ofsetstring == C'
returnindex = &int'7it-onverter.ToQ0ntAB &metadataarray , arrayofset '4
return returnindex4
(
public int 9ead7lob0ndex &byte 56 metadataarray , int arrayofset'
%
int returnindex = "4
if & ofsetblob == B'
244260235.doc 62 od 541
returnindex = 7it-onverter.ToQ0nt2@ &metadataarray , arrayofset '4
if & ofsetblob == C'
returnindex = &int'7it-onverter.ToQ0ntAB &metadataarray , arrayofset '4
return returnindex4
(
public int 9eadMuid0ndex &byte 56 metadataarray , int arrayofset'
%
int returnindex = "4
if & ofsetguid == B'
returnindex = 7it-onverter.ToQ0nt2@ &metadataarray , arrayofset '4
if & ofsetguid == C'
returnindex = &int'7it-onverter.ToQ0ntAB &metadataarray , arrayofset '4
return returnindex4
(
public void <isplayTables8or<ebugging&'
%
-onsole.#rite?ine&G3trings Table+%"(G , strings.?ength'4
for & int o = " 4 o F strings.?ength 4 oDD'
%
if & strings5o6 == "'
%
-onsole.#rite?ine&'4
-onsole.#rite&G%"(+G , oD2'4
(
else
-onsole.#rite&G%"(G , &char'strings5o6'4
(
-onsole.#rite?ine&'4

-onsole.#rite?ine&GModule Table+ 9ecords %"(G , Module3truct.?ength'4
-onsole.#rite?ine&G/ame=%"( %2(G, Met3tring&Module3truct526./ame' ,
Module3truct526./ame.To3tring&GWG''4
-onsole.#rite?ine&GMeneration=%"( Mvid=%2( >nc0d=%B( >nc7ase0d=%A(G ,
Module3truct526.Meneration , Module3truct526.Mvid , Module3truct526.>nc0d ,
Module3truct526.>nc7ase0d'4
-onsole.#rite?ine&'4
-onsole.#rite?ine&GType9ef Table+ 9ecords %"(G , Type9ef3truct.?ength '4

for & int o = 2 4 o F Type9ef3truct.?ength 4 oDD'
%
-onsole.#rite?ine&GType %"(G, o '4
-onsole.#rite?ine&G9esolution 3cope=%"( %2(G ,
Met9esolution3copeTable&Type9ef3truct5o6.resolutionscope',
Met9esolution3cope:alue&Type9ef3truct5o6.resolutionscope''4
-onsole.#rite?ine&G/ame3pace=%"( %2(G ,
Met3tring&Type9ef3truct5o6.nspace' , Type9ef3truct5o6.nspace.To3tring&GWG''4
-onsole.#rite?ine&G/ame=%"( %2(G , Met3tring&Type9ef3truct5o6.name',
Type9ef3truct5o6.name.To3tring&GWG''4
(
-onsole.#rite?ine&'4
244260235.doc 63 od 541
-onsole.#rite?ine&GType<ef Table+ 9ecords %"(G , Type<ef3truct.?ength '4
for & int o = 2 4 o F Type<ef3truct.?ength 4 oDD'
%
-onsole.#rite?ine&GType %"( G, o' 4
-onsole.#rite?ine&G/ame=%"( %2(G , Met3tring&Type<ef3truct5o6.name',
Type<ef3truct5o6.name.To3tring&GWG''4
-onsole.#rite?ine&G/ame3pace=%"( %2(G ,
Met3tring&Type<ef3truct5o6.nspace' , Type<ef3truct5o6.nspace.To3tring&GWG''4
-onsole.#rite?ine&G8ield5%"(6G, Type<ef3truct5o6.ndex'4
-onsole.#rite?ine&GMethod5%"(6G, Type<ef3truct5o6.mindex'4
(
(
public string Met3tring &int starting'
%
int ending = starting4
starting , strings.?ength'4
if & starting F "'
return GG4
if & starting )= strings.?ength '
return GG4
while &strings5ending6 ^= " '
%
endingDD4
(
3ystem.Text.>ncoding e = 3ystem.Text.>ncoding.QT8H4
string returnstring = e.Met3tring&strings, starting , ending J starting '4
if & returnstring.?ength == "'
return GG4
else
return returnstring4
(
public string Met9esolution3copeTable &int rvalue'
%
string returnstring = GG4
int tag = rvalue X "x"A4
if & tag == " '
returnstring = returnstring D GModuleG 4
if & tag == 2 '
returnstring = returnstring D GModule9efG 4
if & tag == B '
returnstring = returnstring D G;ssembly9efG 4
if & tag == A '
returnstring = returnstring D GType9efG 4
return returnstring4
(
public int Met9esolution3cope:alue &int rvalue'
%
return rvalue )) B4
(
(
244260235.doc 64 od 541

3trings Table+I@
2+FModule)
2"+a.exe
2@+mscorlib
B!+3ystem
AB+Object
AI+$$$
CA+Main
CH+.ctor
!C+3ystem.<iagnostics
LA+<ebuggable;ttribute
IA+a
I!+
I@+

Module Table+ 9ecords B
/ame=a.exe ;
Meneration=" Mvid=2 >nc0d=" >nc7ase0d="

Type9ef Table+ 9ecords A
Type 2
9esolution 3cope=;ssembly9ef 2
/ame3pace=3ystem 2I
/ame=Object B"
Type B
9esolution 3cope=;ssembly9ef 2
/ame3pace=3ystem.<iagnostics A@
/ame=<ebuggable;ttribute CI

Type<ef Table+ 9ecords A
Type 2
/ame=FModule) 2
/ame3pace= "
8ield526
Method526
Type B
/ame=$$$ BL
/ame3pace= "
8ield526
Method526
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJBH
th
8eb
The program above is one of the largest to date and is the last program
before we start writing our disassembler. #e have added a function
9eadTables0nto3tructures that reads all the table data into structures. ;ll that
we have done so far is read the stream called .\ into an array metadata.

The BC
th
byte of this stream contains a series of ints that tell us the number of
rows. ;s we are ignorant of how many tables we have that contain rows, the
start of the actual table data is unknown to us. The si$e of each table is
244260235.doc 65 od 541
stored in the si$es array. ?ets see how we read the table data by specically
looking at the module and typeref tables.

#e start with initiali$ing the variable old to tableofset that has a value that is
set to the rst byte of the table data. 0n the function 9ead3treams<ata we
kept increasing its value by C so that at the end of the function it pointed to
the start of the table data. #e then call a function called tablepresent.

This function returns a true or a false depending upon whether the table
number passed as a parameter has rows or not. The rst that we do is nd
out the bit representing the table by shifting that many bits to the right and
bit wising anding by one. ;ll this is not new as we explained it earlier.

<epending on whether this bit is 2 or ", we return a true or a false. The
assumption is that if the table is present the table has rows. ;nother way
would be to check the value of the corresponding rows parameter, it is $ero,
then return false else return true.

The most important thing that this function does is changed the value of the
variable tableofset so that it now points to the start of the data for this table
number passed as a parameter and not the start of the table data. #e use a
for loop to loop through all the tables but the one we are passed as a
parameter.

#e know that the number of records is stored in the rows array and the si$e
in the si$es array. #e multiply the two to give us the number of bytes
occupied by this table and add this value stored in variable o to the
tableofset variable.

This way at the end of the loop, the tableofset parameter now contains the
position of the rst byte of data for this table number. #e then store the
value of the tableofset variable into the ofs variable and use this variable
from now on. The #rite?ine function use is to display debugging information.

#e can only read table data if it the table has records and if the tablehasrows
variable is true the rest of the code gets called. The tableofset variable is set
again to its original value stored in old that is the start of table data. This is
why we need the variable ofs to read the data of each table.

The problem with arrays is that they start at " and not one. This makes
program a little counter intuitive. #e prefer languages that start arrays at
one and not $ero. #e need to store the module table data in a structure. Thus
we created a structure tag called ModuleTable that has ve members or
elds.

The second eld as explained before a index into the string eld. This eld
can either be B or C bytes. ;s we do not know in advance we will take the
larger and hence the name eld is an int. The rst eld is the Meneration eld
and even though we know that it is short, we have yet made its data type a
int, as we are not concerned with 1uestions of eSciency.
244260235.doc 66 od 541

;ll that will happen is that our programs run a little slower, but at least you
understand what is happening. 9emember our job is to help you write a
disassembler, not a fast eScient disassembler. #e then create an array of
structures ModuleTable that look like Module3truct as an instance variable.

0n this function we actually create the structure ModuleTable passing it the
number of rows stored in the rows array plus one. The reason we add one is
that we will store all the data starting at member ModuleTable526 and not
member ModuleTable5"6. Thus we have created a global structure for the
module table and an array of structures as an instance variable.

#e thus for each table. #e then in a for loop read that many records. #e
start the count at 2 and not " as the rst array member we initiali$e starts at
2 and not $ero. Thus ModuleTable5"6 will always be null. The generation eld
is always a short and thus we use the ToQint2@ function to set its value.

The name eld could be either B or C bytes large. Thus we use a function
9ead3tring0ndex to fetch its value. This function simply looks at the value of
variable ofsetstring and if it is B uses th ToQint2@ function to read of the
array or otherwise the ToQintAB function.

The ofs variable needs to be set to the next eld each time and for the
generation eld it is always B and for the name eld we use the value of the
ofsetstring variable. The Muid and 7lob indexes are read using the same
concept and the functions 9eadMuid0ndex and 9ead7lob0ndex do the job.

The Type<ef table has some problems for the eld called cindex as it is a
coded index eld. Thus we have a function 9ead-oded0ndex that takes an
extra parameter which is the name of the coded index. This function uses
another Met-oded0ndex3i$e that we had learned earlier to gure out the si$e
of the coded index.

#e use the return value to either read B or C bytes from the array. The ofset
variable is increased by B or C depending upon the return value of the
Met-oded0ndex3i$e function. The next eld carries an ofset into a table
called eld. #e pass this table name as the last parameter to the function
9eadTable0ndex.

#e reuse the function MetTable3i$e that we did earlier and once again
depending upon the value returned read B or C bytes. <itto for the ofs
variable, it is also set to the return value of this function. Thus we have never
tried to assume the si$e of a eld unless the specication very clearly says a
constant number of bytes.

Thus we have now lled up a series of arrays of structures with table data
from the metadata array, bearing in mind that the rst record is array
dimension 2 and not ". ?ets now actually display some table data using the
second function we have added <isplayTables8or<ebugging. 0n succeeding
programs we simply comment out this function.
244260235.doc 67 od 541

#e would rst like to display the stream called .3trings and then the rst
three tables. The array called strings contains the .3trings stream and we
start by displaying its length. #e then display each byte a char by moving
through the strings array one byte at a time.

#e know that each string is null terminated and hence when an array
member is a ", we know that it is the end of a string. #e write out a new line
and then display the corresponding ofset of the string in the array. This table
is very useful in manually reading the string ofsets that are stored in the
tables.

The rst table we display is the Module table. #e start by displaying the
length of the array object Module3truct and we get two in spite of the fact
that the module table can only have one record. 0f you have forgotten, we
have added one to the si$e of the array.

Thus to display the /ame eld, we use the member Module3truct 526./ame
and not Module3truct5"6./ame. The problem is that we see a hex number
that is an ofset into the strings heap. Thus we have written a function
Met3tring that fetches the string at the ofset specied by the /ame eld.

This function rst needs to gure out the length of the string. #e have the
string as a series of bytes in an array and need to convert these bytes into a
string. Thus we need to know where the last byte of the string is. 7ut rst,
some error checks.

0f the value of the parameter passed for some reason is negative or larger
than the si$e of the strings array we return an empty string. #e then scan
though the strings array starting from the beginning of the string as we have
initiali$ed the variable ending that we are using as the array parameter to the
value of the start of the string stored in the parameter passed starting.

#hen we exit the while loop on reaching the null character, the ending
variable will tell us where the string ends. #e then use the same old
Met3tring function that we did earlier. The only diference is that the second
parameter is the start of the string in the strings array and is the value of the
variable starting.

The length of the string is the diference between the end of the string and
beginning and thus is the diference between the two values ending and
starting. Once again if the ?ength of the string is $ero we return an empty
string. 8or the module table we know that we have only one record and hence
we used no loop.

The Type9ef and Type<ef structures can have as many records as they like.
The rst eld is called the 9esolution scope eld and is a coded index. This
coded index can take one of C values. 0f we display the coded index, it makes
no sense to use and hence we have two functions, Met9esolution3copeTable
244260235.doc 68 od 541
that returns the table name and the other Met9esolution3cope:alue that
gives us the row in the table.

This coded index has three bits to store the table number and thus we rst
bitwise and with A as two bits are used for coding the table. Then we check
the value of the variable and return the appropriate table name. 0n our case
as the second bit is on, we get a value of ;ssembly9ef.

The Met9esolution3cope:alue function is easier as we know that two bits are
used to store the table number, we simply right shift the int by B, throwing of
the table number bits and returning this value. The bits that move in from the
left are " and thus do not efect the answer.

Zou could display the data from all the other tables stored in structures in the
same way if you like.

,rogramL.csc

public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
8illTable3i$es&'4
9eadTables0nto3tructures&'4
<isplayTables8or<ebugging&'4
9eadand<isplay:Table8ixup&'4
(

public void 9eadand<isplay:Table8ixup &'
%
if & vtablerva ^= "'
%
long save 4
long position = -onvert9:;&vtablerva' 4
if & position == J2'
return4
mlestream.,osition = position4
-onsole.#rite?ine&G** :Table8ixup <irectory+G'4
int count2 = vtablesi$e*H4
for & int ii = " 4 ii F count2 4 iiDD'
%
int xuprva = mbinaryreader.9ead0ntAB&'4
-onsole.#rite?ine&G** 0M;M>T-O9T:T;7?>80WQ,5%"(6+G , ii'4
-onsole.#rite?ine&G** 9:;+ %"(G,xuprva.To3tring&GxHG''4
short count = mbinaryreader.9ead0nt2@&'4
-onsole.#rite?ine&G** -ount+ %"(G, count.To3tring&GxCG''4
short type = mbinaryreader.9ead0nt2@&'4
244260235.doc 69 od 541
-onsole.#rite?ine&G** Type+ %"(G, type.To3tring&GxCG''4
save = mlestream.,osition4
mlestream.,osition = -onvert9:;&xuprva' 4
int i2 4
long val = " 4
for & i2 = " 4 i2 F count 4 i2DD'
%
if & &typeX"x"2' == "x"2'
val = mbinaryreader.9ead0ntAB&'4
if & &typeX"x"B' == "x"B'
val = mbinaryreader.9ead0nt@C&'4
if & &typeX"x"2' == "x"2'
-onsole.#rite?ine&G** 5%"(6 &%2('G,i2.To3tring&GxCG' ,
val.To3tring&GWHG''4
if & &typeX"x"B' == "x"B'
-onsole.#rite?ine&G** 5%"(6 & %2('G,i2.To3tring&GxCG' ,
&valX"xffff'.To3tring&GWG''4
(
mlestream.,osition = save4
(
-onsole.#rite?ine&'4
(
(
(

e.il
.class public a22222
%
.method public static void adf&' cil managed
%
.entrypoint
(
.method public int@C a2&' cil managed
%
(
.method public int@C aB&' cil managed
%
(
.method public int@C aA&' cil managed
%
(
.method public int@C aC&' cil managed
%
(
.method public int@C a!&' cil managed
%
(
.method public int@C a@&' cil managed
%
(
244260235.doc 70 od 541
.method public int@C aL&' cil managed
%
(
(
.vtxup 526 intAB at <T""""H"2"
.vtxup 526 intAB fromunmanaged at <T""""H"B"
.vtxup 526 int@C at <T""""H"A"
.vtxup 526 int@C fromunmanaged at <T""""H"C"
.vtxup 5"6 int@C at <T""""H"!"
.vtxup 5B6 int@C int@C at <T""""H"@"
.data <T""""H"2" = bytearray & "2 "" "" "@'
.data <T""""H"B" = bytearray & "B "" "" "@'
.data <T""""H"A" = bytearray & "A "" "" "@'
.data <T""""H"C" = bytearray & "C "" "" "@'
.data <T""""H"!" = bytearray & "! "" "" "@'
.data <T""""H"@" = bytearray & "@ "" "" "@ "" "" "" "" "L "" "" "@ "" ""
"" ""'

Output
** :Table8ixup <irectory+
** 0M;M>T-O9T:T;7?>80WQ,5"6+
** 9:;+ """"C"""
** -ount+ """2
** Type+ """2
** 5""""6 &"@"""""2'
** 0M;M>T-O9T:T;7?>80WQ,526+
** 9:;+ """"C""C
** -ount+ """2
** Type+ """!
** 5""""6 &"@"""""B'
** 0M;M>T-O9T:T;7?>80WQ,5B6+
** 9:;+ """"C""H
** -ount+ """2
** Type+ """B
** 5""""6 & @"""""A'
** 0M;M>T-O9T:T;7?>80WQ,5A6+
** 9:;+ """"C""c
** -ount+ """2
** Type+ """@
** 5""""6 & @"""""C'
** 0M;M>T-O9T:T;7?>80WQ,5C6+
** 9:;+ """"C"2"
** -ount+ """"
** Type+ """B
** 0M;M>T-O9T:T;7?>80WQ,5!6+
** 9:;+ """"C"2C
** -ount+ """B
** Type+ """B
** 5""""6 & @"""""@'
** 5"""26 & @"""""L'
244260235.doc 71 od 541


#e start this program by letting you on the bad news. 0f you really want to
write the worlds best disassembler, the only way to do it is by learning 0?. 0? is
the new machine language of the ./et world and all code whether in -. or
managed -DD or :7./et gets converted into 0? and then machine language.

#hat bytecodes is to Uava, 0? is to the ./et world. Thus from now on all our
code will be in 0? and we will explain 0? as we go along. ;lso the dissembler
output is also in 0?. ?ets start with the le e.il rst. 0? is a lot like any
programming language and instead of writing class we write .class.

This is followed by the access modier and the name of the class. ; class
carries methods and the .method denes a method, followed by the access
modiers, then the static keyword if it is a static function. Then we have the
return value and the name of the function.

Then we end with an optional keyword il managed which means that the code
is written by us using 0? and it is managed and not unmanaged. -ode that is
managed follows all the rules of the ./et world and is save and trusted. 0n -.
there was one function that was the rst one to get executed and was called
Main.

0n 0? the name of the function can be whatever we like but must have the
directive .entrypoint. 0n the same vein we create seven more function ranging
from a2 to aL. Then we have a directive that our program focuses on
namely .vtxup. ?ets rst understand what this directive is all about.

0f we write a -DD program, we may never write such a directive, the compiler
that generates 0? code is what writes out these directives. The main point to
be noted is that if il does not have a directive or instruction to accomplish
something, the programming language will also not have such a feature.

;ll code written in any ./et language is always converted into 0?. The reason
why the .vtxup directive was introduced was because we wanted to call
from unmanaged code into managed code. ;s mentioned earlier unmanaged
code was written in languages like -, -DD where no error checks were done
by the system.

The language could read and write any memory locations and was very easy
to introduce a virus. Managed code has tons of checks built and it is next to
impossible or so says Microsoft that we can add arbitrary code and have it
executed. One of the reasons why .net code is slower than the older
conventional code is that lots of checks happen before your code is stamped
ready to run.

3ome operating systems may need to follow a series of steps to transition
from unmanaged code to managed code. The other reason is that the data
types of the parameters may need to be converted from one type to another
for the call. This conversion is called data marshalling.
244260235.doc 72 od 541

#e specify all this using the .vtxup directive. 0f we forget to mention, in any
machine language, anything that begins with a dot is called a directive. This
directive may appear a million times but has to appear at the top level of a
0? le. ; top level means that it cannot appear inside of a directive like a class
or namespace directive.

;fter the directive .vtxup we have with s1uare brackets a number that tells
is how many entries are present in the vtable. #e will come to the concept of
a vtable a little later. -oming back to our 0? le #e have six .vtxup
directives. 8our of them have 2 in s1uare brackets that tells us that they have
only 2 vtable entry. The last vtxup directive has two vtable entries and
nally the fourth has none.

This number is followed by the width of each slot in the vtable. The attributes
or values that can be used are intAB and int@C and they are mutually
exclusive. 0f we do not specify one intAB is the default. ; slot is made up of a
AB bit metadata token. This token starts with the number of the table called
Method<ef that is @ and then a BC bit number specifying the row within the
table.

This is how we use AB bits to represent a table and row with a table. These
entities are called meta data tokens. 0f the slot is @C bits, the remaining AB
bits are $eroed out. 0t is the job of the system to gure out a pointer to the
function that is represented by the metadata token and convert it into the
same width as the slot.

The only other attribute that can be used along with intAB and int@C is
fromunmanaged. This attribute tells the -?0 to rst generate a piece of code
called the thunk that will convert the unmanaged method call to a managed
call. Then it will call the actual method and return the result of the managed
call to the unmanaged code.

The thunk will obviously convert the parameter type or do data marshalling
and also follow the rules of calling code that the platform it is running on
wants it to do. This is followed by the block address that contains the
metadata token. Thus we specify a block address of <T""""H"2" for the rst
directive.

#e now have to create such a block and use the .data directive to do so and
specify some data to be present in this block using the bytearray keyword.
The value we specify is the metadata token. ;s the last vtxup directive is @C
bits, the metadata token has C bytes of $eroes.

The ilasm syntax however does not specify a specic way of creating these
tables of tokens and simply recommends that we use the data directive as we
have. Once again to summari$e, the .vtxup directive tells us that if we go to
a memory location we shall nd a table. This table contains metadata tokens
that represent method names that will be converted into method pointers.

244260235.doc 73 od 541
0t is the job of the system or -?0 to do the above conversion automatically
when the loader loads the le into memory which being executed. ;ll that we
specify is the number of entries in the table or vtable, the kind of method
pointer and the width of the entry of each slot and nally where the table is
located in memory.

The programming language -DD introduced a concept of virtual functions
where the object calling the function could be of the base type but the
function called would be of the derived type. This was possible only if the
base class type object was initiali$ed to the derived type object.

To achieve this the compiler and not the linker or runtime created a table in
memory with the address of the virtual functions called the vtable. This also
meant that languages like -DD chose not to follow a common type system
runtime model. 8inding the correct vJtable slot and calling the code
represented by that slot was handled by the compiler.

The compiler simply placed the latest address of the function in the vJtable. 0t
is the vtxup directive that contains the location and si$e of the vtable xups
and they have to be present in a read write part of the ,> le. These vtable
slots are all contiguous and must be of the same si$e.

0t is at run time that the ?oader will convert every table entry into a pointer to
machine code for the -,Q. This code can also be called directly. This structure
has A members, the rst a int that contains the 9:; of the table, then
followed by two shorts that tell us the count or number of vtable entries and
nally the type of entry that can be intAB or int@C followed by unmanaged.

There is a fourth type called call most derived that we were not able to
simulate as it deals with virtual methods. ?ets now look at the actual code
that lets us display the vtxup directive as ildasm does. #e start by adding a
function 9eadand<isplay:Table8ixup to the abc function.

0n the -?9 header there was a data directory entry that specied the 9:; and
si$e of the vtable xups table and we used the instance variables vtablerva
and vtablesi$e to store the rva and si$e respectively. #e can only display the
xups if the variable vtablerva is not $ero.

#e then use the -onvert9:; function to convert the rva o a physical si$e on
disk and then set the ,osition property of the 8ile3tream object to its value.
#e however rst build a error check to make sure that the position variable
does not have a value of $ero.

3ome time ago we mentioned that the vtable xups structure is H bytes and
contains three elds. Thus the count2 variable tells us how many vtxup
entries there are. These structures are stored back to back and thus in the for
loop we iterate count2 number of times. #e rst read the rva of where the
table is loaded.

244260235.doc 74 od 541
Then we have the number of vtable slots or entries that we store in the
variable count and nally the type of the entries. 0n the s1uare brackets we
simply display the value of the loop variable ii. #e then save the le pointer
position in the variable save and then jump to the actual vtable location that
is stored in the rst eld xuprva and using the -onvert9:; function.

Kere is stored the actual meta data tokens whose count is the second eld.
;s we are moving the le pointer we save it in the variable old and at the end
of the loop we restore the le pointer again as we need to read the next
vtxup structure. The actual vtable entries are stored in a diferent place than
the vtxup structures.

0n the for loop we loop depending upon the vtable slots and depending upon
the type of entries, we either read a int or a long. Then we display the loop
variable as well as the metadata token. Kere we need to format the display
depending upon whether it is a AB bit or @C bit slot. #e nally end with a new
line.

,rogramH.csc
public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
8illTable3i$es&'4
9eadTables0nto3tructures&'4
<isplayTables8or<ebugging&'4
9eadand<isplay:Table8ixup&'4
9eadand<isplay>xport;ddressTableUumps&'4
<isplayModule9efs&'4
(

public void 9eadand<isplay>xport;ddressTableUumps &'
%
-onsole.#rite?ine&G** >xport ;ddress Table Uumps+G'4
if & exportaddressrva == "'
%
-onsole.#rite?ine&G** /o data.G'4
-onsole.#rite?ine&'4
(
(
public void <isplayModule9efs&'
%
if &Module9ef3truct == null '
return4
for & int ii = 2 4 ii F Module9ef3truct.?ength 4 iiDD'
%
string dummy = Met3tring&Module9ef3truct5ii6.name'4
244260235.doc 75 od 541
-onsole.#rite?ine&G.module extern %"( *V2;%2(V*G , dummy ,
ii.To3tring&GW@G''4
(
(

e.il
.module extern kernelAB.dll
.module extern dd.dll
.class $$$
%
.method public static void adf&' cil managed
%
.entrypoint
(
(

Output
** >xport ;ddress Table Uumps+
** /o data.

.module extern kernelAB.dll *V2;"""""2V*
.module extern dd.dll *V2;"""""BV*

;n extremely short program but we have added two function calls to the abc
function. The rst is called 9eadand<isplay>xport;ddressTableUumps that
reads the export address table. This data directory entry is always $ero as
mandated by the specications. The second displays all the modules that
contain functions that we reference from our code.

The .module extern directive is extremely unintelligent and simply lls up the
Module9ef table which has a number 2a with a record for each directive. This
table is the smallest possible table with only one eld the module name that
is an index into the 3tring heap.

The index eld into the 3tring heap follows some basic rules that we will not
repeat again. The name must point to a non null string in the heap. The
system does not bother to check at assemble time whether the dll actually
exists or not. The name has a restriction depending upon M;WT,;TKT/;M>.

;s it stands for the name of a le its format is lename.extension. There are
no drive letters or directory names or colons or any form of slashes. There
should be no duplicate rows. This is however a warning only and the name
that we nd in this table must also be present in the 8ile table that we will
come to later.

This le table entry is used to locate the actual le that hold or contains the
module. 0f the Module9ef table has no records, the Module9ef3truct has a
value of null. 0f a variable holds such a value, it means that we have not
instantiated the object and hence are not allowed to reference any members
of this array.
244260235.doc 76 od 541

0n the for loop the count variable starts from 2 and goes on to the length of
the array using the eld ?ength that every array contains. 0f the array
variable Module9ef3truct is not initiali$ed, an exception will be thrown.

Thus as a policy at the start of every function, we check whether the instance
array variables we are using in the function are instantiated or not. 0f not, it
only means that the corresponding table is empty and therefore we bail out
of the function.

;ll that we do in the for loop is display the string represented by the name
index using the Met3tring function. #e also display the record number and
the table name within comments.

,rogramI.csc
public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
8illTable3i$es&'4
9eadTables0nto3tructures&'4
<isplayTables8or<ebugging&'4
9eadand<isplay:Table8ixup&'4
9eadand<isplay>xport;ddressTableUumps&'4
<isplayModule9efs&'4
<isplay;ssembley9efs&'4
(

public void <isplay;ssembley9efs &'
%
if &;ssembly9ef3truct == null'
return4
for & int i = 2 4 i F ;ssembly9ef3truct.?ength 4 iDD'
%
-onsole.#rite?ine&G.assembly extern *VBA%"(V* %2(G, i.To3tring&GW@G' ,
Met3tring&;ssembly9ef3truct5i6.name''4
-onsole.#rite?ine&G%G'4
if &;ssembly9ef3truct5i6.publickey ^= "'
%
-onsole.#rite&G .publickeytoken = &G'4
<isplay8ormatted-olumns&;ssembly9ef3truct5i6.publickey,BB , false'4
(

if & ;ssembly9ef3truct5i6.hashvalue ^= " '
%
-onsole.#rite&G .hash = &G'4
<isplay8ormatted-olumns&;ssembly9ef3truct5i6.hashvalue,22 , false'4
244260235.doc 77 od 541
(
int rev = ;ssembly9ef3truct5i6.revision4
if & rev F "'
rev = @!!A@ D rev4
-onsole.#rite?ine&G .ver %"(+%2(+%B(+%A(G , ;ssembly9ef3truct5i6.major,
;ssembly9ef3truct5i6.minor,;ssembly9ef3truct5i6.build,rev'4
The hash directive is similar to the publickeytoken directive. #e next come to
the ver directive. The elds major, minor, build are elds in the ;ssembly9ef
table. The revision eld needs some special handling.
if & ;ssembly9ef3truct5i6.culture ^= " '
%
-onsole.#rite&G .locale = &G'4
int index = ;ssembly9ef3truct5i6.culture4
int cnt = "4
while & strings5index6 ^= "'
%
-onsole.#rite&G%"( "" G , strings5index6.To3tring&GWG''4
cntDD4
indexDD4
(
int nos = @C J &2C D @ D &@VcntD2''4
-onsole.#rite&G"" ""G'4
-onsole.#rite&G '%"(** G , -reate3paces&nos''4
index = ;ssembly9ef3truct5i6.culture4
while & strings5index6 ^= "'
%
-onsole.#rite&G%"(.G , &char'strings5index6'4
indexDD4
(
-onsole.#rite?ine&G..G'4
(
-onsole.#rite?ine&G(G'4
(
(
public void <isplay8ormatted-olumns & int index , int startingspaces , bool
putonespace'
%
int howmanybytes,uncompressedbyte 4
howmanybytes = -or3igQncompress<ata &blob , index , out
uncompressedbyte'4
index = index D howmanybytes4
byte 56 blobarray = new byte5uncompressedbyte64
;rray.-opy&blob , index , blobarray , " , uncompressedbyte'4
int maincounter = "4
while &maincounter F uncompressedbyte'
%
string rststring = GG4
string secondstring = GG4
int counterforascii = "4
int ii 4
244260235.doc 78 od 541
bool noascii = false4
for &counterforascii = " 4 counterforascii F 2@ 4 counterforasciiDD'
%
if & maincounter == uncompressedbyte '
break4
if & blobarray5maincounter6 )= "xB" XX blobarray5maincounter6 F= "xLe'
noascii = true4
maincounter DD4
(
maincounter J= counterforascii4
for & ii = " 4 ii F 2@ 4 iiDD'
%
if & maincounter == uncompressedbyte'
break4
rststring = rststring D blobarray5maincounter6.To3tring&GWBG' D G G4
if & blobarray5maincounter6 )= "xB" XX blobarray5maincounter6 F= "xLe'
secondstring = secondstring D &char'blobarray5maincounter64
else
secondstring = secondstring D G.G4
maincounter DD4
(
if &maincounter == uncompressedbyte'
%
int leftovers = maincounter[ 2@4
if & leftovers ^= "'
%
leftovers = 2! J leftovers4
rststring = rststring D G'G 4
int space = leftoversVA D A4
if &noascii'
rststring = rststring D -reate3paces&space'4
else
rststring = rststring D G G4
(
else
%
rststring = rststring D G'G4
if & putonespace XX uncompressedbyte F= 2@'
rststring = rststring D G G4
rststring = rststring D -reate3paces&"'4
(
(
if & maincounter == uncompressedbyte '
%
if & noascii '
rststring = rststring D G ** G D secondstring4
(
else
if &noascii'
rststring = rststring D G ** G D secondstring4
244260235.doc 79 od 541
-onsole.#rite?ine&rststring'4
if & maincounter ^= uncompressedbyte '
-onsole.#rite&-reate3paces&startingspaces''4
(
(
public string -reate3paces &int howmanyspaces'
%
string returnstring = GG4
for & int j = 2 4 j F= howmanyspaces 4 jDD'
returnstring = returnstring D G G4
return returnstring 4
(
public int -or3igQncompress<ata & byte 56 blobarray , int index , out int
answer'
%
int howmanybytes = "4
answer = "4
if & &blobarray5index6 X "xH"' == "x""'
%
howmanybytes = 24
answer = blobarray5index64
(
if & &blobarray5index6 X "x-"' == "xH"'
%
howmanybytes = B4
answer = &&blobarray5index6 X "xAf' FFH ' ] blobarray5indexD264
(
if & &blobarray5index6 X "x>"' == "x-"'
%
howmanybytes = A4
answer = &&blobarray5index6 X "x2f' FFBC ' ] &blobarray5indexD26 FF 2@' ]
&blobarray5indexDB6 FF H' ] blobarray5indexDA64
(
return howmanybytes4
(
(

e.il
.assembly extern $$$
%
.ver 2+B+A+C
.hash = & 2 B A a b'
.locale Gvijay G
.publickeytoken = & "2 B A C ! @ L H I 2" 22 2B 2A 2C 2! 2@'
.publickey = & "2 B A C ! @ L H I 2" 22'
(
.class $$$
%
.method public static void adf&' cil managed
%
244260235.doc 80 od 541
.entrypoint
(
(

Output
.assembly extern *VBA"""""2V* $$$
%
.publickeytoken = &"2 "B "A "C "! "@ "L "H "I 2" 22 2B 2A 2C 2! 2@ '
.hash = &"2 "B "A "; "7 '
.ver 2+B+A+C
.locale = &L@ "" @I "" @; "" @2 "" LI "" B" "" "" "" ' ** v.i.j.a.y. ...
(
.assembly extern *VBA"""""BV* mscorlib
%
.ver "+"+"+"
(

0n this program we now display all the assembly refs. #e will come to the
diference between a assembly and a module a little later. ; assembly
contains lots of les. #e use the assembly to mediate accesses to these les
from other assemblies.

;ny code that we access from an assembly should contain a assembly extern
directive stating that these assemblies will be referenced by code following.
This directive is also a top level directive.

The as clause is optional and all that it does is provides an alias to the
assembly name, if and only if there are two assembly extern directives that
have the same name. 0f there is no clash like in our case then the as clause is
ignored.

The assemblies that have the same name must difer in version, culture etc
that we will explain in a short while. There are a million things that we have
not implemented in our disassembler and one of them is the as clause.

The reason we did not was that if we have more than one assembly ref with
the same name, the alias name is not stored in the ;ssembly9ef table. ;ll
that happens is that the name of the assembler gets a underscore and a
number 2 or B added to it.

Thus we have to rst sort the records in the ;ssembly table and if there are
duplicates we call them in our case $$$T2, $$$TB etc. #e have left the above
as an exercise for you, the reader. 0f we added everything that ildasm does,
you would not be reading this book, we would yet be writing the
disassembler.

The name of the assembler ref is called the dotted name and it obviously
must match the name of the assembler as specied in the .assembly
directive in that assembly. Kowever for some reason ilasm does not bother to
even check whether the assembler $$$ actually exists or not.
244260235.doc 81 od 541

7ut as per the specs, the name should match in a case sensitive way even
though the operating system or le system is like <O3 that is case
insensitive. 0f you see the output, there is a reference to the assembly
mscorlib. #e have not referred to this assembly in any way in our 0? le.

#hat we forget was that every class in the 0? world is derived from object,
whether we specify it or not. ;s the class $$$ is derived from nothing, it gets
derived from object which like all basic types is present in mscorlib.dll. Thus
the il assembler always adds mscorlib as a assembly reference.

?ets look at the individual directives present within the assembly ref directive
which are similar to the assembly directive. The assembly directive creates
the manifest so that the assembly extern can refer to it. The rst directive we
touch on is the ver directive or the version number of the assembly.

This is a series of four AB intPs or AB bit integers separated by colons. This
version number is decided at compile time and is used to bind this assembly
to all parts in the compiled module that need to refer to it. The specs
however do not specify how the version numbers should be used.

The implementation may decide to ignore the version numbers or may check
that the version numbers are the same or match precisely when referring to
or binding to the assembly. /ormally or by convention the rst number is the
main version number.

Thus if the assembly extern has a version number of 2 and the assembly with
the same name has the version number of B, they are to be considered
diferent assemblies and are not interchangeable. This makes sense as when
we change the major version number we are saying that a this is a major
upgrade.

;lso by convention larger version numbers should be compatible with smaller
version numbers so that existing code does not break and backward
compatibility is maintained. The other way around is not true.

The second number is the minor version number and assemblies that difer
only in the second number are said to refer to the same assembly. This
means that the assembly has changed in a signicant way but backward
compatibility has been maintained. This is also called a point release.

The third number changing is called the revision number and are meant to be
fully compatible if this is the only number that has changed. The revision
number changes to x some bugs or a major security hole. The last one is the
build number and if it changes, then the source code has remained the same
but a recompilation was carried out.

This was because the processor changed, or some compiler option was
changed or was compiled for a new operating system. The rst major version
244260235.doc 82 od 541
number means that lots of changes have taken place in the source code, the
last is at the other extreme, no changes took place in the source.

The above rules are only a convention that may or may not be carried. ;fter
all who is to decide whether the changes made are big enough to change the
major or minor or revision version number. ;t times the toss of a coin is the
best way to decide. Keads change the major version, tails the minor and if
the coin gets lost as is normally the case the revision number.

The next eld we will look at is what most of the world including is lacks,
culture. The specs say that instead of using the directive locale, the Microsoft
implementations will use culture instead. The culture directive uses a string
that denotes the culture and this is called a Y3tring.

-ulture locale etc have to do with the language used for storing strings and is
part of the internationali$ation of software. This is also called i2Hn as there
are 2H characters between 0 and n of internationali$ation. 7y specifying a
culture we are saying that this assembly has been customi$ed or uses a
certain culture.

The specs have a doc le called ,artition 0: that specify the culture strings
that can be used. The metadata specs are part of what is called ,artition B.
The class 3ystem.Mlobali$ation.-ulture0nfo is what is the class responsible for
understanding diferent cultures. The culture strings are meant to be case
insensitive.

8or some reason the Microsoft implementation uses .locale rather than
.culture. These culture rules follow the internet standard that is called a 98-
or re1uest for comments. The 98- is 2L@@. The format of the culture names
should be languageJcountry*region and not what we have used.

The language should follow the two character code that every country has
been given by another international standard 03O @AIJ2. This is the same
codication that domain names use on the internet. The country*region code
is also an uppercase two letter code that is specied by the 03O standard
A2@@.

The third directive is the hash algorithm used. Kashing is a very known
concept in the computer world and the bytes after the hash directive specify
the hash value of the algorithm. The :>3 or :irtual >xecution system will rst
calculate the hash value and then only access the le. 0f the hash value does
not match, an exception will be thrown.

#hen the created the assembly, we used the .hash algorithm where we
specied the hashing method to be used. #e will come back to it when we do
the assembly table. The publickey token is the last directive that can be
placed in the assembly ref directive.

This directive is used to store the lower H bytes of the 3K;2 hash of the
originators public key. The assembly reference can store either the full public
244260235.doc 83 od 541
key or only the lower H bytes as the publickeytoken directive does. #e can
use either of them.

#e need the above to validate that the same private key that was used to
sign the assembly at the time of compilation is now being used to sign at
runtime. 0t is not mandatory that any of the two directives .publickey or
.publickeytoken must be present and if present, only one is useful not both.

To conform to the rules of ./et, this validation is not a must. 7ut if it does,
and the validation fails, it may not load the assembly. ;s an added caveat,
the system may refuse access to an assembly unless the assembly ref
species the correct publickey or publickeytoken directive.

The full key is always cryptographically safe but the converse is that it
re1uires more storage space in all assembly references as it is larger.

#e add jut one more function call <isplay;ssembley9efs to the abc function.
0t is this function that displays all the assembly refs or the assembly extern
directive. >very assembly extern directive that we write gets one row in the
;ssembly9ef table. Thus the rst thing we check is whether we have an
records in the ;ssembly9ef3truct array.

#e iterate as always the relevant array starting the loop counter from one
and up to the ?ength of the array. 8or most of these tables we display the
table number followed by the name of the assembly stored in the name eld
and using the Met3tring function.

The order of directives is important and the rst one to be seen is the
publickeytoken directive. This directive is not mandatory and hence we check
if the led has a value, 0f and if it does we display the string publickeytoken.
#e then use a function <isplay8ormatted-olumns that displays its value.

#e will come to this function in a short while as other directives also use it.
#e rst store the eld revision in a variable called rev. 0f the value of variable
rev is less than " we add @!!A@ or B_2@ to it and then display it. The last
eld we need to display is the culture or locale eld.

The culture eld is a index into the strings heap that we store in a variable
called index. #e know that any index into the strings heap will be null
terminated and this is used as the condition in the while loop. #e do three
things in the while loop, we rst display the ascii value in hex of the string.

Qnfortunately the string bytes must be displayed as Qnicode where every
character is 2@ bytes wide. Thus we have to add the extra "" after each ;3-00
character. #e also need a count of bytes we are displaying and hence we
increase the cnt variable by 2. #e also have to increase the index variable by
2 as the while loop uses it as a condition.

#e next write a null at the end which in Qnicode is a set of $eroes. #e then
close the bracket and now need to display the Qnicode characters as
244260235.doc 84 od 541
readable texts but within comments. #e thus need to place a series of spaces
before we can display the characters. #e learnt that the comments always
start at @C characters.

The assembly extern directive takes B" characters and each Qnicode
character takes @ bytes and the number of Qnicode characters is stored in
the cnt variable. #e hope you understand why we need the extra space. This
way we calculate the number of spaces and use a simple function
-reate3paces to add that many spaces.

Throughout this book we have had to focus on how many spaces to add at
diferent points of time. The above example is the one of the easiest that you
will nd in this book. ;ll that we do in the -reate3paces function is in a for
loop keep adding a space to the string returnstring which at the end of the for
loop is made up of howmanyspaces.

#e once again initiali$e the index variable to the culture eld and then iterate
the while loop again. This time however we display the ;3-00 value by casting
the string heap byte to a char and putting a dot after each character
signifying the null character. #e end with two dots for the null characters and
nally we close the brace for the assembly extern directive.

7efore we start explaining the function <isplay8ormatted-olumns, lets speak
the truth. Our program is littered with functions like these that simply take
care of formatting. ;ll that the above function does is display some bytes in a
table with formatting done like the way ildasm does.

The problem with code that formats things in a pretty way is that when we
write the code, we have to keep a dentists knife in our mind, not a butchers
knife. #e have to write very precise code as a space here or there makes a
lot of diference. The rst parameter is an ofset into the blob heap.

The blob heap is a uni1ue entity as it has no apparent structure. There is no
end of string marker like the string heap or us heap or is made up of 2@ byte
entities like the guid heap. 8or the blob heap, the rst byte is the important
byte, as this byte tells us the length of the bytes owned by the eld.

0f the designers chose only one byte, we would have problem as then the
maximum length represented would be B!! characters. 0f we keep the length
bytes as B, then the maximum length represented will be @!!A! bytes but for
those entities that are less than B!! bytes, a byte in the blob heap would be
wasted and thus make the blob heap larger and less eScient in si$e.

Thus the designers created a uni1ue manner of representing the length
owned by a series of bytes. #e have a function -or3igQncompress<ata that
excepts three two parameters and gives two answers. The rst is obviously
the array of bytes, in our case the blob array and second is the index byte or
starting byte in the array.

244260235.doc 85 od 541
#e are returned the number of bytes that make up the length or count byte
and the third parameter uncompressedbyte will contain the actual value that
makes up the count or length bytes. ?ets rst move on to this function and
understand the compression method used. The name of this function has a
interesting story.

7efore we write a line of code ourselves, we look at other who have written
on similar subjects. The ./et samples have a -DD program that displays
metadata. That program comes with source code and uses the function
-or3igQncompress<ata to decode the count or length byte. ;ll that we did
was rewrite the -DD code into -..

8or some reason code that does lots of useful stuf like a debugger are not
available as -. samples. Maybe Microsoft is telling us something and we are
turning a deaf ear to it. The Microsoft disassembler ildasm is a -DD program
also. The function -or3igQncompress<ata rst checks the last bit of the rst
byte.

0f it is $ero, then the next seven bits tells us the count or length bytes. #e set
the variable howmanybytes to 2 as the count or length byte is one and the
out parameter answer to the value of the byte whose index is the parameter
index.

Thus a count of up to 2BL bytes can be represented by 2 byte and normally
the indexes into the blob will not be own more than 2BL bytes. #e then check
the last two bits of the next 2@ bytes. 0f they are 2 and ", i.e. the last bit is 2
and the second last ", this means that the next 2C bits store the si$e.

This now means that a length larger than 2BL to 2@AHA can be represented
by only B bytes. Thus we set the variable howmanybytes to B and the answer
parameter rst knocks of the last two bits and then left shifts by H for the
multiplication and places the next H bits by using a simple or.

8inally if the last three bits are 2, 2 and ", then the next BI bits stand for the
length. The howmanybytes variable is set to C as this value is what we return
back. The answer variable is a little more complex as now we have to strip of
bits A", A2 and AB using bit wise anding and then left shifting by BC.

The remaining next three bytes are bit wise ored after shifting them to the
left by 2@ and H and 2. 0f the above is not clear, another way is to actually
read in the individual bytes using variables and then doing the multiplication
and then adding them up.

?ets now move back to the earlier function <isplay8ormatted-olumns and
after the call to the -or3igQncompress<ata that we have just explained. The
howmanybytes variable tells us the number of bytes occupied by the length
byte in the blob array.

#e then add this value to the index variable so that the variable points to the
start of the rst byte of data. #e cannot assume that the variable
244260235.doc 86 od 541
howmanybytes will have a value of 2. Most of the time if we make the above
assumption, we will not be wrong, but we will show you cases where the
length byte is B.

The variable uncompressedbyte now contains the actual length of the bytes.
#e would now like to copy these se1uence of bytes from the ofset in the
blob array into an separate array just for our convenience. Thus we create a
new array blobarray that is uncompressedbyte bytes or the length of the
bytes in the blob array large.

#e then use the static function -opy to copy from source array blob, the rst
parameter, starting at position index within the array, the second parameter.
The third parameter is the destination array blobarray and the fourth and fth
is the starting point and the length in the destination array.

Throughout this book you will come across code like the above as it is more
convenient referring to bytes starting at $ero than at position index within an
array. #e will run thorough each byte in the array blobarray using the
variable maincounter and stopping when we loop uncompressedbyte bytes.

0n the main while loop we rst initiali$e two strings rststring and
secondstring to an empty string. #e enter a for statement that will loop 2@
times and the variable counterforascii is only used as loop variable. This for
statement will be executed many times and if ever the outer loop variable
maincounter ever become e1ual to uncompressedbyte we 1uit the for
statement.

The main part of the for is a if statement that checks whether we have nay
printable ascii characters or not as part of the 2@ bytes we are checking. 0f we
do, we take the 7oolean variable noascii that is false and set its value to true.

Thus even if only one of the 2@ bytes is a printable ascii character that we
dene as from hex B" to Le, the variable noascii will be true. #hy we do this
will be clearer to you a couple of lines down the road. #e also increment the
maincounter by one as we use as an index into the blobarray variable.

#hen we exit the for loop we again set the maincounter variable back to the
value it was before we entered the loop. 0t could be 2@ but if the rst if
statement is true, the value of the counterforascii variable will be far less
than 2@.

#e now have another for loop that uses a loop variable ii and starts for " to
2@ like the earlier for loop variable did. #e again make sure that the
maincounter variable does not exceed the number of bytes stored in the
uncompressedbyte variable. The rst string variable is nothing but a series of
bytes in hex that we concatenate together.

This is because the hash directive etc show us a series of bytes. The second if
statement checks whether the byte is a printable ascii byte or it. 0f it is, then
244260235.doc 87 od 541
it gets concatenated as its character value using a cast as before. 0f not, the
disassembler shows it as a dot.

/ormally most table displays by ildasm have the 2@ bytes in the rst column
and then the printable ascii characters or a dot following comments. ;s this
sort of display is very common, we have created a function to handle it. #e
as before increment maincounter but when we leave the for loop we do not
set it back as we did earlier.

;fter this for loop we have a if and else where the if true if we have run out of
bytes to display which will happen once only when the two variables
maincounter and uncompressedbyte are e1ual and we have left the for
statement due to the rst if being true. Thus lets focus on the else statement
rst.

;ll that we do in the else is rst look at value of the noascii variable. 0f it is
true, we simply add to rst string a space followed comment and the value of
the variable second string. The ildasm program says that it will display the
comments and the printable ascii characters if and if there is at least one
printable ascii char among the ones it is trying to display.

0f there are all non printable it will display none. 0f you recall the variable
noascii is false and it becomes through only if it meets one printable ascii.
This is why we needed a special for just to tell us whether to display the
variable secondstring along with the contents.

The guy who wrote ildasm felt that a display with all dots does not loop
pretty. 9emember this applies to a single line being displayed only. #e then
use the #rite?ine function to display the variable rststring. #e have reached
the end of our tether and also the end of the main while.

Thus we have to write out a series of spaces so that the next time we come
to the above #rite?ine we display everything one below the other neatly laid
out. The second parameter is the number of spaces that we need to write out
and we use the startingspaces parameter to the -reate3paces function. The
vertical position where the table starts for the moment is a constant as the
name of the directive does not change nor are there any extra spaces before
the directive name.

This only needs to be written out for all line but the last and hence when the
two variables maincounter and uncompressedbyte are not e1ual. ?ets come
back to what happens when we reach the last line to be displayed.

?et us reiterate. #e are here in the if statement because the last line has to
be displayed. #e rst need to know how many characters will be written on
the lat line. The variable leftovers will tells us how many bytes will be
displayed on this th last line.

;s an example if we have to display 2H bytes in all, the rst line will display
2@ bytes and as leftovers will be B, the last line will have B characters. #e
244260235.doc 88 od 541
rst take the normal case where the number of characters to be displayed on
the last line is not 2@.

#e rst subtract by 2! to get the number of characters that we have not
displayed on this last line. #e then add a close bracket to the variable
rststring.

#e need this new number in leftovers as it lets us calculate how many spaces
we need to reach the end of the line so that we can display the comment sign
below the earlier comment sign. >ach number displayed takes up A bytes and
one for the road is how we calculate the number of spaces to be placed.

#e also look at the noascii variable which if true means that we have to place
the spaces and this will followed by the string. 0f false i.e. no printable ascii
chars, we simply place a single space. /ow lets look at the else which kicks in
if the number of characters on the last line is exactly 2@.

#e as before concatenate the close bracket like before and now decide
whether to concatenate a space or not. The third parameter is a true or a
false. 0f it is true, which is not so in our case and the number of bytes to be
written out is less than 2@ or one line, at times we have to add a extra space.

The last line of the else does nothing ad can be ignored. >ven we forgot why
it was placed there. 8inally the same if statement again and we placed it out
of the earlier if for reasons of clarity.

#e once again check the noascii variable and if true we concatenate the
comments and the contents of the variable secondstring as we did earlier. 0f
you look hard enough we really do not need this if statement as it duplicates
what the else does.

7ut hey we never said code we wrote would win a competition. This is the
end of a large program where we spend a lot of time in simply displaying data
in a table.

,rogram2".csc
int spacesforrest = B4
int spacesfornested4

public void abc&string 56 args'
%
9ead,>3tructures&args'4
<isplay,>3tructures&'4
9eadand<isplay0mport;dressTable&'4
9eadand<isplay-?9Keader&'4
9ead3treams<ata&'4
8illTable3i$es&'4
9eadTables0nto3tructures&'4
<isplayTables8or<ebugging&'4
9eadand<isplay:Table8ixup&'4
244260235.doc 89 od 541
9eadand<isplay>xport;ddressTableUumps&'4
<isplayModule9efs&'4
<isplay;ssembley9efs&'4
<isplay;ssembley&'4
(

public void <isplay;ssembley&'
%
if &;ssembly3truct.?ength == 2'
return4
-onsole.#rite?ine&G.assembly *VB""""""2V* %"(G ,
Met3tring&;ssembly3truct526.name''4
-onsole.#rite?ine&G%G'4
<isplay;ll3ecurity& B , 2'4
if & ;ssembly3truct526.publickey ^= "'
%
-onsole.#rite&G .publickey = &G'4
<isplay8ormatted-olumns&;ssembly3truct526.publickey ,2@ , true'4
(
if & ;ssembly3truct526.Kash;lg0d ^= "'
-onsole.#rite?ine&G .hash algorithm
"x%"(G,;ssembly3truct526.Kash;lg0d.To3tring&GxHG''4
int rev = ;ssembly3truct526.revision4
if & rev F "'
rev = @!!A@ D rev4
-onsole.#rite?ine&G .ver %"(+%2(+%B(+%A(G , ;ssembly3truct526.major,
;ssembly3truct526.minor,;ssembly3truct526.build,rev'4
if & ;ssembly3truct526.culture ^= " '
%
-onsole.#rite&G .locale = &G'4
int index = ;ssembly3truct526.culture4
int cnt = "4
while & strings5index6 ^= "'
%
-onsole.#rite&G%"( "" G , strings5index6.To3tring&GWG''4
indexDD4
cntDD4
(
-onsole.#rite&G"" ""G'4
-onsole.#rite&G 'G'4
int nos = @C J &2! D cntV@ D @'4
-onsole.#rite&-reate3paces&nos''4
-onsole.#rite&G** G'4
index = ;ssembly3truct526.culture4
while & strings5index6 ^= "'
%
-onsole.#rite&G%"(.G , &char'strings5index6'4
indexDD4
(
-onsole.#rite?ine&G..G'4
244260235.doc 90 od 541
(
-onsole.#rite?ine&G(G'4
(
public void <isplay;ll3ecurity &int tabletype , int tableindex'
%
if &<ecl3ecurity3truct == null'
return4
for & int ii = 2 4 ii F <ecl3ecurity3truct.?ength 4 iiDD'
%
int coded = <ecl3ecurity3truct5ii6.coded4
int table = coded X "x"A4
int row = coded )) B4
if & &table == tabletype XX row == tableindex ' '
%
string returnstring4
if & tabletype == B'
returnstring = -reate3paces&B '4
else if & tabletype == "'
returnstring = -reate3paces&spacesforrest D spacesfornested'4
else
returnstring = -reate3paces&spacesforrest DB D spacesfornested'4
returnstring = returnstring D G.permissionset G 4
string actionname = Met;ction3ecurity &<ecl3ecurity3truct5ii6.action'4
returnstring = returnstring D actionname 4
returnstring = returnstring D G = &G 4
-onsole.#rite&returnstring'4
int index = <ecl3ecurity3truct5ii6.bindex4
if & index == "'
-onsole.#rite?ine&G'G'4
else
<isplay8ormatted-olumns&index ,returnstring.?ength, false '4
(
(
(
public string Met;ction3ecurity &int actionbyte'
%
string returnstring = GG4
if & actionbyte == 2'
returnstring = Gre1uestG4
if & actionbyte == B'
returnstring = GdemandG4
if & actionbyte == A'
returnstring = GassertG4
if & actionbyte == C'
returnstring = GdenyG4
if & actionbyte == !'
returnstring = GpermitonlyG4
if & actionbyte == @'
returnstring = GlinkcheckG4
if & actionbyte == L'
244260235.doc 91 od 541
returnstring = GinheritcheckG4
if & actionbyte == H'
returnstring = Gre1minG4
if & actionbyte == I'
returnstring = Gre1optG4
if & actionbyte == 2"'
returnstring = Gre1refuseG4
if & actionbyte == 22'
returnstring = GprejitgrantG4
if & actionbyte == 2B'
returnstring = GprejitdenyG4
if & actionbyte == 2A'
returnstring = GnoncasdemandG4
if & actionbyte == 2C'
returnstring = GnoncaslinkdemandG4
if & actionbyte == 2!'
returnstring = GnoncasinheritanceG4
return returnstring4
(
(

e.il
.assembly $$$
%
.ver 2+B+A+C
.hash algorithm ABLLA
.permissionset assert = & 2 B A @! @! @L @H @I L" L2 LB LA B" B2 BB BA BC
B!'
(
.class $$$
%
.method public static void adf&' cil managed
%
.entrypoint
(
(

Output
.assembly *VB""""""2V* $$$
%
.permissionset assert = &"2 "B "A @! @! @L @H @I L" L2 LB LA B" B2 BB BA
** ...eeghip1rs ^G.
BC B! ' ** `[
.hash algorithm "x""""H""!
.ver 2+B+A+C
(

?et us now display the actual ;ssembly table by calling the function
<isplay;ssembley in the abc function. #e are following the same order that
ildasm follows. ;s always we check whether the ;ssembly3truct array has
244260235.doc 92 od 541
been created or not and then decide to exit or not. 8rom none on we will
ignore this family of error checks.

The rst directive that we discuss in the assembly directive is all about
security. #e use a function <isplay;ll3ecurity to display the security
directives and pass the function two parameters B and 2. The security
directive called permissionset can be placed in lots of other places and hence
we call this function many times.

7ut before we look at what it does, most of what we did with the assembly ref
or assembly extern directive is repeated here also. The only diference is that
the third parameter to the <isplay8ormatted-olumns columns is true and not
false as before.

The rst is the publickey directive that is the same along with the ver
directive. There is a hash algorithm directive that simply takes a number
representing the algorithm that we use. ; assembly is made up of many les
and all the les must use the same hashing algorithm to calculate the hash
value.

There is only one value that can be specied by a conforming implementation
that is the algorithm 3K;2 that has a value of ABLLB. 0t makes sense to
specify a single value but we used a diferent value and the system did not
bother to check.

The culture code is the same as in the assembly extern case and we were to
tired to convert it into a function. The problem with compilers is that they
allow la$y practices like what we have done to continue. #e would have
preferred if the compiler refused to compile our code saying that we rst
place the above code in a function. 0ts like my car refusing to move if the seat
belts are not worn.

The key function in the above code is the one that displays the security or the
function <isplay;ll3ecurity. This function has two parameters, one the
tabletype that has nothing to do with the metadata tables and the second the
table index. ;ll the security attributes are stored in a table called
<ecl3ecurity.

This table has a eld called coded that as the name suggests is a coded index
eld and the specs call the eld parent. The directive permissionset can
appear in one of three places, a type def or a method or a assembly. The rst
two bits are assigned for the table and the remaining for the row within the
table.

This coded index is called the HasDeclSecurity coded index. 7y shifting the
bits two to the right we have in the variable row the actual row number. #hen
we called the function <isplay;ll3ecurity, the tabletype was B as this is value
of the coded index for the assembly table and the tableindex had a value of 2
as this is a row number and the assembly table can have only one row.

244260235.doc 93 od 541
8or the method table, it will stand for an index for the method that should
carry the security directive or the method in which we wrote the
permissionset directive. Thus it is the if statement checks for the right table
and row to gure out whether the permissionset directive should be placed
here or not.

The tabletype parameter has another role to play. <epending upon its value
which represents a coded index, we decide how many spaces the string
returnstring should have. The ;ssembly extern directive has no indentation
and hence the permissionset directive is always indented by two spaces.

#hen the tabletype is ", the value of the coded index is the type def table
and here the indentation is decided by the namespace and whether the type
is a nested type. The third table is the method table which has a coded index
value of 2. Kere the .method directive has to be indented by B.

The variables spacesforrest and spacesfornested will store for us the number
of indentations. This we will explain as we move along. ;s a reiteration, we
need to nd that row in the <ecl3ecurity table that has a coded index that
matches the ;ssembly, Type<ef or method table.

#e are passing as the second parameter the row which may contain the
permissionset directive. ;fter writing the directive permissionset we must
gure which action the directive pertains to. #e pass the action number
stored in the eld action to the function Met;ction3ecurity which returns the
action as a name.

This function simply checks whether the parameter actionbyte has a value
from 2 to 2!. These are the only values the action eld can have and
depending upon the value we return a certain string. Zou can not get a easier
function to write. The bindex eld is similar to the elds in the assembly
extern directive that point to a index in the blob heap.

#e make sure that the index into the blob heap is not $ero which means no
security and thus display the close bracket. #e use our good old
<isplay8ormatted-olumns function to display the security in a tabular format.

Two 1uestions come to our mind, what is the permissionset attribute all about
and where did we get the action eld value from. The documentation as of
the moment does not give us all the action eld values.

#hat we did was write out the permissionset directive in a il le, used ilasm
to give us an exe le and then ran both the original ildasm program and our
disassembler. 0n our disassembler we display the value of the parameter
actionname which gives us a number and the ildasm program gives us a
name.

Tedious, but we have no choice as the specs do not give us all the names and
number combinations. #e ran our disassembler through !""" les that we
keep boasting about but yet we must have missed out certain action eld
244260235.doc 94 od 541
values. #e did the unthinkable. #e ran a le spying program that we
downloaded from the site sysinternals.com.

This program told us all the les that ildasm.exe opens up. #e scanned these
les though a he editor and reali$ed that the disassembler itself ildasm.exe
had loads of strings in it. #e wrote out these strings in a separate le.

#e then searched for the string assert and this is how we gured out that the
action eld has 2! possible values. 0ldasm.exe is a program written in -*-DD
and all the output the program generates must use strings stored in an array.
The contents of these arrays is what tells us all possible options for every
directive and or instruction. Tell us if you know of a better way.

The .permissionset directive is a way to attach declarative security attributes
to a typedef, assembly or a method. The bytes displayed after the action
value are a WM? based representation. These are meant to specify a
seriali$ed version of the security settings.

,rogram22.csc
public string /ame9eserved &string name'
%
if & name.?ength == "'
return name4
if & &byte'name5"6 == L '
return GabbaaG4
if & &byte'name5"6 == H '
return GabbbaG4
if & &byte'name5"6 == I'
return GabbtaG4
if & &byte'name5"6 == 2"'
return GabbnaG4
if & &byte'name5"6 == 22 '
return GabbvaG4
if & &byte'name5"6 == 2B '
return GabbfaG4
if & &byte'name5"6 == 2A '
return GabbraG4
if & &byte'name5"6 == AB '
return Ga aG4
if & name == GaG'
return GabbaaG4
if & name == GbGG'
return GabbbGaG4
if & name.?ength == B XX &byte'name526 == L '
return GaG D name5"6 D GbbaaG4
if & name.?ength == B XX &byte'name526 == H '
return GaG D name5"6 D GbbbaG4
if & name.?ength == B XX &byte'name526 == abta '
return GaG D name5"6 D GbbtaG4
if & name.?ength == B XX &byte'name526 == abna '
244260235.doc 95 od 541
return GaG D name5"6 D GbbnaG4
if & name.?ength == B XX &byte'name526 == abva '
return GaG D name5"6 D GbbvaG4
if & name.?ength == B XX &byte'name526 == abfa '
return GaG D name5"6 D GbbfaG4
if & name.?ength == B XX &byte'name526 == abra '
return GaG D name5"6 D GbbraG4
if & name.?ength == B XX &byte'name526 == aGa '
return GaG D name5"6 D GbbbGaG4
if & name.?ength == B XX &byte'name526 == abaa '
return GaG D name5"6 D GbbbaaG4
if & name.?ength )= 2 XX name5"6 == abaa XX name5name.?engthJ26 == abaa '
return name4
int i = "4
while & i F name.?ength '
%
if & &name5i6 )= a"a XX name5i6 F= aIa' XX i == " '
return GaG D name D GaG4
if & name5i6 )= 2 XX name5i6 F= A2 '
return GaG D name D GaG4
if & name5i6 )= 2BL ]] name5i6 == aFa ]] name5i6 == aDa ]] name5i6 == aJa ]]
name5i6 == a a ]] name5i6 == abaa '
%
int ind = name.0ndexOf&GaG'4
if & ind ^= J2'
name = name.0nsert&ind , GbbG'4
return GaG D name D GaG4
(
iDD4
(
string 56 namesarray =
%GvalueG,GblobG,GobjectG,GmethodG ,GinitG,G.initG,GarrayG,Gpolicy.B.".myasmG,Gpo
licy.B.".myasm.dllG,GaddG, GassemblyG, Gseriali$ableG, GlcidG , GstreamG ,
GlterG , GhandlerG , GrecordG, Gre1uestG, GoptG, GclsidG, GhresultG, GcfG, GcustomG
, GtoG, GretG, GimportG, GeldG, GsubG, GanyG, GpopG, GnalG, GremG , GstorageG,
GerrorG, GnestedG, GilG , GinstanceG, GdateG, GiunknownG, GliteralG, GimplementsG,
GunusedG, GnotG , GalignmentG, GunicodeG, GbstrG, GautoG, GretvalG, GvariantG,
GorG, GfamilyG, GarglistG, GbrG, GwrapperG, GdemandG, GfaultG, GcallG ,
GalgorithmG, GnativeG, GxedG, GstringG, GcharG , GdecimalG, GEoatG , GintG,
GvoidG, GpinnedG, GdivG, GtrueG , GfalseG, GdefaultG, GabstractG , G_G , GcG, G%G,
G]G , G(G, G\G , G^G , G.G , G&G, G[G, GJG , G'G, G+G , G4G, G=G, G)G, GassertG,
Gsynchroni$edG, GruntimeG, GwithG, GclassG, GnewarrG, GldobjG, GldlocG, GstobjG,
GstlocG, GstargG, GrefanyG, GldelemaG, GldargaG, GldargG, GinitobjG ,
GboxG ,GdemandG , GldEdG, GldEdaG, GldsEdG, GldsEdaG, GvectorG, GinG , GoutG,
GandG, GintHG, GxorG , GasG, GatG, GstructG, GnallyG , GinterfaceG , G.-,mainG,
GenumG, GvarargG, GmarshalG,
Gpolicy.2.".Math?ibraryG,Gpolicy.2.".Math?ibrary.dllG,GnalG,
G3ystem.#indows.8orms.<esign.B!@TB.bmpG ,
G3ystem.#indows.8orms.<esign.B!@T2.bmpG(4
for & int ii = " 4 ii F namesarray.?ength 4 iiDD'
244260235.doc 96 od 541
%
if & name == namesarray5ii6'
%
int ind = name.0ndexOf&GaG'4
if & ind ^= J2'
name = name.0nsert&ind , GbbG'4
return GaG D name D GaG4
(
(
return name4
(

string dummy = /ame9eserved&Met3tring&Module9ef3truct5ii6.name''4
-onsole.#rite?ine&G.module extern %"( *V2;%2(V*G , dummy ,
ii.To3tring&GW@G''4

-onsole.#rite?ine&G.assembly extern *VBA%"(V* %2(G, i.To3tring&GW@G' ,
/ame9eserved&Met3tring&;ssembly9ef3truct5i6.name'''4

-onsole.#rite?ine&G.assembly *VB""""""2V* %"(G ,
/ame9eserved&Met3tring&;ssembly3truct526.name'''4

e.il
.assembly a``vijayJ2a
%
(
.class adda
%
.method public static void adf&' cil managed
%
.entrypoint
(
(

.assembly *VB""""""2V* a``vijayJ2a
%
.ver "+"+"+"
(

3hakespeare once said #hatPs in a name. ; rose by another name will smell
just the same. 8or us, however a name is very important for a simple reason.
0n -. the word ldarg may not be a reserved word but it is so in 0?. The ,erl
programming may not treat the word class as a reserved word.

;t the end of the day, it is immaterial whether a programming treats a word
as reserved or not, what is material is whether 0? treats it as a reserved word
or not. #e are allowed to use a reserved word as a valid identier in 0? but
with on proviso. 0t has to be enclosed in single inverted commas, if and only if
it is a reserved word.

244260235.doc 97 od 541
#e have been using names already in three diferent places, for assembly
and assembly and module externPs. 0f the name is reserved by 0? standards,
we have to place it as said before in single and not double inverted commas.

Thus a name that has a minus sign in it is a reserved word in 0? and hence
the name of the assembly has to be in single inverted commas or the
assembler gives us an error. This is one type of reserved word that is not
allowed to contain certain characters. The second are words that form part of
the 0? vocabulary like ldarg, class etc.

The third case is where we use the unprintable ;3-00 chars like number L as a
name. 0f we use the #rite?ine function, we will not see a legible output and
the number 2" will instead give us a new line. These special characters have
to be handled separately.

#hy would anyone in their right mind use a enter a name is beyond us but
we came across scores of les that for some reason chose to use the
unprintable ;3-00 chars that have a value of up to A2. Thus we rst check if
the string has a length of " and if true, we simply return the empty string.

Then we check for some of the unprintable ascii chars and return a bn instead
of the unprintable character when for say the value is 2". Kowever the bn will
be read as a enter by all and sundry and we need to escape the black slash
by putting one more. ;ll this must be protected by placing them in single
inverted commas.

;ll this assumes that the rst array member is a unprintable character. ;t
times the second member is and hence the next series of if statements take
care of just this eventuality. #e should have instead used a loop to take care
of the general case but in our minds asked why should anyone in the world
use such unprintable characters for names.

0f they insist, use someone elsePs disassembler. 8or the these series of if
statements we are checking the second member of the array name526. 0f the
string is only one char or byte large we will have an exception thrown as we
are moving beyond the bounds of the array. Kence the check for the length of
the string being greater than B.

#e rst check if the name is a single or double inverted comma. Once again
we ask why would somebody chose such a name. 0t seems that they are such
intelligent people in the world and hence we have to write such code. 8or a
single inverted comm. #e have to simply use two back slashes but the
double is more complex.

Kere we have to use three backslashes. The rst two become a single
backslash and the third escapes the double inverted commas as we are in
double inverted commas. The next if statement checks whether the entire
string is already enclosed within single 1uotes. This check is needed if we are
by mistake calling this function /ame9eserved twice.

244260235.doc 98 od 541
Thus we rst check the rst and last array member. 0f the length of the string
is 2, then both the rst and last member are the same which is the single
inverted comma. 0f you have been paying attention, we had checked for a
single inverted comma earlier. Thus to be politically correct we should check
for string with a length of B or more.

7ut hey, we know that this book will win no pri$e for the best code. #hat
matters is that it works and you understand why. /ow comes the meat. There
are certain special cases where if we nd some special characters in the
string, we need to 1uote the string.

Thus we check character by character of the string and use variable 0 for the
array ofset. 0f the rst character is a numeric digit, then the string needs to
be 1uoted or else an array results. 9emember this applies to only the rst
character of the string.

The second rule is that if the string contains a non printable ;3-00 char, then
1uote the string. Once again the special ones that re1uire special handling we
have taken care of earlier using dedicated if statements. #e could have used
the same if statements here also.

8inally from the printable ;3-00 set chars like the less than sign, minus, plus ,
space etc are reserved and hence need to be 1uoted. ;lso if the string
contains chars beyond 2BL, then also the entire string has to be 1uoted. This
check again is for individual chars. There is one small problem.

0f ever the string that is to be single 1uoted also contains a single 1uote, we
have a problem as this single 1uote has to be escaped using the backslash.
3o before we single 1uote the string, we check whether it has a single 1uote
using the 0ndexOf function which returns e2 if the string is not present.

>lse it returns where the search string in the actual string. Rnowing this
number we sue the 0nsert function to actually put a backslash at that point.
The backslash has to be also escaped and the 0nsert function will insert this
backslash where the single inverted comma was earlier and move the rest of
the string to the right.

This will increase the si$e of the string by one. 8inally we have a huge array
called namesarray that we ll up with a list of reserved names from the 0?
specications. #e in a for loop check we check whether any of the array
members is e1ual to the string called name passed as a parameter.

0f it is a match, we check for the single 1uote problem mentioned earlier. Zes
you are right, we should have had a function to the check as we are repeating
the same code. To be honest, we did not write the code again, we simply
block copied it. #e nally 1uote the string if a match is found.

#e learned some interesting things along the way. ; dot or two dots or full
stops is not always a reserved. Kaving a extension of bmp is not reserved and
also having a underscore and a dot and a bmp extension is not reserved. 7ut
244260235.doc 99 od 541
a name like the last two is reserved. MO gure out and remember what
3hakespeare said about names.

,rogram2B.csc
public void <isplay8ileTable &'
%
if & 8ile3truct == null '
return4
for & int ii = 2 4 ii F 8ile3truct.?ength 4 iiDD'
%
-onsole.#rite?ine&G.le *VB@%"(V* %2(%B(G , ii.To3tring&GW@G' ,
Met8ile;ttributes&8ile3truct5ii6.Eags' ,
/ame9eserved&Met3tring&8ile3truct5ii6.name'''4
int table = entrypointtoken )) BC4
if & table == "xB@ '
%
int row = entrypointtoken X "x""fff4
if & row == &ii' '
-onsole.#rite?ine&G .entrypointG'4
(
if & 8ile3truct5ii6.index ^= "'
%
-onsole.#rite&G .hash = &G'4
int index = 8ile3truct5ii6.index 4
<isplay8ormatted-olumns&index ,2A , false'4
(
(
(
public string Met8ile;ttributes&int leEags'
%
string returnstring = GG4
if & leEags == "x""'
returnstring= GG4
if & leEags == "x"2'
returnstring= Gnometadata G4
return returnstring4
(

e.il
.le aa.exe
.le nometadata bb.exe
.le nometadata cc.exe .hash = & 2 B A'
.le dd.exe .hash = & 2 B A' .entrypoint
.class $$$
%
(

Output
.le *VB@"""""2V* aa.exe
.le *VB@"""""BV* nometadata bb.exe
244260235.doc 100 od 541
.le *VB@"""""AV* nometadata cc.exe
.hash = &"2 "B "A '
.le *VB@"""""CV* dd.exe
.entrypoint
.hash = &"2 "B "A '

The above program displays the directive .le. 0n the ./et world, we start with
the concept of a module. >very le has to have only one entry in the module
table. ;n assembly is the next level of aggregation and many modules can
make up an assembly. Thus there is a one to many relationship between
modules and assemblies.

Kowever an assembly can be made up of a number of other les like text
les, documentation les or what have you. There must be some directive
that tells the assembly about the existence of these le. 0n the shipping world
a manifest is a list of containers in the ship and thus the le directive is used
to add the le name to the assembly manifest.

>very le that is added to the assembly manifest does not have to be a .net
executable and have metadata. Thus the nometadata option indicates that
this le has no metadata and its format is not known to us. 0t may be
considered as a pure data le. The point is that no one checks whether the
le name exits or not at the time of assembly.

Thus the attribute nometadata tells us that the le name following is not a
module and does not adhere to the ./et specications. #hen ever we create
the smallest ./et executable, the directive .entrypoint has to be present in a
function. This is mandatory as otherwise there is no way of knowing which is
the rst function to be executed.

Thus the .entrypoint directive tells us that this le is part of a multi module
assembly and also contains the starting function. #hen we move to this le,
we must see a static function with the entrypoint directive.

The assembly does not go out and do the check, but prevents you from
creating a function in this module with the .entrypoint directive. The hash
option is optional and if we do not specify it, the assembly linker that is a
program called al will automatically calculate it during creation of the
assembly.

Thus it may be optional at assemble time for ilasm, but at runtime this hash
value must be present. Thus if we do not create one, it has to be present at
runtime. #e have a simple philosophy, if someone else does the work for us,
why should we. The designers of the ./et world have created a table just to
store the .le directive.

#e loop through all the table entries and reali$e that this table has only three
elds. The rst is a bitmask of type 8ile;ttributes that can have only two
values in spite of being four bytes large. ; bitmask is a entity where the
244260235.doc 101 od 541
value of the byte is unimportant, it is the individual bits that carry
information.

The le directive has only one option, nometadata. Thus a value of $ero
implies that it is a resource le and hence we use the function
Met8ile;ttributes to return a null. ; value of 2 means that the option
nometadata was used and hence we return the string nometadata.

The second eld is called name and is a ofset into the strings heap and the
last value is a index into the blob heap for the hash value. #e rst check
whether this eld is no $ero and if in the aSrmative, we use the
<isplay8ormatted-olumns function as before to display the hash value.

The name eld cannot be null and it cannot be a absolute path name. 0ts
length is restricted by the value stored in M;WT,;TKT/;M>. There are also
some reserved names like con, aux, lpt, null and com that cannot be used as
they represent device names. ;lso we cannot use numbers or special
characters like a ` or a colon.

7ut, ilasm does not do these error checks for some reason. ?ike always
duplicate rows are an theoretically an error that nobody checks. ;lso if the
name of the le is in the ;ssembly table, it means that the module holds the
manifest, the same name cannot appear in the le table also.

The le table being empty means that we have a single le assembly. This
also means that the >xported Type table should also be empty. ; long time
back we came across a instance variable called entrypointtoken whose value
was set by the -?9 header.

This value is a like and unlike a coded index where the last and not the rst H
bits give us the table that contains the function for the entrypoint token. #e
right shift this variable by BC bits and if we get a value of B@, it means that
the entrypoint function lies in some other le.

#e then take the rst BC bits that contain the row in the le table that
contains the entrypoint token. 0f this value matches the loop index, we
display the words entrypoint.

Tutorial on ;ssemblies, Modules, 8iles and other such aliens from outer space.

p.il
.class $$$
%
.method public static void abc&'
%
.entrypoint
ret
(
(

244260235.doc 102 od 541
?etPs start at the very beginning. #e create a le called p.il and assemble it
using the program ilasm to get a executable p.exe. #e have done this in the
past is your immediate response. There is no way we could disagree. #hen
we run the program, we get an error that says that the le p.exe was
expected to contain a assembly manifest.

This is another way of saying that we have no directive called assembly. Thus
every executable le has to have a assembly directive otherwise we cannot
execute it. There is no physical entity called a manifest stored anywhere in
the le. This concept of a manifest is logical and is created using rows from
diferent metadata tables.

Thus if we have no row at all in the ;ssembly table, we get the above error. ;
manifest is a entity created by the runtime loader that species all the les
an assembly is made up of. #e must reiterate again that there is no physical
table that stores the assembly it is computed at run time and is made up of a
list of les.

.assembly aa
%
(
.class $$$
%
.method public static void abc&'
%
.entrypoint
ret
(
(

0n the above program we have added an assembly called aa and left the
declaration blank as they are all optional. ;fter reassembling the program
and running we get no error as we have a manifest or assembly directive
called aa. 0n practical terms, you should always have the assembly name and
the le name the same as we will later demonstrate.

The reason being, the assembly directive has no le option that species the
name of the physical le. Thus it is assumed that the le name will either be
name of assembly with a dll or exe extension added. Therefore the assembly
or manifest name should not have an le extension ever.

.assembly aa
%
(
.assembly bb
%
(
.class $$$
%
.method public static void abc&'
244260235.doc 103 od 541
%
.entrypoint
ret
(
(

#ith the assembly directive we can have one and only one. #e cannot have
$ero or two. This makes sense as the assembly name is what we refer to
when we want to access code from other assemblies. More on this later.

; module directive if missing is not a problem as mentioned before as the
assembler adds one automatically for us with the same name as the name of
the le and the words dll in caps as the extension. ?ike an assembly we
cannot have two module directives. Zou will agree wit us a little later why an
assembly directive does not get added on.

p2.il
.assembly p2
%
(
.class public yyy
%
.method public static void p1r&'
%
ret
(
(

p.il
.assembly aa
%
(
.assembly extern p2
%
(
.class $$$
%
.method public static void abc&'
%
.entrypoint
call void 5p26yyy++p1r&'
ret
(
(

#e have now created two les p.il and p2.il. #e rst assemble p2.il to a <??
and not a exe le as ilasm *<ll p2.il. 0t does not really matter whether we
make it into a <?? or a exe le, we chose the dll option just to be diferent
and have a change of scene. 0n this le we have a class yyy that in turn has a
static function called p1r.
244260235.doc 104 od 541

#e would like the world to call this function. #e have also called the
assembly p2, which is the same name as the name of the physical le. #e
then move on the le p.il which will be compiled to a executable le and
hence the assembly directive that does not have the same name as the
physical le.

To call a function, we use the call instruction and rst specify the return type
that is void in this case. Then we specify the function to be called. This gets a
little complex. 3tarting from the left we specify not the parameters in
brackets but the data types of the parameters.

0ts our job to place the parameters on the stack as we shall see how to
accomplish in the next program. #e then state the function name i.e. p1r
followed by the class*namespace name. 8or some reason the delimiter for
class*namespace is a dot but for class*function it is a colon.

<onPt ask us why, as we believe the guy was allergic to too many dots. 8inally
in s1uare brackets we place the name of the assembly that contains the code
of the class yyy. This is assembly p2 and hence we have to use the assembly
extern directive. 0f we do not we get a assemble error that tells us that we
have a undened assembly ref.

#e are only allowed to put the name of a assembly in the s1uare brackets
and not a le or a module or any such entity. 3ome basic 1uestions that come
to our minds. #e change the function name from p1r to p1r2 and even
though the function name is not present in the class yyy, ilasm does not
actually check the le p2.dll.

#hen we run the program p.exe, an exception gets thrown at us that tells us
that the method yyy+p1r2 is not found. Thus it is our responsibility to check
that the function is available. ;ll that ilasm checks is that whatever we use in
s1uare brackets is backed up by a assembly ref directive.

0lasm does not even check for the existence of such a le. #e delete the le
p2.dll and when we now reassemble, we do not get an error. #e now run the
program p and now have a leJnotJfound exception thrown at us. The error
message clearly tells us that the loader rst checks for p2.dll and then p2.dll
again in a subJdirectory p2.

0t then checks for p2.exe and nally p2.exe in subJdirectory o2. 8or some
reason the loader prefers looking for a dll over a exe. /ow you know why the
name of the assembly should match the name of the physical le. #e used
the assembly name in our call instruction and there is no mapping from
assembly ref to physical le and thus please keep the two the same.


p.il
.assembly aa
%
244260235.doc 105 od 541
(
.assembly extern mscorlib
%
(
.class $$$
%
.method public static void abc&'
%
.entrypoint
ldstr GhiG
call void 5mscorlib63ystem.-onsole++#rite?ine&string'
ret
(
(

0n the above program we simply call the static function #rite?ine from the
class -onsole in the 3ystem namespace. ;s the #rite?ine function in this
case takes one string as a parameter, we place it within the round brackets.
To put a string on the stack we use the ldstr instruction and there are similar
instructions for other data types.

#e rst put the parameters on the stack and then call the function. This
function is in the assembly mscorlib and thus we have a assembly reference
to it. The code for this class is obviously in the le mscorlib.dll.

#hen we run the program it displays hi. 0n -., the compiler actually checks
whether the le mscorlib.dll has a function #rite?ine that accepts a string as
a parameter and is present in the -onsole class. ;ll these checks have to
done by you and me. 0f we do not, as said above we get an exception thrown
at runtime.

p.il
.assembly aa
%
(
.assembly extern p2
%
(
.class $$$
%
.method public static void abc&'
%
.entrypoint
call void 5p26yyy++p1r&'
ret
(
(

p2.il
.assembly p2
244260235.doc 106 od 541
%
(
.class public yyy
%
.method public static void p1r&'
%
.entrypoint
ldstr Gp2.exeG
call void 5mscorlib63ystem.-onsole++#rite?ine&string'
ret
(
(

7efore we run the above set of programs, delete the le p2.dll rst. ;ll that
the p.il le does is calls the function p1r from the assembly p2. #e next
compile p2.il to an exe and we get p2.exe. #hen we run p, it actually calls
the above p1r function as the assembly name specied is p2. #e then
replace the above p2.il with the one below.

p2.il
.assembly p2
%
(
.class public yyy
%
.method public static void p1r&'
%
ldstr Gp2.dllG
call void 5mscorlib63ystem.-onsole++#rite?ine&string'
ret
(
(

The two changes made are that we have removed the entrypoint directive
and also changed the string to be displayed. #hen we assemble to a dll, and
then run p, the loader rst checks for the dll and as it nds it, it executes p1r
from the dll and ignores the exe le.

p2.il
.assembly p22
%
(

#e change the assembly name in p2.il to p22 and the assembler gives us no
errors but the loader rst loads the le p2.dll and then immediately looks in
the ;ssembly table for the single roe to contain the name p2. 0n our case it is
p22 and hence an exception gets thrown. 3o we hope that from now on you
will always keep the assembly name the same as the physical le name
minus the extension please.

244260235.doc 107 od 541

p.il
.assembly aa
%
(
.assembly extern p2
%
(
.class $$$
%
.method public static void abc&'
%
.entrypoint
call void 5p26yyy++p1r&'
call void 5p26xxx++xy$&'
ret
(
(

p2.il
.assembly p2
%
(
.le pB.dll
.class extern xxx
%
.le pB.dll
(
.class public yyy
%
.method public static void p1r&'
%
ret
(
(

pB.il
.class public xxx
%
.method public static void xy$&'
%
ret
(
(

The above example takes our understanding of assemblies on level further.
?ets start with p.il, the exe le. Kere we are calling two functions p1r and xy$
from the classes yyy and xxx respectively. ;lso these classes exist in a
assembly p2. 3o what you say, nothing new, read on.

244260235.doc 108 od 541
0n le p2.il, we have a assembly declaration with the same name p2. The only
problem is that we have a single class yyy with the static function p1r. There
is no code for the class xxx anywhere in this assembly. /ow turn your eyes to
le pB.il. Kere we have a function xy$ in a class xxx.

#e will compile both les to a dll and in some way we need to relate the two.
0f you look at the code in pB.il, there is no linkage with eth le p2.il. The way
we do it is place all the linkages in the assembly le or manifest. #e start
with the class extern directive that only declares is a class called xxx.

The le directive inside it tells us which le this class xxx will be found in. #e
cannot stop here as there has to be a corresponding global le directive at
the same time. These two le directives tell the manifest that this assembly
is now comprised of two les, p2.dll and pB.dll.

The le pB.dll contains the code of the class xxx. Thus when the assembly
p2.dll is loaded, the le pB.dll will also be loaded. This is how we can have
multiple les comprise an assembly. There is no explicit way of saying this le
belong to this assembly only. ; le can belong to as many assemblies as it
wants.

7y using the class extern along with the le directive twice, once to specify
which les are part of the assembly and the second one to specify which
classes belong to which le.

The .class extern needs the le directive because if we do not specify one,
the assembler does not know the name of the le that contains the code of
the class xxx. This le directive does not actually check for the existence of
the le at assemble time like always. 0f we remove this line as in.

p2.il
.class extern xxx
%
(

The assembler does not give us an error but an warning that says that the
xxx class is not added to the list of classes that the assembly is made up of.
Obviously we will get a runtime error as the class xxx is not around.

0f we remove the .le directive from the le p2.il, the assembler gives us a
error saying that there is no top level le directive.

,2.il
.assembly p2
%
(
.le pB.dll
.class extern xxx
%
.le pB.dll
244260235.doc 109 od 541
(
.class extern xxx
%
.le pA.dll
(
.class public yyy
%
.method public static void p1r&'
%
ret
(
(

pB.il
.class public xxx
%
.method public static void xy$&'
%
ldstr GpB.dllG
call void 5mscorlib63ystem.-onsole++#rite?ine&string'
ret
(
(

pA.il
.class public xxx
%
.method public static void xy$&'
%
ldstr GpA.dllG
call void 5mscorlib63ystem.-onsole++#rite?ine&string'
ret
(
(

The above example is to illustrate a simple point. The assembler does not do extensive error
checs. !e have t"o #iles$ p2.il and p3.il that contain the same class xxx and #unction x%&. 'n the
#ile p1.il$ "e have the same .class extern t"ice and "e (et no error. The second class extern re#ers
to a #ile p3.dll that does not have a #ile directive at the top level.

)o errors at all at assemble time "hich means that the assembler i(nores our indiscretions. *lso
at runtime the x%& method (ets called #rom p2.dll. +han(e the order o# the class externs and
"atch the assembler complain. ,emember the old ada(e bu% at %our o"n ris applies here also.
)o helpin( hand #rom the assembler. )o hand holdin( also.

* assembl% and a module lets us (roup constructs to(ether and each pla% a di##erent role in the
.)et "orld. * set or a (roup o# #iles is "hat "e call an assembl%. 't is the abstract entit% that "e
call a mani#est that eeps trac o# all the #iles present.

244260235.doc 110 od 541
The assembl% table onl% store #or us the -ersion$ name$ culture and securit% re.uirements that "e
have not touched upon %et. The assembl% mani#est must eep trac o# not onl% the #iles but also
the cr%pto(raphic hash o# each #ile. The mani#est is computed #rom the metadata as mentioned
earlier.

The runtime also needs to no" "hich t%pes are de#ined b% other #iles and can be exported out o#
this assembl%. This is achieved usin( the class extern directive.

/bviousl% i# the t%pe is de#ined in the same #ile that has the assembl% directive$ its attributes lie
public$ private etc decide "hether it can be exported #rom this assembl% or not. !e could use
di(ital si(natures and a public e% to compute it "ith the 0ani#est.

The problem "ith di(ital si(natures is that #or some reason it did not set the Thames on #ire. The
ma1or di##erence bet"een assemblies and modules is that assemblies comprise modules. *
module consists o# a sin(le #ile that adheres to the rules o# the .net "orld. 't can either be a dll or
a exe #ile$ it must contain executable code.

There is one #ile in the list o# #iles that carries the assembl% directive and it is this #ile that (ives
us a list o# other modules that mae up the assembl%. The #ile that carries the assembl% directive
is also a module. '# the assembl% is a dll$ then "e do not need a #unction that has the entr%point
directive.

2o"ever i# it is a exe #ile$ then the #ile that contains the entr%point directive should also contain
the assembl% directive or mani#est. The concept o# namespaces ma% exist in pro(rammin(
lan(ua(e$ the +3' does not understand "hat "e are talin( about.

T%pe names are al"a%s speci#ied usin( the #ull name "hich is relative to the assembl% that "e
have created them in. '# the #ile is sa% a text #ile or a bmp #ile or a video #ile and does not contain
metadata$ "ill not have the module directive. 't is normall% not a common practice that man%
assemblies can re#er to the same module but nothin( stops us #rom doin( so.

The advanta(e is that once a dll is loaded into memor%$ the next assembl% that re#erences the dll
"ill not result in the dll bein( loaded a(ain in memor%.

4ro(ram13.csc
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
244260235.doc 111 od 541
=ispla%+lass:xtern58<
@

public void =ispla%+lass:xtern 58
9
i# 5:xportedT%pe;truct AA null8
return<
#or 5 int ii A 1 < ii B :xportedT%pe;truct.3en(th < iiCC8
9
strin( ss1 A DetT%pe*ttribute>la(s>or+lass:xtern5:xportedT%pe;truct6ii7.#la(s 8<
strin( ss A Det;trin(5:xportedT%pe;truct6ii7.nspace8 <
i# 5 ss.3en(th EA 08
ss A ss C F.F<
ss A ss C )ame,eserved5Det;trin(5:xportedT%pe;truct6ii7.name88<
int table A :xportedT%pe;truct6ii7.coded G 0x03<
int index A :xportedT%pe;truct6ii7.coded HH 2<
i# 5 index EA 08
9
+onsole.!rite5F.class extern IJ2790@JI 91@F $ ii.To;trin(5FK6F8 $ ss1 8<
+onsole.!rite3ine5ss8<
+onsole.!rite3ine5F9F8<
i# 5 table AA 08
9
+onsole.!rite3ine5F .#ile 90@IJ2691@JI F $ )ame,eserved5Det;trin(5>ile;truct6index7.name88 $
index.To;trin(5FK6F88<
@
i# 5 table AA 28
9
+onsole.!rite3ine5F .comt%pe L90@L IJ2791@JI F $
)ame,eserved5Det;trin(5:xportedT%pe;truct6index7.name88 $ index.To;trin(5FK6F88<
@
i# 5 :xportedT%pe;truct6ii7.t%pede#index EA 08
+onsole.!rite3ine5F .class 0x90@F$ :xportedT%pe;truct6ii7.t%pede#index.To;trin(5FK8F88<
+onsole.!rite3ine5F@F8<
@
@
@
public strin( DetT%pe*ttribute>la(s>or+lass:xtern5int t%peattribute#la(s 8
9
t%peattribute#la(s A t%peattribute#la(s G 0x07<
strin( visibilt%masstrin(AFF<
i# 5 t%peattribute#la(s AA 18
visibilt%masstrin( A Fpublic F<
i# 5 t%peattribute#la(s AA 28
visibilt%masstrin( A Fnested public F<
return visibilt%masstrin(<
@

e.il
.#ile mscorlib.dll
.#ile 11.dll
244260235.doc 112 od 541
.assembl% e
9
@
.#ile aa.dll
.#ile bb
.class extern o1
9
.#ile 11.dll
@
.#ile 11.dll
.class extern public 111
9
.#ile aa.dll
@
.class extern nested public
9
.#ile aa.dll
@
.class extern public lll
9
.class extern
@
.class extern public ooo
9
.class extern nnn
@
.class extern public ppp
9
.class extern 111
@
.class extern public mmm
9
.class extern ;%stem./b1ect
@
.class extern public ;%stem./b1ect
9
.#ile mscorlib.dll
@
.class extern public nnn
9
.#ile 11.dll
@
.class extern a1
9
.#ile 11.dll
.class 56

@
.class &&&
9
.method static void abc58
244260235.doc 113 od 541
9
.entr%point
ret
@
@

/utput
.assembl% extern IJ23000001JI mscorlib
9
.ver 0M0M0M0
@
.assembl% IJ20000001JI e
9
.ver 0M0M0M0
@
.#ile IJ26000001JI mscorlib.dll
.#ile IJ26000002JI 11.dll
.#ile IJ26000003JI aa.dll
.#ile IJ26000004JI bb
.class extern IJ27000001JI o1
9
.#ile 11.dllIJ26000002JI
@
.class extern IJ27000002JI public 111
9
.#ile aa.dllIJ26000003JI
@
.class extern IJ27000003JI nested public
9
.#ile aa.dllIJ26000003JI
@
.class extern IJ27000004JI public lll
9
.comt%pe LL IJ27000003JI
@
.class extern IJ27000006JI public ppp
9
.comt%pe L111L IJ27000002JI
@
.class extern IJ27000008JI public ;%stem./b1ect
9
.#ile mscorlib.dllIJ26000001JI
@
.class extern IJ27000009JI public nnn
9
.#ile 11.dllIJ26000002JI
@
.class extern IJ2700000*JI a1
9
.#ile 11.dllIJ26000002JI
.class 0x00000038
244260235.doc 114 od 541
@


'n this pro(ram "e simpl% displa% the directive class extern. >irst "e as al"a%s add a #unction
=ispla%+lass:xtern to the abc #unction. !e then in a loop iterate throu(h all the ro"s in the
:xportedT%pe table. The #irst thin( "e need to #i(ure out is the export attributes that can have one
o# t"o values$ public or nested public.

These speci#% the visibilit% or "ho all can see and thus use this t%pe. !e have a #unction
DetT%pe*ttribute>la(s>or+lass:xtern to do the 1ob #or us and return the strin( #or us. The
visibilit% attributes are stored in the #irst three bits. Thus "e bit "ise and the parameter passed b%
7 as the other bits speci#% other attributes.

!e then chec "hether the value is 1 or 2 "hich tells us "hether the public or nested public
attributes are on. !e then need the name or more precisel% the dotted name o# the extern t%pe.
This is stored in t"o #ields name and nspace.

!e #irst (et the name o# the namespace and then i# the namespace is present "e add a dot and
then add the name o# the class name. The next #ield coded is most important as it tells us "hat
directives are used in the braces. !e could i# %ou remember use .#ile and .class extern.

The coded #ield tells us the name o# the table and the ro" in that table. The ro" in the table must
be non &ero i# the directive class extern has to be displa%ed. !h% this is so "ill be explained in a
short "hile b% usin( a practical example.

Thus the entire directive "ill not be displa%ed i# the variable index is &ero even thou(h the dotted
name has a non null value. )o" that the index is non &ero "e then chec the table that the index
re#ers to. '# its value is &ero$ it re#ers to the #ile table$ 2 means that it re#ers to the :xported T%pe
table.

* value o# 1 means the *ssembl% ,e# table and #or some reason "e have #ound no "a% to
simulate this value. )o" "e tae each individual table that mae up the coded index. The #irst is
the #ile table "ith a value o# 0. 2ere "e simpl% use the index variable as a index into the
>ile;truct table and displa% the name o# the #ile stored there.

!e also need to displa% the ro" number o# the #ile table that is available to us in the index
variable. * table "ith number 2 means that "e have used the class extern directive and lets
understand it "ith a speci#ic re#erence to the class lll in the #ile e.il. 2ere "e had "ritten the class
extern directive "ith the name o# the class .

The class happens to be another class extern "ith a #ile directive. This (ets converted to a
directive comt%pe "hose explanation is no "here to be #ound. *lso ilasm does not understand
such a directive. *ll that "e no" is that "e have used a class name that is a class de#ined
some"here else as "e have used the class extern directive.

This class name is stored in the :xportedT%pe table and use the index variable to #etch its
name. !e are not allo"ed to use a t%pe name lie &&& in the class extern as it is a t%pe "e are
creatin( in the current #ile. The i# statement "hich checs the value o# the t%pede#index as its
al"a%s &ero unless "e add the .class directive. *ll that this directive does is #ills up the
t%pede#index #ield "ith the ro" number o# the t%pe table "hich is present in the other module. *s
244260235.doc 115 od 541
"e "ill explain much later this is onl% a hint and nobod% checs the value "e "rite a#ter the class
directive.

3ooin( at the #ile e.il$ the #irst three class extern classes o1$111 and simpl% use #ile directive.
The di##erence is the visibilit% attributes. The class ooo is not present in the output at all even
thou(h it is there in the e.il #ile.

3ets investi(ate. >or this class "e have used the class extern directive "ith the class name nnn.
This class in turn is stated to be in the #ile aa.dll. Thus as class ooo does nothin( but re#ers to
class nnn$ there is no use #or its independent existence and hence ilasm bein( a smart cooie
i(nores it and does not place it in the :xported T%pe table.

0aes sense as the class is simpl% an alias #or another class. This class ppp is similar in concept
to the class ppp that uses the undocumented comt%pe directive. The class mmm is also not #ound
as its an alias #or the class ;%stem./b1ect. no point clutterin( up this table "ith classes that do
nothin(.

!henever "e use the class extern directive "e should use the assembl% directive also but "e "ill
not (et a error i# "e do not. /bviousl% there is internall% one mani#est module onl% and all t%pes
exported should be present in this mani#est.

The rational #or this table is that a#ter some tool reads this table$ heIshe can #i(ure out all the
t%pes that others can use #rom this assembl%. This mani#est module "ill there#ore contain all the
t%pes exported #rom all the modules that mae up the assembl%. Nn#ortunatel% this mani#est
module is also called the assembl%.

Thus each time "e create a t%pe in an% module o# an assembl%$ this table o# ours (ets one ro"
added. 'n other "ords$ ever% t%pe created in another module has a entr% in the T%pe=e# table and
this ro" number "ill be placed in the :xported T%pe table. The T%pe=e#'= or t%pede#index #ield
in our case is al"a%s &ero as mentioned earlier unless o# course "e use the class directive.

The point "e are main( is that this is the #irst time "e are re#errin( to a ro" in another module
and these are called #orei(n toens. The #act o# the matter is that the assembler is too la&% to (o
the other modules and #i(ure out "hat the t%pe de# ro" indexes are.

The t%pe name is stored in the name and namespace #ields and there "as a plan to use the
t%pede#id #ield i# the above search #ailed. The specs at one place sa% that the implementation
coded index can contain onl% the >ile and :xported T%pe table and at a another place adds the
*ssembl% ,e# table also.

>or the #ile table the visibilit% mas has to be public and not nested public but "e do not (et an
error i# "e do mae such a mistae. The specs also sa% that i# the table is the :xported t%pe then
the visibilit% mas has to be nested public. )o error a(ain i# "e brea the rule. !h% have rules
"hen no one checs #or them.

4ro(ram14.csc
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
244260235.doc 116 od 541
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
@
public void =ispla%,esources58
9
i# 5 0ani#est,esource;truct AA null8
return<
#or 5 int ii A 1 < ii B 0ani#est,esource;truct.3en(th < iiCC8
9
strin( #la(s A Det0ani#est,esource*ttributes50ani#est,esource;truct6ii7.#la(s8<
+onsole.!rite3ine5F.mresource IJ2890@JI 91@92@F $ ii.To;trin(5FK6F8 $ #la(s$
)ame,eserved5Det;trin(50ani#est,esource;truct6ii7.name88 8<
+onsole.!rite3ine5F9F8<
strin( table A Det0ani#est,esourceTable50ani#est,esource;truct6ii7.coded8<
int index A Det0ani#est,esource-alue50ani#est,esource;truct6ii7.coded8<
i# 5 table AA F*ssembl%,e#F8
+onsole.!rite3ine5F .assembl% extern 90@ IJ2391@JI F $
)ame,eserved5Det;trin(5*ssembl%,e#;truct6index7.name88 $ index.To;trin(5FK6F88<
else i# 5 table AA F>ileF GG index H 08
+onsole.!rite3ine5F .#ile 90@IJ2691@JI at 0x92@F $
)ame,eserved5Det;trin(5>ile;truct6index7.name88 $ index.To;trin(5FK6F8
$0ani#est,esource;truct6ii7.o##set.To;trin(5FK8F8 8<
else
+onsole.!rite3ine5F II !*,)')DM mana(ed resource #ile 90@
createdF$)ame,eserved5Det;trin(50ani#est,esource;truct6ii7.name8 8 8<
+onsole.!rite3ine5F@F8<
@
@
public int Det0ani#est,esource-alue5int mani#iestvalue8
9
return mani#iestvalueHH 2<
@
public strin( Det0ani#est,esourceTable5int mani#iestvalue8
9
strin( returnstrin( A FF<
short ta( A 5short85mani#iestvalue G 5short80x038<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F>ileF<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F*ssembl%,e#F<
244260235.doc 117 od 541
return returnstrin(<
@
public strin( Det0ani#est,esource*ttributes5int mani#iestvalue8
9
strin( returnstrin(AFF<
i# 5 5mani#iestvalue G 0x0018 AA 0x0018
returnstrin( A returnstrin( C Fpublic F<
i# 5 5mani#iestvalue G 0x0028 AA 0x0028
returnstrin( A returnstrin( C Fprivate F<
return returnstrin(<
@

e.il
.assembl% e
9
@
.assembl% extern a1
9
@
.#ile aa.dll
.mresource r1
9
@
.mresource public r1
9
@
.mresource private r2
9
.assembl% extern a1
@
.mresource public r3
9
.#ile aa.dll at 12
@
.mresource public r4
9
.#ile aa.dll at 12
.assembl% extern a1
@
.class &&&
9
.method static void abc58
9
.entr%point
ret
@
@

/utput
.assembl% extern IJ23000001JI a1
9
244260235.doc 118 od 541
.ver 0M0M0M0
@
.assembl% extern IJ23000002JI mscorlib
9
.ver 0M0M0M0
@
.assembl% IJ20000001JI e
9
.ver 0M0M0M0
@
.#ile IJ26000001JI aa.dll
.mresource IJ28000001JI r1
9
II !*,)')DM mana(ed resource #ile r1 created
@
.mresource IJ28000002JI public r1
9
II !*,)')DM mana(ed resource #ile r1 created
@
.mresource IJ28000003JI private r2
9
.assembl% extern a1 IJ23000001JI
@
.mresource IJ28000004JI public r3
9
.#ile aa.dllIJ26000001JI at 0x0000000+
@
.mresource IJ28000005JI public r4
9
.assembl% extern a1 IJ23000001JI
@

The above pro(ram displa%s all the resources that "e have. !e have added a #unction
=ispla%,esources that displa%s all the ro"s #rom the 0ani#est ,esource table. This table (ets
#illed up b% the mresource directive. The #irst #ield is the #la(s #ield "hich (ives us the visibilit%
mas that is similar to the class extern directive.

The onl% di##erence is that the t"o valid values are public and private. !e use the #unction
Det0ani#est,esource*ttributes to return one o# these values. )one o# these visibilit% attributes is
mandator%. !e displa% the visibilit% attributes alon( "ith the mresource directive and the ro"
number in the 0ani#est ,esource table.

)earl% ever% table has a coded index and the ,esource table does not la( behind. 'n this case the
coded index either points to the >ile table i# the value is 0 or assembl% re# table "hose value is 1.
The specs call this the 'mplementation coded index "hich also included the :xported t%pe table
but #or resources it is onl% the above t"o.

!e use the Det0ani#est,esourceTable #unction to return the table name and the #unction
Det0ani#est,esource-alue to return the ro" number a#ter ri(ht shi#tin( the coded index b% t"o
bits. 'n the mresource directive "e can either "rite the *ssemble% extern directive or the #ile
directive or both or none.
244260235.doc 119 od 541

'# "e use the assembl% extern directive$ then the index variable is the ro" number o# the
*ssembl% ,e# table and "e displa% the name o# the assembl%. '# "e had had used the #ile
directive and this indexes a ro" number lar(er than or e.ual to 1$ then "e displa% the #ile name
alon( "ith the position o# the #ile "here the resource starts.

The index variable is the ro" number in the >ile table and the o##set "ithin the #ile is stored in the
o##set #ield o# the ,esource table. >inall% i# "e have used the #ile directive and the index variable
is &ero$ then "ithin comments "e displa% a "arnin( statin( that a #ile "ith the same name as the
mresource directive has been created.

'# "e speci#% no directive$ "e (et no error and the above "arnin( is displa%ed. '# "e use both$ the
assembl% directive is used and not the #ile directive. *s al"a%s no error checs #or the #ile
directive or the o##set. *n assembl% can have lots o# di##erent data items associated "ith it.

'# "e ever "ant to name a item o# data$ "e use the mani#est resource to do so. '# "e do not have a
assembl% directive$ it is per#ectl% le(al to use the mresource directive$ but "e "ill not be able to
execute the assembl%.

The reason "e speci#% public or private #or a mani#est resource is so that the assembl% no"s
"hether this item can be exported or seen outside this assembl% or should remain visible onl%
"ithin the assembl% i# it is #la((ed private.

'# the resource is stored in the #ile and that #ile is not a module$ it can be a text #ile #or example$
then "e "ould need a separate #ile directive$ declarin( that #ile. 'n this case the b%te o##set "ill be
&ero.

'# the resource is de#ined in another assembl%$ "e "ould need to have a assembl% extern directive
at the top level be#ore "e can use the assembl% extern directive "ithin the mresource directive.
The o##set #ield is normall% a valid o##set "hich is relative #rom the resource data director% entr%
in the +/, header.

Out as said earlier$ this error chec is not done at present. '# the index is null$ it means that the
resource is stored in the current #ile and hence the "arnin(.

4ro(ram15.csc
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
244260235.doc 120 od 541
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
@
public void =ispla%0odule*nd0ore58
9
+onsole.!rite3ine5F.module 90@F $ )ame,eserved5Det;trin(50odule;truct617.)ame888<
+onsole.!rite5FII 0-'=M F8<
=ispla%Duid50odule;truct617.0vid8<
+onsole.!rite3ine58<
+onsole.!rite3ine5F.ima(ebase 0x90@F $ 'ma(eOase.To;trin(5Fx8F88<
+onsole.!rite3ine5F.subs%stem 0x90@F $ subs%stem.To;trin(5FK8F88<
+onsole.!rite3ine5F.#ile ali(nment 90@F $ #ilea8<
+onsole.!rite3ine5F.cor#la(s 0x90@F $ cor#la(s.To;trin(5Fx8F88<
+onsole.!rite3ine5FII 'ma(e baseM 0x03000000F8<
@
public void =ispla%Duid 5int (uidindex8
9
+onsole.!rite5F9F8<
+onsole.!rite5F90@91@92@93@F$ (uid6(uidindexC27.To;trin(5FK2F8 $
(uid6(uidindexC17.To;trin(5FK2F8 $ (uid6(uidindex7.To;trin(5FK2F8 $ (uid6(uidindexP
17.To;trin(5FK2F88<
+onsole.!rite5FP90@91@PF$(uid6(uidindexC47.To;trin(5FK2F8 $
(uid6(uidindexC37.To;trin(5FK2F88<
+onsole.!rite5F90@91@PF$(uid6(uidindexC67.To;trin(5FK2F8 $
(uid6(uidindexC57.To;trin(5FK2F88<
+onsole.!rite5F90@91@PF$(uid6(uidindexC77.To;trin(5FK2F8 $
(uid6(uidindexC87.To;trin(5FK2F88<
+onsole.!rite5F90@91@92@93@94@
95@F$(uid6(uidindexC97.To;trin(5FK2F8$(uid6(uidindexC107.To;trin(5FK2F8$(uid6(uidindexC117.
To;trin(5FK2F8$(uid6(uidindexC127.To;trin(5FK2F8$(uid6(uidindexC137.To;trin(5FK2F8$(uid6(ui
dindexC147.To;trin(5FK2F88<
+onsole.!rite5F@F8<
@

e.il
.assembl% e
9
@
.module aaaa
.class &&&
9
.method static void abc58
9
.entr%point
ret
@
@

output
244260235.doc 121 od 541
.module aaaa
II 0-'=M 9:=O:9:84P>6=:P468+PO8+OP0+O099>=1:*4@
.ima(ebase 0x00400000
.subs%stem 0x00000003
.#ile ali(nment 512
.cor#la(s 0x00000001
II 'ma(e baseM 0x03000000

This one is a small pro(ram and all that it does is adds one more #unction call
=ispla%0odule*nd0ore to the abc #unction. The .module directive is optional and this adds one
record to the 0odule table. *s mentioned earlier "e can have onl% one module directive and not
t"o and i# "e do not$ one (ets added #or us automaticall%.

!e simpl% displa% the directive module and #ollo" this "ith the "ords 0-'=. !e then call a
#unction =ispla%Duid that displa%s a (uid #or us. :ver% application needs to be uni.uel%
identi#ied and the assembler (ives it a uni.ue 128 bit number stored in the #ield 0vid. :ach time
"e re(enerate our assembl%$ this number chan(es.

The reason it is a 128 bit number is because such a number is uni.ue across time and space. The
problem "ith the (uid is that it is displa%ed in a certain manner and the #unction =ispla%Duid
simpl% displa%s the b%tes #rom the o##set o# the (uid stream passed as a parameter.

>or example "e displa% the third b%te #irst #ollo"ed b% the second etc. This (uid is calculated
usin( the ';/I':+ standard 11578M1996. The #ull #orm o# a DN'= is a Dloball% Nni.ue
'=enti#ier. 't is a concept used b% +/,O* and /3: in the past.

The -:; 5-irtual :xecution ;%stem or ,untime8 does not mae an% use o# the Duid but
debu((ers should use this number to uni.uel% identi#% the module. The name o# the #ile is not the
ph%sical #ile name but the lo(ical name stored in the metadata.

The module table is the #irst one the desi(ners o# the metadata thou(ht o# as the% (ave it a number
o# 0. The (eneration #ield is reserved and has a value o# &ero. :nc'd and :ncOase'd are also
reserved but the% are indexes into th Duid heap and also have a value o# 0. Ooth 0vid and the
name #ield have to have a non null value.

'# %ou remember earlier "e had #i(ured some instance variables lie #ile ali(nment and
subs%stem. !e are simpl% displa%in( these values here. The 'ma(ebase$ subs%stem and #ile
ali(nment variables "e have alread% displa%ed earlier. The 'ma(eOase is once a(ain displa%ed
"ithin comments "ith a constant value.

;ome points that "e missed about these values "e "ill explain no". The cor#la(s directive "as
not "ritten b% us and the +3' expects the value to be 1. >or bac"ards compatibilit% the least 3
si(ni#icant bits are reserved. Thus the values #rom 8 to 65535 "ill be used b% #uture versions.

The (u%s "ho create experimental and or non standard versions have the blessin(s o# the .)et
standard to use values lar(er than 65535. The subs%stem directive is used onl% "hen "e execute
the assembl% and thus dllQs have no use #or it. This ma% be a 32 bit number but it can have onl%
t"o possible values.

* value o# 2 means that the pro(ram should be run usin( "hatever conventions are #it #or a DN'
applications. * value o# 3 is #or a console application. *t this point in time there is no third
244260235.doc 122 od 541
environment #or a application to execute. The #ile ali(nment can onl% be values that are a multiple
o# 512 b%tes.

4ro(ram16.csc
strin( 67 vt#ixuparra%<

public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
=ispal%-t>ixup58<
@

public void ,eadand=ispla%-Table>ixup58
9
i# 5 0ethod;truct AA null8
return<
i# 5 vtablerva EA 08
9
lon( save <
lon( position A +onvert,-*5vtablerva8 <
i# 5 position AA P18
return<
m#ilestream.4osition A position<
+onsole.!rite3ine5FII -Table>ixup =irector%MF8<
int count1 A vtablesi&eI8<
vt#ixuparra% A ne" strin(6count17<
#or 5 int ii A 0 < ii B count1 < iiCC8
9
vt#ixuparra%6ii7 A F.vt#ixup F<
int #ixuprva A mbinar%reader.,ead'nt3258<
+onsole.!rite3ine5FII '0*D:R+/,R-T*O3:>'KN4690@7MF $ ii8<
+onsole.!rite3ine5FII ,-*M 90@F$#ixuprva.To;trin(5Fx8F88<
short count A mbinar%reader.,ead'nt1658<
+onsole.!rite3ine5FII +ountM 90@F$ count.To;trin(5Fx4F88<
short t%pe A mbinar%reader.,ead'nt1658<
244260235.doc 123 od 541
+onsole.!rite3ine5FII T%peM 90@F$ t%pe.To;trin(5Fx4F88<
save A m#ilestream.4osition<
m#ilestream.4osition A +onvert,-*5#ixuprva8 <
int i1 <
lon( 67 val A ne" lon(6count7 <
#or 5 i1 A 0 < i1 B count < i1CC8
9
i# 5 5t%peG0x018 AA 0x018
val6i17 A mbinar%reader.,ead'nt3258<
i# 5 5t%peG0x028 AA 0x028
val6i17 A mbinar%reader.,ead'nt6458<
i# 5 5t%peG0x018 AA 0x01 8
+onsole.!rite3ine5FII 690@7 591@8F$i1.To;trin(5Fx4F8 $ val6i17.To;trin(5FK8F88<
i# 5 5t%peG0x028 AA 0x028
+onsole.!rite3ine5FII 690@7 5 91@8F$i1.To;trin(5Fx4F8 $
5val6i17G0x########8.To;trin(5FKF88<
@
m#ilestream.4osition A save<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F6F C 5i18.To;trin(5FKF8 C F7 F<
i# 5 5t%peG0x018 AA 0x018
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fint32 F<
i# 5 5t%peG0x028 AA 0x028
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fint64 F<
i# 5 5t%peG0x048 AA 0x048
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F#romunmana(ed F<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fat =RF C #ixuprva.To;trin(5FK8F8<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F IIF<
#or 5 i1 A 0 < i1 B count < i1CC8
9
i# 5 5t%peG0x018 AA 0x018
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F F C val6i17.To;trin(5FK8F8<
i# 5 5t%peG0x028 AA 0x028
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F F C val6i17.To;trin(5FK16F8<
@
@
+onsole.!rite3ine58<
@
@

public void =ispal%-t>ixup58
9
i# 5vt#ixuparra% AA null8
return<
#or 5 int ii A 0 < ii B vt#ixuparra%.3en(th < iiCC8
+onsole.!rite3ine5vt#ixuparra%6ii78<
@

e.il
.class public a11111
9
.method public static void ad#58 cil mana(ed
244260235.doc 124 od 541
9
.entr%point
@
.method public int64 a158 cil mana(ed
9
@
.method public int64 a258 cil mana(ed
9
@
.method public int64 a358 cil mana(ed
9
@
.method public int64 a458 cil mana(ed
9
@
.method public int64 a558 cil mana(ed
9
@
.method public int64 a658 cil mana(ed
9
@
.method public int64 a758 cil mana(ed
9
@
@
.vt#ixup 617 int32 at =R00008010
.vt#ixup 617 int32 #romunmana(ed at =R00008020
.vt#ixup 617 int64 at =R00008030
.vt#ixup 617 int64 #romunmana(ed at =R00008040
.vt#ixup 607 int64 at =R00008050
.vt#ixup 627 int64 int64 at =R00008060
.data =R00008010 A b%tearra% 5 01 00 00 068
.data =R00008020 A b%tearra% 5 02 00 00 068
.data =R00008030 A b%tearra% 5 03 00 00 068
.data =R00008040 A b%tearra% 5 04 00 00 068
.data =R00008050 A b%tearra% 5 05 00 00 068
.data =R00008060 A b%tearra% 5 06 00 00 06 00 00 00 00 07 00 00 06 00 00 00 008

/utput
.vt#ixup 617 int32 at =R00004000 II 06000001
.vt#ixup 617 int32 #romunmana(ed at =R00004004 II 06000002
.vt#ixup 617 int64 at =R00004008 II 0600000406000003
.vt#ixup 617 int64 #romunmana(ed at =R0000400+ II 0600000506000004
.vt#ixup 607 int64 at =R00004010 II
.vt#ixup 627 int64 at =R00004014 II 0000000006000006 0000000006000007

'# %ou loo at pro(ram7.csc care#ull%$ "e displa%ed the directive vt#ixup. '# %ou looed at the
output o# that pro(ram ver% care#ull%$ %ou "ould have reali&ed that it "as all in comments. !e
did not displa% the actual directive vt#ixup at that time.

244260235.doc 125 od 541
!e have added a instance arra% vt#ixuparra% and "e also call a #unction =ispal%-t>ixup in the
#unction abc to displa% the directive. !e have also added some more code in the
,eadand=ispla%-Table>ixup #unction that "ill populate the arra% vt#ixuparra% and then displa%
it later at the end.

*s explained be#ore the count1 variable is a count o# the items and "e use this to (ive us an arra%
o# the desired si&e. +reatin( an arra% o# si&e is not an error and the arra% 1ust does not (et created.
!e use the same variable count1 to also create the arra% val to store the individual values.

=ependin( upon the t%pe bein( a int32 or int64 "e read either 4 or 8 b%tes into the correspondin(
val arra%. !e then create the entire strin( into the vt#ixuparra% and use the t%pe variable to
determine the "idth o# the table. The #ixuprva (ives us the data address "hich "e concatenate
"ith a =R.

Then "e place the comments and a#ter this "e need the values that "e "rote in the b%tearra%.
These depend upon the count value "e speci#ied in the s.uare bracets. Thus "e use the same
loop a(ain and concatenate the b%tearra% values$ readin( either 4 or 8 b%tes dependin( as "e said
on the "idth o# the table.

!hen "e loo at the =ispal%-t>ixup #unction$ it simpl% displa%s the members o# the
vt#ixuparra%.


4ro(ram17.csc
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
=ispal%-t>ixup58<
=ispla%T%pe=e#s58<
@

public void =ispla%T%pe=e#s 58
9
i# 5 T%pe=e#;truct.3en(th EA 28
9
244260235.doc 126 od 541
+onsole.!rite3ine5FIIF8<
+onsole.!rite3ine5FII AAAAAAAAAAAAAA +3*;; ;T,N+TN,: =:+3*,*T'/)
AAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine5FIIF8<
"ritenamespace A true<
#or 5 int i A 2 < i B T%pe=e#;truct.3en(th < iCC8
9
i# 5 Det;trin(5T%pe=e#;truct6i7.name8 AA FR=eletedF GG streamnames607 AA FSPF8
9
continue<
@
i# 5 E 'sT%pe)ested5i8 8
9
=ispla%/neT%pe4rotot%pe5i8<
@
@
@
@
public bool 'sT%pe)ested 5int t%peindex8
9
i# 5)ested+lass;truct AA null8
return #alse<
#or 5 int ii A 1 < iiB )ested+lass;truct.3en(th < iiCC8
9
i# 5 )ested+lass;truct6ii7.nestedclass AA t%peindex8
return true<
@
return #alse<
@
public void =ispla%/neT%pe4rotot%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%)estedT%pes4rotot%pes5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index8<
@
public void =ispla%/neT%pe=e#;tart 5int t%pero"8
9
strin( namespacename A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pero"7.nspace88<
i# 5 namespacename EA FF8
9
i# 5 "ritenamespace 8
9
+onsole.!rite3ine5F.namespace 90@F $ namespacename 8<
+onsole.!rite3ine5F9F 8<
space#ornamespace A 2<
spaces#orrest A 4<
@
@
strin( t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
244260235.doc 127 od 541
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F.class IJ02F C t%pero".To;trin(5FK6F8 C FJI F<
strin( attribute#la(s A DetT%pe*ttribute>la(s5T%pe=e#;truct6t%pero"7.#la(s $ t%pero"8<
+onsole.!rite3ine5F90@91@92@F $ t%pestrin( $ attribute#la(s $
)ame,eserved5Det;trin(5T%pe=e#;truct6t%pero"7.name888<
strin( tablename A DetT%pe=e#/r,e#Table5T%pe=e#;truct6t%pero"7.cindex8<
int index A DetT%pe=e#/r,e#-alue5T%pe=e#;truct6t%pero"7.cindex8<
strin( t%peextends A FF<
i# 5 tablename AA FT%pe,e#F 8
9
t%peextends A =ispla%T%pe,e#:xtends5index8<
@
i# 5 tablename AA FT%pe=e#F 8
9
t%peextends A Det)estedT%pe*s;trin(5index8 C =ispla%T%pe=e#:xtends5index8<
@
i# 5 t%peextends.3en(th EA 08
9
t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F extends F C t%peextends<
+onsole.!rite3ine5t%pestrin(8<
@
strin( inter#acestrin( A =ispla%*ll'nter#aces5t%pero"8<
i# 5 inter#acestrin(.3en(th EA 08
9
t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F implements F C inter#acestrin(<
+onsole.!rite5t%pestrin(8<
@
t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F9F<
+onsole.!rite3ine5t%pestrin(8<
@
public strin( DetT%pe*ttribute>la(s 5int t%peattribute#la(s $ int t%peindex8
9
strin( returnstrin( A FF<
int visibilt%mas A t%peattribute#la(s G 0x07<
strin( visibilt%masstrin(AFF<
i# 5 visibilt%mas AA 08
visibilt%masstrin( A Fprivate F<
i# 5 visibilt%mas AA 18
visibilt%masstrin( A Fpublic F<
244260235.doc 128 od 541
i# 5 visibilt%mas AA 28
visibilt%masstrin( A Fnested public F<
i# 5 visibilt%mas AA 38
visibilt%masstrin( A Fnested private F<
i# 5 visibilt%mas AA 48
visibilt%masstrin( A Fnested #amil% F<
i# 5 visibilt%mas AA 58
visibilt%masstrin( A Fnested assembl% F<
i# 5 visibilt%mas AA 68
visibilt%masstrin( A Fnested #amandassem F<
i# 5 visibilt%mas AA 78
visibilt%masstrin( A Fnested #amorassem F<
int classla%outmas A t%peattribute#la(s G 0x18<
strin( classla%outstrin( A FF<
i# 5 classla%outmas AA 08
classla%outstrin( A Fauto F<
i# 5 classla%outmas AA 0x088
classla%outstrin( A Fse.uential F<
i# 5 classla%outmas AA 0x108
classla%outstrin( A Fexplicit F<
strin( inter#acestrin( A FF<
i# 5 5t%peattribute#la(s G 0x208 AA 0x208
inter#acestrin( A Finter#ace F<
strin( abstractstrin( A FF<
i# 5 5t%peattribute#la(s G 0x808 AA 0x808
abstractstrin( A Fabstract F<
strin( sealedstrin( A FF<
i# 5 5t%peattribute#la(s G 0x1008 AA 0x1008
sealedstrin( A Fsealed F<
strin( specialnamestrin( A FF<
i# 5 5t%peattribute#la(s G 0x4008 AA 0x4008
specialnamestrin( A Fspecialname F<
strin( importstrin( A FF<
i# 5 5t%peattribute#la(s G 0x10008 AA 0x10008
importstrin( A Fimport F<
strin( seriali&ablestrin( A FF<
i# 5 5t%peattribute#la(s G 0x20008 AA 0x20008
seriali&ablestrin( A Fseriali&able F<
int strin(#ormatmas A t%peattribute#la(s G 0x30000<
strin( strin(#ormastrin( A FF<
i# 5 strin(#ormatmas AA 08
strin(#ormastrin( A Fansi F<
i# 5 strin(#ormatmas AA 0x100008
strin(#ormastrin( A Funicode F<
i# 5 strin(#ormatmas AA 0x200008
strin(#ormastrin( A Fautochar F<
strin( be#ore#ieldinitstrin( A FF<
i# 5 5t%peattribute#la(s G 0x001000008 AA 0x001000008
be#ore#ieldinitstrin( A Fbe#ore#ieldinit F<
IIstrin( rtspecialnamestrin( A FF<
IIi# 5 5t%peattribute#la(s G 0x8008 AA 0x8008
244260235.doc 129 od 541
IIrtspecialnamestrin( A Frtspecialname F<
i# 5 'sT%pe)ested5t%peindex8 8
returnstrin( A inter#acestrin( C abstractstrin( C classla%outstrin( C strin(#ormastrin( C
seriali&ablestrin( C sealedstrin( C importstrin( C visibilt%masstrin( C be#ore#ieldinitstrin(<
else
returnstrin( A inter#acestrin( C visibilt%masstrin( C abstractstrin( C classla%outstrin( C
strin(#ormastrin( C importstrin( C seriali&ablestrin( C sealedstrin( C specialnamestrin( C
be#ore#ieldinitstrin( <
return returnstrin(<
@
public strin( =ispla%T%pe=e#:xtends 5int t%pede#index8
9
i# 5 t%pede#index AA 08
return FF<
strin( name A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#index7.name88<
strin( returnstrin( A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#index7.nspace88<
i# 5 returnstrin(.3en(th EA 08
returnstrin( A returnstrin( C F.F<
returnstrin( A returnstrin( C name C FIJ 02F C t%pede#index.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
public strin( Det)estedT%pe*s;trin(5int ro"index8
9
strin( netsedt%pestrin( A FF<
strin( namespaceandnameparent2 A FF<
strin( namespaceandnameparent3A FF<
i# 5 'sT%pe)ested5ro"index8 8
9
int ro"indexparent A Det4arent>or)estedT%pe5ro"index8<
i# 5 'sT%pe)ested5ro"indexparent8 8
9
int ro"indexparentparent A Det4arent>or)estedT%pe5ro"indexparent8<
i# 5 'sT%pe)ested5ro"indexparentparent8 8
9
int ro"indexp3 A Det4arent>or)estedT%pe5ro"indexparentparent8<
strin( nameparent3 A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexp37.name88<
namespaceandnameparent3A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexp37.nspace88<
i# 5 namespaceandnameparent3.3en(th EA 08
namespaceandnameparent3 A namespaceandnameparent3 C F.F<
namespaceandnameparent3A namespaceandnameparent3 C nameparent3 C FIJ 02F C
ro"indexp3.To;trin(5FK6F8 C F JIIF<
@
strin( nameparent2 A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparentparent7.name88<
namespaceandnameparent2 A
)ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparentparent7.nspace88<
i# 5 namespaceandnameparent2.3en(th EA 08
namespaceandnameparent2 A namespaceandnameparent2 C F.F<
namespaceandnameparent2 A namespaceandnameparent3 C namespaceandnameparent2 C
nameparent2 C FIJ 02F C ro"indexparentparent.To;trin(5FK6F8 C F JIIF<
@
strin( nameparent1 A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparent7.name88<
244260235.doc 130 od 541
netsedt%pestrin( A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparent7.nspace88<
i# 5 netsedt%pestrin(.3en(th EA 08
netsedt%pestrin( A netsedt%pestrin( C F.F<
netsedt%pestrin( A namespaceandnameparent2 C netsedt%pestrin( C nameparent1 C FIJ 02F C
ro"indexparent.To;trin(5FK6F8 C F JIIF<
@
return netsedt%pestrin(<
@
public int Det4arent>or)estedT%pe 5int t%peindex8
9
int ii A 0<
i# 5 )ested+lass;truct AA null8
return 0<
#or 5 ii A 0 < ii B )ested+lass;truct.3en(th P 1 < iiCC8
9
i# 5 t%peindex AA )ested+lass;truct6ii7.nestedclass 8
brea<
@
return )ested+lass;truct6ii7.enclosin(class<
@
public strin( =ispla%T%pe,e#:xtends 5int t%pere#index8
9
strin( returnstrin( A FF<
int resolutionscope A T%pe,e#;truct6t%pere#index7.resolutionscope<
strin( resolutionscopetable A Det,esolution;copeTable5resolutionscope8<
int resolutionscopeindex A Det,esolution;cope-alue5resolutionscope8<
strin( dumm% A FF<
i# 5 resolutionscopetable AA F0oduleF8
9
@
i# 5 resolutionscopetable AA F*ssembl%,e#F8
9
returnstrin( A F6F C )ame,eserved5Det;trin(5*ssembl%,e#;truct6resolutionscopeindex7.name88 <
returnstrin( A returnstrin( C FIJ 23F C resolutionscopeindex.To;trin(5FK6F8 C F JI7F<
@
i# 5 resolutionscopetable AA F0odule,e#F8
9
returnstrin( A F6.module F C
)ame,eserved5Det;trin(50odule,e#;truct6resolutionscopeindex7.name88 <
returnstrin( A returnstrin( C FIJ 1*F C resolutionscopeindex.To;trin(5FK6F8 C F JI7F<
@
i# 5 resolutionscopetable AA FT%pe,e#F8
9
int resolutionscopeindex1 A
Det,esolution;cope-alue5T%pe,e#;truct6resolutionscopeindex7.resolutionscope 8<
strin( resolutionscopetable1 A
Det,esolution;copeTable5T%pe,e#;truct6resolutionscopeindex7.resolutionscope 8<
i# 5 resolutionscopetable1 AA F*ssembl%,e#F8
9
dumm% A F6F C )ame,eserved5Det;trin(5*ssembl%,e#;truct6resolutionscopeindex17.name88 C
FIJ 23F C resolutionscopeindex1.To;trin(5FK6F8 C F JI7F<
244260235.doc 131 od 541
strin( nspace1 A )ame,eserved5Det;trin(5T%pe,e#;truct6resolutionscopeindex7.nspace88<
i# 5 nspace1 EA FF8
nspace1 A nspace1 C F.F<
dumm% A dumm% C nspace1 C
)ame,eserved5Det;trin(5T%pe,e#;truct6resolutionscopeindex7.name88 C FIJ 01F C
resolutionscopeindex.To;trin(5FK6F8 C F JIIF<
@
@
int namespaceindex A T%pe,e#;truct6t%pere#index7.nspace<
strin( nspace A )ame,eserved5Det;trin(5namespaceindex88<
returnstrin( A returnstrin( C nspace <
i# 5 nspace.3en(th EA 08
returnstrin( A returnstrin( C F.F<
int nameindex A T%pe,e#;truct6t%pere#index7.name<
returnstrin( A dumm% C returnstrin( C )ame,eserved5Det;trin(5nameindex88 C FIJ 01F C
t%pere#index.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
public strin( =ispla%*ll'nter#aces 5int t%peindex8
9
strin( returnstrin( A FF<
i# 5 'nter#ace'mpl;truct AA null TT 'nter#ace'mpl;truct.3en(th AA 18
return FF<
#or 5 int i A 1 < i B 'nter#ace'mpl;truct.3en(th < iCC8
9
i# 5 t%peindex AA 'nter#ace'mpl;truct6i7.classindex 8
9
strin( codedtablename A DetT%pe=e#/r,e#Table5'nter#ace'mpl;truct6i7.inter#aceindex8<
int inter#aceindex A DetT%pe=e#/r,e#-alue5'nter#ace'mpl;truct6i7.inter#aceindex8<
strin( inter#acename A FF<
i# 5 codedtablename AA FT%pe,e#F 8
inter#acename A =ispla%T%pe,e#:xtends5inter#aceindex8<
i# 5 codedtablename AA FT%pe=e#F 8
inter#acename A Det)estedT%pe*s;trin(5inter#aceindex8 C
=ispla%T%pe=e#:xtends5inter#aceindex8<
returnstrin( A returnstrin( C inter#acename<
bool nextclassindex <
i# 5 i AA 5'nter#ace'mpl;truct.3en(th P 188
nextclassindex A #alse<
else i# 5 t%peindex EA 'nter#ace'mpl;truct6iC17.classindex 8
nextclassindex A #alse<
else
nextclassindex A true<
i# 5 nextclassindex 8
returnstrin( A returnstrin( C F$UrUn F C
+reate;paces5space#ornamespaceCspaces#ornested8<
else
returnstrin( A returnstrin( C FUrUnF<
@
@
return returnstrin(<
244260235.doc 132 od 541
@
public strin( DetT%pe=e#/r,e#Table 5int codedvalue8
9
strin( returnstrin( A FF<
short ta( A 5short85codedvalue G 5short80x038<
i# 5 ta( AA 08
returnstrin( A returnstrin( C FT%pe=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C FT%pe,e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C FT%pe;pecF<
return returnstrin(<
@
public int DetT%pe=e#/r,e#-alue5int codedvalue8
9
return codedvalue HH 2<
@
public void =ispla%)estedT%pes4rotot%pes 5int t%pede#index8
9
i# 5)ested+lass;truct AA null8
return <
#or 5 int ii A 1 < ii B )ested+lass;truct.3en(th < iiCC8
9
i# 5)ested+lass;truct6ii7.enclosin(class AA t%pede#index8
9
spaces#ornested CA 2<
=ispla%/neT%pe4rotot%pe5)ested+lass;truct6ii7.nestedclass 8<
spaces#ornested PA 2<
@
@
@
public void =ispla%/neT%pe=e#:nd 5int t%peindex 8
9
strin( dumm% A FF<
i# 5 'sT%pe)ested5t%peindex8 8
dumm% A dumm% C +reate;paces5spaces#ornested8<
dumm% A dumm% C +reate;paces5space#ornamespace8<
dumm% A dumm% C F@ II end o# class F<
strin( classname A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88<
dumm% A dumm% C classname <
+onsole.!rite3ine5dumm%8<
strin( namespacename A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
+onsole.!rite3ine58<
i# 5 namespacename EA FF8
9
strin( nspace1 A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
int ii<
#or 5 ii A t%peindex C 1 < ii B T%pe=e#;truct.3en(th P 1 < iiCC8
9
i# 5 'sT%pe)ested5ii8 8
continue<
244260235.doc 133 od 541
brea<
@
strin( nspace2 A FF<
i# 5 ii EA T%pe=e#;truct.3en(th 8
nspace2 A )ame,eserved5Det;trin(5T%pe=e#;truct6ii7.nspace88<
i# 5 nspace1 EA nspace2 8
9
i# 5 lastt%pedispla%ed AA t%peindex GG notprotot%pe 8
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
placedend A true<
@
+onsole.!rite5F@F8<
+onsole.!rite3ine5F II end o# namespace 90@F$ namespacename8<
space#ornamespace A 0<
spaces#orrest A 2<
"ritenamespace A true<
+onsole.!rite3ine58<
@
else
"ritenamespace A #alse<
@
@

e.il
.class public abstract be#ore#ieldinit a1
9
.method public static void 0ain58
9
.entr%point
@
@
.class private se.uential unicode explicit sealed specialname rtspecialname inter#ace R=eleted
9
@
.namespace n1
9
.namespace n2
9
.class public autochar a2
9
.class public a3
9
.class a33
9
.class a333
9
.class a3333
244260235.doc 134 od 541
9
@
@
@
@
.class a4
9
@
@
@
@
.class a5
9
@
.class a6 extends a5
9
@
.class a7 extends n1.n2.a2Ia3Ia33Ia333
9
@
.class a71 extends n1.n2.a2Ia3
9
@
.class a72 extends n1.n2.a2Ia3Ia33
9
@

.class a8 extends 6mscorlib7aaa
9
@
.class a9 extends 6mscorlib7ppp.aaaIaa
9
@
.module extern bb
.module e.exe
.class a10 extends 6.module bb7a11
9
@
.class a12 extends 6.module e.exe7a13
9
@
.assembl% ee
9
@
.class a14 extends 6ee7a13
9
@
.class inter#ace a15
9
@
.class inter#ace a16
244260235.doc 135 od 541
9
@
.class a17 implements a15$a16$6mscorlib7aa
9
@

/utput
.module extern bb IJ1*000001JI
.assembl% extern IJ23000001JI mscorlib
9
.ver 0M0M0M0
@
.assembl% extern IJ23000002JI ee
9
.ver 0M0M0M0
@
.assembl% IJ20000001JI ee
9
.ver 0M0M0M0
@
.module e.exe
II 0-'=M 9=O25OO73P*933P4O68P9124P8>5135*+4=55@
.ima(ebase 0x00400000
.subs%stem 0x00000003
.#ile ali(nment 512
.cor#la(s 0x00000001
II 'ma(e baseM 0x03000000
II
II AAAAAAAAAAAAAA +3*;; ;T,N+TN,: =:+3*,*T'/) AAAAAAAAAAAAAAAAAA
II
.class IJ02000002JI public abstract auto ansi be#ore#ieldinit a1
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class a1

.class IJ02000003JI inter#ace private abstract explicit unicode sealed specialname R=eleted
9
@ II end o# class R=eleted

.namespace n1.n2
9
.class IJ02000004JI public auto autochar a2
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.class IJ02000005JI auto ansi nested public a3
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.class IJ02000006JI auto ansi nested private a33
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.class IJ02000007JI auto ansi nested private a333
244260235.doc 136 od 541
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.class IJ02000008JI auto ansi nested private a3333
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class a3333

@ II end o# class a333

@ II end o# class a33

@ II end o# class a3

.class IJ02000009JI auto ansi nested private a4
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class a4

@ II end o# class a2

@ II end o# namespace n1.n2

.class IJ0200000*JI private auto ansi a5
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class a5

.class IJ0200000OJI private auto ansi a6
extends a5IJ 0200000* JI
9
@ II end o# class a6

.class IJ0200000+JI private auto ansi a7
extends n1.n2.a2IJ 02000004 JIIa3IJ 02000005 JIIa33IJ 02000006 JIIa333IJ 02000007 JI
9
@ II end o# class a7

.class IJ0200000=JI private auto ansi a71
extends n1.n2.a2IJ 02000004 JIIa3IJ 02000005 JI
9
@ II end o# class a71

.class IJ0200000:JI private auto ansi a72
extends n1.n2.a2IJ 02000004 JIIa3IJ 02000005 JIIa33IJ 02000006 JI
9
@ II end o# class a72

.class IJ0200000>JI private auto ansi a8
extends 6mscorlibIJ 23000001 JI7aaaIJ 01000002 JI
9
@ II end o# class a8
244260235.doc 137 od 541

.class IJ02000010JI private auto ansi a9
extends 6mscorlibIJ 23000001 JI7ppp.aaaIJ 01000003 JIIaaIJ 01000004 JI
9
@ II end o# class a9

.class IJ02000011JI private auto ansi a10
extends 6.module bbIJ 1*000001 JI7a11IJ 01000005 JI
9
@ II end o# class a10

.class IJ02000012JI private auto ansi a12
extends a13IJ 01000006 JI
9
@ II end o# class a12

.class IJ02000013JI private auto ansi a14
extends 6eeIJ 23000002 JI7a13IJ 01000007 JI
9
@ II end o# class a14

.class IJ02000014JI inter#ace private abstract auto ansi a15
9
@ II end o# class a15

.class IJ02000015JI inter#ace private abstract auto ansi a16
9
@ II end o# class a16

.class IJ02000016JI private auto ansi a17
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
implements a15IJ 02000014 JI$
a16IJ 02000015 JI$
6mscorlibIJ 23000001 JI7aaIJ 01000008 JI
9
@ II end o# class a17

!e no" add the second last #unction call to the #unction =ispla%T%pe=e#s in the abc #unction.
This #unction simpl% displa%s the protot%pes o# all the classes or t%pes that "e have created. 'n
+S "e ma% have t%pes lie enums$ inter#aces or structures$ but these are alien concepts in the '3
"orld.

These t%pes are all represented b% the class directive. *n enum is in the '3 "orld is a sealed class
that extends the ;%stem.:num class. * struct is the same but instead extends #rom the
;%stem.-alueT%pe class. >inall% a inter#ace has a inter#ace attribute. Thus in the '3 "orld "e use
the class directive to represent all t%pes.

'n the '3 "orld "e are allo"ed to have methods that are (lobal and thus unlie the lan(ua(e +S
"e are permitted to create a valid il #ile "ith no t%pe de#ined. :ach time "e assemble a il #ile$ a
t%pe called B0oduleH "ithin a null namespace (ets automaticall% created. Thus our T%pe=e#
table "ill have contain at least one t%pe come "hat happens.
244260235.doc 138 od 541

'# %ou remember "e have one more member in our arra% and thus "e can onl% displa% a t%pe i#
the len(th o# our arra% that stores the t%pe is lar(e than 2. There are valid cases "here the il #ile
has onl% (lobal #unctions and thus onl% t%pe called 0odule that does not have to be displa%ed.

!e #irst displa% the headin( class structure declaration and then initiali&e a variable
"ritenamespace to true. This instance variable "ill be used to determine "hether the directive
namespace be displa%ed or not.

!e then iterate throu(h the #or loop but the loop variable here starts #rom 2 and not 1 as the
dumm% class 0odule is dislied b% ildasm "hich does not displa% it. '# the name o# the class is
R=eleted and the stream name is SP and not SV$ ildasm does not displa% such a stream. '# %ou
remember the older assemblers called the main stream SP and not SV.

This is "hat happens "hen %ou stress test the code to catch all exceptions. Wet "e are not sure
"hether "e have a "orin( disassembler. * class "ithin a class is a nested class and the #unction
'sT%pe)ested checs "hether the class is a nested class. 't returns true i# the class is nested.

3ets #irst tae a pee at "hat this #unction is all about. '# %ou #irst tae a .uic pee at the e.il #ile$
%ou "ill reali&e that the class a1 ahs a class a3 de#ined "ithin it. This means that class a3 is
nested "ithin class a2. 't ho"ever does not stop there and class a33 is aloes created "ithin class
a3.

This means that class a33 is nested "ithin class a3. To mae matters "orse class a333 is nested
"ithin class a33. The class a2 has one more nested class a4 "hich has no more classes nested
"ithin it. Thus "e are allo"ed to nest as man% classes "ithin each other to our hearts content.

:ach t%pe "e create is stored in the T%pe=e# table. The )ested classes table has onl% t"o #ields
called the )ested class and the enclosin( class #ield "hich both are indexes into the T%pe=e#
table. The nested class is de#ined as a class that is placed inside or "ithin the text o# the
enclosin( class.

Thus the nested class #ield is the name o# the nested t%pe and the enclosin( class #ield is the class
"ithin "hich the nested class resides in. *s a example the class a2 is the enclosin( class and the
a3 class the nested class.

2o"ever there "ill also "e a record "here the class a3 "ill be the enclosin( or parent class and
the class a33 the nested class. *ll that "e do in this #unction is simpl% loop thou(h each record o#
the nested class table and i# the t%pe passed as the parameter matches the nestedclass #ield "e
return a true.

'# "e .uit out o# the loop "e no" that no match has been #ound$ "e return a #alse. The t"o must
index valid ro"s in the T%pe=e# table. Ooth the #ields cannot index the T%pe,e# table "here "e
store all the t%pes that "e are re#errin( to but exist some"here else. /bviousl% duplicate ro"s are
not allo"ed.

* nested t%pe can have onl% one parent or enclosin( t%pe. Thus the nestedclass table cannot have
t"o ro"s "ith the same value #or the nestedclass #ield but di##erin( enclosin( class #ield values as
that "ould mean that it is nested "ithin t"o classes "hich is not possible.

244260235.doc 139 od 541
The class a2 "ill appear t"ice in the nested class table as the value o# the enclosin( class #ield as
it contains t"o nested classes a3 and a4. The nestedclass #ields have di##erent values ho"ever.
The displa% o# the class protot%pe is carried out b% a #unction =ispla%/neT%pe4rotot%pe.

!e "ill onl% call this #unction i# the class is not a nested class. )ested classes do have an
independent existence and the% are displa%ed "ithin their enclosin( class. )ested classes are
displa%ed b% their parent class but the T%pe=e# table does not distin(uish bet"een nested and no
nested classes$ each is o##ered one ro" each.

Thus there is no column in the t%pede# table that tells us that "e have a nested class in our hands.
The onl% "a% "e no" that is class is nested is i# "e loo at the nestedclass #ield o# the nested
class table.

>unction call a#ter #unction call$ are "e out o# our minds or are "e (oin( to (et a a"ard #or the
maximum use o# #unctions in our code. The ans"er is as usual some"here in the middle. The
point is that "e are (oin( to displa% the t%pe protot%pes t"ice$ once no"$ once a(ain "hen "e
displa% the t%pes "ith all sorts o# thin(s lie #ields$ methods etc "ithin the t%pes.

)o point in "ritin( the same code t"ice. Thus the #unction =ispla%/neT%pe4rotot%pe calls three
other #unctions to do the 1ob. The #irst =ispla%/neT%pe=e#;tart displa%s the class name and the
attributes. Oe#ore "e displa% the t%pe "e need to #i(ure out "hether it part o# a namespace or not.

'n the il #ile "e have placed the t%pe a2 "ithin t"o namespace directives$ but ilasm ver% smartl%
converts in into a sin(le namespace "ith a dot "ithin it. !e use the strin( namespacename to
store the namespace name or null i# one does not exist. !e then spec the value o# this variable is
not null and then "rite the namespace directive.

*s this is a top level directive$ it needs to spaces in #ront o# it. !e then place the open braces and
then initiali&e t"o ver% crucial variables. The space#ornamespace variable is either 2 or its
de#ault 0. '# the t%pe is "ithin a namespace$ then "e have to add t"o spaces #or indentation and i#
there is no namespace$ then the spaces #or a namespace is &ero.

The spaces#orrest "ill be explained in a short "hile. The variable "ritenamespace is true and
hence the inner i# statement is true. !e "ill explain the use o# this variable later.

0ost o# the time "e "ill not use the !rite3ine #unction to "rite somethin( out but use a strin( to
store "hat "e "ant to "rite and then use a sin(le !rite3ine to "rite the entire strin( out #or us.
This is "here "e use the t%pestrin( to store the entire strin( #or the class directive.

!e #irst need to no" "hether our class is a nested class or not. '# it is then "e add to the
t%pestrin( variable the number o# spaces stored in the spaces#ornested variable. This variable has
a value o# 2 at present but "e "ill sho" %ou later that each time "e come across a nested class "e
increase this variable b% 2.

!e then add the number o# spaces &ero or 2 dependin( "hether the t%pe has a namespace or not.
,emember this variable space#ornamespace has a value o# &ero or t"o onl%. )o" that "e have
"ritten out the number o# initial spaces "e "rite out the "ords class and then the table name plus
the ro" number or "hat is called a toen "ithin comments.

This toen onl% (ets "ritten out i# the I*33 option is speci#ied to the disassembler and is ver%
use#ul to as it tells us the table and ro" number the entit% belon(s to. :ver%thin( in the metadata
244260235.doc 140 od 541
is stored in tables and "e are simpl% displa%in( "hat is there in these tables. :ach t%pe has lots o#
attributes and the "e the #unction DetT%pe*ttribute>la(s to return all the attributes as strin(.

The #la(s member o# the T%pe=e# table is a bit mas o# all the attributes and "e also pass the ro"
o# the t%pe. 3ets move on to this #unction to #i(ure out ho" the bit mas is decoded.

The desi(ners o# the t%pe attributes "e "ere ver% meticulous. )ot onl% do the% speci#% "hich bits
si(ni#% "hat attributes but the% also created lo(ical (roups #or them. Thus the #irst three bits
speci#% the visibilit% attributes. !e #irst bit "ise and "ith 7 to cull out the #irst three bits and then
chec "hich bits are on or o##.

Thus "e have 8 visibilit% values and each one is mutuall% exclusive o# the other. Thus both
private and public "ill not be on to(ether. ;trictl% speain( this sets o# bits are called visibilit%
and accessibilit%. * t%pe that is not nested "ithin a another t%pe "ill either "e public or private
and it "ill have no accessibilit%.

* pro(rammin( lan(ua(e ma% have introduce an% visibilit% attributes but in '3 a t%pe can onl% be
private or public. )ested t%pes instead have no visibilit% but have one o# six accessibilit%
attributes. These are nested assembl%$ nested #amil% and assembl% or #amandassem$ nested #amil%
or assembl% or #amorassem$ simpl% nested #amil% or assembl% or #inall% nested public or private.

>amil% is protected in +S "here the derived classes have accessibilit% and assembl% is restricts it
to classes in the same assembl% or #ile. *s al"a%s in li#e there are de#aults$ private #or non nested
t%pes and #or nested t%pes nested private.

*lon( "ith visibilit% and accessibilit% "e have one more concept called hidin( or better still
method name hidin(. 2idin( controls "hich method names that "e (et or inherit #rom a base t%pe
are available to the compiler #or compile time name bindin(.

* nested t%pe can have no visibilit% attributes as this privile(e is reserved #or top level t%pes onl%.
2ere "e have onl% t"o possibilities$ visible to t%pes "ithin the same assembl% private or public
visible to t%pes an%"here in the "orld or #or(et about the assembl% it resides in.

)ested t%pes are di##erent$ as the accessibilit% #urther re#ines "hich set o# methods can access this
t%pe. The visibilit% is decided b% the parent or enclosin( or top level t%pe. This means that the
nested t%pe can not be more visible than the enclosin( t%pe. This maes sense as the enclosin(
t%pe cannot be private the nested t%pe public.

'# "e do speci#% the enclosin( t%pe as assembl%$ even thou(h the nested t%pe is public$ the
enclosin( t%pe decides and the nested t%pe is onl% available "ithin the assembl%. 2o"ever i# the
enclosin( t%pe is public to be seen ever%"here$ but i# the nested t%pe is private$ the "ishes o# the
nested t%pe hold and it is not visible outside the assembl%.

The same lo(ical model is used to describe both the top level and nested t%pes. The "ord class is
"hat "e have been usin( all our lives and "e should be usin( t%pe instead. * inter#ace$ structures
or value t%pes are not classes and hence "e should use the broader term t%pe instead o# class. /ld
habits die hard.

2idin( does not appl% to t%pes but to the methods o# a t%pe and is compile time phenomena not a
runtime. The +ommon T%pe ;%stem o##ers us one bit to distin(uish bet"een the t"o mechanism
244260235.doc 141 od 541
o# 2idin(. The #irst is hide b% name "here b% speci#%in( a method o# a certain name hides all
method "ith that name #rom all derived classes.

The more complex one is name and si(nature "here the data t%pes o# the parameters passed
decides the name o# the method. Thus t"o methods havin( the same name but di##erent
parameters as in t%pe and number are treated as di##erent methods. There is no runtime support
#or hidin(.

The +3' treats all method as i# the% used the name and si(nature method o# hidin(. The ne"slot
attribute is "hat is used to speci#% hide b% name onl%. The next set o# attributes are the t%pe
la%out attributes. !e do "hat "e did earlier$ mas o# the bits that represent this lo(ical #amil% and
then chec "hich bits are on.

The t%pe la%out attributes tae an% o# three values$ auto$ explicit and se.uential. '# these bits are
&ero$ then the auto attribute is on. The onl% "a% "e can determine this is b% masin( o## all the
other bits but those that represent the t%pe attributes. !e cannot chec the b%te #or &ero as the
private visibilit% mas also has a value o# &ero.

The t%pe la%out decides "ho is in char(e o# arran(in( the #ields o# an instance o# a t%pe. The t%pe
can have onl% one o# these t%pe attributes. '# "e speci#% no attribute$ the de#ault is auto. This auto
attribute tells the +3' that the pro(rammer does not tae the responsibilit% o# la%in( out the #ields
in memor%.

3et the +3' place the #ields "herever it "ants and the user "ill not la% do"n an% conditions at
all. The onl% problem "ith this "a% is that "e lac #lexibilit% and at times "e "ould "ant to
decide ho" thin(s are laid out at the dinner table or in memor%. *t these times "e use the explicit
attribute "here "e decide "here the #ields "ill be laid out in memor%.

The last option is se.uential "here "e let the +3' la% the #ields out "ith one small condition. The
#ields should be placed one a#ter the a#ter in memor% and the metadata tables decide "hich #ields
come in "hat order. !e should normall% in our interest let the +3' decide ho" to la% #ields in
memor%.

!e should use se.uential #or lan(ua(es lie +I+CC as "e (et the best o# both "orlds. !e (et
veri#iable output and "e also #ollo" the rules o# these lan(ua(es also. The last option is explicit
"here "e are the masters o# the memor% la%out. *s "e told %ou earlier a t%pe can be a class or
value t%pe or inter#ace.

The t%pe semantics attribute tells us 1ust that and it is sin(le bit "hich i# on tells us that "e have
an inter#ace. '# the t%pe is derived #rom ;%stem.-alue either directl% or indirectl% a value t%pe and
i# none o# the above is true$ a simple class. The si&e o# a value t%pe at runtime is 1 0O or
0x100000 and the implementation "e are usin( taes us up to 0x3#0000 and this value ma% be
reduced.

2onestl% "h% do people "ant such lar(e value t%pe is be%ond out understandin(. * value t%pe is
a class that becomes a value t%pe #or reasons o# e##icienc%. The basic +S classes lie int and char
are all value t%pes. !e no" have t"o inheritance attributes abstract or sealed.

These attributes are not mutuall% exclusive and thus "e have t"o separate strin(s to hold their
values. * abstract class cannot be used directl% i.e. "e cannot instantiate it usin( ne". This is
244260235.doc 142 od 541
because it contains #unctions and unless "e implement these in a derived class "e cannot use the
abstract class.

!e use abstract classes "hen "e "ant to user to implement some methods be#ore usin( our class.
Thus an abstract t%pe must contain abstract methods that the derived class has to suppl% code #or.
;ealed classes are a di##erent ettle o# #ish. These classes cannot be derived #rom or have
subclasses.

/ne o# the reasons o# doin( this is e##icienc% as the compiler no"s that no one can derive #rom
these classes and thus (enerate more e##icient code. *lso at times ' do "ant m% classes to be
tampered "ith and thus b% usin( the sealed attribute ' let no pro(rammer modi#% m% code. Nse as
is or donQt.

-irtual #unctions are used so that the derived classes can override them and in a sealed class the%
become common instance methods as there are no derived class to override them. The bi(
problem "ith sealed classes is that the% stop the user #rom extendin( the class hierarch%.

/ne reason to use sealed is "hen "e have a class that implements di##erent inter#aces becomes
interdependent on implementation issues that "ill not be visible to sub classes. * t%pe that is both
abstract and sealed should have onl% static members as the abstract is not a usable class and the
sealed does not let us derive #rom the class.

This is also "hat is called a namespace in some lan(ua(es. !e no" come to the three
interoperation attributes ansi$ autochar or unicode. !e are runnin( in "hat is called mana(ed
code and the earlier pro(rams "e ran in +I+CC be#ore the advent o# .)et "ere runnin( in
unmana(ed code.

!e "ould lie to call unmana(ed code #rom mana(ed code and thus these attributes tell the
s%stem ho" to deal "ith strin(s. Thus is the return t%pe or a parameter is o# t%pe strin($ does an%
speci#ic conversion need to be done. This conversion is called marshallin(. /nce a(ain these
values are mutuall% exclusive and the de#ault us ansi.

This means that the marshallin( "ill done #rom either side as ansi strin(s. The unicode attribute
speci#ies that strin( both sides "ill be in unicode. >inall% the best is autochar that "ill use either
unicode or ansi dependin( upon the plat#orm "e are runnin(. *ll decent plat#orms toda% support
unicode as computer people have reali&ed that the "orld does not spea :n(lish #or(et about
(ood :n(lish.

>inall% "e come to the special handlin( attributes that are #our in number and can be combined in
an% manner that "e desire. These attributes are also meant #or the tools because i# the +3' treats
an item in a di##erent or special "a%$ "h% hide it #rom the tools.

The special name attribute means that the item name is special not onl% to the +3' but also to
tools. /ne example is the name .ctor "hich stands #or a non static constructor. The attribute
rtspecialname is lie special name but "ith a small di##erence. 't ver% clearl% means that the +3'
understands this item.

There are no t%pes as o# toda% that "ill be mared "ith this attribute as it is reserved #or #uture
use. *n% item that "ill be mared rtspecialname "ill also be mared special name. !e have
placed this code in comments as i# "e use this attribute$ the assembler i(nores it.

244260235.doc 143 od 541
!hen a static method is called #rom a t%pe "e do not have to create a instance o# the t%pe. O%
usin( the be#ore#ieldinit attribute "e are tellin( the +3' that it need no initiali&e the t%pe "hen a
static method is called. The de#ault is that it does initiali&e the t%pe. ;eriali&ation is the art o#
"ritin( data to dis or a data stream.

O% speci#%in( the seriali&able attribute "e are allo"in( the +3' seriali&er to "rite the t%pe to a
data stream. >inall% the import attribute tells the +3' that this t%pe is imported #rom a +/0 t%pe
librar%. Oe#ore the .)et came on$ the mantra at 0icroso#t "as *ctiveK "hich "as based on +/0
or the +omponent /b1ect 0odel.

)o" that "e have individual strin(s #rom each lo(ical #amil%$ "e need to displa% them in a
certain order. This order speci#ies that the inter#ace attribute comes #irst and the be#ore#ieldinit
attribute last. The attributes are not displa%ed in the order that "e "rote them. *lso the nested
t%pes #ollo" a di##erent order. 't too us a lon( time to #i(ure out this order.

)o" that "e have all the attributes$ "e "rite out the name o# the t%pe alon( "ith the attributes.
:ver% t%pe derives #rom a t%pe and i# do not speci#% one$ the t%pe derives #rom ;%stem./b1ect in
the assembl% mscorlib. *lso a t%pe can implement #rom a number o# inter#aces but it can derive
#rom a sin(le t%pe onl%.

!e use the extends e%"ord to speci#% the base t%pe. 'n the same vein the implements e%"ord is
used #or inter#aces. These "ords are "hat are also used in ?ava$ the arch enem% o# the .net "orld.
'# the inter#ace has sa% #ive #unctions$ the t%pe implementin( this inter#ace has to implement all
the #ive #unctions be#ore it can be instantiated.

Thus the t%pe has to #ul#ill a contract o# implementin( all the method speci#ied in the inter#ace
be#ore the t%pe can be used. The #ield extends or "het "e call cindex tells us "hich class this t%pe
extends #rom. *n extends speci#ies onl% one t%pe "hereas the implements clause can speci#%
man% inter#aces.

These t"o bits o# in#ormation are ept separatel% in the metadata. The cindex #ield speci#ies a
T%pe=e#/r,e# +oded index. This coded index speci#ies one o# three tables$ T%pe=e#$ T%pe,e# or
the T%pe;pec table. 'n this case it cannot speci#% the T%pe;pec table as that table ahs a sin(le
#ield and there is no name attached to the t%pe.

Thus "e cannot use these t%pes #ound in the T%pe;pec table #or the extends clause. !e use the
DetT%pe=e#/r,e#Table to #i(ure "hich table the coded index points to. '# the code index re#ers
to the T%pe,e# table$ it means that t%pe used is de#ined in another assembl% and had it been the
T%pe=e# table$ the same assembl%.

!e use the #unctions =ispla%T%pe,e#:xtends and =ispla%T%pe=e#:xtends to #i(ure out the name
o# the class. /ver to the =ispla%T%pe,e#:xtends #unction #irst.

'# %ou have not noticed ever% coded index #unction comes in a pair$ the name endin( "ith table
(ives us the coded index table$ the name endin( "ith -alue (ives us the coded index table ro"
number. The #unction =ispla%T%pe,e#:xtends is a prett% lar(e and thus "e advise to have a bi(
hot cop o# co##ee be#ore %ou start readin(.

Wou have been "arned. This #unction is passed the t%pe re# ro" number as "henever "e use a
t%pe de#ined some"here else$ the t%pe re# table (ets a ro" added. This t%pe re# ro" has a coded
index called the resolution scope.
244260235.doc 144 od 541

This coded index points to #our tables$ 0odule$ 0odule,e#$ *ssembl%,e# and itsel#$ T%pe,e#. 'n
spite o# it pointin( to #our tables "e "ill explain "h% "e have onl% checed #or three tables$
0odule,e#$ T%pe,e# and *ssembl%,e#. The #irst value "e chec is *ssembl%,e# as this should
be the most common.

!hen %ou loo at class a8 "e are extendin( it #rom the class aaa in the mscorlib assembl%. The
resolutionscopeindex variable no" points to a ro" number in the *ssembl%,e# table and "e
displa% the name o# the assembl% re# struct and the ro" number in s.uare bracets. The class a9
also meets the same #ate but this class is a nested class.

The class a10 and a12 are sli(htl% similar. 'n the case o# class a10 "e are speci#%in( that the
external class a11 is in a module called bb. This module is de#ined b% usin( the module extern
directive. Thus in the s.uare bracets "e can either speci#% a assembl% re# or a external module.

The class can be in the present in the same assembl% but in a separate module. 'n this case "e
"rite out the "ords .module and use the variable resolutionscopeindex as index into the
0odule,e# table. !e also "rite out the table number as 1*. Thus the above t"o coded index
tables are similar in concept onl% the table chan(es.

!e come to class a12 "here "e speci#% the module directive a(ain but use the name o# the
module as the name o# the current module e.exe. The assembler is smart enou(h to no" that "e
are re#errin( to the same module that "e are in and i(nores our module directive.

Thus the resolutionscope index can have a coded index o# 0odule but "e have to "rite no code
to handle it. ,emember i# somethin( is in the same module "e do not have to .uali#% it. !e onl%
need to speci#% "here an entit% is i# it is some"here else. This some"here else can be a di##erent
module than the one "e are in or a another assembl%.

)o" lets loo at the #ourth table T%pe,e# "hich means that coded index is pointin( to a ro" in
itsel#. This happens in the case o# class a9 "hich extends #rom a nested class in the assembl% re#
mscorlib. The class a8 also extends #rom the class aaa in the assembl% mscorlib but it is not
nested the coded index table is strai(ht #or"ard.

)o" that "e have a nested class the coded index table "ill be a t%pere#. !hen "e (o to that ro"
in the T%pe,e# table$ "e "ill once a(ain pic up the coded index and in this speci#ic case it "ill
be the *ssembl% ,e# table as our nested class is in the mscorlib assembl%.

!e #irst "rite out the assembl% name lie be#ore and then #i(ure out "hether the class aaa
belon(s to a namespace or not. The #ield nspace tells us the name o# the namespace but "e use
the earlier coded index ro" variable resolutionscopeindex and not the second one. Thus variable
nspace1 "ill contain the value ppp.

!e then add a dot as the class namespace separator onl% i# the class aaa belon(s to a namespace.
!e next displa% the ro" number o# the class aaa that happens to be 3 in this case. Then "e place
a I because the next class #ollo"in( is the nested class and separator bet"een nested classes is a
sin(le I.

The problem "ith "ritin( code is that there are too man% possibilities to tae care o#. '# the #irst
coded index table is T%pe,e#$ then "e have to chec #or the other tables also. '# "e place a nested
244260235.doc 145 od 541
class "ith module$ then the second coded index table "ill have the values o# 0odule or
0odule,e#.

!e have not "ritten code #or these cases as "e have le#t it to %ou to implement. Thus a class
statement as .class a99 extends 6.module bb7ppp.aaaIaa 9@ "ill not "or as the second coded
index "ill no" be 0odule,e# and "e have not handled such a case.

The mistae "e made is that "e should have had a #unction that handles a resolution coded index.
Then "e could call this #unction each time. The reason "e do not is that it "ould mae the
pro(ram more di##icult to understand.

>inall% i# "e "rite a line lie .class a99 extends 6mscorlib7ppp.aaaIaaIbb "e "ill also (et an error
as the second coded index table "ill be a T%pe,e#. Thus each nested "ithin nested class "ill eep
(ivin( us a ro" in the T%pe,e# table.

!hat "e are sa%in( is that each nested class "ithin a nested class is a separate ro" in the
T%pe=e# table and "e "ould need a concept called recursion to handle this. >inall% "e come the
end "here "e need to displa% the namespace and the name o# the class.

!e use the parameter t%pere#index to (et at the name o# the class and namespace and decide
"hether to place the dot separator. *s this is a common thin( "e al"a%s do$ "e "ill not explain it
a(ain. The point to understand is that the class name is "ritten in the reverse order #or a nested
class.

The enclosin( class is speci#ied #irst and then the nested classes. Thus #or class a9$ it extends
nested class aa that has a ro" number o# 4 in the T%pe,e# table. This class is nested "ithin class
aaa "hich is ro" number 3 and is in a namespace ppp.

/ur pro(ram lie all pro(rams is not complete because the #ollo"in( line is in error. .class a99
extends 6mscorlib7ppp.aaaI....aa. The assembler passes it in spite o# a #la". The nested class aa
cannot have a namespace ... as a namespace is a top level construct.

The disassembler is smart enou(h to understand and it removes the namespace. !e thus need to
"rite code that sa%s i# the #irst coded index table is T%pe,e# then the nested classes cannot have a
namespace. !e did not as the assembler did not.

!he". )o" "e come bac to the #unction =ispla%/neT%pe=e#;tart and chec the second table
name o# the T%pe=e#/r,e# coded index T%pe=e#. This happens "hen "e extend #rom a t%pe that
is created in the same module. This t%pe "ill obviousl% have a ro" in the T%pe=e# table.

!e simpl% have to displa% the contents o# the T%pe=e# table and this is "hat the #unction
=ispla%T%pe=e#:xtends does. '# ever the ro" number o# an% table is 0$ this means that this is not
a valid ro" number. This is a simple #unction as the name and nspace #ields (ive us the name and
namespace and "e add the toen "ithin comments and return this strin(.

The problem is not #or simple t%pes but #or nested t%pes. Thus "e have a #unction
Det)estedT%pe*s;trin( that #irst #i(ures out the nested t%pe. The problem is "ith class a7 "hich
extends nested class a333 that is nested "ithin classes a33 and a3. '# %ou are not clear about the
toens "hich is displa%ed immediatel% a#ter the class name.

244260235.doc 146 od 541
The class a2 has a ro" number o# 4 "hich %ou can veri#% b% seein( the class 4 de#inition. The
parameter ro"index is that o# class a333 and its value is ro" 7. !e #irst chec i# this class is
nested usin( the #unction 'sT%pe)ested. )o" that "e have nested class$ "e "ould "ant to #i(ure
out the parent o# this nested class a333.

!e use a #unction Det4arent>or)estedT%pe that returns the enclosin( class #or us. This #unction
is a no brainer. !e told %ou eons a(o that the )ested +lass table has t"o #ields$ one that "as the
t%pe index o# the nested class and other the enclosin( class.

Thus "e loop thou(h the entire arra% )ested+lass;truct and brea "hen "e meet a ro" "here the
parameter t%peindex e.uals the #ield nestedclass$ the ro" number o# the nested class. !e return
the enclosin(class #ield as this is the ro" number o# the enclosin( class.

!e build no error chec as both #ields have to valid indexes in the T%pe=e# table. !e then chec
"hether ro" 6 or class a33 is a nested class$ and i# it is "e a(ain determine the parent o# the
nested class a33 "hich is a3 or ro" number 5. >inall% "e come to the parent o# class a33 that is
class a3 or ro" number 4.

The strin( nameparent3 and namespaceandnameparent3 "ill displa% the name and namespace #or
the top most class a2 .i.e. ro" 4 as it uses the variable ro"indexp3. This is responsible #or the
namespace n1.n2. !e then place the nested class separator and then use the variable
ro"indexparentparent to (ive us the name o# class a33.

Then "e use variable ro"indexparent to (ive us the next nested class a33 and the namespace i#
an% and #inall% the variable ro"indexparent #or the actual name o# the class a333. The second
namespace is used in the case o# class a72. Thus dependin( upon the number o# levels o# nested
classes "e use the relevant namespace #ield.

'n the case o# class a71$ the netsedt%pestrin( variable (ives us the namespace n1.n2. This is "h%
"e need to place the namespace t"ice in our code. /bviousl% all is not ri(ht in our pro(ram as "e
have assumed a certain level o# nestin(.

Thus i# "e introduce a class .class a72 extends n1.n2.a2Ia3Ia33Ia333Ia3333 "e "ill (et an error
as "e have one more level o# nestin(. * better "a% "ould be to use recursion as "e mentioned
earlier. To solve the above problem add one more level o# nestin( but %et it "ould be a imper#ect
solution.

* similar problem arises "ith the T%pe,e# class and "e have onl% handled one level o# nested
classes. Thus the class .class a91 extends 6mscorlib7ppp.aaaIaaIbb "ill (ive us a problem as "e
have not handled a case "here there are t"o levels o# nestin(. The coded index table "ill have a
value o# T%pe,e# in the second case.

* point to understand is the di##erence in ho" nested classes are handled b% a T%pe,e# and a
T%pe=e#. :ach nested class exists in the T%pe,e# table as a separate ro" and the coded index tells
us that there are more t%pes nested b% a value o# T%pe,e#. 'n the case o# the T%pe=e# table$ the
)ested +lass table tells us "hether the levels o# nestin(.

The t%peextends variable b% no" contains the class name that "e "rite a#ter the "ord extends.
The problem is that i# "e do not speci#% a class name$ ilasm adds the class name /b1ect
automaticall%. The problem comes in "hen "e have a inter#ace. 'nter#aces do not automaticall%
derive #rom the class /b1ect.
244260235.doc 147 od 541

Thus i# and onl% i# the t%peextends variable is non null do "e "rite out the e%"ord extends
alon( "ith the t%pe. Oe#ore "e "rite the "ords extends on a ne" line "e need to #irst "rite
spaces #or nested classes #ollo"ed b% the space taen i# the class is "ithin a namespace.

The last part o# the class directive is the implements that carr% the list o# inter#aces and not
inter#ace that "e implement #rom. The #unction =ispla%*ll'nter#aces is "hat "e use. :ach time
"e create an inter#ace it is stored in the 'nter#ace'mpl table. !e loop thou(h all the records in this
table and chec #or the #ield called classindex.

* inter#ace is also a class and has a valid ro" number in the T%pe=e# table. This same ro"
number is also the value o# the classindex #ield. '# a class implements more than one inter#ace$ the
classindex #ield "ill repeat. Thus i# a class implements #rom three inter#aces$ this table "ill have
three ro"s "ith the same value o# the classindex #ield.

The extends and the implements classes are stored in di##erent tables as the implements shares a
one to man% relationship. The #ield inter#aceindex is the T%pe=e#/r,e# coded index and #rom
no" on the same code "e used earlier to retrieve the class name is also used here. The last
problem in this #unction is one o# indentation.

:ach inter#ace needs a line o# its o"n to be displa%ed. The problem on hand is ho" do "e no"
that this is the last inter#ace to be displa%ed. !e tae a Ooolean variable nextclassindex to tell us
"hether "e should displa% an enter and spaces a#ter the inter#ace name. !e #irst chec i# it is the
last ro"$ there cannot be an% more inter#aces and hence "e set variable nextclassindex to #alse.

*lso i# the classindex o# the next ro" is not the same as the parameter t%peindex "e set
nextclassindex to #alse. This assumes that #or the same t%pe$ all the inter#aces are stored one a#ter
another. '# none o# the above are true$ "e set variable nextclassindex to true. !e then use this
variable to "rite out a ne" line "ith spaces or not.

The last thin( "e do is displa% the 9 "ith the ri(ht number o# spaces. !ithin the class protot%pe
"e displa% nothin( else but protot%pes o# nested classes.

+omin( bac to one #unction =ispla%/neT%pe4rotot%pe "e no" call the #unction
=ispla%)estedT%pes4rotot%pes. !e "ill use this #unction to displa% all the nested t%pes #or "hich
the t%peindex is a enclosin( class.

The important thin( to understand here is that nested classes are to be displa%ed in the same "a%
as the enclosin( class but onl% need to be indented b% 2 each time. Thus the code that "e "rote in
the #unction =ispla%/neT%pe=e#;tart can be reused.

*lso unlie the "a% "e have been "ritin( code so #ar$ "e cannot assume that the level o# nestin(
"ill be 3 or 4 or 5. This is the #irst time "e "ill use the concept o# recursion. The basic premise o#
nestin( is that "rite the code once call it a(ain. This mae recursion lie a #unction call. True but
"ith a sli(ht di##erence.

!e "ill call the same #unction "ithin the same #unction. +omplex$ lets explain "ith a actual
example. 'n the #unction =ispla%)estedT%pes4rotot%pes "e have no idea o# ho" man% classes
are nested "ithin this class or does it have an% nested classes.

244260235.doc 148 od 541
There is one table the )ested classes table that has the nested classes details stored. !e iterate
thou(h this table and chec "hether the parent or enclosin( class #ield has the t%peindex passed
as a parameter. '# %es$ then this class o# ours has nested classes.

!e then call the #unction =ispla%/neT%pe4rotot%pe that displa%s the protot%pe o# a t%pe. !e
pass the nestedclass #ield as that #ield contains the nested class to be displa%ed. * class can have 6
nested classes in it and this i# statement "ill be true six times.

The ma1or point is that each nested class in turn ma% have a million levels o# nestin(. 'n the
#unction =ispla%/neT%pe4rotot%pe "e are #irst callin( the #unction =ispla%/neT%pe=e#;tart
"hich displa%s the class directive.

Oe#ore callin( this #unction "e increase the instance variable spaces#ornested b% 2 and thus this
nested class "ill indent b% 2 as its value "ill be 4 and not 2 as earlier. *#ter the 9 is displa%ed$ the
#unction =ispla%)estedT%pes4rotot%pes "ill be called a(ain. ,emember the #irst
=ispla%)estedT%pes4rotot%pes is not %et over.

This is the #lavor o# recursion$ callin( the same #unction a(ain in spite o# the #act that the earlier
call is not over and lies suspended in memor% "aitin( #or the second call to be over. )o" in the
#or loop the t%peindex value is o# the nested class and no" it is the enclosin( class.

'# the nested class has an% #urther nests$ then the second =ispla%)estedT%pes4rotot%pes is
suspended and the variable spaces#ornested increase b% 2. *t some point in time the #or loop "ill
not match and the #unction =ispla%/neT%pe4rotot%pe "ill not (et called. This "ill result in the
#unction =ispla%/neT%pe=e#:nd be called "hich displa%s the end o# the class closin( brace.

!e "ill then move out o# the #unction =ispla%/neT%pe4rotot%pe as there are no more #unctions
le#t to be called. This "ill result in the variable spaces#ornested havin( a value o# t"o less. The
problem "ith recursion is that some tae a million tries be#ore the% (et it but no one (ets it in one
or t"o.

;o read a(ain and then come bac to the last #unction =ispla%/neT%pe=e#:nd.

This #unction simpl% has to displa% the close brace$ end o# class and the end o# namespace i# an%.
The "ritenamespace variable starts "ith a value o# true and i# and onl% i# its value is true do "e
displa% the namespace directive in the #unction =ispla%/neT%pe=e#;tart.

!e #irst chec "hether the namespace variable contains a valid namespace name. '# it is null "e
mae the variable "ritenamespace to #alse so that the directive namespace is not displa%ed. !e
then need to #ind out the next class that "ill be displa%ed a#ter this class.

!e cannot assume that it "ill be the next ro" as that could be a nested t%pe "ithin the current
t%pe. Thus "e need to scan the next ro" #rom the t%pe "e have ri(ht no" displa%ed and eep
(oin( till "e reach the end. !e chec each succeedin( t%pe and loop bac i# it is a nested t%pe
under the t%pe "e have 1ust displa%ed.

'# the t%pe is not nested "e brea. !e are assumin( that the enclosin( t%pes and nested t%pes are
placed one a#ter the other. )o" that "e have le#t the #or loop "e are on a t%pe that "ill be
displa%ed a#ter this t%pe. !e add a chec that "e are not at the end o# the table and #ind out the
namespace o# this t%pe.

244260235.doc 149 od 541
!e "rite out the closin( brace o# the namespace and also its name. *s this is the end o# a
namespace "e reset the variable space#ornamespace to 0 as there is no indentation #or the
namespace and the spaces#orrest is reset to 2 as this variable (ives us the indentation #or the
succeedin( entit% to be placed as "e shall soon see.

*s the "ritenamespace is set to true$ the next time "e come across a class that has a namespace
the namespace directive "ill be displa%ed. The point is that i# t"o classes #all under the same
namespace$ the namespace directive is not repeated at all.

!e displa% the #irst namespace directive and then onl% displa% it i# "e have "ritten out the end o#
namespace as the namespace directive cannot be nested. 2ence the "ritenamespace variable is set
to null in the else o# the #irst i#.

The T%pe,e# table contains onl% three #ields and the ,esolution;cope coed index as per the specs
can tae #ive possible values. /ut o# these #our "e could demonstrate i.e. the T%pe,e#$ 0odule$
0odule,e# and *ssembl%,e# tables. The #i#th is "hen the value is null "hich means that the
table is the :xportedT%pe table. * t%pe in this table is not a valid t%pe a#ter the extends e%"ord.
!e cannot have t"o t%pes in this table "here the name and namespace #ields are the same.

'# "e did not mention this be#ore the 'nter#ace'mpl table onl% has t"o #ields class "hich is the
index into the T%pe=e# table and the #ield inter#ace that is a T%pe=e#/r,e# coded index. '# "e
have 10 ro"s in this table$ it means that the t%pe denoted b% the class #ield implements a certain
inter#ace.

/bviousl% the class #ield must be non null and i# is b% mistae null$ "e should assume that this
ro" does not exist at all. 't happens "hen a class is deleted and the metadata is not updated and
re"ritten "hen the compiler incrementall% compiles. * time saver. The inter#ace #ield indexes
into the T%pe=e# or T%pe,e# table and not T%pe;pec as T%pe;pecs do not have a name.

*lso the class must have the inter#ace #la( on and cannot be a #ormal class or -alue T%pe. The
class and inter#ace values to(ether cannot be duplicate$ but the class b% itsel# and be more than
one as a class can implement lots o# inter#aces. -ice -ersa the inter#ace #ield can be multiple as
one inter#ace can be used b% multiple classes.

4ro(ram18.csc
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
244260235.doc 150 od 541
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
=ispal%-t>ixup58<
=ispla%T%pe=e#s58<
=ispla%T%pe=e#s*nd0ethods 58<
@
public void =ispla%T%pe=e#s*nd0ethods 58
9
notprotot%pe A true<
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
@
+onsole.!rite3ine58<
+onsole.!rite3ine5FII AAAAAAAAAAAAAAA D3/O*3 >':3=; *)= 0:T2/=;
AAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
II=ispla%Dlobal>ields58<
II=ispla%Dlobal0ethods58<
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
+onsole.!rite3ine58<
+onsole.!rite3ine5FII AAAAAAAAAAAAAAA +3*;; 0:0O:,; =:+3*,*T'/)
AAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine5FII note that class #la(s$ LextendsL and LimplementsL clausesF8<
+onsole.!rite3ine5FII are provided here #or in#ormation onl%F8<
+onsole.!rite3ine58<
int A T%pe=e#;truct.3en(th <
#or 5 int i A 2 < i B < iCC8
9
i# 5 Det;trin(5T%pe=e#;truct6i7.name8 AA FR=eletedF GG streamnames607 AA FSPF8
continue<
i# 5 E 'sT%pe)ested5i8 8
9
=ispla%/neT%pe5i8<
@
@
@
=ispla%:nd 58<
@
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
244260235.doc 151 od 541
=ispla%)estedT%pes5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%)estedT%pes 5int t%pede#index8
9
i# 5)ested+lass;truct AA null8
return <
#or 5 int ii A 1 < ii B )ested+lass;truct.3en(th < iiCC8
9
i# 5)ested+lass;truct6ii7.enclosin(class AA t%pede#index8
9
spaces#ornested CA 2<
=ispla%/neT%pe5)ested+lass;truct6ii7.nestedclass 8<
spaces#ornested PA 2<
@
@
@
public void =ispla%:nd58
9
strin( nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6T%pe=e#;truct.3en(thP17.nspace88<
i# 5 E placedend8
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
placedend A true<
@
+onsole.!rite3ine5FIIJJJJJJJJJJJ =';*;;:0O3W +/043:T:
JJJJJJJJJJJJJJJJJJJJJJJF8<
i# 5datadirector%rva627 EA 08
+onsole.!rite3ine5FII !*,)')DM +reated !in32 resource #ile a.resF8<
@

public void ,eadTables'nto;tructures58
9


int ii <
#or 5 ii A 1 < ii BA T%pe=e#;truct.3en(th P 1 < iiCC8
9
II+onsole.!rite3ine5F........90@ 91@ 92@F $ T%pe=e#;truct.3en(th $ 'sT%pe)ested5ii8 $ ii8<
i# 5 E 'sT%pe)ested5ii8 8
lastt%pedispla%ed A ii<
@
@

e.il
.namespace aa
9
.class a1
244260235.doc 152 od 541
9
.class a33
9
@
@
@
.class a2
9
@

/utput
II AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA


II AAAAAAAAAAAAAAA D3/O*3 >':3=; *)= 0:T2/=; AAAAAAAAAAAAAAAAAAA


II AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA


II AAAAAAAAAAAAAAA +3*;; 0:0O:,; =:+3*,*T'/) AAAAAAAAAAAAAAAAAAA
II note that class #la(s$ LextendsL and LimplementsL clauses
II are provided here #or in#ormation onl%

.namespace aa
9
.class IJ02000002JI private auto ansi a1
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.class IJ02000003JI auto ansi nested private a33
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class a33

@ II end o# class a1

@ II end o# namespace aa

.class IJ02000004JI private auto ansi a2
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class a2


II AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

IIJJJJJJJJJJJ =';*;;:0O3W +/043:T: JJJJJJJJJJJJJJJJJJJJJJJ

*#ter a lon( time pro(ram18 (ives us a output that matches the output displa%ed b% the ori(inal
disassembler. !e have a namespace aa that has a class a1 "hich in turn has a nested class a33.
244260235.doc 153 od 541
The class a2 is not enclosed in a namespace. The above il #ile has no methods and thus "e need to
compile it into a dll usin( the I=33 option.

)o" lets loo at code that "e have added to (et the above ma(ic. Th excitement no" starts and
step b% step "e "ill eep addin( more and more to the il #ile and "rite code that matches the
output b% the disassembler. !e call the #unction =ispla%T%pe=e#s*nd0ethods in the #unction
abc to displa% the contents o# the t%pes #or us.

'n this #unction "e #irst set the variable notprotot%pe to true "hich i# %ou remember "as set to
#alse earlier and thus some code "hich "e did not explain but "ill explain no" did not (et called.
!e also told %ou some time bac that a dumm% class called module al"a%s (ets created even
thou(h %ou do not have a sin(le class de#ined.

Thus "e #irst chec that the user has created at least one class and then onl% displa% the A si(ns in
comments. !e then "rite out the comments #or (lobal >ields and 0ethods. These (lobal entities
are allo"ed in lan(ua(es lie '3$ +CC but not in +S.

!e use t"o #unctions to displa% these (lobal #ields and methods but comment them out #or the
moment as "e "ill explain them later. !e have more pressin( thin( to do at this moment. /nce
a(ain i# there are classes to be displa%ed "e "rite out the "ords class members declaration "ith
the re.uired comments #or extends and implements.

* "aste o# code and space i# %ou as us. !e then place a blan line and come to the core o# this
#unction usin( a #or loop that starts at 2 and not 1 and till the number o# ro"s in the arra%
T%pe=e#;truct. *s be#ore "e tae care o# classes called R=eleted and let the #unction
=ispla%/neT%pe tae care o# the displa%in( one T%pe.

This is lie the earlier T%pe 4rotot%pe displa% #unction and thus "e "ill not explain the i#
statement checin( #or nested classes. >inall% "hen "e leave the #or loop the #unction
=ispla%:nd "ill displa% the last lines o# the output. *#ter this it (oin( bac to bed.

)o more #unction calls. 3ooin( at the =ispla%/neT%pe #unction$ all that "e do is call t"o
#unctions "e have called be#ore =ispla%/neT%pe=e#;tart and =ispla%/neT%pe=e#:nd. This is
ho" "e reuse code.

!e also call the =ispla%)estedT%pes #unction to displa% nested t%pes "ith the onl% di##erence
#rom its protot%pe cousin is that is calls the =ispla%/neT%pe #unction instead o# the protot%pe
cousin. 3ets explain the role o# a variable lastt%pedispla%ed that "e initiali&e in the #unction
,eadTables'nto;tructures.

*t the end o# this #unction "e have a #or loop that loop throu(h the t%pe table. !e "ould lie to
no" the last t%pe "e are displa%in(. !e cannot assume that it is the last ph%sical t%pe as that
t%pe could be a nested t%pe that "ill displa% "ithin another t%pe.

Thus set the variable lastt%pedispla%ed to the loop variable ii as lon( as the t%pe is not nested. !e
do this once and then do not chan(e the value o# this variable at all. To understand better "e
"ould lie to #lip lots o# pa(es and move over to =ispla%/neT%pe=e#:nd #unction o# the earlier
pro(ram. 3ets tae a di##erent e.il #or this case.

e.il
.namespace aa
244260235.doc 154 od 541
9
.class a1
9
@
@

!e have to "rite out a series o# A e.ual to si(ns "ith a enter be#ore and a#ter. '# the last t%pe to be
displa%ed #alls "ithin a namespace "e have to "rite out the e.ual to si(ns be#ore "e close the
namespace.

Thus i# "e are displa%in( the last t%pe "hich happens "hen the variables lastt%pedispla%ed e.uals
t%peindex then "e "rite out the man% e.ual to si(ns. *s this #unction (ets called t"ice once #or
protot%pes i# %ou have not #or(otten$ the notprotot%pe variable has to be set to true.

The placedend variable is set to true as "e have "ritten out the e.ual to si(ns. The above il #ile
calls the #irst i# statement as the t%pe to be displa%ed a1 is also the last t%pe. !e must remember
that the t"o namespaces nspace1 and nspace2 must not be null. >inall% "e come to the #unction
=ispla%:nd "hich as said be#ore is the last #unction to be called.

'# "e have a il #ile "ith no namespace or better still the last class is not "ithin a namespace the
earlier code "ill not place the A si(ns. Thus "e #irst chec the value o# the placedend variable. '#
it is #alse$ it means that "e have to "rite out the closin( e.ual to si(ns.

!e do have to initiali&e the placedend variable to true as no code (ets called a#ter this but even i#
"e do it onl% means that "e are lous% pro(rammers. '# the second data director% member is non
&ero$ it means that "e have a the disassembler create a resource #ile #or us and "e need to displa%
the value o# this #ile that is al"a%s called a.res.

Thus "e have no" "ritten a pro(ram that matches the output (enerated b% the disassembler but
do not start the celebrations as "e have miles an miles to (o.

4ro(ram19.csc
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac 5t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%;i&e*nd4ac 5int t%peindex8
9
i# 5 +lass3a%out;truct AA null8
return<
#or 5 int ii A 1 < ii B +lass3a%out;truct.3en(th < iiCC8
9
i# 5 +lass3a%out;truct6ii7.parent AA t%peindex 8
9
+onsole.!rite5+reate;paces5spaces#ornested C spaces#orrest88<
+onsole.!rite3ine5F.pac 90@F $ +lass3a%out;truct6ii7.pacin(si&e8<
+onsole.!rite5+reate;paces5spaces#ornested C spaces#orrest88<
+onsole.!rite3ine5F.si&e 90@F $ +lass3a%out;truct6ii7.classsi&e8<
244260235.doc 155 od 541
@
@
@

e.il
.class a1
9
.pac 2
@
.class a2
9
.si&e 2
@
.class a3
9
.si&e 2
.pac 2
@


/utput
.class IJ02000002JI private auto ansi a1
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.pac 2
.si&e 0
@ II end o# class a1

.class IJ02000003JI private auto ansi a2
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.pac 1
.si&e 2
@ II end o# class a2

.class IJ02000004JI private auto ansi a3
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.pac 2
.si&e 2
@ II end o# class a3

!e have added a #unction =ispla%;i&e*nd4ac that displa%s the directive si&e and pac that "e
have added in our class. * si&e and pac directive #ill up a ro" in +lass 3a%out table. This table
has three #ields$ t"o to store the si&e and pac directives and the third to tell us "hich t%pe carries
these directives.

The reason "e do not store these pac and si&e directives in the T%pe=e# table itsel# as the% are
optional. The 4acin( ;i&e #ield is a short "hereas the class si&e is lar(er at #our b%tes. !e use
the class la%out table to tell the compiler ho" the #ields in '3 and instance variables in 'l should
be laid out or arran(ed in memor%.
244260235.doc 156 od 541

These directives onl% appl% to a class or value t%pe and not to an inter#ace. )ormall% the +3' is
#ree to place the #ields "herever it "ants in memor% and leave as man% (as it lies. '# it so pleases
it is also allo"ed to move the #ields in memor%.

The mana(ed "orld o# .net has to (ive %ou most o# the #eatures available "ith the unmana(ed
"orld o# +I+CC. 'n these lan(ua(es "e had the #reedom o# placin( our #ields or structures the
"a% "e lied. O% allo"in( us the same #lexibilit%$ "e can no" access unmana(ed code structures
in the same "a% usin( mana(ed code.

There are i# %ou have been readin( this boo se.uentiall%$ three t%pes o# la%out attributes$ *uto$
se.uential and explicit. The de#ault is auto i# "e do not speci#% a la%out. +omin( to our pro(ram$
the #irst class a1 has a pac si&e o# 2 and no si&e directive and the /utput sho"s us that the
de#ault si&e o# 0..

* value o# 0 does not mean that the class si&e is &ero$ it means that the +3' "ill #i(ure it out. The
second class a2 has a si&e and no pac and the de#ault pac si&e is 1 and not 0. 'n our #unction
=ispla%;i&e*nd4ac all that "e do is scan the class la%out table and chec #or that sin(le record
that has the parent #ield bein( e.ual to the parameter t%peindex.

'# a record does not match the t%pe$ "e do not displa% these directives. !e #irst chec "hether the
pacin(si&e is non &ero as the de#ault is &ero "hen "e do not speci#% a si&e and onl% a pac as
mentioned be#ore.

!e "rite out the indentation and the spaces#orrest taes care o# the indentation other than that #or
the nested classes. !e "rite out the pac and si&e directives. 3ets no" understand "hat the pac
directive is all about. '# "e have a pac si&e o# sa% 16$ this means that ever% #ield in memor% at
runtime should start at a address "hich is a multiple o# 16 or a natural ali(nment o# the #ield t%pe.

Nnlie li#e$ the +3/ chose "hichever is smaller and not lar(er. Thus i# "e speci#% a pac 2$ then
a 32 bit #ield "ill be(in at an address that is a multiple o# 2 and 4 "hich "ould happen naturall% i#
there "as no pac. The pac can onl% have values o# 0$ 1$2 $ 4 $ 8 $ 16$ 32 $ 64 or 128.

* value o# &ero does not mean no pac but the pac si&e used should be decided b% the plat#orm
"e are runnin( on. /bviousl% the pac directive and the explicit attribute "here "e are bein(
explicit cannot be used to(ether.

The si&e directive is easier to understand as it speci#ies the si&e o# memor% allocated to th #ields
o# the class and not #or the methods. This value should be lar(er or at the ver% best e.ual to the
calculated si&e o# the class. The si&e o# the class is the sum o# the individual #ields and the extra
(aps due to the pac directive.

The pac and si&e directives are not hints and the s%stem better obe% our values or else X . The
class la%out table ma% be empt% and normall% is. /bviousl% the class containin( these t"o
directives must not have the auto la%out as (ave have$ but "e (et a "arnin( b% the assembler and
not a error.

'# the class si&e is lar(er than the actual si&e$ paddin( is provided at the end o# the class b% the
compiler. * class si&e o# &ero speci#ies the s%stem can #i(ure out the si&e o# the class as it
normall% does. :ven thou(h "e use the :xplicit la%out attribute$ "e can %et have a veri#iable t%pe
i# out t%pe does not have a union.
244260235.doc 157 od 541

* union is a entit% that allo"s di##erent #ields to start at the same location in memor%. >or a
explicit la%out attribute the pacin( si&e is 0 as "e are explicitl% speci#%in( each o##set. '# %ou
have #or(otten all classes derive #rom ;%stem./b1ect and value t%pes #rom ;%stem.-alueT%pe.

* la%out has to start #rom the #irst class that derives #rom class /b1ect and it cannot start #rom an%
other point in the inheritance hierarch%. !e can stop the la%out an%"here in the chain but #rom
then on no class can have la%out. !e cannot stop the la%out and t"o classes later start a(ain.

Thus no holes are allo"ed in the la%out o# classes. Thus the t"o rules "e have speci#ied are no
holes and also that the la%out starts #rom the hi(hest class.

4ro(ram20.csc
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%*ll0ethods5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%*ll0ethods 5int t%pero"8
9
i# 5 T%pe=e#;truct AA null8
return<
i# 5 0ethod;truct AA null8
return<
int start $ starto#nextA0<
start A T%pe=e#;truct6t%pero"7.mindex <
i# 5 t%pero" AA 5T%pe=e#;truct.3en(th P18 8
9
starto#nextA 0ethod;truct.3en(th<
@
else
starto#next A T%pe=e#;truct6t%pero"C17.mindex <
#or 5 int methodindex A start < methodindex B starto#next < methodindexCC8
9
strin( methodstrin( A +reate;paces5spaces#orrest8<
i# 5 'sT%pe)ested5t%pero"88
methodstrin( A methodstrin( C +reate;paces5spaces#ornested8<
methodstrin( A methodstrin( C F.method F<
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( methodattribute A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $ methodindex8<
+onsole.!rite3ine5methodstrin( C methodattribute8<
@
@
public strin( Det0ethod*ttribute 5int method#la(s $ int methodro"8
9
strin( returnstrin( A FF<
methodaccessattributeAFF <
methodhideb%si(attributeA FF<
244260235.doc 158 od 541
methodpinvoestrin( A FF<
methodunmana(edexpattribute A FF<
methodre.secob1attribute A FF<
methodstaticinstanceattrAFF<
methodne"slotattr A FF<
methodspecialnameattr A FF<
methodrtspecialnameattr A FF<
methodpinvoeimplattr A FF<
method#inalattr A FF<
methodvirtualattr A FF<
methodabstractattr A FF<
i# 5 5method#la(s G 0x00068 AA 0x00068
returnstrin( A Fpublic F<
else
i# 5 5method#la(s G 0x00058 AA 0x00058
returnstrin( A F#amorassem F<
else
i# 5 5method#la(s G 0x00038 AA 0x00038
returnstrin( A Fassembl% F<
else
i# 5 5method#la(s G 0x00048 AA 0x00048
returnstrin( A F#amil% F<
else
i# 5 5method#la(s G 0x00018 AA 0x00018
returnstrin( A Fprivate F<
else i# 5 5method#la(s G 0x00028 AA 0x00028
returnstrin( A F#amandassem F<
else
returnstrin( A Fprivatescope F<
methodaccessattribute A returnstrin(<
i# 5 5method#la(s G 0x00808 AA 0x00808
9
methodhideb%si(attribute A Fhideb%si( F C methodstaticinstanceattr<
returnstrin( A returnstrin( C Fhideb%si( F<
@
i# 5 5method#la(s G 0x01008 AA 0x01008
9
methodne"slotattr A Fne"slot F <
returnstrin( A returnstrin( C Fne"slot F<
@
i# 5 5method#la(s G 0x08008 AA 0x0800 TT 5method#la(s G 0x02008 AA 0x0200 8
9
methodspecialnameattr A Fspecialname F<
returnstrin( A returnstrin( C Fspecialname F<
@
i# 5 5method#la(s G 0x10008 AA 0x10008
9
methodrtspecialnameattr A Frtspecialname F <
returnstrin( A returnstrin( C Frtspecialname F<
@
i# 5 5method#la(s G 0x00108 AA 0x00108
244260235.doc 159 od 541
9
methodstaticinstanceattr A Fstatic F C methodstaticinstanceattr <
returnstrin( A returnstrin( C Fstatic F<
@
else
9
methodstaticinstanceattr A Finstance F C methodstaticinstanceattr<
returnstrin( A returnstrin( C Finstance F<
@
i# 5 5method#la(s G 0x00208 AA 0x00208
9
method#inalattr A F#inal F <
returnstrin( A returnstrin( C F#inal F<
@
i# 5 5method#la(s G 0x00408 AA 0x00408
9
methodvirtualattr A Fvirtual F <
returnstrin( A returnstrin( C Fvirtual F<
@
i# 5 5method#la(s G 0x04008 AA 0x04008
9
methodabstractattr A Fabstract F <
returnstrin( A returnstrin( C Fabstract F<
@
i# 5 5method#la(s G 0x20008 AA 0x20008
9
methodpinvoeimplattr A Fpinvoeimpl F <
returnstrin( A returnstrin( C Fpinvoeimpl5F<
int ii<
i# 5 'mpl0ap;truct AA null8
9
returnstrin( A returnstrin( C FIJ )o map JI8 F<
return returnstrin(<
@
else
9
#or 5 iiA1< ii B 'mpl0ap;truct.3en(th < iiCC8
9
int index A 'mpl0ap;truct6ii7.cindex<
index A index HH 1<
i# 5 index AA methodro" 8
brea<
@
i# 5 ii AA 'mpl0ap;truct.3en(th 8
9
returnstrin( A returnstrin( C FIJ )o map JI8 F<
return returnstrin(<
@
strin( methodname A )ame,eserved5Det;trin(50ethod;truct6methodro"7.name88<
strin( name A )ame,eserved5Det;trin(5'mpl0ap;truct6ii7.name88<
int scope A 'mpl0ap;truct6ii7.scope<
244260235.doc 160 od 541
strin( modulename A )ame,eserved5Det;trin(50odule,e#;truct6scope7.name88<
modulename A modulename.,eplace5FUUF $ FUUUUF8<
returnstrin( A returnstrin( C FUFF C modulename C FUFF <
i# 5 ;trin(.+ompare5methodname $ name8 EA 08
returnstrin( A returnstrin( C F as UFF C name C FUFF<
strin( pinvoeattribute1<
strin( pinvoeattribute A Det4invoe*ttributes5'mpl0ap;truct6ii7.attr $ out pinvoeattribute18<
returnstrin( A returnstrin( C pinvoeattribute1<
i# 5pinvoeattribute.'ndex/#5FstdcallF8 AA P18
returnstrin( A returnstrin( C F F C pinvoeattribute<
returnstrin( A returnstrin( C F8 F<
int index1 A returnstrin(.'ndex/#5FpinvoF8 <
methodpinvoestrin( A returnstrin(.,emove50$ index18<
@
@
i# 5 5method#la(s G 0x088 AA 0x088
9
methodunmana(edexpattribute A Funmana(edexp F<
returnstrin( A returnstrin( C Funmana(edexp F<
@
i# 5 5method#la(s G 0x####80008 AA 0x####80008
9
methodre.secob1attribute A Fre.secob1 F<
returnstrin( A returnstrin( C Fre.secob1 F<
@
return returnstrin(<
@
public strin( Det4invoe*ttributes 5int attribute $ out strin( returnattribute8
9
returnattribute A FF<
i# 5 5attribute G 0x0018 AA 0x00018
returnattribute A F noman(leF<
i# 5 5attribute G 0x0068 AA 0x00068
returnattribute A returnattributeC F autocharF<
else i# 5 5attribute G 0x0028 AA 0x00028
returnattribute A returnattribute C F ansiF<
else i# 5 5attribute G 0x0048 AA 0x00048
returnattribute A returnattribute C F unicodeF<
i# 5 5attribute G 0x0408 AA 0x00408
returnattribute A returnattribute C F lasterrF<
strin( returnstrin( A FF<
i# 5 5attribute G 0x05008 AA 0x05008
returnstrin( A returnstrin(C F#astcallF<
else i# 5 5attribute G 0x03008 AA 0x03008
returnstrin(A returnstrin( C FstdcallF<
else i# 5 5attribute G 0x01008 AA 0x01008
returnstrin( A returnstrin( C F"inapiF<
else i# 5 5attribute G 0x02008 AA 0x02008
returnstrin( A returnstrin( C FcdeclF<
else i# 5 5attribute G 0x04008 AA 0x04008
returnstrin( A returnstrin( C FthiscallF<
244260235.doc 161 od 541
return returnstrin(<
@

e.il
.class a1
9
.method public pinvoeimpl5F/le32.dllF as F+o+reate'nstanceF autochar "inapi8 int32
+o+reate'nstance258
9
@
.method public pinvoeimpl5F/le322.dllF as F+o+reate'nstanceF autochar "inapi8 int32
+o+reate'nstance358
9
@
.method public pinvoeimpl5F/le322.dllF as F+o+reate'nstanceF autochar "inapi8 int32
+o+reate'nstance58
9
@
.method public pinvoeimpl5F/le322.dllF as F+o+reate'nstanceF autochar stdcall8 int32
+o+reate'nstance458
9
@
@


/utput
.module extern /le322.dll IJ1*000001JI
.module extern /le32.dll IJ1*000002JI

.class IJ02000002JI private auto ansi a1
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.method IJ06000001JI public instance pinvoeimpl5F/le32.dllF as F+o+reate'nstanceF autochar
"inapi8
.method IJ06000002JI public instance pinvoeimpl5F/le322.dllF as F+o+reate'nstanceF
autochar "inapi8
.method IJ06000003JI public instance pinvoeimpl5F/le322.dllF autochar "inapi8
.method IJ06000004JI public instance pinvoeimpl5F/le322.dllF as F+o+reate'nstanceF
autochar8
@ II end o# class a1

This pro(ram on"ards "ill displa% the method directive b% means o# "hich "e de#ine a method
or #unction as "e ne" them earlier. The problem "ith the method directive is that the% are reall%
complex and i# "e did all o# the method directive the pro(ram "ill run into 1500 lines.

Thus "e brea up this directive b% havin( smaller pro(rams deal "ith each individual #eature and
then lie 2umt% =umt% put them to(ether a(ain. 3ets start "ith displa%in( the attributes that a
method can have. >irst thin(s #irst.

'n the method =ispla%/neT%pe "e add a call to the method passin( it the t%pe ro" number that
carries the methods. This #unction "ill displa% all the method o"ned b% a t%pe and a little later all
244260235.doc 162 od 541
the (lobal methods also that have a t%pe o# 1. :ach method directive adds one ro" in the method
table.

The .uestion in %our mind is ho" do "e represent all the methods a t%pe contains. The simplest
"a% in our mind is to have to have t"o #ields$ one #ield #or the startin( method number in the
method table and the second #ield #or the last method number in the methods table.

The problem "ith out "a% is that it is too space consumin( and "here "e can use one #ield "h%
use t"o. The #ield mindex tells us the #irst method number in the methods table but there is no
#ield #or the last method. !e in#er this b% looin( at the next mindex #ield o# the next t%pe.

!e thus have the startin( method numbers o"ned b% t"o succeedin( t%pes. !e thus have t"o
ro" numbers in the method table. The #irst is the startin( point and the second minus 1 is the last
method that this t%pe o"ns. Thus the variable start is the #irst method ro" number and variable
starto#next is the method ro" o# the succeedin( t%pe.

!e need to chec i# the t%pe "e are displa%in( method #or is the last t%pe$ then the last method
o"ned b% this t%pe is the last ro" number or the len(th o# the 0ethod table. 'n the #or loop the
methodindex variable is the loop variable and "e start at the variable start and (o one less than
the value o# starto#next.

The other reason that "e do not have t"o #ields is that a t%pe can have no methods at all. 'n this
case this t%pe and the next t%pe "ill have the same value #or the #ield mindex. !h% use t"o "hen
one can do the 1ob.

'# there is one variable "e have used the most it is the variable spaces#orrest. This variable has
basicall% three di##erent values 0$ 2 or 4. the value o# 0 is "hen "e are displa%in( (lobal #unctions
and there is no indentation needed then. The value o# t"o is most common as there is 2 spaces
bet"een a t%pe and a method.

>inall% i# "e in a namespace the indentation is 4. The spaces#ornested store the spaces needed i#
there is a nested class. Thus "henever "e "rite somethin( out these t"o variable "ill al"a%s be
used #or the initial spaces to be "ritten out. !e "rite out the directive method and then its ro"
number and "e then use a #unction Det0ethod*ttribute to (ive us the method attributes "hich
are lie the class attribute.

!e "rite out the method directive and the attributes and nothin( else. Thus the output (ive b% the
disassembler "ill not match as "e are as "e said be#ore onl% displa%in( parts. These parts "ill
ho"ever match the same part displa%ed b% the disassembler. 3ets move on to this method
Det0ethod*ttribute.

The 0ethod table has a member called #la(s that tells us "hich attributes this method carries lie
in the case o# the t%pe$ this #ield has to be read bit"ise and not the b%te "ise. The problem that "e
"ill come across later is "hether the abstract attribute (ets displa%ed #irst or the ne"slot attribute.

Thus "e "or "ithin this #unction in t"o "a%s$ "e use a common variable returnstrin( to store
the individual attributes and also another series o# variables lie methodaccessattribute that store
the individual attribute values. !e "ill use these variables to "rite out the attributes in a certain
order.

244260235.doc 163 od 541
The return strin( also contains all the attributes but in the "ron( order. ;ome pro(rams later "e
"ill tell %ou "hat the ri(ht order o# "ritin( out the attributes is all about. These attributes are
divided into #amilies and the #irst is the accessibilit% attributes.

These are attributes that decide "ho can access these methods and even thou(h the% are seven o#
them$ the seventh compilercontrolled (ives us an ilasm error. This is because ilasm does not
support this attribute in its #irst release and "e are advised b% the specs to use privatescope
instead as the e##ect is the same. 't is hidden and cannot be re#erenced.

The other six lie assembl%$ #amandassem $ #amil%$ #amorassem $ private and public have been
touched upon earlier. The assembl% attribute has the #irst and second bit on and thus "e bit"ise
and "ith 3. The tric here is that the #irst bit on means private$ the second bit on means
#amandassem.

/nl% i# both bits are on$ its means assembl%. This means that the order o# i# statements is
important because i# "e chec #or private and #amandassem #irst$ "hen the attribute is assembl%$
the% "ill match. Thus "e #irst chec #or the combination bit bein( on and then the sin(le bits.

That is "h% the sin(le bits chec is carried out at the end and those attributes that have more than
one bit on at the be(innin(. *nother "a% o# handlin( it "ould be lie the "a% "e did earlier$
extract the bits #or accessibilit% and then chec the absolute varies and not bite. To each his o"n.

The above attributes are mutuall% exclusive and cannot be combined. This is because a method
can have onl% one attribute. The next attribute is the attribute that lets us override methods called
ne"slot and is onl% used b% virtual #unctions. !e "ill delve into the ne"slot and virtual methods
some time later.

*bstract classes "e explained earlier "e incomplete and could not be used. This is because the%
had abstract #unctions. This abstract attribute can onl% be used "ith virtual #unctions and these
must not be mared #inal as abstract methods must be over"ritten as its in the% (enes.

* abstract sa%s that there is no code or implementation #or this method and the class that
overrides this class containin( a abstract method "ill suppl% the bod% o# the code. /bviousl%
abstract methods must be present in onl% abstract t%pes.

/ne important attribute that "e "ould do later is the pinvoeimpl attribute and a ma1or part o#
this #unction deals "ith this attribute. The nest #amil% is the method contact attribute that has #our
members$ #inal$ hideb%si($ static and virtual. These attributes can be combined eepin( some
conditions in mind.

* method cannot be static and virtual and i# it is virtual then onl% can it be #inal. * #inal method is
a method that a subclass is not allo"ed to override. 't is a "a% o# sa%in( use the #unction as is$
thou can override the class but not this method. !e explained earlier that the hideb%si( is i(nored
b% the -:; or s%stem but is used b% tools to do "hatever the% lie "ith the name.

This attribute speci#ies that this method "ill hide all the methods #rom the inheritance hierarch%
that have the same method si(nature. '# this attribute is not present$ the hidin( %et taes place but
the si(nature is not taen into account and all methods havin( the same name are hidden.

* method name is its name plus si(nature and this is "hat (ives the ob1ect oriented "orld a bi(
advanta(e over plain + "hich hide method onl% b% name. >inall% "e have the special handlin(
244260235.doc 164 od 541
attributes that are rtspecialname and specialname. * constructor is called .ctor and a static
constructor .cctor.

These names are reco(ni&ed b% the runtime and treated in a special "a%. This is the meanin( o#
the rtspecialname attribute and the specialname is #or use b% tools and not the runtime. There are
t"o more special attributes bou(ht in b% 0icroso#t "hich are unmana(edexp and re.secob1.

The unmana(edexp sa%s that the method is exported to unmana(ed code usin( +/0 interop that
"e "ill explain in a short "hile. ,e.secob1 sa%s that this method calls another method "hich has
securit% attributes. >inall% some #inal conditions on appl%in( attributes$ static cannot be sued "ith
#inal$ virtual or ne"slot.

This maes sense as static #unctions belon( to a t%pe or class and not to an instance. *bstract
#unctions have no code and hence cannot be used "ith pinvoeimpl and #inal. !hen
compilercontrolled "hen implemented cannot be used "ith virtual$ #inal$ specialname or
rtspecialname.

* small bit o# in#ormation$ i# "e use the attribute specialname$ the #la(s #ield has a value o#
0x800 as the specs tell us. 'n our #ile is%m"rapper.dll$ the specialname attribute "as "ritten out
b% ildasm even thou(h the #la(s #ield had a value o# 0x200.

This value o# 0x200$ the specs are silent on so "e put t"o and t"o to(ether and assumed that a
value o# 0x200 or 0x800 stand #or the attribute specialname. !e have also not checed #or a value
o# 0x4000 "hich is the securit% attributes as "e did not no" the name o# the attribute.

* little later "e "ill trouble %ou "ith "hat is called the custom attribute and this directive adds
the securit% attribute. The problem is that ildasm i(nores it and so do "e. )o" lets move on to the
pinvoeimpl attribute that "e have been promisin( "e "ould do.

!e #irst chec "hether "e have the attribute pinvoeimpl "hich has a value o# 0x2000. !e #irst
"rite out the name o# the attribute and then tell ourselves that each time "e have such an
attribute$ a extra ro" (ets added to the 'mpl0ap table. 3ets start "ith a simple error chec #irst.

!e assume that "e onl% one method that uses the pinvoeimpl attribute and this attribute re.uires
some values in "ithin bracets. '# "e do not suppl% these values$ the 'mpl0ap table has no ro"s
and hence "e need to return the "ords )o map "ithin bracets. '# the 'mpl0ap table has records
"e iterate throu(h each and ever% one o# them.

Out #irst a small note on the use o# the pinvoeimpl attribute. >or %ears pro(rammers have "ritten
code that runs under "indo"s and this code has passed the test o# time. 't maes no sense that
this tried and tested code (oes "aste 1ust because somethin( ne" has come about.

Thus 0icroso#t invested lots o# time to come "ith a method b% means o# "hich$ mana(ed code
i.e. .net code can call the earlier unmana(ed code. This method is called 4invoe or plat#orm
invoe. Thus code "ritten in the past and present in =llQs can no" be executed in the mana(e
"orld o# .net.

Thus 4invoe s"itches #rom mana(ed to unmana(ed$ maes the #unction call and then bac to
mana(ed code. The .net "orld ma% have a data t%pe that needs to be trans#ormed to another data
t%pe in the unmana(ed "orld and the return value in the unmana(ed "orld ma% need to be
trans#ormed to another data t%pe as "e enter the mana(ed "orld.
244260235.doc 165 od 541

This trans#ormation is called data marshallin(. These #unctions that reall% do not exist in the
mana(ed "orld as the% carr% no code but are a (ate"a% to the unmana(ed "orld are mared as
pinvoeimpl. * little later "e "ill tal o# another set o# attributes called implementation attributes
that come a#ter the #unction parameters.

* pinvoeimpl attribute must have the implementation attributes o# native and unmana(ed. '# %ou
loo closel% at the il #ile$ a#ter the pinvoeimpl attribute name "e have a set o# parameters in
bracets. This is the onl% attribute that excepts parameters. The #irst is the name o# the dll that
carries the code that "ill (et executed.

This is a .uoted strin( or "hat the docs call a Y;T,')D$ a strin( in double and not sin(le
inverted commas. 'n our case "e are speci#%in( that the code o# the #unction +o+reate'nstance2
actuall% lies in this dll. The second strin( is optional and speci#ies the real name o# the #unction as
it exists on that plat#orm.

3ets tae %ou bac in time and in the da%s o# pro(rammin( in + a #unction name "as simpl% its
name. Then came in +CC and the name o# a #unction "as the name plus data t%pes o# parameters.
* #unction abc that too t"o ints as a parameter "as renamed b% the +CC compiler #rom Oorland
to abcZ.ii.

'n the same vein the same #unction abc "ith a sin(le int "as renamed to abcZ.i. Thus the Oorland
compiler added a Z. and then the data t%pes o# each parameter. This chan(ed the name o# the
#unction be%ond reco(nition and is called name man(lin(.

The 0icroso#t complier -isual +CC "ould ho"ever use a di##erent set o# s%mbols to represent the
parameter t%pes. There is no standard that describes name man(lin(.

Thus in our case "e are sa%in( that the #unction name in the .net "orld is +o+reate'nstance2 but
in /le32.dll it "ill be seen as +o+reate'nstance instead due to name man(lin(. The .net la" sa%s
that i# a method is to be mared b% the pinvoeimpl attribute then it should be a (lobal method
i.e. outside a t%pe and must be static.

>ortunatel% #or us the assembler does not seem to care. *lso pinvoeimpl methods as the% are a
stand in #or methods in unmana(ed code$ need not contain an% code as this code the% carr% is not
to be called. !e no" scan our 'mpl0ap table and move our e%es to the cindex #ield.

This #ield as the name su((ests is a coded index #ield called the 0ember>or"arded coded index
that points to t"o tables$ method or #ield. >or some reason$ a #ield "ill never have a pinvoeimpl
attribute and thus the coded index al"a%s represents a ro" in the 0ethod table.

!e ri(ht shi#t the coded index b% 1 and then chec "hether it is the ro" number o# pour method.
:ach time a method has the pinvoeimpl attribute$ the #ield cindex "ill carr% the method number.
!e no" brea out o# the #or loop i# a match is #ound. !e need to chec "hether our method ro"
number actuall% exits in this table.

This happens i# the pinvoeimpl attribute exits on the method but has no parameters in bracets.
This "as the same condition that "e checed #or earlier but here the chec is a little. There "e
had onl% method and this method did not have pinvoeimpl parameters.

244260235.doc 166 od 541
'n this case "e have at least one method that has the pinvoeimpl parameters$ but the current
method has the pinvoeimpl attribute but no parameters. !e #irst pic up the name o# the method
as stored in the method table and store it in the methodname variable.

The #ield name in the 'mpl0ap;truct stores the actual name o# the #unction "e "rote in the as
clause. The #irst thin( "e "rote "as the name o# the =ll that carries the code o# this #unction and
there is no #ield that (ives us this dll name. The pinvoeimpl attribute is a lot more complex.

:ver% dll name that "e "rite$ a ro" (ets added to the 0odule,e# table. This ro" number is the
value o# the scope #ield. Thus i# "e have t"o pinvoeimpl attributes$ "ith di##erent dll name$
/le32.dll and /le322.dll in our case$ the output carries t"o module extern directives.

'# the module name caries a bacslash$ "e need to replace it "ith t"o bacslashes. !e then
compare the name o# the method as stored in the method table "ith the name o# the actual
unmana(ed code method name. '# the% di##erent$ "e put the as clause and the ori(inal method
name.

Thus in our il #ile$ the third method has the as method name the same as the method name and
thus the as is omitted #orm the pinvoeimpl attribute. There are some more attributes that "e
"rite out a#ter the as clause and "e use the #unction Det4invoe*ttributes to (et at these extra
attributes stored in the attr #ield.

'n this #unction "e are returnin( one set o# attributes as the return value and another set throu(h
the second out parameter returnattribute. The our parameter is one o# #ive attributes$ noman(le$
autochar$ ansi$ unicode that "e did earlier and lasterr. The second set o# attributes that "e actuall%
return do "ith the callin( convention and the% are #astcall$ stdcall$ "inapi $cdecl and thiscall.

!e #irst "rite out the out parameter #irst and then the callin( convention. The onl% problem "ith
the callin( convention stdcall is that even i# "rite it lie #or the #unction +o+reate'nstance4$ the
assembler does not spit it out #or us. Thus the i# statement maes sure that all callin( conventions
but the stdcall "ill (et "ritten out.

!e then "rite out the close bracet and then #ind out the index o# the "ords pinvo in the
returnstrin(. '# %ou have not #or(otten so #ar$ the "ords pinvoeimpl are preceded "ith the other
attributes. !e need to noc o## all the other attributes be#ore the pinvoeimpl attribute and thus
use the ,emove #unction o# the strin( class.

The #irst parameter is the startin( point in the strin(. !e store this pinvoeimpl attribute in a
variable in the variable methodpinvoestrin( and this variable "ill be used later to actuall% "rite
out the method attributes. !e #inall% chec #or the last t"o attributes and then return the value o#
returnstrin( that "e #inall% displa%.

/ne o# the thin(s that "e have explained above is the abilit% o# the +3' to call pre existin( native
code #rom a plat#orm that "e call unmana(ed code. The plat#orm "ill decide "hat the rules are
and hence speci#ic to a operatin( s%stem.

!hat this entails is decidin( a #ile #ormat so that #unction pointer to mana(ed code can be called
#rom unmana(ed code. !hat "e have seen so #ar is a "a% #or speci#%in( methods to be
implemented in unmana(ed code.

244260235.doc 167 od 541
!e also need a "a% #or marin( call sites i.e. callin( #unctions throu(h instructions to indicate
that the #unction to be called is actuall% in unmana(ed code. The call and calli instructions "ill be
explained in detail later.

!hat the speci#ication #inall% speci#ies is a set o# pre de#ined data t%pes that can be marshaled
across irrespective o# "here the +3' has been implemented. !e can ho"ever extend these small
number o# data t%pes usin( custom attributes and modi#iers.

These extensions are speci#ic to each plat#orm and are not (uaranteed to "or across plat#orms.
3ets tae up the attributes ansi$ autochar and unicode that "e have dealt "ith earlier. >irst lie
be#ore these attributes are exclusive and "e no" that "e are repeatin( ourselves in a manner o#
speain(.

These attributes decide ho" strin(s "ill be passed across or marshaled to the other side. * value
o# ansi mean that the native code or unmana(ed code "ill receive or return the strin( as an ansi
strin(. This normall% is the "a% +I+CC stores strin(s. Nnicode speci#ies that the strin( is in
unicode the international standard "hich ever%one #ollo"s toda%.

The sa#est is autochar that chooses "hatever is natural #or that plat#orm$ ansi #or !in 95$ unicode
#or !in 2000. The callin( conventions speci#% issues lie ho" the parameters are seen on the
stac and the% are a lar(e number o# them.

The oldest is cdecl "hich is the standard ori(inall% #ollo"ed b% the + pro(rammin( lan(ua(e.
!indo"s pro(rammin( in + bou(ht in the stdcall callin( convention. The this pointer "ill be
explained later and this introduced the thiscall. There are variations o# the + callin( conventions
lie #astcall.

To (et out o# the mess "e have plat#ormapi that sa%s lie autochar$ use "hatever is appropriate
#or the plat#orm. /nce a(ain "e have to use "inapi instead o# plat#ormapi. These callin(
conventions are #or native code and not #or mana(ed code "here "e have no choice and tae
"hatever 0icroso#t (ives us.

3ie al"a%s$ there are t"o attributes speci#ic to !indo"s$ lasterr and noman(le. 'n the (ood da%s
o# + pro(rammin( "e "ould use lasterr to (et at the last error. !hen !indo"s #irst came about$
there "as a #unction called 0essa(eOox amon(st others that (ave us "hat the #unction name sa%s
a 0essa(e Oox.

*ll "as "ell until unicode arrived on the seen. This created a problem as strin(s had to be passed
to this #unction. The solution "as that lets have t"o #unctions$ 0essa(eOox* #or the ascii or ansi
verison and 0essa(eOox! #or the unicode version.

' "ould "rite m% code usin( the #unction name 0essa(eOox and dependin( upon the plat#orm '
run on$ the appropriate *5ascii8 or !5"idechar8 "ould be added to the #unction name. Thus the
pro(rammer "as insulated #or no"in( an%thin( about ansi or unicode. ,emember there is no
#unction called 0essa(eOox in !indo"s an% more.

!e no" all this because "e have used computers #or a ver% lon( time. Thus the attribute
noman(le indicates that the name o# the dll should be used as "e have "ritten it and no addin(
the endin( * or ! that normall% "ould happen. !e can also call unmana(ed #unctions as brie#l%
mentioned above usin( #unction pointers.

244260235.doc 168 od 541
The "a% "e call #unctions usin( #unction pointers is the same #or mana(ed or unmana(ed
#unctions. The little "e do is ta( the unmana(ed #unction "ith the pinvoeimpl attribute.

There is onl% one table that stores the in#ormation about unmana(ed #unctions that can be called
#rom mana(ed #unctions usin( the 4'nvoe dispatch. To sum up a(ain$ each ro" in the 'mpl0ap
table tells us the method ro" number in the method table and the name o# the method in the dll
"hose is speci#ied in the module re# table.

Thus each time a call is made to an% method$ the +3' "ill #irst loo at this table and i# the coded
index 0ember>or"arded matches the method number$ it "ill call the #unction speci#ied b% the
#ield 'nport)ame that resides in the extern module speci#ied b% the 'mport;cope #ield.

>inall% there is the 0appin(>la(s #ield. 'n the 0icroso#t "orld$ the callin( convention attribute
can onl% have the values "inapi$ cdecl and stdcall. The values #astcall and thiscall are not
allo"ed. This is #or in#ormation purposes onl% as most o# time ilasm does not lie to #ollo" the
specs "e are readin(.

4ro(ram21.csc
public void =ispla%*ll0ethods 5int t%pero"8
9
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( parammarshalstrin( A FF<
parammarshalstrin( A Det4aram*ttr#or0ethod0arshal5methodindex $ 08<
+onsole.!rite3ine5methodstrin( C parammarshalstrin(8<
@
@

public strin( Det4aram*ttr#or0ethod0arshal 5int methodindex $ int se. 8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null8
return returnstrin(<
int end<
int start A 0ethod;truct6methodindex7.param<
i# 5 methodindex AA 50ethod;truct.3en(th P 18 8
end A 4aram;truct.3en(th C 1<
else
end A 0ethod;truct6methodindexC17.param<
i# 5 start AA 4aram;truct.3en(th8
return returnstrin(<
i# 5 start AA end8
return returnstrin(<
i# 5 se. AA 0 GG 4aram;truct6start7.se.uence EA 08
return FF<
int pattr A 4aram;truct6start7.pattr<
returnstrin( A =ecode4aram*ttributes5pattr $ 1 $ start $ 0x20008<
i# 5 returnstrin( EA FF GG returnstrin(607 AA 328
returnstrin( A returnstrin(.,emove50 $ 18<
return returnstrin(<
@
public strin( =ecode4aram*ttributes5int pattr $ int tablet%pe $ int start $ int b%temas8
244260235.doc 169 od 541
9
strin( returnstrin( A FF<
i# 5 5pattr G b%temas8 AA b%temas8
9
int ii <
#or 5 ii A 1 < ii BA >ield0arshal;truct.3en(th < iiCC8
9
int coded A >ield0arshal;truct6ii7.coded<
int table A >ield0arshal;truct6ii7.coded G 0x01<
coded A coded HH 1<
i# 5 coded AA start GG tablet%pe AA table8
brea<
@
int blobindex A >ield0arshal;truct6ii7.index<
int len(th $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ blobindex$ out len(th8<
II+onsole.!rite3ine5F90@ 91@ 92@ 93@F $blob6blobindex7.To;trin(5FKF8 $
blob6blobindexC17.To;trin(5FKF8$blob6blobindexC27.To;trin(5FKF8$blob6blobindexC37.To;trin(5
FKF8 8<
int blobvalue A blob6blobindexCho"man%b%tes7<
strin( ss1 A Det0arshallT%pe5blob6blobindexCho"man%b%tes7 $ ho"man%b%tes $ blobindex8<
i# 5 ss1 AA F67F TT ss1.'ndex/#5F6 C F8 EA P1 TT ss1 AA FF TT 5 ss1.3en(th HA 2 GG ss1607 AA L6L GG
ss16ss1.3en(thP17 AA L7L 88
returnstrin( A F marshal5F C ss1<
else
returnstrin( A F marshal5 F C ss1<

returnstrin( A returnstrin( C F8F<
@
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin( C F F<
return returnstrin( <
@
public strin( Det0arshallT%pe 5b%te marshal#la(s $ int ho"man%b%tes $ int blobindex8
9
II+onsole.!rite3ine5F...90@ 91@ 92@ 93@ 94@F $blob6blobindex7 $
blob6blobindexC17.To;trin(5FKF8$ blob6blobindexC27.To;trin(5FKF8$
blob6blobindexC37.To;trin(5FKF8 $ blob6blobindexC47.To;trin(5FKF8 8<
i# 5 blob6blobindex7 AA 08
return FF<
i# 5 marshal#la(s AA 0x018
return FvoidF<
i# 5 marshal#la(s AA 0x028
return FboolF<
i# 5 marshal#la(s AA 0x038
return Fint8F<
i# 5 marshal#la(s AA 0x048
return Funsi(ned int8F<
i# 5 marshal#la(s AA 0x058
return Fint16F<
i# 5 marshal#la(s AA 0x068
244260235.doc 170 od 541
return Funsi(ned int16F<
i# 5 marshal#la(s AA 0x078
return Fint32F<
i# 5 marshal#la(s AA 0x088
return Funsi(ned int32F<
i# 5 marshal#la(s AA 0x098
return Fint64F<
i# 5 marshal#la(s AA 0x0a8
return Funsi(ned int64F<
i# 5 marshal#la(s AA 0x0b8
return F#loat32F<
i# 5 marshal#la(s AA 0x0c8
return F#loat64F<
i# 5 marshal#la(s AA 0x0=8
return Fs%scharF<
i# 5 marshal#la(s AA 0x0e8
return FvariantF<
i# 5 marshal#la(s AA 0x0#8
return Fcurrenc%F<
i# 5 marshal#la(s AA 0x108
return FJF<
i# 5 marshal#la(s AA 0x118
return FdecimalF<
i# 5 marshal#la(s AA 0x128
return FdateF<
i# 5 marshal#la(s AA 0x138
return FbstrF<
i# 5 marshal#la(s AA 0x148
return FlpstrF<
i# 5 marshal#la(s AA 0x158
return Flp"strF<
i# 5 marshal#la(s AA 0x168
return FlptstrF<
i# 5 marshal#la(s AA 0x178
9
int uncompressedb%te<
+or;i(Nncompress=ata5blob $ blobindexCho"man%b%tesC1 $ out uncompressedb%te8<
return F#ixed s%sstrin( 6F C uncompressedb%te.To;trin(58 C F7F<
@
i# 5 marshal#la(s AA 0x188
return Fob1ectre#F<
i# 5 marshal#la(s AA 0x198
return Fiunno"nF<
i# 5 marshal#la(s AA 0x1a8
return FidispatchF<
i# 5 marshal#la(s AA 0x1b8
return FstructF<
i# 5 marshal#la(s AA 0x1c8
return Finter#aceF<
i# 5 marshal#la(s AA 0x1d8
9
244260235.doc 171 od 541
strin( returnstrin( A Fsa#earra%F<
i# 5 blob6blobindex7 H 18
9
strin( dumm% A Det;a#e*rra%T%pe5blob6blobindexCho"man%b%tesC178<
i# 5 dumm% EA FF8
returnstrin( A returnstrin( C F F C dumm%<
@
int len A blob6blobindex7 P 3<
i# 5 len H 08
9
returnstrin( A returnstrin( C F$ UFF <
#or 5 int iii A 0 < iii B len < iiiCC8
returnstrin( A returnstrin( C 5char8blob6blobindexCiiiCho"man%b%tesC37 <
returnstrin( A returnstrin( C FUFF <
@
return returnstrin(<
@
i# 5 marshal#la(s AA 0x1e8
9
int uncompressedb%te<
+or;i(Nncompress=ata5blob $ blobindexCho"man%b%tesC1 $ out uncompressedb%te8<
return F#ixed arra% 6F C uncompressedb%te.To;trin(58 C F7F<
@
i# 5 marshal#la(s AA 0x1#8
return FintF<
i# 5 marshal#la(s AA 0x208
return Funsi(ned intF<
i# 5 marshal#la(s AA 0x218
return Fnested structF<
i# 5 marshal#la(s AA 0x228
return Fb%valstrF<
i# 5 marshal#la(s AA 0x238
return Fansi bstrF<
i# 5 marshal#la(s AA 0x248
return FtbstrF<
i# 5 marshal#la(s AA 0x258
return Fvariant boolF<
i# 5 marshal#la(s AA 0x268
return FmethodF<
i# 5 marshal#la(s AA 0x278
return FF<
i# 5 marshal#la(s AA 0x288
return Fas an%F<
i# 5 marshal#la(s AA 0x298
return FF<
i# 5 marshal#la(s AA 0x2a8
9
IJ
#or 5 int i A 0 < i BA blob6blobindex7 < iCC8
+onsole.!rite5F90@ F $ blob6blobindexCi7.To;trin(5FKF88<
+onsole.!rite3ine58<
244260235.doc 172 od 541
JI
strin( returnstrin( A FF<
strin( arra%s A F67F<
strin( dumm%1 A FF<
i# 5 blob6blobindex7 AA 38
9
dumm%1 A F F<
arra%s A F6 C F C blob6blobindexC2Cho"man%b%tes7.To;trin(58 C F7F<
@
i# 5 blob6blobindex7 AA 48
9
dumm%1 A FF<
i# 5 blob6blobindexC2Cho"man%b%tes7 EA 08
arra%s A F6F C blob6blobindexC3Cho"man%b%tes7.To;trin(58 C F C F C
blob6blobindexC2Cho"man%b%tes7.To;trin(58 C F7F<
else
arra%s A F6F C blob6blobindexC3Cho"man%b%tes7.To;trin(58 C F7F<
@
i# 5 blob6blobindex7 HA 78
9
int ho"man%t%pes A blob6blobindex7I3<
returnstrin( A Det0arshallT%pe5blob6blobindexCho"man%b%tesCho"man%t%pes7
$ho"man%b%tes $ blobindex8<
i# 5 blob6blobindexC1Cho"man%b%tesCho"man%t%pes7 EA 08
arra%s A F6F C blob6blobindexC2Cho"man%b%tesCho"man%t%pes7.To;trin(58 C F C F C
blob6blobindexC1Cho"man%b%tesCho"man%t%pes7.To;trin(58 C F7F<
else
arra%s A F6F C blob6blobindexC2Cho"man%b%tesCho"man%t%pes7.To;trin(58 C F7F<
returnstrin( A returnstrin( C arra%s <
#or 5 int i A 1 < i B ho"man%t%pes < iCC8
9
i# 5 blob6blobindexCho"man%b%tesCho"man%t%pesCiJ2C27 AA 08
returnstrin( A returnstrin( C F F C
Det0arshallT%pe5blob6blobindexCho"man%b%tesCho"man%t%pesCiJ2C17 $ho"man%b%tes $
blobindex8<
else
returnstrin( A returnstrin( C F F C
Det0arshallT%pe5blob6blobindexCho"man%b%tesCho"man%t%pesCiJ2C27 $ho"man%b%tes $
blobindex8<
@
return returnstrin(<
@
i# 5 blob6blobindexCho"man%b%tesC17 AA 0x508
returnstrin( A arra%s<
else
returnstrin( A dumm%1 C Det0arshallT%pe5blob6blobindexCho"man%b%tesC17 $ho"man%b%tes $
blobindex8 C arra%s<
return returnstrin(<
@
i# 5 marshal#la(s AA 0x2b8
return FlpstructF<
244260235.doc 173 od 541
i# 5 marshal#la(s AA 0x2c8
9
int len A 0<
int ho"man%b%tes1 A 0<
ho"man%b%tes1 A +or;i(Nncompress=ata5blob $ blobindex C ho"man%b%tesC3 $ out len 8<
strin( returnstrin( A Fcustom 5UFF<
#or 5 int ii1 A 0 < ii1 B len < ii1CC8
returnstrin( A returnstrin( C 5char8blob6blobindexC3Cii1Cho"man%b%tesCho"man%b%tes17<
returnstrin( A returnstrin( C FUFF C F$F <
int len1 A len<
int b%tes A 1<
i# 5 len1 HA 1288
b%tes A 2<
ho"man%b%tes1 A +or;i(Nncompress=ata5blob $ blobindex C ho"man%b%tesC3Clen1Cb%tes $
out len 8<
returnstrin( A returnstrin( C FUFF <
#or 5 int ii1 A 1 < ii1 BA len < ii1CC8
returnstrin( A returnstrin( C
5char8blob6blobindexC3Clen1Cii1Cho"man%b%tesCho"man%b%tes17<
returnstrin( A returnstrin( C FUF8F<
return returnstrin(<
@
i# 5 marshal#la(s AA 0x2d8
return FerrorF<
return FNnno"nF<
@
public strin( Det;a#e*rra%T%pe 5b%te sa#earra%t%pe8
9
strin( returnstrin( A FF<
i# 5sa#earra%t%pe AA 08
returnstrin( A FF<
i# 5sa#earra%t%pe AA 18
returnstrin( A FnullF<
i# 5sa#earra%t%pe AA 28
returnstrin( A Fint16F<
i# 5sa#earra%t%pe AA 38
returnstrin( A Fint32F<
i# 5sa#earra%t%pe AA 48
returnstrin( A F#loat32F<
i# 5sa#earra%t%pe AA 58
returnstrin( A F#loat34F<
i# 5sa#earra%t%pe AA 68
returnstrin( A Fcurrenc%F<
i# 5sa#earra%t%pe AA 78
returnstrin( A FdateF<
i# 5sa#earra%t%pe AA 88
returnstrin( A FbstrF<
i# 5sa#earra%t%pe AA 98
returnstrin( A FidispatchF<
i# 5sa#earra%t%pe AA 0x0a8
returnstrin( A FerrorF<
244260235.doc 174 od 541
i# 5sa#earra%t%pe AA 0x0b8
returnstrin( A FboolF<
i# 5sa#earra%t%pe AA 0x0c8
returnstrin( A FvariantF<
i# 5sa#earra%t%pe AA 0x0d8
returnstrin( A Fiunno"nF<
i# 5sa#earra%t%pe AA 0x0e8
returnstrin( A FdecimalF<
i# 5sa#earra%t%pe AA 0x0#8
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x108
returnstrin( A Fint8F<
i# 5sa#earra%t%pe AA 0x118
returnstrin( A Funsi(ned int8F<
i# 5sa#earra%t%pe AA 0x128
returnstrin( A Funsi(ned int16F<
i# 5sa#earra%t%pe AA 0x138
returnstrin( A Funsi(ned int32F<
i# 5sa#earra%t%pe AA 0x148
returnstrin( A Fint64F<
i# 5sa#earra%t%pe AA 0x158
returnstrin( A Funsi(ned int64F<
i# 5sa#earra%t%pe AA 0x168
returnstrin( A FintF<
i# 5sa#earra%t%pe AA 0x178
returnstrin( A Funsi(ned intF<
i# 5sa#earra%t%pe AA 0x188
returnstrin( A FvoidF<
i# 5sa#earra%t%pe AA 0x198
returnstrin( A FhresultF<
i# 5sa#earra%t%pe AA 0x1a8
returnstrin( A FJF<
i# 5sa#earra%t%pe AA 0x1b8
returnstrin( A Fsa#earra%F<
i# 5sa#earra%t%pe AA 0x1c8
returnstrin( A Fcarra%F<
i# 5sa#earra%t%pe AA 0x1d8
returnstrin( A Fuserde#inedF<
i# 5sa#earra%t%pe AA 0x1e8
returnstrin( A FlpstrF<
i# 5sa#earra%t%pe AA 0x1#8
returnstrin( A Flp"strF<
i# 5sa#earra%t%pe AA 0x208
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x218
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x228
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x238
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x248
244260235.doc 175 od 541
returnstrin( A FrecordF<
i# 5sa#earra%t%pe HA 0x258
returnstrin( A Fille(alF<
return returnstrin(<
@

e.il
.class a1
9
.method void marshal 58 a158
9
@
.method void marshal 5 int88 a258
9
@
.method void marshal 5 #ixed s%sstrin( 61278 a358
9
@
.method void marshal 5 sa#earra%8 a458
9
@
.method void marshal 5 sa#earra% int88 a558
9
@
.method void marshal 5 sa#earra% int8 $ FhiF8 a658
9
@
.method void marshal 5 int16 6C47 8 a758
9
@
.method void marshal 5 int16 67 8 a858
9
@
.method void marshal 5 int8 607 8 a958
9
@
.method void marshal 5677 8 a1058
9
@
.method void marshal 5custom 5F*OF $ F+=:>F8 8 a1158
9
@
.method void marshal 5custom 5F*OF $ FF8 8 a1158
9
@
.method void marshal 5int8 64 C 57 8 a1258
9
@
@

/utput
244260235.doc 176 od 541
.method IJ06000001JI marshal58
.method IJ06000002JI marshal5 int88
.method IJ06000003JI marshal5 #ixed s%sstrin( 61278
.method IJ06000004JI marshal5 sa#earra%8
.method IJ06000005JI marshal5 sa#earra% int88
.method IJ06000006JI marshal5 sa#earra% int8$ FhiF8
.method IJ06000007JI marshal5 int166 C 478
.method IJ06000008JI marshal5 int16678
.method IJ06000009JI marshal5 int86078
.method IJ0600000*JI marshal56778
.method IJ0600000OJI marshal5 custom 5F*OF$F+=:>F88
.method IJ0600000+JI marshal5 custom 5F*OF$FF88
.method IJ0600000=JI marshal5 int864 C 578

e.il
.class a1
9
.method void marshal 5int16 64C57 627 8 a12258
9
@
.method void marshal 5int32 647 627637 8 a12358
9
@
.method void marshal 5unsi(ned int8 64C57 627637647 8 a12458
9
@
.method void marshal 5unsi(ned int16 6C57 627637647657 8 a12558
9
@
@

/utput
.method IJ06000001JI marshal5 int1664 C 57 bool8
.method IJ06000002JI marshal5 int32647 bool int88
.method IJ06000003JI marshal5 unsi(ned int864 C 57 bool int8 unsi(ned int88
.method IJ06000004JI marshal5 unsi(ned int1660 C 57 bool int8 unsi(ned int8 int168


'n this pro(ram "e displa% the marshal e%"ord. *s explained be#ore "e have broen the various
parts o# "hat comprises a method declaration and are doin( each on separatel%. !e are not
displa%in( the entire #unction =ispla%*ll0ethods as most o# the code is repetitive.

*ll that "e "ould lie %ou to do is remove the last t"o lines at the end or a#ter the methodstrin(
variable and replace them "ith "hat "e have above. !e are callin( a #unction
Det4aram*ttr#or0ethod0arshal that "ill contain the marshal attribute. Out$ "ait$ "e are movin(
ahead and #irst lets be clear on "hat this marshal is all about.

't "ould be ideal i# the +3' ran on its o"n and did not need or been hosted on top o# another
operatin( s%stem. !e are runnin( .)et or the +3' under a operatin( s%stem !indo"s 2000.
Nnder these operatin( s%stems some data t%pes have a certain speci#ic meanin( or the% per#orm
certain #unctions.
244260235.doc 177 od 541

Thus "e need a "a% to convert the built in or our user de#ined data t%pes to the native data t%pes
o# that operatin( s%stem. This marshallin( in#ormation is speci#ied usin( the e%"ord marshal.
:ver% #unction ma% have a return t%pe "hich is the value returned b% the native code in that
operatin( s%stem and "e can use the marshal e%"ord to convert it into a +3' data t%pe.

Thus the marshal e%"ord tells us the ori(inal data t%pe in th operatin( s%stem and "e "ill use
the marshal e%"ord to convert it into a +3' data t%pe that "e have speci#ied. '# "e did not have
the marshal e%"ord$ ho" does our +3' no" "hat is the return value. 't "ould assume the
return value o# the native code is e.uivalent to our #unctions return t%pe.

The marshal e%"ord comes in to tell the +3' that the native #unction "ill return a certain data
t%pe and "e need to convert this data t%pe to the data t%pe that our '3 #unction re.uires. The same
holds (ood #or parameters to #unctions in a sli(htl% di##erent "a%. 2ere "e need to speci#% "hat
the +3' data t%pe needs to be converted to as the marshal e%"ord speci#ies the data t%pe that the
native #unctions expects.

?ust the reverse o# "hat "e explained earlier. This means that in our #unction =ispla%*ll0ethods$
the Det4aram*ttr#or0ethod0arshal #unctions (ets called more than once and hence the di##erent
parameters and the complexit% o# our code increases. The #irst parameter is the method ro"
number as this is "hat identi#ies each method uni.uel% in the metadata.

The second number is the "hat "e cal the se.uence number. This value is either 0 or 1. *t this
point in time its value is 0 and "e "ill see its use a little later. *t little "hile a(o "e explained the
concept o# ho" a t%pe can have a more than one method and ho" a sin(le #ield can tell us "hich
method is o"ned b% "hich t%pe.

This is a one to man% relationship "hich also applies to methods and parameters as one method
can have man% parameters. The param #ield stores the startin( parameter index in the param table
o# each method. !hen %ou have a (ood idea its nice to use it ever%"here. Thus "e (et t"o
variables start and end that tell us the #irst and last param index o"ned b% this method in the
param table.

!e use these values #or error checs onl%. '# the value o# start points to the end o# the param
table$ it means that "e have methods that have parameters as the 4aram;truct table is not empt%$
but this method and the ones #ollo"in( have no parameters at all and also no marshal e%"ord.
The second error chec is "hen both the start and end variables have the same value.

This means that these methods have no parameters at all. The .uestion uppermost in %our mind is
"hat does parameters have to do "ith the marshal e%"ord. *t this point "e are talin( not about
the marshallin( o# parameters but that o# the return value. =oes not matter. '# the return value has
a marshal e%"ord$ a ro" (ets added into the param table.

Out this method does not have a parameter at all and thus the se.uence #ield o# the param table
"hich other"ise tells us the param number is no" &ero. !e have one last error chec "hich
checs #or those cases "here "e have parameters but no marshal e%"ord #or the return t%pe.

This checs sa%s that i# se. is 0$ "e are checin( #or the return t%pe bein( marshaled and thus the
se.uence #ield must also be 0. !e no" need to decode the marshal e%"ord and use the method
=ecode4aram*ttributes to do the 1ob #or us. *s both methods and #ields can be marshaled this
#unction (ets called more than once "ith di##erent parameters.
244260235.doc 178 od 541

't is this #unction that actuall% (ives us the marshal e%"ord and "e #irst chec "hether the #irst
character o# the return strin( is a space usin( the read onl% indexer. '# in the a##irmative$ "e
remove this space. !e do this because at times "e do not need the #irst space that "e "rite out
be#ore the e%"ord marshal.

'# %ou loo closel% at the #unction =ecode4aram*ttributes "e have the marshal e%"ord startin(
"ith a space and #or methods "e remove this space. The return strin( ma% be null and hence
be#ore accessin( the strin( "e need to mae sure that it is non null. 3et us no" move on to the
#unction =ecode4aram*ttributes that does the bil o# the "or in #i(urin( out the marshal
e%"ord.

The #irst and last parameters are used to(ether. The 4aram table has a #la(s #ield that tells us all
about the attributes on a parameter. The return value is also taen to be a parameter "ith a
se.uence number o# 0. * bit mas o# 0x2000 means that this parameter has a marshal attribute.

There#ore the last parameter also has a value o# 0x2000. '# a #ield has a marshal attribute
associated "ith it$ the bit mas is di##erent. Thus an% parameter that has a marshal attribute$ the
pattr #ield o# the param table "ill have a bit mas o# 0x2000.

This is "h% "e start the #unction b% checin( "hether the pattr parameter has a bit mas o#
0x2000 or i# there is a marshal attribute associated "ith the parameter or in this case the return
value. '# the ans"er is in the a##irmative$ "e no" scan the >ield0arshal table that has one ro" #or
ever% marshal e%"ord used.

This table uses a coded index that has a sin(le bit that points to the #ield or param table. 3ooin(
at our code the value o# 1 means the param table and 0 means the #ield table. The second
parameter to this #unction is the param table number o"ned b% this parameter or return value.

Thus to #ind a matchin( ro" in the >ield0arshal table "e need to chec the param or #ield ro"
number as "ell as the table t%pe at the same time. '# "e meet a match$ "e then use the index
variable ii to (et at the index #ield "hich is nothin( but an o##set o# the marshal si(nature in the
blob stream.

The variable blobindex no" holds an o##set into the blob stream "hich as al"a%s starts "ith a
len(th o# b%tes that it controls. This is as a blob means somethin( that is not de#ined has no
no"n structure. !e #irst need to no" t"o thin(s$ the number o# b%tes that mae up the blob
marshal si(nature and its value.

!e use our (ood old trust% method +or;i(Nncompress=ata that returns i# %ou #or(et the number
o# b%tes that mae up the si(nature and the last out parameter the actual b%tes. )ormall% the
marshal blob si(nature "ill not be (reater than 127 b%tes and in the #ollo"in( code at times "e
have directl% read the len(th and not used the +or;i(Nncompress=ata method.

!e can lie %ou (et slopp% at times. That is "h% "e as %ou to also mae chan(es in the code
and treat it lie a 1oint venture$ bet"een %ou and us. !e then have a comment that displa%s the
#irst #our b%tes o# the marshal si(nature. !here "e use this "ill become clear in a short "hile.

;ta% "ith us as %ou "ill then appreciate ho" "e (et thin(s "orin(. !e call a #unction
Det0arshallT%pe that taes three parameters. 't is actuall% this #unction that decodes the blob
244260235.doc 179 od 541
si(nature. The marshal si(nature starts "ith the len(th b%te and then a b%te that describes the
actual data t%pe "hich "ill be marshaled to at the other end.

't is this b%te that "e pass to the Det0arshallT%pe method #ollo"ed b% the len(th o# the si(nature
and also the startin( blob index. This #unction returns the marshal si(nature startin( "ith space
that "e ma% remove in the earlier #unction i# %ou remember.

'# the marshal si(nature is the empt% arra% braces 67 or contains an arra% and a plus si(n$ the
po"ers to be decided that the space a#ter the open bracet a#ter the "ord marshal should not be
there. Thus the i# statement removes a pes% space. !e have spend a lot o# i# statements
removin( a space or addin( a space. !hat a li#e.

!e then close the bracet and i# there is a valid marshal si(nature "e add a space at the end o# the
marshal si(nature. ;ee one more i# statement. )o" lets move on the Det0arshallT%pe #unction.
The #irst thin( "e do in this #unction is chec the len(th o# the blob si(nature.

'# it is &ero$ then "e have no si(nature and bail out. This means that "e have the marshal
e%"ord but no data t%pe "ithin bracets lie in method a1 in the il #ile. This #or some reason is a
valid marshal e%"ord. )ormall% "e use the marshal e%"ord as in #unction a2 "here "e
speci#% a data t%pe lie int8.

Thus "e no" have a series o# i# statements that chec the value o# the #irst parameter
marshal#la(s "ith a prede#ined set o# values. !hen "e come to a value o# 0x17 "hich has a data
t%pe o# #ixed s%sstrin($ "here "e have to pass it a number in s.uare bracets lie method a3.
!hile most o# the data t%pes are simple a value o# 0x1d is a little more complex as it stands #or
sa#earra%.

The sa#earra% data t%pe ma% or ma% not #ollo"ed b% data t%pe lie method a4 or a5. !e #irst call
a method Det;a#e*rra%T%pe that "e pass the b%te #ollo"in( the len(th and the marshal t%pe$ i.e.
the third b%te o# the blob si(nature. This #unction once a(ain checs the b%te a(ainst a prede#ined
set o# values and returns is the sa#e arra% data t%pe.

There is nothin( in this #unction that "ill surprise us and it is a lon( series o# i# statements. !e
onl% add a extra space i# the Det;a#e*rra%T%pe method returns a data t%pe. The i# statement is
important as "e have a sa#earra% data t%pe onl% i# the len(th o# the marshal si(nature is lar(er
than 2. !e then tell ourselves that the sa#earra% data t%pe can have a comma #ollo"ed b% a strin(
in double inverted commas.

This is uni.ue to the sa#earra% data t%pe and "ill occur onl% i# the len(th is lar(er than 3. The 3
b%tes are taen b% the len(th$ the sa#earra% data t%pe and the data t%pe #ollo"in( the sa#e arra%.
!e thus reduce the len(th b%te b% 3 and i# this result is lar(er than 0$ "e print out the strin( in
double .uotes "ith a comma. The value 0x1e is #or a #ixed arra% "hich is similar to the #ixed
s%sstrin(.

* value o# 0x2a in our opinion is the most complex as it deals "ith an arra%. * arra% starts "ith a
data t%pe and then ma% have a number in bracets. The data t%pe ho"ever is optional. Thus the
arra% data t%pe i# it is three b%tes lar(e "ould mean that the #irst b%te is the len(th that "e do not
count$ the second the arra% data t%pe value 0x2a$ the third the data t%pe be#ore the arra% and the
last the number in bracets "ith the plus si(n.

This is represented b% the method a7.
244260235.doc 180 od 541
2o"ever #or the method a8 the len(th is 2 b%tes and the second b%te is the b%te 2a #ollo"ed b%
the arra% data t%pe. This is as the bracets have no value. >or #unction a9 "e have a len(th o# #our
as the #irst t"o b%tes are the same as above and "e are #ollo"ed b% t"o &eroes. The last method
a10 is special as "e have no data t%pe.

2ere the #irst t"o b%tes are the same #ollo"ed b% a 0x50 "hich means no data t%pe$ then
#ollo"ed b% a &ero and then the number in the bracets. 'n our code the variable dumm%1 simpl%
contains a space or null dependin( upon the len(th o# the blob si(nature. * value o# three means a
space$ 4 no space. The strin( arra%s has the number in arra% bracets "ith the plus si(n "ith or
"ithout the space be#ore the plus si(n.

The de#ault is the empt% arra% bracets. This number is either the second or third b%te o# the blob
si(nature dependin( upon the len(th o# the si(nature. The #irst b%te a#ter the marshal data t%pe is
al"a%s the data t%pe o# the arra% and thus "e use the Det0arshallT%pe t%pe #unction to return this
value to us.

/nce a(ain a use o# recursion as "e are in the same #unction and callin( the same #unction. 3ets
tae #unction a12 to demonstrate all the b%tes o# a blob si(nature #or a arra%. !e have added t"o
numbers 4 and 5 to(ether. The blob si(nature reads as 4 2* 3 5 4. The #irst as al"a%s is the len(th
o# the blob si(nature "ithout considerin( the len(th b%te itsel#.

This is #ollo"ed b% the arra% t%pe 0x2a. Then comes the data t%pe o# the arra% int8 or 3. this is
#ollo"ed b% the t"o number in bracets 5 and 4. 3ets no" turn our attention to the second il #ile
and lets understand the complexities here and "h% "e have broen our arra% si(nature into t"o
separate il #iles.

!e start our arra% i# statement "ith a #or loop that simpl% displa%s the arra% si(nature usin( the
#irst b%te as the len(th. 'n our pro(ram "e have commented it out$ but this is the "a% "e have
seen the blob si(nature. >or the #irst #unction a122 the marshal e%"ord is marshal 5int16 64C57
627 8.

!e have added a 2 in s.uare bracets a#ter the #irst arra% (ets over. This results in the blob
si(nature loo lie 7 2* 2* 5 5 4 0 2. The len(th "hich is normall% 4 (ets increased b% 3. The
three b%tes are made up o# a extra 0x2a as "ell as a 0 and the number 2 "hich "e "rote.

'# %ou no" loo at #unction a123 "hich has the marshal e%"ord as marshal 5int32 647 627637 8$
"e have added t"o arra% dimensions to it. The b%tes it creates are * 2* 2* 2* 7 0 4 0 2 0 3.
There is a #urther increase o# 3 b%tes "ith a 0x2a in the be(innin( and a 0 and the number "e
"rite 3 at the end.

Thus each extra dimensions adds a 0x2a as "ell as t"o b%tes representin( the dimension at the
ver% end. !e no" need to handle this special case. *s mentioned earlier$ the len(th is normall% 3
or 4. '# it is (reater than 7$ "e ic o## a ne" i# statement. !e start "ith #i(urin( out ho" man%
dimensions "e have.

This number can be obtained b% dividin( b% 3 as each ne" dimension increases the len(th b% 3.
!e store this value in the variable ho"man%t%pes. The main data t%pe o# the arra% is stored a#ter
all the 0x2aQs (et over and thus "e no" need the o##set o# "here the arra% data t%pe starts.

!e start at blobindex and then add the number o# b%tes this len(th taes and then the number o#
0x2aQs that "e have. !e do not add b% 1 as there is al"a%s one 0x2a. !e use the
244260235.doc 181 od 541
Det0arshallT%pe method to return this data t%pe as a strin( and then use the same method earlier
to (et at the #irst arra% dimension "ith or "ithout the plus si(n.

!e then need to add the #inal data t%pes. The variable ho" man% b%tes (ives us one more than the
number o# data t%pes and hence the #or loop is one less. !e use the variable ho"man%t%pes to (et
at the end o# the normal si(nature and then "e hit a roadbloc.

The len(th o# the arra% si(nature can be 3 or 4 and hence i# "e hit a 0$ "e no" that the len(th is
3 and hence "e increase b% 1 and not 2. "e displa% these dimensions as a data t%pes. !e no"
move on to the ori(inal #ile e.il.

'# the #irst data t%pe is 0x50$ this means that "e do not have a data t%pe and hence the returnstrin(
is onl% the s.uare bracets. The last value is the custom data t%pe "hich is nothin( but the "ords
custom #ollo"ed b% t"o strin(s. The #ormat is the len(th o# the strin($ #ollo"ed b% 0x2c and then
t"o &eros.

This is #ollo"ed b% the len(th o# the #irst strin($ then the actual strin(. !hen this strin( (ets over$
"e then have the second strin( and its contents. Thus "e #irst #i(ure out the len(th o# the #irst
strin( that is 3 b%tes #rom the data t%pe and in a #or loop print out the strin(.

!e then 1ump to the len(th o# the second strin( no"in( that its len(th is stored in the variable
len1 and "e need to (o one more and hence "e add b% the value stored in the variable b%tes. This
can be 1 or 2 dependin( upon the len(th o# the t"o strin(s.

'# the sum exceeds 128$ then the len(th o# the blob si(nature b%te "ill be 2 and not one and hence
i# "e assume a value o# 1$ "e "ill be readin( the last b%te o# the #irst strin( as the len(th b%te.
The rest o# the code remains the same.

There are a minimum set o# data t%pes that have to b supported b% the +3' and these are int8$
int16$ unsi(ned int8$ bool $ char and all the native inte(er data t%pes. ,emember under !indo"s
all code is "ritten in the + pro(rammin( lan(ua(e.

The list o# data t%pes (oes on and this includes enums that are (lori#ied constants and the #loatin(
point data t%pes #loat32 and #loat64. :ven thou(h + and cCC do not support the strin( data t%pe it
is common enou(h to be included in the list o# mandator% data t%pes.

/bviousl% pointer to the above data t%pes are also included alon( "ith one dimensional arra%s
"ho start countin( #rom &ero. These conversions are #rom mana(ed to unmana(ed and need not
be supported #orm unmana(ed to mana(ed i.e. #or the return t%pes. =ele(ates and pointers to
#unctions are not the same and thus a dele(ate cannot be used in unmana(ed code.

The marshal e%"ord is the onl% interoperable e%"ord available and lets us "or closel% "ith
older le(ac% code. 't is plat#orm speci#ic and "ill not "or across the board. This means that the
"indo"s implementation "ill never ever "or sa% on 3inux. /nce a(ain the marshal e%"ord
speci#ies the data t%pe that the mana(ed code "ill be converted to "hen it (oes to unmana(ed
code.

The s%stem ho"ever has a lot o# de#ault rules that (overn "hat happens "hen "e do not use this
e%"ord. The problem arises "ith the use o# user de#ined t%pes or classes and the +3' does not
re.uire this marshallin( #rom all its con#ormin( implementations.

244260235.doc 182 od 541
:ach implementation decides ho" to marshal user de#ined t%pes and the s%stem imposes no
restrictions. This "ill (uarantee that code (enerated "ill not be portable but it is a price to pa% as
user de#ined t%pes are too (eneric #or an%one to impose rules. The >ield0arshal table has onl%
columns "hich "e have used earlier.

't is obvious that this table is onl% used b% code that calls into unmana(ed code. /nce the code
calls unmana(ed code$ "e are l%in( outside the re(ime o# the +3' and thus "e are assumin( that
the code "e call does not brea an% rules.

The .uestion uppermost in %our mind is ho" did "e #i(ure out all the data t%pes that "e could
use "ith the marshal. :lementar%$ %ou mi(ht sa%$ pee into the specs. !e did 1ust that and
reali&ed that there "ere hu(e (aps in the data t%pes that "e speci#ied in the docs. Thus "e "ere in
a .uandar%.

2o" do "e #i(ure out all o# them. :ven thou(h "e "ent thou(h 5000 #ile$ "e "ere %et not sure
"hether "e had it all se"ed up. Thus "e #irst displa%ed the marshal si(nature b%tes and then
searched #or them in a hex editor lie ultra edit that can be do"nloaded #ree #rom the net.

These b%tes "ill al"a%s be a#ter the O;?O si(nature. )o" that "e have #ound the b%tes$ "e
chan(e the b%te that contains the sa% data t%pe and then save the #ile. !e next call the ildasm
pro(ram "hich no" tells us "hat data t%pe that value stood #or. ;imple is it not. This is ho" "e
could #i(ure out "hat the specs did not contain.

!e are tellin( %ou all this as this as the best "a% to learn. +han(e the b%tes in the table itsel# and
see "hat the disassembler has to sa% about the chan(e. This is "h% ever%"here %ou "ill #ind us
displa% the b%tes.

4ro(ram22.csc
public void =ispla%*ll0ethods 5int t%pero"8
9
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( paramattrstrin( A FF<
paramattrstrin( A Det4aram*ttr#or0ethod+allin( 5methodindex8<
+onsole.!rite3ine5methodstrin( C paramattrstrin(8<
@
@

public strin( Det4aram*ttr#or0ethod+allin( 5int methodindex8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null8
return returnstrin(<
int end<
int start A 0ethod;truct6methodindex7.param<
i# 5 methodindex AA 50ethod;truct.3en(th P18 8
end A 4aram;truct.3en(th C 1<
else
end A 0ethod;truct6methodindexC17.param<
i# 5 start AA 4aram;truct.3en(th8
return returnstrin(<
i# 5 start AA end8
244260235.doc 183 od 541
return returnstrin(<
i# 54aram;truct6start7.se.uence EA 08
return FF<
int pattr A 4aram;truct6start7.pattr<
i# 5 5pattr G 0x018 AA 0x018
returnstrin( A returnstrin( C F6in7F <
i# 5 5pattr G 0x028 AA 0x028
returnstrin( A returnstrin( C F6out7F <
i# 5 5pattr G 0x108 AA 0x108
returnstrin( A returnstrin( C F6opt7F <
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin( C F F<
return returnstrin( <
@


e.il
.class a1
9
.method 6in7 void a158
9
@
.method 6out76opt7 void a258
9
@
@


/utput
.method IJ06000001JI 6in7
.method IJ06000002JI 6out76opt7

4arameters and return values can have a parameter attribute o# in$ out or optional. These are part
o# the parameter de#inition and not part o# the method si(nature. The above attributes are
associated "ith parameters and not reall% "ith return values. The in and out attributes appl% to
pointers o# either mana(ed or unmana(ed t%pes.

*ll that the% sa% is "hether the parameter supplies a value to the #unction in or the #unction #ills it
up "ith a value or both. The de#ault is in. 2o"ever the +3' does not "orr% about "hether this
contract is bein( en#orced.

This helps the +3' in optimi&ations #or distributed computin($ speciall% i# it is a in parameter$ the
value needs to send across to another computer i# the called #unction resides there and "e do not
"orr% about the return value. >or a out parameter it is the reverse$ "e do not send a value across
but the return value is meanin(#ul.

The opt value means that #rom the pro(rammers point o# vie"$ the value is optional. * little later
"e "ill deal "ith the .param e%"ord that "ill suppl% opt parameters "ith values. The method
=ispla%*ll0ethods no" calls a method Det4aram*ttr#or0ethod+allin( to #i(ure out these
values.

244260235.doc 184 od 541
'n this method "e start "ith the mandator% error checs and then chec "hether "e have a
attribute or not. '# the se.uence #ield is not &ero "e abort "ith a null strin( as this means our
return value does not have an% param attributes.

!e then bit "ise and "ith 1$ 2 or 0x10 to chec "hich o# the 3 param attributes "e have. The
onl% thin( to remember is that these attributes are not mutuall% exclusive. * small pro(ram a#ter a
lon( time. =o not expect such small mercies #or a lon( time.

4ro(arm23.csc

strin( 67 methodde#returnarra%<
strin( 67methodde#t%pearra%<
int 67 methodde#paramcount<

public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
+reate;i(natures58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
=ispal%-t>ixup58<
=ispla%T%pe=e#s58<
=ispla%T%pe=e#s*nd0ethods58<
@

public void +reate;i(natures 58
9
i# 50ethod;truct EA null8
9
methodde#returnarra% A ne" strin(60ethod;truct.3en(th7<
methodde#t%pearra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramcount A ne" int60ethod;truct.3en(th7<
#or 5 int l A 1 < l B 0ethod;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe 51 $ 0ethod;truct6l7.si(nature$ l8<
@
@
244260235.doc 185 od 541
@
public void +reate;i(nature>or:achT%pe 5b%te t%pe $ int index $ int ro"8
9
II+onsole.!rite3ine5F.......t%peA90@ ro"A91@ indexA92@ blob.3en(thA93@ 94@F $ t%pe $
ro".To;trin(5FKF8 $ 5ushort8index $ blob.3en(th $ 5uint8index8<
int uncompressedb%te $ count $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata 5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blob1 A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blob1 $ 0 $ count8<
i# 5 t%pe AA 18
+reate0ethod=e#;i(nature 5blob1 $ ro"8<
@
public void =ispla%*ll0ethods 5int t%pero"8
9
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( s A methodstrin( C F F C methodde#returnarra%6methodindex7C F F C
methodde#t%pearra%6methodindex7 <
+onsole.!rite3ine5s8<
@
@
public void +reate0ethod=e#;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F+reate0ethod=e#;i(nature *rra% 3en(thA90@ method ro"A91@
nameA92@F $ blobarra%.3en(th $ ro" $ Det;trin(50ethod;truct6ro"7.name88<
int aa A P1<
i# 5 ro" AA aa8
9
+onsole.!rite3ine5Det;trin(50ethod;truct6ro"7.name88<
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
+onsole.!rite3ine5F3en(th o# arra% is 90@F $ blobarra%.3en(th8<
@
int ho"man%b%tes$uncompressedb%te $ count $ index<
index A 0<
ho"man%b%tes A +or;i(Nncompress=ata 5blobarra% $ index $ out uncompressedb%te8<
methodde#t%pearra% 6ro"7 A =ecode>irstO%teo#0ethod;i(nature 5uncompressedb%te $ ro"8<
index A index C ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata 5blobarra% $ index $ out uncompressedb%te8<
count A uncompressedb%te<
methodde#paramcount6ro"7 A count<
index A index C ho"man%b%tes<
strin( returnt%pestrin( A FF<
returnt%pestrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes 8<
methodde#returnarra% 6ro"7 A returnt%pestrin(<
@
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
244260235.doc 186 od 541
b%te t%pe A blobarra%6index7<
i# 5 t%pe HA 0x01 GG t%pe BA 0x0e 8
9
returnstrin( A DetT%pe5t%pe8<
ho"man%b%tes A 1<
@
return returnstrin(<
@
public strin( =ecode>irstO%teo#0ethod;i(nature 5int #irstb%te $ int methodro"8
9
strin( returnstrin( A FF<
i# 5 5#irstb%teG 0x20 8 AA 0x20 8
returnstrin( A Finstance F<
i# 5 5#irstb%te G 0x40 8 AA 0x40 8
returnstrin( A Fexplicit instance F<
int #irstbits A #irstb%te G 0x#<
i# 5 #irstbits AA 0x02 8
returnstrin( A returnstrin( C Funmana(ed stdcall F<
else i# 5 #irstbits AA 0x03 8
returnstrin( A returnstrin( C Funmana(ed thiscall F<
else i# 5 #irstbits AA 0x05 8
returnstrin( A returnstrin( C Fvarar( F<
else i# 5 #irstbits AA 0x01 8
returnstrin( A returnstrin( C Funmana(ed cdecl F<
else i# 5 #irstbits AA 0x04 8
returnstrin( A returnstrin( C Funmana(ed #astcall F<
return returnstrin(<
@
public strin( DetT%pe 5int t%peb%te8
9
i# 5 t%peb%te AA 0x018
return FvoidF<
i# 5 t%peb%te AA 0x028
return FboolF<
i# 5 t%peb%te AA 0x038
return FcharF<
i# 5 t%peb%te AA 0x048
return Fint8F<
i# 5 t%peb%te AA 0x058
return Funsi(ned int8F<
i# 5 t%peb%te AA 0x068
return Fint16F<
i# 5 t%peb%te AA 0x078
return Funsi(ned int16F<
i# 5 t%peb%te AA 0x088
return Fint32F<
i# 5 t%peb%te AA 0x098
return Funsi(ned int32F<
i# 5 t%peb%te AA 0x0a8
return Fint64F<
i# 5 t%peb%te AA 0x0b8
244260235.doc 187 od 541
return Funsi(ned int64F<
i# 5 t%peb%te AA 0x0c8
return F#loat32F<
i# 5 t%peb%te AA 0x0d8
return F#loat64F<
i# 5 t%peb%te AA 0x0e8
return Fstrin(F<
return Funno"nF<
@


e.il
.class a1
9
.method explicit instance bool a158
9
@
.method instance int16 a258
9
@
.method varar( void a358
9
@
.method de#ault int8 a458
9
@
.method unmana(ed stdcall int8 a558
9
@
.method unmana(ed thiscall int8 a658
9
@
.method unmana(ed cdecl int8 a758
9
@
.method unmana(ed #astcall int8 a858
9
@
@

/utput
.method IJ06000001JI bool explicit instance
.method IJ06000002JI int16 instance
.method IJ06000003JI void instance varar(
.method IJ06000004JI int8 instance
.method IJ06000005JI int8 instance unmana(ed stdcall
.method IJ06000006JI int8 instance unmana(ed thiscall
.method IJ06000007JI int8 instance unmana(ed cdecl
.method IJ06000008JI int8 instance unmana(ed #astcall

244260235.doc 188 od 541
'n this pro(ram "e displa% some more stu## about a method lie its callin( convention as "ell as
the data t%pe o# the return value. The problem "ith the data t%pe is that it #ills up hundreds o#
pa(es and hence "e have broen up the data t%pes into do&ens o# pro(rams.

Thus the next couple o# pro(rams onl% #ocus on the data t%pes that a return value can carr%. !e
have three instance arra%s that "ill carr% the callin( convention methodde#t%pearra%$ the data t%pe
o# the return value methodde#t%pearra% and #inall% the number o# parameters that the method has.

These variables are arra%s as "e "ill have scores o# #unctions in our il code. '# %ou loo at the
ne" abc method$ "e have a added a method +reate;i(natures that simpl% create all the method
si(natures in one (o and populate our arra%s. Thus in our code later on "e simpl% displa% the
relevant arra% members.

'n the +reate;i(natures method "e #irst mae sure that "e have at least one method in our code
as there is no point in computin( si(natures i# "e have no methods to deal. 't is here that "e #irst
create the three arra%s o# the desired si&es usin( the len(th o# the messa(e table as the si&e o# the
arra%.

!e then use a #or loop to call another method +reate;i(nature>or:achT%pe that does the actual
"or. !e have broen up our code into di##erent #unctions as "e need to calculate di##erent t%pes
o# si(natures. These include those #or local variables$ #ields etc.

Thus the #irst parameter is 1 as "e have used this number to denote a method de# si(nature. *
method de# is a method that "e have de#ined$ a method re# a method "e are callin( that is de#ined
some"here else. The second parameter is the #ield si(nature that is an o##set into the blob heap
"here the si(nature o# the method is located.

The third is the ro" number o# each method. !e no" move on the #unction
+reate;i(nature>or:achT%pe "here "e do some "or. *ll the si(nature to start "ith have a
common rule. The #irst b%te is the len(th o# the si(nature as "e are dealin( "ith the blob stream.

!e use our #unction +or;i(Nncompress=ata to (et at the len(th as the si(nature ma% cross 127
b%tes. )o" that "e no" the len(th o# the si(nature$ "e create an arra% blob1 that is o# the same
si&e. !e cop% the si(nature b%tes minus the len(th b%te into this arra% usin( the static +op%
method o# the arra% class.

This methods #irst parameter is the source arra% that contains the ori(inal data blob$ then "e have
the startin( point in the ori(inal arra% blob #rom "here "e "ant to start the cop%. The index
variable tells us the startin( point and the ho"man%b%tes the len(th o# the count b%tes.

The third parameter is the destination arra% blob1 and the #ourth the startin( point in the
destination arra%. !e use 0 as "e "ant to start the cop% #rom the be(innin(. >inall% "e have the
len(th o# the number o# b%tes to cop% "hich is the count variable. Thus all that "e have done is
create an arra% blob1 that contains onl% the si(nature.

*s the t%pe parameter is 1 "e no" call the method +reate0ethod=e#;i(nature "ith the ne"l%
created arra% and the ro" number. 't is this #unction that does the actual (runt "or.

The idea bein( that its easier to "or "ith a arra% that contains onl% the method si(nature than an
arra% that contains the same si(nature but at an o##set. Wou do have to a(ree "ith us on this one.
3ets tae a short detour and #irst move on the #unction =ispla%*ll0ethods.
244260235.doc 189 od 541

*ll that "e do here is displa% the contents o# t"o o# the three arra%s that the
+reate0ethod=e#;i(nature populates. 'n the method +reate0ethod=e#;i(nature "e start "ith
displa%in( the entire si(nature b%tes o# the #unction. The ro" number can never be [1 and hence
the displa% code never (ets code.

!e chan(e the aa variable to the ro" number "hose si(nature "e "ant to loo at. The #irst b%te
o# the method de# si(nature includes t"o thin(s. 'n a method "e use either the "ords explicit or
explicit instance lie in method a1 or onl% instance in method a2.

Then comes in the variable number o# ar(uments varar( in method a3 or the de#ault "hich is
de#ault as in method a4. The hasthis and explicitthis is ored "ith the t"o callin( convention
values de#ault or varar(. :ven thou(h "e no" that this b%te "ill al"a%s be one$ "e %et use the
+or;i(Nncompress=ata to extract its value.

To #i(ure out "hich bits stand #or "hat "e use the =ecode>irstO%teo#0ethod;i(nature to
populate the methodde#t%pearra% arra%. This method is lie "hat "e have done be#ore and "e
hope %ou understand "h% the order o# the second round o# i# statements is ver% important.

:ven thou(h the method de# rules onl% use t"o callin( conventions$ "e have included #our more
as the others si(natures use them. *lso i# "e ta( our methods "ith these callin( conventions lie
unmana(ed stdcall$ ildasm does not complain. *lso usin( the de#ault e%"ord is not an error but
it does not sho" up in the disassembled output.

The second b%te is the number o# parameters that "e have. !e ma% have more than 127
parameters and hence "e use the +or;i(Nncompress=ata to (et at this value. Oe#ore usin( this
#unction "e need to add to the index variable the number o# b%tes taen up b% the earlier #ield
"hich in this case is 1.

!e "ill eep addin( the variable ho"man%b%tes to the index variable. !e store the number o#
parameters in the arra% methodde#paramcount #or #uture use and no" call a ver% important
method Det:lementT%pe that "ill (ive us the data t%pe o# the return value o# the #unction.

This is the next bit o# in#ormation stored in the si(nature. !e pass the Det:lementT%pe method
three parameters. The #irst is the startin( b%te o# the return data t%pe stored in the index variable$
the arra% blobarra% and #inall% the number o# b%tes o# the si(nature the return data t%pe taes up.

This number could be in the hundreds as %ou "ill soon see. The return value o# this #unction$ the
actual data t%pe is stored in the arra% methodde#returnarra%. The #irst b%te o# the data t%pe
si(nature tells us about the rest o# the b%tes.

'# its value is bet"een is 1 and 14$ then the data t%pe is a ver% simple data t%pe lie bool or strin(
or int8. !e thus use a i# statement to tell us "hether it is a simple data t%pe and use the DetT%pe
method to return this t%pe. The DetT%pe method is simpl% a series o# 14 i# statements.

!e return the value stored in the variable returnstrin( and set the out variable ho"man%b%tes to 1
as our data t%pe bein( simple taes onl% one b%te in the si(nature. This is ho" "e tae care o# the
elementar% data t%pes. The next example taes on more complex data t%pes and unless "e #inish
all o# them "e "ill not proceed to do an%thin( else.

4ro(ram24.csc
244260235.doc 190 od 541
public void =ispla%*ll0ethods 5int t%pero"8
9
strin( s A methodstrin( C F F C methodde#returnarra%6methodindex7 <
+onsole.!rite3ine5s8<
@

public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe HA 0x01 GG t%pe BA 0x0e 8
9
returnstrin( A DetT%pe5t%pe8<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x13 8
9
returnstrin( A FEF C blobarra%6indexC17.To;trin(58<
ho"man%b%tes A 2<
@
i# 5 t%pe AA 0x15 TT t%pe AA 0x17 TT t%pe AA 0x1e TT t%pe AA 0x21 8
9
returnstrin( A FIJ N)\)/!) TW4: 50xF C t%pe.To;trin(5FKF8 C F8JIF<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x168
9
returnstrin( A Ft%pedre#F<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x188
9
returnstrin( A Fnative intF<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x198
9
returnstrin( A Fnative unsi(ned intF<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x1a8
9
returnstrin( A Fnative #loatF<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x1c8
9
returnstrin( A Fob1ectF<
ho"man%b%tes A 1<
@
244260235.doc 191 od 541
i# 5 t%pe AA 0x45 8
9
int ho"man%b%tes2 <
returnstrin( A Det:lementT%pe5 index C 1 $ blobarra% $ out ho"man%b%tes28 C F pinnedF<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
return returnstrin(<
@

e.il
.class a1
9
.method E20 a158
9
@
.method t%pedre# a258
9
@
.method native int a358
9
@
.method native unsi(ned int a458
9
@
.method native #loat a558
9
@
.method ob1ect a658
9
@
.method int8 pinned a758
9
@
@

/utput
.method IJ06000001JI E20
.method IJ06000002JI t%pedre#
.method IJ06000003JI native int
.method IJ06000004JI native unsi(ned int
.method IJ06000005JI native #loat
.method IJ06000006JI ob1ect
.method IJ06000007JI int8 pinned

'n this example "e lie in the earlier one have simpl% handled some o# the more easier t%pes. *ll
the code remains the same but some i# statement that "e have added to the Det:lementT%pe
method. The #irst #unction a1 uses a depreciated t%pe E that stands #or the var t%pe.

The speci#ications do not speci#% this t%pe and "e #ollo"ed the advice "e (ave %ou some time
a(o. !e "ent to the third b%te o# the si(nature and put 0x13 there. !e then ran the disassembler
244260235.doc 192 od 541
"hich came up "ith the E t%pe. This t%pe is #ollo"ed b% a number and hence the ho"man%b%tes
variable should be 2 as this is the len(th o# the t%pe.

The values 15$ 17$ 1e and 21 are unno"n. The others but the last are simple t%pes. The last one
"hich is 45 is a t%pe but #ollo"ed b% the "ords pinned. This t%pe 0x45 is #ollo"ed b% the t%pe
and hence "e call the Det:lementT%pe method "ith one added to the index variable. This method
returns the t%pe and "e simpl% add the "ords pinned to it.

The ho"man%b%tes variable is "hat the Det:lementT%pe method returns plus 1.

4ro(ram25.csc
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe AA 0x1d8
9
returnstrin( A Det;&*rra%5index $ blobarra% $ out ho"man%b%tes8<
@
return returnstrin(<
@
public strin( Det;&*rra% 5int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int i A 1<
returnstrin( A F67F<
"hile 5 true 8
9
b%te next A blobarra%6indexCi7<
i# 5 next EA 0x1d 8
brea<
returnstrin( A returnstrin( C F67F<
i A i C1 <
@
int ho"man%b%tes2<
returnstrin( A Det:lementT%pe5index C i $ blobarra% $ out ho"man%b%tes28 C returnstrin(<
ho"man%b%tes A i C ho"man%b%tes2<
return returnstrin(<
@


e.il
.class a1
9
.method int8 676767 a158
9
@
@

/utput
244260235.doc 193 od 541
.method IJ06000001JI int8676767

'n this example and the next "e deal "ith arra%s. 'n the method Det:lementT%pe "e add one
more i# statement that checs i# the t%pe b%te or the #irst b%te is 0x1d. This t%pe is #or a simple
arra% that has no speci#ic dimensions values. !e can have as man% dimensions as "e lie.

'# "e see the si(nature "e #ind the #ollo"in( 1= 1= 1= 04. Thus each dimension "e add brin(s
in a extra 0x1d. *t the end i# the t%pe si(nature is the actual data t%pe. The #act that the
Det;&*rra% (ets called simple means that "e have at the ver% least one dimension "hich is a
must but can have more.

!e initiali&e the returnstrin( variable to a empt% arra% bracets and then set out in a loop that is
inde#inite as "e do not no" ho" man% dimensions the arra% "ill have. !e at the be(innin( at
the loop chec "hether the #ollo"in( b%te is not a 0x1d. '# the ans"er is %es$ "e no" that all is
over and "e exit #rom the loop.

'# the next b%te is a 0x1d$ "e add a extra pair o# arra% bracets or a extra dimension to the
variable returnstrin(. !hen "e #inall% leave the inde#inite "hile loop$ "e have the returnstrin(
variable contain the ri(ht number o# arra% bracets and the variable ' tells us ho" man% 0x1dQs
"e there.

!e no" call the method Det:lementT%pe to (et the t%pe stored a#ter the last 0x1d. This is "h%
"e add the value o# ' to the index variable. The b%tes to be returned are the number o# b%tes taen
up b% the t%pe itsel# and variable '$ "hich as "e told %ou earlier (ives us the number o# 0x1d or
the arra% dimensions.

4ro(ram26.csc
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe AA 0x14 8
9
int ho"man%b%tes2<
returnstrin( A Det*rra%T%pe5 blobarra% $ index $ out ho"man%b%tes28<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
return returnstrin(<
@

public strin( Det*rra%T%pe 5b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
9
strin( returnstrin( <
int total A 1<
int uncompressedb%te<
int ran<
int numsi&es<
int ho"man%b%tes1<
returnstrin( A Det:lementT%pe5index C1 $ blobarra% $ out ho"man%b%tes8<
total A total C ho"man%b%tes<
244260235.doc 194 od 541
returnstrin( A returnstrin( C F6F<
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
ran A uncompressedb%te<
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
numsi&es A uncompressedb%te<
int 67 si&earra% A ne" int6numsi&es7<
#or 5 int l A 1 < l BA numsi&es < lCC8
9
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
si&earra%6lP17 A uncompressedb%te<
@
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
int bounds A uncompressedb%te<
int 67 boundsarra% A ne" int6bounds7<
II+onsole.!rite3ine5F.....ranA90@ numsi&esA91@ boundsA92@ F $ ran$ numsi&es$bounds8<
i# 5 ran EA 0 GG bounds AA 0 GG numsi&es AA 08
9
#or 5 int i A 1 < i B ran < iCC8
returnstrin( A returnstrin( C F$F<
returnstrin( A returnstrin( C F7F<
return returnstrin(<
@
int dots A 0<
#or 5 int l A 1 < l BA bounds < lCC8
9
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
int ul;i(ned A uncompressedb%te G 0x1<
uncompressedb%te A uncompressedb%te HH 1<
boundsarra%6lP17 A uncompressedb%te <
@
i# 5 numsi&es AA 08
9
#or 5 int l A 0 < l B bounds < lCC8
9
returnstrin( A returnstrin( C boundsarra%6l7 C F...F <
i# 5 l EA 5boundsP18 8
returnstrin( A returnstrin( C F$F<
@
@
else
9
#or 5 int l A 0 < l B bounds < lCC8
9
i# 5 l B numsi&es 8
9
int upper A boundsarra%6l7 C si&earra%6l7 P 1 <
244260235.doc 195 od 541
i# 5 boundsarra%6l7 AA 0 GG si&earra%6l7 EA 0 8
returnstrin( A returnstrin( C si&earra%6l7 <
i# 5boundsarra%6l7 AA 0 GG si&earra%6l7 AA 08
returnstrin( A returnstrin( C F0F <
else i# 5boundsarra%6l7 EA 0 GG si&earra%6l7 EA 08
returnstrin( A returnstrin( C boundsarra%6l7 C F...F C upper.To;trin(58 <
else i# 5boundsarra%6l7 EA 0 GG si&earra%6l7 AA 08
returnstrin( A returnstrin( C boundsarra%6l7 C F...F <

@
else
9
dotsCC<
returnstrin( A returnstrin( C boundsarra%6l7 C F...F <
@
i# 5 l EA bounds P 1 8
returnstrin( A returnstrin( C F$F<
@
@
i# 5 numsi&es EA 08 II method a6
9
int le#tover A ran P numsi&es P dots <
#or 5 int l A 1 < l BA le#tover < lCC8
returnstrin( A returnstrin( C F$F<
@
returnstrin( A returnstrin( C F7F<
ho"man%b%tes A totalP1<
return returnstrin(<
@

e.il
.class a1
9
.method int8 647 a158
9
@
.method int16 657 a258
9
@
.method int32 65$7$127 a358
9
@
.method int32 67$$$7 a458
9
@
.method int32 60...3$ 3...8 $ 10...147 a558
9
@
.method int32 63...7 a658
9
@
244260235.doc 196 od 541
.method int32 66...9$1$137 a758
9
@
.method int32 6$$$7 a858
9
@
.method int32 66$$137 a958
9
@
.method int32 6$ 3...8 $ 4... $ 8...7 a1058
9
@
.method int32 6$ 3...8 $ 4... $ $ 8... $$$7 a1158
9
@
.method int32 6$ $ 4... $ $ 8...7 a1258
9
@
.method int32 6$$6...9$1$137 a1358
9
@
.method int32 68... $ 4 $ 57 a1458
9
@
@

/utput
.method IJ06000001JI int8647
.method IJ06000002JI int16657
.method IJ06000003JI int3265$7$127
.method IJ06000004JI int3267$$$7
.method IJ06000005JI int3264$3...8$10...147
.method IJ06000006JI int3263...7
.method IJ06000007JI int3266...9$1$137
.method IJ06000008JI int326$$$7
.method IJ06000009JI int3266$0$137
.method IJ0600000*JI int3260$3...8$4...$8...7
.method IJ0600000OJI int3260$3...8$4...$0...$8...$$$7
.method IJ0600000+JI int3260...$0...$4...$0...$8...7
.method IJ0600000=JI int3260$0$6...9$1$137
.method IJ0600000:JI int3268...$4$57

'n this example "e deal "ith ho" the arra% data t%pe is handled. This is di##erent #rom the earlier
"here "e did not speci#% a dimension alon( "ith the arra%. *ll that "e have done is add a i#
statement that checs #or t%pe 0x14 that represents a arra%.

!e then call a method Det*rra%T%pe that understands arra%s. 3ets #irst loo at the method a1 that
has the simplest arra% int8 647. !e "ill be extremel% practical as the arra%s can be a pain in the
nec. Thus each time "e "ill see the si(nature also. 'n this case it is 14 04 01 and this is onl% part
o# the si(nature$ the part "e are tr%in( to explain to %ou.

244260235.doc 197 od 541
* arra% si(nature starts "ith the number 0x14 and then #ollo"s the data t%pe o# the arra%. *
number o# 4 stands #or int8. Thus the #irst thin( "e do in our Det*rra%T%pe #unction is call the
Det:lementT%pe method passin( indexC1 as index points to the arra% t%pe 0x14.

This is ho" "e #i(ure out the data t%pe o# the arra% and "e increase the variable total b%
ho"man%b%tes as the arra% data t%pe can be as complex as "e please. The second #unction a2 has
the t%pe int16 657 and its si(nature is 14 06 01 as the data t%pe #or a int16 is 06. The b%te
#ollo"in( the data t%pe is called the ran.

This speci#ies the number o# dimensions "hich has to be 1 or more. !e use the method
+or;i(Nncompress=ata to pic it up #or us as it ma% be lar(er than 127. 3ooin( at the method
a3 "hose arra% t%pe is int1665$7$127 and si(nature is 14 06 03. The ran here is 3 as "e have
three dimensions in the arra%.

This is di##erent #rom a double dimensional arra% "hich ahs multiple 67. !e "ill consider them
later. The ran is stored in our pro(ram in a variable called ran and the returnstrin( variable "ill
contain our actual arra% si(nature that "e return and each time "e increase total b% the return
value o# the +or;i(Nncompress=ata method.

*#ter the ran is the number o# si&es member. This (ives us the number o# dimensions that have a
si&e. 3ets start "ith method a8$ its t%pe is int326$$$7 and its si(nature is 14 08 04 00. The numsi&es
is &ero as no dimension has an% si&e at all. '# "e tae method a9$ t%pe int32 66$$137$ si(nature 14
08 03 03.

The numsi&es is 3 and not 2 as the dimension that has no si&e is in the middle. 0ethod a4 t%pe
int3267$$$7 si(nature 14 08 04 01 sa%s it better. The numsi&es is 1 as onl% one dimension has a
value and it is the #irst. Thus the numsi&es is the number o# dimensions that do not have a value$
but countin( #rom the last one that has no value.

The next series o# b%tes tell us the si&e o# each dimension. '# the numsi&es #ield is 3$ the next
three b%tes tell us the si&e o# each dimension. 3ets loo at method a11$ t%pe int32 6$ 3...8 $ 4... $ $
8... $$$7 and si(nature 14 08 08 02 00 06. *s the numsi&es is onl% 2$ the next t"o b%tes tell us the
si&e o# each dimension.

The ran ho"ever is 8. The #irst dimension is empt% and hence it is a &ero. The second dimension
starts at 3 and end at 8. Thus its si&e is 6 as "e count both 3 and 6. The ones that have a upper
unde#ined limit lie 3X have no si&e as "e have not speci#ied a upper bound.

Tae another example$ method a7 t%pe int3266...9$1$137si(nature 14 08 03 03 04 01 0=. !e have
3 si&es$ the #irst is #rom 6 to 9 and hence 4. The second is a 1 and the third 13. !e do not no" in
advance ho" man% si&es "e have an hence "e create an arra% si&earra% that is numsi&es lar(e.

'n a #or loop "e read each b%te and store it into the arra% si&earra%. !e also increase total b% the
number o# b%tes each dimension taes up. !e no" handle a special case "here "e have a ran
"hich is a must but no numsi&es or bounds. This means that the arra% has no dimension that has a
si&e and also no dimension that has a lo"er bound.

This could onl% happen in case o# method a8 t%pe int326$$$7 si(nature 14 08 04 00 00. 2ere "e
have a ran o# 4 and the next t"o numbers 0. "e loop dependin( upon the number o# dimensions
and eep addin( a comma and then return the strin(. * special case and no" lets move to the last
#ield.
244260235.doc 198 od 541

!hen "e leave the loop "e are at the next #ield that tells us ho" man% dimensions have a lo"er
bound as the upper bound is optional. '# "e loo at method a7 t%pe int3266...9$1$137 b%tes 14 08
03 03 04 01 0= 03 0+ 00 00. !e have to move to the 8th b%te that is a three. The have three
lo"er bounds and the last t"o are &ero as the% are a sin(le bound.

/nl% the three dots come into the picture here. The lo"er bound is 3 but "e see the value 0x0c.
!h% the discrepanc%. This is because the lo"er bound is stored in a compressed #orm. 2ere is
ho" it "ors. !e #irst tae the lo"er bound and bit "ise and "ith a one to chec "hether the #irst
bit is on or not. '# it is on or set$ then the b%te is compressed. 'n all our cases$ there is no
compression on the b%te at all.

Thus the #irst bit is not used to store the lo"er bound and is al"a%s &ero. !e then ri(ht shi#t the
b%tes b% 1. Thus 12 becomes 6 as b% ri(ht shi#tin( "e are dividin( b% 2. >inall% lets tae method
a5$ t%pe int3264$3...8$10...147$ si(nature 20 00 14 08 03 03 04 06 05 03 00 06 14.

!e tae the #ourth last number "hich tells is that "e have three upper bounds. The #irst
dimension is not a ran(e and hence its value is 0$ the second is 6$ "e divide b% 3 and "e (et 3 the
lo"er bound and the last is 20 divided b% 2 is 10.

>inall% method a11 sums it up$ t%pe int3260$3...8$4...$0...$8...$$$7$ si(nature 14 08 08 02 00 06 05 00
06 08 00 10. !e start at the be(innin( as the si(nature is complex and "e see a arra% t%pe 0x14.
The #irst 08 is the data t%pe #or in32 and the second 8 is the number o# rans as "e have 8
dimensions. +ount i# %ou do not believe us.

Then "e have 2 si&es as onl% the second has a si&e and the #irst "ho si&e is 0 (ets in because o#
the second. Then "e have t"o b%tes #or the si&e o# the dimensions$ 0 and 6. This is #ollo"ed b%
the number o# lo"er bounds "hich are 5.

The #irst has no lo"er bound as it is a actual value and the second and third have a lo"er bound
o# 3 and 4 that sho" as double 6 and 8. The next has a lo"er bound o# 0 and hence its &ero and
this is #ollo"ed b% a lo"er bound o# 8 that doubles to 16 or 0x10.

The last three dimensions have no values and hence to save on si(nature space b% not speci#%in(
a endless number o# &eroes the% are i(nored. This causes trouble #or us as "e no" have to
account #or all this optimi&ations in our code. !e store the uncompressed value o# the lo"er
bound in an arra% boundsarra% lie "e did #or the si&es.

)o" is the time #or actuall% creatin( the arra% si(nature. >or the moment "e have simpl% #illed
up t"o arra%s. 3ets loo at #unction a12 t%pe int32 6$ $ 4... $ $ 8...7 $ ildasm sho"s us
int3260...$0...$4...$0...$8...7 si(nature 14 08 05 00 05 00 00 08 00 10.

*s none o# the dimension has a si&e as the% are either empt% or do not have a upper bound$ the
numsi&es #ield is &ero and hence the #irst i# statement (ets called. Thus "e start "ith a #or loop
and simpl% tae "hat is there in the boundsarra% and add a X to it.

The bounds and ran members "ill be the same and i# the dimension is 0 or empt%$ a &ero (ets
displa%ed instead. *t the end i# it is the last dimension$ "e do not place the comma and the i#
statement handles it. )o" lets move on to the else statement that has some complex code.

244260235.doc 199 od 541
3ie in the i#$ in the else "e also iterate in the #or loop usin( the number o# bounds as the index
variable. !e do this as the ran is the theoretical number o# dimensions. The bounds are those
that have a lo"er dimension "hich is a must. The di##erence bet"een ran and bounds are the last
empt% dimensions.

'# there are no empt% dimensions both ran and bounds "ill be the same value. The numsi&es
have no si(ni#icance. !e have a i# statement as the si&earra% arra% "ill be less than the bounds
arra% as ever% dimension does not have a si&e. This happens #or t"o reasons$ it is empt% or the
upper bound is not speci#ied.

2o"ever as speci#ied be#ore$ the empt% ones #all into the purvie" o# the numsi&es i# the% are
be#ore a si&ed dimension. Thus the i# statement maes sure that "e are not accessin( a si&earra%
member that does not exist.

!hen the i# statement is #alse it could mean that all the valid si&es are over and the dimensions
#ollo"in( are either empt% or have no upper dimension value. This happens "ith method a11$
t%pe int32 6$ 3...8 $ 4... $ $ 8... $$$7 si(nature 14 08 08 02 00 06 05 00 06 08 00 10 and actual ans"er
is int3260$3...8$4...$0...$8...$$$7.

2ere the ran is 8$ numsi&es is 02 and the number o# bounds is 05. Thus #or values o# l #rom 2$3
and 4$ the else (ets called. >or these dimensions "e have no upper bounds at all and the third
empt% dimension also (ets displa%ed "ith a ran(e startin( "ith 0.

!e also increase the variable dots b% one that "ill tell us ho" man% times the else (ets called.
These remember are at the end o# all the dimensions that have si&es. The '# the i# statement is true
"hich means "e have a si&e as "ell as lo"er bound$ the upper variable stores #or us the upper
bound.

This is calculated as the lo"er bound plus the si&e minus 1 (ives us the upper bound. !e no"
need to #i(ure out "hether "e place the three dots or is it is sin(le dimension. This is achieved b%
the next series o# three i# statements. 3ets tae a method a13 t%pe int32 6$$6...9$1$137 si(nature 14
08 05 05 00 00 04 01 0= 05 00 00 0+ 00 00.

The ran$ numsi&es and bounds are all 5. '# the lo"er bound is &ero and the si&e is non &ero$ this
is a sin(le dimension value. Thus the i# statement (ets called #or the last t"o dimensions "here
the si&e arra% has values 1 and 13. These are si&es that do not have a ran(e and hence the lo"er
bound is &ero.

'# there is a sin(le value this is stored in the si&earra%. !e also chec "hether the comma needs to
be placed at the end. !e then chec i# both the bounds and si&e arra% are &ero. This can happen in
the #irst t"o dimensions and "e need to place a 0.

>inall% "e chec "hether both the si&e and bounds are non &ero "hich means that it is a ran(e
lie the middle case and here "e place the X. !e should place the comma onl% i# it is not at the
end and that explains the #inal i# statement. !e #inall% need to place the #inal empt% commas i#
an%.

!e #irst need to #ind out i# there "e an% empt% dimensions at the ver% end. This "e do b%
subtractin( ran #orm the number o# si&es. !e also need to subtract dots as this variable contains
the number o# ran(e dimensions at the end that do not have a upper bound. 'n this #or loop "e
onl% #ill up the returnstrin( b% a certain number o# commas.
244260235.doc 200 od 541

!e place this code "ithin a i# statement #or a method lie a6 that have a ran o# 1$ numsi&es o# 0
not to activate this code. !e #inall% come to method a14 that has the t%pe int32 68... $ 4 $ 57$
si(nature 14 08 03 03 00 04 05 03 10 00 00 and the ans"er b% ildasm is int3268...7$4$57.

Thus "e (et the ri(ht ans"er and ildasm the "ron( one and %es "e are (loatin(. This is because
"e have one more i# statement that checs "hether the si&e arra% is &ero "hich is in this case and
the bounds arra% is not &ero "hich means that "e have a ran(e dimension "ith no upper bound.

>inall% "e have to as ourselves can our code handle double dimension arra%s lie int32657647.
The si(nature #or the above "ill be prett% lar(e as 14 14 08 01 01 05 01 00 01 01 04 01 00. The
#irst 14 is the arra% t%pe and the data t%pe #or the arra% is another arra%.

!e read this arra% usin( the Det:lementT%pe method and it is #ollo"ed b% the 8 "hich speci#ies a
int32. The ran and number o# si&es are 1 and the 5 is the arra% si&e. Thus the #irst arra% is the
inner one and the arra% dimension 4 is the outer arra%.

4ro(ram27.csc.txt
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
>ill*rra%58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
+reate;i(natures58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
=ispal%-t>ixup58<
=ispla%T%pe=e#s58<
=ispla%T%pe=e#s*nd0ethods58<
@
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe AA 0x12 8
9
int ho"man%b%tes2<
244260235.doc 201 od 541
returnstrin( A DetToenT%pe5 blobarra% $ index $ out ho"man%b%tes28<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
public strin( DetToenT%pe 5 b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int uncompressedb%te<
int ho"man%b%tes1 A 0<
ho"man%b%tes1A ho"man%b%tes1 C +or;i(Nncompress=ata 5blobarra% $ index C 1 $ out
uncompressedb%te8<
strin( dumm%1 A =ecodeToen5uncompressedb%te $ blobarra%6index78<
returnstrin( A Fclass F C dumm%1<
ho"man%b%tes A ho"man%b%tes1<
return returnstrin(<
@
public strin( =ecodeToen 5int toen $ int t%pe8
9
b%te tablet%pe A 5b%te85toen G 0x038<
int tableindex A toen HH 2<
strin( returnstrin( A FF<
i# 5 tablet%pe AA 08
returnstrin( A t%pede#names6tableindex7<
return returnstrin(<
@

strin( 67 t%pede#names<
public void >ill*rra% 58
9
int old A tableo##set<
bool tablehasro"s A tablepresent528<
int o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
t%pede#names A ne" strin(6ro"s627C17<
#or 5 int A 1 < BA ro"s627 < CC8
9
int name A T%pe=e#;truct67.name<
o##s CA o##setstrin(<
int nspace A T%pe=e#;truct67.nspace<
o##s CA o##setstrin(<
strin( nestedt%pestrin( A FF<
nestedt%pestrin( A Det)estedT%pe*s;trin(58<
strin( namestrin( A Det;trin(5name8<
strin( namespacestrin( A )ame,eserved5Det;trin(5nspace88<
i# 5 namespacestrin(.3en(th EA 08
namespacestrin( A namespacestrin( C F.F<
namestrin( A )ame,eserved5namestrin( 8<
t%pede#names67 A nestedt%pestrin( C namespacestrin( C namestrin( C FIJ 02F C
.To;trin(5FK6F8 C F JIF<
@
244260235.doc 202 od 541
@
@

e.il
.class %%%
9
@
.class &&&
9
.method class &&& a158
9
@
.method class %%% a258
9
@
@

/utput
.class IJ02000002JI private auto ansi %%%
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class %%%

.class IJ02000003JI private auto ansi &&&
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.method IJ06000001JI class &&&IJ 02000003 JI
.method IJ06000002JI class %%%IJ 02000002 JI
@ II end o# class &&&

'n this pro(ram "e sho" %ou ho" to "or "ith return values that are a instance o# a t%pe that "e
create ourselves in our code. '# %ou tae a close loo at the il #ile$ method a1 returns a prede#ined
t%pe &&& and method a2 returns a t%pe %%%. '# "e loo at the si(natures$ both start "ith a value
0x12 and then some number that "e "ill explain soon.

'# %ou loo closel% at the abc #unction "e have called a ne" method >ill*rra%. This is the last
method "e "ill add in the abc #unction and "e "ill explain this method ver% soon. 'n the
Det:lementT%pe method "e have simpl% added a i# statement that chec #or the t%pe bein( 0x12.

'# it is$ "e call a #unction called DetToenT%pe to #i(ure out the t%pe #or us "hich "e simple
return. The DetToenT%pe method taes a out parameter that tells us ho" man% b%tes the
numbers that represent the t%pe tae up. !e add one to this value to account #or the 0x12 data
t%pe.

!hat "e are sa%in( is that the minute "e #ind a 0x12$ this si(ni#ies some t%pe. The method
DetToenT%pe is passed the blob arra% as "ell as the index in the arra% o# the 0x12. !e #irst call
the +or;i(Nncompress=ata method "hich si(ni#ies that the b%tes #ollo"in( ma% be compressed.

!e then pass this uncompressed b%te that in our case is a sin(le b%te as the value o#
ho"man%b%tes1 "ill con#irm. !e pass this b%te to the method =ecodeToen and also the value
244260235.doc 203 od 541
0x12 that is the start o# the t%pe si(nature. The return strin( "e simpl% add the "ord class and
return it.

The number o# b%tes taen up is simpl% the return value o# the +or;i(Nncompress=ata #unction.
Thus all the action no" moves to the method =ecodeToen. *#ter the b%te 0x12 is stored "hat
the specs call a toen. * toen is a e##icient "a% o# storin( a table and ro" number to(ether.

Thus the #irst t"o bits are the table number and the remainin( the ro" number. !e thus bit "ise
and "ith 0x3 to extract the table number and ri(ht shi#t b% 2 to (et the ro" number. '# the
tablet%pe is 0$ the toen ro"s point to the t%pe de# table. Thus the value o# 0xc denotes table 0
and b% dividin( b% 4$ "e (et a value o# 3.

The class &&& has a ro" number o# 3. The second toen value "as 8$ divided b% 4 (ives us 2 and
class %%% is ro" 2 in the t%pe de# table.

*s "e simpl% have to read the name and namespace #rom the t%pe de# table "h% can "e not
create a arra% t%pede#names that simpl% store the name o# the t%pe as a strin( and "e simpl% read
the t%pe name b% usin( the appropriate index into the arra%. This "hat the >ill*rra% method does.

!e start "ith de#inin( a instance arra% o# strin(s t%pede#names. !e then use the same old$
tableo##set variables to position us on the startin( point o# the t%pe de# table "hich is no"n as
number 2.

!e "ill have at least one ro" and "e create an arra% t%pede#names that is one lar(er then the
number o# ro"s$ bearin( in mind the (lobal t%pe that (ets automaticall% created. !e no" iterate
in a #or loop dependin( upon the number o# ro"s "e have. !e store the name and namespace
#ields #or later use to (et at the name and namespace names as strin(s.

!e have to concatenate the name and namespace names and place a dot bet"een them i# and onl%
i# there exists a non null namespace name. This "e chec b% addin( a dot to the namespace name
onl% it has a valid len(th. !e could have used the )ame,eserved #unction a#ter the Det;trin(
#unction but chose to brea it up on t"o lines.

* t%pe ma% also be nested as hence "e use our trusted method Det)estedT%pe*s;trin( passin( it
the t%pe so that it returns the names o# the nested t%pes this t%pe #alls in. 4ro(ram17 is "here "e
#irst introduced this method.

!e no" #ill up the t%pede#names arra% b% #irst startin( "ith the nested t%pe$ then the
namespacename "ith or "ithout the dot$ #ollo"ed b% the name o# the t%pe and its number in
comments.

4ro(ram28.csc.txt
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe AA 0x12 TT t%pe AA 0x11 8
9
int ho"man%b%tes2<
returnstrin( A DetToenT%pe5 blobarra% $ index $ out ho"man%b%tes28<
244260235.doc 204 od 541
ho"man%b%tes A ho"man%b%tes2 C 1<
@
return returnstrin(<
@
public strin( DetToenT%pe 5 b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int uncompressedb%te<
int ho"man%b%tes1 A 0<
ho"man%b%tes1 A ho"man%b%tes1 C +or;i(Nncompress=ata5blobarra% $ index C 1 $ out
uncompressedb%te8<
strin( dumm%1 A =ecodeToen5uncompressedb%te $ blobarra%6index78<
i# 5 blobarra%6index7 AA 0x128
returnstrin( A Fclass F C dumm%1<
else i# 5 blobarra%6index7 AA 0x118
returnstrin( A Fvaluet%pe F C dumm%1<
ho"man%b%tes A ho"man%b%tes1<
return returnstrin(<
@

e.il
.class %%%
9
@
.class &&&
9
.method valuet%pe &&& a158
9
@
.method valuet%pe %%% a258
9
@
@

/utput
.class IJ02000002JI private auto ansi %%%
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
@ II end o# class %%%

.class IJ02000003JI private auto ansi &&&
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.method IJ06000001JI valuet%pe &&&IJ 02000003 JI
.method IJ06000002JI valuet%pe %%%IJ 02000002 JI
@ II end o# class &&&

This example is a sli(ht variation o# the earlier one. 'n the il #ile$ instead o# usin( the "ord class
"e use the "ord valuet%pe. There are t"o basic data t%pes in the il "orld. Those that are created
on the stac and are simple are called value t%pes. The others are represented b% the "ord class.

244260235.doc 205 od 541
* class denotes a ob1ect "hose actual value is not passed but a re#erence. Thus each time "e "ant
to access a classIob1ect "e have to dePre#erence the value "hich is pointed at b% the re#erence. *
value t%pe instead stores the actual value and hence is #aster. * value t%pe ob1ect is extended #rom
the -alueT%pe class.

These data t%pes are simpler and #aster to access and there is chec to mae sure that the data
t%pe is derived #rom the -alueT%pe class. There is onl% one "a% to create a data t%pe and that is
usin( the class directive. 'n the Det:lementT%pe method "e simpl% add the chec #or a t%pe
0x11.

Thus both the class and value t%pe are #ollo"ed b% a t%pe toen. 'n the class DetToenT%pe "e
use a i# statement to #i(ure out "hether "e add the "ords class or valuet%pe. This is "h% "e pass
the #irst b%te or t%pe b%te to this #unction.

4ro(ram29.csc
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe AA 0x108
returnstrin( A DetO%re#Toen5index$ blobarra% $ out ho"man%b%tes8<
return returnstrin(<
@
public strin( DetO%re#Toen 5int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int ho"man%b%tes2<
returnstrin( A Det:lementT%pe 5indexC1 $ blobarra% $ out ho"man%b%tes28 C FGF<
ho"man%b%tes A ho"man%b%tes2 C 1<
return returnstrin(<
@

e.il
.class &&&
9
.method int32 G a158
9
@
.method class &&& G a258
9
@
.method int32 612763$57 G a358
9
@
@

/utput
.method IJ06000001JI int32G
.method IJ06000002JI class &&&IJ 02000002 JIG
.method IJ06000003JI int32612763$57G
244260235.doc 206 od 541

'# %ou loo at il #ile "e have a G #ollo"in( the data t%pe. This maes the data t%pe a unmana(ed
pointer. !e "ill stud% the di##erence bet"een mana(ed and unmana(ed pointers in (reater detail
later. *ll that "e "ould lie to sa% is that all pro(rammers i# the% do not "or "ith pointers need
to (o bac to school.

The onl% di##erence "e see b% addin( a G is that the #irst t%pe b%te is 0x10. Then "e have the
same t%pe si(nature as "e have "ored "ith be#ore. 'n method a3$ an arra% #ollo"s and thus "e
have a 0x14 #ollo"in( the 0x10. 'n the Det:lementT%pe method "e call the method
DetO%re#Toen "hich does the (runt "or.

!e #irst call the Det:lementT%pe method to #i(ure out the t%pe #or us and then return the same
t%pe #ollo"ed b% a G. !e also initiali&e the ho"man%b%tes variable to one lar(er than the value
set b% the Det:lementT%pe method as in the Det:lementT%pe method "e do not increase it b%
one eepin( the extra 0x10 in mind.

:ver%thin( else remains the same and %ou can no" see ho" "e use recursion to call the same
code over and over a(ain.

4ro(ram30.csc.txt
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
b%te t%pe A blobarra%6index7<
i# 5 t%pe AA 0x0#8
returnstrin( A Det4ointerToen5index$ blobarra% $ out ho"man%b%tes8<
return returnstrin(<
@

public strin( Det4ointerToen5int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int ho"man%b%tes2<
returnstrin( A Det:lementT%pe5indexC1 $ blobarra% $ out ho"man%b%tes28 C FJF<
ho"man%b%tes A ho"man%b%tes2 C 1<
return returnstrin(<
@

e.il
.class &&&
9
.method int32 JJJ a158
9
@
.method class &&& JJJJJJ a258
9
@
.method int32 612763$57 J a358
9
@
244260235.doc 207 od 541
@

/utput
.method IJ06000001JI int32JJJ
.method IJ06000002JI class &&&IJ 02000002 JIJJJJJJ
.method IJ06000003JI int32612763$57J

'n the above il #ile "e have added a unmana(ed pointer J lie "e added a mana(ed pointer G in
the earlier example. There is not much chan(e in #rom the earlier pro(ram.

The onl% di##erence is that the unmana(ed pointer has a t%pe o# 0x0# and in the il #ile "e have
sho"n ho" recursion reall% "ors b% addin( as man% stars as "e could and %et demonstrate that
the pro(ram "ors. Thus the short explanation.

4ro(ram31.csc
public strin( =ecodeToen 5int toen $ int t%pe8
9
b%te tablet%pe A 5b%te85toen G 0x038<
int tableindex A toen HH 2<
strin( returnstrin( A FF<
i# 5 tablet%pe AA 08
returnstrin( A t%pede#names6tableindex7<
i# 5 tablet%pe AA 1 8
returnstrin( A t%pere#names6tableindex7 <
return returnstrin(<
@
public strin( DetTable,e#)ame>or>ill*rra%5 int tablero" $ int t%pero" $ strin( tablename8
9
strin( nameandnamespace A FF<
i# 5 tablename AA F*ssembl%,e#F8
nameandnamespace A )ame,eserved5Det;trin(5*ssembl%,e#;truct6tablero"7.name88 <
i# 5 tablename AA F0odule,e#F8
nameandnamespace A F.module F C
)ame,eserved5Det;trin(50odule,e#;truct6tablero"7.name88 <
strin( strin(namespace A )ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.nspace88 <
strin( strin(nested A FF<
i# 5 strin(namespace EA FF8
strin(namespace A strin(namespace C F.F<
i# 5 tablename AA F*ssembl%,e#F8
strin(nested A F6F C nameandnamespace C FIJ 23F C tablero".To;trin(5FK6F8 C F JI7F C
strin(namespace C )ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.name88<
i# 5 tablename AA F0odule,e#F8
strin(nested A F6F C nameandnamespace C FIJ 1*F C tablero".To;trin(5FK6F8 C F JI7F C
strin(namespace C )ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.name88<
i# 5 tablename AA F0oduleF8
strin(nested A strin(nested C strin(namespace C
)ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.name88<
strin(nested A strin(nested C FIJ 01F C t%pero".To;trin(5FK6F8 C F JIIF <
return strin(nested<
@
public strin( DetT%pe,e#>or>illarra%5int 8
244260235.doc 208 od 541
9
strin( strin(namespace A )ame,eserved5Det;trin(5T%pe,e#;truct67.nspace88 <
i# 5 strin(namespace EA FF8
strin(namespaceA strin(namespace C F.F<
strin( strin(nested A strin(namespace C )ame,eserved5Det;trin(5T%pe,e#;truct67.name88 <
strin(nested A strin(nested C FIJ 01F C .To;trin(5FK6F8 C F JIF <
return strin(nested<
@
strin( 67 t%pere#names<
strin( 67 t%pede#names<
public void >ill*rra% 58
9
int old A tableo##set<
bool tablehasro"s A tablepresent518<
int o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
t%pere#names A ne" strin(6ro"s617C17<
#or 5 int A 1 < BA ro"s617 < CC8
9
short resolutionscope A Oit+onverter.To'nt16 5metadata $ o##s8<
o##s A o##s C 2<
int name A ,ead;trin('ndex5metadata $ o##s8<
o##s A o##s C o##setstrin(<
int nspace A ,ead;trin('ndex5metadata $ o##s8<
o##s A o##s C o##setstrin(<
strin( strin(name A )ame,eserved5Det;trin(5name88<
strin( strin(t%pe#minusnested A Det;trin(5nspace8 <
i# 5 strin(t%pe#minusnested .3en(th EA 08
strin(t%pe#minusnested A strin(t%pe#minusnested C F.F<
strin(t%pe#minusnested A strin(t%pe#minusnested C strin(name<
strin( strin(nested A FF<
strin( resolutioncodedtable A Det,esolution;copeTable5resolutionscope 8<
int resolutionro" A Det,esolution;cope-alue5resolutionscope 8<
i# 5 resolutioncodedtable AA F0oduleF8
9
strin(t%pe#minusnested A strin(t%pe#minusnested C FIJ 01F C .To;trin(5FK6F8 C F JIF<
@
i# 5 resolutioncodedtable AA F*ssembl%,e#F8
9
strin(nested A F6F C )ame,eserved5Det;trin(5*ssembl%,e#;truct6resolutionro"7.name88 C FIJ
23F C resolutionro".To;trin(5FK6F8 C F JI7F<
strin(t%pe#minusnested A strin(t%pe#minusnested C FIJ 01F C .To;trin(5FK6F8 C F JIF<
@
i# 5 resolutioncodedtable AA F0odule,e#F8
9
strin(nested A F6.module F C )ame,eserved5Det;trin(50odule,e#;truct6resolutionro"7.name88
C FIJ 1*F C resolutionro".To;trin(5Fx6F8 C F JI7F<
strin(t%pe#minusnested A strin(t%pe#minusnested C FIJ 01F C .To;trin(5FK6F8 C F JIF<
@
244260235.doc 209 od 541
i# 5 resolutioncodedtable AA FT%pe,e#F 8
9
strin( resolutioncodedtable1 A
Det,esolution;copeTable5T%pe,e#;truct6resolutionro"7.resolutionscope 8<
int resolutionro"1 A Det,esolution;cope-alue5T%pe,e#;truct6resolutionro"7.resolutionscope 8<
i# 5 resolutioncodedtable1 AA F*ssembl%,e#F TT resolutioncodedtable1 AA F0odule,e#F TT
resolutioncodedtable1 AA F0oduleF8
9
strin(nested A DetTable,e#)ame>or>ill*rra%5resolutionro"1 $ resolutionro" $
resolutioncodedtable18<
strin(nested A strin(nested C DetT%pe,e#>or>illarra%58<
strin(t%pe#minusnested A FF<
@
else
9
strin( tablename A Det,esolution;copeTable5T%pe,e#;truct67.resolutionscope 8<
int ro" A Det,esolution;cope-alue5T%pe,e#;truct67.resolutionscope 8<
int cnt A 0<
"hile 5 tablename AA FT%pe,e#F8
9
ro" A Det,esolution;cope-alue5T%pe,e#;truct6ro"7.resolutionscope 8<
tablename A Det,esolution;copeTable5T%pe,e#;truct6ro"7.resolutionscope 8<
cntCC<
@
int i A 0<
int 67 t%pero"s A ne" int6cnt7<
strin( tablename1 A Det,esolution;copeTable5T%pe,e#;truct67.resolutionscope 8<
int ro"1 A Det,esolution;cope-alue5T%pe,e#;truct67.resolutionscope 8<
"hile 5 i B cnt 8
9
ro"1 A Det,esolution;cope-alue5T%pe,e#;truct6ro"17.resolutionscope 8<
tablename1 A Det,esolution;copeTable5T%pe,e#;truct6ro"17.resolutionscope 8<
t%pero"s6i7 A ro"1<
iCC<
@

int assembl%ro" A Det,esolution;cope-alue5T%pe,e#;truct6ro"7.resolutionscope 8<
int t%pero" A t%pero"s6t%pero"s.3en(thP17<
strin(nested A DetTable,e#)ame>or>ill*rra%5 assembl%ro" $ t%pero" $ tablename8<

i A 0<
strin( dumm% A FF<
"hile 5 i B cntP1 8
9
dumm% A DetT%pe,e#>or>illarra%5t%pero"s6i78 C FIF C dumm%<
iCC<
@
strin(nested A strin(nested C dumm%<
strin(nested A strin(nested C DetT%pe,e#>or>illarra%5resolutionro"8<
strin(nested A strin(nested C FIF C DetT%pe,e#>or>illarra%58<
strin(t%pe#minusnested A FF<
244260235.doc 210 od 541
@
@
t%pere#names67 A strin(nested C strin(t%pe#minusnested <
II+onsole.!rite3ine5F.......90@ 91@ 92@F $ resolutioncodedtable $ t%pere#names67 $ 8<
@
@
old A tableo##set<
tablehasro"s A tablepresent528<
o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
t%pede#names A ne" strin(6ro"s627C17<
#or 5 int A 1 < BA ro"s627 < CC8
9
int name A T%pe=e#;truct67.name<
o##s CA o##setstrin(<
int nspace A T%pe=e#;truct67.nspace<
o##s CA o##setstrin(<
strin( nestedt%pestrin( A FF<
nestedt%pestrin( A Det)estedT%pe*s;trin(58<
strin( namestrin( A Det;trin(5name8<
strin( namespacestrin( A )ame,eserved5Det;trin(5nspace88<
i# 5 namespacestrin(.3en(th EA 08
namespacestrin( A namespacestrin( C F.F<
namestrin( A )ame,eserved5namestrin( 8<
t%pede#names67 A nestedt%pestrin( C namespacestrin( C namestrin( C FIJ 02F C
.To;trin(5FK6F8 C F JIF<
@
@
@

e.il
.assembl% extern vi1a%
9
@
.module extern bbb
.module ccc
.class &&&
9
.method class 6vi1a%7&1 a158
9
@
.method class 6.module bbb7&2 a258
9
@
.method class 6.module ccc7&3 a358
9
@
.method class 6vi1a%7&4I&5 a4158
9
244260235.doc 211 od 541
@
.method class 6vi1a%7&4I&5I&6 a558
9
@
.method class 6vi1a%7&4I&5I&6I&7 a658
9
@
.method class 6vi1a%7&4I&5I&6I&7I&8I&9I&10I&11 a7158
9
@
.method class 6.module bbb7&4I&5I&6I&7I&8I&9I&10I&11 a7258
9
@
.method class 6.module ccc7&4I&5I&6I&7I&8I&9I&10I&11 a7358
9
@
@

/utput
.method IJ06000001JI class 6vi1a%IJ 23000001 JI7&1IJ 01000002 JI
.method IJ06000002JI class 6.module bbbIJ 1*000001 JI7&2IJ 01000003 JI
.method IJ06000003JI class &3IJ 01000004 JI
.method IJ06000004JI class 6vi1a%IJ 23000001 JI7&4IJ 01000005 JII&5IJ 01000006 JI
.method IJ06000005JI class 6vi1a%IJ 23000001 JI7&4IJ 01000005 JII&5IJ 01000006 JII&6IJ
01000007 JI
.method IJ06000006JI class 6vi1a%IJ 23000001 JI7&4IJ 01000005 JII&5IJ 01000006 JII&6IJ
01000007 JII&7IJ 01000008 JI
.method IJ06000007JI class 6vi1a%IJ 23000001 JI7&4IJ 01000005 JII&5IJ 01000006 JII&6IJ
01000007 JII&7IJ 01000008 JII&8IJ 01000009 JII&9IJ 0100000* JII&10IJ 0100000O JII&11IJ
0100000+ JI
.method IJ06000008JI class 6.module bbbIJ 1*000001 JI7&4IJ 0100000= JII&5IJ 0100000:
JII&6IJ 0100000> JII&7IJ 01000010 JII&8IJ 01000011 JII&9IJ 01000012 JII&10IJ 01000013
JII&11IJ 01000014 JI
.method IJ06000009JI class &4IJ 01000015 JII&5IJ 01000016 JII&6IJ 01000017 JII&7IJ
01000018 JII&8IJ 01000019 JII&9IJ 0100001* JII&10IJ 0100001O JII&11IJ 0100001+ JI



;o #ar "e have looed at data t%pes that have been created "ithin our pro(ram and no" "e need
to loo at those de#ined some"here else. Thus the method a1 has a return t%pe o# class &1. The
onl% problem is that this class &1 is de#ined in vi1a% "hich is placed in s.uare bracets.

This name vi1a% has to been a assembl% re# as "e speci#ied earlier. The onl% problem is there is
no chec to see "hether this assembl% vi1a% actuall% exits and "ithin it there exists a t%pe called
&1. :ver% t%pe "e re#erence in our pro(ram is stored in the t%pe re# table.

The name and namespace #ield store #or us the name and namespace name respectivel%. The #ield
resolution "e "ill deal "ith in a short "hile. 'n the t%pe si(nature$ the class t%pe remains at 12
and the toen #or the method a1 is 09. *s the #irst bit is 1$ this toen re#ers to the t%pe re# table
and not the t%pede# table.

244260235.doc 212 od 541
Thus in the =ecodeToen table the i# statement checs i# the variable tablet%pe is 1$ it pics up
the ro" #rom the t%pere# and not t%pede# table. Thus in the >ill*rra% method "e no" populate the
t%pere#names arra%. The variable strin(t%pe#minusnested simpl% (ives us the name and
namespace combo o# the t%pe used "ith or "ithout the dot.

Then "e move on to the core o# "hat this pro(ram is all about. !e "ant to no" "here this t%pe
is reall% stored. The #ield resolutionscope is 1ust "hat the doctor ordered. This method used
earlier (ives us one o# the #our tables$ *ssembl%,e#$ 0odule$ 0odule,e# and T%pe,e#. These
values tell us "here to #ind the t%pe.

>or the method a1$ the t%pe is to be #ound in a *ssembl% and hence the coded index is a
*ssemble%,e#. The coded index ro" variable no" points to the *ssembl%,e# table.

Thus "e start "ith a open 6$ then "e pic up the name o# the assembl% #rom the *ssembl%,e#
table usin( the resolutionro" variable$ #ollo"ed b% the table number o# the *ssembl%,e# table
0x23 and the ro" number in this table usin( the resolutionro" variable. >inall% the #or loop index
variable tells us the ro" number in the t%pe re# table that has a number 1.

This is at the end as a comment #or all the t%pere# ro"s. !e add the t"o strin(s
strin(t%pe#minusnested and strin( strin(nested at the end and place this value into the
t%pere#names arra%. 'n this case "e need not have t"o separate variables as one "ould have done
the 1ob. ,ead on.

>or method a2$ the return t%pe is &2 and this is no" #ound in a module bbb. There is a module
extern directive that speci#ies the existence o# a module "ith this name. Thus the coded index
table is no" 0odule,e# as the t%pe is in the same assembl% but a di##erent module.

>or the module re# "e add the .module directive and no" the variable resolution ro" is an o##set
into the 0odule,e# table "hose number is 0x1a. The rest o# the code remains lie that o# the
*ssembl%,e#.

The third method a3 has its return data t%pe &3 stored in a module called ccc and this is also the
name o# the current module usin( the module directive. Thus the code index table "ill return
0odule and in the output "e do not displa% the "ords module and the name o# the module$ but
onl% the t%pe name.

The problems starts "ith the method a4 that has a t%pe in the *ssembl%,e# vi1a% but its t%pe is
nested. The main t%pe is &4 and "ithin this t%pe "e have a nested t%pe &5. The )ested T%pes table
does not (et an entr% added as that table deals "ith nested t%pes created in this assembl% and not
some"here else.

Thus t"o records "ill be added to the T%pe,e# table$ one #or the t%pe &4 and the second #or the
t%pe &5. To mae matters simpler #or us to understand "e "ill comment the entire il #ile and onl%
#ocus on one method at a time #rom no" on. /ur current #ocus is method a4.

The T%pe,e# table has three records$ the #irst #or the t%pe /b1ect as all classes are derived #rom
class /b1ect at the end o# the da%. Thus "e "ill not sho" %ou the #irst record o# the t%pe re# table
that re#ers to the class /b1ect.

244260235.doc 213 od 541
The second ro" re#ers to the class &4 and the resolution scope re#ers to the assembl% re# table
record 1 that is vi1a%. This is obvious as the class or t%pe must reside someplace. The third record
re#ers to the class &5. This class is nested "ithin the class &4.

This relationship is mapped b% speci#%in( the resolution scope o# T%pe,e# and the ro" number is
the ro" number o# the class "ithin "hich this class is nested. Thus "henever "e see a T%pe,e#
resolution scope it means that the current class is nested "ithin the class speci#ied b% the
resolution index.

This class i# it has a resolution scope o# T%pe,e# means one more level o# nestin(. This
relationship ends "ith a t%pe "hose resolution scope is 0odule$ 0odule,e# or *ssembl%,e# as
"e shall soon see.

,o" S2
,esolution;cope M *ssembl%,e#617
)ame M F&4F
,o" S3
,esolution;cope M T%pe,e#627
)ame M F&5F

The i# statement #or the value o# the resolution scope index bein( T%pe,e# is true #or the nested
t%pe &5 and not t%pe &4. The value o# the variable resolutionro" is no" 2 "hich simpl% means
that this T%pe,e# ro" ma% be the parent t%pe.

!e use this value to move to ro" 2$ "e are at ro" three no" and #ind out the ne" values o# this
coded index. '# it is an% o# the terminatin( table t%pes$ "e call the #unction
DetTable,e#)ame>or>ill*rra% that (ives us the name o# the *ssembl% or 0odule or 0odule,e#
that the t%pe is in.

The last parameter is the t%pe o# container that this t%pe resides in. The #irst parameter is the
tablero" in the table t%pe speci#ied in the last parameter and the second parameter is the t%pe ro"
number that has a coded index other than T%pe,e#. 3ets loo at this #unction
DetTable,e#)ame>or>ill*rra% #irst.

!e #irst as "hich table the tablero" parameter is an o##set to. =ependin( upon one o# t"o and
not three possible tables$ "e use the relevant arra% to (ives us the name o# the assembl% or
module. '# the t%pe resides in the same module$ the module directive is removed.

>or the *ssembl%,e# table$ it is simpl% the table name and #or the 0odule,e# table it is the
module directive plus the extern module name. !e no" need to add the t%pe name and
namespace name "hich is stored in the T%pe,e# table. This t%pe is the parent t%pe &4 and not
nested t%pe &5 in this case.

!e then add the relevant name o# the t%pe and the ro" number in comments. *s this is a nested
t%pe "e end "ith a sin(le slash speci#%in( a nested t%pe. )o" that "e have the parent t%pe$ "e
need to add the last nested t%pe &5 "hich is the value o# the loop index .

Thus "e have a method DetT%pe,e#>or>illarra% that simpl% displa%s a t%pe "ith a certain index.
This #unction is ver% elementar% and all that "e do is add the name and namespace and then the
ro" number o# the t%pe re# table in comments. This is ho" "e tae care o# a sin(le level o# a
nested t%pe.
244260235.doc 214 od 541

This does not "or "ith a t%pe that has more than one level o# nestin(. !e need more complex
code. This i# statement "as unnecessar% but as an aid to understandin(. The else taes place
"henever "e have more than one level o# nestin(. 3ets tae a certain case o# method a6 "hich is
complex enou(h.

'ts data t%pe o# the return value is &4I&5I&6I&7 "here "e have #our levels o# nestin(. 2o" do "e
handle complex cases lie this. ;imple "e start at the inner else statement.

,o" S2
,esolution;cope M *ssembl%,e#617
)ame M F&4F
,o" S3
,esolution;cope M T%pe,e#627
)ame M F&5F
,o" S4
,esolution;cope M T%pe,e#637
)ame M F&6F
,o" S5
,esolution;cope M T%pe,e#647
)ame M F&7F

3ets start "ith the ro"s o# the T%pe,e# table. 'n the =ecodeToen method$ the value o# the
tableindex "ill b3 5$ the record number #or the &7 t%pe. '# "e loo at the ro"s$ the resolution
coded table is t%pere# that tells us that the parent t%pe o# &7 is &6.

Out this ro" also has a coded index o# T%pe,e# and thus class &5 is the parent o# class &6.
2o"ever class &5 or ro" 3 has also a T%pe,e# coded index and thus ro" 2 or class &4 is the
parent #or class &5. The (ood ne"s is that class &4 has a coded index o# *ssembl%,e#. 3ets tae a
hands on loo at our code.

The strin( tablename is T%pe,e# and the t%pe ro" is 5 or class &7. The ro" variable is 4
speci#%in( that this ro" "ill be the parent o# class &7. !e "ould no" need to #ind out ho" man%
levels o# nestin( are there. Thus "e need to eep loopin( until "e #ind a t%pe ro" "hose coded
index table is not T%pe,e#.

The problem is that "e cannot assume that each nested t%pes parent is stored one about it. ;o "e
in a "hile loop$ eep loopin( until "e reach a table name that is not T%pe,e#. )o" that "e have
entered the "hile loop$ "e are on a nested t%pe and hence "e calculate the ro" number o# the
parent t%pe.

This is stored in ro". !e then use this ro" number to (ive us the coded index table o# the parent
t%pe. '# this is ever not T%pe,e# "e exit the "hile loop. Thus in our speci#ic case the cnt variable
"ill have a value o# 2 as "e have entered the "hile loop t"ice and the ro" number that had a
coded index other than T%pe,e# is the second ro".

Thus the value o# cnt is actuall% one less than the number o# t%pes. 't (ives us t%pes &5 and &6. ]7
is the t%pe denoted b% the index and &4 b% the *ssemble%,e#. !e "ould no" lie to create an
arra% o# 2 intQs t store the ro" numbers o# t%pes &5 and &6.

244260235.doc 215 od 541
!e once a(ain enter the "hile loop t"ice and simpl% recalculate the coded index ro" variable
and store it in the t%pero"s arra%. The values in this arra% are ro"s 3 and 2 as "e are movin( up
the t%pe ro" table. The tablename1 and ro"1 variables are set to a value o# the t%pe &7 or ro" 5
in the t%pe re# table.

!e are no" callin( the method DetTable,e#)ame>or>ill*rra% "ith the #irst parameter
assembl%ro" as 1 as this is the record number o# the *ssembl%;truct table and name vi1a%. The
t%pero" variable is the 2 as this is the #irst parent t%pe &4. This method "ill return a strin( as
6vi1a%IJ 23000001 JI7&4IJ 01000002 JII.

!e no" enter the "hile loop onl% once as the value o# cnt is onl% t"o. 2ere "e displa% the next
series o# nested t%pes. The t%pero" arra% has a value o# 3 and the strin( dumm% contains &5IJ
01000003 JII. )o" "e need to displa% the second last t%pe that is denoted b% the resolutionro"
variable or ro" 4 or t%pe &6.

>inall% the current t%pe denoted b% or ro" 5 or t%pe &7 is displa%ed at the end "ithout the
nested slash. !e could not have placed the second last DetT%pe,e#>or>illarra% "ithin the "hile
as the t%pe &4 "ould come t"ice. '# %ou are not clear please reread the entire explanation a couple
o# times "ith some aspirin.

4ro(ram32.csc
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
strin( modoptstrin( A FF<
int b%testaen<
modoptstrin( A Det0od/pt/r0od,e.5 index $ blobarra% $ out b%testaen8<
index A index C b%testaen<
b%te t%pe A blobarra%6index7<
i# 5 t%pe HA 0x01 GG t%pe BA 0x0e 8
9
returnstrin( A DetT%pe5t%pe8<
ho"man%b%tes A 1<
@
i# 5 t%pe AA 0x45 8
9
int ho"man%b%tes2 <
returnstrin( A Det:lementT%pe5 index C 1 $ blobarra% $ out ho"man%b%tes28 C F pinnedF<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
ho"man%b%tes A ho"man%b%tes C b%testaen<
i# 5 modoptstrin( EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(<
return returnstrin( <
@
public strin( DetToenT%pe 5 b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int uncompressedb%te<
int ho"man%b%tes1 A 0<
244260235.doc 216 od 541
ho"man%b%tes1 A ho"man%b%tes1 C +or;i(Nncompress=ata5blobarra% $ index C 1 $ out
uncompressedb%te8<
strin( dumm%1 A =ecodeToen5uncompressedb%te $ blobarra%6index78<
i# 5 blobarra%6index7 AA 0x128
returnstrin( A Fclass F C dumm%1<
else i# 5 blobarra%6index7 AA 0x118
returnstrin( A Fvaluet%pe F C dumm%1<
else
returnstrin( A dumm%1<
ho"man%b%tes A ho"man%b%tes1<
return returnstrin(<
@

public strin( Det0od/pt/r0od,e. 5 int index $ b%te 67 blobarra% $ out int b%testaen8
9
strin( returnstrin( A FF<
b%testaen A 0<
int "hileindex A index<
i# 5 blobarra%6index7 AA 0x20 TT blobarra%6index7 AA 0x1#8
9
"hile 5 true 8
9
int noo#b%tes<
strin( toens A DetToenT%pe 5blobarra% $ "hileindex $ out noo#b%tes8 <
i# 5 blobarra%6"hileindex7 AA 0x208
toens A Fmodopt5F C toens C F8F<
i# 5 blobarra%6"hileindex7 AA 0x1#8
toens A Fmodre.5F C toens C F8F<
b%testaen A b%testaen C noo#b%tes C 1<
returnstrin( A toens C F F C returnstrin( <
"hileindex A "hileindex C noo#b%tes C 1<
i# 5 E5blobarra%6"hileindex7 AA 0x20 TT blobarra%6"hileindex7 AA 0x1#8 8
brea<
@
@
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin(.,emove5returnstrin(.3en(thP1$18<
return returnstrin(<
@

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method void modopt56vi1a%7aa 8 a158
9
@
.method void modre.56vi1a%7aa 8 a258
9
244260235.doc 217 od 541
@
.method void J modopt56vi1a%7aa 8 modre.56vi1a%7bb 8 modre. 56vi1a%7cc 8 modre.56vi1a%7dd 8
a358
9
@
@

/utput
.method IJ06000001JI void modopt56vi1a%IJ 23000001 JI7aaIJ 01000002 JI8
.method IJ06000002JI void modre.56vi1a%IJ 23000001 JI7aaIJ 01000002 JI8
.method IJ06000003JI voidJ modopt56vi1a%IJ 23000001 JI7aaIJ 01000002 JI8 modre.56vi1a%IJ
23000001 JI7bbIJ 01000003 JI8 modre.56vi1a%IJ 23000001 JI7ccIJ 01000004 JI8 modre.56vi1a%IJ
23000001 JI7ddIJ 01000005 JI8

!e are no" (oin( to delve into t"o modi#iers modre. and modopt that "e have no parallel "hen
it comes to the +S pro(rammin( lan(ua(e. '# %ou "ere a +CC pro(rammer$ thee custom modi#iers
ma% have made some sense. These modi#iers are similar to custom attributes but the% are part o#
the method si(nature unlie attributes that are not.

The modre. modi#er means that the caller must understand the modi#er "hereas modopt means
that the modi#er ma% be i(nored. These modi#iers can be attached to a parameter or a return
value$ in other "ords the% associate onl% "ith a data t%pe. This allo"s us to associate a t%pe
re#erence "ith a item.

The +3' ho"ever does not care about these modi#iers other than chan(in( the si(nature o# the
method. These modi#iers are thus used b% tools that interact "ith the metadata. These tools are
compilers$ pro(ram anal%sers etc. These modi#iers tell us that a modopt ma% be i(nored but a
modre. has some special meanin(.

'# this "as a +CC boo$ "e "ould have explained ho" the concept o# a const can be modelled
usin( custom modi#iers. 3ets loo at the #irst method a1 "hich has a optional modi#er "ith a t%pe
re#erence to t%pe aa in assembl% vi1a%. The modi#iers need a an% t%pe re#erence. This could be a
t%pe created some"here else or in the same #ile.

* int32 t%pe "ill not su##ice. >or consistenc% "e have used a t%pe aa #or all. The si(nature #or this
method reads as 20 00 20 09 01. Wou "ill reali&e that the third b%te is not a 1 "hich is the data
t%pe o# a void but 0x20. This is the t%pe number #or a modopt modi#ier.

These modi#iers are #ollo"ed b% a toen t%pe that pinpoints the t%pe re#erence. This is the reason
in built t%pes lie int32 are not permitted. *#ter the t%pe toen #ollo"s the data t%pe o# the return
value. 3ets loo at method a2 that uses a modre. instead.

'ts si(nature is 20 00 1> 09 01 "hich tells us that a modre. has a t%pe o# 0x1#. >inall% method a3
is more complex$ it starts "ith one modopt and then "e have three modre. modi#iers. 'ts
si(nature is 20 00 1> 15 1> 11 1> 0= 20 09 0> 01. The last t"o b%tes are #or the pointer to void.

:ven thou(h "e start "ith a modopt$ then the modre.s$ the order is the si(nature is reversed. This
"e see the three modre.s #irst and then the modopt. !hen "e displa% these custom modi#iers "e
"ill have to reverse them. 3ets start "ith the method Det:lementT%pe #irst.

244260235.doc 218 od 541
*t the ver% be(innin( "e "ould lie to #ind out i# there are an% custom modi#iers. This is most
important as custom modi#iers come #irst and then the data t%pe. This is true #or a return value as
"ell as #or parameters.

!e pass the #unction Det0od/pt/r0od,e. three parameters$ the index o# the t%pe in the blob
arra%$ the blobarra% and "e expect a strin( that has all the modopt and modre. modi#iers. *lso "e
expect the out parameter to (ive us the number o# b%tes taen up b% the custom modi#iers.

!e then increase the index variable b% the number o# b%tes taen up b% the custom modi#iers so
"e no" point to the actual data t%pe. *t the end o# the Det:lementT%pe method "e add the
ho"man%b%tes variable b% the b%testaen or the number o# b%tes taen up b% the custom
modi#iers.

This variable is the out parameter #or the Det:lementT%pe method. >inall% "e add the
modoptstrin( to the end o# the returnstrin( and not at the be(innin( "ith a space. 3ets move on
the Det0od/pt/r0od,e. that actuall% does all the "or. 0ost o# the time$ custom modi#iers are
rarel% used and this method "ill do nothin(.

Thus "e initiali&e the out parameter b%testaen to b &ero and the returnstrin( to a empt% strin(. '#
and onl% i# the b%te denoted b% the index parameter is a modre. 0x1# or a modopt 0x20$ do "e
need to do somethin(. *s "e ma% have scores o# custom modi#iers "e enter a in#inite "hile loop.

The #act that "e are here no" means that "e have at least one custom modi#er. !e then call the
method DetToenT%pe to #i(ure out the toen that #ollo"s a custom modi#er. This method
remains the same lie be#ore but "ith a small else added.

:arlier "e called this #unction #or a class or valuet%pe toen and "ithin i# statements added a
class or valuet%pe to the value returned b% the =ecodeToen method. )o" as "e are callin( it
#rom a third method$ "e need to add no such embellishments to the toen strin( and thus the #inal
else simpl% initiali&es the return value.

Thus variable toens no" contains the t%pe re#erence toen as a strin( but "e need to place this
toen in a modopt or modre. e%"ord. Thus "e chec "hether the b%te t%pe is that o# modopt
0x20 or modre. 0x1#. !e use the variable "hileindex #or this o##set.

!e no" set b%testaen to increase b% the number o# b%tes the toen has taen that is stored in
noo#b%tes and a(ain b% 1 as one b%te (ets taen b% the custom modi#ier. !e then set the return
strin( returnstrin( to this value o# the toen but as the "orld is reverse$ "e add the toens at the
be(innin( and not at the end.

!e increase the "hileindex b% the same amount as b%testaen and no" chec i# the next b%te
a#ter the custom modi#ier is also another custom modi#er. '# it is "e (o bac to the loop$ i# not "e
end the loop. >inall% these is an extra space le#t in this strin( returnstrin( "hich "e remove usin(
the ,emove method.

This is ho" "e handle custom modi#iers.

4ro(ram33.csc
public void +reate0ethod=e#;i(nature 5b%te 67 blobarra% $ int ro"8
9
strin( returnt%pestrin( A FF<
244260235.doc 219 od 541
returnt%pestrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ro" $ F0ethodF8 C F
F<
methodde#returnarra%6ro"7 A returnt%pestrin(<
@
public void =ispla%*ll0ethods 5int t%pero"8
9
methodstrin( A methodstrin( C F.method F<
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( s A methodstrin( C F F C methodde#returnarra%6methodindex7 C F F C
Det;trin(50ethod;truct6methodindex7.name8<
+onsole.!rite3ine5s8<
@
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes $ int ro" $
strin( name8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
strin( modoptstrin( A FF<
int b%testaen<
modoptstrin( A Det0od/pt/r0od,e. 5 index $ blobarra% $ out b%testaen8<
index A index C b%testaen<
b%te t%pe A blobarra%6index7<
else i# 5 t%pe AA 0x1b8
9
int ho"man%b%tes2 <
returnstrin( A Det4ointerTo>unction;i(nature 5 index $ blobarra% $ out ho"man%b%tes2 $ re#
modoptstrin($ ro" $ name8 <
modoptstrin( A FF<
ho"man%b%tes A ho"man%b%tes2 <
@
ho"man%b%tes A ho"man%b%tes C b%testaen<
i# 5 modoptstrin( EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(<
return returnstrin( <
@
public strin( Det4ointerTo>unction;i(nature 5 int index $ b%te 67 blobarra% $ out int
ho"man%b%tes $ re# strin( modoptstrin($ int ro" $ strin( name8
9
int uncompressedb%te<
index A index C 1<
int nob%tes <
int totalb%tes A 1<
strin( returnstrin( A FF<
nob%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
i# 5 ro" EA 0 GG name AA F0ethodF8
9
methodde#t%pearra% 6ro"7 A =ecode>irstO%teo#0ethod;i(nature 5uncompressedb%te $ ro"8<
methodde#t%pearra%6ro"7 A Fmethod F C methodde#t%pearra% 6ro"7<
@
else
returnstrin( A Fmethod F C =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<
244260235.doc 220 od 541
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
nob%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
int noo#t%pes A uncompressedb%te<
int b%testaen1<
strin( modoptstrin(1 A Det0od/pt/r0od,e.5 index $ blobarra% $ out b%testaen18<
index A index C b%testaen1<
totalb%tes A totalb%tes C b%testaen1<
returnstrin( A returnstrin( C Det:lementT%pe5index $ blobarra% $ out nob%tes $ 0 $ FF8 <
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
i# 5modoptstrin(1EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(1 <
returnstrin( A returnstrin( C F J5F<
i# 5 noo#t%pes AA 08
returnstrin( A returnstrin( C F8F<
else
#or 5 int i A 1< i BA noo#t%pes < iCC8
9
returnstrin( A returnstrin( C Det:lementT%pe5index $ blobarra% $ out nob%tes $0 $ FF8<
i# 5 i EA noo#t%pes8
returnstrin( A returnstrin( C F$F<
else
returnstrin( A returnstrin( C F8F<
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
@
i# 5 modoptstrin( EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(<
ho"man%b%tes A totalb%tes<
return returnstrin(<
@

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method public static method unmana(ed stdcall int32J5int8$int16$strin( 8 a15unsi(ned int8 a8
9
@
.method public static method unmana(ed #astcall int32 modopt5&&&8 modopt 56vi1a%7 %%%8
modopt 56vi1a%7 xxx8 J5int8$int16$strin( 8 modre.56vi1a%7a18 modre.56vi1a%7a28 a25int8 a$ int16
b8
9
@
.method public static method unmana(ed thiscall int32 J5int8$int16$strin( 8 modre.56vi1a%7a18
modre.56vi1a%7a28 a35int8 a$ int16 b8
244260235.doc 221 od 541
9
@
.method public static method unmana(ed cdecl int32 modopt5&&&8 modopt 56vi1a%7 %%%8 modopt
56vi1a%7 xxx8 J5int8$int16$strin( 8 a45int8 a$ int16 b8
9
@
@

/utput

.method IJ06000001JI int32 J5int8$int16$strin(8 a1
.method IJ06000002JI int32 modopt5&&&IJ 02000002 JI8 modopt56vi1a%IJ 23000001 JI7%%%IJ
01000002 JI8 modopt56vi1a%IJ 23000001 JI7xxxIJ 01000003 JI8 J5int8$int16$strin(8
modre.56vi1a%IJ 23000001 JI7a1IJ 01000004 JI8 modre.56vi1a%IJ 23000001 JI7a2IJ 01000005 JI8
a2
.method IJ06000003JI int32 J5int8$int16$strin(8 modre.56vi1a%IJ 23000001 JI7a1IJ 01000004
JI8 modre.56vi1a%IJ 23000001 JI7a2IJ 01000005 JI8 a3
.method IJ06000004JI int32 modopt5&&&IJ 02000002 JI8 modopt56vi1a%IJ 23000001 JI7%%%IJ
01000002 JI8 modopt56vi1a%IJ 23000001 JI7xxxIJ 01000003 JI8 J5int8$int16$strin(8 a4

'n the above example the =ispla%*ll0ethods #unction has onl% one chan(e and that is the name
o# the method stored in the #ield name is also displa%ed. The ma1or chan(es taes place in the
Det:lementT%pe method. !e have added t"o more parameters to this method. This is ho" code
(ets "ritten in real li#e.

*s "e did no prior plannin( earlier$ "e did not account #or the #act that the existin( parameters
#or the Det:lementT%pe method "e not enou(h. Thus each and ever% place "e have called the
Det:lementT%pe method in the past$ "e no" have to add these t"o extra parameters.

*s these earlier calls did not use these parameters$ "e use 0 and the empt% strin( ^_. The onl%
place "e use it is in the +reate0ethod=e#;i(nature method "here "e pass the ro" number in the
method table #or the #ourth parameter and the #i#th is "here "e have called the Det:lementT%pe
method #rom$ the 0ethod table obviousl%.

There is one more addition to the Det:lementT%pe method and that is the t%pe 0x1b that stands
#or a #ull method si(nature. 3ets loo at the #irst method a1 in the il #ile. The #irst chan(e is the
addition o# the "ord method to the callin( convention. This is #ollo"ed b% the data t%pe int32 and
then a star.

This complicates li#e as "e no" have a pointer to a #unction. The open and close bracets no"
encompass the parameters o# this #unction. !henever "e have a pointer to a #unction$ "e shall
see a 0x1b in our si(nature b%te. These b%tes no" loo as 00 01 1O 02 03 08 04 06 0: 05.

The #irst is the callin( convention b%te that is &ero$ #ollo"ed b% the number o# parameters o# the
method a1 01. Then "e (et a 0x1b "hich is the t%pe #or a #ull method si(nature #ollo"in(. This
b%te no" has the callin( convention b%te #irst and 2 is stdcall. *s this is a pointer to a #unction$
"e need to add the "ord method to the callin( convention.

The next b%te is the stdcall callin( convention #ollo"ed b% not the count b%tes o# number o#
parameters to #unction a1 but to the #unction that the return value points to 3. :ach and ever%
#unction call returns a value and in our case our #unction returns a int32 and its t%pe b%te 08 is
244260235.doc 222 od 541
next. This is #ollo"ed b% the three parameter t%pes to the method a int8 or 04$ then a int16 a 06
and a strin( 0e.

This completes the pointer to method and then "e have the data t%pe o# the #irst parameter.
0ethod a2 complicates li#e a little bit #or us. The modopt and modre. appear a#ter an% data t%pe.
!e have t"o data t%pes in a pointer to #unction situation$ the #irst is the int32 or return t%pe o# the
pointer method.

'n #unction a2 "e have a series o# modopt "hich i# %ou #or(otten is 0x20 and then "e have a
series o# modre.s or 0x1# a#ter the pointer #unction parameters and be#ore the name o# the
#unction. Thus the si(nature b%tes read as 00 02 1> 15 1> 11 1O 04 03 20 0= 20 09 20 08 08 04
06 0: 04 06.

This mae loo complex but i# %ou loo at them closel%$ %ou "ill see that b%te 3 on"ards are the
modre.s 0x1#. Thus "hat "e "rite at the end come #irst in the si(nature. This is then #ollo"ed b%
the si(nature o# the pointer to #unction 0x1b and the next t"o b%tes.

Then come the modoptQs and return value o# the pointer$ the three #unction pointer data t%pes and
the data t%pes o# the three parameters. 0ethods a3 and a4 have the re.uired modi#er at the
be(innin( or at the end. >irst lets loo at the code o# the Det:lementT%pe method *ll that "e do
is "hat "e have al"a%s done.

!e call a method Det4ointerTo>unction;i(nature "hich taes the same #ive parameters passed to
the Det:lementT%pe method. The #ourth is a valid ro" number o# the method in the method table
and the last is the strin( 0ethod. 'n the same vein the ho"man%b%tes variable is set to the third
parameter o# the Det4ointerTo>unction;i(nature method.

The ma1or deviation is that "e set the variable modoptstrin( to null "hich means that "e undo
the e##ect o# the #irst Det0od/pt/r0od,e. method called. *lso "e pass this strin( modoptstrin(
as the #i#th parameter. +omin( to the Det4ointerTo>unction;i(nature method "e start "ith usin(
the index variable as an o##set into the si(nature.

!e are no" at the 0x1b and need to pic up the callin( convention b%te. !e increase the index
variable b% 1 and also use the totalb%tes to tell us ho" man% b%tes the pointer to #unction
si(nature consumes. *s the 0x1b taes up one b%te$ "e start variable totalb%tes "ith 1 and not
&ero.

)o" "e need to decode the callin( convention b%te usin( the method
=ecode>irstO%teo#0ethod;i(nature that "e have done be#ore. !e also need to add the "ords
method be#ore it. The onl% problem is that #or a method "e have stored the callin( convention in
the arra% methodde#t%pearra%.

>or others lie a local var si(nature$ method re# si(nature etc "e have created no such arra%. Thus
"e chec i# the ro" is non &ero and the name parameter is 0ethod. '# %es "e simpl% place the
callin( convention strin( in the arra% methodde#t%pearra%.

'# another si(nature$ "e add the callin( convention to the returnstrin( variable that "ill contain
the entire si(nature to be returned. The index and totalb%tes variable "ill move in loc step
al"a%s. !e then tae care o# the number o# parameters to the #unction b% storin( the result in
noo#t%pes that "e use later to simpl% print out the data t%pes to the method.

244260235.doc 223 od 541
)o" "e ma% or ma% not have custom modi#iers modopt or modre.. 2ere the modi#iers are the
one be#ore and the #irst set o# modi#iers are stored in the strin( modoptstrin(. !e then call the
Det:lementT%pe method to (ives the data t%pe o# the pointer to #unction "hich is a int32 in our
case.

!e once increase the index and totalb%tes variables. !e no" chec "hether the modoptstrin(1is
blan or not as "e need to add the modopt strin( "ith a space. These custom modi#iers are the
custom modi#iers that "e have 1ust (ot. !e then place the J and the bracets and i# the #unction
has no data t%pes$ i.e. noo#t%pes is &ero "e add the closin( bracets.

!e then in a #or loop use Det:lementT%pe to (ive us the data t%pe o# each parameter. !e also
no" that o# the last parameter "e do not put a comma but a close bracet. >inall% "e add the
last modoptstrin( that actuall% comes #irst in the si(nature b%te and "e captured at the be(innin(
o# the Det:lementT%pe method.

!e also initiali&e the out parameter ho"man%b%tes to totalb%tes. This completes "hat "e believe
is the most di##icult method si(nature.

>inall% "e have used the same pointer to #unction as a parameter. .method public static int32
a25method unmana(ed stdcall int8 modopt56vi1a%7aa8 modopt56vi1a%7bb8 J 5int16$int328
modre.56vi1a%7cc8 a 8
9
@

'ts si(natures b%tes are 00 01 08 1> 11 1O 02 02 20 0= 20 09 04 06 08. Thus li#e remains the
same "hether "e deal "ith parameters or return values.

!e #inall% tae a real complex method si(nature. >irst lets tae a loo at the il #ile.

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method public static method unmana(ed stdcall bool modopt56vi1a%7bb8 J 5 method unmana(ed
thiscall int8 modre.56vi1a%7cc8 modre.56vi1a%7dd8 J5int16$method unmana(ed #astcall int32
modre.56vi1a%7&18 modopt56vi1a%7&28 J 5 bool $ unsi(ned int328 8 $ int64 $ unsi(ned int648
modre.56vi1a%7ee8 a258
9
@
@

3oos ver% intimidatin( but lets tae it one b%te at a time b% looin( at the si(nature (enerated.
This loos lie 00 00 1> 1= 1O 02 03 20 09 02 1O 03 02 1> 11 1> 0= 04 06 1O 04 02 20 19 1>
15 08 02 09 0* 0O.3ets as al"a%s start #rom the be(innin( tain(.

The #irst 00 is the callin( convention and the second 00 the number o# parameters the #unction a1
taes that are none. Then "e come across the modre. modi#er 1# that is the last modre. modi#er
modre.56vi1a%7ee8. ,emember these modi#iers are stored bac"ards$ the last is seen #irst.

244260235.doc 224 od 541
Then "e have a 0x1b or the pointer to #unction si(nature. The 02 is the standard callin( t%pe
stdcall o# the main pointer to #unction that is #ollo"ed b% the number o# parameters 03 that this
pointer has. The last t"o are a int64 and unsi(ned int64. This is #ollo"ed b% the t"o modoptQ s
modopt56vi1a%7aa8 modopt56vi1a%7bb8 that "e have be#ore the J.

The 02 is the data t%pe #or a bool "hich is the return value data t%pe #or the pointer to #unction.
Then "e have the data t%pe o# the #irst parameter out o# three "hich un#ortunatel% starts "ith a
0x1b or a pointer to #unction. The 03 is the data t%pe #ir a thiscall and the 02 is the number o#
parameters o# this pointer to #unction.

The t"o 0x1#Qs are the modre.Qs modre.56vi1a%7cc8 modre.56vi1a%7dd8 and the 04 is the data t%pe
int8 the return t%pe o# this pointer to #unction. *s "e have t"o parameters to this #unction a int16
"hose data t%pe is 06. The second parameter is a another pointer to #unction and hence "e see a
0x1b.

'ts callin( convention is 04 or #astcall. The next 02 tells us that "e have t"o parameters. !e have
a modopt and a modre. #ollo"in( modre.56vi1a%7&18 modopt56vi1a%7&28. The int32 data is the
return t%pe o# the #unction and this accounts #or the 08. The 02 and 09 and the bool and unsi(ned
int32 data t%pes o# the innermost pointer to #unction.

>inall% the in64 and unsi(ned int64 have a data t%pe 0# 0x0a and 0x0b that tae up the last t"o
b%tes o# the si(nature.

The #ollo"in( il #ile han(s ilasm.

.method public static method unmana(ed stdcall bool modopt56vi1a%7bb8 J 5 method unmana(ed
thiscall int8 modre.56vi1a%7cc8 modre.56vi1a%7dd8 J5int16$method unmana(ed #astcall int32
modre.56vi1a%7&18 modopt56vi1a%7&28 J 5 bool $ unsi(ned int328 8 8 modre.56vi1a%7ee8 a25int8 aa$
int16 bb8
9
@

4ro(ram34.csc.txt
public void =ispla%*ll0ethods 5int t%pero"8
9
i# 5 T%pe=e#;truct AA null8
return<
i# 5 0ethod;truct AA null8
return<
int start $ starto#nextA0<
start A T%pe=e#;truct6t%pero"7.mindex <
i# 5 t%pero" AA 5T%pe=e#;truct.3en(th P18 8
9
starto#nextA 0ethod;truct.3en(th<
@
else
starto#next A T%pe=e#;truct6t%pero"C17.mindex <
#or 5 int methodindex A start < methodindex B starto#next < methodindexCC8
9
strin( methodstrin( A +reate;paces5spaces#orrest8<
i# 5 'sT%pe)ested5t%pero"88
244260235.doc 225 od 541
methodstrin( A methodstrin( C +reate;paces5spaces#ornested8<
methodstrin( A methodstrin( C F.method F<
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( s A methodstrin( C methodde#returnarra%6methodindex7 C
Det;trin(50ethod;truct6methodindex7.name8 C F5F C methodde#paramarra% 6methodindex7 C
F8F <
+onsole.!rite3ine5s8<
@
@
strin( 67 paramnames<
public void +reate0ethod=e#;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F+reate0ethod=e#;i(nature *rra% 3en(thA90@ method ro"A91@
nameA92@F $ blobarra%.3en(th $ ro" $ Det;trin(50ethod;truct6ro"7.name88<
int ho"man%b%tes$uncompressedb%te $ count $ index<
index A 0<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
methodde#t%pearra%6ro"7 A =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<
index A index C ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
count A uncompressedb%te<
methodde#paramcount6ro"7 A count<
index A index C ho"man%b%tes<
strin( returnt%pestrin( A FF<
returnt%pestrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ro" $ F0ethodF8 C F
F<
index A index C ho"man%b%tes<
methodde#returnarra%6ro"7 A returnt%pestrin(<
strin( returnstrin(1 A FF <
strin( returnstrin(2 A FF<
strin( t%pestrin( A FF<
#or 5 int l A 1 < l BA count < lCC8
9
t%pestrin( A Det:lementT%pe 5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
index A index C ho"man%b%tes<
returnstrin(2A returnstrin(2 C t%pestrin( <
i# 5 l EA count8
returnstrin(2 A returnstrin(2 C F$F<
int ind A Det4aram,o")umber 5ro"$ l 8<
)o" ever% parameter lie a return value can have attributes lie in$ out$ opt as "ell as
marshallin( in#ormation. The Det4aram*ttr#or4aram+allin( #unction taes the param ro"
number and returns the attributes.

strin( paramcallin( A Det4aram*ttr#or4aram+allin( 5ind8<
strin( parammarshal A Det4aram*ttr#or4aram0arshal5ind $ 1 8 <
returnstrin(1 A returnstrin(1 C paramcallin( <
returnstrin(1 A returnstrin(1 C t%pestrin( C F F <
returnstrin(1 A returnstrin(1 C parammarshal <
returnstrin(1 A returnstrin(1 C Det4aram)ame>or0ethod5 ro" $ count $ l8<
i# 5 l EA count8
returnstrin(1 A returnstrin(1 C F$F <
244260235.doc 226 od 541
methodde#paramarra%6ro"7 A returnstrin(1<
methodde#paramarra%16ro"7 A returnstrin(2<
@
@
public strin( Det4aram)ame>or0ethod 5int ro" $ int count $ int l8
9
strin( returnstrin( A FF<
strin( mattributes A Det0ethod*ttribute50ethod;truct6ro"7.#la(s $ ro"8<
i# 5 4aram;truct AA null8
9
IIisnan.exe
i# 5 mattributes.'ndex/#5FstaticF8 EA P18
lPP<
return F*RF C l.To;trin(58<
@
int start $ starto#nextA0 $ paramcount<
start A 0ethod;truct6ro"7.param <
i# 5 ro" AA 50ethod;truct.3en(th P18 8
starto#nextA 4aram;truct.3en(th<
else
starto#next A 0ethod;truct6ro"C17.param<
paramcount A starto#next P start<
int ind<
bool param#ound A #alse<
#or 5 ind A start < ind B starto#next < indCC8
9
i# 5 4aram;truct6ind7.se.uence AA l8
9
param#ound A true<
brea<
@
@
i# 5 param#ound GG paramnames6ind7 EA FF 8
returnstrin( A )ame,eserved5paramnames6ind78<
else
9
II'nterop.orders.dll
i# 5 mattributes.'ndex/#5FstaticF8 EA P18
lPP<
returnstrin( A F*RF C l.To;trin(58<
@
return returnstrin(<
@
int Det4aram,o")umber5 int ro" $ int l 8
9
i# 5 0ethod;truct AA null TT 4aram;truct AA null8
return 0<
int start A 0ethod;truct6ro"7.param <
int end A 0<
i# 5 ro" AA 50ethod;truct.3en(th P18 8
end A 4aram;truct.3en(th<
244260235.doc 227 od 541
else
end A 0ethod;truct6ro"C17.param<
endPP<
int i<
#or 5 i A start < i BA end < iCC8
9
i# 5 4aram;truct6i7.se.uence AA l8
return i<
@
return 0<
@
public strin( Det4aram*ttr#or4aram0arshal 5int paramindex $ int tablet%pe8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null 8
return FF<
i# 5paramindex HA 4aram;truct.3en(th 8
return FF<
int pattr A 4aram;truct6paramindex7.pattr<
returnstrin( A =ecode4aram*ttributes5 pattr $ tablet%pe $ paramindex $ 0x20008<
return returnstrin(<
@
public strin( Det4aram*ttr#or4aram+allin( 5int paramindex8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null 8
return FF<
i# 5paramindex HA 4aram;truct.3en(th 8
return FF<
i# 54aram;truct6paramindex7.se.uence AA 08
return returnstrin(<
int pattr A 4aram;truct6paramindex7.pattr<
i# 5 5pattr G 0x018 AA 0x018
returnstrin( A returnstrin( C F6in7F <
i# 5 5pattr G 0x028 AA 0x028
returnstrin( A returnstrin( C F6out7F <
i# 5 5pattr G 0x108 AA 0x108
returnstrin( A returnstrin( C F6opt7F <
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin( C F F<
return returnstrin( <
@
public void >ill*rra% 58
9
int old A tableo##set<
bool tablehasro"s A tablepresent588<
int o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
paramnames A ne" strin(6ro"s687 C 17<
244260235.doc 228 od 541
#or 5 int A 1 < BA ro"s687 < CC8
9
short pattr A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
int se.uence A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
int name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
strin( dumm% A Det;trin(5name8<
paramnames 67 A )ame,eserved5dumm%8<
@
@
@


e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method void a15int8 i1 $ int16 i28
9
@
.method void a25int8 $ int16 i38
9
@
.method static void a215int8 $ int16 i38
9
@
.method static void a35int8 $ int16 8
9
@
.method 6in7 void a45 int8 i4 $ int16 i58
9
@
.method void marshal 5int328 a5 56out7 int8 i4 $ int16 i58
9
@
.method void modopt56vi1a%7aa8 modre.56vi1a%7bb8 a656out7 int8 i4 $ int16 i58
9
@
.method public static method unmana(ed stdcall int32J5int8$int16 aa $strin( bb8 a75unsi(ned int8
a8
9
@
II.method public static method unmana(ed stdcall bool J5 method unmana(ed thiscall int8
J5int16$method unmana(ed #astcall int32 J 5 bool pp$ unsi(ned int32 8 8 $ int64 (($ unsi(ned
int64 dd8 a82589@
@

244260235.doc 229 od 541
0ethod nameAa1 4arm)oA1
0ethod nameAa2 4arm)oA3
0ethod nameAa21 4arm)oA5
0ethod nameAa3 4arm)oA7
0ethod nameAa4 4arm)oA9
0ethod nameAa5 4arm)oA12
0ethod nameAa6 4arm)oA15
0ethod nameAa7 4arm)oA17
4aram 1 nameAi1 se.A1 attrA0
4aram 2 nameAi2 se.A2 attrA0
4aram 3 nameA*R0 se.A1 attrA0
4aram 4 nameAi3 se.A2 attrA0
4aram 5 nameA*R0 se.A1 attrA0
4aram 6 nameAi3 se.A2 attrA0
4aram 7 nameA*R0 se.A1 attrA0
4aram 8 nameA*R1 se.A2 attrA0
4aram 9 nameA se.A0 attrA1
4aram 10 nameAi4 se.A1 attrA0
4aram 11 nameAi5 se.A2 attrA0
4aram 12 nameA se.A0 attrA8192
4aram 13 nameAi4 se.A1 attrA2
4aram 14 nameAi5 se.A2 attrA0
4aram 15 nameAi4 se.A1 attrA2
4aram 16 nameAi5 se.A2 attrA0
4aram 17 nameAa se.A1 attrA0

/utput
.method IJ06000001JI void a15int8 i1$int16 i28
.method IJ06000002JI void a25int8 *R0$int16 i38
.method IJ06000003JI void a215int8 *R0$int16 i38
.method IJ06000004JI void a35int8 *R0$int16 *R18
.method IJ06000005JI void a45int8 i4$int16 i58
.method IJ06000006JI void a556out7 int8 i4$int16 i58
.method IJ06000007JI void modopt56vi1a%IJ 23000001 JI7aaIJ 01000002 JI8 modre.56vi1a%IJ
23000001 JI7bbIJ 01000003 JI8 a656out7 int8 i4$int16 i58
.method IJ06000008JI int32 J5int8$int16$strin(8 a75unsi(ned int8 a8

'n the =ispla%*ll0ethods method "e no" print out the contents o# the arra%
methodde#paramarra%. 'n this example "e "ill displa% the method alon( "ith all the parameter
data t%pes and names. Oe#ore "e move onto the code$ lets loo at the il #ile #irst and at the same
time "e have displa%ed the ro"s #rom the method table as "ell as the 4aram table.

3ets loo at method a1 in the il #ile$ it has t"o parameters i1 and i2. The method table has a #ield
called 4aram that behaves lie the method #ield in the T%pe=e# table. The current ro" tells us the
#irst ro" number in the 4aram table and the next record tells us the #irst ro" o# the next method in
the 4aram table.

Thus #or ro" 1 in the method table the param #ield has a value o# 1 and #or the next ro" the same
#ield has a value o# 3 as the #irst method has t"o params. 0ovin( on to the 4arams table$ the
name #ield is the name o# the param that is i1 and i2. 'n the second method a2$ the #irst param has
no name and the second param a name i1.
244260235.doc 230 od 541

'n il "e are allo"ed to speci#% a parameter but (ive it no name. 'n spite o# this$ ilasm adds t"o
records to the param table and lets the second param have its name i3$ but (ives the #irst param a
name *R0. 'n method a21$ the e%"ord static has been added and "e %et have the unno"n name
parameter as *R0.

Thus addin( static does not chan(e the name that ilasm automaticall% chooses. 'n method a3$ both
the parameters have no names and the s%stem decides the names *R0 and *R1 respectivel%. This
creates one more parameter that has no name and a se.uence number o# &ero.

'n method a5 "e have added the marshal e%"ord "hich also add a ne" parameter "ith no name
but a se.uence number o# &ero. 'n method a6 "e have the modi#iers modopt and modre. but this
does not e##ect the number o# ro"s in the param table unlie the earlier t"o cases.

0ethod a7 has a return value o# a pointer to #unction but this does not matter to ilasm as the
#unction called ma% have parameters but "e do not speci#% an% names. '# "e do$ the% (et i(nored.
)o" lets tae a loo at the +reate0ethod=e#;i(nature method that #ills up the arra%
methodde#paramarra% "ith all the parameter data t%pes and names.

The count variable tells us the number o# parameters that "e have and "e iterate all the
parameters usin( a #or loop. !e store in t%pestrin( the parameter data t%pe that "e (et usin( the
Det:lementT%pe method. !e do not speci#% the method ro" number and a method name as "e
do not "ant to add the "ords method to the callin( convention.

The returnstrin(2 variable is set to the value o# t%pestrin( and then "e decide to add a comma or
not. The comma should be added to separate all parameters but the last. !e no" that "e are on
the last parameter "hen variable count is e.ual to the variable l.

2e% "here are the parameter names. !e need t"o t%pes o# si(natures$ one "ith parameter names
"hen "e displa% a declaration o# a #unction. !hen "e call a #unction "e also need the si(nature
but "ithout the parameter names and onl% the data t%pes. Thus "e have t"o separate strin(s
returnstrin(2 and returnstrin(1.

The #unction Det4aram,o")umber is passed t"o parameters$ the method ro" number and the
parameter number l. Diven these t"o values$ it must return the correspondin( ro" number o"ned
b% this parameter. '# #or some reason$ a parameter does not o"n an% ro"$ this #unction returns
&ero.

3ets #i(ure out ho" this #unction "ors. !e #irst store in the start and end variable the #irst and
last parameter ro" o"ned b% this method. !e reduce the end variable b% 1 as "e do not$ it "ill
(ive us the startin( ro" o# the next method. Then "e iterate in a #or loop startin( #rom start and
endin( "ith end.

This means that i# our method o"ns 5 ro"s in the param table$ this loop "ill iterate #ive times. *ll
that "e chec is #or a record "ith the same se.uence number that the parameter has. '# "e meet a
match "e return the param ro" number stored in the loop variable i.

'# "e (et out o# the loop$ it means that this param have no ro" in the param table and hence "e
return 0. :arlier "e sho"ed %ou that in spite o# havin( parameters "ith no names and attributes$
the s%stem %et allocated a ro" in the param table and (ave the parameter a name. This is "hat the
current verison o# ilasm does.
244260235.doc 231 od 541

Thus all that "e need to do is #i(ure out the startin( param ro" number and then add l to it. The
onl% precaution "e need to tae is as "hether "e have a param number "ith a se.uence o# &ero.
The point is that toda% ever% parameter o"ns one record in the param table.

:arlier versions o# ilasm made our lives more di##icult and #or reasons o# e##icienc% did not
allocate one ro" to the param table. Thus in method a2$ the #irst param that has no name "ould
not be allocated a ro" in the param table. Thus method a2 "ould have onl% one ro" in the param
table "ith a se.uence number o# 2. 0ethod a3 "ould be "orse.

't "ould be allocated no ro" in the param table as both params have no names or attributes. Thus
"e cannot assume that ever% param has a ro" in the param table. Out i# it has one$ the se.uence
number #ield "ill have a value correspondin( to the variable l. !e had a method called
Det4aram*ttr#or0ethod+allin( "hich returned the attributes.

There "e read #rom the 0ethod;truct table and here "e are readin( #rom the 4aram;truct table.
*s the code #or the attributes is not ver% lar(e "e decided to simpl% cop%$ cut paste #rom the
earlier method. * better "a% "ould be to create a separate method #or the common code "hich
both methods could then call.

2e% but "e do not "ant to "in a pri&e #or "ritin( politicall% correct code. !e did not mae the
same mistae #or the method Det4aram*ttr#or4aram0arshal "here "e no" call the
=ecode4aram*ttributes "ith the attribute b%te that "e read #rom the 4aram table.

The tablet%pe is 1 and the #la(s is 0x2000 to speci#% a param attribute and not a return value
attribute. )o" lets move on to the most important method Det4aram)ame>or0ethod that does
the real "or. !e pass it the 0ethod ro" number$ the count o# parameters as "ell as the
parameter number.

The #irst problem is that "e ma% have a situation "here "e have 10 methods$ all o# them "ith
parameters but none o# them "ith a name. This "ould (ive us as per the earlier compiler a empt%
param or no param table. Thus "e #irst chec "hether our param table is empt%. '# %es$ then "e
need to name the parameter ourselves.

The namin( convention is that the parameter names start "ith 1 #or instance methods and one less
#or static methods. Thus i# the method has a static attribute$ "e reduce the parameter number
stored in l b% 1 and then create a name *R alon( "ith the parameter number.

!e then #i(ure out as be#ore the statin( and end param table ro" number but as "e do not reduce
the starto#next b% one$ in the #or loop "e remove the e.ual to si(n. *lso the paramcount variable
tells us the number o# parameters as per the 0ethod table.

The count variable is as per the method si(nature. Toda% both are the same$ Westerda% this need
not be true. *s be#ore "e loop in the #or statement and leave "hen "e #ind a se.uence number
that matches our parameter count number stored in variable l. *lon( the "a% "e set the
param#ound parameter to true.

!e #irst move to our method >ill*rra% "here "e have #illed up our paramnames arra% "ith the
names o# the parameters. This is reall% not necessar% as all that "e do is #ill up the paramnames
arra% "ith the name o# the param stored in the name #ield. !e then as i# the ro" has a param$
then the name "ould be stored in the paramnames arra%.
244260235.doc 232 od 541

*t times ho"ever$ the parameter has a ro" in the param arra% but the name is a null. >or these
cases the else must be called. The else must also be called "hen the param has no ro" un the
param table. /nce a(ain the earlier rules appl%$ reduce b% 1 i# it is static method.

The #ollo"in( (ives us the "ron( ans"er #or the parameter names. The se.uence numbers (o
ha%"ire.

.method public static method unmana(ed stdcall bool modopt56vi1a%7bb8 J 5 method unmana(ed
thiscall int8 modre.56vi1a%7cc8 modre.56vi1a%7dd8 J5int16$method unmana(ed #astcall int32
modre.56vi1a%7&18 modopt56vi1a%7&28 J 5 bool $ unsi(ned int328 8 $ int64 $ unsi(ned int648
modre.56vi1a%7ee8 a25int8 aa$ int16 bb8
9
@

0ethod a2 1
4aram se.A4 nameAaa attrA0
4aram se.A2 nameAbb attrA0

!e have not #inished methods %et and "e have miles to (o.

4ro(ram35.csc.txt
public void =ispla%*ll0ethods 5int t%peindex8
9
i# 5 T%pe=e#;truct AA null8
return<
i# 5 0ethod;truct AA null8
return<
int start $ starto#nextA0<
start A T%pe=e#;truct6t%peindex7.mindex <
i# 5 t%peindex AA 5T%pe=e#;truct.3en(th P18 8
9
starto#nextA 0ethod;truct.3en(th<
@
else
starto#next A T%pe=e#;truct6t%peindexC17.mindex <
bool placedrva&ero <
#or 5 int methodindex A start < methodindex B starto#next < methodindexCC8
9
placedrva&ero A #alse<
strin( methodstrin( A +reate;paces5spaces#orrest8<
i# 5 'sT%pe)ested5t%peindex88
methodstrin( A methodstrin( C +reate;paces5spaces#ornested8<
methodstrin( A methodstrin( C F.method F<
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( methodattribute A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $ methodindex8<
int pos1 A methodattribute.'ndex/#5FinstanceF8<
i# 5 pos1 EA P18
methodattribute A methodattribute.,emove5pos1$ 98<
strin( enter#ormethodattrbute A FF<
strin( enter#orreturnvalue A FF<
244260235.doc 233 od 541
strin( enter#ormarshal A FF<
strin( paramattrstrin( A FF<
strin( parammarshalstrin( A FF<
paramattrstrin( A Det4aram*ttr#or0ethod+allin(5methodindex8<
parammarshalstrin( A Det4aram*ttr#or0ethod0arshal5methodindex $ 0 8<
II+onsole.!rite3ine5F..methodattributeA90@ returnA91@ paramA92@ marshalA93@ t%peA94@F $
methodattribute $ methodde#returnarra%6methodindex7 $ parammarshalstrin( $
parammarshalstrin(1 $ methodde#t%pearra%6methodindex78<
IIint t%peindex A DetT%pe>or0ethod5methodindex8<
strin( nspaceA FF<
nspaceA )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
int parentt%pe A Det4arent>or)estedT%pe5t%peindex8<
i# 5 parentt%pe EA 08
nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6parentt%pe7.nspace88<
bool cat2return A #alse<
bool cat3returnvaluemarshal A #alse<
bool cat4 A #alse<
int ho"man% A 2o"0an%0ethod*ttributes5methodattribute8<
IIcat2return
i# 5 parammarshalstrin( AA FF 8
9
i# 5 methodattribute AA Fpublic static F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fprivate static F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA F#amil% static F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fassembl% static F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF 8
cat2return A true<

i# 5 methodattribute AA Fpublic virtual F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fprivate virtual F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA F#amil% virtual F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fpublic ne"slot F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fprivate ne"slot F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA F#amil% ne"slot F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fpublic #inal F 8
cat2return A true<
i# 5 methodattribute AA Fprivate #inal F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA F#amil% #inal F 8
cat2return A true<
i# 5 methodattribute AA Fpublic abstract F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA Fprivate abstract F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
244260235.doc 234 od 541
cat2return A true<
i# 5 methodattribute AA F#amil% abstract F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA Fpublic hideb%si( F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF 8
cat2return A true<
i# 5 methodattribute AA F#amil% hideb%si( F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF 8
cat2return A true<
i# 5 methodattribute.'ndex/#5FpinvoeimplF8 AA P18
9
i# 5 ho"man% AA 0 GG methodde#t%pearra%6methodindex7.'ndex/#5Finstance F8 EA P1 8
cat2return A true<
@
@

int aa A 0x00<

IIcat3returnvaluemarshal
i# 5 parammarshalstrin( EA FF 8
9
i# 5 methodattribute AA Fpublic hideb%si( F GG nspace AA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA F#amil% hideb%si( F GG nspace AA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic virtual F GG nspace EA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic virtual F GG nspace AA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic virtual F GG nspace AA FF GG 'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic static F GG E 5'sT%pe)ested5t%peindex8 GG nspace EA FF88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fprivate static F GG E 5'sT%pe)ested5t%peindex8 GG nspace EA FF88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA F#amil% static F GG E 5'sT%pe)ested5t%peindex8 GG nspace EA FF88
cat3returnvaluemarshal A true<

i# 5 methodattribute AA Fassembl% static F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat3returnvaluemarshal A true<
i# 5 ho"man% AA 0 GG methodde#t%pearra%6methodindex7 AA Finstance F 8
cat3returnvaluemarshal A true<
@

IIcat4
i# 5parammarshalstrin( EA FF GG methodattribute.'ndex/#5FpinvoeimplF8 AA P18
9
i# 5 methodattribute AA Fpublic virtual F GG nspace EA FF GG 'sT%pe)ested5t%peindex88
cat4 A true<
i# 5 ho"man% AA 0 GG 'sT%pe)ested5t%peindex8 GG nspace EA FF GG
methodde#t%pearra%6methodindex7 AA FF 8
9
bool problem1 A true<
244260235.doc 235 od 541
i# 5 methodindex AA aa8
+onsole.!rite3ine5F....90@ 91@..F $ methodde#returnarra%6methodindex7.3en(th $
methodde#returnarra%6methodindex78<
i# 5 methodattribute AA Fassembl% static F TT methodattribute AA Fpublic static F TT methodattribute
AA Fprivate static F TT methodattribute AA F#amil% static F 8
9
i# 5 paramattrstrin( AA FF 8
problem1 A #alse<
@
i# 5 problem18
cat4 A true<

@
i# 5 methodattribute.'ndex/#5Fhideb%si(F8 EA P18
9
i# 5 methodattribute.'ndex/#5FpublicF8 EA P1 TT methodattribute.'ndex/#5F#amil%F8 EA P18
9
i# 5 'sT%pe)ested5t%peindex8 TT nspace EA FF 8
cat4 A true<
@
else
cat4 A true<
@
i# 5 ho"man% HA 2 8
cat4 A true<
@

i# 5 cat2return 8
9
enter#ormethodattrbute A FF<
enter#orreturnvalue A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#ormarshal A FF<
@
else i# 5 cat3returnvaluemarshal8
9
enter#ormethodattrbute A FF<
enter#orreturnvalue A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#ormarshal A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
@
else i# 5 cat48
9
enter#ormethodattrbute A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#orreturnvalue A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#ormarshal A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
@
else
9
enter#ormethodattrbute A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#orreturnvalue A F F<
i# 5parammarshalstrin( EA FF8
enter#ormarshal A F F<
244260235.doc 236 od 541
@
methodstrin( A methodstrin( C methodattribute C enter#ormethodattrbute<
methodstrin( A methodstrin( C methodde#t%pearra%6methodindex7 C paramattrstrin( <
methodstrin( A methodstrin( C methodde#returnarra%6methodindex7 C enter#orreturnvalue<
methodstrin( A methodstrin( C parammarshalstrin( C enter#ormarshal <
int no A 0<

i# 5 cat2return 8
noCC<
i# 5 cat3returnvaluemarshal8
noCC<
i# 5 cat48
noCC<

i# 5 methodindex AA aa TT no HA 28
9
+onsole.!rite3ine5F...cat2returnA90@ cat3returnvaluemarshalA91@ cat4A92@ ho"man%A93@
methodde#t%pearra%A94@ paramattrstrin(A95@F $ cat2return$cat3returnvaluemarshal$cat4
$ho"man% $methodde#t%pearra%6methodindex7$paramattrstrin( 8<
+onsole.!rite3ine5F...'sT%pe)estedA90@ nspaceA91@
parammarshalstrin(A92@F$'sT%pe)ested5t%peindex8$ nspace$parammarshalstrin(8<
@
i# 5 methodstrin(.3en(th P methodstrin(.3ast'ndex/#5FUrUnF8 HA 44 8
9
i# 5 methodindex AA aa TT no HA 28
9
+onsole.!rite3ine5F............F8<
@
methodstrin( A methodstrin(.,emove5methodstrin(.3en(thP1$18<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 8C spaces#ornested8<
@
methodstrin( A methodstrin( C )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 <
i# 5 methodattribute.'ndex/#5FprivatescopeF8 EA P18
methodstrin( A methodstrin( C FZ4;T06F C methodindex.To;trin(5FK6F8<
methodstrin( A methodstrin( C F5F<
+onsole.!rite3ine5methodstrin( 8<
@
public int 2o"0an%0ethod*ttributes5strin( methodattribute8
9
int count A 0<
i# 5 methodattribute.'ndex/#5Fhideb%si(F8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5Fne"slotF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FspecialnameF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FrtspecialnameF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5F#inalF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FvirtualF8 EA P18
244260235.doc 237 od 541
countCC<
i# 5 methodattribute.'ndex/#5FabstractF8 EA P18
countCC<
return count<
@

e.il
.class t1
9
.method public static void a158 9@
@
.namespace n1
9
.class t1
9
.method public static void a258 9@
@
@
.class t2
9
.class t1
9
.method public static void a358 9@
@
@
.namespace n1
9
.class t2
9
.class t1
9
.method public static 6in7 int8J a458 9@
@
@
@

/utput
.method IJ06000001JI public static void
a15

.method IJ06000002JI public static void
a25

.method IJ06000003JI public static void
a35

.method IJ06000004JI public static
6in7 int8J a45

This pro(ram too us a lon( time to #i(ure out. Wou ma% "onder "h% as all that it does is simpl%
displa% the method declaration out #or us. * method declaration consists o# the "ords method$ its
244260235.doc 238 od 541
ro" number in the method table$ #ollo"ed b% the method attributes that the Det0ethod*ttribute
#unction (ives us and "e store in the variable methodattribute.

This is #ollo"ed b% the return value attributes lie inIout #or "hich "e have a method
Det4aram*ttr#or0ethod+allin(. !e store this strin( in the paramattrstrin( variable. Then comes
the return t%pe that is stored in the methodde#returnarra%.

This is #ollo"ed b% the marshal e%"ord that is (ot b% the method
Det4aram*ttr#or0ethod0arshal and stored in the strin( parammarshalstrin(. 3astl% comes the
name o# the method. Dreat$ "e have #etched all these values be#ore and all that "e need to do
no" is strin( them to(ether.

,i(ht$ no "ron(. The problem is not o# spaces but o# the lo"l% enter. 'ldasm can use t"o or three
or #our lines to displa% the method de#inition. Thus "e no" need to #i(ure out "here the enters
are to be placed. This is "hat is the cause o# our troubles toda% and %ours "hile %ou read this
boo.

!e searched in heaven and hell and could not #ind the rules o# "here an enter must be placed. O%
trial and error "e hope that "e have succeeded. !e #irst remove the "ords instance #rom the
variable methodattribute. !e do this b% #irst usin( the method 'ndex/# "hich returns either [1 or
the position o# our strin( in the strin( "e are looin( #or.

'# the strin( is #ound$ "e remove the "ords instance usin( the ,emove method. The "ord static
ho"ever is le#t as is. This is because the "ords instance #ollo" the return value$ unlie static
"here the% remain separate.

!e can have a enter at #our di##erent places. >irst at the end o# the method attributes$ then a#ter
the return value. *n enter can also come a#ter the marshal e%"ord and #inall% be#ore the name o#
the #unction i# it is lar(er than a certain len(th.

Thus "e initiali&e three strin( variables that "ill store a space or an enter dependin( upon the
circumstance. To #i(ure out "here the enter needs be placed "e #irst need to no" the t%pe ro"
number that the method belon(s to. The parameter t%peindex is "hat contains the t%pe ro"
number #or us.

!e also need to no" the namespace the method is in i# an%. !e #irst assume that the t%pe is in
no namespace and hence "e can simpl% store in nspace the name o# the namespace (iven the
t%pe. !e have "ith us a method Det4arent>or)estedT%pe that (iven the t%pe tells us the parent
t%pe "hich "as covered earlier.

This #unction return either the parent t%pe o# a &ero. Thus i# variable parentt%pe is non &ero$ "e
have a nested t%pe and hence the nspace variable "ill contain the namespace o# the parent t%pe.

!e also #i(ured out the hard "a% that as mentioned earlier "here an enter came come so "e have
three Ooolean variables to tells "here the enters should happen. The variable cat2return i# true
tells us that this method should be on t"o lines "ith an enter a#ter the return value.

This means that the method attributes and the return value is on the same line. The second
Ooolean cat3returnvaluemarshal is #or those cases "here the method moves on to three lines and
an enter is needed a#ter the return value as "ell as the marshal e%"ord. The last cat4 is "hen the
method si(nature is over 4 lines.
244260235.doc 239 od 541

*#ter the method attribute$ return value as "ell as the marshal e%"ord. Oe#ore "e actuall% start$
there is a use#ul #unction called 2o"0an%0ethod*ttributes. !e #ound out that not onl% are the
enters decided b% "hether the t%pe is nested or not$ "hether it is "ithin a namespace or not but
also b% ho" man% method attributes there are.

Thus "e need a count o# the number o# attributes lie hideb%si( $ ne"slot$ specialname$
rtspecialname$ #inal$ virtual and abstract. !e have not counted attributes lie the access ones lie
public or static or pinvoeimpl. !e no" move on to #indin( out "hich cate(or% out o# our #our a
method belon(s to.

The #irst is "hen "e have the method on t"o lines and the enter must come a#ter the return value
placin( the method name on a ne" line or cat2retrun. To stress test our h%pothesis "e have used a
separate il #ile #or each test. 3ets start "ith public static as the onl% attributes #or our method.

'n our il #ile "e tr% it "ith #our possibilities. 'n a class "ith no namespace and no nestin($ in a
class that is placed "ithin a namespace $ in a class that is nested$ and #inall% a nested class as "ell
as in a namespace. !hat "e leaned that as lon( as the class does not have both a namespace and
is nested$ the cat2return "ill be true.

Thus the i# statement is true #or all cases but those "here both nspace is not null as "ell as the
t%pe is not nested. This case onl% applies i# the marshal e%"ord is absent or the variable
parammarshalstrin( is null. The private static and public static also #ollo" the same rules and
hence are not mentioned.

The deviation is assembl% static "here cat2return is true onl% is both the t%pe is not nested and
the namespace is empt%. Thus "e have reali&ed that there "as no consistenc% in "here the enters
are to be placed.

The next three i# statements chec "hether the method attribute is public virtual$ private virtual as
"ell as #amil% virtual and that both t%pe is not nested as "ell as the namespace is not null.
>ortunatel% the public ne"slot$ private ne"slot and #amil% ne"slot behave in the same "a%.

2o"ever #or public #inal #amil% #inal$ the namespace and nestin( is not relevant but #or private
#inal both namespace and nestin( cannot be true. !hen it comes to public abstract$ private
abstract and #amil% abstract$ there must be no nestin( and the namespace must be null.

The same rules also appl% to public hideb%si( and #amil% hideb%si( also. The last rule is prett%
di##erent. >irst the pinvoeimpl attribute must be absent. Then this must appl% to an instance
method and not a static one. >inall% there must be no attribute lie ne"slot$ #inal etc be present.

This can happen onl% i# the ho"man% variable is &ero. Thus lets loo at a speci#ic case.

.class t1
9
.method public void a158 9@
.method void a258 9@
@

.method IJ06000001JI public instance void
a15
244260235.doc 240 od 541
.method IJ06000002JI privatescope instance void
a2Z4;T060000025

Thus i# "e have no attributes other than the access modi#iers and privatescope is the de#ault #or
no access modi#er "e meet the last rule.

3ets move on to the second condition "here "e place the messa(e de#inition on three lines "ith a
enter a#ter the return values as "ell as a#ter the e%"ord marshal. This obviousl% assumes that the
e%"ord marshal is exists. 3ets tae the case o# the attributes public static but "ith the marshal
e%"ord present unlie earlier.

.class t1
9
.method public static void marshal5int32 8a158 9@
@
.namespace n1
9
.class t1
9
.method public static void marshal5int32 8 a258 9@
@
@
.class t2
9
.class t1
9
.method public static void marshal5int32 8 a358 9@
@
@
.namespace n1
9
.class t2
9
.class t1
9
.method public static 6in7 int8J marshal5int32 8 a458 9@
@
@
@

.method IJ06000001JI public static void
marshal5 int328
a15
.method IJ06000002JI public static void
marshal5 int328
a25
.method IJ06000003JI public static void
marshal5 int328
a35
.method IJ06000004JI public static
6in7 int8J
244260235.doc 241 od 541
marshal5 int328
a45

The same il #ile as be#ore no" "ith the marshal e%"ord added. The #irst three methods come on
three lines "ith a enter a#ter the return value and marshal e%"ord. !hen the class is nested as
"ell as the namespace is present$ the method #alls over #our lines.

The same rules appl% #or private static and #amil% static. The odd man out is al"a%s assembl%
static "here the t%pe must not be nested as "ell as the t%pe cannot be present "ithin a namespace.
The attributes public hideb%si( and #amil% hideb%si( are lie assembl% static. ;ome thin(s do not
chan(e.

The attributes public virtual are lie public static but "e have "ritten them as three separate
conditions instead o# one. Wou #i(ure out "hich one is better #or %ou to understand. The +S
compiler does not seem to care.

The last rule is lie the earlier case "here "e had a sin(le access attribute and nothin( else and a
instance #unction. ;ome similarit% "ith the cat2return case but not enou(h to (enerali&e them in
code.

3ets tae the case "here ever%thin( #alls over #our lines. This "ill set the cat4 variable to true.
The t"o (eneral conditions are that the marshal e%"ord must be present and the pinvoeimpl
attribute absent. The simple case o# public virtual sho"s the method de#inition over #our lines
onl% #or the most complex case$ nestin( and namespace.

.namespace n1
9
.class t2
9
.class t1
9
.method public virtual 6in7 int8J marshal5int32 8 a458 9@
@
@
@

.method IJ06000001JI public virtual
instance 6in7 int8J
marshal5 int328
a45

Thus the method de#inition is placed over #our lines.

The second case is more complex. 't starts "ith us havin( a sin(le access modi#ier as the
ho"man% variable is &ero. Then the t%pe must be nested and the namespace not empt% and the
method bein( static and not instance.

!e set the variable problem1 to true and this sets o## the cat4 variable bein( true. This is
demonstrated b% methods a1 and a2. The onl% problem is that it "ors #or attributes lie
privatescope and #amandassem and not #or assembl% static$ public static$ private static and #amil%
static.
244260235.doc 242 od 541

2ere "e have t"o #urther conditions that "ill set the problem1 variable to #alse and ne(ate the
cat4 variable bein( set to true. The #irst case is "hen the param attribute strin( is null. Thus
methods a3 and a4 have no param attributes lie in and out and thus problem1 is #alse and the
method do not #all over #our lines.

There are ho"ever cases "here the len(th o# the marshal t%pe matters$ but "e have i(nored them.

.namespace n1
9
.class t2
9
.class t1
9
.method static 6in7 int8J marshal5int32 8 a158 9@
.method #amandassem static 6in7 int8J marshal5int32 8 a258 9@
.method public static void marshal5int8 8 a358 9@
.method public static int8 JJ marshal5int32 8 a458 9@
@
@
@

.method IJ06000001JI privatescope static
6in7 int8J
marshal5 int328
a1Z4;T060000015
.method IJ06000002JI #amandassem static
6in7 int8J
marshal5 int328
a25
.method IJ06000003JI public static
void marshal5 int88 a35
.method IJ06000004JI public static
int8JJ marshal5 int328 a45

The complexities have 1ust started. '# the attributes contain a hideb%si( and "ithin this either
public or #amil%. 'n the #irst set o# the il #ile$ the t%pe is nested and both private and public are
seen over t"o lines. 4rivate is the normal case and public because it is either in a nested class or
in a namespace. 'n the second case$ the class is not nested or in a namespace and the private is on
#our lines but the public onl% on three.

.class t2
9
.class t1
9
.method private hideb%si( 6in7 int8J marshal5int32 8 a158 9@
.method public hideb%si( 6in7 int8J marshal5int32 8 a258 9@
@
@
.class t1
9
244260235.doc 243 od 541
.method private hideb%si( 6in7 int8J marshal5int32 8 a158 9@
.method public hideb%si( 6in7 int8J marshal5int32 8 a258 9@
@

.method IJ06000001JI private hideb%si(
instance 6in7 int8J
marshal5 int328
a15
.method IJ06000002JI public hideb%si(
instance 6in7 int8J
marshal5 int328
a25
.method IJ06000003JI private hideb%si(
instance 6in7 int8J
marshal5 int328
a15
.method IJ06000004JI public hideb%si( instance 6in7 int8J
marshal5 int328
a25

The #inal case is "hen "e have t"o or more than t"o attributes lie ne"slot$ virtual etc and "e
have a marshal e%"ord$ then ever%thin( #alls over three lines. )o" "e have to implement "hat
"e have doe so #ar.

Thus "e have a series o# i# statements that set the three strin( variables enter#ormethodattrbute$
enter#orreturnvalue and enter#ormarshal to their values. '# cat2return is true$ then there should be
nothin( a#ter the method attribute and "e set the enter#ormethodattrbute variable to null.

This also means that some later "e "ill concatenate the methodattribute variable "ith the
enter#ormethodattrbute variable and then concatenate the return value stored in the
methodde#returnarra% "ith the enter#orreturnvalue variable.

*s "e "ant an enter a#ter the return value "e set the enter#orreturnvalue to an enter #ollo"ed b%
spaces. These depend upon the nestin( level as "ell as the "ords .method. Then "e come to the
second case cat3returnvaluemarshal "here "e mae the strin( enter#ormethodattrbute null as no
enter a#ter the method attributes but "e need a enter a#ter the return value and the
enter#ormarshal.

>or the cat4 "e need an enter placed #or all the three variables. >inall% "e let %ou on a secret. The
most common occurrence is "hen the ever%thin( is placed on t"o lines "ith a enter a#ter the
method attribute. This places the return value on a ne" line alon( "ith the method name.

*s this occurs most o#ten "e put it in the #inal statement. This is "h% our code is s small as the
else taes care o# ever%thin( else. The il #ile has a small sample.

.class &&&
9
.method public ne"slot virtual #inal static 6in7 int8 JJa358
9
@
@
244260235.doc 244 od 541

.method IJ06000001JI public ne"slot static #inal virtual
6in7 int8JJ a35


The above occurs is the spoilt child and occurs "ith the maximum #re.uenc%. )o" "e
concatenate the strin(s as explained be#ore to the strin( methodstrin(. >inall% "e have to add the
last enter i# the len(th o# the strin( is lar(er than 44.

>or some reason ildasm does not lie the last line be#ore the method name to exceed 44. !e
chec the len(th o# the strin( to date and minus the last occurrence o# an enter. '# this value is
(reater than 44$ "e no" need to add a enter. Out be#ore "e do this$ "e have a space at the end o#
the line that "e need to remove and hence the ,emove method removes the last space.

Then "e add a ne" enter to the method strin(. *ll is not over a#ter addin( the name as i# this
methods attribute is privatescope$ "e have to add the "ords Z4;T "ith the ro" number o# the
method table. !e #inall% add the 5 bracet.

pro(ram36.csc.txt

methodstrin( A methodstrin( C F5F<
int len A 0<
i# 5 methodde#paramarra%6methodindex7 EA null8
9
int indexo#enter A methodstrin(.3ast'ndex/#5FUrUnF8<
int len(tho#strin( A methodstrin(.3en(th <
len A len(tho#strin( P indexo#enter P 2<
methodstrin( A methodstrin( C 4aram/n0ultiple3ines 5methodde#paramarra%6methodindex7 $
len 8<
@
else
methodstrin( A methodstrin( C methodde#paramarra%6methodindex7<
methodstrin( A methodstrin( C F8F<
strin( impl#la(s A Det0ethod*ttribute1 50ethod;truct6methodindex7.imp#la(s8<
methodstrin( A methodstrin( C F F C impl#la(s <
strin( methodsi(nature A Det0ethod;i(natureO%tes 5methodindex8<
methodstrin( A methodstrin( C methodsi(nature<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrestC spaces#ornested8 C F9F <
+onsole.!rite3ine5methodstrin( 8<
@
@
public strin( 4aram/n0ultiple3ines 5strin( paramstrin( $ int spaces8
9
i# 5 paramstrin( AA FF8
return FF<
i# 5 paramstrin( AA null8
return FF<
strin( returnstrin( A FF<
i# 5 paramstrin(.'ndex/#5F$F8 AA P1 8
9
paramstrin( A paramstrin(.,eplace5F`F $ F$F8<
244260235.doc 245 od 541
return paramstrin(<
@
char 67 chararra% A 9L$L@<
strin( 67 strin(arra% A paramstrin(.;plit5chararra%8<
returnstrin( A strin(arra%607 C F$F<
#or 5 int ii A 1 < ii B strin(arra%.3en(th < iiCC8
9
returnstrin( A returnstrin( C FUrUnF C +reate;paces5spaces8 C strin(arra%6ii7 <
i# 5 ii EA strin(arra%.3en(th P1 8
returnstrin( A returnstrin( C F$F<
@
returnstrin( A returnstrin(.,eplace5F`F $ F$F8<
return returnstrin(<
@
public strin( Det0ethod*ttribute1 5int method#la(s8
9
strin( returnstrin( A FF<
i# 5 5method#la(s G 0x00038 AA 0x00038
returnstrin( A returnstrin( C Fruntime F<
else
i# 5 5method#la(s G 0x00018 AA 0x00018
returnstrin( A returnstrin( C Fnative F<
else
returnstrin( A returnstrin( C Fcil F<
i# 5 5method#la(s G 0x00048 AA 0x00048
returnstrin( A returnstrin( C Funmana(edF<
else
returnstrin( A returnstrin( C Fmana(edF<
i# 5 5method#la(s G 0x00808 AA 0x00808
returnstrin( A returnstrin( C F preservesi(F<
i# 5 5method#la(s G 0x00108 AA 0x00108
returnstrin( A returnstrin( C F #or"ardre#F<
i# 5 5method#la(s G 0x010008 AA 0x10008
returnstrin( A returnstrin( C F internalcallF<
i# 5 5method#la(s G 0x00208 AA 0x00208
returnstrin( A returnstrin( C F s%nchroni&edF<
i# 5 5method#la(s G 0x00088 AA 0x00088
returnstrin( A returnstrin( C F noinlinin(F<
return returnstrin(<
@
public strin( Det0ethod;i(natureO%tes 5int methodro"8
9
strin( returnstrin( A FUrUnF C +reate;paces5spaces#orrestC spaces#ornested8 C FII ;'DM F<
int uncompressedb%te<
int si(natureindex A 0ethod;truct6methodro"7.si(nature<
int ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ si(natureindex$ out uncompressedb%te8<
int count A uncompressedb%te<
i# 5 ho"man%b%tes AA 28
countCC<
#or 5int 1 A ho"man%b%tes < 1 BA count < 1CC8
244260235.doc 246 od 541
9
returnstrin( A returnstrin( C blob6si(natureindex C 1 7.To;trin(5FK2F8 <
i# 5 1 EA count 8
returnstrin( A returnstrin( C F F<
@
return returnstrin(<
@

e.il
.class &&&
9
.method public ne"slot virtual #inal static 6in7 int8 JJaa5int8 ' $ int16 1$ int32 8
9
@
@

.method IJ06000001JI public ne"slot static #inal virtual
6in7 int8JJ aa5int8 '$
int16 1$
int32 8 cil mana(ed
II ;'DM 00 03 0> 0> 04 04 06 08
9

This pro(ram is much simpler than the previous one as "e are usin( it as a breather. The next one
obviousl% "ill be more problematic to understand. !e #irst place the 5 bracet and then "e have
to place the parameters to the method. '# the method has no parameter or a sin(le one ver% (ood.

'# it has more than one$ the second one on"ards comes on a ne" line "ith some spaces so that it
is indented one belo" the other. This "e onl% do i# "e have parameters and thus "e chec the
value o# the methodde#paramarra% bein( non null. !e #irst need to #ind out "here "e placed the
last enter.

This as explained earlier could be at a number o# places. !e then #i(ure out the len(th o# the
strin( so #ar and the number o# spaces "e need to place is the di##erence bet"een the t"o and "e
#urther need to subtract 2 #rom this. This is because the data t%pes have to line up one a(ainst the
other in a loc step #ashion.

Tain( the example o# method aa$ the last enter has been placed be#ore the name o# #unction and
the di##erence bet"een them "ill (ive us in this case the column number "here the t%pe name o#
the #irst parameter is to be placed. 3ooin( at it #rom another vie"point$ "e place the t%pe name
a#ter the name o# the method and the open bracet.

*#ter puttin( the last enter$ "e added some spaces$ "e then placed the name o# the method and a
open bracet. Then "e "rote the t%pe name. !e "ant to no" ho" man% characters "e placed
a#ter the last enter bearin( in mind that the enter is t"o characters.

!e no" pass the method 4aram/n0ultiple3ines the arra% methodde#paramarra% that contains
the parameters "ith commas and also the number o# spaces. *ll that "e "ant this method to do is
place a enter and len number o# spaces a#ter each comma and return such a strin( that "e
concatenate "ith methodstrin(.

244260235.doc 247 od 541
The #unction is prett% simple as "e #irst chec #or a null or empt% strin(. ,emember this #unction
(ets called #rom lots o# places. !e then chec "hether "e have a comma or not in our
paramstrin(. '# "e do not then it could onl% mean that "e have onl% a sin(le parameter and thus
"e do nothin(.

*t t"o places in this #unction "e replace a ` "ith a $ and "e "ill later explain "h%. )o"Qs not the
time and place. The ;trin( class lets us split a strin( on a series o# characters. !henever someone
"ants more than one "e can (ive it in an arra%.

Thus the split method re.uires an arra% o# chars and it "ill split the strin( into a series or arra%s
o# strin(s "henever that character is met. Thus in method aa as "e have three parameters and t"o
commas$ "e "ill (et an arra% o# three strin(s minus the commas. This happens as "e have placed
a comma in the chararra% arra%.

2ad "e also placed a semicolon$ the ;plit method "ould brea the strin( "henever it #ound a
comma or a semicolon. )o" "e start concatenatin( the strin( in the variable returnstrin( b%
simpl% initiali&in( it to the #irst member o# the arra% strin(arra% and placin( a comma.

Then "e (o in a loop and eep addin( to returnstrin( an enter and the number o# spaces "e had
calculated earlier. *s al"a%s "e add a comma onl% i# it is not the last member.

)o" "e add the close the bracet and then there are some more attributes that come at the end o#
the method name. !e have a method Det0ethod*ttribute1 that (ets us these attributes and there
is a separate #ield #or these attributes in the 0ethod table.

'# "e do not speci#% an attribute the de#ault is cil mana(ed. !e "ill delve on these attributes in a
short "hile. !e no" add these #inal attributes and no" "e need to displa% the method si(nature
"ithin comments on a #resh line.

!e have a method aptl% called Det0ethod;i(natureO%tes that does the "or #or us. This
si(nature "e "ill not explain as "e be(an the create method de# method "ith displa%in( these
b%tes o## the blob arra%.

!e onl% place a space i# it is not the last b%te$ the same "e do #or a comma. The reason "e
increment the count variable b% 1 i# the ho"man%b%tes variable is 2 as "e have taen t"o b%tes
#or the len(th o# the si(nature. !e also add a enter and a series o# spaces as "ell as the open the
brace.

e.il
.class &&&
9
.method int8 aa5int8 63...7$$$0...$457 i8
9
@
@

.method IJ06000001JI privatescope instance int8
aaZ4;T060000015int863...7$0$0$0$457 i8 cil mana(ed
II ;'DM 20 01 04 14 04 05 05 05 00 00 00 2= 05 06 00 00 00 00

244260235.doc 248 od 541
!hen "e "rote the #unction 4aram/n0ultiple3ines "e did not consider that an arra% data t%pe
can also have commas and in this case "e cannot brea at the commas. Thus "e needed to hide
the commas in the arra% data t%pe. ;o "e came up "ith an in(enious solution.

'n the Det*rra%T%pe #unction at three di##erent places "e add a comma to the return strin(. !e
simpl% replace these commas "ith a E si(n. *s an example "e replace the line returnstrin( A
returnstrin( C F$F< "ith returnstrin( A returnstrin( C F`F<.

Thus in the param method i# "e have a sin(le parameter "e have replace the E "ith a comma and
at the end. Then un#ortunatel% a return value can also have arra%s and hence the
methodde#returnarra% must also have all EQs replaced b% commas. Thus in the
+reate0ethod=e#;i(nature method "e must add the line returnt%pestrin( A
returnt%pestrin(.,eplace5F`F$F$F8<

This is the .uic and dirt% "a% o# "ritin( code. =o not thin about all the options at the
be(innin( and then eep main( chan(es and "atch the pro(ram (o berser at the "ron( time.
Thin #irst and then thin a(ain and then "rite code. >ree advise that no one heeds. )o" %ou
no" "hat slopp% pro(rammin( is all about.

4ro(ram37.csc
strin( methodsi(nature A Det0ethod;i(natureO%tes5methodindex8<
methodstrin( A methodstrin( C methodsi(nature<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrestC spaces#ornested8 C F9F <
int tablero" A entr%pointtoen G 0x00######<
i# 5 tablero" AA methodindex 8
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C
F.entr%pointF<
+onsole.!rite3ine5methodstrin(8<
II=ispla%+ustom*ttribute5F0ethod=e#F $ methodindex $ 2 C spaces#orrest C spaces#ornested8<
II+onsole.!rite5=ispla%4arams>or0ethod5methodindex88<
II=ispla%0ore4arams>or0ethod5methodindex8<
=ispla%*ll;ecurit%5 1 $ methodindex 8<
II=ispla%/verride0ethod5methodindex8< II inter#aces.exe
i# 5impl#la(s.'ndex/#5Fcil mana(edF8 AA P1 TT 0ethod;truct6methodindex7.rva AA 08
9
bool problem1 A true<
i# 5 methodattribute.'ndex/#5FpinvoeimplF8 EA P1 8
9
i# 5 methodattribute.'ndex/#5Fpinvoeimpl5IJ )o map JI8F8 EA P18
9
IIproblem is that "e cannot create one in ilasm because o# the )o 0ap and i# no map is not there
then else (ets called
+onsole.!rite3ine5F II :mbedded native codeF8<
+onsole.!rite3ine5F II =isassembl% o# native methods is not supported.F8<
+onsole.!rite3ine5F II 0ana(ed Tar(et,-* A 0x90@F $
0ethod;truct6methodindex7.rva.To;trin(5Fx4F88<
+onsole.!rite3ine5+reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o# (lobal method F
C )ame,eserved5Det;trin(50ethod;truct6methodindex7.name888<
@
else
9
244260235.doc 249 od 541
methodstrin( A +reate;paces5spaces#orrestC spaces#ornested8 C F@F <
+onsole.!rite5methodstrin(8<
@
methodstrin( A FF<
problem1 A #alse<
@
else i# 5impl#la(s.'ndex/#5Fruntime mana(edF8 EA P18
9
methodstrin( A FF<
@
else i# 5impl#la(s.'ndex/#5Fruntime unmana(edF8 EA P18
methodstrin( A F II 0ethod provided b% ,untimeUrUnF<
else i# 5impl#la(s.'ndex/#5Fnative unmana(edF8 EA P18
methodstrin( A F II Nnmana(ed Tar(et,-* A 0xF C
0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
else i# 5 impl#la(s.'ndex/#5FnativeF8 EA P18
9
methodstrin( A F II =isassembl% o# native methods is not supported.F<
methodstrin( A methodstrin( C FUrUn II 0ana(ed Tar(et,-* A 0xF C
0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
@
else i# 5 0ethod;truct6methodindex7.rva AA 0 GG impl#la(s.'ndex/#5Funmana(edF8 AA P1 8
9
methodstrin( A +reate;paces5spaces#orrestC spaces#ornested C 28 C FII 0ethod be(ins at ,-*
0x0UrUnF<
@
else
9
methodstrin( A FF<
@
i# 5problem18
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o#
method F C )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 C FMMF C
)ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C FUrUnF<
+onsole.!rite3ine5methodstrin(8<
continue<
@
methodstrin( A FF<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII 0ethod
be(ins at ,-* 0xF C 0ethod;truct6methodindex7.rva.To;trin(5Fx4F8<
+onsole.!rite5methodstrin(8<
@
@
@

e.il
.class abstract &&&
9
.method public static pinvoeimpl5Fuser32.dllF ansi stdcall lasterr 8 int8 a158 native unmana(ed
9
@
244260235.doc 250 od 541
.method static public int8 a058 cil mana(ed
9
.entr%point
@
.method public int8 a458 runtime mana(ed
9
@
.method public int8 a558 runtime unmana(ed
9
@
.method public int8 a658 native unmana(ed
9
@
.method public int8 a758 native mana(ed
9
@
.method abstract void a958 cil mana(ed
9
@
.method public int8 a858 cil unmana(ed
9
@
.method void a1058 cil mana(ed preservesi( #or"ardre# internalcall s%nchroni&ed noinlinin(
9
@
@
II.method public static pinvoeimpl5Fuser32.dllF ansi stdcall lasterr 8 int8 a258
II9
II@
II.method public static pinvoeimpl5IJ )o map JI8 unsi(ned int32 Rmain+,T;tartup58 native
unmana(ed preservesi(9@


/utput1
IIDlobal methods
IIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVV
.method IJ06000001JI public static pinvoeimpl5Fuser32.dllF ansi lasterr8
int8 a258 cil mana(ed
II ;'DM 00 00 04
9
@

/utput2
.class IJ02000002JI private abstract auto ansi &&&
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.method IJ06000001JI public static pinvoeimpl5Fuser32.dllF ansi lasterr8
int8 a158 native unmana(ed
II ;'DM 00 00 04
9
244260235.doc 251 od 541
@
.method IJ06000002JI public static int8
a058 cil mana(ed
II ;'DM 00 00 04
9
.entr%point
II 0ethod be(ins at ,-* 0x2051 .method IJ06000003JI public instance int8
a458 runtime mana(ed
II ;'DM 20 00 04
9
@ II end o# method &&&MMa4

.method IJ06000004JI public instance int8
a558 runtime unmana(ed
II ;'DM 20 00 04
9
II 0ethod provided b% ,untime
@ II end o# method &&&MMa5

.method IJ06000005JI public instance int8
a658 native unmana(ed
II ;'DM 20 00 04
9
II Nnmana(ed Tar(et,-* A 0x2054
@ II end o# method &&&MMa6

.method IJ06000006JI public instance int8
a758 native mana(ed
II ;'DM 20 00 04
9
II =isassembl% o# native methods is not supported.
II 0ana(ed Tar(et,-* A 0x2055
@ II end o# method &&&MMa7

.method IJ06000007JI privatescope abstract
instance void a9Z4;T0600000758 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x0
@ II end o# method &&&MMa9

.method IJ06000008JI public instance int8
a858 cil unmana(ed
II ;'DM 20 00 04
9
@ II end o# method &&&MMa8

.method IJ06000009JI privatescope instance void
a10Z4;T0600000958 cil mana(ed preservesi( #or"ardre# internalcall s%nchroni&ed
noinlinin(
II ;'DM 20 00 01
244260235.doc 252 od 541
9
II 0ethod be(ins at ,-* 0x0
@ II end o# method &&&MMa10

@ II end o# class &&&

'n this example "e once a(ain displa% some more details about a method. !e #irst "ant to no"
"hether the method is the #irst method to be called or does it have the entr%point directive
attached to it. ;ome %ears a(o "e explained the instance variable entr%point that "as stored in the
#irst metadata structure contained the ro" index o# the entr%point method.

!e thus noc o## the last or hi(h ei(ht bits and store the method ro" number in the tablero"
variable. !e then chec this value "ith the variable methodindex and i# "e #ind a match "e "rite
out the entr%point directive. Thus method a0 has the entr%point toen and this is "h% the method
is static.

!e then come across #our methods that are commented out and "e "ill deal "ith them in
separate pro(rams #ollo"in( this one. Too man% coos spoil the broth and too man% concepts in
one pro(ram (ives ?ac a splittin( headache. * method at the end also has attributes that are
divided into three cate(ories.

The #irst is the nature o# code and this can be #our o# "hich "e do three no". These are il$ native
and runtime. These are mutuall% exclusive. The attribute il is the normal one "hich sa%s the
obvious$ the code "e "rite is in the '3 pro(rammin( lan(ua(e "hich is the de#ault.

The problem is that usin( the pinvoeimpl e%"ord "e can speci#% that the code is some"here
else and hence in a another lan(ua(e and hence the attribute native. >or dele(ates$ the code is
supplied b% the s%stem and hence "e have the attribute runtime to describe it. Then "e have
another complication$ mana(ed or unmana(ed.

0ana(ed code is code "ritten in il that the s%stem (uarantees "ill brea no rules and hence is
sa#e to run. Nnmana(ed code is normall% code "ritten "ith pointers in +S and as no rules can be
en#orced on it$ the s%stem does not (uarantee that the code "ill brea no rules and hence
unmana(ed. Thus "e have six combinations$ all not valid.

Thus native mana(ed maes no sense as the code is some"here else and the s%stem ho"ever
cannot tae an% responsibilit% #or its (ood behavior. The problem as al"a%s is that nobod% chec
or nonsensical combinations. Then #inall% there are attributes lie noinlinin( that #all into their
o"n separate cate(or%.

The onl% attribute that carries code is the one "ith cil mana(ed. Thus "e need to trap those "here
the attribute is not cl mana(ed and also the rva #ield that tells us "here in memor% the code is
stored is stored #or this #unction is not &ero. '# this #ield is &ero$ then it onl% means that there is no
code #or this method.

!e #irst chec #or the attributes pinvoeimpl. 2ere "e a(ain mae a distinction on "hether the
method is (lobal or not. >unctions a1 and a2 have the pinvoeimpl attribute and a2 is (lobal
"hich means that it is outside a t%pe. 'n +S because o# ?ava$ #unctions outside a class or (lobal
are not permitted "hereas in il the% are.

244260235.doc 253 od 541
These are arti#icial rules that pro(rammin( lan(ua(es appl% #or no valid rh%me or reason. )o" i#
"e have alon( "ith the pinvoeimpl attribute a )o map value$ then "e are speci#%in( that there is
no dll that has the code #or this method. '# "e have such a method in our code$ ilasm (ives us an
error.

Out #or some reason there are scores o# pro(rams "ritten in other lan(ua(es that #or some reason
compile to an executable. /ne o# them is a #ile called is%m"rapper.dll. This .net executable "hen
run throu(h ildasm and then the out throu(h ilasm (ives us an error at the pinvoeimpl attribute.
The round trippin( does not "or at all.

Thus in the il #ile "e have a example commented out #or %ou to see the error that happens. '# the
pinvoeimpl attribute taes a )o 0ap attribute$ "e need to the displa% three lines alon( "ith the
rva #ield. '# the no map is absent all that "e do is simpl% displa% the closin( brace and nothin(
else.

!e also the methodstrin( attribute to empt% as "e have alread% used the !rite3ine #unction to
displa% its value alon( "ith the entr%point directive outside the i# statement. !e also set the
problem1 bool variable to #alse as it value b% de#ault is true. )o" there are some individual cases
to handle.

'# the impl#la(s are runtime mana(ed as in method a4 "e need no displa% an%thin( and hence the
methodstrin( variable is set to #alse. '# the attributes are runtime unmana(ed in #unction a5$ or
native unmana(ed method a6$ "e need to displa% another value. :lse i# it an% variation o# native
lie method a7 "e displa% another strin(.

Then i# the rva is &ero and not unmana(ed lie method a9 "hich is abstract and mana(ed "e have
one more i# statement to handle it. >inall% #or cases that do not #it in an% o# the above lie the
lies o# method a8 that does not have the abstract attribute "e have the #inal else that taes o#
ever% case "hich re.uires an empt% strin(.

0ethod a10 has all the extra attributes ta((ed alon(. >or all except the pinvoeimpl attribute "e
have not "ritten the "ords end o# method. Thus onl% i# variable problem1 is not set to #alse do "e
set the methodstrin( to the "ords end o# method.

!e then also "rite out the name o# the namespace and the name and in all these cases as there is
no code$ "e need to loop bac to the start o# the #or and the next method. '# "e do not enter this i#
statement$ it onl% means that "e have lots o# code and thus "e "rite out the rva o# the method
and then proceed to displa% the code that "e "ill displa% %ears #rom no". 3ots o# other more
important "or to be done #irst.

!e are also displa%in( one such pinvoeimpl attribute #rom the #ile is%m"rapper.dll "here it is a
(lobal method.

else i# 5 impl#la(s.'ndex/#5FoptilF8 EA P1 8
9
methodstrin( A +reate;paces5spaces#orrestC spaces#ornested C 28 C FII 0ethod be(ins at ,-*
0xF C 0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested C 28 C FII +ode si&e
0 50x08UrUnF<
@
else
244260235.doc 254 od 541
9
methodstrin( A FF<
@

e.il
.class &&&
9
.method void a158 optil mana(ed
9
@
@

/utput
.method IJ06000001JI privatescope instance void
a1Z4;T0600000158 optil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 0 50x08
@ II end o# method &&&MMa1

Det0ethod*ttribute1
i# 5 5method#la(s G 0x00028 AA 0x00028
returnstrin( A returnstrin( C Foptil F<
else
returnstrin( A returnstrin( C Fcil F<

There is one last reserved attribute optil that cannot carr% an% code. Thus in the
Det0ethod*ttribute1 "e simpl% chec "hether the value is 2 "hich is the code #or the attribute
optil. !e next add a i# statement to chec this value o# optil to add t"o lines o# code to our
method.


4ro(ram38.csc
public void =ispla%/verride0ethod 5int methodro"8
9
i# 5 0ethod'mp;truct AA null 8
return<
#or 5 int ii A 1 < ii B 0ethod'mp;truct.3en(th < iiCC8
9
strin( codedde#tablename A Det0ethod=e#Table 50ethod'mp;truct6ii7.codedde# 8<
int codedde#index A Det0ethod=e#-alue 50ethod'mp;truct6ii7.codedde# 8<
strin( codedbod%tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedbod%8<
int codedbod%index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedbod% 8<
II+onsole.!rite3ine5F...codedde#tablenameA90@
codedbod%tablenameA91@F$codedde#tablename$codedbod%tablename8<
int t%peindex A DetT%pe>or0ethod5codedbod%index8<
i# 5 t%peindex AA 0ethod'mp;truct6ii7.classindex GG codedbod%tablename AA F0ethod=e#F
GG codedbod%index AA methodro"8
9
i# 5codedde#tablename AA F0ethod,e#F 8
244260235.doc 255 od 541
9
+onsole.!rite5+reate;paces5spaces#orrestC2 C spaces#ornested88<
+onsole.!rite5F.override F8<
int t%pere#index A DetT%pe,e#>rom0ethod,e# 5codedde#index8<
+onsole.!rite3ine5F90@MM91@ IJ0192@MM0*93@JI F $ t%pere#names 6t%pere#index7$
)ame,eserved5Det;trin(50ember,e#;truct6codedde#index7.name88 $ t%pere#index
.To;trin(5FK6F8 $ codedde#index.To;trin(5FK6F88<
@
i# 5codedde#tablename AA F0ethod=e#F 8
9
+onsole.!rite5+reate;paces5spaces#orrestC2 C spaces#ornested88<
int t%pede#index A DetT%pe>or0ethod5codedde#index8<
strin( nestedt%pestrin( A FF<
nestedt%pestrin( A Det)estedT%pe*s;trin( 5t%pede#index8<
strin( nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#index7.nspace88<
i# 5 nspace EA FF8
nspace A nspace C F.F<
nspace A nestedt%pestrin( C nspace C
)ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#index7.name88<
+onsole.!rite5F.override 90@IJ 0291@ JIMM92@ F $ nspace$
t%pede#index.To;trin(5FK6F8$)ame,eserved5Det;trin(50ethod;truct6codedde#index7.name88 8<
+onsole.!rite3ine5FIJ0290@MM0691@JI F $ t%pede#index.To;trin(5FK6F8 $
codedde#index.To;trin(5FK6F88<
@
@
@
@
public int Det0ethod=e#-alue5int implcoded8
9
return implcoded HH 1<
@
public strin( Det0ethod=e#Table5int implcoded8
9
strin( returnstrin( A FF<
short ta( A 5short85implcoded G 5short80x018<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F0ethod,e#F<
return returnstrin(<
@
public int DetT%pe>or0ethod 5int methodro"8
9
int t%pede#index A 0<
#or 5 t%pede#index A 1 < t%pede#index B T%pe=e#;truct.3en(th P 1 < t%pede#indexCC8
9
int start A T%pe=e#;truct6t%pede#index7.mindex<
int end A T%pe=e#;truct6t%pede#indexC17.mindex P1 <
i# 5 methodro" HA start GG methodro" BA end8
return t%pede#index<
@
244260235.doc 256 od 541
return t%pede#index<
@
public int DetT%pe,e#>rom0ethod,e#5int methodre#ro"8
9
int memberre#codedindex A 0<
memberre#codedindex A 0ember,e#;truct6methodre#ro"7.clas<
strin( tablename A Det0ember,e#Table5memberre#codedindex8<
int t%pere#index A Det0ember,e#-alue5memberre#codedindex8<
return t%pere#index<
@
public strin( Det0ember,e#Table5int memberre#codedindex8
9
strin( returnstrin( A FF<
short ta( A 5short85memberre#codedindex G 5short80x078<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F)otNsedF<
i# 5 ta( AA 18
returnstrin( A returnstrin( C FT%pe,e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F0odule,e#F<
i# 5 ta( AA 38
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 48
returnstrin( A returnstrin( C FT%pe;pecF<
return returnstrin(<
@
public int Det0ember,e#-alue5int memberre#codedindex8
9
return memberre#codedindex HH 3<
@
@

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method void a158 native unmana(ed
9
.override &&&MMa2
.override 6vi1a%7%%%MMa3
@
.method void a258 runtime mana(ed
9
@
@

/utput
.class IJ02000002JI private auto ansi &&&
extends 6mscorlibIJ 23000002 JI7;%stem./b1ectIJ 01000001 JI
244260235.doc 257 od 541
9
.method IJ06000001JI privatescope instance void
a1Z4;T0600000158 native unmana(ed
II ;'DM 20 00 01
9
.override &&&IJ 02000002 JIMMa2 IJ02000002MM06000002JI
.override 6vi1a%IJ 23000001 JI7%%%IJ 01000002 JIMMa3 IJ01000002MM0*000001JI
II Nnmana(ed Tar(et,-* A 0x2050
@ II end o# method &&&MMa1

.method IJ06000002JI privatescope instance void
a2Z4;T0600000258 runtime mana(ed
II ;'DM 20 00 01
9
@ II end o# method &&&MMa2

@ II end o# class &&&

This pro(ram basicall% loos at the override e%"ord. This e%"ord can occur "ithin a class or a
method. The simpler version is #ound in the method and not in the class. *ll that the e%"ord
override does is speci#% a method that the method it is in "ill override. *s "e are in method a1
"e "ant this method to override method a2 in the same class.

'n the second override "e "ant this method a1 to override method a3 in class %%% assembl% vi1a%.
'n the pro(rammin( "orld "e have the concept o# a virtual #unction "hich speci#ies that there is
someone some"here "ho "ill override me. The 1ob o# the override e%"ord is to suppl% the
actual #unction.

The concept o# 4ol%morphisms is implemented usin( the override e%"ord. The lon(er o# the
override does the same thin( but as it is in a t%pe$ "e have to suppl% both the overridden #unction
and the #unction that "ill override it.

!e "ill #irst have to uncomment the method =ispla%/verride0ethod that is passed the method
ro" number as a parameter. :ach time "e use a override e%"ord a ro" (ets added to the
0ethod'mp;truct table. The #irst #ield i# this table is the codedde# #ield that is a coded index that
can store one o# t"o tables$ 0ethod=e# or 0ethod,e#.

!e use the dual methods Det0ethod=e#Table and Det0ethod=e#-alue to decipher the coded
index. This #ield simpl% tells us the name o# the method that "e "ant to override. The next #ield
codedbod% is a similar coded index but it tells us the method name that "ill override and in our
case it has to a 0ethod=e# as "e are "ritin( the override e%"ord in a actual method.

Thus decipherin( the codedbod% is o# reall% use to us as it "ill (ive us our method ro" number.
!e no" need to no" the t%pe that contains the override e%"ord as it is normall% stored in a
t%pe. !e #or(et to pass the t%pe this method belon(s to even thou(h "e have it in the
=ispla%*ll0ethods #unction.

!e use the DetT%pe>or0ethod to return the t%pe a method belon(s to (iven the method ro"
number. *ll that "e do in this method is scan all the t%pes that "e have present exceptin( the
last. !e then #i(ure out the #irst and the last method ro" number that this t%pe o"ns and hence
244260235.doc 258 od 541
"e subtract b% one. !e then chec i# our method #alls "ithin this ran(e and then return the t%pe
i# success#ul.

>inall% i# no match is #ound$ "e return the last t%pe number. !e complicated %our li#e b% brin(in(
this #unction as "e al"a%s have the method t%pe available. !e #irst chec three thin(s be#ore "e
do an%thin(. >irst the t%pe o# the method is in should match the classindex #ield that stores the
t%pe.

Then the codedbod%tablename must be 0ethod=e# and #inall% the methodro" parameter must
match the codedbod%index index #ield. '# these three conditions match "e are not %et home #ree
as "e could have either a 0ethod=e# or a 0ethod=e# method name a#ter the override e%"ord.

3ets tae the #irst override "here "e speci#% the name o# a method created b% us or "here the
codedde#tablename variable has a value o# 0ethod=e# the second i# statement. !e #irst "rite out
the spaces and once a(ain (et the t%pe #or this method. This is unnecessar% but the pro(ram
"ors.

!e then need the name o# the t%pe and as it can be nested$ "e tae our (ood old method
Det)estedT%pe*s;trin( to #i(ure the out all the nested t%pes i# an%. Then "e #i(ure the
namespace b% looin( at the nspace #ield o# the T%pe=e# arra% and 1oinin( then i# the namespace
is not null.

0ust have "ritten this code at least a &illion times b% no". Then "e #inall% add the name o# the
t%pe minus the nested t%pes. !e then "rite out the override e%"ord "ith the t%pe number in
comments and #inall% the method ro" number in comments. The interestin( part is "hen "e are
overridin( a method de#ined some"here else.

The second override activates the #irst i# statement "here the value o# variable
codedde#tablename is 0ethod,e# as "e are overridin( a method in the assembl% vi1a% that has a
class %%% and the method name is a3.!e as be#ore "rite out the initial spaces and the override
e%"ord.

!e no" use a method DetT%pe,e#>rom0ethod,e# that (ives us a t%pe index #rom the T%pe,e#
table as the variable codedde#index (ives us a ro" number in the 0ethod,e# table and not the
0ethod=e# table as be#ore.

/nce "e (et this T%pe,e# ro" number$ all that "e do is simpl% displa% the correspondin(
member o# the arra% t%pere#names that store the #ull #orm #rom the T%pe,e# table. ' hope %ou
no" appreciate all the trouble "e too in populatin( this t%pere#names arra%. ,emember "ithin
the s.uare bracets %ou can also have a module name etc.

/nce "e have the T%pe,e# name$ "e also displa% the name o# the method "hich is present in the
0ember,e# arra% and also the ro" number #rom the T%pe,e# and 0ember,e# tables. Thus all
that "e need to understand is ho" the method DetT%pe,e#>rom0ethod,e# does its 1ob. This
method is prett% simple as all that "e do is pic up the class #ield #rom the 0ember,e# arra%.

This #ield is a coded index as the class could reside in di##erent places. !e had spend a lot o# time
o# this earlier. The table name is reall% not necessar% and 1ust there #or debu((in( purposes and to
tell %ou "hat are the possible places a t%pe can be. !e ri(ht shi#t b% 3 to (et the T%pe,e# index
that "e simpl% return.

244260235.doc 259 od 541
!e "ill come bac to the more complex #orm o# override a little later and then deal "ith all the
di##erent table t%pes.

4ro(ram39.csc
public strin( =ispla%4arams>or0ethod 5int methodro"8
9
i# 5 4aram;truct AA null8
return FF<
strin( returnstrin( A FF<
i# 5+onstants;truct AA null8
return FF<
int startA0$ endA0<
start A 0ethod;truct6methodro"7.param<
i# 5 methodro" AA 50ethod;truct.3en(th P 188
end A 4aram;truct.3en(th <
else
end A 0ethod;truct6methodro"C17.param <
#or 5 int ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
strin( consttablename A Det2as+onstTable5+onstants;truct6ii7.parent8<
int constindex A Det2as+onst-alue5+onstants;truct6ii7.parent8<
i# 5 consttablename AA F4aram=e#F 8
9
i# 5 constindex HA start GG constindex B end GG start EA end8
9
int se. A 4aram;truct6constindex7.se.uence<
returnstrin( A returnstrin( C +reate;paces5spaces#orrestC spaces#ornestedC28 C F.param 6F C
se..To;trin(58 C F7F<
returnstrin( A returnstrin( C FIJ08F C constindex.To;trin(5FK6F8 C FJI A F <
int val1 A Oit+onverter.To'nt325blob $ +onstants;truct6ii7.valueC18<
i# 5 +onstants;truct6ii7.dt%pe AA 2 8
9
bool val A Oit+onverter.ToOoolean5blob $ +onstants;truct6ii7.valueC18<
i# 5 val 8
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5true8F C FUrUnF<
else
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5#alse8FC FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x03 8
9
int val A blob6+onstants;truct6ii7.valueC17<
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50xF C val.To;trin(5FK4F8 C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x04 TT +onstants;truct6ii7.dt%pe AA 0x058
9
int val A blob6+onstants;truct6ii7.valueC17<
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50xF C val.To;trin(5FK2F8 C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x06 TT +onstants;truct6ii7.dt%pe AA 0x07 8
244260235.doc 260 od 541
9
int val A Oit+onverter.To'nt165blob $ +onstants;truct6ii7.valueC18<
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50xF C val.To;trin(5FK4F8 C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x08 TT +onstants;truct6ii7.dt%pe AA 0x09 8
9
int val A Oit+onverter.To'nt325blob $ +onstants;truct6ii7.valueC18<
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50xF C val.To;trin(5FK8F8 C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x0a TT +onstants;truct6ii7.dt%pe AA 0x0b 8
9
lon( val A Oit+onverter.To'nt645blob $ +onstants;truct6ii7.valueC18<
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50xF C val.To;trin(5FKF8 C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0xc 8 II#loat32
9
double val A Oit+onverter.To=ouble5blob $ +onstants;truct6ii7.valueC18<
i# 5 val AA 0.100000000000000018
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50.100000000000000018F C
FUrUnF<
else
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5F C val.To;trin(58 C F.F C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0xd 8
9
double val A Oit+onverter.To=ouble5blob $ +onstants;truct6ii7.valueC18<
i# 5 val AA 0.100000000000000018
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F50.100000000000000018F C
FUrUnF<
else
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5F C val.To;trin(58 C F.F C
F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0xe 8
9
int len A blob6+onstants;truct6ii7.value7 <
i# 5 len HA 18
9
returnstrin( A returnstrin( C FUFF<
#or 5 int 11 A 1 < 11 B len < 11CC8
9
i# 5 blob6+onstants;truct6ii7.valueC117 EA 08
returnstrin( A returnstrin( C 5char8blob6+onstants;truct6ii7.valueC117<
@
returnstrin( A returnstrin( C FUFUrUnF <
@
else
244260235.doc 261 od 541
returnstrin( A returnstrin( C FUFUFF C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x12 8
9
returnstrin( A returnstrin( C Fnullre#F C FUrUnF<
@
@
@
@
return returnstrin(<
@
public int Det2as+onst-alue5int constcodedindex8
9
return constcodedindex HH 2<
@
public strin( Det2as+onstTable5int constcodedindex8
9
strin( returnstrin( A FF<
int ta( A constcodedindex G 0x03<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F>ield=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F4aram=e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F4ropert%F<
return returnstrin(<
@
@

e.il
.class &&&
9
.method void a15int32 i 8 native unmana(ed
9
.param617 A bool5true8
.param607 A int32518
.param627 A int325138
@
.method void a258 native unmana(ed
9
.param607 A int325118
.param617 A int325128
@
.method void a35int32 $ int32 $ int32$ int32 $ int32 $ int32$ int32$ int32$ int328 native unmana(ed
9
.param617 A char518
.param627 A int8528
.param637 A int16548
.param647 A int32558
.param657 A int64568
II.param667 A #loat3256.28
244260235.doc 262 od 541
II.param677 A #loat6457.28
.param687 A F*O+F
.param697 A nullre#
@
@

/utput
.class IJ02000002JI private auto ansi &&&
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.method IJ06000001JI privatescope instance void
a1Z4;T060000015int32 i8 native unmana(ed
II ;'DM 20 01 01 08
9
.param 617IJ08000001JI A bool5true8
II Nnmana(ed Tar(et,-* A 0x2050
@ II end o# method &&&MMa1

.method IJ06000002JI privatescope instance void
a2Z4;T0600000258 native unmana(ed
II ;'DM 20 00 01
9
II Nnmana(ed Tar(et,-* A 0x2051
@ II end o# method &&&MMa2

.method IJ06000003JI privatescope instance void
a3Z4;T060000035int32 *R0$
int32 *R1$
int32 *R2$
int32 *R3$
int32 *R4$
int32 *R5$
int32 *R6$
int32 *R7$
int32 *R88 native unmana(ed
II ;'DM 20 09 01 08 08 08 08 08 08 08 08 08
9
.param 617IJ08000002JI A char50x00018
.param 627IJ08000003JI A int850x028
.param 637IJ08000004JI A int1650x00048
.param 647IJ08000005JI A int3250x000000058
.param 657IJ08000006JI A int6450x68
.param 687IJ08000009JI A F*O+F
.param 697IJ0800000*JI A nullre#
II Nnmana(ed Tar(et,-* A 0x2052
@ II end o# method &&&MMa3

@ II end o# class &&&

'n this example lets tae a close loo at the param directive. This directive taes a number in
s.uare bracets that represents the parameter position. >or the #irst time "e count #rom 1 and not
244260235.doc 263 od 541
&ero. 'n the method a1 the param directive that has a value 0 and 2 does not sho" up as "e have
onl% one parameter.

Thus i# "e !rite an% erroneous param directives$ ilasm discards them. =itto #or method a2$ both
(et discarded. !onder "h% such error checs are not done al"a%s$ "ould mae our li#e much
easier. The param directive is used to (ive a param a value and hence the e.ual to si(n and a data
t%pe alon( "ith a value compatible "ith this data t%pe.

*ll the params constant values are stored in the +onstants table and our 1ob no" is to displa% all
the param directives$ the% can be more per #unction as method a3 demonstrates. * value o# &ero
stands #or or represents the return value.

The +3' maes sure that ever% parameter (ets a value but in lan(ua(es lie +CC i# a parameter
does not have a value$ it can (et a de#ault one. This is "here "e have the param directive. Thus i#
the parameter does not have a value$ the tool "ill use the param directive #or a value as the user
did not suppl% one.

Thus the +3' has a hands o## approach to the param directive and the compilers can do "hatever
the% lie "ith the param directive. !e no" uncomment the method =ispla%4arams>or0ethod
and pass it the method ro" number. This method is sli(htl% di##erent #rom the others as it returns
a strin( "ith a enter at the end.

Thus "e use the !rite and not the !rite3ine method to displa% it. The 0ethod;truct arra% tells
us the #irst and last parameter in the 4arams table that this method o"ns. *s al"a%s "e store these
values in the start and end variables respectivel%. )o" the +onstants table stores constants that
appear an%"here in our code.

Thus the parent #ield o# the +onstants table tells us usin( a coded index "hich table o"ns this
constant. !e have up to three possible o"ners$ a #ield$ propert% or a param. *s "e are interested
in onl% the param directive the #irst i# statement checs #or the parent name to be 4aram=e#.

The variable constindex "ill no" stand #or a ro" number in the 4aram table and i# it lies bet"een
start and end$ it is a param directive #or this method. '# start and end are the same$ then the
method o"ns no parameters.

>ortunatel% #or us the se.uence number is also the parameter number and hence "e "rite out the
param directive as "ell as the se.uence number in bracets and the 4aram table ro" number in
comments. Then "e place the e.ual to si(n to be #ollo"ed b% the data t%pe. The #ield dt%pe (ives
us the t%pe o# the data t%pe.

The +onstants table also has a #ield value that is an index into the blob heap "hich al"a%s be(ins
b% a len(th #ield. !e have al"a%s assumed that no one in his ri(ht mind "ill create a constant
lar(er than 127 b%tes. Thus i# the t%pe is 2$ then the data t%pe #ollo"s that o# method DetT%pe i.e.
a bool.

!e pic up the Ooolean value stored one more #rom the blob arra% due to the len(th and displa%
the "ords true or #alse. This is sho"n in method a1. Then movin( to method a3$ "e start "ith the
char data t%pe "hose dt%pe is 3. * value o# dt%pe 3 is that o# a b%te and hence "e pic up the
value directl%.

244260235.doc 264 od 541
!e also have to chose the #ormat t%pe x2 or x4 accordin(l%. The value 4 and 5 are that o# int8
"hich "e also read one b%te o# the blob arra%. 6 and 7 are #or int16 and 8 and 9 are #or in32. The
unsi(ned data t%pe (ives an error ad hence the clubbin(. >inall% 0xa and 0xb are #or int64.

'n each case "e use the relevant Oit+onverter method to read o## the blob arra%. The problem
"ith numbers "ith decimal places is ho" do "e displa% them. The ori(inal ildasm has been
"ritten in + and hence "e "ill "or "ith decimal numbers later. *ll that "e sa% is that dt%pe
values 0xc and 0xd are #or such numbers.

* value o# 0xe stands #or a strin( and hence "e loo at the #irst b%te the len(th b%te. '# it is lar(er
than 1 "e have a strin( that is not null or empt% and "e no" displa% the strin( in ascii i(norin(
the b%tes that are &eroes. !e also add a double inverted comma at the be(innin( and at the end
and use no data t%pe$ 1ust the strin(.

'# the strin( is a null strin($ "e simpl% displa% t"o double inverted commas "ith nothin( in
bet"een. >inall% a value o# 0x12 means the "ords nullre#. There are some special cases lie 0$ 1 $
0x# $ 0x11 "hose values are ille(al and hence "e have not accounted #or them.

*lso i# the strin( does not contain displa%able characters$ "e use the b%tearra% data t%pe instead.
This "ould loo lie
.param617 A b%tearra% 50+ 00 00 00 00 00 00 00 8
This is ho" the param directive is implemented and "e have not seen the last o# this directive.

4r(ram40.csc
4ublic void =ispla%*ll0ethods58
9

+onsole.!rite3ine5methodstrin(8<
continue<
@
strin( vtentr%strin( A Det-tentr%;trin(5methodindex8<
methodstrin( A vtentr%strin(<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII 0ethod
be(ins at ,-* 0xF C 0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII +ode
si&e 0 50x08F C FUrUnF<
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o#
method F C )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 C FMMF C
)ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C FUrUnF<
+onsole.!rite3ine5methodstrin(8<
@
@

int 67 methodvtentr%arra% <
public void ,eadand=ispla%-Table>ixup58
9
II+onsole.!rite3ine5F........90@F $ 0ethod;truct.3en(th 8<
i# 5 0ethod;truct AA null8
return<
methodvtentr%arra% A ne" int60ethod;truct.3en(th C 17<
#or 5 int 11 A 1 < 11 BA 0ethod;truct.3en(th < 11CC8
244260235.doc 265 od 541
methodvtentr%arra%6117 A 0<
i# 5 vtablerva EA 08
9
lon( save <
lon( position A +onvert,-*5vtablerva8 <
i# 5 position AA P18
return<
m#ilestream.4osition A position<
+onsole.!rite3ine5FII -Table>ixup =irector%MF8<
int count1 A vtablesi&eI8<
vt#ixuparra% A ne" strin(6count17<
#or 5 int ii A 0 < ii B count1 < iiCC8
9
vt#ixuparra%6ii7 A F.vt#ixup F<
int #ixuprva A mbinar%reader.,ead'nt3258<
+onsole.!rite3ine5FII '0*D:R+/,R-T*O3:>'KN4690@7MF $ ii8<
+onsole.!rite3ine5FII ,-*M 90@F$#ixuprva.To;trin(5Fx8F88<
short count A mbinar%reader.,ead'nt1658<
+onsole.!rite3ine5FII +ountM 90@F$ count.To;trin(5Fx4F88<
short t%pe A mbinar%reader.,ead'nt1658<
+onsole.!rite3ine5FII T%peM 90@F$ t%pe.To;trin(5Fx4F88<
save A m#ilestream.4osition<
m#ilestream.4osition A +onvert,-*5#ixuprva8 <
int i1 <
lon( 67 val A ne" lon(6count7 <
#or 5 i1 A 0 < i1 B count < i1CC8
9
i# 5 5t%peG0x018 AA 0x018
val6i17 A mbinar%reader.,ead'nt3258<
i# 5 5t%peG0x028 AA 0x028
val6i17 A mbinar%reader.,ead'nt6458<
i# 5 5t%peG0x018 AA 0x01 8
+onsole.!rite3ine5FII 690@7 591@8F$i1.To;trin(5Fx4F8 $ val6i17.To;trin(5FK8F88<
i# 5 5t%peG0x028 AA 0x028
+onsole.!rite3ine5FII 690@7 5 91@8F$i1.To;trin(5Fx4F8 $
5val6i17G0x########8.To;trin(5FKF88<
@
m#ilestream.4osition A save<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F6F C 5i18.To;trin(5FKF8 C F7 F<
i# 5 5t%peG0x018 AA 0x018
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fint32 F<
i# 5 5t%peG0x028 AA 0x028
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fint64 F<
i# 5 5t%peG0x048 AA 0x048
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F#romunmana(ed F<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fat =RF C #ixuprva.To;trin(5FK8F8<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F IIF<
#or 5 i1 A 0 < i1 B count < i1CC8
9
i# 5 5t%peG0x018 AA 0x018
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F F C val6i17.To;trin(5FK8F8<
244260235.doc 266 od 541
i# 5 5t%peG0x028 AA 0x028
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F F C val6i17.To;trin(5FK16F8<
@
lon( index A 0<
i# 5 val EA null8
index A val607 G 0x######<
methodvtentr%arra%6iiC17 A 5int8index<
@
+onsole.!rite3ine58<
@
@
public strin( Det-tentr%;trin( 5int methodro"8
9
strin( returnstrin( AFF<
int A Det-tentr%'nte(er5methodro"8<
i# 5 HA 18
returnstrin( A +reate;paces5spaces#orrestC28 C F.vtentr% F C .To;trin(58 C F M 1F C FUrUnF <
return returnstrin(<
@
public int Det-tentr%'nte(er 5int methodro"8
9
int ii <
#or 5 ii A 1 < ii B methodvtentr%arra%.3en(thP1 < iiCC8
9
i# 5 methodvtentr%arra%6ii7 AA methodro"8
brea<
@
i# 5 methodvtentr%arra%6ii7 AA 08
return 0<
else
return ii<
@
@


e.il
.vt#ixup 617 int32 #romunmana(ed at =R0000000
.vt#ixup 617 int32 #romunmana(ed at =R0000040
.vt#ixup 617 int32 #romunmana(ed at =R0000010
.vt#ixup 617 int32 #romunmana(ed at =R0000020
.data =R0000010 A b%tearra% 5 03 00 00 068
.data =R0000020 A b%tearra% 5 01 00 00 068
.data =R0000000 A b%tearra% 5 02 00 00 068
.data =R0000040 A b%tearra% 5 04 00 00 068
.class &&&
9
.method void a158
9
@
.method void a258
9
244260235.doc 267 od 541
@
.method void a358
9
@
.method void a458
9
@
.method void a558
9
@
@

/utput
.method IJ06000001JI privatescope instance void
a1Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
.vtentr% 4 M 1
@ II end o# method &&&MMa1

.method IJ06000002JI privatescope instance void
a2Z4;T0600000258 cil mana(ed
II ;'DM 20 00 01
9
.vtentr% 1 M 1
@ II end o# method &&&MMa2

.method IJ06000003JI privatescope instance void
a3Z4;T0600000358 cil mana(ed
II ;'DM 20 00 01
9
.vtentr% 3 M 1
@ II end o# method &&&MMa3

.method IJ06000004JI privatescope instance void
a4Z4;T0600000458 cil mana(ed
II ;'DM 20 00 01
9
.vtentr% 2 M 1
@ II end o# method &&&MMa4

.method IJ06000005JI privatescope instance void
a5Z4;T0600000558 cil mana(ed
II ;'DM 20 00 01
9
@ II end o# method &&&MMa5

>or one last time "e come bac to the #unction ,eadand=ispla%-Table>ixup. !e have displa%ed
the entire #unction a(ain as "e have added some more lines to it. !henever "e have the directive
vt#ixup$ "e also have in a method the directive vtentr%.

244260235.doc 268 od 541
This pro(ram does t"o thin(s$ it adds the vtentr% directive and also ends a cil mana(ed method.
*s o# no" "e "ill have no code in our methods and a little later "e "ill onl% #ocus on il code.
3ets (ets ever%thin( else out o# the "a%.

'n our il code "e have #our o# each$ #our vt#ixup directives$ #our data directives and #our methods.
'n the output "e have 4 vtentr% directives. 'n the il #ile as the #irst data directive is at =R0000000$
it re#ers to method 2 and the second data directive at =R0000040 to method 4. There is no
semblance o# order either in the data directives or the vt#ixupQs.

Thus in the output$ method a1 (ets a vtentr% directive "ith 4M1 $ the second method a2 vtentr% 1M1
and the third 3M1. The #irst chan(e "e have made is add a instance arra% o# ints called
methodvtentr%arra% and lie all arra%s in our pro(ram is one lar(er. Then "e set ever% member to
&ero in this arra%.

Then at the ver% end "e simpl% add the method ro" number to the arra%. '# %ou see the e.il #ile
a(ain$ the lot o# vt#ixupQs are all not ordered$ the data directives are also not ordered. The s%stem
#i(ures them as the order o# the data directives are not important as is the ro" number stored in
them. The arra% thus contains ro" numbers 2$4$3 and 1.

This is as the #irst vt#ixup directive has the data directive as =R00 "hich has ro" number 2. the
second vt#ixup is =R40 "hich is ro" 4 and the third is =R10 that is 3. Thus the vt#ixupQs decide
the method ro" numbers. This simpl% means that the method 2 "ill have a vtentr% o# 1 as this is
the #irst member o# the arra%$ the method 4 a vtentr% o# 2 as it is the second and the method 3 "ill
have a slot value o# 3 and #inall% method 1 slot 4.

!e no" call the Det-tentr%;trin( method that returns the vtentr% directive as a strin(. 2ere "e
call another method Det-tentr%'nte(er that simpl% returns a number and all that "e do is add the
directive vtentr% "ith this number and a colon "ith a 1. This "e do onl% o# "e are returned a non
&ero. >or method a5 "e "ill be returned a &ero as in the methodvtentr%arra% arra% there is no ro"
number 5 as one o# its values.

0ovin( to the Det-tentr%'nte(er method$ all that "e do here is scan the methodvtentr%arra% till
the 3en(th o# the arra% minus 1 and i# "e ever meet a match "here the methodro" variable has
the value o# an% o# our methodvtentr%arra% arra% members "e simpl% brea. )o" "e as "h%
did the brea happen.

'# it happened because the loop (ot over or because "e met a match. !e have t"o "a%s o#
.uittin( the loop. '# the value o# the methodvtentr%arra% arra% "as &ero then "e return &ero as
no match "as #ound. !e could have also checed "hether the value o# ii is e.ual to the len(th o#
the arra% minus 1.

:lse "e return the ii or the index member o# the methodvtentr%arra% arra% that has the matchin(
ro" number. This is the slot number "e use in the vtentr% directive.

4o(ram41.csc
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/verride5t%pede#index8<
244260235.doc 269 od 541
=ispla%*ll0ethods5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%/verride 5int t%pede#index8
9
i# 5 0ethod'mp;truct AA null 8
return<
#or 5 int ii A 1 < ii B 0ethod'mp;truct.3en(th < iiCC8
9
i# 5 t%pede#index AA 0ethod'mp;truct6ii7.classindex 8
9
strin( codede#tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedde# 8<
int codede#index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedde# 8<
strin( codebod%tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedbod%8<
int codebod%index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedbod% 8<
II+onsole.!rite3ine5F...codede#tablenameA90@ codebod%tablenameA91@ codede#indexA92@
codebod%indexA93@ F$codede#tablename $codebod%tablename$codede#index$codebod%index 8<
i# 5 codebod%tablenameAA F0ethod=e#F8
continue<
strin( #inals A FF<
i# 5 codede#tablename AA F0ethod=e#F 8
9
#inals A +reate;paces5spaces#orrest C spaces#ornested8<
#inals A #inals C F.override F <
int t%pede#methodindex A DetT%pe>or0ethod5codede#index8<
#inals A #inals C )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#methodindex 7.name88 <
#inals A #inals C FIJ 02F C t%pede#methodindex.To;trin(5FK6F8 C F JIMMF<
#inals A #inals C )ame,eserved5Det;trin(50ethod;truct6codede#index7.name88 C F "ithF<
@
else
9
#inals A +reate;paces5spaces#orrest C spaces#ornested8<
#inals A #inals C F.override F <
int t%pere#index A DetT%pe,e#>rom0ethod,e#5codede#index8<
#inals A #inals C t%pere#names6t%pere#index7 C FMMF<
#inals A #inals C )ame,eserved5Det;trin(50ember,e#;truct6codede#index7.name88 C F "ithF<
@
int t%pere#index1 A DetT%pe,e#>rom0ethod,e#5codebod%index8<
#inals A #inals C F F C methodre#t%pearra%6codebod%index7<
#inals A #inals C methodre#returnarra%6codebod%index7 C F F <
#inals A #inals C =ispla%T%pe,e#:xtends5t%pere#index18 C FMMF<
#inals A #inals C )ame,eserved5Det;trin(50ember,e#;truct6codebod%index7.name88 C F5F <
int len A #inals.3en(th<
strin( paramstrin( A 4aram/n0ultiple3ines5methodre#paramarra%16codebod%index7$ len8 <
#inals A #inals C paramstrin( C F8 IJ 0*F C codebod%index.To;trin(5FK6F8 C F JIF<
+onsole.!rite3ine5#inals8<
@
@
@
strin( 67 methodre#paramarra%1 <
strin( 67 methodre#returnarra% <
244260235.doc 270 od 541
strin( 67 methodre#t%pearra%<

public void +reate;i(natures 58
9
i# 50ethod;truct EA null8
9
methodde#paramarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra%1 A ne" strin(60ethod;truct.3en(th7<
methodde#returnarra% A ne" strin(60ethod;truct.3en(th7<
methodde#t%pearra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramcount A ne" int60ethod;truct.3en(th7<
#or 5 int l A 1 < l B 0ethod;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe51 $ 0ethod;truct6l7.si(nature$ l8<
@
@
II0ethod,e#Table
i# 5 0ember,e#;truct EA null 8
9
methodre#t%pearra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#returnarra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#paramarra%1 A ne" strin(60ember,e#;truct.3en(th7<
#or 5 int l A 1 < l B 0ember,e#;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe52 $ 0ember,e#;truct6l7.si($ l8<
@
@
@
public void +reate;i(nature>or:achT%pe 5b%te t%pe $ int index $ int ro"8
9
II+onsole.!rite3ine5F.......t%peA90@ ro"A91@ indexA92@ blob.3en(thA93@ 94@F $ t%pe $
ro".To;trin(5FKF8 $ 5ushort8index $ blob.3en(th $ 5uint8index8<
int uncompressedb%te $ count $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blob1 A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blob1 $ 0 $ count8<
i# 5 t%pe AA 18
+reate0ethod=e#;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 28
+reate0ethod,e#;i(nature5blob1 $ ro"8<
@
public void +reate0ethod,e#;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F+reate0ethod,e#;i(nature )ameA90@ ro"A91@ b.3en(thA92@F $
Det;trin(50ember,e#;truct6ro"7.name8$ ro"$ blobarra%.3en(th8<
int aa A P1<
i# 5 ro" AA aa8
9
+onsole.!rite3ine5Fro" number 90@ 91@F $ ro" $ Det;trin(50ember,e#;truct6ro"7.name88<
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
244260235.doc 271 od 541
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
int ho"man%b%tes$uncompressedb%te $ index<
index A 0<
ho"man%b%tesA +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
i# 5 uncompressedb%te AA 0x06 8
9
index A index C ho"man%b%tes<
methodre#returnarra%6ro"7 A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8<
return<
@
methodre#t%pearra%6ro"7 A =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<<
index A index C ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
count A uncompressedb%te<
index A index C ho"man%b%tes<
strin( t%pestrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes$ 0 $ FF8<
methodre#returnarra%6ro"7 A t%pestrin(<
index A index C ho"man%b%tes<
strin( returnstrin( A FF <
methodre#paramarra%16ro"7 A FF<
#or 5 int l A 1 < l BA count < lCC8
9
strin( sentinel A FF<
i# 5 blobarra%6index7 AA 0x418
9
sentinel A F...F C F$F <
index A index C 1<
@
t%pestrin( A sentinel C Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
index A index C ho"man%b%tes<
returnstrin( A returnstrin( C t%pestrin(<
i# 5 l EA count8
returnstrin( A returnstrin( C F$F <
@
i# 5 index B blobarra%.3en(th GG blobarra%6index7 AA 0x418
returnstrin( A returnstrin( C F$...F <
methodre#paramarra%16ro"7 A returnstrin(<
@

e.il
.assembl% extern vi1a%
9
@
.class inter#ace iii
9
.method public void aa58 cil mana(ed
9
@
@
244260235.doc 272 od 541
.namespace mmm
9
.class ccc
9
.method public void abc58
9
@
.method public void p.r58
9
@
.override iiiMMaa "ith instance void cccMMabc58
.override &&&MMp.r "ith instance void cccMMabc58
.override 6vi1a%7aaaMMp.r "ith instance void cccMMabc58
.override 6vi1a%7aaaMMp.r "ith instance void 6vi1a%7aaaMMiii5int32$...$int328
@
@

/utput
.namespace mmm
9
.class IJ02000003JI private auto ansi ccc
extends 6mscorlibIJ 23000002 JI7;%stem./b1ectIJ 01000001 JI
9
.override iiiIJ 02000002 JIMMaa "ith instance void cccIJ 01000002 JIMMabc58 IJ 0*000001 JI
.override &&&IJ 01000003 JIMMp.r "ith instance void cccIJ 01000002 JIMMabc58 IJ 0*000001 JI
.override 6vi1a%IJ 23000001 JI7aaaIJ 01000004 JIMMp.r "ith instance void cccIJ 01000002
JIMMabc58 IJ 0*000001 JI
.override 6vi1a%IJ 23000001 JI7aaaIJ 01000004 JIMMp.r "ith instance void 6vi1a%IJ 23000001
JI7aaaIJ 01000004 JIMMiii5int32$
...$
int328 IJ 0*000004 JI

:arlier "e "ored "ith the override directive that "e placed in a method and no" "e place them
in a t%pe. The #irst thin( "e need to do is add a line in the =ispla%/neT%pe method called
=ispla%/verride that "ill displa% all the overrides #or one t%pe.

The placement is important as all the override directives #or a t%pe are placed be#ore displa%in(
all the methods. The same basic rules that "e mentioned earlier appl% here also$ "hich is that a
record (ets added to the 0ethod'mpl table.

!e as be#ore chec "hether the classindex #ield carries the t%pe that "e are currentl% displa%in(.
!e need to understand once a(ain that "hen "e use the override directive$ "e #irst speci#% the
method "e "ant to override and then use the "ith clause to speci#% the method "e "ant to
override it "ith. *s "e are re#errin( to a method in the "ith clause$ this "ill al"a%s be a re#erence
to the 0ethod,e# table.

'n the earlier case there "as no "ith clause that "e sued "ith the override. Thus the codedbod%
#ield or the variable codebod%tablename "ill al"a%s represent the 0ember,e# table as earlier it
"as al"a%s 0ethod table.

244260235.doc 273 od 541
'n this case there#ore the variable codede#index taen #rom the coded index codebod%index "ill
al"a%s be a ro" number in the 0ember,e# table. Thus "e #irst chec i# the codebod%tablename
table has the value 0ethod=e# and i# so "e loop bac as the =ispla%/verride0ethod method "ill
handle it as it is a override directive "ithout the "ith clause and hence part o# a method and not
t%pe.

)o" the #irst method name that is represented b% the codedde# #ield ma% be either a 0ethod=e#
or a 0ember,e#. 3ets move to the il #ile #irst to understand "hich table value this #ield has. The
#irst override directive speci#ies the name o# a method aa that is an inter#ace iii.

!henever this case happens "e have a table value o# 0ethod=e#. 'n the second case$ even
thou(h "e speci#% a method p.r in the same class &&& this is a 0ethod,e# and not a 0ethod=e#
as "e "ould lie to understand. The last t"o are 0ember,e#Qs as the% are represents methods in
a *ssembl%.

Thus a 0ethod=e# onl% comes in "hen "e are dealin( "ith methods in a inter#ace and not
methods that "e have created ourselves. This is important as i# the variable codede#tablename is
0ethod=e#$ "e need to pic up the t%pe name #rom the T%pede# table and the method name #rom
the 0ethod table.

The codede#index is the ro" number in the 0ethod table and as "e need the t%pe it belon(s to "e
use the DetT%pe>or0ethod method to (ive us the t%pe.

/nce "e have the t%pe "e then simpl% displa% the t%pe name "ithout the namespace #or some
reason and then the t%pe ro" number in comments and the name o# the method #rom the 0ethod
table and #inall% the clause "ith. '# the else (ets called then "e no" that "e have a 0ember,e#
and hence "e use the method DetT%pe,e#>rom0ethod,e# that (ives us the ro" number o# this
method in the T%pe,e# table.

!e have done this method earlier in 4ro(ram38. !e use the t%pere#names arra% to displa% the
T%pe name and then the codede#index variable to displa% the name o# the method #rom the
0ember,e# table. )o" all that is le#t is the method name and t%pe a#ter the "ith clause and this
is a re#erence to the 0ember,e# table.

!e as be#ore (et the T%pe,e# table index usin( the codebod%index variable. !e then use the
methodre#t%pearra% that (ives us the t%pe i.e. instance or static #or the 0ember,e# method. This
is the same concept "e used #or the 0ethod table "here "e had three arra%s store the t%pe$ the
return value and the parameters.

The onl% di##erence is the "ords de# are replaced "ith re#. !e "ill sho" %ou in a short "hile ho"
similar are the 0ember,e# and 0ethod tables. !e then displa% the return value stored in the
methodre#returnarra% arra% and then the t%pe name #rom the T%pe,e# table usin( a method "e
used be#ore =ispla%T%pe,e#:xtends.

!e then add a colon and #inall% add the name o# the method #rom the 0ember,e# table. >inall%
the arra% methodre#paramarra%1 (ives us the parameters to the method and "e use the
4aram/n0ultiple3ines method to displa% then on di##erent lines. 0ost o# the code used here
#ortunatel% has been done be#ore.

244260235.doc 274 od 541
3ets no" loo at ho" "e populate the three re# arra%s. *s al"a%s "e de#ine three arra%s o# strin(s
as instance variables. Then "e in the +reate;i(natures method "e initiali&e these three arra%s to
the len(th o# the 0ember,e# table.

Then "e call the +reate;i(nature>or:achT%pe #unction once #or each ro" o# the 0ember,e#
table but "ith the #irst parameter as 2 and not 1 as #or the method table. !e also pass the si(
o##set in the blob heap. 'n the +reate;i(nature>or:achT%pe "e do nothin( di##erent that "hat "e
did earlier and call the +reate0ethod,e#;i(nature as the value o# the t%pe variable is 2 no".

'n this method +reate0ethod,e#;i(nature "e #irst chec #or the value o# the #irst b%te a#ter the
len(th to be 06 or not. '# it is then "e do not have a #ull method si(nature "ith parameters
#ollo"in( but onl% a data t%pe that "e set the methodre#returnarra% to. This is not a re#erence to a
method "ith parameters but onl% a return t%pe.

The number 6 is actuall% the t%pe #or #ields that "e "ill come to later. 3ie al"a%s "e have the
t%pe b%te that "e store in the methodre#t%pearra% arra% and then the count o# parameters #ollo"ed
b% the return t%pe that "e store in the methodre#returnarra% arra%.

Then "e loop in a #or statement to pic up the parameters and as "e are in a 0ember,e# "e have
no parameter names. The onl% addition is the use o# three dots or a sentinel X. This as explained
be#ore is used #or parameters "ith a variable number o# ar(uments. The t%pe #or a sentinel is 0x41
and i# "e meet one "e simpl% add three dots and a comma.

!e #inall% store the parameter list in the arra% methodre#paramarra%1. )o ma1or chan(es in "hat
"e have done earlier. The last override uses a sentinel. 'n case %ou did not notice both the arra%
t%pere#names and =ispla%T%pe,e#:xtends return the same result and could have been used in
place o# each other.

There is the lat i# statement that "e have not explained in the +reate0ethod,e#;i(nature. The
problem is that "hen "e encounter a sentinel$ this is not counted as a valid parameter. The count
member does not acno"led(e its presence. This is "h% "hen "e meet a sentinel$ "e simpl%
increase the index variable b% 1.

The problem is that i# the last parameter is the sentinel$ it does not (et added to the return strin(
variable at all. Thus "e have to chec "hen "e exit the #or$ are "e on the sentinel as "ell as "e
are not crossin( the bounds o# the arra%. * simple 0ember,e# "ith the si(nature b%tes "ill
clari#% matters #or us.

20 2 1 8 41 8
.override 6vi1a%7aaaMMp.r "ith instance void 6vi1a%7aaaMMiii5int32$...$int328

20 1 1 8 41
.override 6vi1a%7aaaMMabc "ith instance void 6vi1a%7aaaMMiii5int32$...8

'n the case o# the #irst override$ the iii method has t"o parameters as the second b%te o# the
si(nature tells us. The sentinel b%te 0x41 in the middle o# the t"o int32Qs does (et counted. 'n the
last override$ the sentinel b%te is at the ver% end and the count b%te is onl% 1.

4ro(ram42.csc
public strin( =ispla%>rom+onstantsTable5int start $ int end $strin( tablename 8
9
244260235.doc 275 od 541
strin( returnstrin( A FF<
#or 5 int ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
strin( consttablename A Det2as+onstTable5+onstants;truct6ii7.parent8<
int constindex A Det2as+onst-alue5+onstants;truct6ii7.parent8<
i# 5 consttablename AA tablename 8
9
i# 5 5constindex HA start GG constindex B end GG start EA end GG tablename AA F4aram=e#F 8 TT
5tablename AA F4ropert%F GG start AA constindex 8 8
9
int se. A 4aram;truct6constindex7.se.uence<
i# 5 tablename AA F4aram=e#F 8
9
returnstrin( A returnstrin( C +reate;paces5spaces#orrestC spaces#ornestedC28 C F.param 6F C
se..To;trin(58 C F7F<
returnstrin( A returnstrin( C FIJ08F C constindex.To;trin(5FK6F8 C FJI A F <
@
else
returnstrin( A F A F<
int val1 A Oit+onverter.To'nt325blob $ +onstants;truct6ii7.valueC18<
i# 5 +onstants;truct6ii7.dt%pe AA 2 8
9
bool val A Oit+onverter.ToOoolean5blob $ +onstants;truct6ii7.valueC18<
i# 5 val 8
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5true8F C FUrUnF<
else
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5#alse8FC FUrUnF<
@
@
@
@
return returnstrin(<
@
public strin( =ispla%4arams>or0ethod 5int methodro"8
9
i# 5 4aram;truct AA null8
return FF<
strin( returnstrin( A FF<
i# 5+onstants;truct AA null8
return FF<
int startA0$ endA0<
start A 0ethod;truct6methodro"7.param<
i# 5 methodro" AA 50ethod;truct.3en(th P 188
end A 4aram;truct.3en(th <
else
end A 0ethod;truct6methodro"C17.param<
returnstrin( A =ispla%>rom+onstantsTable5start $ end $F4aram=e#F8<
return returnstrin(<
@
public void =ispla%/neT%pe 5int t%pede#index8
9
244260235.doc 276 od 541
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%*ll;ecurit%5 0 $ t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/verride5t%pede#index8<
=ispla%*ll0ethods5t%pede#index8<
=ispla%*ll4roperties 5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@

strin( 67 propert%t%pearra%<
strin( 67 propert%returnarra% <
strin( 67 propert%parmarra%<

public void +reate;i(natures 58
9
II0ethodTable
i# 50ethod;truct EA null8
9
methodde#returnarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra%1 A ne" strin(60ethod;truct.3en(th7<
methodde#t%pearra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramcount A ne" int60ethod;truct.3en(th7<
#or 5 int l A 1 < l B 0ethod;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe51 $ 0ethod;truct6l7.si(nature$ l8<
@
@
II0ethod,e#Table
i# 5 0ember,e#;truct EA null 8
9
methodre#t%pearra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#returnarra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#paramarra%1 A ne" strin(60ember,e#;truct.3en(th7<
#or 5 int l A 1 < l B 0ember,e#;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe52 $ 0ember,e#;truct6l7.si($ l8<
@
@
IIpropert%table
i# 5 4ropert%;truct EA null 8
9
propert%parmarra% A ne" strin(64ropert%;truct.3en(th7<
propert%returnarra% A ne" strin(64ropert%;truct.3en(th7<
propert%t%pearra% A ne" strin(64ropert%;truct.3en(th7<
#or 5 int l A 1 < l B 4ropert%;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe 57$ 4ropert%;truct6l7.t%pe$ l8<
@
@
244260235.doc 277 od 541
@
public void +reate;i(nature>or:achT%pe 5b%te t%pe $ int index $ int ro"8
9
int uncompressedb%te $ count $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blob1 A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blob1 $ 0 $ count8<
i# 5 t%pe AA 78
+reate4ropert%;i(nature 5blob1 $ ro"8<
i# 5 t%pe AA 18
+reate0ethod=e#;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 28
+reate0ethod,e#;i(nature5blob1 $ ro"8<
@
public void +reate4ropert%;i(nature 5b%te 67 blobarra% $ int ro"8
9
int aa A P1<
i# 5 ro" AA aa8
9
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
int ho"man%b%tes $ uncompressedb%te<
int index A 0<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
i# 5 5uncompressedb%teG0x208 AA 0x208
propert%t%pearra% 6ro"7 A Finstance F<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
int count A uncompressedb%te<
strin( t%pestrin( A FF<
strin( returnstrin( A FF<
returnstrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
propert%returnarra% 6ro"7 A returnstrin(<
index A index C ho"man%b%tes<
returnstrin( A FF<
#or 5 int l A 1 < l BA count < lCC8
9
t%pestrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
returnstrin( A returnstrin( C t%pestrin(<
index A index C ho"man%b%tes<
i# 5 l EA count8
returnstrin( A returnstrin( C F$F<
@
propert%parmarra% 6ro"7 A returnstrin(<
@
public void =ispla%*ll4roperties 5int t%peindex8
9
244260235.doc 278 od 541
int ii<
i# 5 4ropert%0ap;truct AA null TT 4ropert%;truct AA null 8
return<
#or 5 ii A 1 < ii B 4ropert%0ap;truct.3en(th < iiCC8
9
i# 5 t%peindex AA 54ropert%0ap;truct6ii7.parent8 8
brea<
@
i# 5 ii AA 4ropert%0ap;truct.3en(th8
return<
int start A 4ropert%0ap;truct6ii7.propert%list<
int end<
i# 5 iiC1 AA 4ropert%0ap;truct.3en(th 8
end A 4ropert%;truct.3en(th P 1<
else
end A 4ropert%0ap;truct6ii C 17.propert%list P1<
#or 5 int propert%ro" A start < propert%ro" BA end < propert%ro"CC8
9
strin( returnstrin( A +reate;paces5spaces#orrest C spaces#ornested8<
returnstrin( A returnstrin( C F.propert% IJ17F C propert%ro".To;trin(5FK6F8 C FJI F<
strin( name A )ame,eserved5Det;trin(54ropert%;truct6propert%ro"7.name88 <
int #la(s A 4ropert%;truct6propert%ro"7.#la(s<
strin( propert%attribute A Det4ropert%*ttribute 5#la(s 8<
returnstrin( A returnstrin( C propert%attribute C propert%t%pearra%6propert%ro"7 C
propert%returnarra%6propert%ro"7 <
i# 5 returnstrin(.3en(th HA 41 8
returnstrin( A returnstrin( C FUrUnF C +reate;paces5spaces#orrest C spaces#ornested8C
+reate;paces578<
returnstrin( A returnstrin( C F F C name C F5F <
int len A returnstrin(.3en(th<
int len1 A returnstrin(.3ast'ndex/#5FUrUnF8<
i# 5 len1 AA P18
len1 A P2<
strin( dumm% A 4aram/n0ultiple3ines 5propert%parmarra%6propert%ro"7$ lenPlen1P28<
returnstrin( A returnstrin( C dumm% C F8F<
returnstrin( A returnstrin( C Det4ropert%*ttribute=e#ault 5#la(s$ propert%ro"8<
+onsole.!rite3ine5returnstrin(8<

+onsole.!rite3ine5+reate;paces5spaces#orrest C spaces#ornested8 C F9F8<
#or 5 int A 1 < B 0ethod;emantics;truct.3en(th < CC8
9
strin( attributes A Det0ethod;emantics*ttributes
50ethod;emantics;truct67.methodsemanticsattributes8<
strin( table A Det2as;emanticsTable 50ethod;emantics;truct67.association8<
int propert%index A Det2as;emantics-alue 50ethod;emantics;truct67.association8<
int methodindex A 0ethod;emantics;truct67.methodindex<
strin( methodattribute A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $ methodindex8<
strin( paramstrin( A methodde#paramarra%16methodindex7<
i# 5 propert%index AA propert%ro" GG table AA F4ropert%F 8
9
strin( dumm%1 A +reate;paces5spaces#orrest C 2 C spaces#ornested8<
244260235.doc 279 od 541
dumm%1 A dumm%1 C attributes C F IJ06F C methodindex.To;trin(5FK6F8 C FJI F C
methodde#t%pearra% 6methodindex7 C methodde#returnarra%6methodindex7<
strin( nestedt%pestrin( A Det)estedT%pe*s;trin( 5t%peindex8<
strin( name1 A )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C F5F<
strin( nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
i# 5 nspace EA FF8
nspace A nspace C F.F<
strin( dumm%2 A dumm%1 C nestedt%pestrin( C nspace C
)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 C FIJ 02F C
t%peindex.To;trin(5FK6F8 C F JIMMF C name1<
int dumm%int A dumm%2.'ndex/#5F5F8<
strin( dumm%3 A 4aram/n0ultiple3ines5paramstrin( $ dumm%int C 18 <
dumm%3 A dumm%3 C F8F C F IJ 06F C 5methodindex8.To;trin(5FK6F8 C F JIF<
+onsole.!rite3ine5dumm%2 C dumm%38<
@
@
+onsole.!rite5+reate;paces5spaces#orrest C spaces#ornested88<
+onsole.!rite5F@ F8<
+onsole.!rite3ine5FII end o# propert% 90@MM91@F $
)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 $ name8<
@
@
public strin( Det2as;emanticsTable5int asscoiationb%te8
9
strin( returnstrin( A FF<
int ta( A asscoiationb%te G 0x01<
i# 5 ta( AA 0 8
returnstrin( A returnstrin( C F:ventF<
i# 5 ta( AA 1 8
returnstrin( A returnstrin( C F4ropert%F<
return returnstrin(<
@
public int Det2as;emantics-alue5int asscoiationb%te8
9
return asscoiationb%te HH 1<
@
public strin( Det0ethod;emantics*ttributes5short asscoiationb%te8
9
strin( returnstrin( A FF<
i# 5 5asscoiationb%te G 0x018 AA 0x018
returnstrin( A returnstrin( C F.setF<
i# 5 5asscoiationb%te G 0x028 AA 0x028
returnstrin( A returnstrin( C F.(etF<
i# 5 5asscoiationb%te G 0x048 AA 0x048
returnstrin( A returnstrin( C F.otherF<
i# 5 5asscoiationb%te G 0x088 AA 0x088
returnstrin( A returnstrin( C F:vent *ddonF<
i# 5 5asscoiationb%te G 0x108 AA 0x108
returnstrin( A returnstrin( C F:vent ,emoveF<
i# 5 5asscoiationb%te G 0x208 AA 0x208
returnstrin( A returnstrin( C F:vent >ireF<
244260235.doc 280 od 541
return returnstrin(<
@
public strin( Det4ropert%*ttribute5int #la(s 8
9
strin( returnstrin( A FF<
i# 5 5#la(sG0x2008 AA 0x200 8
returnstrin( A returnstrin( C Fspecialname F<
i# 5 5#la(sG0x4008 AA 0x400 8
returnstrin( A returnstrin( C Frtspecialname F<
return returnstrin( <
@
public strin( Det4ropert%*ttribute=e#ault5int #la(s$ int ro"8
9
strin( returnstrin( A FF<
i# 5 5#la(sG0x10008 AA 0x10008
9
returnstrin( A =ispla%>rom+onstantsTable 5 ro" $ 0 $F4ropert%F8<
returnstrin( A returnstrin(.,emove5returnstrin(.3en(thP2$28<
@
return returnstrin(<
@
@

e.il
.class &&&
9
.method public static int32 a158
9
@
.method public instance void a25int32 LvalueL8
9
@
.method public instance void a358
9
@
.method public static int32 a458
9
@
.propert% rtspecialname specialname instance class &&& aa5int32 $ int64 $ int88 A int325108
9
.(et int32 &&&MMa158
.set instance void &&&MMa25int328
.other instance void &&&MMa358
@
.propert% int32 bb58
9
.(et int32 &&&MMa458
@
@


244260235.doc 281 od 541
/utput
.propert% IJ17000001JI specialname instance class &&&IJ 02000002 JI
aa5int32$
int64$
int88 A int3250x0000000*8
9
.(et IJ06000001JI int32 &&&IJ 02000002 JIMMa158 IJ 06000001 JI
.set IJ06000002JI instance void &&&IJ 02000002 JIMMa25int328 IJ 06000002 JI
.other IJ06000003JI instance void &&&IJ 02000002 JIMMa358 IJ 06000003 JI
@ II end o# propert% &&&MMaa
.propert% IJ17000002JI int32 bb58
9
.(et IJ06000004JI int32 &&&IJ 02000002 JIMMa458 IJ 06000004 JI
@ II end o# propert% &&&MMbb


This example "ill displa% all the properties that "e have in our t%pe. There is reall% no concept o#
a propert% in il. 'n +S$ a propert% loos lie$ "als lie$ tals lie a variable. '# "e have no access
to source code$ there is no "a% o# no"in( "hether a entit% is a propert% or a variable.

The concept o# properties is touted as one o# the ma1or #eatures o# the +S pro(rammin( lan(ua(e.
!hen +S code (ets converted to il$ the propert% aa (ets converted to t"o methods (etRaa and
setRaa. !henever "e set the value o# a propert% $ the setRaa method replaces the settin( o# the
propert% in our '3 code.

'n the same vein "hen "e access a propert% value$ this (ets replaced b% a call to the (etRaa
method that returns the value o# the propert%. The setRaa method (ets called "ith a parameter
value that contains the ne" value o# our propert%. Thus properties in il are nothin( but t"o
method calls.

2o"ever in '3 "e have a propert% directive "hich "e "ill no" discuss. Out be#ore that a small
chan(e. ;ome pro(rams above "e displa%ed the param e%"ord that had a value taen #rom the
+onstants table. Thus in the #unction =ispla%4arams>or0ethod "e #irst #i(ured out the param
numbers that our method o"ned and then displa%ed the value #rom the constants table.

*t that time "e #or(et that the constants table is also used b% t"o other directives$ one the
properties directive and the other the #ields directive. Thus "e did not "ant to repeat the same
code to retrieve the constants value #rom the constants table and thus broe up the
=ispla%4arams>or0ethod into t"o methods.

'n this method "e #irst #i(ure out the start and end param numbers and then call the
=ispla%>rom+onstantsTable method "ith the last strin( parameter bein( 4aram=e# and the #irst
and second parameter bein( the start and end param numbers o"ned b% this method.

Then in the =ispla%>rom+onstantsTable "e simpl% displa% the value #rom the constants table. 't
is this method that "e "ill call once a(ain a little later. !e then move our #ocus to the method
=ispla%/neT%pe "here "e have added a method =ispla%*ll4roperties that "ill displa% #or us all
the properties associated "ith a t%pe.

Out be#ore "e come to this method "e need to #ocus on the +reate;i(natures method "here "e
populate the strin( arra%s associated "ith properties. *s al"a%s "e initiali&e the three strin(
244260235.doc 282 od 541
arra%s dependin( upon the len(th o# the 4ropert% table. This table has one ro" #or ever% propert%
directive present in the il code.

The variable propert%parmarra% "ill contain the parameters that a propert% can carr%$ the
propert%returnarra% the return value$ methodre#t%pearra% the t%pe o# method instance or a null i#
static. !e then call the +reate;i(nature>or:achT%pe "ith a value o# 7 that stands #or a propert%.

'n this method "e simpl% call the +reate4ropert%;i(nature method that populates the above three
strin( arra%s. 'n this case "e call the #ield that holds the si(nature t%pe and not si( 1ust #or a
chan(e o# scene. The propert% si(nature is much simpler to understand than the t"o that "e did
earlier.

The #irst b%te "ill contain the value 0x8 to si(ni#% a propert%. This b%te "ill have 0x20 set i# it is
a instance method and static is not permitted. Thus a value o# 0x28 si(ni#ies the presence o#
instance .!e #irst chec the value o# the #irst b%te #or the presence o# instance or 0x20 and i# %es
"e set the correspondin( ro" o# the propert%t%pearra% to instance.

The next b%te is the count o# parameters. This is #ollo"ed b% the return t%pe that "e store in the
propert%returnarra% arra%. Then a #or loop "e read all the propert% parameters in the
propert%parmarra% arra%. 't is in the =ispla%*ll4roperties method that "e actuall% displa% the
properties directive.

Out #irst lets loo at all the tables that "ill be populated b% our propert% e%"ord. *s "e have
t"o properties aa and bb the 4ropert% table "ill have t"o records onl%. This table has three #ields$
t%pe that "e sa" earlier$ then the name #ield and #inall% the #la(s #ield that store one o# three #la(s
that "e "ill soon decipher.

The propert% is associated "ith a t%pe and a t%pe can have more than one propert%. Thus
properties behave lie methods and lo(icall% should have been stored in the T%pe=e# table lie
methods are. Nn#ortunatel% properties are not as common as methods and thus a ne" table
4ropert%0ap (ot created "hich stores "hich properties are associated "ith "hich t%pe.

This table has t"o #ields$ the T%pe=e# that o"ns the propert% and the startin( propert% number.
Thus "e have to read this table to #i(ure out the #irst and last propert% that is o"ned b% the t%pe.
This is "h% in the =ispla%*ll4roperties method "e (et the variables start and end b% readin( the
4ropert%0ap table.

)o" that "e have the startin( and end propert% ro" numbers "e in a #or loop use the
propert%ro" variable to iterate thou(h all o# them. '# "e start b% placin( the spaces$ the "ords
propert% $ the propert% ro" number in comments and then the name o# the propert%.

)o" "e use the method Det4ropert%*ttribute to #i(ure out "hich o# the #la(s the propert% has. *
value o# 0x200 means that "e have used the #la( specialname and the value 0x400 rtspecialname.
The value 0x1000 is #or havin( a de#ault value that "e displa% a#ter the properties parameters are
displa%ed.

This de#ault "ill be handled b% a di##erent method. Thus "e thou(ht that the Det4ropert%*ttribute
"ill be eas% to understand. There is one problem. The rtspecialname attribute i# placed b% us$ is
i(nored b% ilasm and thus #or propert% aa$ the #la(s value is not 0x600
"hich means both attributes but onl% 0x200 that means specialname.

244260235.doc 283 od 541
2o"ever i# "e (o into the dll and chan(e the value to 0x600$ then ildasm displa%s both
specialname and rtspecialname. O% no" %ou understand the depth "e have (one to mae our
boo as complete as possible but "e can (uarantee %ou ma1or (oo# ups. !e then add this attribute
and t%pe o# the propert% alon( "ith the return value and then stop.

This is because i# the len(th o# all this is be%ond 41 characters$ then "e need to put an enter to
place ever%thin( else lie the name and parameters on a ne" line. )o" "e add the name o# the
propert% and the open bracets and then need the parameters "hich i# more than one have to be
placed on a ne" line.

!e use the 4aram/n0ultiple3ines to do this #or us but it re.uires the number o# spaces to be
placed be#ore each parameter. !e #irst calculate the len(th o# the propert% strin( up to the open
bracet and then also #ind out the last enter placed.

The number o# spaces is lie be#ore$ the len(th so #ar minus the last enter minus 2 #or the enter.
2o"ever in most cases unlie methods there "ill be no enter placed and here "e simpl% subtract
2 #or the ali(nment. !e then "rite call the method Det4ropert%*ttribute=e#ault to "rite out the
constant value that the propert% has been initiali&ed to.

!e pass it t"o parameters$ the #la(s and the propert% ro" number. !e #irst chec i# the de#ault
#la( o# 0x1000 is turned on or not. '# it is "e next call the =ispla%>rom+onstantsTable "ith the
#irst parameter as the propert% ro" number or start$ the second parameter as &ero as the end has
no meanin( here and the third bein( 4ropert% as this constant ro" is o"ned b% the propert% table.

+omin( to the =ispla%>rom+onstantsTable method "e no" have an or in the i# statement. The
#irst (ets activated #or the 4aram=e# value$ the second #or i# the constindex variable has a ro"
number e.ual to the propert% ro" number passed and i# the tablename parameter is 4ropert%. *lso
"e have one more i# statement that chec a(ain #or the table name.

'# it is 4aram=e# then "e need the "ords param and id it is 4ropert% "e onl% need the e.ual to
si(n. !hen "e leave this #unction$ "e have added an enter and thus "e need to remove this enter
usin( the ,emove method.

)ormall% the de#ault value #or a propert% is rarel% seen or used. )ormall% a propert% can have as
man% as three directives "ithin it$ a .(et$ a .set or a .other. These attributes are stored in the table
0ethod;emantics. This table is also used b% events "hich the next pro(ram "ill demonstrate.

Thus as "e have a total o# #our directives "ithin our t"o properties$ this table "ill have #our
records. The #ield attributes tells us "hich o# the directives "e have used. The method
Det0ethod;emantics*ttributes tells us that "e can have as man% as six attributes$ three #or
properties as mentioned earlier and three #or events.

The #ield association tells is "hether this ro" is o"ned b% a event or a propert% and the
Det2as;emanticsTable returns one o# these value and the Det2as;emantics-alue method in our
case the propert% ro" number.

!e need the propert% ro" number as the 0ethod;emantics table most important role is to (ive us
the method that "ill handle the (et$ set or the other. Thus "e do not have to search the method
table #or the matchin( method name as there is no rule that sa%s that a set directive #or a propert%
aa must have the method name as setRaa.

244260235.doc 284 od 541
Thus the methodindex variable (ives us the method name that "e "ill displa% a#ter the directive.
Thus "e scan the entire 0ethod;emantics table and chec i# the table variable is 4ropert% and the
propert%index is our propert% number.

!e #irst "rite out the spaces and then the directive stored in the attributes variable and then the
method ro" number in comments. Then "e use the methodde#t%pearra% to "rite out the "ords
instance #or the method$ and then the return value.

!e next use the Det)estedT%pe*s;trin( to (et the name o# the t%pe and then the name and
namespace. !e then 1oin these to(ether and "rite out the T%pe=e# table ro" number. !e #inall%
"rite out the params o# this method and then the end o# the braces and the "ords end o# propert%.
* propert% cannot re#er to an method de#ined in another assembl%.

There are also a million rules that speci#% "hat the parameters to the (et$ set and the propert%
should have. !e have broen all the rules to stress test our pro(ram and ilasm does not seem to
implement these rules. /ver to events.

4ro(ram43.csc

public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%*ll;ecurit%5 0 $ t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/verride5t%pede#index8<
=ispla%*ll0ethods5t%pede#index8<
=ispla%*ll:vents 5t%pede#index8<
=ispla%*ll4roperties5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%*ll:vents 5int t%peindex8
9
int ii<
i# 5 :vent0ap;truct AA null 8
return<
#or 5 ii A 1 < ii B :vent0ap;truct.3en(th < iiCC8
9
i# 5 t%peindex AA 5:vent0ap;truct6ii7.index 8 8
brea<
@
i# 5 ii AA :vent0ap;truct.3en(th8
return<
int start A :vent0ap;truct6ii7.eindex<
int end<
i# 5 ii AA :vent0ap;truct.3en(th P1 8
end A :vent;truct.3en(th P 1<
else
end A :vent0ap;truct6ii C 17.eindex P1<
#or 5 int eventro" A start < eventro" BA end < eventro"CC8
9
244260235.doc 285 od 541
+onsole.!rite5+reate;paces5spaces#orrest C spaces#ornested88<
+onsole.!rite5F.event IJ1490@JI 91@F $ 5eventro"8.To;trin(5FK6F8 $
Det4ropert%*ttribute5 :vent;truct6eventro"7.attr88<
strin( name A )ame,eserved5Det;trin(5:vent;truct6eventro"7.name88 <
strin( codedtablename A DetT%pe=e#/r,e#Table5:vent;truct6eventro"7.coded8 <
int codedindex A DetT%pe=e#/r,e#-alue5:vent;truct6eventro"7.coded8<
strin( returnstrin( A FF<
i# 5 codedtablename AA FT%pe,e#F8
returnstrin( A t%pere#names6codedindex7 C F IJ01F C codedindex.To;trin(5FK6F8 C FJIF<
i# 5 codedtablename AA FT%pe=e#F8
returnstrin( A t%pede#names6codedindex7 C F IJ02F C codedindex.To;trin(5FK6F8 C FJIF<
+onsole.!rite5returnstrin(8<
+onsole.!rite5F F C name8 <
+onsole.!rite3ine58<
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite3ine5F9F8<
#or 5 int A 1 < B 0ethod;emantics;truct.3en(th < CC8
9
strin( attributes A
Det0ethod;emantics*ttributes50ethod;emantics;truct67.methodsemanticsattributes8<
strin( table A Det2as;emanticsTable50ethod;emantics;truct67.association8<
int eventindex A Det2as;emantics-alue50ethod;emantics;truct67.association8<
int methodindex A 0ethod;emantics;truct67.methodindex<
i# 5 eventindex AA eventro" GG table AA F:ventF 8
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ornested88<
+onsole.!rite5F90@ 91@92@F$ attributes $ methodde#t%pearra%6methodindex7$
methodde#returnarra%6methodindex7 8<
strin( name1 A )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88<
strin( nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
i# 5 nspace EA FF8
nspace A nspace C F.F<
nspace A nspace C )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88<
strin( dumm% A FF<
dumm% A Det)estedT%pe*s;trin(5t%peindex8<
nspace A dumm% C nspace<
+onsole.!rite5F90@IJ 0291@ JIMM92@593@8F $ nspace $ t%peindex.To;trin(5FK6F8 $ name1 $
methodde#paramarra%16methodindex78<
+onsole.!rite3ine5F IJ 0690@ JIF $ 5methodindex8.To;trin(5FK6F88<
@
@
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@ F8<
+onsole.!rite3ine5FII end o# event 90@MM91@F $
)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 $ name8<
@
@
public strin( Det0ethod;emantics*ttributes5short asscoiationb%te8
9
strin( returnstrin( A FF<
i# 5 5asscoiationb%te G 0x018 AA 0x018
244260235.doc 286 od 541
returnstrin( A returnstrin( C F.setF<
i# 5 5asscoiationb%te G 0x028 AA 0x028
returnstrin( A returnstrin( C F.(etF<
i# 5 5asscoiationb%te G 0x048 AA 0x048
returnstrin( A returnstrin( C F.otherF<
i# 5 5asscoiationb%te G 0x088 AA 0x088
returnstrin( A returnstrin( C F.addonF<
i# 5 5asscoiationb%te G 0x108 AA 0x108
returnstrin( A returnstrin( C F.removeonF<
i# 5 5asscoiationb%te G 0x208 AA 0x208
returnstrin( A returnstrin( C F.#ireF<
return returnstrin(<
@
@

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method public void a15class 6vi1a%7;%stem.:vent2andler8
9
@
.method public instance void a25class 6vi1a%7;%stem.:vent2andler8
9
@
.method public instance void a358
9
@
.method public static int32 a458
9
@
.method public instance int32 a558
9
@
.method public instance void a658
9
@
.method public instance void a758
9
@
.event specialname rtspecialname 6vi1a%7;%stem.:vent2andler a
9
.addon instance void &&&MMa15class 6vi1a%7;%stem.:vent2andler8
.addon instance void &&&MMa25class 6vi1a%7;%stem.:vent2andler8
.removeon instance void &&&MMa25class 6vi1a%7;%stem.:vent2andler8
.removeon instance void &&&MMa15class 6vi1a%7;%stem.:vent2andler8
.other instance void &&&MMa358
.other int32 &&&MMa458
.#ire instance int32 &&&MMa558
244260235.doc 287 od 541
.#ire instance void &&&MMa658
@
.event specialname rtspecialname &&& b
9
.addon instance void &&&MMa758
@
@

.event IJ14000001JI specialname 6vi1a%IJ 23000001 JI7;%stem.:vent2andlerIJ 01000002 JI
IJ01000002JI a
9
.addon instance void &&&IJ 02000002 JIMMa25class 6vi1a%IJ 23000001 JI7;%stem.:vent2andlerIJ
01000002 JI8 IJ 06000002 JI
.removeon instance void &&&IJ 02000002 JIMMa15class 6vi1a%IJ 23000001
JI7;%stem.:vent2andlerIJ 01000002 JI8 IJ 06000001 JI
.#ire instance void &&&IJ 02000002 JIMMa658 IJ 06000006 JI
.other instance void &&&IJ 02000002 JIMMa358 IJ 06000003 JI
.other int32 &&&IJ 02000002 JIMMa458 IJ 06000004 JI
@ II end o# event &&&MMa
.event IJ14000002JI specialname &&&IJ 02000002 JI IJ02000002JI b
9
.addon instance void &&&IJ 02000002 JIMMa758 IJ 06000007 JI
@ II end o# event &&&MMb

'n this pro(ram "e deal "ith events "hich are ver% similar to properties. !e add 1ust one
#unction call =ispla%*ll:vents to the =ispla%/neT%pe method that displa%s all the events #or us.
The point to be noted is that #irst the overrides are displa%ed$ #ollo"ed b% methods$ #ollo"ed b%
events and then properties.

3ets no" move our #ocus to the =ispla%*ll:vents method. The :vent0ap table stores all the
t%pes that have events in a similar "a% to the 4ropert%0ap table. 'n the same "a% "e (et the
variables start and end to store the #irst and last event o"ned b% this t%pe.

'n the #irst #or loop "e displa% the initial spaces #ollo"ed b% the event directive and the event ro"
number in comments. !e then reuse the method Det4ropert%*ttribute to displa% the specialname
attribute. :vents cannot have de#ault values. !e then (et the name o# the event and unlie
properties that have parameters$ events have a data t%pe.

Thus "e do not need a index into the blob heap #or the event si(nature but simpl% a coded index
#ield coded that tells us "hether the t%pe is a T%pe,e# or a T%pe=e#. >or event a it is a T%pe,e#
and #or event b a T%pe=e#.

=ependin( upon the t%pe re#erence "e simpl% use the t%pere#names or the t%pede#names arra% to
(ive us the #ull t%pe name. !e "rite out the name and then scan the entire 0ethod;emantics table
#or a match o# our event. The attributes variable in this case "ill have three values$ addon$
removeon and #ire.

't shares the other directive "ith properties. Thus "e trap those ro"s that have the table name as
:vent and the event ro" matches our event number. !e have on purpose #or event a have
multiple declarations o# the same t%pe 1ust to tell %ou that onl% the last one is used. 2o"ever #or
the other directive all are used.
244260235.doc 288 od 541

!e "rite out the initial spaces as al"a%s$ then one o# the #our attributes$ #ollo"ed b% the t%pe o#
the method #rom the methodde#t%pearra% and the return value o# the method. The same
methodindex variable is used as the o##set lie "e did #or properties.

!e then (et the name and namespace o# the method and the t%pe that is belon(s to usin( the
Det)estedT%pe*s;trin( and simpl% put them to(ether. These methods have parameters that "e
#inall% "rite out in bracets.

Thus events are no di##erent other than si(nature and havin( one more directive than properties.
Thus the short and s"eet explanations.

4ro(ram44.csc
strin( 67 #ield#la(sarra% <
strin( 67 #ieldparamarra% <

public void +reate;i(natures 58
9
II0ethodTable
i# 50ethod;truct EA null8
9
methodde#returnarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra%1 A ne" strin(60ethod;truct.3en(th7<
methodde#t%pearra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramcount A ne" int60ethod;truct.3en(th7<
#or 5 int l A 1 < l B 0ethod;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe51 $ 0ethod;truct6l7.si(nature$ l8<
@
@
II0ethod,e#Table
i# 5 0ember,e#;truct EA null 8
9
methodre#t%pearra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#returnarra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#paramarra%1 A ne" strin(60ember,e#;truct.3en(th7<
#or 5 int l A 1 < l B 0ember,e#;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe52 $ 0ember,e#;truct6l7.si($ l8<
@
@
II#ieldtable
i# 5 >ield;truct EA null 8
9
#ield#la(sarra% A ne" strin(6>ield;truct.3en(th7<
#ieldparamarra% A ne" strin(6>ield;truct.3en(th7<
#or 5 int l A 1 < l B >ield;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe 56$ >ield;truct6l7.si($ l8<
@
244260235.doc 289 od 541
@
IIpropert%table
i# 5 4ropert%;truct EA null 8
9
propert%parmarra% A ne" strin(64ropert%;truct.3en(th7<
propert%returnarra% A ne" strin(64ropert%;truct.3en(th7<
propert%t%pearra% A ne" strin(64ropert%;truct.3en(th7<
#or 5 int l A 1 < l B 4ropert%;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe57$ 4ropert%;truct6l7.t%pe$ l8<
@
@
@
public void +reate;i(nature>or:achT%pe 5b%te t%pe $ int index $ int ro"8
9
int uncompressedb%te $ count $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blob1 A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blob1 $ 0 $ count8<
i# 5 t%pe AA 78
+reate4ropert%;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 68
+reate>ield;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 18
+reate0ethod=e#;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 28
+reate0ethod,e#;i(nature5blob1 $ ro"8<
@
public void +reate>ield;i(nature 5b%te 67 blobarra% $ int ro"8
9
int ho"man%b%tes $ uncompressedb%te<
int index A 0<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
strin( returnstrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8<
returnstrin( A returnstrin(.,eplace5F`F$F$F8<
#ieldparamarra% 6ro"7 A returnstrin(<
#ield#la(sarra% 6ro"7 A Det>ield*ttributes 5ro"8<
@
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%*ll;ecurit%5 0 $ t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/verride5t%pede#index8<
=ispla%*ll>ields5t%pede#index8<
=ispla%*ll0ethods5t%pede#index8<
=ispla%*ll:vents5t%pede#index8<
=ispla%*ll4roperties5t%pede#index8<
244260235.doc 290 od 541
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%*ll>ields 5int t%peindex8
9
i# 5 >ield;truct AA null 8
return<
int start $ starto#nextA0<
start A T%pe=e#;truct6t%peindex7.#index <
i# 5 t%peindex AA 5T%pe=e#;truct.3en(th P 18 8
starto#nextA >ield;truct.3en(th<
else
starto#next A T%pe=e#;truct6t%peindexC17.#index <
strin( returnstrin( A FF<
#or 5 int #ieldindex A start < #ieldindex B starto#next < #ieldindexCC8
9
i# 5 t%peindex AA 18
returnstrin( A FF<
else
returnstrin( A +reate;paces5spaces#ornested C spaces#orrest8 <
returnstrin( A returnstrin( C F.#ield IJ04F C #ieldindex.To;trin(5FK6F8 C FJIF <
returnstrin( A returnstrin( C F F C #ield#la(sarra% 6#ieldindex7 C #ieldparamarra% 6#ieldindex7 C
F F C )ame,eserved5Det;trin(5>ield;truct6#ieldindex7.name88 <
i# 5 #ield#la(sarra%6#ieldindex7.'ndex/#5FprivatescopeF8 EA P1 8
returnstrin( A returnstrin( C FZ4;T04F C #ieldindex.To;trin(5FK6F8<
strin( #ieldrva A Det>ield,-*5#ieldindex8<
i# 5 #ieldrva EA FF8
returnstrin( A returnstrin( C F atF C #ieldrva<
int len A returnstrin(.3en(th<
strin( str A =ispla%>rom+onstantsTable 5#ieldindex $0 $ F>ield=e#F8<
i# 5 str EA FF8
str A str.,emove5str.3en(thP2$28<
returnstrin( A returnstrin( C str<
+onsole.!rite3ine5F90@F $ returnstrin(8<
@
@
public strin( =ispla%>rom+onstantsTable5int start $ int end $strin( tablename 8
9
strin( returnstrin( A FF<
#or 5 int ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
strin( consttablename A Det2as+onstTable5+onstants;truct6ii7.parent8<
int constindex A Det2as+onst-alue5+onstants;truct6ii7.parent8<
i# 5 consttablename AA tablename 8
9
i# 5 5constindex HA start GG constindex B end GG start EA end GG tablename AA F4aram=e#F 8 TT
55tablename AA F4ropert%F TT tablename AA F>ield=e#F8 GG start AA constindex 8 8
9
@
@
@
return returnstrin(<
244260235.doc 291 od 541
@
public strin( Det>ield*ttributes 5int #ieldro"8
9
int #la(s A >ield;truct6#ieldro"7.#la(s<
strin( returnstrin( A FF<
strin( arra%o##set A FF<
int ii<
i# 5 >ield3a%out;truct EA null8
9
#or 5 ii A 1 < ii B >ield3a%out;truct.3en(th < iiCC8
9
int 11 A >ield3a%out;truct6ii7.#ieldindex <
i# 5 11 AA #ieldro" 8
brea<
@
i# 5 ii EA >ield3a%out;truct.3en(th 8
9
int o##set A >ield3a%out;truct6ii7.o##set <
arra%o##set A F6F C o##set.To;trin(5FF8 C F7 F<
@
@
i# 5 5#la(s G 0x068 AA 0x068
returnstrin( A returnstrin( C Fpublic F<
else
i# 5 5#la(s G 0x058 AA 0x058
returnstrin( A returnstrin( C F#amorassem F<
else
i# 5 5#la(s G 0x038 AA 0x038
returnstrin( A returnstrin( C Fassembl% F<
else
i# 5 5#la(s G 0x018 AA 0x018
returnstrin( A returnstrin( C Fprivate F<
else
i# 5 5#la(s G 0x028 AA 0x028
returnstrin( A returnstrin( C F#amandassem F<
else
i# 5 5#la(s G 0x048 AA 0x048
returnstrin( A returnstrin( C F#amil% F<
else
returnstrin( A returnstrin( C Fprivatescope F<
i# 5 5#la(s G 0x108 AA 0x108
9
int #irst#ourbits A #la(s G 0x><
i# 5 5#irst#ourbits AA 0x068 TT 5#irst#ourbits AA 0x0188
9
returnstrin( A returnstrin( C Fstatic F <
@
else
returnstrin( A Fstatic F C returnstrin(<
@
returnstrin( A arra%o##set C returnstrin(<
244260235.doc 292 od 541
i# 5 5#la(s G 0x208 AA 0x208
returnstrin( A returnstrin( C Finitonl% F<
i# 5 5#la(s G 0x408 AA 0x408
returnstrin( A returnstrin( C Fliteral F<
i# 5 5#la(s G 0x808 AA 0x808
returnstrin( A returnstrin( C Fnotseriali&ed F<
i# 5 5#la(s G 0x2008 AA 0x2008
returnstrin( A returnstrin( C Fspecialname F<
i# 5 5#la(s G 0x4008 AA 0x4008
returnstrin( A returnstrin( C Frtspecialname F<
i# 5 5#la(s G 0x4008 AA 0x4008
returnstrin( A returnstrin( C FF<
returnstrin( A returnstrin( C =ecode4aram*ttributes 5 #la(s $ 0 $ #ieldro" $ 0x10008<
return returnstrin(<
@
public strin( Det>ield,-* 5int #ieldro"8
9
strin( returnstrin( A FF<
int ii<
i# 5 >ield,-*;truct AA null 8
return FF<
#or 5 ii A 1 < ii B >ield,-*;truct.3en(th < iiCC8
9
int 11 A >ield,-*;truct6ii7.#ieldi<
i# 5 11 AA #ieldro" 8
brea<
@
i# 5 ii EA >ield,-*;truct.3en(th 8
9
int rvaA >ield,-*;truct6ii7.rva <
returnstrin( A F =RF C rva.To;trin(5FK8F8 <
@
return returnstrin(<
@

e.il
.class &&&
9
.#ield int32 i
.#ield 6107 public int32 1
.#ield static public int32
.#ield static #amil% int32 l
.#ield public static int32 n at vi1a%
.#ield public marshal5int328 int32 o
.#ield public int32 m1 A bool5true8
.#ield public int32 m2 A int8528
.#ield public int32 m3 A int16538
.#ield public int32 m4 A int32558
.#ield public int32 m5 A int64568
.#ield public strin( p A FhiF
.#ield public rtspecialname strin( .
244260235.doc 293 od 541
@
.data vi1a% A int325118

/utput
.class IJ02000002JI private auto ansi &&&
extends 6mscorlibIJ 23000001 JI7;%stem./b1ectIJ 01000001 JI
9
.pac 1
.si&e 0
.#ield IJ04000001JI privatescope int32 iZ4;T04000001
.#ield IJ04000002JI 6107 public int32 1
.#ield IJ04000003JI public static int32
.#ield IJ04000004JI static #amil% int32 l
.#ield IJ04000005JI public static int32 n at =R00004000
.#ield IJ04000006JI public marshal5 int328 int32 o
.#ield IJ04000007JI public int32 m1 A bool5true8
.#ield IJ04000008JI public int32 m2 A int850x028
.#ield IJ04000009JI public int32 m3 A int1650x00038
.#ield IJ0400000*JI public int32 m4 A int3250x000000058
.#ield IJ0400000OJI public int32 m5 A int6450x68
.#ield IJ0400000+JI public strin( p A FhiF
.#ield IJ0400000=JI public strin( .
@ II end o# class &&&

!hat "e call instance variables in a pro(rammin( lan(ua(e$ il calls the same thin( #ields. >ields
are "hat "e use our pro(rams data in memor%. Thus #ields at the end o# the da% are nothin( but
memor% locations that have a t%pe. *s "ith ever%thin( "e have static and instance #ields. * static
#ield is one no matter ho" man% instances o# the t%pe "e create.

* instance #ield can onl% be used once "e instantiate the #ield and thus each time "e do so$ a ne"
instance o# that #ield (ets created. Thus an instance #ield is not shared b% all the instances lie a
static #ield is. Nnlie +S$ il supports (lobal #ields and methods but "ith the condition that (lobal
#ields must be static.

* #ield is declared usin( the directive .#ield and this is #irst #ollo"ed b% a number speci#%in( the
o##set in memor% "here this #ield must be stored as #or #ield 1 "hich is at an o##set o# 10.
/bviousl% the la%out o# the class must be instance and this o##set is invalid #or (lobal or static
#ields.

This is #ollo"ed b% #ield attributes lie public$ private that "e did earlier plus some uni.ue #or
#ields. Then comes the obvious the t%pe o# the #ield and then the name. *#ter this comes t"o
optional entities$ associatin( the #ield "ith a memor% location lie in #ield n or (ivin( it a de#ault
value lie #iled m on"ards.

*ll (lobal #ields must have such a data label as it speci#ies "here in the 4: #ile the #ields data is
to be #ound. >or static #ields this re.uirement is optional but normall% #ollo"ed.

*s al"a%s "e start "ith the +reate;i(natures method "here "e initiali&e the t"o strin( arra%s$
#ield#la(sarra% "hich stores the #ields attributes and data t%pe o# the #ield "ron(l% called
#ieldparamarra% as the #ield has no parameters. !e no" call the method
+reate;i(nature>or:achT%pe "ith a value o# 6 as this is code (iven #or a #ield.
244260235.doc 294 od 541

'n this method "e simpl% call the method +reate>ield;i(nature "hich is the simplest method "e
have ever "ritten. *ll that "e do here is to #irst read the #irst b%te "hich "ill al"a%s be 6 and this
is then #ollo"ed b% the t%pe o# #ield that "e store in the arra% #ieldparamarra%.

Out be#ore this "e replace the ` si(n "ith a comma due to the arra% problem "e had earlier. The
#ield#la(sarra% is reall% not needed as the #ield attributes are not stored "ith the si(nature in the
blob arra% but alon( "ith each #ield in the >ield table. 3ets move to the #ields attributes "hich (et
decoded b% the method Det>ield*ttributes.

't is the #la(s member o# the #ield table that stores the attributes #or the #ields. The o##set per #ield
is stored in the table >ield3a%out "hich has onl% t"o #ields$ one the #ield table ro" number and
the other the o##set. Thus "e scan the table >ield3a%out and .uit out o# the loop i# "e meet our
#ield number.

'# a match is #ound$ "e displa% the o##set in s.uare bracets in decimals and not in hex.
+onsistenc% th% name is not ildasm. Then as usual "e have the seven access modi#iers #or the
#ields. There is onl% one small problem "ith the static e%"ord "hich has a bit mas o# 0x10.

The onl% problem is "hether static comes be#ore or a#ter the access modi#iers. The problem as all
.uestions ased about li#e are depends. '# "e have a public or private these come be#ore the static$
the rest o# the access modi#iers come a#ter lie "e have "ith #ields and l respectivel%.

!e have the attributes initonl%$ literal$ notseriali&ed$ specialname and #inall% rtspecialname that
do not sho" up lie #or #ield .. !e no" add the method =ispla%*ll>ields in the method
=ispla%/neT%pe and bear in mind the order.

>or displa%in( all #ields "e do "hat "e did #or methods set the start and starto#next to the #irst
and last but one #ield o"ned b% each t%pe. *s "e can have (lobal #ields "e chec i# the t%peindex
value is one as this is #or (lobal #ields and thus set the number o# spaces to &ero else to be decided
b% the namespace and nestin( levels.

!e then "rite out the #ield directive$ the #ield ro" number in comments and then the attributes
#rom the #ield#la(sarra% arra% and then the data t%pe #rom the #ieldparamarra%. * space and then
the name and i# this has the attribute privatescope$ then the name as al"a%s (et the added strin(
Z4;T04 and ro" number.

3ets tae #ield n "hich has the "ords at #ollo"ed b% the name vi1a% that is de#ined usin( the data
directive. The data directive uses the constants seen be#ore to (ive a memor% location in this vi1a%
a value. !e ma% use names lie vi1a% but i# %ou loo at the output$ it (ets replaced b% a label
=R00004000.

'# %ou loo at the output (enerated b% ildasm$ this data directive has a value o# 10 that "e "ill
displa% later. !e have a method Det>ield,-* to #i(ure out the at clause #or us. *ll the at clauses
are stored in another simple table called the >ield,-* table "hich as the earlier table has t"o
columns.

The #irst is the rva o# the #ield and the second the #ield ro" number. 3ie be#ore i# "e meet a
match "e displa% the #ield rva "hich is a number sho" above and not a name lie vi1a%. >inall%
"e have to displa% the de#ault value #or the #ield and use the (ood old
=ispla%>rom+onstantsTable table to do so #or us.
244260235.doc 295 od 541

The second parameter is 0 lie #or a propert%. The onl% chan(e "e have made is that the i#
statement second condition no" has checs that the constindex must be e.ual to start and the
table name could be either >ield=e# or 4ropert% as be#ore. There is no di##erence in "ho uses a
de#ault value$ the% all (et stored in the constants table.

*s mentioned be#ore "e "ill revisit this method #or handlin( #loatin( point numbers and no"
also strin(s. This ends the discourse on #ields.

4ro(ram45.csc
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%+ustom*ttribute5FT%pe=e#F $ t%pede#index $ 2 C space#ornamespace C spaces#ornested8<
=ispla%*ll;ecurit%5 0 $ t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/verride5t%pede#index8<
=ispla%*ll>ields5t%pede#index8<
=ispla%*ll0ethods5t%pede#index8<
=ispla%*ll:vents5t%pede#index8<
=ispla%*ll4roperties5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%+ustom*ttribute 5strin( tname $ int tabindex $ int noo#spaces8
9
i# 5+ustom*ttribute;truct AA null8
return<
strin( initialspaces<
initialspaces A +reate;paces5noo#spaces8<
#or 5 int ii A 1 < ii B +ustom*ttribute;truct.3en(th < iiCC8
9
strin( parentcodedtablename A Det2as+ustom*ttributeTable 5+ustom*ttribute;truct6ii7.parent8 <
int parentcodedindex A Det2as+ustom*ttribute-alue5+ustom*ttribute;truct6ii7.parent8<
strin( t%pecodetable A Det+ustom*ttributeT%peTable 5+ustom*ttribute;truct6ii7.t%pe8 <
int t%pecodedindex A Det+ustom*ttributeT%pevalue5+ustom*ttribute;truct6ii7.t%pe8<
int tableindexcode A 0<
int tablenumber A 0<
strin( returnstrin( A FF<
bool custombu( A #alse<
int t%peindex <
strin( t%pename A FF<
strin( returnvaluestrin( A FF<
strin( paramstrin( A FF<
strin( dumm% A FF<
strin( methodname A FF<
strin( onespaceAFF<
i# 5 t%pecodetable AA F0ethod,e#F 8
9
tableindexcode A 0x0*<
t%peindexA 0ember,e#;truct6t%pecodedindex7.clas HH 3<
244260235.doc 296 od 541
t%pename A t%pere#names6t%peindex7 <
returnvaluestrin( A methodre#returnarra% 6t%pecodedindex7<
paramstrin( A methodre#paramarra%1 6t%pecodedindex7<
tablenumber A 1<
methodname A )ame,eserved5Det;trin(50ember,e#;truct6t%pecodedindex7.name88<
onespace A F F<
@
else
9
tableindexcode A 0x06<
t%peindex A DetT%pe>or0ethod 5t%pecodedindex8<
t%pename A t%pede#names6t%peindex7 <
returnvaluestrin( A methodde#returnarra%6t%pecodedindex7<
paramstrin( A methodde#paramarra%16t%pecodedindex7 <
tablenumber A 02<
methodname A )ame,eserved5Det;trin(50ethod;truct6t%pecodedindex7.name88<
@
i# 5 5tname AA parentcodedtablename GG tabindex AA parentcodedindex8 TT
5parentcodedtablename AA FT%pe,e#F GG tabindex AA 08 8
9
i# 5t%pename.'ndex/#5F;%stem.=ia(nostics.=ebu((able*ttributeF8 EA P18
custombu( A true<
i# 5 custombu( 8
9
+onsole.!rite5+reate;paces5noo#spaces88<
+onsole.!rite3ine5FII PPP The #ollo"in( custom attribute is added automaticall%$ do not
uncomment PPPPPPPF8<
returnstrin( A returnstrin( C +reate;paces5noo#spaces8 C FIIF<
i# 5 initialspaces AA FF8
returnstrin( A returnstrin( C F F<
@
i# 5 parentcodedtablename AA FT%pe,e#F8
9
returnstrin( A returnstrin( C initialspaces C F.custom IJ0+F C ii.To;trin(5FK6F8 CFJI 5F C
t%pere#names6parentcodedindex7<
returnstrin( A returnstrin( C FIJF C tablenumber.To;trin(5FK2F8 C
parentcodedindex.To;trin(5FK6F8 C FJI 8 F<
@
else
returnstrin( A returnstrin( C initialspaces C F.custom IJ0+F C ii.To;trin(5FK6F8 C FMF C
tableindexcode.To;trin(5FK2F8 C t%pecodedindex.To;trin(5FK6F8 C FJI F<
returnstrin( A returnstrin( C Finstance F C returnvaluestrin( C onespace C t%pename <
returnstrin( A returnstrin( C FMMF C methodname<
returnstrin( A returnstrin( C F5F<
i# 5 noo#spaces AA 08
dumm% A 4aram/n0ultiple3ines 5paramstrin( $ returnstrin(.3en(th C 28<
else i# 5 paramstrin( EA null8
dumm% A 4aram/n0ultiple3ines5paramstrin( $ returnstrin(.3en(th8<
i# 5 custombu( 8
9
int ind1 A dumm%.'ndex/#5FUrUnF8<
244260235.doc 297 od 541
dumm%A dumm%.'nsert5ind1C2$ +reate;paces5noo#spaces8 C FIIF8<
dumm%A dumm%.,emove5ind1C10$ 48<
@
returnstrin( A returnstrin( C dumm% <
returnstrin( A returnstrin( C F8F<
returnstrin( A returnstrin( C F IJ F C tableindexcode.To;trin(5FK2F8 C
t%pecodedindex.To;trin(5FK6F8 C F JIF<
+onsole.!rite5returnstrin(8<
int index A +ustom*ttribute;truct6ii7.value<
int ho"man%b%tes$uncompressedb%te <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
i# 5 uncompressedb%te AA 08
9
+onsole.!rite3ine58<
continue<
@
index A index C ho"man%b%tes<
b%te 67 blobarra% A ne" b%te6uncompressedb%te7<
*rra%.+op%5blob $ index $ blobarra% $ 0 $ uncompressedb%te8<
bool displa%oneline A true<
strin( displa%strin( A FF<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
i# 5 blobarra%6117 B 0x208
displa%oneline A #alse<
i# 5 blobarra%6117 HA 0x7#8
displa%oneline A #alse<
@
i# 5 displa%oneline8
9
displa%strin( A F A UFF<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
displa%strin( A displa%strin( C 5char8blobarra%6117<
@
displa%strin( A displa%strin( C FUFF<
i# 5 tname AA F0ember,e#F8
+onsole.!rite5displa%strin(8<
else
+onsole.!rite3ine5displa%strin(8<
@
else
9
int starto##unctionclosebracet A returnstrin(.3ast'ndex/#5F8F8<
int lastenter A returnstrin(.3ast'ndex/#5FUrUnF8<
i# 5 lastenter AA P18
lastenter A P2<
int di##2 A starto##unctionclosebracet P lastenter C 19<
+onsole.!rite5F A 5 F8<
=ispla%>ormatted+olumns 5+ustom*ttribute;truct6ii7.value$di##2 $ #alse8<
@
244260235.doc 298 od 541
@
@
@
public int Det+ustom*ttributeT%pevalue5int attributecodedt%pe8
9
return attributecodedt%pe HH 3<
@
public strin( Det+ustom*ttributeT%peTable5 int attributecodedt%pe8
9
strin( returnstrin( A FF<
int ta( A attributecodedt%pe G 0x07<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F)otNsedF<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F)otNsedF<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 38
returnstrin( A returnstrin( C F0ethod,e#F<
i# 5 ta( AA 48
returnstrin( A returnstrin( C F)otNsedF<
return returnstrin(<
@
public int Det2as+ustom*ttribute-alue5 int attributecodedparent8
9
return attributecodedparent HH 5<
@
public strin( Det2as+ustom*ttributeTable 5 int attributecodedparent8
9
strin( returnstrin( A FF<
int ta( A attributecodedparent G 0x1><
i# 5 ta( AA 08
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F>ield=e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C FT%pe,e#F<
i# 5 ta( AA 38
returnstrin( A returnstrin( C FT%pe=e#F<
i# 5 ta( AA 48
returnstrin( A returnstrin( C F4aram=e#F<
i# 5 ta( AA 58
returnstrin( A returnstrin( C F'nter#ace'mplF<
i# 5 ta( AA 68
returnstrin( A returnstrin( C F0ember,e#F<
i# 5 ta( AA 78
returnstrin( A returnstrin( C F0oduleF<
i# 5 ta( AA 88
returnstrin( A returnstrin( C F=ecl;ecurit%F<
i# 5 ta( AA 98
returnstrin( A returnstrin( C F4ropert%F<
244260235.doc 299 od 541
i# 5 ta( AA 108
returnstrin( A returnstrin( C F:ventF<
i# 5 ta( AA 118
returnstrin( A returnstrin( C F;i(natureF<
i# 5 ta( AA 128
returnstrin( A returnstrin( C F0odule,e#F<
i# 5 ta( AA 138
returnstrin( A returnstrin( C FT%pe;pecF<
i# 5 ta( AA 148
returnstrin( A returnstrin( C F*ssembl%F<
i# 5 ta( AA 158
returnstrin( A returnstrin( C F*ssembl%,e#F<
i# 5 ta( AA 168
returnstrin( A returnstrin( C F>ileF<
i# 5 ta( AA 178
returnstrin( A returnstrin( C F:xportedT%peF<
i# 5 ta( AA 188
returnstrin( A returnstrin( C F0ani#est,esourceF<
return returnstrin(<
@
@

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.custom instance void 6vi1a%7a1MM.ctor5bool$ strin( 8 A 5 41 41 42 8
.custom instance void 6vi1a%7a2MM.ctor5bool8 A 5 7# 41 41 42 8
@
II.custom 56vi1a%7a38 instance void 6vi1a%7a4MM.ctor58A 5 65 8


/utput
.class IJ02000002JI private auto ansi &&&
extends 6mscorlibIJ 23000002 JI7;%stem./b1ectIJ 01000001 JI
9
.custom IJ0+000001M0*000001JI instance void 6vi1a%IJ 23000001 JI7a1IJ 01000002
JIMM.ctor5bool$
strin(8 IJ 0*000001 JI A F**OF
.custom IJ0+000002M0*000002JI instance void 6vi1a%IJ 23000001 JI7a2IJ 01000003
JIMM.ctor5bool8 IJ 0*000002 JI A 5 7> 41 41 42 8 II .**O
@ II end o# class &&&

This example deals "ith one ma1or #eature o# the .net "orld called custom attributes. Nsin( this
"e are allo"ed to extend the .net "orld in directions the ori(inal desi(ners did not plan. Thus in
the =ispla%/neT%pe method "e add the =ispla%+ustom*ttribute method "ith three parameters.

244260235.doc 300 od 541
The #irst is the entit% contains the custom attribute. Wou "ill be surprised to note that there are
over 19 entities that this attribute can be placed in. 'n our pro(ram no" "e "ill "onder about
attributes placed in the T%pe=e# table onl%.

The second parameter is the ro" number o# the previous parameter as each t%pe can have as
man% attributes as it lies. Thus the above tablePindex combination "ill be present in the
+ustom*ttribute table as a coded index. The last is the indentation to be (iven to the custom
directive.

The custom attributes add annotations to an% item o# the metadata and are used to store an%thin(
"e lie at compile time and access it at runtime. !e start "ith the directive custom #ollo"ed b%
the name o# a method that has to be ctor.

This is #ollo"ed b% the parameters i# an% and then some b%tes in bracets that "ill contain the
values that the parameters need to be initiali&ed "ith. 'n our case "e have t"o custom attributes$
both re#er to the .ctor method or the constructor but the #irst is a 0ember,e# as it re#ers to a .ctor
de#ined in the assembl% vi1a% and the second to a 0ethod=e# as the .ctor lies in the same t%pe.

The problem "ith the initiali&ation b%tes is that i# the% are all ascii$ the% are displa%ed one a#ter
the other$ i# there is a sin(le non ascii b%te$ then the% are displa%ed "ith bracets and "ith the
ascii values as comments lie be#ore. There is one last exception.

'# the t%pe is ;%stem.=ia(nostics.=ebu((able*ttribute onl% then there are some comments added
be#ore the attribute. 3ets start "ith the actual code in the =ispla%+ustom*ttribute method "here
"e scan the +ustom*ttribute table as each custom attribute is stored here. The #irst #ield parent is
a coded index that tells us "here this custom directive must be "ritten.

The method Det2as+ustom*ttributeTable has up to 19 di##erent tables and t"o pro(rams do"n
the line "e have tried to sho" %ou each o# the above 19 cases. The parentcodedtablename
variable does store the table name and the parentcodedindex the actual ro" number in that table
that o"ns the custom directive.

This is the onl% coded index that taes up #ive bits. Then "e have one more coded index that tells
us "hether the method .ctor is a 0ethod=e# or a 0ethod,e#. !e have a #unction
Det+ustom*ttributeT%peTable that decodes the t%pe #ield and even thou(h it taes up three bits$
one bit "ould have su##iced.

!e then create a hu(e list o# variables that "e set dependin( upon "hether "e have a 0ethod
de#inition or a 0ethod re#erence. !e "ill explain the values "e set the variables to "hen "e
actuall% use them. !e do this so that "e can have one set o# statements that handle both cases.

!e no" have a i# statement that decides i# "e have a match. There are t"o cases "hen a match is
#ound. /ne "hen both tname and tabindex parameters match the parent #ield coded index. T"o is
"hen "e have a value o# T%pe,e# #or the table and the tabindex parameter is 0. This special case
"e "ill handle a little later.

The #irst thin( "e do "hen "e meet a match is chec "hether "e "ant the extra comments i# the
t%pe is ;%stem.=ia(nostics.=ebu((able*ttribute. The t%pename variable can either be a t%pe in
T%pe=e# or the T%pe,e# table.

244260235.doc 301 od 541
*s "e have the arra% t%pere#names or t%pede#names that store the entire name "e use the
variable t%peindex as an o##set to this arra%. !e (et the t%pe the method is in b% either usin( the
DetT%pe>or0ethod method #or a 0ethod=e# and the simple method #or a 0ember,e# b% readin(
the clas #ield o# the 0ember,e# table.

The t%pecodedindex variable is the index into either o# the t"o tables. !e eep usin( the
noo#spaces to "rite out the spaces. There "ill be one case onl% "here the tablename is T%pe,e#
and the spaces are &ero. 'n comments "e have sho"n %ou a custom attribute that has a open and
close bracet and the name o# the t%pe re# "ithin it.

!e #irst handle this speci#ic this #irst. !e #irst displa% the dumber o# initialspaces and then the
custom directive and the ro" number denoted b% the loop variable ii. Then "e have the open
bracet and use the parentcodedindex variable as the index into the t%pere#names arra% that
contains all the t%pe re#s.

!e then displa% the tablenumber variable that is either 2 #or a t%pede# or a 0ethod=e#. >or a
method re# this "ill be 1 the code #or a T%pe,e# table. 'n the dame vein the tableindexcode
variable is 6 the code #or a 0ethod=e# in the else statement or the code #or a 0ethod,e# "hich is
0a.

!e end b% "ritin( out the ro" number o# the parent table stored in parentcodedindex variable. '#
the parentcodedtablename table is not T%pe,e# but an% o# the other 18$ then li#e (ets simpler. !e
displa% the initial spaces and then the custom directive and the ro" number in the custom table
"ithin comments.

This is #ollo"ed b% the 0ethod,e# or 0ethod=e# table number stored in the tableindexcode
variable and then the ro" number in one o# these tables. *s the constructor is not the static one
.cctor$ "e have to "rite out the "ords instance #ollo"ed b% the return value o# the constructor.

The variable returnvaluestrin( is set to the methodde#returnarra% arra% #or the case o# a
0ethod=e# and the correspondin( methodre#returnarra% #or a 0ember,e#. The variable
t%pecodedindex is used as an o##set lie be#ore. Then comes a problem.

'n the case o# the 0ember,e# "e have not le#t a space at the end o# the each member o# the
methodre#returnarra% arra% and thus "e set the onespace variable to a space. !e do not do this in
the case o# a 0ethod=e#.

!e then "rite out the t%pename variable that "e explained earlier and then the name o# the
method that can either come #rom the name #ield o# the 0ember,e# or 0ethod=e# table. !e then
open a bracet and then a(ain chec #or number o# spaces. '# &ero the special case o# the
T%pe,e# $ "e call the 4aram/n0ultiple3ines "ith t"o spaces more than the len(th o# the strin($
i# not "e 1ust use the len(th as it "ould be obvious.

The paramstrin( strin( that contains all the parameters is once a(ain either the
methodre#paramarra%1 or the methodde#paramarra%1. /ne small problem i# "e have added the
extra comments our "or is not done %et. !e #irst #ind out the last enter or the last line and then
add some comments t"o chars later "ith some spaces and comments.

These should come at the be(innin( o# the last line. !e then need to remove the 4 chars in this
case as noo#spaces is 2 "e have 1ust added to position the parameters one belo" the other.
)ormall% "e "ill remove the number o# chars "e have added in the 'nsert #unction.
244260235.doc 302 od 541

!e then close the bracet and "rite out the table code number #or 0ethod=e# or 0ethod,e# and
the table ro" number. *ll is not over %et as "e have to displa% either the b%tes in bracets or a
strin(. !e use the value #ield as an o##set into the blob arra%.

!e as be#ore use the #irst b%tes to #i(ure out the len(th o# the b%tes o"ned b% the custom
attribute. !e "rite out a empt% enter i# there are no b%tes at all. !e then sue the +op% method to
cop% these b%tes into a #resh and clean arra% called blobarra%. !e then set the displa%oneline
variable to true initiall% and then scan the entire blobarra%.

'# "e meet a sin(le number that is not a ascii char$ "e set the displa%oneline variable to #alse. >or
us a non ascii char is a b%te that is less than 32 or lar(er than 128. '# this variable is true "e start
"ith a double inverted comma and the "rite the entire strin( into the displa%strin( variable.

!e then close the double and either place a enter or not dependin( upon "hether the table name
is 0ember,e# or not. * little later "e "ill explain that a call o# a method can also have a custom
attribute and thus "e "ill have a problem o# a extra enter i# the custom directive is on a
0ember,e#.

>inall% "e have to displa% the b%tes in bracets and thus "e #irst out "here "e placed the last
close #unction bracet and the last enter. '# there "as no enter placed then "e set the lastenter
variable to minus 2 as a enter taes up t"o b%tes. !e then (et the di##erence as the subtraction o#
the t"o minus 19 b%tes.

!e use 19 b%tes as "e painstain(l% calculated the number o# b%tes "e have a#ter the last close
bracet. These include spaces$ the comments and the ro" number and the e.ual to si(n. !e call
our trust% =ispla%>ormatted+olumns to displa% the b%tes #or us.

4ro(ram46.csc
4ublic void =ispla%*ll0ethods 5int t%peindex8
9
int tablero" A entr%pointtoen G 0x00######<
i# 5 tablero" AA methodindex 8
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C
F.entr%pointF<
+onsole.!rite3ine5methodstrin(8<
=ispla%+ustom*ttribute 5F0ethod=e#F $ methodindex $ 2 C spaces#orrest C spaces#ornested8<
=ispla%4arams>or0ethod 5methodindex8<
=ispla%*ll;ecurit%5 1 $ methodindex 8<
@
public strin( =ispla%4arams>or0ethod 5int methodro"8
9
i# 5 4aram;truct AA null8
return FF<
strin( returnstrin( A FF<
int startA0$ endA0<
start A 0ethod;truct6methodro"7.param<
i# 5 methodro" AA 50ethod;truct.3en(th P 188
end A 4aram;truct.3en(th <
else
end A 0ethod;truct6methodro"C17.param<
244260235.doc 303 od 541
#or 5 int index A start < index B end < indexCC8
9
int se. A 4aram;truct6index7.se.uence<
returnstrin( A +reate;paces5spaces#orrestC spaces#ornestedC28 C F.param 6F C se..To;trin(58 C
F7F C FIJ08F C index.To;trin(5FK6F8 C FJIF<
strin( str A =ispla%>rom+onstantsTable 5index $0 $F4aram=e#F8<
i# 5 str EA FF8
+onsole.!rite5returnstrin( C str 8<
bool b A 2as+ustom*ttribute 5F4aram=e#F $ index8<
i# 5 b GG str AA FF8
+onsole.!rite3ine5returnstrin( C F F8<
=ispla%+ustom*ttribute 5F4aram=e#F $ index $ spaces#orrestC spaces#ornestedC28<
@
return FF<
@
public strin( =ispla%>rom+onstantsTable5int start $ int end $strin( tablename 8
9
strin( returnstrin( A FF<
i# 5 +onstants;truct AA null8
return FF<
#or 5 int ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
strin( consttablename A Det2as+onstTable5+onstants;truct6ii7.parent8<
int constindex A Det2as+onst-alue5+onstants;truct6ii7.parent8<
i# 5 consttablename AA tablename 8
9
i# 5 start AA constindex 8
9
i# 5 consttablename AA F4ropert%F8
returnstrin( A F A F<
else
returnstrin( A F A F<
i# 5 +onstants;truct6ii7.dt%pe AA 2 8
9
bool val A Oit+onverter.ToOoolean5blob $ +onstants;truct6ii7.valueC18<
i# 5 val 8
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5true8F C FUrUnF<
else
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5#alse8FC FUrUnF<
@
public bool 2as+ustom*ttribute5 strin( tablename $ int index8
9
i# 5 +ustom*ttribute;truct AA null8
return #alse<
#or 5 int ii A 1 < ii B +ustom*ttribute;truct.3en(th < iiCC8
9
strin( parentcodedtablenameA Det2as+ustom*ttributeTable5+ustom*ttribute;truct6ii7.parent8 <
int parentcodedindexA Det2as+ustom*ttribute-alue5+ustom*ttribute;truct6ii7.parent8<
i# 5 parentcodedtablename AA tablename GG parentcodedindex AA index8
return true<
@
244260235.doc 304 od 541
return #alse<
@

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.method public instance void .ctor5bool i $ bool 1 $ int32 $ int64 l $ int16 m $ int8 n8
9
.custom instance void 6vi1a%7a3MM.ctor5bool8 A 5 41 41 42 8
.custom instance void 6vi1a%7a31MM.ctor5bool8
.param617
.param637
.custom instance void 6vi1a%7a2MM.ctor5bool8 A 5 41 41 42 8
.param627 A int8518
.custom instance void 6vi1a%7a1MM.ctor5bool8 A 5 41 41 42 8
.param647
.custom instance void 6vi1a%7a4MM.ctor5bool8 A 5 41 41 42 8
.param657 A int16528
.param667
.custom instance void 6vi1a%7a6MM.ctor5bool8
.custom instance void 6vi1a%7a6MM.ctor5bool8
.param677
@
@

/utput
.method IJ06000001JI public specialname rtspecialname
instance void .ctor5bool i$
bool 1$
int32 $
int64 l$
int16 m$
int8 n8 cil mana(ed
II ;'DM 20 06 01 02 02 08 0* 06 04
9
.custom IJ0+000001M0*000001JI instance void 6vi1a%IJ 23000001 JI7a3IJ 01000002
JIMM.ctor5bool8 IJ 0*000001 JI A F**OF
.custom IJ0+000002M0*000002JI instance void 6vi1a%IJ 23000001 JI7a31IJ 01000003
JIMM.ctor5bool8 IJ 0*000002 JI
.param 627IJ08000002JI A int850x018
.custom IJ0+000003M0*000004JI instance void 6vi1a%IJ 23000001 JI7a1IJ 01000005
JIMM.ctor5bool8 IJ 0*000004 JI A F**OF
.param 637IJ08000003JI
.custom IJ0+000004M0*000003JI instance void 6vi1a%IJ 23000001 JI7a2IJ 01000004
JIMM.ctor5bool8 IJ 0*000003 JI A F**OF
.param 647IJ08000004JI
.custom IJ0+000005M0*000005JI instance void 6vi1a%IJ 23000001 JI7a4IJ 01000006
JIMM.ctor5bool8 IJ 0*000005 JI A F**OF
244260235.doc 305 od 541
.param 657IJ08000005JI A int1650x00028
.param 667IJ08000006JI
.custom IJ0+000006M0*000006JI instance void 6vi1a%IJ 23000001 JI7a6IJ 01000007
JIMM.ctor5bool8 IJ 0*000006 JI
.custom IJ0+000007M0*000006JI instance void 6vi1a%IJ 23000001 JI7a6IJ 01000007
JIMM.ctor5bool8 IJ 0*000006 JI
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 0 50x08
@ II end o# method &&&MM.ctor

!e no" need to displa% the attributes that come alon( "ith the param directive. '# "e loo at the
method =ispla%*ll0ethods "e "ill #irst see the call o# the method =ispla%+ustom*ttribute "ith
the #irst parameter 0ethod=e# as "e "ant to #irst displa% all custom attributes associated "ith a
0ethod.

This "ill be the #irst custom attribute in our il #ile. Then "e have re"ritten the method
=ispla%4arams>or0ethod as this is the method that "ill earlier displa%ed all the param directives
#or us. 3ets tae a #resh loo at the param directives in our il #ile.

The param directive "ith 1 "ill never sho" up in the output as it re.uires one o# t"o conditions
to be #ul#illed. :ither it must have a constant value or a custom attribute associated "ith it. Thus
param 3 has a custom attribute #ollo"in( it and thus it .uali#ies. The param 2 has both a custom
attribute as "ell as a constant value.

4aram 3 and 2 are not in sorted order but the s%stem sorts them out be#ore placin( them in tables.
4aram 4 has an attribute$ param 5 onl% a constant value and param 6 has t"o custom attributes
and param 7 is not #ound in the output as there are onl% six parameters.

3ets put the above in code "here "e #irst "rite out all the custom attributes #or a method and then
the params and the attributes i# an%. !e start once a(ain b% re"ritin( code and this is the bane o#
our li#e. ;ome pro(rams above "e had such a "orable =ispla%4arams>or0ethod method and all
that (one done the tube. !hat a li#e.

!e #irst tell ourselves that "e have six parameters to the method and thus can have at least 6 ro"s
in the param table. !e "ould %ou to con#irm this and loo at the name o# the params and the
se.uence numbers. Thus at most "e "ill "rite out six .params directives.

!e prepare ourselves b% #irst picin( out the se.uence number as the% are ordered se.uentiall% in
the se. variable "ith index bein( the succeedin( ro" numbers in the 4aram table. !e then create
the param directive strin( "ith the se. variable as the number in bracets and the index variable
bein( used #or the ro" number in the param table as a comment.

This strin( variables value ma% never be used. !e then use the sli(htl% re"ritten method
=ispla%>rom+onstantsTable to (ive us an% constant value that the param attribute ma% have. The
=ispla%>rom+onstantsTable no" uses the same lo(ic as #or >ields and 4roperties$ onl% the #irst
parameter is used$ the second end is i(nored.

>or the sae o# not chan(in( the other method calls #or the method =ispla%>rom+onstantsTable
"e chose to maintain three parameters "hen "e are usin( onl% t"o. The i# statement ' also
simple$ "e chec #or a table name match as "ell as a ro" match. '# this happens "e #irst "rite out
the initial e.ual to si(n and then the constant value "hich code is unaltered.
244260235.doc 306 od 541

The problem is that the propert% table re.uires one less space than #ields and params. Thus "e
chec the strin( return value #rom the method =ispla%>rom+onstantsTable. '# it ' not null$ this
onl% means that "e have a constant value and thus the param directive must be displa%ed.

Thus "e have a i# statement that displa%s the param directive but "e must remember because o#
our initial desi(n this strin( has a enter at the end and there#ore "e use the !rite and not
!rite3ine method. !e also no" need to #i(ure out "hether this param has a custom attribute.

Thus "e #irst have a simple method 2as+ustom*ttribute that taes a table name and a ro"
number and tells us "hether this entit% o"ns a ro" in the +ustom*ttribute table. 'n this method
"e scan all the ro"s o# the +ustom*ttribute table and i# the coded index parent (ives us a ro"
and table name match "e return true and .uit the loop.

'# "e move out o# the loop$ it means no match and "e return #alse. )o" that the variable tells us
"hether "e have a custom attribute associated "ith our param directive or not$ "e use a i#
statement that checs that variable b is true as "ell as the str variable is null.

This is important as i# the str variable is non null$ the earlier i# statement displa%ed the param
directive. !e also add a space a#ter the param directive as i# it has no de#ault value$ it has to have
a extra space. )o" "e use the =ispla%+ustom*ttribute method to displa% the custom attributes i#
an% associated "ith this param ro" number.
4ro(ram47.csc
4ublic void =ispla%*ll0ethods5int t%peindex8
9
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII +ode
si&e 0 50x08F C FUrUnF<
i# 5 'sDlobal0ethod5methodindex88
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o#
(lobal method F C )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C FUrUnF<
else
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o#
method F C )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 C FMMF C
)ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C FUrUnF<
+onsole.!rite3ine5methodstrin(8<
@
public void =ispla%T%pe=e#s*nd0ethods 58
9
notprotot%pe A true<
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
@
+onsole.!rite3ine58<
+onsole.!rite3ine5FII AAAAAAAAAAAAAAA D3/O*3 >':3=; *)= 0:T2/=;
AAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
=ispla%Dlobal>ields58<
244260235.doc 307 od 541
=ispla%Dlobal0ethods58<
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
@

public void =ispla%Dlobal>ields 58
9
int start $ starto#next A0<
i# 5 T%pe=e#;truct AA null TT >ield;truct AA null8
return<
start A T%pe=e#;truct617.#index <
i# 5 T%pe=e#;truct.3en(th AA 2 8
starto#next A >ield;truct.3en(th<
else
starto#next A T%pe=e#;truct627.#index <
i# 5 start EA starto#next 8
9
+onsole.!rite3ine5FIIDlobal #ieldsF8<
+onsole.!rite3ine5FIIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVF8<
=ispla%*ll>ields 518<
@
@
public void =ispla%Dlobal0ethods 58
9
int start $ starto#nextA0<
start A T%pe=e#;truct617.mindex <
i# 5 T%pe=e#;truct AA null TT 0ethod;truct AA null8
return<

i# 5 T%pe=e#;truct.3en(th AA 2 8
starto#nextA 0ethod;truct.3en(th<
else
starto#next A T%pe=e#;truct627.mindex <
i# 5 start EA starto#next 8
9
+onsole.!rite3ine5FIIDlobal methodsF8<
+onsole.!rite3ine5FIIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVF8<
spaces#orrest A 0<
=ispla%*ll0ethods518<
spaces#orrest A 2<
@
@
public bool 'sDlobal0ethod 5int methodro"8
9
int start $ starto#nextA0<
methodro" $ T%pe=e#;truct.3en(th8<
244260235.doc 308 od 541
i# 5 T%pe=e#;truct.3en(th AA 28
return true<
start A T%pe=e#;truct617.mindex <
i# 5 T%pe=e#;truct.3en(th AA 1 8
9
starto#nextA 0ethod;truct.3en(th<
@
else
starto#next A T%pe=e#;truct627.mindex<
i# 5 methodro" HA start GG methodro" B starto#next 8
return true<
else
return #alse<
@

e.il
.namespace
9
.method static private void a158
9
@
.#ield static private int32 i
@
.class &&&
9
@

/utput
II AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA


II AAAAAAAAAAAAAAA D3/O*3 >':3=; *)= 0:T2/=; AAAAAAAAAAAAAAAAAAA

IIDlobal #ields
IIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVV
.#ield IJ04000001JI private static int32 i
IIDlobal methods
IIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVV
.method IJ06000001JI private static void
a158 cil mana(ed
II ;'DM 00 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 0 50x08
@ II end o# (lobal method a1


II AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

244260235.doc 309 od 541
'n this small pro(ram "e displa% all the (lobal method and #ields that "e have in the il #ile. 0ost
ne"er lan(ua(es do not support the concept o# (lobal #ields and variables but "e are #ortunate
that il does. !e told %ou a lon( time a(o that "e al"a%s have a extra t%pe that "ill handle (lobal
entities.

!e have in the =ispla%*ll0ethods a i# statement at the ver% end that checs "hether "e have a
(lobal #unction or not. !e have "ritten a #unction 'sDlobal0ethod that tells us "hether the
current method is (lobal or not b% passin( it the method number. 'n this method "e #irst chec i#
there are onl% (lobal methods in the il #ile.

This happens i# the len(th o# the T%pe=e# arra% is 2$ remember it is al"a%s lar(er b% one. !e also
told %ou that there is al"a%s a (lobal t%pe available. !e then #ind out as be#ore the #irst and last
method o"ned b% this (lobal t%pe. '# the method ro" #alls "ithin this ran(e "e return true or else
"e return #alse.

The onl% chan(e is that as al"a%s "e no not chec #or the last t%pe but #or the #irst t%pe. '# this
method returns true$ "e do displa% the t%pe name that is 0odule but add the "ords (lobal instead.
'n the method =ispla%T%pe=e#s*nd0ethods "e have add t"o lines in the be(innin( that call the
methods =ispla%Dlobal>ields and =ispla%Dlobal0ethods.

The method =ispla%Dlobal>ields #irst checs "hether the% are (lobal #ields available. 't does this
b% settin( start to the #index o# the #irst T%pe=e# entit% that is module. Then it sets the starto#next
to the second T%pede#.

*t times there is onl% a sin(le t%pe and hence "e then set starto#next to the len(th o# the number
o# ro"s in the >ield table. '# start and starto#next are the same$ "e have (lobal #ields and there#ore
displa% some text and call the =ispla%*ll>ields method "ith the t%pe ro" number as 1.

!e do the same #or the =ispla%Dlobal0ethods but no" also set the spaces#orrest at 2 #or the rest
o# the method that "ill #ollo" the (lobal methods. The settin( o# the variable has no e##ect on the
(lobal methods as there is no (lobal namespace #or (lobal #ields or methods and i# "e even add
one$ it (ets removed.

4ro(ram48.csc

e.il
.assembl% extern mscorlib
9
@
.mresource aa
9
.custom instance void 6mscorlib7a18MM.ctor58 A 5658
@
.assembl% extern vi1a%
9
.custom instance void 6mscorlib7a15MM.ctor58 A 5658
@
.assembl% e.dll
9
.custom instance void 6vi1a%7a14MM.ctor58 A 5658
@
244260235.doc 310 od 541
.module extern .dll
.custom instance void 6vi1a%7a12MM.ctor58 A 5658
.module aa.dll
.custom instance void 6vi1a%7a7MM.ctor58 A 5658
.#ile aa
.custom instance void 6mscorlib7a177MM.ctor58 A 5658
.class extern xxx
9
.custom instance void 6mscorlib7a17MM.ctor58 A 5658
.#ile aa
@
.class uuu
9
.permissionset assert A 512 8
.custom instance void 6vi1a%7a8MM.ctor58 A 5658
@
.class &&&
9
.custom instance void 6vi1a%7a4MM.ctor58 A 5658
.#ield public int32 p.r
.custom instance void 6vi1a%7a2MM.ctor58 A 5658
.method public void abc5int32 i $ int32 18
9
.param 617 A int85108
.custom instance void 6vi1a%7a5MM.ctor58 A 5658
@
.method public void abc158
9
.custom instance void 6vi1a%7a1MM.ctor58 A 5658
@
IJ
.method void x%&58
9
call void 6vi1a%7%%%MMp.r58
.custom instance void 6vi1a%7a6MM.ctor58 A 5658
@
JI
.propert% instance int32 aa58
9
.custom instance void 6vi1a%7a9MM.ctor58 A 5658
.(et instance void &&&MMabc158
@
.event 6vi1a%7re a
9
.custom instance void 6vi1a%7a10MM.ctor58 A 5658
.addon instance void &&&MMabc158
@
@
.class inter#ace iii
9
.custom instance void 6vi1a%7a5MM.ctor58 A 5658
244260235.doc 311 od 541
@
.custom 56vi1a%7a38 instance void 6vi1a%7a33MM.ctor58 A 5658
II.custom 56vi1a%7a6MMabc588 instance void 6vi1a%7a66MM.ctor58 A 5658

!e have not made an% ma1or additions to this pro(ram but simpl% added a series o#
=ispla%+ustom*ttribute methods calls at man% places. Thus "e "ill start "ith the il #ile and
sho" %ou code #ra(ments o# the #unctions "here "e have added the call o# the method
=ispla%+ustom*ttribute. !e have also tried to sho" %ou the il output and the method to(ether.
The #irst is the #unction abc "here "e move the method +reate;i(natures above the method
=ispla%0odule,e#s as "e "ould lie all the arra%s to be #illed up earlier.

public void abc5strin( 67 ar(s8
9
+reate;i(natures58<
=ispla%0odule,e#s 58<
=ispla%*ssemble%,e#s58<
@

public void =ispla%*ssemble%,e#s 58
9
i# 5*ssembl%,e#;truct AA null8
return<
#or 5 int i A 1 < i B *ssembl%,e#;truct.3en(th < iCC8
9
+onsole.!rite3ine5F.assembl% extern IJ2390@JI 91@F$ i.To;trin(5FK6F8 $
)ame,eserved5Det;trin(5*ssembl%,e#;truct6i7.name888<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute 5F*ssembl%,e#F $ i $ 2 8<

.assembl% extern IJ23000002JI vi1a%
9
.custom IJ0+00000*M0*000002JI instance void 6mscorlibIJ 23000001 JI7a15IJ 01000002
JIMM.ctor58 IJ 0*000002 JI A FeF
.ver 0M0M0M0
@

!e have a custom attribute in the *ssembl%,e# table and thus "e add the method
=ispla%+ustom*ttribute 1ust a#ter the 9 brace.

public void =ispla%*ssemble% 58
9
i# 5*ssembl%;truct.3en(th AA 18
return<
+onsole.!rite3ine5F.assembl% IJ20000001JI 90@F $
)ame,eserved5Det;trin(5*ssembl%;truct617.name888<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F*ssembl%F $ 1 $ 2 C space#ornamespace8<

.assembl% IJ20000001JI e.dll
9
244260235.doc 312 od 541
.custom IJ0+000006M0*000003JI instance void 6vi1a%IJ 23000002 JI7a14IJ 01000003 JIMM.ctor58
IJ 0*000003 JI A FeF
.ver 0M0M0M0
@

The second place is the *ssembl% table as this table has onl% one ro" "e have used the ro"
number as 1.

public void =ispla%+lass:xtern 58
9

+onsole.!rite5F.class extern IJ2790@JI 91@F $ ii.To;trin(5FK6F8 $ ss1 8<
+onsole.!rite3ine5ss8<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F:xportedT%peF $ ii $ 28<

@

.class extern IJ27000001JI xxx
9
.custom IJ0+000007M0*000006JI instance void 6mscorlibIJ 23000001 JI7a17IJ 01000006
JIMM.ctor58 IJ 0*000006 JI A FeF
.#ile aaIJ26000001JI
@

The third place is the +lass :xtern directive or "hat "e call the :xported T%pe.

public void =ispla%0odule*nd0ore58
9
+onsole.!rite3ine5F.module 90@F $ )ame,eserved5Det;trin(50odule;truct617.)ame888<
+onsole.!rite5FII 0-'=M F8<
=ispla%Duid50odule;truct617.0vid8<
+onsole.!rite3ine58<
=ispla%+ustom*ttribute5F0oduleF $ 1 $ 08<

.module aa.dll
II 0-'=M 9*>4812=>P31OOP48=0P87=5P964909:+>751@
.custom IJ0+000003M0*000005JI instance void 6vi1a%IJ 23000002 JI7a7IJ 01000005 JIMM.ctor58 IJ
0*000005 JI A FeF

The #ourth place is the 0odule table and once a(ain the ro" number is 1.

public void =ispla%*ll>ields 5int t%peindex8
9
+onsole.!rite3ine5F90@F $ returnstrin(8<
=ispla%+ustom*ttribute5F>ield=e#F $ #ieldindex $ spaces#ornested C spaces#orrest8<
@
@

.#ield IJ04000001JI public int32 p.r
244260235.doc 313 od 541
.custom IJ0+000001M0*000009JI instance void 6vi1a%IJ 23000002 JI7a2IJ 0100000*
JIMM.ctor58 IJ 0*000009 JI A FeF

The #i#th one is the attribute "ith #ields and "e place it ri(ht at the end o# the #unction.

+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F:ventF $ eventro" $ spaces#ornested C spaces#orrestC28<
#or 5 int A 1 < B 0ethod;emantics;truct.3en(th < CC8
9

.event IJ14000001JI 6vi1a%IJ 23000002 JI7reIJ 0100000: JI IJ0100000:JI a
9
.custom IJ0+000005M0*00000=JI instance void 6vi1a%IJ 23000002 JI7a10IJ 0100000>
JIMM.ctor58 IJ 0*00000= JI A FeF
.addon instance void &&&IJ 02000003 JIMMabc158 IJ 06000002 JI
@ II end o# event &&&MMa

!ith an event the attribute is placed at the be(innin( lie that o# a propert%.

public void =ispla%*ll4roperties 5int t%peindex8
9
=ispla%+ustom*ttribute5F4ropert%F $ propert%ro" $ 2 C spaces#orrest C spaces#ornested8<
#or 5 int A 1 < B 0ethod;emantics;truct.3en(th < CC8
9

@

.propert% IJ17000001JI instance int32 aa58
9
.custom IJ0+000004M0*00000+JI instance void 6vi1a%IJ 23000002 JI7a9IJ 0100000=
JIMM.ctor58 IJ 0*00000+ JI A FeF
.(et IJ06000002JI instance void &&&IJ 02000003 JIMMabc158 IJ 06000002 JI
@ II end o# propert% &&&MMaa

public void =ispla%:nd58
9
strin( nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6T%pe=e#;truct.3en(thP17.nspace88<
i# 5 E placedend8
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
placedend A true<
@
i# 5 nspace AA FF8
=ispla%+ustom*ttribute5FT%pe,e#F $ 0 $ 08<

.custom IJ0+00000=JI 56vi1a%IJ 23000002 JI7a3IJ 01000010 JIIJ01000010JI 8 instance void
6vi1a%IJ 23000002 JI7a33IJ 01000011 JIMM.ctor58 IJ 0*00000: JI A FeF
IIJJJJJJJJJJJ =';*;;:0O3W +/043:T: JJJJJJJJJJJJJJJJJJJJJJJ
244260235.doc 314 od 541

!e then need to add the T%pe,e# custom attribute at the ver% end o# the output and thus use the
=ispla%:nd i# the namespace is null. *lso "e need the T%pe,e# #or the case "here the namespace
is not null.

public void =ispla%/neT%pe=e#:nd 5int t%peindex 8
9
i# 5 nspace1 EA nspace2 8
9
i# 5 lastt%pedispla%ed AA t%peindex GG notprotot%pe 8
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
placedend A true<
=ispla%+ustom*ttribute5FT%pe,e#F $ 0 $ 28<
@
@

public void =ispla%>ileTable 58
9

=ispla%+ustom*ttribute 5F>ileF $ ii $ 08<
@
@

.#ile IJ26000001JI aa
.custom IJ0+000007M0*000006JI instance void 6mscorlibIJ 23000001 JI7a177IJ 01000006
JIMM.ctor58 IJ 0*000006 JI A FeF

!e have added the method =ispla%+ustom*ttribute at the end o# the =ispla%>ileTable method.

+ustoms that did not happen

e.il
.assembl% extern vi1a%
9
@
.mresource aa
9
.custom instance void 6vi1a%7a18MM.ctor58 A 5658
@
.class &&&
9
}

.mresource IJ28000001JI aa
9
II !*,)')DM mana(ed resource #ile aa created
@
244260235.doc 315 od 541

!e have a custom attribute in the mresource directive and ilasm 1ust does not create an entr% in
the +ustom*ttribute table #or it. 'n the next series o# examples "e "ill manuall% add a custom
attribute and #i(ure out ho" ildasm handles it.

e.il
.assembl% extern vi1a%
9
@
.mresource aa
9
@
.class &&&
9
.custom instance void 6vi1a%7a18MM.ctor58 A 5658
@

!e create a simple il #ile "ith a custom attribute in a t%pe and a sin(le mresource directive. !e
print out the initial b%tes o# the custom attribute table and search #or these b%tes in a hex editor.
!e used Nltra :dit as explained earlier. 'n our case the #irst six b%tes o# the +ustom*ttribute
table are 43 0 O 0 5 0. The #irst t"o b%tes are the parent coded index. The #irst 5 bits o# the #irst
b%te 43 are the table number. This is 3 the table number o# a T%pe=e# and the last 13 bits have a
value o# 2. This is as the #irst T%pe=e# "e create is number as the (lobal t%pe de# is number 1. !e
chan(e the #irst b%te to 32 as the #irst 5 bits are 18$ the code #or a mani#est resource and the last
three bits taen b% themselves are 1$ to stand #or ro" number 1. !hen "e run ildasm on e.dll$ "e
(et the #ollo"in( output.

.mresource IJ28000001JI aa
9
.custom IJ0+000001M0*000001JI instance void 6vi1a%IJ 23000001 JI7a18IJ 01000002 JIMM.ctor58
IJ 0*000001 JI A FeF
II !*,)')DM mana(ed resource #ile aa created
@

Thus ildasm reco(ni&es a custom attribute and ilasm does not. !e have not added code to our
mresource directive to displa% a custom attribute.

.assembl% extern vi1a%
9
@
.module extern aa.dll
.custom instance void 6vi1a%7a18MM.ctor58 A 5658
.class &&&
9
@

!e have added a custom attribute to the module extern directive and ilasm i(nores it. !e once
a(ain (et bac to the earlier pro(ram and no" chan(e the #irst b%te #rom 43 to 2+ as "e "ant the
#irst 5 bits to be 12 the code #or a module re# table and the last three bits to be 1.

.module extern aa.dll IJ1*000001JI
244260235.doc 316 od 541
.custom IJ0+000001M0*000001JI instance void 6vi1a%IJ 23000001 JI7a18IJ 01000002
JIMM.ctor58 IJ 0*000001 JI A FeF

!hen "e run ildasm on e.dll$ "e see the custom attribute belo" the module extern directive.

.assembl% extern vi1a%
9
@
.class &&&
9
.permissionset assert A 5 41 428
.custom instance void 6vi1a%7a18MM.ctor58 A 5658
@

!e have added the .permissionset directive and a custom attribute belo" it. 'lasm instead o#
associatin( the custom directive "ith the =ecl securit% associates it "ith the t%pe. !e once a(ain
chan(e the #irst b%te to 28 as 8 is the number #or securit%. !hen "e run ildasm "e (et the
#ollo"in( output.

.permissionset assert A 541 42 8 II *O
.custom IJ0+000001M0*000001JI instance void 6vi1a%IJ 23000001 JI7a18IJ 01000002 JIMM.ctor58
IJ 0*000001 JI A FeF

/nce a(ain ildasm passes "here ilasm #ails.

.assembl% extern vi1a%
9
@
.class &&& implements iii
9
@
.class inter#ace iii
9
@
.class %%%
9
.custom instance void 6vi1a%7a18MM.ctor58 A 5658
@

'n this case the #irst b%te is 83 as the T%pe=e# ro" is no" 3 and not 2. !e chan(e it to 25 as "e
"ant ro" 1 and 5 is the code #or the inter#ace implementation. 'n this case the custom attribute
comes at the bottom as.

.custom IJ0+000001JI 5N)\)/!)R/!):,IJ09000001JI 8 instance void 6vi1a%IJ 23000001
JI7a18IJ 01000003 JIMM.ctor58 IJ 0*000001 JI A FeF

The 'nter#ace'mpl table has a number o# 9. !e have three more 0ember,e#$ T%pe;pec and
;tand*lone;i( that "e "ill do later.

4ro(ram49.csc
4ublic void =ispla%*ll0ethods5int t%peindex8
244260235.doc 317 od 541
9
strin( vtentr%strin( A Det-tentr%;trin(5methodindex8<
methodstrin( A vtentr%strin(<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII 0ethod
be(ins at ,-* 0xF C 0ethod;truct6methodindex7.rva.To;trin(5Fx4F8<
+onsole.!rite5methodstrin(8<
lon( #ileo##set A +onvert,-*50ethod;truct6methodindex7.rva8<
m#ilestream.;ee5#ileo##set $ ;ee/ri(in.Oe(in8<
=ispla%>at>ormat 5)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 $
)ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 $ methodindex 8<
@
@
public void =ispla%>at>ormat5strin( classname $ strin( methodname $ int methodindex8
9
=ispla%'nitial0ethod2eader5methodindex8<
=ispla%0ethod'3+ode5classname $ methodname $ methodindex8<
@
public void =ispla%'nitial0ethod2eader 5int methodindex8
9
int tin% A mbinar%reader.,eadO%te58<
i# 5 5tin% G 0x038 AA 0x038
tin%#ormat A #alse<
else
9
+onsole.!rite3ine5F.....90@F $ tin%8<
tin%#ormat A true<
@
m#ilestream.;ee5P1$;ee/ri(in.+urrent8<
strin( methodstrin( A FF<
i# 5 Etin%#ormat 8
9
lon( "here A m#ilestream.4osition<
short #irst A mbinar%reader.,ead'nt1658<
#irst12 A 5short85#irst G 0x0###8<
short stacsi&e A mbinar%reader.,ead'nt1658<
codesi&e A mbinar%reader.,ead'nt3258<
methodstrin( A FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII +ode si&e F C
codesi&e.To;trin(58 C F 50xF C codesi&e.To;trin(5FxF8 C F8UrUnF<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2C spaces#ornested8 C F.maxstac F
C stacsi&e.To;trin(58<
int standalonesi( A mbinar%reader.,ead'nt3258<
int ro"standalonesi( A standalonesi( G 0x00######<
+onsole.!rite3ine5F.....90@F $ standalonesi(.To;trin(5FK8F88<
i# 5;tand*lone;i(;truct EA null GG standalonesi(arra% AA null8
standalonesi(arra% A ne" strin(6;tand*lone;i(;truct.3en(th7<
i# 5 ro"standalonesi( EA 0 8
9
+reate;i(nature>or:achT%pe 55 $ ;tand*lone;i(;truct6ro"standalonesi( 7.index $
ro"standalonesi(8<
i# 5standalonesi(arra% 6ro"standalonesi( 7 EA FF8
9
244260235.doc 318 od 541
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2C spaces#ornested8 C
F.locals IJ11F C ro"standalonesi(.To;trin(5FK6F8 C FJI F<
i# 55#irst12G0x108 AA 0x10 8
methodstrin( A methodstrin( C Finit 5F <
else
methodstrin( A methodstrin( C F5F <
methodstrin( A methodstrin( C standalonesi(arra%6ro"standalonesi( 7<
methodstrin( A methodstrin( C F8F<
@
@
@
else
9
mbinar%reader.,eadO%te58<
codesi&e A tin% HH 2<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested 8 C FII
+ode si&e F C codesi&e.To;trin(58 C F 50xF C codesi&e.To;trin(5FxF8 C F8F<
i# 5codesi&e EA 08
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2C spaces#ornested8 C
F.maxstac 8F <
@
+onsole.!rite3ine5methodstrin(8<
@
public void +reate;i(nature>or:achT%pe 5b%te t%pe $ int index $ int ro"8
9
int uncompressedb%te $ count $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blob1 A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blob1 $ 0 $ count8<
i# 5 t%pe AA 78
+reate4ropert%;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 68
+reate>ield;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 58
+reate3ocal-ar;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 18
+reate0ethod=e#;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 28
+reate0ethod,e#;i(nature5blob1 $ ro"8<
@
public void +reate3ocal-ar;i(nature 5b%te 67 blobarra% $ int ro"8
9
int index A 0<
standalonesi(arra%6ro"7 A FF<
i# 5 blobarra%6index7 EA 0x078
return<
indexCC<
int ho"man%b%tes$uncompressedb%te <
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
244260235.doc 319 od 541
strin( returnstrin( A FF<
#or 5 int l A 1 < l BA uncompressedb%te < lCC8
9
strin( t%pestrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8<
t%pestrin( A t%pestrin(.,eplace5F`F$F$F8<
int variable-index A l P 1 <
returnstrin( A returnstrin( C t%pestrin( C F -RF C variable-index.To;trin(58 <
i# 5 l EA uncompressedb%te8
returnstrin( A returnstrin( C F$UrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C
+reate;paces598<
index A index C ho"man%b%tes<
@
standalonesi(arra% 6ro"7 A returnstrin(<
@
public void =ispla%0ethod'3+ode 5 strin( classname $ strin( methodname $int methodindex8
9
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@F8<
i# 5DetT%pe>or0ethod 5methodindex8AA 18
+onsole.!rite3ine5F II end o# (lobal method 90@UrUnF $ methodname8<
else
+onsole.!rite3ine5F II end o# method 90@MM91@UrUnF $ classname $ methodname8<
@
strin( 67 standalonesi(arra%<
int codesi&e <
bool tin%#ormat<
int #irst12<
@

e.il
.class &&&
9
.method void x%&58
9
@
.method void x%&58
9
.locals 5 int32 -R1 $ int8 18
.maxstac 2
ret
@
.method void x%&58
9
.locals init 5 int8 18
ret
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
244260235.doc 320 od 541
9
II 0ethod be(ins at ,-* 0x2050.....2
II +ode si&e 0 50x08
@ II end o# method &&&MMx%&

.method IJ06000002JI privatescope instance void
x%&Z4;T0600000258 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2054.....11000001
II +ode si&e 1 50x18
.maxstac 2
.locals IJ11000001JI 5int32 -R0$
int8 -R18
@ II end o# method &&&MMx%&

.method IJ06000003JI privatescope instance void
x%&Z4;T0600000358 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2064.....11000002
II +ode si&e 1 50x18
.maxstac 8
.locals IJ11000002JI init 5int8 -R08
@ II end o# method &&&MMx%&


)o" is "hen the #un starts as "e are actuall% movin( to displa% or disassemble all the il code in a
method. !e #irst start o## "ith the =ispla%*ll0ethods methods "here #or the last time "e mae
an% chan(es. !e replace the last lines "ith the above lines. The 0ethod arra% has a #ield rva that
tells us "here the code #or this method is to be #ound in memor%.

!e use the +onvert,-* method to tell us "here this location is on dis. !e then use the ;ee
#unction to move the #ile pointer to this position and call a method named =ispla%>at>ormat to
"rite out all the il code #or us. !e pass this method the t%pename$ the method name and the
method index.

!hen "e arrive at this #unction$ "e #ind that "e are callin( t"o more #unctions$ so lets loo at
the #irst =ispla%'nitial0ethod2eader "hich is simpl% passed the methodindex variable. The #irst
thin( "e do is read the #irst b%te o# the method structure. This is the b%te that tells us "hat is the
t%pe o# method structure$ tin% or lar(e.

*ctuall% "e onl% need to loo at the #irst bits o# the #irst b%te. '# its value is 2$ then method
header is tin% or else #or the lar(e t%pe is 3. *s there is no third t%pe$ "e (et a"a% "ith a simple i#
and else. This distinction is made mainl% dependin( upon the si&e o# code.

!e have a instance variable tin%#ormat that is set to true i# the #irst three bits are not 3. )o" that
"e have read the #irst b%te$ "e need to move the #ile pointer bac one and then reread the b%tes
a(ain dependin( upon "hether it is a tin% or lar(e #ormat.

244260235.doc 321 od 541
Thus the method =ispla%>at>ormat should have be renamed =ispla%>at*ndTin%>ormat as it
reads both. 3ets start "ith the more complex #ormat the #at one. This is normall% the de#ault
#ormat and applies to methods "here the code si&e is lar(er than 5 bits or lar(er than 32 b%tes.

*lso methods that have exceptions$ local variables$ extra data sections and the operand stac
needs to handle more than 8 entities all need the #at #ormat. *s "e said be#ore the tint #ormat is
#oe the methods that reall% do nothin(. !e store in the variable "here the current position o# the
#ile pointer that "e "ill use later.

!e also rePread the #irst short "hose three b%tes told us the t%pe o# #ormat. !e need onl% the #irst
12 bits and thus "e mas o## the last #our bits. The top most #our bits (ives us a si&e o# the header
that "e "ill see later. ,emember these 12 bits are called #la(s even thou(h "e have onl% 4 #la(s
o# "hich the tin% and #at have alread% been done.

Thus "e have t"o #la(s onl% to decipher. This #la(s is #ollo"ed b% a short that tells us the si&e o#
the stac. Then "e have a int that is the si&e o# the code and "e immediatel% #irst add the +ode
;i&e to the methodstrin( variable. This is #ollo"ed b% the si&e o# the stac. The codesi&e is not a
directive but maxstac is.

Then a method ma% have variables that are local. These are enclosed "ithin the .locals directive
and have the same #ormat as parameters$ but the% cannot have names lie parameters but
computer (enerated names be(innin( "ith -R and the local variable ordinal number. The last int
(ives us a toen "hich tells us "here the local variables can be #ound.

>or those o# %ou "ith a short memor%$ the top b%te o# a toen is the table number and the
remainin( three b%tes the ro" number. *s "e have displa%ed the si(nature toen$ the #irst b%te
"ill be 11 the stand alone si(nature table number. '# this ro" number is &ero$ then "e no" that
the method has no local variables.

:arlier "e made a simple mistae. Oe#ore our pro(ram started displa%in( stu## "e calculated all
the method si(natures in the +reate;i(natures method. )o" that "a% "as "ritten in stone and
hence he have used another "a%. !e #irst chec "hether the arra% ;tand*lone;i(;truct is not
null and our standalonesi(arra% strin( arra% is also not null.

The #irst chec is to mae sure that "e have some method that has local variables and the second
to mae sure that "e create our strin( arra% standalonesi(arra% onl% once.

Then "e chec "hether this method has local variables and i# %es$ "e call the method
+reate;i(nature>or:achT%pe "ith a number 5$ the t%pe #or stand alone si(natures and then
#ollo"ed b% the blob arra% o##set and the ;tand*lone;i( table ro" number ro"standalonesi( to
set the standalonesi(arra% arra% member to.

This simpl% sets one member o# the arra% to a si(nature. !e "ill come to the
+reate;i(nature>or:achT%pe method a little later. )o" i# the correspondin( standalonesi(arra%
arra% member is not null "e "rite out the directive locals alon( "ith the si(nature.

The locals directive has one more e%"ord init that "ill call the de#ault constructors #or all the
local variables. This #la(s has a value o# 0x10 and "e then "rite out the open and close bracets
o# the locals directive. This completes the #at #ormat the tin% #ormat is reall% ver% simple.

244260235.doc 322 od 541
!e read the #irst b%te and then ri(ht shi#t it b% t"o to remove the #irst t"o bits that "ere the #la(s.
This no" (ive us the si&e o# the code that "e "rite out and i# the code si&e is not &ero$ the si&e o#
the stac is 8. This completes the initial readin( o# the method header.

'n the +reate;i(nature>or:achT%pe method$ "e simpl% call the method
+reate3ocal-ar;i(nature. This is once a(ain a si(nature that is eas% #or us as the #irst b%te is
al"a%s 7. The next b%te is the count o# the number o# local variables that mae up the si(nature.
This is #ollo"ed b% the individual local variable data t%pes that "e pic up usin( the
Det:lementT%pe method.

!e also replace the ` "ith the comma #or arra%s. !e then need to "rite out the name o# the
variable and hence start "ith -R and the loop variable l minus 1 as the count starts "ith 0. !e
then need to place a comma$ #ollo"ed "ith a enter as each o# these variables needs to be on a ne"
line "ith the ri(ht amount o# spaces.

Thus this code cannot be called #or the earlier si(natures as then "e do not have the value o# the
variables spaces#ornested and spaces#orrest. !e #inall% set the standalonesi(arra% arra% "ith the
returnstrin( variable.

!e have the method =ispla%0ethod'3+ode that onl% displa%s some spaces and then dependin(
upon "hether it is a (lobal method or not displa%s the end o# the method. !e could have used the
method 'sDlobal0ethod instead o# DetT%pe>or0ethod at all times.

)o" comin( to the '3 code (enerated b% our pro(ram$ "e have the #irst #unction sho" us that it
has the tin% #ormat as the else is true and the #irstb%te has a value o# 2 "hich also (ives the code a
si&e o# &ero.

>or the second t"o methods$ the local var toen starts "ith 0x11 and then "e have the ro"
numbers in the ;tand*lone;i( table and not the method table. '# "e speci#% a maxstac$ then ours
(ets used or else a de#ault value o# 8 is taen. *lso #or the tint #ormat the maxstac has no place
"here it can be stored.

'# "e mae the mistae o# (ivin( a local variable a name$ ilasm removes the name and "e then
have to (enerate a standard name #or it.

4ro(ram50.csc
public void =ispla%0ethod'3+ode 5 strin( classname $ strin( methodname $int methodindex8
9
b%te 67 codearra% A ne" b%te6codesi&e7<
#or 5 int i A 1 < i BA codesi&e < iCC8
9
codearra%6iP17 A mbinar%reader.,eadO%te58<
+onsole.!rite5F 90@F $ codearra%6iP17.To;trin(5FKF8 8<
@
+onsole.!rite3ine58<
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@F8<
@

e.il
.class &&&
244260235.doc 323 od 541
9
.method void x%&58
9
.locals 5 int32 -R1 $ int8 18
.maxstac 2
ret
nop
ret
nop
ret
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 5 50x58
.maxstac 2
.locals IJ11000001JI 5int32 -R0$
int8 -R18
2* 0 2* 0 2*
@ II end o# method &&&MMx%&

)o" is "hen "e start out boo. 't is in the method =ispla%0ethod'3+ode that "e (et our hands
on the il code. This il code is available 1ust a#ter the initial method structure. !e need to store
this code in an arra% codearra% that "e initiali&e to the si&e o# the code that "e have stored in the
instance variable codesi&e.

!e read each b%te into the arra% and then simpl% displa% the members o# the arra%. !hat "e see
is the ret instruction that must be present as the last instruction o# ever% method has a value o#
0x2a. The nop instruction that behaves lie most o# the "orld has a value o# &ero as it is supposed
to do nothin(.

Thus a#ter the method structure "e have a series o# b%tes that "e "ill have to decipher into il
code. The next pro(ram does 1ust that.

4ro(ram51.csc
usin( ;%stem.,e#lection<
usin( ;%stem.,e#lection.:mit<

public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
244260235.doc 324 od 541
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
,eadand=ispla%:xport*ddressTable?umps58<
>ill*rra%58<
>ill/p+ode*rra% 58<
+reate;i(natures58<
@
/p+ode 67 /p+odes*rra%<
/p+ode 67 /p+odes*rra%1<
public void >ill/p+ode*rra%58
9
/p+odes*rra% A ne" /p+ode6660007<
/p+odes*rra%1 A ne" /p+ode6327<
>ield'n#o67 #ields A t%peo#5/p+odes8.Det>ields5Oindin(>la(s.4ublic T Oindin(>la(s.)on4ublic T
Oindin(>la(s.;tatic T Oindin(>la(s.'nstance T Oindin(>la(s.=eclared/nl%8<
#oreach 5>ield'n#o # in #ields8
9
/p+ode o A 5/p+ode8 #.Det-alue5null8<
i# 5 o.-alue BA 255 GG o.-alue HA 08
/p+odes*rra%65short8o.-alue7 A o<
@
@
public void =ispla%0ethod'3+ode 5 strin( classname $ strin( methodname $int methodindex8
9
b%te 67codearra% A ne" b%te6codesi&e7<
#or 5 int i A 1 < i BA codesi&e < iCC8
codearra%6iP17 A mbinar%reader.,eadO%te58<
#or 5 int arra%o##set A 0 < arra%o##set B codesi&e < 8
9
int instructionb%te A codearra%6arra%o##set7<
/p+ode opcode<
opcode A /p+odes*rra% 6instructionb%te7<
strin( strin(s A +reate;paces5spaces#orrestC2C spaces#ornested8<
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FK2F8 C
F T F<
int si&eo#instructionanddata A =ecode'3'nstrcution25 opcode $ arra%o##set $ codearra% $
methodindex $ strin(s8<
+onsole.!rite3ine58<
arra%o##set A arra%o##set C si&eo#instructionanddata<
@
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@F8<
i# 5 DetT%pe>or0ethod5methodindex8AA 18
+onsole.!rite3ine5F II end o# (lobal method 90@UrUnF $ methodname8<
else
+onsole.!rite3ine5F II end o# method 90@MM91@UrUnF $ classname $ methodname8<
@
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
int si&eo#instructiondata A 0<
244260235.doc 325 od 541
i# 5 opcode./perandT%pe AA /perandT%pe.'nline)one8
9
+onsole.!rite5strin(s8<
+onsole.!rite5F90@JI 91@F$+reate;paces5178 $ opcode.)ame8<
i# 5 opcode.)ame AA FretF GG codeindex EA 5codearra%.3en(th P18 8
+onsole.!rite3ine58<
i# 5 opcode.)ame AA Fthro"F GG codeindex EA 5codearra%.3en(th P18 8
+onsole.!rite3ine58<
si&eo#instructiondata A1<
@
return si&eo#instructiondata<
@
@

e.il
.class &&&
9
.method void x%&58
9
.locals 5 int32 -R1 $ int8 18
.maxstac 2
sub
ret
add
mul
nop
ret
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 6 50x68
.maxstac 2
.locals IJ11000001JI 5int32 -R0$
int8 -R18
'3R0000M IJ 59 T JI sub
'3R0001M IJ 2* T JI ret

'3R0002M IJ 58 T JI add
'3R0003M IJ 5* T JI mul
'3R0004M IJ 00 T JI nop
'3R0005M IJ 2* T JI ret
@ II end o# method &&&MMx%&

>inall% "e have some il code disassembled. !hen %ou loo at the il #ile$ "e have a series o# il
instructions popularl% called opcodes. !e have used ones lie ret and nop earlier and no" add$
244260235.doc 326 od 541
mul etc. These opcodes have one thin( in common$ the% all tae no parameters. The il "orld has
divided the il instructions into a #amil% dependin( upon the parameters or operands that the% tae.

*ll il instructions that have the same operand t%pe behave in a similar manner. The il "orld has
also (iven us a enum called /perandT%pe that tells us ho" man% di##erent t%pes o# operands a il
instruction taes. !hat "e no" need to do is handle each operand t%pe.

!hat "e cannot do is tell ourselves that "e have a series o# i# statements that taes each opcode
and #i(ures out "hat the name o# the opcode is and "hat is its operand t%pe. !e need a more
(eneric "a% o# handlin( the above problem. 3ets tae a loo at method abc #irst.

!e have introduced a ne" method >ill/p+ode*rra% 1ust be#ore "e create the method si(natures.
!e have also de#ined t"o instance arra%s /p+odes*rra% and /p+odes*rra%1 o# t%pe /p+ode.
These classes are #rom the ;%stem.,e#lection namespace. The /p+ode structure represents a 'l
instruction.

't has properties lie )ame that tells us the name o# the 'l instruction$ /perandT%pe that tell us
the /perand t%pes that this instruction taes and -alue that tell us the b%te value or number o# the
il instruction. >or example the above pro(ram sho"ed us that 0x2a is the value o# the ret
instruction$ and 0 #or nop.

Thus "e no" need #ill up the /p+odes*rra% "ith a valid /p+ode ob1ect that represents each
opcode. *s 0x2* represents a ret instruction$ the 2a member o# the /p+odes*rra% arra% should
stand #or the ret instruction. 'n the method >ill/p+ode*rra%$ this is "hat "e do.

!e #irst initiali&e the /p+odes*rra% arra% to a ver% lar(e value o# members 66000 and the
second arra% to 32 members onl%. This second arra% "ill be used later. The #oreach loop lets us
iterate throu(h an ob1ect. The >ield'n#o class simpl% provides access to the metadata #or #ield
attributes.

The Det>ields #unction "hich is part o# the T%pe class (ets us all the #ields #rom the T%pe that
calls it. 'n this case "e re.uire all the #ields #rom the class /p+odes. :ver% valid opcode in the '3
instruction set is a #ield in the /p+ode class. Thus i# "e have 500 il instructions "e "ill have 500
#ields in the /p+ode class.

These #ields are static and read onl%. To be speci#ic$ the /p+ode class has 221 #ields in all. This
"a% "e can #i(ure out all the #ields that a certain class has. The parameter to the Det>ields
#unction allo"s us to (et at those #ields that meet certain conditions lie the% must be static or
public etc.

)o" that "e have all the '3 instructions "ith us in the >ield'n#o arra% "e simpl% use the
Det-alue method to (ive us the actual #ield. The arra% on the le#t is t%pe /p+ode and Det-alue
returns an ob1ect and hence the cast. Thus variable o no" is the /p+ode ob1ect "here o.)ame is
the name o# the /p+ode sa% ret and o.-alue is its b%te value 0x2a.

)o" all that "e have to do is initiali&e the 2a member o# the arra% "ith o "hich is "hat "e do in
the next line. !e onl% tae those opcodes that lie bet"een 0 and 255 onl%. The other cases "e "ill
handle di##erentl% a little later. Thus "e no" have an arra% "ith all the opcode values$ name and
t%pes o# parameters.

244260235.doc 327 od 541
3ets no" move on to the method =ispla%0ethod'3+ode "hich #irst reads all the b%te codes into
the codearra% arra%. Then "e use another #or loop to iterate throu(h this arra%. !e #irst pic up
the #irst or &eroth b%te #rom the codearra% usin( the loop variable arra%o##set.

!e no" that this b%te is an opcode value and not data and thus pic up the relevant /p+ode
structure that represents it #rom the /p+odes*rra% arra%. Thus i# variable instructionb%te had a
value 0x2a$ then opcode "ould stand #or the /p+ode #or the ret instruction.

!e "rite out the initial spaces as al"a%s and then the "ords '3R #ollo"ed b% the instruction o##set
"ithin the code b%tes. This is represented b% the loop variable arra%o##set. !e then have to add a
colon some spaces and then in comments the actual opcode value$ 2a #or a ret.

Then some more spaces and a or si(n T . ;ome instructions "rite some data a#ter the or si(n. Thus
"hat "e have done so #ar is "hat is the same #or each instruction. !e no" call the method
=ecode'3'nstrcution2 to "rite out the actual instruction #or us.

!e pass it the /p+ode representin( the instruction$ the arra% o##set #rom the be(innin( o# the #irst
b%te o# code arra%o##set$ the entire codearra% o# all the b%tes$ the methodindex o# the method and
#inall% the initial strin( that "e have 1ust created o# the instruction stored in the variables strin(s.

This #unction a#ter "ritin( out the entire sin(le instruction$ "ill then return a ans"er that "ill (ive
us ho" man% b%tes this instruction has taen. This is important as the il instructions tae up a
variable number o# b%tes.

!e add this return value to arra%o##set so that the arra%o##set variable points to the next il
instruction at the start o# the loop. Thus all our #ocus #rom no" on "ill be on the
=ecode'3'nstrcution2 method. 3ets move there no".

'n this method "e have a series o# i# statements that handle each operand t%pe. The #irst one "e
chec #or is 'n3ine)one "here "e have no operands at all. Thus "e use the parameter opcode
and chec "hether its #ield /perandT%pe e.uals the value o# the enum /perandT%pe 'n3ine3ine.

'# "e #ind a match "e #irst "rite out the initial b%tes that "e are passed and then the name o# the
opcode. The name does not have to ret as there are a hundred opcodes that have a t%pe
'n3ine)one. This is "h% "e simpl% use the )ame propert% and "e do have to "orr% about the
name o# the /p+ode.

This "a% "e do have a hundred i# statements that chec each opcode value and "rite out a name.
The onl% problem is that onl% i# the opcode name is ret or thro" and "e are not the last
instruction$ "e should "rite out a enter. Thus i# a ret or thro" is the last instruction$ a extra enter
"ill no" be "ritten out$ else it "ill be.

*lso the variable si&eo#instructiondata "ill return the number o# b%tes taen up b% this instruction
t%pe and #or no operands the value is obviousl% one. This "a% "e "ill handle each /perand T%pe.
3ets sum up "hat "e have done so #ar. *s there are #ar too man% '3 instructions #or our liin($ "e
create an arra% o# /p+ode structures that "ill handle each '3 instruction. !hat "e need to no"
is the name and operand t%pes that this '3 instruction "ill tae. !e read each b%te #rom the
codesi&e arra% and then read the correspondin( /p+ode #rom the /p+odes*rra% arra%. Then "e
#i(ure out its operand t%pe and handle each operand t%pe di##erentl%. 3ets see it "or "ith the
next example.

244260235.doc 328 od 541
e.il
.class &&&
9
.method void x%&58
9
ar(list
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 2 50x28
.maxstac 8
'3R0000M IJ >: T JI pre#ix1
'3R0001M IJ 00 T JI nop
@ II end o# method &&&MMx%&

Thin(s 1ust do not cut it. !e have used a simple '3 instruction ar(list and #or some reason "e (et
t"o instructions. !h%. The (u%s "ho desi(ned the '3 instruction set toe some inspiration #rom
the ?ava (u%s "ho had the concept o# a b%te code "hich said that ever% instruction should not be
lar(er than one b%te or have a value ran(in( #rom 0 to 255.

Nn#ortunatel% there are too man% '3 instructions and hence the%
desi(ned a di##erent "a% o# (ivin( them values. The #irst 225 or 0 to 224 '3 opcodes have a direct
value. >rom no" on thin(s chan(e. The ar(list has a value >: 00 as >: stands #or 4re#ix 1 and
there are seven such pre#ixes.

Thus "e #irst need to chec the #irst b%te and i# it is lar(er than >8 "e have a pre#ix b%te. >> is
the last sin(le b%te instruction and is called the pre#ixre#. Thus #or t"o b%te instructions "e have
to i(nore the #irst b%te and simpl% read the second. Thus "e have to mae modi#ications in our
pro(ram to handle t"o b%te instructions.

4ro(ram52.csc
public void >ill/p+ode*rra%58
9
/p+odes*rra% A ne" /p+ode62567<
/p+odes*rra%1 A ne" /p+ode6327<
>ield'n#o67 #ields A t%peo#5/p+odes8.Det>ields5Oindin(>la(s.4ublic T Oindin(>la(s.)on4ublic T
Oindin(>la(s.;tatic T Oindin(>la(s.'nstance T Oindin(>la(s.=eclared/nl%8<
#oreach 5>ield'n#o # in #ields8
9
/p+ode o A 5/p+ode8 #.Det-alue5null8<
i# 5 o.-alue BA 255 GG o.-alue HA 08
/p+odes*rra%65short8o.-alue7 A o<
/p+odes*rra%165ushort8 0x007 A /p+odes.*r(list<
/p+odes*rra%165ushort8 0x017 A /p+odes.+e.<
/p+odes*rra%165ushort8 0x027 A /p+odes.+(t<
/p+odes*rra%165ushort8 0x037 A /p+odes.+(tRNn<
244260235.doc 329 od 541
/p+odes*rra%165ushort8 0x047 A /p+odes.+lt<
/p+odes*rra%165ushort8 0x057 A /p+odes.+ltRNn<
/p+odes*rra%165ushort8 0x067 A /p+odes.3d#tn<
/p+odes*rra%165ushort8 0x077 A /p+odes.3dvirt#tn<
/p+odes*rra%165ushort8 0x097 A /p+odes.3dar(<
/p+odes*rra%165ushort8 0x0*7 A /p+odes.3dar(a<
/p+odes*rra%165ushort8 0x0O7 A /p+odes.;tar(<
/p+odes*rra%165ushort8 0x0+7 A /p+odes.3dloc<
/p+odes*rra%165ushort8 0x0=7 A /p+odes.3dloca<
/p+odes*rra%165ushort8 0x0:7 A /p+odes.;tloc<
/p+odes*rra%165ushort8 0x0>7 A /p+odes.3ocalloc<
/p+odes*rra%165ushort8 0x117 A /p+odes.:nd#ilter<
/p+odes*rra%165ushort8 0x127 A /p+odes.Nnali(ned<
/p+odes*rra%165ushort8 0x137 A /p+odes.-olatile<
/p+odes*rra%165ushort8 0x147 A /p+odes.Tailcall<
/p+odes*rra%165ushort8 0x157 A /p+odes.'nitob1<
/p+odes*rra%165ushort8 0x177 A /p+odes.+pbl<
/p+odes*rra%165ushort8 0x187 A /p+odes.'nitbl<
/p+odes*rra%165ushort8 0x1*7 A /p+odes.,ethro"<
/p+odes*rra%165ushort8 0x1+7 A /p+odes.;i&eo#<
/p+odes*rra%165ushort8 0x1=7 A /p+odes.,e#an%t%pe<
@
@
public void =ispla%0ethod'3+ode 5 strin( classname $ strin( methodname $int methodindex8
9
b%te 67 codearra% A ne" b%te6codesi&e7<
#or 5 int i A 1 < i BA codesi&e < iCC8
codearra%6iP17 A mbinar%reader.,eadO%te58<
#or 5 int arra%o##set A 0 < arra%o##set B codesi&e < 8
9
int instructionb%te A codearra%6arra%o##set 7<
/p+ode opcode<
strin( strin(s A FF<
i# 5 instructionb%te AA 0x>:8
9
instructionb%te A codearra%6arra%o##set C17<
opcode A /p+odes*rra%1 6instructionb%te7 <
strin(s A +reate;paces5spaces#orrestC2C spaces#ornested8<
strin(s A strin(s C F'3RF C arra%o##set.To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FKF8 C F
T F<
arra%o##set A arra%o##set C 1<
@
else
9
opcode A /p+odes*rra%6instructionb%te7<
strin(s A +reate;paces5spaces#orrestC2C spaces#ornested8<
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FK2F8 C
F T F<
@
int si&eo#instructionanddata A =ecode'3'nstrcution2 5 opcode $ arra%o##set $ codearra% $
methodindex $ strin(s8<
244260235.doc 330 od 541
+onsole.!rite3ine58<
arra%o##set A arra%o##set C si&eo#instructionanddata<
@
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@F8<
i# 5 DetT%pe>or0ethod5methodindex8AA 18
+onsole.!rite3ine5F II end o# (lobal method 90@UrUnF $ methodname8<
else
+onsole.!rite3ine5F II end o# method 90@MM91@UrUnF $ classname $ methodname8<
@

e.il
.class &&&
9
.method void x%&58
9
ret
ar(list
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 3 50x38
.maxstac 8
'3R0000M IJ 2* T JI ret

'3R0001M IJ >:00 T JI ar(list
@ II end o# method &&&MMx%&

3ets start "ith the method >ill/p+ode*rra%. 2ere "e have reduced the si&e o# the #irst arra% to a
reasonable 256 as the one b%te opcodes "ill not exceed 255. Thus the arra% /p+odes*rra% "ill
store #or us all the sin(le b%te opcodes.

Then "e have a second arra% /p+odes*rra%1 that "ill store the t"o b%te opcodes. These
un#ortunatel% have to be e%ed in manuall% and the% are 30 o# them. Thus "e "ill no" have to
search in t"o arra%s #or our opcode. This is "hat "e do in the method =ispla%0ethod'3+ode.

!e read the #irst b%te #rom the codearra% and then chec i# it is the pre#ix1 opcode. '# it is$ "e
then pic up the second or the next b%te and use this as an o##set into the /p+odes*rra%1 arra% to
(ive us the ri(ht opcode.

The e% point is that "e are readin( the second b%te and then picin( the opcode #rom the second
and not the #irst opcode arra%. !e then set the strin(s variable to the initial number o# spaces as
"ell as the initial parts o# the 'l instruction "hich is the '3R and the line number stored in the
arra%o##set variable.

244260235.doc 331 od 541
!e stop at the or si(n as be#ore. *s "e are dealin( "ith a 2 b%te instruction$ the arra%o##set
variable is increased b% 1. '# it is a one b%te instruction$ "e do "hat "e did earlier.

Thus "hen "e call the method =ecode'3'nstrcution2$ it does not care "hether it is a one b%te or
t"o b%te instruction set. The strin(s variable has a extra space #or a one b%te instruction set.

>inall% "e "ill list out all the 'n3ine)one operand t%pes or those that tae up no parameters. !e
are decodin( instructions dependin( upon the t%pes o# parameters the% tae. The% are 146
instructions that tae no operand. These are nop $ brea $ ldar(.0 $ ldar(.1 $ ldar(.2 $ ldar(.3 $
ldloc.0 $ ldloc.1 $ ldloc.2 $ ldloc.3 $ stloc.0 $ stloc.1 $ stloc.2 $ stloc.3 $ ldnull $ ldc.i4.m1 $ ldc.i4.0 $
ldc.i4.1 $ ldc.i4.2 $ ldc.i4.3 $ ldc.i4.4 $ ldc.i4.5 $ ldc.i4.6 $ ldc.i4.7 $ ldc.i4.8 $ dup $ pop $ ret $
ldind.i1 $ ldind.u1 $ ldind.i2 $ ldind.u2 $ ldind.i4 $ ldind.u4 $ ldind.i8 $ ldind.i $ ldind.r4 $ ldind.r8 $
ldind.re# $ stind.re# $ stind.i1 $ stind.i2 $ stind.i4 $ stind.i8 $ stind.r4 $ stind.r8 $ add $ sub $ mul $ div $
div.un $ rem $ rem.un $ and $ or $ xor $ shl $ shr $ shr.un $ ne( $ not $ conv.i1 $ conv.i2 $ conv.i4 $
conv.i8 $ conv.r4 $ conv.r8 $ conv.u4 $ conv.u8 $ conv.r.un $ thro" $ conv.ov#.i1.un $ conv.ov#.i2.un $
conv.ov#.i4.un $ conv.ov#.i8.un $ conv.ov#.u1.un $ conv.ov#.u2.un $ conv.ov#.u4.un $ conv.ov#.u8.un
$ conv.ov#.i.un $ conv.ov#.u.un $ ldlen $ ldelem.i1 $ ldelem.u1 $ ldelem.i2 $ ldelem.u2 $ ldelem.i4 $
ldelem.u4 $ ldelem.i8 $ ldelem.i $ ldelem.r4 $ ldelem.r8 $ ldelem.re# $ stelem.i $ stelem.i1 $ stelem.i2
$ stelem.i4 $ stelem.i8 $ stelem.r4 $ stelem.r8 $ stelem.re# $ conv.ov#.i1 $ conv.ov#.u1 $ conv.ov#.i2 $
conv.ov#.u2 $ conv.ov#.i4 $ conv.ov#.u4 $ conv.ov#.i8 $ conv.ov#.u8 $ c#inite $ conv.u2 $ conv.u1 $
conv.i $ conv.ov#.i $ conv.ov#.u $ add.ov# $ add.ov#.un $ mul.ov# $ mul.ov#.un $ sub.ov# $ sub.ov#.un $
end#inall% $ stind.i $ conv.u $ pre#ix7 $ pre#ix6 $ pre#ix5 $ pre#ix4 $ pre#ix3 $ pre#ix2 $ pre#ix1 $
pre#ixre# $ ar(list $ ce. $ c(t $ c(t.un $ clt $ clt.un $ localloc $ end#ilter $ volatile. $ tail. $ cpbl $
initbl $ rethro" $ re#an%t%pe. This is 1ust #or completeness.

4ro(ram53.csc
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
int si&eo#instructiondata A 0<
i# 5 opcode./perandT%pe AA /perandT%pe.'nline'8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
+onsole.!rite5F90@91@92@
93@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5888<
+onsole.!rite5F JI 90@ 91@ 0x92@F$ opcode.)ame $ +reate;paces538 $ toen.To;trin(5FxF88<
si&eo#instructiondata A 5<
@
return si&eo#instructiondata<
@

e.il
.class &&&
9
.method void x%&58
244260235.doc 332 od 541
9
ldc.i4 14
ldc.i4 P4
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 10 50xa8
.maxstac 8
'3R0000M IJ 20 T 0:000000 JI ldc.i4 0xe
'3R0005M IJ 20 T >+>>>>>> JI ldc.i4 0x#######c
@ II end o# method &&&MMx%&

The /perand T%pe 'nline' re.uires a sin(le 32 bit inte(er. !e call the ldc.i4 instruction "ith a
sin(le 32 bit inte(er. This means that in the codearra%$ the instruction 0x20 "ill be #ollo"ed b% a
32 bit inte(er. Thus "e use our trust% To'nt32 method and also use the index into the codearra%
passed as a parameter codeindex plus 1.

!e have to displa% the 32 bit inte(er as a hex number but a#ter the or si(n "e also have to displa%
all the individual b%tes in hex also. Thus "e read the #our b%tes in variables b1 to b4 and displa%
them in the same order. The si&e in b%tes o# this operand t%pe is 5$ one #or the instruction b%te$
#our #or the 32 bit inte(er.

There is no special handlin( #or ne(ative numbers. *lso there is onl% one instruction ldc.i4 that
taes a 32 bit inte(er.

4ro(ram54.csc
i# 5 opcode./perandT%pe AA /perandT%pe.'nline'88
9
+onsole.!rite5strin(s8<
lon( toen A Oit+onverter.To'nt645 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
b%te b5 A codearra%6codeindexC57<
b%te b6 A codearra%6codeindexC67<
b%te b7 A codearra%6codeindexC77<
b%te b8 A codearra%6codeindexC87<
+onsole.!rite5F90@91@92@93@94@95@96@
97@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F8$b5.To;trin(5FK
2F8$b6.To;trin(5FK2F8$b7.To;trin(5FK2F8$b8.To;trin(5FK2F8 8<
+onsole.!rite5F JI 90@ 91@ 0x92@F$ opcode.)ame $ +reate;paces538 $ toen.To;trin(5FxF88<
si&eo#instructiondata A 9<
@
return si&eo#instructiondata<
@
244260235.doc 333 od 541

e.il
.class &&&
9
.method void x%&58
9
ldc.i8 14
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 9 50x98
.maxstac 8
'3R0000M IJ 21 T 0:00000000000000 JI ldc.i8 0xe
@ II end o# method &&&MMx%&

!e no" add one more i# statement to handle a 64 bit inte(er and this operand t%pe is 'n3ine'8.
Nnlie the earlier pro(ram "e have a 64 bit inte(er and not a 32 but inte(er #ollo"in( the ldc.i8
instruction.

Thus "e use the To'nt64 method to read the inte(er and also use 8 b%te variables to read and
displa% the 64 bit inte(er. The si&e o# this instruction is obviousl% 8. *lso there is onl% one
instruction ldc.i8 that taes this operand t%pe.

4ro(ram55.csc
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nline'8
9
+onsole.!rite5strin(s8<
int toen A codearra%6codeindexC17<
+onsole.!rite5F90@F$toen.To;trin(5FK2F88<
+onsole.!rite5+reate;paces51488<
i# 5 toen HA 1288
toen A toen P 256<
i# 5 opcode.)ame AA Funali(ned.F 8
+onsole.!rite5F JI 90@ 91@F$ opcode.)ame $ toen.To;trin(588<
else
+onsole.!rite5F JI 90@ 91@F$ opcode.)ame $ toen.To;trin(588<
si&eo#instructiondata A 2<
@

e.il
.class &&&
9
.method void x%&58
9
ldc.i4.s 12
ldc.i4.s 127
244260235.doc 334 od 541
ldc.i4.s 128
ldc.i4.s 129
ldc.i4.s 130
unali(ned. 14
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 13 50xd8
.maxstac 8
'3R0000M IJ 1> T 0+ JI ldc.i4.s 12
'3R0002M IJ 1> T 7> JI ldc.i4.s 127
'3R0004M IJ 1> T 80 JI ldc.i4.s P128
'3R0006M IJ 1> T 81 JI ldc.i4.s P127
'3R0008M IJ 1> T 82 JI ldc.i4.s P126
'3R000aM IJ >:12 T 0: JI unali(ned. 14
@ II end o# method &&&MMx%&

The next t%pe is the ;hort'nline' that taes a 8 bit inte(er and not a 16 bit one as the
documentation su((ests. Thus "e read a sin(le b%te o## the codearra% arra% and displa% it as a hex
b%te a#ter the or si(n. !e then "rite out 14 spaces #or paddin( and then chec "hether "e have a
plus or a minus number.

*n%thin( over 128 is a ne(ative number. Thus 128 (ets displa%ed as [128$ 129 is one less [127
and so on. Thus i# variable toen is lar(er than 128$ "e subtract 256 #rom it to (ive the number
"ith a ne(ative si(n. There are onl% t"o possible instructions #or this t%pe$ ldc.i4.s and unali(ned.
.

!e have to "rit them out separatel% as the% are o# di##erent len(ths and "e need to ali(n then
toen variable displa%ed at the end. This is displa%ed in decimal and not hex.

4ro(ram56.csc
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineOrTar(et8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 18<
strin( returnstrin( A FF<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
+onsole.!rite5F90@91@92@93@F $
b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces598 C FJI F8<
toen A toen C codeindex C 5<
int len A opcode.)ame.3en(th<
returnstrin( A opcode.)ame C F F C +reate;paces59 P len8 C F '3RF C toen.To;trin(5Fx4F8<
244260235.doc 335 od 541
+onsole.!rite5returnstrin(8<
i# 5 E 5codearra%.3en(th AA codeindex C 5 88
+onsole.!rite3ine58<
si&eo#instructiondata A 5<
@

.class &&&
9
.method void x%&58
9
br 1
ret
br 1234567
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 11 50xb8
.maxstac 8
'3R0000M IJ 38 T 01000000 JI br '3R0006

'3R0005M IJ 2* T JI ret

'3R0006M IJ 38 T 87=61200 JI br '3R12d692
@ II end o# method &&&MMx%&

There are 14 instructions that tae a operand t%pe o# 'nlineOrTar(et. These are br $br#alse$brtrue
$be. $b(e $ b(t $ ble $ blt $ bne.un $ b(e.un $ b(t.un $ ble.un $ blt.un and leave. This instruction t%pe
also taes a 32 bit si(ned number a#ter it that "e read into the variable toen.

*s al"a%s "e also need to displa% the individual b%tes o# the 32 bit si(ned inte(er. !e "rite out
the b%tes$ and the closin( comment "ith spaces. This /perand t%pe is actuall% a 1ump instruction.
The 32 inte(er stands #or a instruction that "e "ant to trans#er control to.

Thus "hen "e "rite br 1$ "e "ould lie to 1ump 1 #rom "here "e are. !e are at '3R0000 and
this br instruction "ill tae 5 b%tes #rom '3R0000 to '3R0004. Thus had "e "rote br 0$ "e "ould
"ant to 1ump to the instruction b%te 'lR0005 and br 1 "ould taes us to the b%te code at '3R0006.

Thus "e need to #ind out the '3R that "e need to 1ump to and this "e do b% addin( the codeindex
or "here "e are to the toen variable toen and then "e also add 5 as this is the amount o# b%tes
this instruction t%pe taes up. This is the ne" value o# toen that "e displa% alon( "ith the '3R.

!e also need to "rite out the name o# the opcode and then put a certain number o# spaces "hich
is 9 minus the len(th o# the name o# the opcode. '# this operand t%pe is the last instruction it must
be not preceded "ith a ne" line or else it must be.

'# "e "rite a ne(ative number$ "e (et nonsensical ans"ers.
244260235.doc 336 od 541

e.il
.class &&&
9
.method void x%&58
9
br '3R0007
nop
'3R0007M nop
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 7 50x78
.maxstac 8
'3R0000M IJ 38 T 01000000 JI br '3R0006

'3R0005M IJ 00 T JI nop
'3R0006M IJ 00 T JI nop
@ II end o# method &&&MMx%&

'# "e "rite a actual label a#ter the br instruction$ then '3R0007 must be a actual label in the
method. * label is an% "ord that ends in a colon and il ilasm removes all labels #rom our code and
puts a o##set into the codearra% #or the br instruction instead o# our label. !e have to re"rite our
entire code "ith the labels put in #resh and hence in the output "e have '3R0006 as the label
instead o# "hat "e "rote out '3R0007.

4ro(ram57.csc
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nlineOrTar(et8
9
+onsole.!rite5strin(s8<
int toen A codearra%6codeindex C 17<
strin( returnstrin( A FF<
+onsole.!rite5F90@F $ toen.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5158 C FJI F8<
i# 5 toen HA 1288
9
toen A 0x## P toen <
toen A codeindex C 1 P toen<
@
else
toen A toen C codeindex C 2<
int len A opcode.)ame.3en(th<
returnstrin( A opcode.)ame C F F C +reate;paces59 P len8 C F '3RF C toen.To;trin(5Fx4F8<
+onsole.!rite5returnstrin(8<
i# 5 E 5codearra%.3en(th AA codeindex C 2 88
+onsole.!rite3ine58<
244260235.doc 337 od 541
si&eo#instructiondata A 2<
@

e.il
.class &&&
9
.method void x%&58
9
nop
nop
br.s 2
br.s P3
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 6 50x68
.maxstac 8
'3R0000M IJ 00 T JI nop
'3R0001M IJ 00 T JI nop
'3R0002M IJ 2O T 02 JI br.s '3R0006

'3R0004M IJ 2O T >= JI br.s '3R0003
@ II end o# method &&&MMx%&

The operand t%pe ;hort'nlineOrTar(et is similar to the one above and the onl% chan(e is that "e
read a b%te o# the codearra% and not a int32. *lso "e chec #or the toen to be (reater than 128
lie earlier and subtract the 0x## #rom it.

Then "e subtract toen #rom "here "e are codeindex and then add 1. '# it is a positive o##set lie
it should be "e add both codeindex and toen lie be#ore and then add 2 as this is si&e o# this
instruction t%pe. *ll else remains the same and "e set si&eo#instructiondata to 2.

There are 14 instructions that all end in s #or this /perand T%pe. This is the same number as the
earlier t%pe. These are br.s $ br#alse.s $ brtrue.s $ be..s $ b(e.s $ b(t.s $ ble.s $ blt.s $ bne.un.s $
b(e.un.s $ b(t.un.s $ ble.un.s $ blt.un.s and leave.s

4ro(ram58.csc
i# 5 opcode./perandT%pe AA /perandT%pe.'nline;"itch8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
244260235.doc 338 od 541
+onsole.!rite5F90@91@92@93@F $
b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces59 88<
+onsole.!rite5FJI s"itch 5 F8<
i# 5 toen AA 08
+onsole.!rite5F8F8<
else
#or 5 int ii A 1 < ii BA toen < iiCC8
9
+onsole.!rite5FUrUnF C +reate;paces5spaces#orrestC2 C spaces#ornested88<
+onsole.!rite5+reate;paces510 8 C FIJ T F8<
int index A Oit+onverter.To'nt325 codearra% $ codeindex C 1 C iiJ48<
b1 A codearra%6codeindexC1 C iiJ47<
b2 A codearra%6codeindexC2 C iiJ47<
b3 A codearra%6codeindexC3 C iiJ47<
b4 A codearra%6codeindexC4 C iiJ47<
+onsole.!rite5F90@91@92@93@F $
b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
int tot A codeindexCindexC1 C toenJ4 C 4<
+onsole.!rite5+reate;paces598 C FJIF C +reate;paces5138 C F'3R90@F $ tot.To;trin(5Fx4F88<
i# 5 ii EA toen8
+onsole.!rite5F$F8<
else
+onsole.!rite5F8F8<
@
si&eo#instructiondata A 5 C toenJ4<
@

e.il
.class &&&
9
.method void x%&58
9
s"itch 5 2 $ 3$ 48
s"itch 5 8
s"itch 5 2$ P28
ret
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 36 50x248
.maxstac 8
'3R0000M IJ 45 T 03000000 JI s"itch 5
IJ T 02000000 JI '3R0013$
IJ T 03000000 JI '3R0014$
IJ T 04000000 JI '3R00158
244260235.doc 339 od 541
'3R0011M IJ 45 T 00000000 JI s"itch 5 8
'3R0016M IJ 45 T 02000000 JI s"itch 5
IJ T 02000000 JI '3R0025$
IJ T >:>>>>>> JI '3R00218
'3R0023M IJ 2* T JI ret
@ II end o# method &&&MMx%&

The s"itch instruction is the onl% one in the #amil% o# /perand T%pe 'nline;"itch. *s it is little
complex lets #irst loo at both the il #ile and the output. The s"itch is nothin( but a series o# 1ump
statements or labels and thus implements a 1ump table. !e have speci#ied three 1umps 2$ 3 and 4.

These 1umps are o##sets a#ter the end o# the s"itch statement. *n empt% s"itch statement taes up
5 b%tes$ the #irst #or the instruction itsel#$ the remainin( #our #or ho" man% 32 bit inte(ers "e
have or ho"man% entries in the 1ump table.

*s "e have 3$ the total si&e o# the s"itch statement is 17 b%tes and thus the next valid instruction
is at o##set 17 or 11 hex. Thus the o##sets 2$ 3 and 4 and #rom this number 0x11 and thus "e see
0x13$ 0x14 and 0x15 in the 1ump table. The last s"itch starts at 0x16 or 22 decimal.

*s it has t"o entries in the 1ump table$ its si&e is 5 C 8$ 13 and thus the ret statement is at decimal
35 or 0x23. The o##sets 2 and [2 are #rom 0x23 and thus "e (et 0x25 or 0x21. 3ets us see ho" "e
implement this in code. !e #irst read into toen the number o# entries in our 1ump table.

!e also read the individual b%tes that "e displa%. Then "e "rite out 9 spaces and the "ords
s"itch "ith a open bracet. '# toen is 0$ then "e have a empt% s"itch and "e close the bracet
immediatel%. '# "e have a non &ero value$ "e no" that "e have so man% 32 bit numbers
#ollo"in( and hence "e use a #or loop to displa% all the entire 1ump table usin( ii as the loop
variable.

!e #irst "rite out the initial spaces on a ne" line as each 1ump table starts on a ne" line. !e read
the o##set o# each 1ump table as in int as "ell as individual b%tes. !e #irst displa% the individual
b%tes and then calculate the next label o##set a#ter the s"itch instruction.

!e do this b% addin( the constant 5 #or the empt% s"itch and then the codeindex that tells us
"here "e are and then the toen itsel# stored in the variable index. !e also multipl% the toen
variable b% 4 as it tells us ho" man% toens or 1ump table entries "e have. :ach 1ump table entr%
has a si&e o# 4 b%tes.

!e "rite out this label and then either put a comma i# it is not the last 1ump table entr% or i# it is
the last a close bracet. !e #inall% set the si&e o# the si&eo#instructiondata variable to 5 plus the
si&e o# the toens.

4ro(ram59.csc
i# 5 opcode./perandT%pe AA /perandT%pe.'nline-ar8
9
+onsole.!rite5strin(s8<
ushort toen A 5ushort8Oit+onverter.To'nt165codearra% $ codeindex C 18<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
+onsole.!rite5F90@91@F $ b1.To;trin(5FK2F8$b2.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5138 C FJI 90@F $ opcode.)ame8<
244260235.doc 340 od 541
int len A opcode.)ame.3en(th<
i# 5opcode.)ame AA Fldar(F TT opcode.)ame AA Fldar(aF TT opcode.)ame AA Fstar(F8
9
strin( methodattribute#la(s A Det0ethod*ttribute 50ethod;truct6methodindex7.#la(s $
methodindex8<
strin( sname A FF<
i# 5 toen H methodde#paramcount 6methodindex7 GG methodattribute#la(s.'ndex/#5FstaticF8 EA
P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen H methodde#paramcount6methodindex7C1 GG
methodattribute#la(s.'ndex/#5FinstanceF8 EA P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen AA 0 GG methodattribute#la(s.'ndex/#5FinstanceF8 EA P1 8
sname A F0F<
else
9
i# 5 methodattribute#la(s.'ndex/#5FstaticF8 EA P18
toenCC<
sname A Det4aram)ame>or0ethod 5 methodindex $ 0 $ toen8<
@
+onsole.!rite5F90@91@F $ +reate;paces511 P len8 $ sname8<
@
else
+onsole.!rite5F90@-R91@F $ +reate;paces511 P len8 $ toen8<
si&eo#instructiondata A 3<
@

e.il
.class &&&
9
.method void x%&5int32 i $ int32 1 $ int32 8
9
ldar( 0
ldar( 1
ldar( 2
ldar( 3
ldar( 4
ldar( 5
@
.method static void p.r5int32 i $ int32 1 $ int32 8
9
ldar( 0
ldar( 1
ldar( 2
ldar( 3
ldar( 4
ldar( 5
@
.method void x%&15int32 i $ int32 1 $ int32 8
244260235.doc 341 od 541
9
ldloc 0
ldloc 1
ldloc 2
ldloc 3
ldloc 4
ldloc 5
@
.method static void p.r15int32 i $ int32 1 $ int32 8
9
ldloc 0
ldloc 1
ldloc 2
ldloc 3
ldloc 4
ldloc 5
@
@

.class &&&
9
.method void x%&5int32 i $ int32 1 $ int32 8
9
ldar( 0
ldar( 1
ldar( 2
ldar( 3
ldar( 4
@
.method static void p.r5int32 i $ int32 1 $ int32 8
9
ldar( 0
ldar( 1
ldar( 2
ldar( 3
ldar( 4
@
.method void x%&15int32 i $ int32 1 $ int32 8
9
ldloc 0
ldloc 1
ldloc 2
ldloc 3
ldloc 4
@
.method static void p.r15int32 i $ int32 1 $ int32 8
9
ldloc 0
ldloc 1
ldloc 2
ldloc 3
244260235.doc 342 od 541
ldloc 4
@
@

.method IJ06000001JI privatescope instance void
x%&Z4;T060000015int32 i$
int32 1$
int32 8 cil mana(ed
II ;'DM 20 03 01 08 08 08
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 24 50x188
.maxstac 8
'3R0000M IJ >:09 T 0000 JI ldar( 0
'3R0004M IJ >:09 T 0100 JI ldar( i
'3R0008M IJ >:09 T 0200 JI ldar( 1
'3R000cM IJ >:09 T 0300 JI ldar(
'3R0010M IJ >:09 T 0400 JI ldar( *R4
'3R0014M IJ >:09 T 0500 JI ldar( 5 II :,,/,M invalid ar( index 5HA48
@ II end o# method &&&MMx%&

.method IJ06000002JI privatescope static
void p.rZ4;T060000025int32 i$
int32 1$
int32 8 cil mana(ed
II ;'DM 00 03 01 08 08 08
9
II 0ethod be(ins at ,-* 0x2069
II +ode si&e 24 50x188
.maxstac 8
'3R0000M IJ >:09 T 0000 JI ldar( i
'3R0004M IJ >:09 T 0100 JI ldar( 1
'3R0008M IJ >:09 T 0200 JI ldar(
'3R000cM IJ >:09 T 0300 JI ldar( *R3
'3R0010M IJ >:09 T 0400 JI ldar( 4 II :,,/,M invalid ar( index 5HA48
'3R0014M IJ >:09 T 0500 JI ldar( 5 II :,,/,M invalid ar( index 5HA48
@ II end o# method &&&MMp.r

.method IJ06000003JI privatescope instance void
x%&1Z4;T060000035int32 i$
int32 1$
int32 8 cil mana(ed
II ;'DM 20 03 01 08 08 08
9
II 0ethod be(ins at ,-* 0x2082
II +ode si&e 24 50x188
.maxstac 8
'3R0000M IJ >:0+ T 0000 JI ldloc -R0
'3R0004M IJ >:0+ T 0100 JI ldloc -R1
'3R0008M IJ >:0+ T 0200 JI ldloc -R2
'3R000cM IJ >:0+ T 0300 JI ldloc -R3
244260235.doc 343 od 541
'3R0010M IJ >:0+ T 0400 JI ldloc -R4
'3R0014M IJ >:0+ T 0500 JI ldloc -R5
@ II end o# method &&&MMx%&1

.method IJ06000004JI privatescope static
void p.r1Z4;T060000045int32 i$
int32 1$
int32 8 cil mana(ed
II ;'DM 00 03 01 08 08 08
9
II 0ethod be(ins at ,-* 0x209b
II +ode si&e 24 50x188
.maxstac 8
'3R0000M IJ >:0+ T 0000 JI ldloc -R0
'3R0004M IJ >:0+ T 0100 JI ldloc -R1
'3R0008M IJ >:0+ T 0200 JI ldloc -R2
'3R000cM IJ >:0+ T 0300 JI ldloc -R3
'3R0010M IJ >:0+ T 0400 JI ldloc -R4
'3R0014M IJ >:0+ T 0500 JI ldloc -R5
@ II end o# method &&&MMp.r1

'n this pro(ram "e "or "ith the /perand t%pe 'nline-ar that has onl% six instructions. These are
ldar($ ldar(a$ star($ ldloc$ ldloca and
;tloc. Oe#ore "e loo at code lets us understand the ldar( instruction. * + pro(rammer deals
extensivel% "ith a area o# memor% that is used to store parameters and local variables called the
stac.

* +S or -O pro(rammer does not bother about the stac at all. Out #or an '3 pro(rammer the
stac is the most important part o# their pro(rammin( li#e. Thus "e need a instruction that "ill
tae the value o# a parameter passed to our method and place it on the stac. Thus i# "e loo at
method x%&$ it has three parameters i$ 1 $ .

't also has a hidden parameter called this as it is a instance method. !e start "ith the parameter 0
passed and irrespective o# the number o# parameters passed$ this sho"s up as a &ero in the output.
The is because the ildasm "riter pre#erred the &ero to the "ords this.

The next three ldar( instructions have a 1$2 and 3 and these sho" up as '$ 1 and $ the three
parameters. Thus the parameters #rom our point o# vie" are numbered #rom 1 on"ards. )ormall%
"e "ill not place a parameter that does not exist on the stac and thus "e "ill never have a
number a#ter ldar( lar(er than the param count.

'# "e do lie in the second last case$ there is no error but the name o# the parameter becomes *R4.
The problem is that i# "e have a value o# 5$ i.e. t"o more$ "e (et an error statin( that the number
o# parameters is more than "hat is allo"ed.

The tric in our code is (iven a number a#ter the ldar( instruction$ ho" do "e convert it into a
parameter name. Out be#ore that lets move on to the second #unction x%& $ similar to the #irst but
bein( static in t%pe and not instance. 0ost rules no" chan(e.

* static method has no this parameter passed and hence the count o# parameters is #rom &ero
on"ards. This is "h% "e #irst see '$ 1$ and then as "e cross the last parameter "e (et no error
244260235.doc 344 od 541
but *R3. The minute "e cross t"o more$ "e (et an error instead. Thus a mistae o# 1 is pardoned
but not o# t"o or more.

'# "e (et an error "e are also told about the number o# parameters plus 1 that the method taes.
The% are t"o more instructions in this #amil% called ldar(a and star(. There is another set o#
instructions ldloc$ ldloca and stloc that deal "ith local variables and the stac.

The ld loads a value on the stac and the st ones do the reverse$ set the value o# the entit% #rom
"hat is available o## the stac. These are ver% simple$ )o error checs$ no bother about static or
not$ simple add -R and the toen number$ the count starts #rom &ero.

*s al"a%s "e "rite out the strin(s variable and then pic up the unsi(ned short or b%tes a#ter this
operand t%pe. The reason "e sa% unsi(ned is because "e have a short that is allo"ed onl%
positive numbers and not ne(ative. * positive or ne(ative number is onl% ho" "e interpret the
si(n bit.

!e then "rite out the individual bits and then #ind out the len(th o# the instruction name. The
rules #or the instruction that deal "ith parameters is di##erent #rom those #or local variables and
the i# statement taes care o# that. *s explained be#ore "e need to #ind out "hether the method
"as static or instance and thus "e a(ain use the method Det0ethod*ttribute.

The #irst thin( "e do is chec "hether the toen is be%ond the count o# parameters stored in the
methodde#paramcount arra%. >or instance variables it must be one more than static variables and
"e store the error messa(e in the variable sname.

Then "e add one more chec on "hether "e have a toen o# &ero and the method bein( instance
"e do not displa% the this but a 0. >inall% "e call our trust% Det4aram)ame>or0ethod method
that taes the toen or param number and #i(ures out the name. The second parameter to this
#unction is unused.

'# the method is static "e increase the toen b% 1 as the toen count here is 0 but in our method
Det4aram)ame>or0ethod the se.uence number is al"a%s one #or static or instance members.
!e #inall% "rite out the sname variable and in the else handle the local variables. The si&e o# this
instruction is 3 b%tes.


4ro(ram60.csc
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nline-ar8
9
+onsole.!rite5strin(s8<
int toen A codearra%6codeindexC17<
+onsole.!rite5F90@F $ toen.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5158 C FJI 90@F $ opcode.)ame8<
int len A opcode.)ame.3en(th<
i# 5opcode.)ame AA Fldar(.sF TT opcode.)ame AA Fldar(a.sF TT opcode.)ame AA Fstar(.sF8
9
strin( methodattribute#la(s A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $
methodindex8<
strin( sname A FF<
i# 5 toen H methodde#paramcount6methodindex7 GG methodattribute#la(s.'ndex/#5FstaticF8 EA
P18
244260235.doc 345 od 541
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen H methodde#paramcount6methodindex7C1 GG
methodattribute#la(s.'ndex/#5FinstanceF8 EA P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen AA 0 GG methodattribute#la(s.'ndex/#5FinstanceF8 EA P1 8
sname A F0F<
else
9
i# 5 methodattribute#la(s.'ndex/#5FstaticF8 EA P18
toenCC<
sname A Det4aram)ame>or0ethod5 methodindex $ 0 $ toen8<
@
+onsole.!rite5F90@91@F $ +reate;paces511 P len8 $ sname8<
@
else
+onsole.!rite5F90@-R91@F $ +reate;paces511 P len8 $ toen8<
si&eo#instructiondata A 2<
@

This pro(ram deals "ith the ;hort'nline-ar t%pe that is similar to the 'nline-ar. The onl%
di##erence is that the six instructions have a .s #ollo"in( them and the toen is on b%te and not
t"o. The code has been simpl% cut$ copied and pasted. !e could have mer(ed the t"o into one
but chose not to do so. The si&e o# these instructions is 2 b%tes and not three.

4ro(ram61.csc
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineT%pe 8
9
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
int seriouserror<
=ecodeToen'3 5toen $ opcode $ methodindex $ strin(s $ out seriouserror8<
int table A 5int85toen G 0x##0000008<
table A table HH 24<
toen A toen G 0x00######<
i# 5 table AA 0x0a8
9
bool b A 2as+ustom*ttribute 5F0ember,e#F $ toen 8<
i# 5 b8
9
+onsole.!rite3ine58<
=ispla%+ustom*ttribute5F0ember,e#F $ toen$ 2 C spaces#orrest C spaces#ornested8<
@
@
i# 5seriouserror AA 18
si&eo#instructiondata A codearra%.3en(th C 1<
else
si&eo#instructiondata A 5<
@
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
244260235.doc 346 od 541
9
seriouserror A 0<
int table A 5int85toen G 0x##0000008<
table A table HH 24<
toen A toen G 0x00######<
+onsole.!rite5strin(s8<
i# 5table AA 0x018
9
strin( returnstrin( A F5018F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pere#names 6toen7<
+onsole.!rite5returnstrin(8<
@
@

e.il

.assembl% extern vi1a%
9
@
.module extern vi1a%1
.class &&&
9
.method void abc58
9
ne"arr 6vi1a%7aa.bbIcc
ne"arr 6vi1a%7aa.bb
ne"arr %%%
ne"arr 6.module vi1a%17cc.dd
@
@
.class public %%%
9
@

.method IJ06000001JI privatescope instance void
abcZ4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 20 50x148
.maxstac 8
'3R0000M IJ 8= T 5018000003 JI ne"arr 6vi1a%IJ 23000001 JI7aa.bbIJ 01000002 JIIccIJ
01000003 JI
'3R0005M IJ 8= T 5018000002 JI ne"arr 6vi1a%IJ 23000001 JI7aa.bbIJ 01000002 JI
'3R000aM IJ 8= T 5018000004 JI ne"arr %%%IJ 01000004 JI
'3R000#M IJ 8= T 5018000005 JI ne"arr 6.module vi1a%1IJ 1*000001 JI7cc.ddIJ
01000005 JI
@ II end o# method &&&MMabc

,o" S2
244260235.doc 347 od 541
,esolution;cope M *ssembl%,e#617
)ame M FbbF
)amespace M FaaF
,o" S3
,esolution;cope M T%pe,e#627
)ame M FccF
)amespace M FF
,o" S4
,esolution;cope M 0odule617
)ame M F%%%F
)amespace M FF
,o" S5
,esolution;cope M 0odule,e#617
)ame M FddF
)amespace M FccF

'n this example "e start "ith the il #ile #irst to explain a instruction ne"arr that lets us create a
arra% (iven a t%pe as a parameter. This ne"arr instruction taes a t%pe as a parameter and "e can
either speci#% a t%pe re# or a t%pe de# as a parameter.

*s "e have seen be#ore a T%pe,e# can be ver% complex and can tae up a lot o# b%tes. These
t%pes are stored in tables and thus "e come bac to the concept o# a toen. !e "ill no" "or
"ith a set o# instructions that tae a toen "hich is nothin( but the top 8 bits #or the table t%pe
and the remainin( 24 bits #or the ro" "ithin the table.

Thus in the il #ile "e speci#% a t%pe re#$ but in the exe #ile "ill (o a toen speci#%in( the table and
ro" number o# the t%pe and not the t%pe itsel#. 3ets loo at our =ecode'3'nstrcution2 method
#irst "here "e chec #or the operand t%pe to be 'nlineT%pe.

'# it is "e no" that "e have a toen or a 32 bit number #ollo"in( and there#ore "e use the
To'nt32 method to extract the toen. !e then call the =ecodeToen'3 method to displa% the
entire #or us and "e next handle a special case.

'# the toen table is 0ember,e#$ "e chec "hether "e have a +ustom *ttribute on this
0ember,e# ro" number usin( the 2as+ustom*ttribute method. '# in the a##irmative$ "e "rite
out a ne" line and displa% the +ustom*ttribute #or this 0ember,e#.

*lso the =ecodeToen'3 method taes a out parameter seriouserror that i# is set to 1 on return
means a serious error has occurred and "e set the si&eo#instructiondata not to 5$ the len(th o# the
instruction but be%ond the last b%te as need to abort disPassemblin( this method.

)ormall% the assembler should catch these errors but "e "ill sho" %ou later ho" %ou can
"ill#ull% place b%tes that (enerate these errors. The 'nlineT%pe operand t%pe has the #ollo"in(
instructions in its repertoire P cpob1 $ ldob1 castclass $ isinst $ unbox $ stob1 $ box $ ne"arr $ ldelema
$ re#an%val $ mre#an% $ initob1 and si&eo#.

To understand better "e have also displa%ed the last 4 ro"s o# the t%pe table. ,o" 2 stands #or the
t%pe bb in the namespace aa comes #rom the *ssembl% ,e# ro" 1 or assembl% vi1a%. ,o" 3
stands #or a t%pe cc that depends on ro" 2 as t%pe cc is nested "ithin t%pe bb.

244260235.doc 348 od 541
,o" 4 stands #or t%pe %%% that actuall% should have been a T%pe=e# as "e are creatin( it in our
code but the ,esolution scope is 0odule ro" 1 "hich is the current module. Thus all classes
#ound in the T%pe=e# table can also be #ound in the T%pe,e# table.

>inall% ro" 5 re#ers to class dd in a module re# ro" 1 or vi1a%1. To understand better "e have also
displa%ed the last 4 ro"s o# the t%pe table. ,o" 2 stands #or the t%pe bb in the namespace aa
comes #rom the *ssembl% ,e# ro" 1 or assembl% vi1a%. ,o" 3 stands #or a t%pe cc that depends
on ro" 2 as t%pe cc is nested "ithin t%pe bb.

,o" 4 stands #or t%pe %%% that actuall% should have been a T%pe=e# as "e are creatin( it in our
code but the ,esolution scope is 0odule ro" 1 "hich is the current module. Thus all classes
#ound in the T%pe=e# table can also be #ound in the T%pe,e# table. >inall% ro" 5 re#ers to class dd
in a module re# ro" 1 or vi1a%1.

'n the method =ecodeToen all that "e do is set the variable seriouserror to0 be de#ault and then
extract the table b% andin( the #irst 24 bits b% 0 and then ri(ht shi#tin( the top 8 bits b% 24. !e
extract the ro" number b% masin( o## the hi(her or top 8 bits. !e "rite out the initial strin( and
then chec #or a T%pe,e# table code 1.

'n this i# statement "e "rite out the table code number 01 #or the T%pe,e# table in bracets
#ollo"ed b% the variable toen that contains onl% the ro" number. !e #i(ure out the len(th o# the
name o# the opcode$ put some spaces ad then call #i(ure out the t%pe name usin( the
t%pere#names arra% that contains all the T%pe,e# table names.

4ro(ram62.csc
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
9
seriouserror A 0<
int table A 5int85toen G 0x##0000008<
table A table HH 24<
toen A toen G 0x00######<
+onsole.!rite5strin(s8<
i# 5 table AA 0x028
9
strin( returnstrin( A F5028F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame<
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pede#names6toen7<
+onsole.!rite5returnstrin(8<
@
@

e.il
.class &&&
9
.method void abc58
9
ne"arr &&&
@
@

244260235.doc 349 od 541
.method IJ06000001JI privatescope instance void
abcZ4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 5 50x58
.maxstac 8
'3R0000M IJ 8= T 5028000002 JI ne"arr &&&IJ 02000002 JI
@ II end o# method &&&MMabc

,o" S1
)ame M FB0oduleHF
,o" S2
)ame M F&&&F

The next example is easier as "e use the same ne"arr instruction and pass it a T%pe=e# ob1ect
and not a T%pe,e# ob1ect. These instructions need a t%pe and "e can either pass it a T%pe,e# or a
T%pe=e# ob1ect. '# "e speci#% a class &&&$ then the toen is 02 and the table number 000002 as "e
have sho" above.

'n our =ecodeToen'3 "e simpl% add a i# statement that checs #or the table number to be 2 and
then prints the T%pe name #orm the t%pede#names arra% and not the t%pere#names arra%.

4ro(ram63.csc
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineT%pe TT opcode./perandT%pe AA
/perandT%pe.'nline0ethod 8
9
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
int seriouserror<
@
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
9
i# 5table AA 0x068 II0ethod
9
strin( returnstrin( A F5068F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame<
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C =ecode0ember=e#Toen 5toen8<
+onsole.!rite5returnstrin(8<
@
@
public strin( =ecode0ember=e#Toen 5int toen8
9
strin( returnstrin( A FF<
i# 5 toen HA 0ethod;truct.3en(th8
return returnstrin(<
strin( name A )ame,eserved5Det;trin(50ethod;truct6toen7.name88<
strin( methodattributes A Det0ethod*ttribute50ethod;truct6toen7.#la(s $ toen 8<
244260235.doc 350 od 541
i# 5 methodattributes.'ndex/#5Fprivatescope F8 EA P18
name A name C FZ4;T06F C toen.To;trin(5FK6F8<
int t%peindex A DetT%pe>or0ethod5toen8<
returnstrin( A methodde#t%pearra% 6toen7 C methodde#returnarra% 6toen7 C t%pede#names
6t%peindex7 <
returnstrin( A returnstrin( C FMMF C name C F5F <
int len A returnstrin(.3en(th C 53 C spaces#orrest C spaces#ornested<
strin( s#inal A methodde#paramarra%1 6toen7<
returnstrin( A returnstrin( C 4aram/n0ultiple3ines5s#inal $ len 8 C F8F<
returnstrin( A returnstrin( C F F C FIJ 06F C toen.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
@

e.il
.class &&&
9
.method void abc58
9
call instance void &&&MM.ctor5int32 $ int328
call instance void &&&MMp.r5int328
@
.method public instance void .ctor5int32 $ int32 8
9
@
.method public instance void p.r5int32 8
9
@
@

.method IJ06000001JI privatescope instance void
abcZ4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 10 50xa8
.maxstac 8
'3R0000M IJ 28 T 5068000002 JI call instance void &&&IJ 02000002 JIMM.ctor5int32$
int328 IJ 06000002 JI
'3R0005M IJ 28 T 5068000003 JI call instance void &&&IJ 02000002 JIMMp.r5int328 IJ
06000003 JI
@ II end o# method &&&MMabc
.method IJ06000002JI public specialname rtspecialname
instance void .ctor5int32 *R0$
int32 *R18 cil mana(ed
II ;'DM 20 02 01 08 08
9
II 0ethod be(ins at ,-* 0x205b
II +ode si&e 0 50x08
@ II end o# method &&&MM.ctor
.method IJ06000003JI public instance void
244260235.doc 351 od 541
p.r5int32 *R08 cil mana(ed
II ;'DM 20 01 01 08
9
II 0ethod be(ins at ,-* 0x205c
II +ode si&e 0 50x08
@ II end o# method &&&MMp.r

'n this example "e deal "ith the method table. !e add one more operand t%pe 'nline0ethod to
the i# statement #or the =ecode'3'nstrcution2 method but call the same =ecodeToen'3 method.
2ere "e add one more i# statement #or table t%pe 6 or the method table. 'n this i# statement "e
simpl% do "hat "e mostl% did in the earlier t"o cases but also call the method
=ecode0ember=e#Toen.

The principle in the toen examples is that "e are (iven a ro" number o# a table and need to
displa% a strin( representin( that ro" entit%. '# it is a T%pe=e# then "e need to displa% the name
o# the t%pe in certain manner. 'n this speci#ic case "e need to displa% the entire method in a
certain #ormat.

!e start "ith the t%pe o# the method instance or static $ then the return t%pe$ the #ull name o# the
method and the parameters passed "ithout parameter names. This "as somethin( "e did "hen
displa%ed the method de#inition and the =ecode0ember=e#Toen method does somethin(
similar.

!e start "ith checin( that the ro" number or toen can never be lar(er than the 0ethod table
and once a(ain #i(ure out the name and attributes o# the methods. 0ost o# this code "ill sound
#amiliar. !e add the strin( 4;T06 i# the methods attribute is privatescope and then "e #ind out
the t%pe that this method belon(s to.

!e next concatenate the t%pe o# the method stored in the methodde#t%pearra% arra% usin( the ro"
number variable toen as the index$ then the return value stored in the methodde#returnarra% and
#inall% the t%pe that this method called comes #rom stored in the t%pede#names arra%.

This is "h% "e need the t%pe the method belon(s to. !e then add t"o colons and the name and a
open bracet. >inall% "e need the parameters to this method "hich is stored in the
methodde#paramarra%1 arra% as this arra% onl% contains the t%pes o# the parameters$ not th
parameter names.

These parameters are to be placed on multiple lines and 43 is "hat "e #i(ured out "as the other
stu## that (ets displa%ed. !e end "ith the 0ethod table ro" number. !e have called the call
instruction t"ice$ once "ith a constructor and the second time method p.r de#ined in the same
t%pe. Thus callin( a method "hich is de#ined b% us in our code places a table t%pe 6 in the toen.

Ooth cases the table t%pe is 06 and "e displa% the entire method call plus parameters. The other
instructions that mae up this /perand t%pe are 1mp $ callvirt $ ne"ob1 $ ld#tn and ldvirt#tn.

4ro(ram64.csc
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineT%pe TT opcode./perandT%pe AA
/perandT%pe.'nline0ethod TT opcode./perandT%pe AA /perandT%pe.'nline;i( 8
244260235.doc 352 od 541
9
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
@
@
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
9
seriouserror A 0<
int table A 5int85toen G 0x##0000008<
table A table HH 24<
int ori(inaltoen A toen<
toen A toen G 0x00######<

i# 5 table AA 0x118 II;tand*lonesi(
9
int b1 A toen G 0x##<
int b2 A 5toen G 0x##008 HH 8<
int b3 A 5toen G 0x##00008 HH 16<
strin( returnstrin( A b1.To;trin(5FK2F8 C b2.To;trin(5FK2F8 C b3.To;trin(5FK2F8 C
table.To;trin(5FK2F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame C F F<
strin( dumm% A +reate;i(nature>or+alli 5toen8<
int len A opcode.)ame.3en(th<
i# 5 dumm% AA FerrorF8
returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8 C F JI F C
opcode.)ame C +reate;paces511Plen8 C FBunno"n toen t%pe 0xF C table.To;trin(5FK2F8CFHF <
else
returnstrin( A returnstrin( C dumm% C F IJF C ori(inaltoen.To;trin(5FK8F8 C FJIF<
+onsole.!rite5returnstrin(8<
@
@
public strin( +reate;i(nature>or+alli5int ro"8
9
int aa A P1<
int ho"man%b%tes$uncompressedb%te $ count<
i# 5 ro" HA ;tand*lone;i(;truct.3en(th8
return FerrorF<
int index A ;tand*lone;i(;truct6ro"7.index <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blobarra% A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blobarra% $ 0 $ count8<
i# 5 ro" AA aa8
9
#or 5 int i A 0 < i B count < iCC8
+onsole.!rite5F90@ F $ blobarra%6i7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
strin( t%pes A =ecode>irstO%teo#0ethod;i(nature 5 blobarra%607 $ ro"8<
index A 1<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
244260235.doc 353 od 541
count A uncompressedb%te<
index A index C ho"man%b%tes <
strin( returnstrin( At%pes<
int dumm%int1<
returnstrin( A returnstrin( C Det:lementT%pe5 index $ blobarra% $ out dumm%int1 $ 0 $ FF8<
index A index C dumm%int1<
returnstrin( A returnstrin( C F5F<
#or 5 int l A 1 < l BA count < lCC8
9
i# 5 blobarra%6index7 AA 0x41 8
9
returnstrin( A returnstrin( C F...$F<
index A index C 1<
@
strin( dumm% A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $0 $ FF8<
returnstrin( A returnstrin( C dumm% <
i# 5 l EA count 8
returnstrin( A returnstrin( C F$F<
index A index C ho"man%b%tes<
@
i# 5 index B blobarra%.3en(th GG blobarra%6index7 AA 0x418
returnstrin( A returnstrin( C F$...F <
returnstrin( A returnstrin( C F8F<
return returnstrin(<
@

e.il
.class &&&
9
.method void abc58
9
calli varar( int32 5 int64$ int8 $ ...8
@
@

.method IJ06000001JI privatescope instance void
abcZ4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 5 50x58
.maxstac 8
'3R0000M IJ 29 T 01000011 JI calli varar( int325int64$int8$...8 IJ11000001JI
@ II end o# method &&&MMabc

The next instruction belon(s to the /perand T%pe 'nline;i(. There#ore "e add one more operand
t%pe in the i# statement #or the =ecode'3'nstrcution2 and as al"a%s call the =ecodeToen'3
method "ith a table t%pe 0x11 "hich is #or the table ;tand*lone;i(. *ll si(natures are stored in
the metadata blob heap #or us.

244260235.doc 354 od 541
These si(natures are accessed b% readin( a metadata table as there is some column that contains
there o##set in the blob. There are ho"ever t"o cases "here "e "ill #ind a si(nature in the blob
and no column in an% table "ill contain an o##set to them.

:ach time "e have local variables in a method$ a ro" (ets created in the standalonesi( table. This
table has onl% one column. The second case that interests us is "hen "e have a calli instruction.
'n this case the toen (enerated "ill contain the table t%pe 0x11 and the ro" "ill contain the call
site si(nature #or a pointer to a #unction.

These pointer si(natures describe the callin( convention$ "e have used unmana(ed stdcall$ then
"e have the return t%pe and the parameters data t%pes onl% alon( on the same line.

There is no name #or the #unction call as these are pointer to #unctions and the% call into an%
method provided the above si(nature is the same as that o# the method called indirectl% throu(h
the pointer. /bviousl% it is our responsibilit% to push the address o# the #unction on the stac #irst.

!e store in the =ecodeToen'3 method the ori(inal toen that contained the table name and ro"
number in a variable ori(inaltoen #irst be#ore removin( the table name #rom the toen variable.
The #ormat #or this operand t%pe is a little di##erent. !e displa% the ro" numbers as b%tes #irst
and then the table number "ithout bracets.

:arlier it "as the other "a% around. Then "e have a method +reate;i(nature>or+alli that (ives
us the pointer to method si(nature. *#ter this is displa% an error messa(e i# the above #unctions
returns an error and then standalonesi( table ro" number in comments.

3ets us no" #i(ure out ho" to (enerate the stand alone si(nature in the method
+reate;i(nature>or+alli. !e start as al"a%s b% main( sure that "e have a valid ro" number in
the standalonesi( table or else "e return an error.

!e have explained all o# this si(nature earlier and thus "ill rush thorou(h the entire explanation.
The #ield index is an o##set into the blob arra% and "e #irst #ind out the len(th o# this si(nature
stored at the start. Then "e cop% this si(nature into an arra% blobarra%.

The #irst real b%te a#ter the count is the callin( convention that "e read usin( our earlier method
=ecode>irstO%teo#0ethod;i(nature. Then "e read the count o# the number o# parameters and
use the index variable as an o##set into the si(nature.

!e use the Det:lementT%pe to (et at the return value and then in a loop (et each o# the
parameters "ithout the names o# the parameters that are not stored an%"here and all these
parameters are on the same line. !e also have to add the sentinel b%te as sho"n in the il #ile.

4ro(ram65.csc
e.il
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
9
seriouserror A 0<
i# 5 table AA 0x1b8 II T%pespec
9
strin( returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame <
244260235.doc 355 od 541
int len A opcode.)ame.3en(th<
strin( t%pes A +reate;i(nature>orT%pe;pec 5toen8<
t%pes A t%pes.,eplace5F`F$F$F8<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pes <
+onsole.!rite5returnstrin(8<
@
@
public strin( +reate;i(nature>orT%pe;pec5int ro"8
9
strin( returnstrin( A FF<
int ho"man%b%tes$uncompressedb%te $ count<
int index A T%pe;pec;truct6ro"7.si(nature <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blobarra% A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blobarra% $ 0 $ count8<
returnstrin( A Det:lementT%pe5 0 $ blobarra% $ out ho"man%b%tes $0 $ FF8<
return returnstrin(<
@

.class &&&
9
.method void abc58
9
castclass valuet%pe %%%
@
@
.class %%%
9
@

.method IJ06000001JI privatescope instance void
abcZ4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 5 50x58
.maxstac 8
'3R0000M IJ 74 T 51O8000001 JI castclass valuet%pe %%%IJ 01000002 JI
@ II end o# method &&&MMabc

!e simpl% add one more table t%pe 0x1b or the T%pespec table to the =ecodeToen'3 method.
!e displa% the table name in bracets and #ollo" this "ith the ro" number b%tes and call a
method +reate;i(nature>orT%pe;pec that reads the si(nature #rom the T%pe;pec table.

This method is ver% simple as all that it does is cop% the b%tes as be#ore into the blobarra% arra%
and then read the sin(le t%pe stored in the si(nature. The point a(ain is that there is onl% a sin(le
t%pe stored and not a si(nature.

244260235.doc 356 od 541
'# "e loo at the t"o b%tes "e #ind 0x11 the element t%pe #or a value t%pe #ollo"ed b% 9 the
toen. 3ie the standalonesi( table the t%pespec also has onl% one column. )ormall% arra%
operations use the T%pe;pec but "e have used the castclass instruction that lets us cast t%pes.

The T%pe;pec toen can be used "ith an% '3 instruction that taes a T%pede# or a T%pe,e# toen
lie castclass$ cpob1$ initob1$ isinst$ ldelema$ ldob1$ mre#an%$ ne"arr$ re#an%val$ si&eo#$ stob1$ box
and unbox.

4ro(ram66.csc
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
9
seriouserror A 0<
i# 5table AA 0x0a8 II0ember,e#
9
strin( returnstrin( A F50*8F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C =ecode0ember,e#Toen5toen $
methodindex $ opcode8<
+onsole.!rite5returnstrin(8<
@
@
public strin( =ecode0ember,e#Toen 5int toen $ int methodindex $ /p+ode opcode8
9
strin( returnstrin( A FF<
i# 5 toen HA 0ember,e#;truct.3en(th 8
return F Z0,ZF C toen.To;trin(5FK2F8 C F58 IJ 0*0000F C toen.To;trin(5FK2F8 C F JIF<
int ro" A 0ember,e#;truct6toen7.clas<
strin( codedindextable A Det0ember,e#4arent+oded'ndexTable 5ro"8<
int codedindexro" A ro" HH 3<
strin( initialstrin( A FF<
i# 5 codedindextable AA F0odule,e#F8
9
initialstrin( A methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
strin( name A )ame,eserved5Det;trin(50odule,e#;truct6codedindexro"7.name88<
initialstrin( A initialstrin( C F6.module F C name C FIJ 1*F C codedindexro".To;trin(5FK6F8 C F
JI7F <
@
i# 5 codedindextable AA FT%pe;pecF8 IIarra%s.exe
9
strin( returnarra% A methodre#returnarra%6toen7<
strin( t%peplusreturn A methodre#t%pearra%6toen7 C returnarra%<
strin( t%pes A +reate;i(nature>orT%pe;pec5codedindexro"8<
t%pes A t%pes.,eplace5F`F$F$F8<
initialstrin( A t%peplusreturn C F F C t%pes <
@
else i# 5 codedindextable AA F0ethod=e#F8
9
initialstrin( A methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
int t%peindex A DetT%pe>or0ethod5codedindexro"8<
initialstrin( A initialstrin( C t%pede#names6t%peindex7<
244260235.doc 357 od 541
@
else i# 5 codedindextable AA FT%pe,e#F8
9
initialstrin( A initialstrin( C methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
initialstrin( A initialstrin( C t%pere#names6codedindexro"7<
@
strin( methodparmarra%strin( A methodre#paramarra%1 6toen7<
strin( nameplusparams A FF<
i# 5 methodparmarra%strin( EA null8
9
nameplusparams A )ame,eserved5Det;trin(50ember,e#;truct6toen7.name88 C F5F<
int len A 55 C spaces#orrestCspaces#ornested C nameplusparams.3en(th C initialstrin(.3en(th<
nameplusparams A nameplusparams C 4aram/n0ultiple3ines5methodparmarra%strin($len8<
nameplusparams A nameplusparams C F8F<
@
else
nameplusparams A )ame,eserved5Det;trin(50ember,e#;truct6toen7.name88 <
returnstrin( A initialstrin( C FMMF C nameplusparams C F IJ 0*F C toen.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
public strin( Det0ember,e#4arent+oded'ndexTable5int memberre#parentcodedindex8
9
strin( returnstrin( A FF<
memberre#parentcodedindex A memberre#parentcodedindex G 0x07<
i# 5 memberre#parentcodedindex AA 1 8
returnstrin( A FT%pe,e#F<
i# 5 memberre#parentcodedindex AA 2 8
returnstrin( A F0odule,e#F<
i# 5 memberre#parentcodedindex AA 3 8
returnstrin( A F0ethod=e#F<
i# 5 memberre#parentcodedindexAA 4 8
returnstrin( A FT%pe;pecF<
return returnstrin(<
@

e.il
.assembl% extern vi1a%
9
@
.module extern vi1a%1
.class &&&
9
.method void p.r58
9
@
.method void abc58
9
call instance void 6vi1a%7&&&MMp.r258
call instance void 6vi1a%7&&&MMp.r158
ne"ob1 instance void int3260...$0...7MM.ctor5int32$int328
call instance void 6.module vi1a%17MMp.r258
244260235.doc 358 od 541
@
@
.class public %%%
9
.method void p.r58
9
@
@

.method IJ06000002JI privatescope instance void
abcZ4;T0600000258 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2051
II +ode si&e 20 50x148
.maxstac 8
'3R0000M IJ 28 T 50*8000001 JI call instance void 6vi1a%IJ 23000001 JI7&&&IJ
01000002 JIMMp.r258 IJ 0*000001 JI
'3R0005M IJ 28 T 50*8000002 JI call instance void 6vi1a%IJ 23000001 JI7&&&IJ
01000002 JIMMp.r158 IJ 0*000002 JI
'3R000aM IJ 73 T 50*8000003 JI ne"ob1 instance void int3260...$0...7MM.ctor5int32$
int328 IJ 0*000003 JI
'3R000#M IJ 28 T 50*8000004 JI call instance void 6.module vi1a%1IJ 1*000001
JI7MMp.r258 IJ 0*000004 JI
@ II end o# method &&&MMabc

,o" S1
+lass M T%pe,e#627
)ame M Fp.r2F
,o" S2
+lass M T%pe,e#627
)ame M Fp.r1F
,o" S3
+lass M T%pe;pec617
)ame M F.ctorF
,o" S4
+lass M 0odule,e#617
)ame M Fp.r2F

'n this example "e deal "ith the table t%pe 0xa or 0ember,e#. Thus in the =ecodeToen'3 "e
add a i# statement that checs #or table t%pe 0xa and then calls a method
=ecode0ember,e#Toen to handle the member re# table.

!e start "ith checin( "hether "e have a ro" lar(er than the len(th o# the 0ember,e# table and
i# so "e return a strin( be(innin( "ith Z0,Z and the ro" number. The clas #ield o# the
0ember,e# table is a complex coded index that can tae up to #our table t%pes. These are
T%pe,e#$ 0odule,e#$ T%pe;pec and 0ethod.

The specs allo" #or a #i#th table T%pe=e# but have not (iven us its coded index value. Thus "e
use the method Det0ember,e#4arent+oded'ndexTable to (ive us one o# these #our tables as a
strin( and then ri(ht shi#t the coded index to (ive us the relevant ro" number in that table.
244260235.doc 359 od 541

>or the #irst time "e have not used a #unction to do this. The member re# table stores re#erences to
each method that "e mae that do not lie "ithin the t%pe the method that maes the member
re#erence lies in.

3ets loo at the #irst coded index table 0odule,e#. This happens "hen "e call method p.r2 in
the module vi1a%1 that is external. The output also in#orms us that ro" 4 o# the member re# table
is "hat "e have displa%ed.

!e start "ith "ritin( out the t%pe o# the method and the return value #rom the methodre# arra%s.
Then "e (et the name o# the method #rom the 0odule,e# table and the variable codedindexro"
is an o##set into this table.

!e "rite out the directive .module and then the module re# table number in comments. /nce "e
are done "ith this "e need the parameters passed to this #unction "ithout the param names and
this is stored in the methodre#paramarra%1 arra%.

!e no" need to #ind out the len(th o# spaces i# the parameters are on more than one line and this
is done b% usin( the same principles enumerated above. !e end b% "ritin( out the member re#
table ro" number. )o" lets loo at the next coded index table t%pe T%pe;pec.

This occurs "hen "e have used a '3 instruction lie ne"ob1 that creates a value t%pe #or us and
has a arra% t%pe as that t%pe. The ne"ob1 instruction in our case calls the constructor "ith t"o
ints and is o# t%pe arra% t%pe int32.

This maes the coded index as T%pe;pec and ro" 3 o# the 0ember,e# table con#irms "hat "e
are sa%in(. Then lets loo at the next coded index t%pe T%pe,e# that happens "hen "e call a
method de#ined some"here else in some other assembl%.

The method p.r1 is in assembl% vi1a% and is present in ro" 2 o# the 0ember,e# table and the clas
#ield is a T%pe,e# ro" 2. This in turn points to an assembl% re# ro" 1. The class &&& is represented
b% the second ro" o# the T%pe,e# table and the *ssembl% ,e# table ro" 1 is the assembl% vi1a%.

The code o# this i# statement is eas% as all that "e do is concatenate the t%pe$ return and the name
o# the t%pe #rom the t%pere#names arra%. The onl% problem is that "e could not simulate the last
coded index table 0ethod. Thus "e have a extra call to the method p.r2.

!e then #ound out that the #irst ro" o# the member re# table has the #ollo"in( b%tes 11 00 38 00.
This is done b% settin( the debu( variable to true. !e search #or these b%tes in the e.dll #ile and
chan(e the #irst b%te to 0x0b.

This is because the #irst 3 bits represent the coded index and a value o# 3 represents the table
0ethod=e#. )o" "e "ant ro" 1 to be method ro" "hich is method p.r. !hen "e run ildasm on
e.dll "e see the #irst method call as.

50*8000001 call instance void &&&IJ 02000002 JIMMp.r258 IJ 0*000001 JI

The member re# ro" number is 1 "hich speci#ies a coded index o# 0ethod and ro" 1 o# the
method table. The name o# the method re# is p.r2 and the 0ethod ro" 1 sa%s that the name o# the
method is p.r and its t%pe is class &&&.

244260235.doc 360 od 541
,o" 1
+lass M 0ethod617
)ame M Fp.r2F

Thus in our code "e tae the t%pe and return value #rom the member re# arra% and then calculate
the t%pe that the 0ethod #alls under. This t%pe is used #or #i(urin( out the name o# the T%pe to be
placed be#ore the method.

The onl% problem is that "hen "e do the same thin( b% ilasm$ this assembler pre#ers speci#%in( a
T%pe,e# instead o# a 0ethod to #i(ure out the class name. This T%pe,e# points to a class &&&
thou(h the module coded index ro" 1. Thus "e had to simulate it b% actuall% chan(in( the b%tes
on dis.

The point is that "e "ant to no" the class name and there are t"o "a%s o# doin( it$ one usin(
the coded index o# 0ethod and t"o b% usin( a T%pe,e# that in turn uses a re#erence to the
0odule table that can have onl% one ro" and has the class name as &&& even thou(h the same
class name is #ound in the T%pe=e# table.

Thus even thou(h "e have told %ou that the T%pe,e# table has classes the% are contained
some"here else$ classes that "e create can also be present in the T%pe,e# table. These classes
"ill have a coded index o# module and the module directive onl% (et "ritten i# it is a external
module.

4ro(ram67.csc
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineT%pe TT opcode./perandT%pe AA
/perandT%pe.'nline0ethod TT opcode./perandT%pe AA /perandT%pe.'nline;i( TT
opcode./perandT%pe AA /perandT%pe.'nline>ield 8
9
@
@

public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror8
9
seriouserror A 0<
i# 5 table AA 0x048
9
strin( returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame <
+onsole.!rite5returnstrin(8<
returnstrin( A #ieldparamarra% 6toen7<
int len A opcode.)ame.3en(th<
+onsole.!rite5+reate;paces511Plen88<
+onsole.!rite5returnstrin(8<
int t%peindex A DetT%pe>or>ield 5toen8<
strin( #inalstrin( A t%pede#names6t%peindex7<
+onsole.!rite5F 90@MMF $ #inalstrin( $ t%peindex.To;trin(5FK6F88<
strin( name A )ame,eserved5Det;trin(5>ield;truct6toen7.name88<
244260235.doc 361 od 541
i# 5#ield#la(sarra%6toen7.'ndex/#5Fprivatescope F8 EA P18
name A name C FZ4;T04F C toen.To;trin(5FK6F8<
name A name C F IJ 04F C toen.To;trin(5FK6F8 C F JIF<
+onsole.!rite5name8<
@
@
public int DetT%pe>or>ield 5int #ieldro"8
9
int ii A 0<
#or 5 ii A 1 < ii B T%pe=e#;truct.3en(th P 1 < iiCC8
9
int start A T%pe=e#;truct6ii7.#index<
int end A T%pe=e#;truct6iiC17.#index P 1<
i# 5 #ieldro" HA start GG #ieldro" BA end8
return ii<
@
return ii<
@

e.il
.class &&&
9
.#ield int32 i
.method void abc58
9
ld#ld int32 &&&MMi
@
@

.method IJ06000001JI privatescope instance void
abcZ4;T0600000158 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 5 50x58
.maxstac 8
'3R0000M IJ 7O T 5048000001 JI ld#ld int32 &&&IJ 02000002 JIMMiZ4;T04000001 IJ
04000001 JI
@ II end o# method &&&MMabc

!e no" deal "ith a #ield. !e start as al"a%s "hen "e are dealin( "ith a ne" /perand T%pe
'nline>ield b% addin( it to the i# statement to the =ecode'3'nstrcution2 method.

!e then move on to the =ecodeToen'3 method and here chec #or a table code o# 4. !e #irst
"rite out the table name in bracets and then the ro" number and the name o# the opcode. These
can be one o# six$ ld#ld $ ld#lda $ st#ld $ lds#ld $ lds#lda and sts#ld.

!e then need the data t%pe o# the #ield stored in the "ron(l% named arra% #ieldparamarra%
#ollo"ed b% some spaces. !e then need to "rite out the t%pe that this #ield belon(s to. 3ie "e
had a method DetT%pe>or0ethod "e also have a DetT%pe>or>ield method.

244260235.doc 362 od 541
The onl% di##erence is that instead o# looin( at the #ield mindex "e loo at the #ield #index.
)othin( else chan(es. !e use the t%pede#names arra% to (et at the t%pe name and then "rite out
the name o# the #ield. *s al"a%s "e loo at the privatescope attribute be#ore "e do. Thus #ields
toens are ver% simple to "or "ith unlie method toens.

4ro(ram68.csc
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
int si&eo#instructiondata A 0<
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineT%pe TT opcode./perandT%pe AA
/perandT%pe.'nline0ethod TT opcode./perandT%pe AA /perandT%pe.'nline;i( TT
opcode./perandT%pe AA /perandT%pe.'nline>ield TT opcode./perandT%pe AA
/perandT%pe.'nlineTo 8
9
@
return si&eo#instructiondata<
@
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror 8
9
seriouserror A 0<
i# 5 table AA 0x048
9
strin( returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame <
+onsole.!rite5returnstrin(8<
int t%peindex A DetT%pe>or>ield5toen8<
i# 5 opcode.)ame AA FldtoenF 8
+onsole.!rite5F #ield F8<
else
9
int len A opcode.)ame.3en(th<
+onsole.!rite5+reate;paces511Plen88<
@
+onsole.!rite5#ieldparamarra%6toen78<
strin( #inalstrin( A t%pede#names6t%peindex7<
+onsole.!rite5F 90@MMF $ #inalstrin( $ t%peindex.To;trin(5FK6F88<
strin( name A )ame,eserved5Det;trin(5>ield;truct6toen7.name88<
i# 5#ield#la(sarra%6toen7.'ndex/#5Fprivatescope F8 EA P18
name A name C FZ4;T04F C toen.To;trin(5FK6F8<
name A name C F IJ 04F C toen.To;trin(5FK6F8 C F JIF<
+onsole.!rite5name8<
@
i# 5table AA 0x068 II0ethod
9
strin( returnstrin( A F5068F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame<
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C =ecode0ember=e#Toen5toen $ opcode8<
+onsole.!rite5returnstrin(8<
@
244260235.doc 363 od 541
i# 5table AA 0x0a8 II0ember,e#
9
strin( returnstrin( A F50*8F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C =ecode0ember,e#Toen5toen $
methodindex $ opcode 8<
+onsole.!rite5returnstrin(8<
@
@
public strin( =ecode0ember=e#Toen 5int toen $ /p+ode opcode8
9
strin( returnstrin( A FF<
i# 5 toen HA 0ethod;truct.3en(th8
return returnstrin(<
strin( name A )ame,eserved5Det;trin(50ethod;truct6toen7.name88<
strin( methodattributes A Det0ethod*ttribute50ethod;truct6toen7.#la(s $ toen 8<
i# 5 methodattributes.'ndex/#5Fprivatescope F8 EA P18
name A name C FZ4;T06F C toen.To;trin(5FK6F8<
int t%peindex A DetT%pe>or0ethod5toen8<
i# 5 opcode.)ame AA FldtoenF8
returnstrin( A Fmethod F<
returnstrin( A returnstrin( C methodde#t%pearra%6toen7 C methodde#returnarra%6toen7 C
t%pede#names6t%peindex7 <
@

public strin( =ecode0ember,e#Toen 5int toen $ int methodindex $ /p+ode opcode 8
9
strin( returnstrin( A FF<
II+onsole.!rite3ine5F.......90@F $ toen.To;trin(5FKF88<
i# 5 toen HA 0ember,e#;truct.3en(th 8
return F Z0,ZF C toen.To;trin(5FK2F8 C F58 IJ 0*0000F C toen.To;trin(5FK2F8 C F JIF<
int ro" A 0ember,e#;truct6toen7.clas<
strin( codedindextable A Det0ember,e#4arent+oded'ndexTable5ro"8<
int codedindexro" A ro" HH 3<
strin( initialstrin( A FF<
else i# 5 codedindextable AA FT%pe,e#F8
9
i# 5 opcode.)ame AA FldtoenF8
9
int t%peindex1 A 0<
strin( t%pename A )ame,eserved5Det;trin(5T%pe,e#;truct6codedindexro"7.name88<
strin( t%penamespace A )ame,eserved5Det;trin(5T%pe,e#;truct6codedindexro"7.nspace88<
#or 5 int t%pecnt A 1 < t%pecnt B T%pe=e#;truct.3en(th < t%pecntCC8
9
i# 5 t%pename AA )ame,eserved5Det;trin(5T%pe=e#;truct6t%pecnt7.name88 GG t%penamespace
AA )ame,eserved5Det;trin(5T%pe=e#;truct6t%pecnt7.nspace888
9
t%peindex1 A t%pecnt<
II+onsole.!rite3ine5F...90@F $ t%pename $ 8<
brea<
@
244260235.doc 364 od 541
@
int start $ starto#next<
start A T%pe=e#;truct6t%peindex17.#index <
i# 5 t%peindex1 AA 5T%pe=e#;truct.3en(th P 18 8
starto#nextA >ield;truct.3en(th<
else
starto#next A T%pe=e#;truct6t%peindex1C17.#index <
bool #ound A #alse<
#or 5 int #ieldindex A start < #ieldindex B starto#next < #ieldindexCC8
9
strin( name A )ame,eserved5Det;trin(50ember,e#;truct6toen7.name88<
i# 5 name AA )ame,eserved5Det;trin(5>ield;truct6#ieldindex7.name888
9
#ound A true<
brea<
@
@
i# 5 #ound 8
initialstrin( A F#ield F<
else
initialstrin( A Fmethod F<
@
initialstrin( A initialstrin( C methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
initialstrin( A initialstrin( C t%pere#names6codedindexro"7<
II+onsole.!rite3ine5F......90@ 91@F $ codedindexro" $ t%pere#names6codedindexro"7 8<
@
else i# 5 codedindextable AA FT%pe=e#F8
9
i# 5 opcode.)ame AA FldtoenF8
initialstrin( A F#ield F<
initialstrin( A initialstrin( C methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
initialstrin( A initialstrin( C t%pede#names6codedindexro"7<
@
return returnstrin(<
@
public strin( Det0ember,e#4arent+oded'ndexTable5int memberre#parentcodedindex8
9
strin( returnstrin( A FF<
memberre#parentcodedindex A memberre#parentcodedindex G 0x07<
i# 5 memberre#parentcodedindex AA 0 8
returnstrin( A FT%pe=e#F<
i# 5 memberre#parentcodedindex AA 1 8
returnstrin( A FT%pe,e#F<
i# 5 memberre#parentcodedindex AA 2 8
returnstrin( A F0odule,e#F<
i# 5 memberre#parentcodedindex AA 3 8
returnstrin( A F0ethod=e#F<
i# 5 memberre#parentcodedindexAA 4 8
returnstrin( A FT%pe;pecF<
return returnstrin(<
@
244260235.doc 365 od 541

e.il
.assembl% extern vi1a%
9
@
.class &&&
9
.#ield public int32 ii
.#ield public int32 11
.method public void abc58
9
ldtoen 6vi1a%7Kml;eriali&ation2o"To.4urchase/rder
ldtoen &&&
ldtoen valuet%pe %%%IJ 01000004 JI
ldtoen method instance void &&&MMabc58
ldtoen #ield int32 ii
ldtoen #ield int32 &&&MMii
ldtoen #ield int32 %%%MM11
ldtoen method instance int32 6vi1a%7...MMhhh58
@
.method void abc158
9
call instance int32 6vi1a%7...MMhhh58
castclass valuet%pe %%%
@
@
.class public %%%
9
.#ield public int32 11
@

.method IJ06000001JI public instance void
abc58 cil mana(ed
II ;'DM 20 00 01
9
II 0ethod be(ins at ,-* 0x2050
II +ode si&e 40 50x288
.maxstac 8
'3R0000M IJ =0 T 5018000002 JI ldtoen 6vi1a%IJ 23000001
JI7Kml;eriali&ation2o"To.4urchase/rderIJ 01000002 JI
'3R0005M IJ =0 T 5028000002 JI ldtoen &&&IJ 02000002 JI
'3R000aM IJ =0 T 51O8000001 JI ldtoen valuet%pe %%%IJ 01000003 JI
'3R000#M IJ =0 T 5068000001 JI ldtoen method instance void &&&IJ 02000002
JIMMabc58 IJ 06000001 JI
'3R0014M IJ =0 T 50*8000001 JI ldtoen #ield int32 LB0oduleHLIJ 02000001 JIMMii IJ
0*000001 JI
'3R0019M IJ =0 T 50*8000002 JI ldtoen #ield int32 &&&IJ 01000004 JIMMii IJ 0*000002
JI
'3R001eM IJ =0 T 50*8000003 JI ldtoen #ield int32 %%%IJ 01000003 JIMM11 IJ 0*000003
JI
244260235.doc 366 od 541
'3R0023M IJ =0 T 50*8000004 JI ldtoen method instance int32 6vi1a%IJ 23000001
JI7...IJ 01000005 JIMMhhh58 IJ 0*000004 JI
@ II end o# method &&&MMabc

This pro(ram deals "ith the instruction ldtoen that has a operand t%pe o# 'nlineTo. This is the
onl% instruction that this operand t%pe has and hence "e add one more condition in the
=ecode'3'nstrcution2 method. !e "ill explain the extra code added in the table t%pe 4 a little
later.

The ldtoen instruction taes a toen and places its runtime representation on the stac. The
ldtoen instruction cannot handle all the table t%pes and the ones it can handle "e (ive %ou an
example. The rest are disallo"ed and "e do not displa% the error messa(e "hen "e (ive a "ron(
table t%pe.

The #irst three ldtoen instructions deal "ith the T%pe,e#$ T%pe=e# and T%pe;pec tables. There is
no chan(e at all #or these table t%pes. The #ourth table is the 0ethod=e# table. !e are callin( a
method abc #rom the t%pe &&&. The onl% chan(e in s%ntax is that "e have to add the "ord method
at the ver% start or else "e (et a error.

Thus in the method =ecode0ember=e#Toen that handles a method$ "e have to at the ver% start
chec i# the opcode name is ldtoen. '# it is "e set the returnstrin( that "as null to method. !e
#inall% "ere able to sho" %ou an example "here the coded index table name "as T%pede#.

!e have added a i# statement to the Det0ember,e#4arent+oded'ndexTable "here i# the b%te
value is 0$ "e return a table t%pe o# T%pe=e#. '# "e loo at the 5
th
ldtoen$ "e are "ritin( the
"ords #ield $ its data t%pe and the #ield name ii. !e are on purpose not speci#%in( the t%pe and it
is assumed to be &&&.

!hen such a case happens$ the coded index table name in the T%pe,e# table is T%pe=e# and i# the
opcode is ldtoen "e add the "ord #ield at the be(innin(. !e then use the methodre# arra%s #or
the t%pe and return value and the t%pede#names arra% #or the t%pe name. )o" comes the problem
case.

'n the next t"o ldtoen instructions "e are re#errin( to t"o #ields #rom the class &&& and %%%. 'n
these case the coded index table is T%pe,e#. The problem is that "e need to #i(ure out "hether to
"rite the "ords #ield or method as the next ldtoen is used "ith a 0ethod,e# and this has the
"ord method precedin( it.

2o" do "e decide "hether the entit% #ollo"in( is a #ield or a method. 3ets loo at ho" our code
is handlin( it. !e start b% checin( "hether the opcode name is ldtoen. !e no" that the
T%pe,e# struct "ill store the name and namespace o# the entit% that contains the t%pe.

Thus #or the #irst #ield the T%pe,e# table "ill contain the class name &&& and #or the second class
%%%. Thus "e no" no" the t%pe #rom "hich the #ield or method comes #rom. !e scan the t%pe
de# table #rom start to end and #ind that name and namespace that "e (ot #rom the t%pe re# table.

The minute "e #ind a match$ "e brea out o# that loop and t%peindex contains the t%pe name o#
the t%pe that "as stored in the T%pe,e# table. )o" "e need to #i(ure out "hether it is a #ield or a
method. !e no" #ind out the #irst and last #ield o"ned b% the t%pe stored in the variable
t%peindex.

244260235.doc 367 od 541
!e do this lie be#ore and also store the startin( and endin( #ield numbers in start and starto#next.
!e have simpl% copied this code #rom the earlier examples. !e no" a #or loop scan these ro"
numbers in the #ield table #or a name matchin( the name "e #ound in the 0ember,e# table ro"
number speci#ied b% the toen variable.

'# a match is #ound "e set the #ound variable to true. !e then dependin( upon the value o# this
variable #ound decide to start the strin( initialstrin( to #ield or method. !e are assumin( that i#
the #ield name is not #ound in the >ield table$ it must be a method. * better "a% "ould be to also
scan the member re# table also.

!e are not scannin( the entire #ield table$ but onl% those that are o"ned b% our t%pe. There "as
one speci#ic "e could not sho" %ou and that "as the table t%pe 4 #or a #ield. The compiler
(enerates the il code and the +S compiler uses the ldtoen instruction "ith a table t%pe o# 4.

!hen "e (ive ilasm the same ldtoen instruction$ it converts it to a member re# table t%pe
instead. Thus i# "e meet "ith a #ield t%pe 4 and the instruction is ldtoen$ "e #irst "rite out "ords
#ield and then in the else tae care o# the spaces as be#ore. Thus the onl% chan(e is the "ord #ield
to be added and ad1ustment o# spaces.

4ro(ram69.csc
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror 8
9
seriouserror A 0<
int ori(inaltoen A toen<
int table A 5int85toen G 0x##0000008<
table A table HH 24<
toen A toen G 0x00######<
IIi# 5 opcode.)ame AA FldtoenF8
II+onsole.!rite3ine5F........F8<
i# 5 table AA 4 GG toen H >ield;truct.3en(th 8
9
+onsole.!rite5F JJJJJJJJJ :,,/, =';*;;:0O3')D T2: 0:T2/= '3 +/=:
JJJJJJJJJJJF8<
seriouserror A 1<
return <
@
i# 5 table AA 1 GG toen H T%pe,e#;truct.3en(th 8
9
+onsole.!rite5F JJJJJJJJJ :,,/, =';*;;:0O3')D T2: 0:T2/= '3 +/=:
JJJJJJJJJJJF8<
seriouserror A 1<
return <
@
+onsole.!rite5strin(s8<
i# 5 table AA 08
9
+onsole.!rite5F590@891@ JI 92@93@0x94@ F $ table.To;trin(5FK2F8 $toen.To;trin(5FK6F8$
opcode.)ame$ +reate;paces511Popcode.)ame.3en(th8 $ toen.To;trin(5FK2F8 8<
@
i# 5 table HA 60 TT table B 08
244260235.doc 368 od 541
9
b%te dumm%b%te A 5b%te8 table<
strin( returnstrin( A F5F C dumm%b%te.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame <
+onsole.!rite5returnstrin(8<
int len A 31 P returnstrin(.3en(th<
+onsole.!rite5+reate;paces5len88<
+onsole.!rite5FBunno"n toen t%pe 0xF C dumm%b%te.To;trin(5Fx2F8 C FHF8<
@
i# 5table AA 0x018
9
strin( returnstrin( A F5018F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pere#names6toen7<
+onsole.!rite5returnstrin(8<
@

This pro(ram can be i(nored as it deals "ith error checs. There are a series o# classes that
(enerate the il code #or %ou. This is the class '3Denerator. !e are allo"ed to place an% b%tes into
the code stream. Thus the examples "e "ent throu(h had all sorts o# errors and "e handled each
one.

Thus i# the table t%pe is 1$ the T%pere# table$ the toen or the table ro" in this case can never be
lar(er than the ro"s o# the T%pe,e# struct. '# this happens$ "e displa% a certain error and it is here
that "e set the variable seriouserror to 1 and then return.

!hen "e come bac$ "e need to abort this method onl% and thus "e set the code count be%ond
the len(th o# the code arra% and .uit out o# this method.

4ro(ram60.csc
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s8
9
i# 5 opcode./perandT%pe AA /perandT%pe.'nline,8
9
+onsole.!rite5strin(s8<
double toen A Oit+onverter.To=ouble5 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
b%te b5 A codearra%6codeindexC57<
b%te b6 A codearra%6codeindexC67<
b%te b7 A codearra%6codeindexC77<
b%te b8 A codearra%6codeindexC87<
+onsole.!rite5F90@91@92@93@94@95@96@
97@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F8$b5.To;trin(5FK
2F8$b6.To;trin(5FK2F8$b7.To;trin(5FK2F8$b8.To;trin(5FK2F8 8<
+onsole.!rite5F JI 90@ 91@ F$ opcode.)ame $ +reate;paces5388<
=ispla%,8 5toen$ codearra% $ codeindex8<
si&eo#instructiondata A 9<
244260235.doc 369 od 541
@

public void =ispla%,85double toen $ b%te 67 codearra% $ int codeindex8
9
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
b%te b5 A codearra%6codeindexC57<
b%te b6 A codearra%6codeindexC67<
b%te b7 A codearra%6codeindexC77<
b%te b8 A codearra%6codeindexC87<
strin( doubles A toen.To;trin(58<
int pos A doubles.'ndex/#5F:PF8<
int d2 A 0<
i# 5 pos EA P18
9
strin( d1 A doubles.;ubstrin(5posC28<
d2 A +onvert.To'nt325d18<
@
i# 5 doubles.'ndex/#5F'n#init%F8 EA P1 TT doubles.'ndex/#5F)a)F8 EA P1 TT d2 HA 3088
+onsole.!rite5F590@ 91@ 92@ 93@ 94@ 95@ 96@
97@8F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F8$b5.To;trin(5F
K2F8$b6.To;trin(5FK2F8$b7.To;trin(5FK2F8$b8.To;trin(5FK2F8 8<
else i# 5 toen AA 0 GG b8 AA 0x808
+onsole.!rite5FP0.0F 8<
else i# 5 toen AA 0 GG b8 AA 0x008
+onsole.!rite5F0.0F 8<
else
9
sss s1 A ne" sss58<
strin( ss A s1.,eturn;trin(>or,8 5toen $ 08<
+onsole.!rite5ss8<
@
@
@

e.il
.class &&&
9
.method public void abc58
9
ldc.r8 12.6
ldc.r8 12.61098767
ldc.r8 12
ldc.r8 0
ldc.r8 0.0
ldc.r8 P0.0
ldc.r8 500 00 00 00 00 00 >0 7>8 II ')>
ldc.r8 1.2:C309 II ')>
ldc.r8 5## ## ## ## ## ## ## ##8 II)an
244260235.doc 370 od 541
ldc.r8 501 00 00 00 00 00 00 008 II 4.9406564584124654eP324
@
@

'3R0000M IJ 23 T 3333333333332940 JI ldc.r8 12.6
'3R0009M IJ 23 T 88=13960=3382940 JI ldc.r8 12.61098767
'3R0012M IJ 23 T 0000000000002840 JI ldc.r8 12.
'3R001bM IJ 23 T 0000000000000000 JI ldc.r8 0.0
'3R0024M IJ 23 T 0000000000000000 JI ldc.r8 0.0
'3R002dM IJ 23 T 0000000000000080 JI ldc.r8 P0.0
'3R0036M IJ 23 T 000000000000>07> JI ldc.r8 500 00 00 00 00 00 >0 7>8
'3R003#M IJ 23 T 000000000000>07> JI ldc.r8 500 00 00 00 00 00 >0 7>8
'3R0048M IJ 23 T >>>>>>>>>>>>>>>> JI ldc.r8 5>> >> >> >> >> >> >> >>8
'3R0051M IJ 23 T 0100000000000000 JI ldc.r8 501 00 00 00 00 00 00 008

'n this pro(ram "e "ill come do "hat "e promised %ou a lon( time a(o and that is ho" to handle
numbers "ith decimal places. '# "e start "ith the #ile e.il #irst numbers lie 12.6 are called
#loatin( point numbers as the% have a decimal point in them. The% are displa%ed as is. '# "e have
a number lie 12$ a decimal point is added and no &ero a#ter it.

'# the number has tons o# decimal places lie the third case$ all the decimal places are displa%ed.
The next case is that o# a &ero "hich is displa%ed as a &ero "ith a decimal point and then a
ne(ative &ero that re.uires a ne(ative si(n. !e have to "rite the ne(ative &ero as [0.0 or else it
becomes a positive 0. >or the positive &ero it is optional.

;o #ar so (ood but the problem is "ith numbers lie 'n#init% and )a) that stands #or not a
number. These have to be displa%ed "ithin bracets. Oe#ore "e explain "hat a )a) is lets
understand that a =ouble taes up 8 b%tes and represents a double precision #loatin( point
number.

The ran(e #or a double is ne(ative 1.79769313486232e308 to positive 1.79769313486232e308.
Thus "hen "e cross this ran(e on the hi(her or lo"er ran(e "e (et to displa% the number in
bracets. * )a) is not a number that happens "hen "e divide b% &ero. 3ets loo at our code
startin( "ith the =ecode'3'nstrcution2. !e add a i# statement checin( #or operand t%pe 'n3ine,.

*s ei(ht b%tes #ollo" this operand t%pe "e use the To=ouble method to extract the b%te as "ell as
use the b%tes b1 to b8 to individuall% extract them. !e then "rite out the b%tes in round bracets
and then displa% the name o# the op code. !e then call a #unction =ispla%,8 to actuall% displa%
the #loatin( point number and then set the si&eo#instructiondata to 9.

Thus it is the =ispla%,8 method that does the (runt "or. 'n this method "e once a(ain pic up
the 8 b%tes as individual b%tes and then convert the double number stored in the variable toen to
a strin( usin( the To;trin( #unction o# the ob1ect class. !e then need to #ind out i# this number is
a ver% small number and the thus "e #ind "hether it contains a :P.

'# pos is positive$ "e #ound the match and no" "e extract the strin( 2 b%tes #rom the "ords :P to
(et a strin( that onl% contains the number a#ter the exponent or :. !e convert this to an inte(er
stored in the variable d2. )o" i# the ori(inal #loatin( point number in toen is too lar(e or is
)a)$ then "hen "e convert to a strin($ "e (et 'n#init%.

244260235.doc 371 od 541
This does not happen "ith numbers smaller than :P308 #or some unno"n reasons. !e expected
that i# "ith lar(e numbers "e (et 'n#init% "hen "e convert it into a strin($ "e expected the same
behavior "ith smaller numbers that are out o# ran(e. This "h% "e need to chec #or three
conditions i# the number should be in bracets.

'# there is an in#init% or )a) in the strin( and i# d2 is lar(er than 308. 'n these cases "e simpl%
displa% the number in bracets. !e then chec #or a positive or ne(ative &ero b% looin( at the
last b%te as the topmost bit is the si(n bit. )o" comes the problem. * number lie 12 should be
displa%ed as 12. and 12 b% itsel#.

The ori(inal ildasm "as "ritten in +CC "hich has its o"n #unctions #or displa%in( #loatin( point
numbers. Thus "e decided in callin( those #unctions that ildasm calls. :asier said than done. !e
created a class sss in "hich "e have a method ,eturn;trin(>or,8 that taes the #loatin( point
number and a &ero.

This method "ill be called #or #ields "here this variable has a value o# 1. !e simpl% displa% the
strin( that this #unction returns. 3ets loo at the code #or this class sss #irst.

abcde#.cpp
Sinclude Bstdio.hH
Sinclude Bstdlib.hH
Sinclude Bstrin(.hH
Susin( Bmscorlib.dllH
usin( namespace ;%stem<
RR(c public class sss
9
publicM
@<
;trin( J sssMM,eturn;trin(>or,85double e $ int 18
9
char s&prt610007<
char s&#6327$Jpch<
(cvt5e $ 17 $ s&#8<
double d# A strtod5s&# $ Gpch8<
i# 5 1 AA 08
sprint# 5 s&prt $ FasF$ s&#8<
else i# 5 d# AA e 8
sprint# 5 s&prt $ Fas8F$ s&#8<
else
sprint# 5 s&prt $ F0xa'64K8 II asF$ e $ s&#8<
;trin( Jss A s&prt<
return ss<
@

!e no" "rite in a #ile abcde#.cpp in the same director% and this is in mana(ed +CC ver% similar
to +S. !e start "ith some header #iles that carr% no code but #unction protot%pes. These header
#iles are somethin( that both ?ava and +S do not lie and hence are not present in these
lan(ua(es.

!e need to use the class ;trin( and mae "ant to call code #rom the ;%stem class and hence "e
have the t"o usin( clauses. *s "e are callin( this code #rom mana(ed code$ "e "ant this class to
244260235.doc 372 od 541
be (arba(e collected and hence the e%"ord RR(c. 'n +CC "e place the protot%pes o# the methods
in the class and the code outside the class.

Thus outside the class "e pre#ace the method name "ith the name o# the class and t"o colons.
!e simpl% use the #unction (cvt that is a old + #unction to convert the double e into a strin( "ith
17 di(its and store it in the arra% s&#. *s the value o# 1 is 0$ "e simpl% "rite out the strin( that "e
have in the s&# to s&prt.

!e could have copied the strin( #rom one arra% to another. The as tells us that the parameter
#ollo"in( is a strin( as ad "ould be a number. !e no" all this as "e have #irst cut our teeth on
+ and then +CC and then ?ava and no" +S. "e then create a pointer to a stin( class ss and e.uate
it to the arra% s&prt that "e return.

The rest o# the code "e do a little later. Thus to displa% #loatin( point numbers. !e handle the
exception cases #irst and then use + code to (et us the number as a strin(. !e looed at a #ile
called dis.cpp that comes "ith the ;hared ;ource and #i(ured out ho" ildasm "as displa%in(
numbers.

*lso "e need to compile the above as

+l Iclr I]= abcde#.cpp.

The cl is the +CC compiler$ Iclr tells it to produce .)et or mana(ed code and I]= to produce a dll.
)o" "e have to add I, abcde#.dll to the +S compiler option.

4ro(ram61.csc
public void =ispla%*ll>ields 5int t%peindex8
9
int len A returnstrin(.3en(th<
+onsole.!rite5returnstrin(8<
Det>ield+onstant-alue5#ieldindex $ len 8<
=ispla%+ustom*ttribute5F>ield=e#F $ #ieldindex $ spaces#ornested C spaces#orrest8<
@

public void Det>ield+onstant-alue 5int constantro" $ int len 8
9
int ii<
i# 5 +onstants;truct AA null 8
9
+onsole.!rite3ine58<
return <
@
#or 5 ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
int tablet%pe A +onstants;truct6ii7.parent G 0x03<
i# 5 tablet%pe AA 08
9
int constantro"coded A +onstants;truct6ii7.parent HH 2<
i# 5 constantro"coded AA constantro"8
brea<
@
244260235.doc 373 od 541
@
i# 5 ii EA +onstants;truct.3en(th 8
9
i# 5 +onstants;truct6ii7.dt%pe AA 148
Det>ield+onstant-alue*s;trin( 5constantro" $ +onstants;truct6ii7.dt%pe
$+onstants;truct6ii7.value $ len8<
else
9
strin( ss A =ispla%>rom+onstantsTable 5constantro"$0 $F>ield=e#F8<
+onsole.!rite5ss8<
@
@
else
+onsole.!rite3ine58<
@
public strin( =ispla%>rom+onstantsTable 5int start $ int end $strin( tablename 8
9
strin( returnstrin( A FF<
i# 5 +onstants;truct AA null8
return FF<
#or 5 int ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
strin( consttablename A Det2as+onstTable5+onstants;truct6ii7.parent8<
int constindex A Det2as+onst-alue5+onstants;truct6ii7.parent8<
i# 5 consttablename AA tablename 8
9
i# 5 start AA constindex 8
9
i# 5 consttablename AA F4ropert%F TT consttablename AA F>ield=e#F8
returnstrin( A F A F<
else
returnstrin( A F A F<
int value A +onstants;truct6ii7.value<
i# 5 +onstants;truct6ii7.dt%pe AA 138
9
returnstrin( A returnstrin( C F#loat645F <
=ouble val A Oit+onverter.To=ouble5blob $ valueC18<
IIint dumm% A Oit+onverter.To'nt325blob $ valueC18<
sss s1 A ne" sss58<
strin( ss A s1.,eturn;trin(>or,8 5val $ 18<
returnstrin( A returnstrin( C ss C FUrUnF<
@
@
e.il
.class &&&
9
.#ield int64 16 A #loat64510.338
.#ield int64 15 A #loat6450x*8
@

.#ield IJ04000001JI privatescope int64 16Z4;T04000001 A #loat64510.338
244260235.doc 374 od 541
.#ield IJ04000002JI privatescope int64 15Z4;T04000002 A #loat6450x*8 II
4.9406564584124654eP323

'n this pro(ram "e once a(ain displa% numbers "ith decimal places but no" "ith re#erence to
#ields. >ields can have constant values that are stored in the constants table. !e have a method
Det>ield+onstant-alue that simpl% displa%s the constant value o# the #ield (iven the #ield ro"
number and the len(th o# the #ield directive so #ar.

'n this method Det>ield+onstant-alue "e as in the #unction =ispla%>rom+onstantsTable scan the
+onstants table. '# this table is null$ "e have no constants and thus no constant value #or the #ield
and hence "e need to "rite out the enter. !e then scan the +onstants table #or a coded index
value o# &ero #or the #ield table t%pe and the ro" number.

'# "e meet a match "e exit the loop and no" chec a#ter the loop i# the variable ii is a valid ro"
number in the +onstants table. '# %es$ "e no" chec i# its #ield t%pe is 14$ that o# a strin(. '# it is
"e have a #unction Det>ield+onstant-alue*s;trin( that handles 1ust the strin( t%pe and then call
the =ispla%>rom+onstantsTable to handle all the other t%pes.

'# the constants table is not null and the #ield has no initiali&ations done$ "e simpl% "rite out a
ne" line. The method =ispla%>rom+onstantsTable taes the #ield ro" number and the second
parameter is not used. The third is the name o# the table >ield=e#. The method
=ispla%>rom+onstantsTable has onl% t"o small chan(es initiall%.

The #irst is that "e add the table name >ield=e# to the #irst i# statement so that the returnstrin(
variable (ets one less space be#ore the e.ual to si(n. T"o #or the sae o# convenience "e also
create a variable value and set it to the value #ield o# the +onstants table. !e then chec #or the
t%pe to be 13 "hich stands #or a #loatin( point number.

!e #irst "rite out the strin( #loat64 "ith a open bracet in the variable returnstrin(. !e then read
the double stored in the blob arra%. )o" "e do no other computation in +S but call the
,eturn;trin(>or,8 in the abcde#.dll to return the #loatin( point starin(.

*s "e are dealin( "ith #ields$ "e have the last parameter a 1 and not &ero. 'n the
,eturn;trin(>or,8 method$ as the value o# variable 1 is 1 and not &ero$ the else i# and the else (et
called. There is a method called strtod that converts a strin( bac to a #loatin( point number and
returns this value.

The second parameter is a pointer to chars that "ill stop the scannin(. !e do not "ant the
scannin( to stop and hence (ive no chars. Thus "e started "ith a #loatin( point number and then
converted it into a strin( usin( (cvt and then once converted it bac to a double.

'# there is no loss alon( the "a%$ the t"o doubles "ill be the same and thus "e displa% it as a
strin( stored in the s&# arra% "ith a closed bracet. '# there is a mismatch$ then "e displa% the
#loatin( point number in hex #irst alon( "ith the exponential notation in bracets.

Thus the #irst #ield 10.33 sho"s "ith the else i# and the ver% small value o# the second #ield
sho"s up "ith comments. Thus "e have let the +CC #unction handle all the cases. Thus #loatin(
point numbers "ith #ields and in a il instruction are ver% di##erent.

4ro(ram62.csc
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nline,8
244260235.doc 375 od 541
9
+onsole.!rite5strin(s8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
;in(le sin(levalue A Oit+onverter.To;in(le5codearra%$ codeindexC18<
strin( s A sin(levalue.To;trin(58<
+onsole.!rite5F90@91@92@
93@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5888<
+onsole.!rite5F JI 90@ 91@ F$ opcode.)ame $ +reate;paces538 8<
i# 5 sin(levalue AA 0.0156258
+onsole.!rite5F1.5625eP002F8<
else i# 5 sin(levalue AA 1.5eC0098
+onsole.!rite5F1.5eC009F8<
else i# 5 sin(levalue AA 1.5eC0088
+onsole.!rite5F1.5eC008F8<
else i# 5 sin(levalue AA 0 GG b4 AA 0x808
+onsole.!rite5FP0.0F 8<
else i# 5 sin(levalue AA 08
+onsole.!rite5F0.0F 8<
else i# 5 s.:nds!ith5F.5F8 TT s.:nds!ith5F.25F8 TT s.:nds!ith5F.75F8 TT s.:nds!ith5F0625F8 TT
s.:nds!ith5F125F8TT s.:nds!ith5F.375F8 8
+onsole.!rite5s8<
else
9
II+onsole.!rite3ine5F.......*F8<
sss s4 A ne" sss58<
strin( ss A s4. ,eturn;trin(>or,45sin(levalue 8<
i# 5 ss AA FF8
+onsole.!rite5F590@ 91@ 92@ 93@8F $ b1.To;trin(5FK2F8$ b2.To;trin(5FK2F8$ b3.To;trin(5FK2F8$
b4.To;trin(5FK2F88<
else
+onsole.!rite5ss8<
@
si&eo#instructiondata A 5<
@

.method public void abc58
9
ldc.r4 15.1
ldc.r4 P15.1
ldc.r4 15.01
ldc.r4 15.1234
ldc.r4 15.256789
ldc.r4 12345.15
ldc.r4 0.6
ldc.r4 0.05
ldc.r4 34.5129
ldc.r4 0.115625
244260235.doc 376 od 541
ldc.r4 P2000000000000000000
ldc.r4 0.075
ldc.r4 1000000
ldc.r4 21
ldc.r4 10
ldc.r4 16777216
ldc.r4 8.5
ldc.r4 8.25
ldc.r4 9.25
ldc.r4 9.75
ldc.r4 14.
ldc.r4 15.0
ldc.r4 1.5eC009
ldc.r4 10000001
ldc.r4 1500000000
ldc.r4 20000000
ldc.r4 10000001
@

'3R0000M IJ 22 T 9*997141 JI ldc.r4 59* 99 71 418
'3R0005M IJ 22 T 9*9971+1 JI ldc.r4 59* 99 71 +18
'3R000aM IJ 22 T >6287041 JI ldc.r4 5>6 28 70 418
'3R000#M IJ 22 T 72>97141 JI ldc.r4 572 >9 71 418
'3R0014M IJ 22 T +>1O7441 JI ldc.r4 5+> 1O 74 418
'3R0019M IJ 22 T 9*:44046 JI ldc.r4 59* :4 40 468
'3R001eM IJ 22 T 9*99193> JI ldc.r4 59* 99 19 3>8
'3R0023M IJ 22 T +=++4+3= JI ldc.r4 5+= ++ 4+ 3=8
'3R0028M IJ 22 T 360=0*42 JI ldc.r4 536 0= 0* 428
'3R002dM IJ 22 T +=++:+3= JI ldc.r4 5+= ++ :+ 3=8
'3R0032M IJ 22 T 6O0O=:== JI ldc.r4 56O 0O =: ==8
'3R0037M IJ 22 T 9*99993= JI ldc.r4 59* 99 99 3=8
'3R003cM IJ 22 T 00247449 JI ldc.r4 1000000.
'3R0041M IJ 22 T 0000*841 JI ldc.r4 21.
'3R0046M IJ 22 T 00002041 JI ldc.r4 10.
'3R004bM IJ 22 T 0000804O JI ldc.r4 16777216
'3R0050M IJ 22 T 00000841 JI ldc.r4 8.5
'3R0055M IJ 22 T 00000441 JI ldc.r4 8.25
'3R005aM IJ 22 T 00001441 JI ldc.r4 9.25
'3R005#M IJ 22 T 00001+41 JI ldc.r4 9.75
'3R0064M IJ 22 T 00006041 JI ldc.r4 14.
'3R0069M IJ 22 T 00007041 JI ldc.r4 15.
'3R006eM IJ 22 T 5:=0O24: JI ldc.r4 1.5eC009
'3R0073M IJ 22 T 8196184O JI ldc.r4 10000001
'3R0078M IJ 22 T 5:=0O24: JI ldc.r4 1.5eC009
'3R007dM IJ 22 T 8096984O JI ldc.r4 20000000
'3R0082M IJ 22 T 8196184O JI ldc.r4 10000001

This pro(ram no" displa%s a sin(le or hal# a double. This #loatin( point is a sin(le precision and
taes up onl% #our b%tes. 'ts value ran(es #rom ne(ative 3.402823e38 to positive 3.402823e38$ as
"ell as the #ive exceptions $ positive or ne(ative &ero$ positive or ne(ative in#init% and )a).
;in(le is hal# a double or #loat in +. 3ets loo at the output #irst and chec "hether "e can #ind
244260235.doc 377 od 541
some pattern. The #irst 12 #loatin( point numbers sho" up as #our numbers in bracets. Thus a
15.1 or 15.01 sho"s up as bracets but 15 b% itsel# "ith a decimal point. * 0.05 and a 115625 are
in bracets but 8.5 and 9.75 are sho"n as is. !e (ot lost in tr%in( to #i(ure out "hether "e need
to displa% in bracets or as a #loatin( point number. 2ence this part is not complete as "e could
not #i(ure out ho" ildasm displa%s a #loatin( point number "ith sin(le precision. :ven looin( at
the code in dis.cpp did not help. Thus lets loo at the code in the last i# statement in the method
=ecode'3'nstrcution2. !e read the ;in(le value stored in the blob heap and "rite out the #our
individual b%tes. !e then account #or some special cases. The (cvt #unction has some problem in
displa%in( numbers that have the #orm 0.0BxH$ "here x is a se.uence o# di(its. This is
documented in the 0icroso#t \no"led(e base article Y37794 "here it displa%s the number in
scienti#ic notation and not the normal "a%. The #irst i# statement handles this. !hen "e have
numbers lie 15 and six or seven &eroes$ these numbers also use the exponential notation. !e
then handle the positive and ne(ative &eroes as be#ore and then i# the number ends in .5 or .25 etc$
"e displa% it usin( the strin( value. )o" "e call the ,eturn;trin(>or,4 "ritten in +CC to return
the rest and i# it returns a null$ "e use the de#ault that is in bracets. 3ets loo at the +CC code
#irst.

RR(c public class sss
9
publicM
;trin( J ,eturn;trin(>or,85double e $ int 8<
;trin( J ,eturn;trin(>or,45#loat e 8<
@<
;trin( J sssMM,eturn;trin(>or,45#loat e 8
9
char s&#6327$Jpch<
(cvt5e $ 8 $ s&#8<
#loat d# A ato#5s&# 8<
char Js A strchr5s&# $ L.L8<
int result A 5int8 5 s P s&#8<
;trin( Jss <
ss A s&#<
i# 5 5strlen5s&#8 P result 8 AA 1GG e BA 99999998
return ss<
else i# 5 strchr5s&#$L.L8 AA 08
return ss<
else
ss A FF <
return ss<
@

'n this #unction "e #irst use the (cvt method to (ive us the strin( representation o# the #loat in the
arra% s&#. Then "e use ato# to convert the #loat strin( bac into a #loat d#. !e also use the strchr
method to #ind "hether the #loat strin( has a decimal point.

'# it does$ "e (et a non &ero pointer to "here the decimal point is in the strin( s&#. '# the strin(
does not have a decimal point$ "e (et null or &ero. 'n + a pointer can not have a null or &ero
value. The variable result "ill contain the "here the decimal point is "ithin the strin(.

244260235.doc 378 od 541
Thus i# the value is 2$ it means that the decimal point is at the third place as in 15.9. !e then
subtract the len(th o# the strin( (ot b% usin( the strlen #rom this value and i# it is one "e return
the value o# ss or the strin( in arra% s&#. 't is this strin( that is non &ero is displa%ed.

'# the strin( is null$ it means that the #loatin( point number is to displa%ed in bracets. Thus #or
10000. the value o# result is 5 and the di##erence is 1 as the i# statement in :n(lish means that "e
have a number "ith a decimal point but no decimal places. '# the number becomes 10000.1$ it
(ets displa%ed in bracets.

'# "e simpl% displa% the value o# the s variable in +S$ "e do not (et the dot. Then "e chec
"hether the strin( does not have a dot. Thus 1.677722:C07 (ives us true as there is no decimal
place and 10000 (ives us #alse as there is no decimal place. >or threes numbers "e return the
same strin( bac "hich is not in exponential #orm.

:lse "e return a null and let +S displa% the number in bracets. Thus "e chec in +CC #or t"o
cases one i# it is the decimal point is at the ver% end and #or no decimal point at all in the strin(.
O% "ritin( such code$ "e have covered nearl% all cases.

4ro(ram71.csc
i# 5 +onstants;truct6ii7.dt%pe AA 12 8
9
returnstrin( A returnstrin( C F#loat325F <
;in(le sin(levalue A Oit+onverter.To;in(le5blob$ valueC18<
int val A Oit+onverter.To'nt325blob $ valueC18<
strin( s A sin(levalue.To;trin(58<
int decimalpoint A s.'ndex/#5F.F8<
i# 5 val AA 0x4:O2=05:8
returnstrin( A returnstrin( C F1.5eC009F <
else i# 5 decimalpoint AA P1 GG E5s.'ndex/#5F'n#init%F8 EA P1 TT s.'ndex/#5F)a)F8 EA P188
returnstrin( A returnstrin( C s C F.F <
else
returnstrin( A returnstrin( C F0xF C val.To;trin(5FK8F8<
returnstrin( A returnstrin( C F8UrUnF<
II+onsole.!rite3ine5returnstrin(8<
@

.class &&&
9
.#ield public #loat64 i A #loat3251.28
.#ield public #loat64 i1 A #loat325158
.#ield public static literal #loat32 )a) A #loat3250x>>+000008
.#ield public static literal #loat32 4ositive'n#init% A #loat3250x7>8000008
.#ield public static literal #loat32 )e(ative'n#init% A #loat3250x>>8000008
.#ield private static literal #loat32 T//RO'D A #loat3250x4:O2=05:8
@

.#ield IJ04000001JI public #loat64 i A #loat3250x3>99999*8
.#ield IJ04000002JI public #loat64 i1 A #loat3250x0000000>8
.#ield IJ04000003JI public static literal #loat32 )a) A #loat3250x>>+000008
.#ield IJ04000004JI public static literal #loat32 4ositive'n#init% A #loat3250x7>8000008
.#ield IJ04000005JI public static literal #loat32 )e(ative'n#init% A #loat3250x>>8000008
244260235.doc 379 od 541
.#ield IJ04000006JI private static literal #loat32 T//RO'D A #loat3251.5eC0098

'n the last pro(ram #or sin(le precision #loatin( point numbers "e are dealin( "ith #ields as "e
did #or double precision #loatin( point numbers. !e as be#ore tae into a account some special
cases lie 1.5e0009 as explained be#ore. !e need to displa% this value in a exponential notation.

!e then #i(ure out the decimal point and i# it is not there and the strin( does not contain a in#init%
or a )a) "e displa% it "ith a dot. This applies to numbers lie 15.0. >inall% "e have to displa%
the value as a hex number and thus "e use the variable val to read the read the #loatin( point
number as a int. !e do not call the code in the abcde#.dll #ile.

4ro(ram.
i# 5 opcode./perandT%pe AA /perandT%pe.'nline;trin(8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
toen A toen G 0x00######<
int ho"man%b%tes$ uncompressedb%te5<
ho"man%b%tesA +or;i(Nncompress=ata5us $ toen $ out uncompressedb%te58<
int count A uncompressedb%te5 P 1<
i# 5 ho"man%b%tes AA 38
ho"man%b%tesCC<
int startin(pt A toen C ho"man%b%tes<
b%te 67 strin(arra% A ne" b%te6count7<
*rra%.+op%5us $ startin(pt$ strin(arra% $ 0 $ count8<
bool maearra% A 's0ae*rra% 5strin(arra%8<
i# 5 maearra% GG count EA 08
9
+onsole.!rite5F570890@ JI 91@ F $ toen.To;trin(5FK6F8 $ opcode.)ame8<
+onsole.!rite5Fb%tearra% 5F8<
=ispla%>ormatted+olumns 5toen$ 62 C 5spaces#orrestC2C spaces#ortr% C spaces#ornested8 $
#alse $ true8<
@
else
9
strin( str A Det)ameN 5toen $ #alse $ 08<
+onsole.!rite5F570890@ JI 91@ F $ toen.To;trin(5FK6F8 $ opcode.)ame8<
+onsole.!rite5FUFF8<
strin( returnstrin(<
returnstrin( A =ispla%;trin(0ethod 5str$spaces#orrestC2C spaces#ortr% C spaces#ornested $ 0 $
#alse8<
+onsole.!rite5returnstrin(8<
+onsole.!rite5FUF IJ 7090@ JIF $ toen.To;trin(5FK6F88<
@
si&eo#instructiondata A 5<
@
bool 's0ae*rra%5b%te 67 strin(arra%8
9
int countascii A 0<
int index A 0<
bool maearra% A #alse<
244260235.doc 380 od 541
"hile 5 index B strin(arra%.3en(th P 1 8
9
i# 5 strin(arra%6index7 HA 129 8
countasciiCC<
i# 5 strin(arra%6index7 BA 31 GG E5 strin(arra%6index7 AA 0x0d TT strin(arra%6index7 AA 0x0a TT
strin(arra%6index7 AA 0x09 88
countasciiCC<
i# 5 strin(arra%6indexC17 EA 0 8
countasciiCC<
index A index C 2<
@
i# 5 countascii HA 18
maearra% A true<
return maearra%<
@
public strin( =ispla%;trin(0ethod5strin( str$int spaces $ int tablero" $ bool #ield8
9
bool not#irstline A #alse<
int len A str.3en(th <
int counto#chars A 0<
int totalcount A 0<
int b%tecount A 49<
strin( returnstrin( A FF<
int secondline A 101<
i# 5 #ield 8
9
strin( s A Det>ield*ttributes5tablero"8<
secondline A s.3en(th C #ieldparamarra%6tablero"7.3en(th C
)ame,eserved5Det;trin(5>ield;truct6tablero"7.name88.3en(th C 74<
@
#or 5 int ii A 0 < ii B len < iiCC8
9
i# 5 str6ii7 AA LUtL8
returnstrin( A returnstrin( C FUUtF <
else i# 5 str6ii7 AA LFL8
returnstrin( A returnstrin( C FUUUFF <
else i# 5 str6ii7 AA LUUL8
returnstrin( A returnstrin( C FUUUUF<
else i# 5 str6ii7 AA 138
returnstrin( A returnstrin( C FUUrF<
else i# 5 str6ii7 AA 108
returnstrin( A returnstrin( C FUUnF<
else i# 5 str6ii7 AA LbL8
returnstrin( A returnstrin( C FUUbF<
else
returnstrin( A returnstrin( C str6ii7<
i# 5 str.3en(th HA 50 GG str6497 AA LUUL8
b%tecount A 48<
i# 5 counto#chars AA b%tecount GG Enot#irstline GG E5 len AA 50 TT len AA 51 TT len AA 528 8
9
returnstrin( A returnstrin( C FUFUrUnF C +reate;paces5spaces8 C FC UFF <
244260235.doc 381 od 541
not#irstline A true<
counto#chars A 0<
@
else i# 5 not#irstline GG 5counto#chars a secondline8 AA 0 8
9
int charsle#t A len P totalcount <
i# 5 charsle#t HA 48
returnstrin( A returnstrin( C FUFUrUnF C +reate;paces5spaces8 C FC UFF <
counto#chars A 0<
@
totalcountCC<
counto#charsCC<
@
return returnstrin(<
@
public strin( Det)ameN5int startin( $ bool blobtable $ int tablero"8
9
int ho"man%b%tes $ uncompressedb%te<
i# 5 blobtable 8
ho"man%b%tes A +or;i(Nncompress=ata5blob $ startin( $ out uncompressedb%te8<
else
ho"man%b%tes A +or;i(Nncompress=ata5us $ startin( $ out uncompressedb%te8<
int len A uncompressedb%te<
;%stem.Text.:ncodin( e A ;%stem.Text.:ncodin(.Nnicode<
strin( returnstrin( <
i# 5 blobtable 8
returnstrin( A e.Det;trin(5blob$ startin( C ho"man%b%tes $ len8<
else
returnstrin( A e.Det;trin(5us$ startin( C ho"man%b%tes $ len8<
return returnstrin(<
@
.class &&&
9
.method public void abc58
9
ldstr F0% name is vi1a% muhi. 4lease tell m% "i#e sonal that ' love her a lot and "ill F
ldstr b%tearra% 501 65 8
@
@

'3R0000M IJ 72 T 5708000001 JI ldstr F0% name is vi1a% muhi. 4lease tell m% "i#e
sonal F
C Fthat ' love her a lot and "ill F IJ 70000001 JI
'3R0005M IJ 72 T 57080000*6 JI ldstr b%tearra% 501 65 8 II
.e IJ 700000*6 JI


The last /perandT%pe t%pe is 'nline;trin(. There is 1ust one instruction ldstr that #alls in this
#amil%. !e start as al"a%s addin( a i# statement #or this t%pe and then picin( up the #our b%te
number that (ives us an o##set into the us heap "here this strin( is stored.

244260235.doc 382 od 541
The us heap is "here strin(s created b% the pro(rammer in code are stored. This heap also starts
"ith a count b%te that "e store in the variable count and the variable startin(pt (ives us the actual
start o# the strin(. This "e (et b% addin( the ho"man%b%tes that tell us ho" man% b%tes this
strin(s len(th occupies to the toen variable.

!e then create an arra% strin(arra% o# si&e count b%tes and then use the +op% method #rom the
arra% class to cop% the strin( #rom the us heap to this arra%. !e no" have a method 's0ae*rra%
that returns a true or #alse dependin( upon "hether "e have to displa% the strin( as a strin( or as
series o# b%tes.

3ets no" loo at "hat this method has to o##er. !e pass this method our arra% o# b%tes and then
scan each b%te in a loop. !e then increment a variable countascii b% one i# "e meet a non ascii
character i.e. an% number lar(er than 128.

!e also increment this variable i# "e meet a b%te that is smaller than 31$ but "e i(nore the tab$
and the t"o ne" line characters. *lso as all our strin(s are unicode strin(s$ the next b%te or the
odd b%te must be &ero and thus i# "e #ind a non &ero odd b%te$ "e also increase countascii b% 1.

!e increment the index variable b% 2 as "e are dealin( "ith 16 bit unicode characters. !hen "e
leave the "hile$ i# "e #ind an% o# the above characters$ the variable countascii "ill be lar(er than
1 and "e return true. Thus "e displa% the b%tes as b%tes i# "e #ind that "e do have a unicode
strin(.

'# "e have some b%tes to displa% and the variable maearra% is true$ "e "rite out the o##set in the
us heap that has a number 0x70 and then the "ords b%tearra%. !e then use the trusted
=ispla%>ormatted+olumns method to "rite out the b%tes properl% #ormatted one belo" the other.

'# variable maearra% is #alse$ then "e have to displa% the b%tes as a strin( and "e use the method
Det)ameN to (ive us the strin( stored in the us heap. 'n this method "e tae t"o parameters$ the
startin( point o# the strin( and a bool. The use o# this boolean variable is to tell us "hether this
strin( is stored in the us heap or the blob heap.

>ields can also be initiali&ed to a strin( and these strin(s are stored in the blob heap and not the us
heap. Thus the second parameter is #alse #or strin(s in the us heap. !e repeat ourselves once
a(ain in this #unction and "e (et the count b%tes once a(ain and the len(th occupied b% the count
b%tes.

!e use the Det;trin( method that taes a arra% o# b%tes and a startin( point in that arra% and the
len(th or count o# the b%tes and (ives us a strin( in return. This is the unicode strin( that "e
return bac.

!e once a(ain "rite out the o##set o# the strin( and no" use a method =ispla%;trin(0ethod to
"rite out the strin( on multiple lines passin( it the actual strin( and the initial spaces as "ell as
the last t"o parameters are used #or #ields and hence the last one is #alse as "e are dealin( "ith
instructions. 'n this method the strin( has to be displa%ed properl% #ormatted on multiple lines.

The variable not#irstline is #alse #or the #irst line and then true #or the second line on"ards. The
variable b%te count is the number o# characters that "ill be "ritten on the #irst line and secondline
tells us ho" man% "ill be "ritten on the second line. The variable ii "ill let us scan the entire
strin( stored in the strin( variable str.

244260235.doc 383 od 541
!e #irst chec #or special characters lie a tab and enter and "e need to .uote these characters as
"e are usin( the !rite3ine #unction to "rite them out. Thus i# the !rite3ine method sees a enter
or a 13$ it "ill "rite out a ne" line and hence "e have a add a bacslash to escape the special
characters. Thus "e escape six special characters.

The entire strin( is stored in the returnstrin( variable alon( "ith the enters and the spaces also.
The onl% problem is that i# the last character on a line is a bacslash$ it is moved on to the next
line b% reducin( the "idth o# the line #rom 49 to 48 that is stored in the b%tecount variable.

The variable counto#chars starts at &ero and is incremented #or each character. !hen it touches 49
or b%tecount$ "e no" that "e need to "rite on the next line. Thus the #irst i# statement checs
that the counto#chars e.uals b%tecount and the not#irstline is #alse.

'# this condition is met "e add a return "ith spaces and a plus si(n to returnstrin( and set
counto#chars to &ero. Thus this variable each time tells us ho" man% characters "e have "ritten
on a ne" line so #ar. !e also set the not#irstline to true so that this i# statement (ets called onl%
once.

*lso i# the len(th o# the strin( is up to 52 characters$ "e do not displa% it on t"o lines but a sin(le
line and hence the #inal condition on the i# statement. 'n the else "e do not reall% need the #irst
condition and chec "hether "e "ritten out enou(h characters #or the second line on"ards.

This number is store in the variable secondline. There is one small exception and that is i# the last
line "ill have less than #our characters$ "e "rite them out on the same line and do not create a
ne" line. Thus "e #irst #ind out "hether ho" man% characters "e have le#t to "rite out.

'# this number is less than 4$ "e do not "rite out a ne" line. !e once a(ain set the counto#chars
to &ero and this else (ets called #or the second line on"ards. !e use totalcount to (ive us a count
o# all characters "ritten out so #ar and is e.ual to the index variable ii.

4ro(ram.
public void Det>ield+onstant-alue*s;trin( 5int tablero" $ int value $ int len8
9
strin( returnstrin( A F A F<
+onsole.!rite5returnstrin(8<
int ho"man%b%tesA0$uncompressedb%te $ count<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ value $ out uncompressedb%te8<
count A uncompressedb%te<
value A value C ho"man%b%tes<
b%te 67 strin(arra% A ne" b%te6count7<
*rra%.+op%5blob $ value $ strin(arra% $ 0 $ count8<
bool maearra% A 's0ae*rra%5strin(arra%8<
i# 5 maearra% GG count EA 08
9
+onsole.!rite5Fb%tearra% 5F8<
=ispla%>ormatted+olumns5valuePho"man%b%tes$ lenC14 $ #alse $ #alse8<
@
else
9
strin( str A FF<
str A Det)ameN5value P ho"man%b%tes$ true $ tablero"8<
244260235.doc 384 od 541
returnstrin( A FUFF<
returnstrin( A returnstrin( C =ispla%;trin(0ethod 5str$spaces#orrestC spaces#ortr% C
spaces#ornested $ tablero" $ true8<
returnstrin( A returnstrin( C FUFF<
+onsole.!rite3ine5returnstrin(8<
@
return <
@

.class &&&
9
.#ield public int8 bb A F0% name is vi1a% muhi. 4lease tell m% "i#e sonal that ' love her a lot
and "ill F
.#ield public int8 cc A b%tearra% 501 48 498
@

.#ield IJ04000001JI public int8 bb A F0% name is vi1a% muhi. 4lease tell m% "i#e sonal F
C Fthat ' love her a lot and "ill F
.#ield IJ04000002JI public int8 cc A b%tearra% 501 48 8 II .2

The last pro(ram on strin(s deals "ith the displa%in( strin(s that "e use to initiali&e a #ield "ith.
The Det>ield+onstant-alue*s;trin( method (ets called "ith the #ield ro" number and then the
o##set in the blob heap "here this strin( be(ins. The last parameter is len(th o# the strin( "ritten
out so #ar. !e as be#ore pic up the count and ho"man%b%tes and call the 's0ae*rra% #unction.

'# it returns true "e simpl% call the =ispla%>ormatted+olumns methods. '# it is #alse$ "e call the
=ispla%;trin(0ethod "ith the last parameter bein( true si(ni#%in( a #ield and the second last
parameter the #ield ro" o# the #ield that has the constant value. 'n the =ispla%;trin(0ethod "e
chec i# the variable #ield is true and i# %es "e no" need to calculate the value o# the secondline
variable.

This value is decided b% the len(th o# the attributes describin( the #ield$ the return value and also
the name o# the #ield. To all these len(th "e add a constant 74. !e should have actuall% also
checed #or a namespace and #or nested classes but le#t that as an exercise #or the reader.

*s three in the mornin($ %ou can (o #ar and no #urther. Thus the onl% di##erence in the last t"o
pro(rams is calculatin( the len(th o# characters on the second line and also the strin(s are stored
in di##erent places.

:xception 2andlin(

public void =ispla%'nitial0ethod2eader 5int methodindex8
9
int tin% A mbinar%reader.,eadO%te58<
i# 5 5tin% G 0x038 AA 0x038
tin%#ormat A #alse<
else
tin%#ormat A true<
m#ilestream.;ee5P1$;ee/ri(in.+urrent8<
strin( methodstrin( A FF<
i# 5 Etin%#ormat 8
244260235.doc 385 od 541
9
lon( "here A m#ilestream.4osition<
short #irst A mbinar%reader.,ead'nt1658<
#irst12 A 5short85#irst G 0x0###8<
short #irst4 A 5short85#irst G 0x#0008<
#irst4 A 5short8 5#irst4 HH 128<
short stacsi&e A mbinar%reader.,ead'nt1658<
codesi&e A mbinar%reader.,ead'nt3258<
methodstrin( A FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII +ode si&e F C
codesi&e.To;trin(58 C F 50xF C codesi&e.To;trin(5FxF8 C F8UrUnF<
i# 5 5#irst12G0x088 AA 0x08 8
,ead:xceptions5"here $ codesi&e $ methodindex 8<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2C spaces#ornested8 C F.maxstac F
C stacsi&e.To;trin(58<
int standalonesi( A mbinar%reader.,ead'nt3258<
int ro"standalonesi( A standalonesi( G 0x00######<
@
public void ,ead:xceptions 5lon( pos$ int codesi&e $ int methodindex 8
9
int aa A P1<
lon( "here A m#ilestream.4osition<
lon( pos1 A pos C codesi&e C 12 <
lon( extra A 0 <
extra A pos1 a 4 <
i# 5 extra EA 0 8
extra A 4 P extra <
lon( ne"pos A pos1 C extra<
m#ilestream.4osition A ne"pos<
int #irst A mbinar%reader.,eadO%te58<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F...........>la(A90@F $ #irst.To;trin(5FKF88<
i# 5 5#irst G 0x408 EA 0x408
9
int second A mbinar%reader.,eadO%te58<
mbinar%reader.,ead'nt1658<
int cnt A 5second P 4 8 I 12<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F................countA90@F $ cnt8<
:xception;truct A ne" :xceptionTable6cnt7<
#or 5 int 11 A 0 < 11 B cnt < 11CC 8
9
:xception;truct6117.#la(s A mbinar%reader.,ead'nt1658<
:xception;truct6117.tr%o##set A mbinar%reader.,ead'nt1658<
:xception;truct6117.tr%len(th A mbinar%reader.,eadO%te58<
:xception;truct6117.handlero##set A mbinar%reader.,ead'nt1658<
:xception;truct6117.handlerlen(th A mbinar%reader.,eadO%te58<
:xception;truct6117.toen A mbinar%reader.,ead'nt3258<
:xception;truct6117.oneline A0<
@
i# 5 methodindex AA aa8
+onsole.!rite3ine5F...........'# /verF 8<
244260235.doc 386 od 541
@
else
9
i# 5 methodindex AA aa8
+onsole.!rite3ine5F............in elseF8<
int a1 A mbinar%reader.,eadO%te58<
int a2 A mbinar%reader.,eadO%te58<
int a3 A mbinar%reader.,eadO%te58<
int second A a1 C a2 J 256 C a3 J 65536<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F............a1A90@ a2A91@ a3A92@ secondA93@F $ a1 $ a2 $ a3 $ second8<
int cnt<
i# 5 second AA 248
cnt A 1<
else i# 5 second AA 488
cnt A 2<
else
cnt A 5second P 4 8 I 24<
:xception;truct A ne" :xceptionTable6cnt7<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F................countA90@F $ cnt8<
#or 5 int 11 A 0 < 11 B cnt < 11CC 8
9
:xception;truct6117.#la(s A mbinar%reader.,ead'nt3258<
:xception;truct6117.tr%o##set A mbinar%reader.,ead'nt3258<
:xception;truct6117.tr%len(th A mbinar%reader.,ead'nt3258<
:xception;truct6117.handlero##set A mbinar%reader.,ead'nt3258<
:xception;truct6117.handlerlen(th A mbinar%reader.,ead'nt3258<
:xception;truct6117.toen A mbinar%reader.,ead'nt3258<
:xception;truct6117.oneline A0<
@
@
m#ilestream.4osition A "here<
@

public void =ispla%0ethod'3+ode 5 strin( classname $ strin( methodname $int methodindex 8
9
b%te 67 codearra% A ne" b%te6codesi&e7<
#or 5 int i A 1 < i BA codesi&e < iCC8
9
codearra%6iP17 A mbinar%reader.,eadO%te58<
@
spaces#ortr% A 0<
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
+reate:xception*rra% 5methodindex $ codearra% 8<
#or 5 int arra%o##set A 0 < arra%o##set B codesi&e < 8
9
int instructionb%te A codearra%6arra%o##set 7<
/p+ode opcode<
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
=ispla%:xceptions 5arra%o##set $ codearra% 8<
244260235.doc 387 od 541
strin( strin(s A FF<
int t"ob%te A 0<
i# 5 instructionb%te AA 0x>:8
9
instructionb%te A codearra%6arra%o##set C17<
opcode A /p+odes*rra%16instructionb%te7 <
strin(s A +reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested8<
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FKF8 C F
T F<
II+onsole.!rite5strin(s8<
arra%o##set A arra%o##set C 1<
t"ob%te A 1<
@
else
9
opcode A /p+odes*rra%6instructionb%te7<
strin(s A +reate;paces5spaces#orrestC2Cspaces#ortr% C spaces#ornested8<
t"ob%te A 0<
i# 5 E 5opcode.-alue AA 0 GG opcode.)ame EA FnopF88
9
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FK2F8 C
F T F<
II+onsole.!rite5strin(s8<
@
@
i# 5 opcode.-alue AA 0 GG opcode.)ame EA FnopF8
9
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C instructionb%te.To;trin(5FK2F8
C F T F<
strin(s A strin(s C +reate;paces5178 C FJI unusedF <
+onsole.!rite3ine5F90@F$ strin(s 8<
arra%o##set A arra%o##set C 1<
@
else
9
int si&eo#instructionanddata A =ecode'3'nstrcution25 opcode $ arra%o##set $ codearra% $
methodindex $ strin(s 8<
+onsole.!rite3ine58<
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
=ispla%:xceptions15arra%o##set $ codearra% $ t"ob%te8<
arra%o##set A arra%o##set C si&eo#instructionanddata<
@
@
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
9
i# 5 :xception;truct607.oneline AA 28
9
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested C 2 88<
+onsole.!rite3ine5F'3R90Mx4@M F $ codearra%.3en(th8<
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested C 2 88<
+onsole.!rite3ine5FII :xception count 1F8<
244260235.doc 388 od 541
=ispla%/ne3ineTr%508<
@
@
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@F8<
i# 5 DetT%pe>or0ethod5methodindex8AA 18
+onsole.!rite3ine5F II end o# (lobal method 90@UrUnF $ methodname8<
else
+onsole.!rite3ine5F II end o# method 90@MM91@UrUnF $ classname $ methodname8<
@

public void +reate:xception*rra%5int methodindex $ b%te 67 codearra%8
9
i# 5:xception;truct AA null8
return<
i# 5 :xception;truct607.handlero##set C :xception;truct607.handlerlen(th AA codearra%.3en(th
GG :xception;truct.3en(th AA 18
:xception;truct607.oneline A 2<
i# 5 :xception;truct607.tr%o##set C :xception;truct607.tr%len(th EA
:xception;truct607.handlero##set GG :xception;truct.3en(th AA 18
:xception;truct607.oneline A 1<
i# 5 :xception;truct.3en(th AA 28
9
bool a A :xception;truct607.tr%o##set C :xception;truct607.tr%len(th EA
:xception;truct607.handlero##set<
bool b A :xception;truct617.tr%o##set C :xception;truct617.tr%len(th EA
:xception;truct617.handlero##set<
i# 5 a GG b8
9
:xception;truct607.oneline A 1<
:xception;truct617.oneline A 1<
@
@
i# 5 :xception;truct.3en(th AA 28
9
bool a A :xception;truct607.tr%o##set C :xception;truct607.tr%len(th EA
:xception;truct607.handlero##set<
bool b A :xception;truct617.tr%o##set C :xception;truct617.tr%len(th AA
:xception;truct617.handlero##set<
i# 5 a GG b8
9
:xception;truct607.oneline A 1<
:xception;truct617.oneline A 0<
@
@
i# 5 :xception;truct.3en(th AA 28
9
i# 5 :xception;truct607.tr%o##set AA :xception;truct617.tr%o##set GG
:xception;truct607.tr%len(th AA :xception;truct617.tr%len(th GG
:xception;truct617.handlero##set C :xception;truct617.handlerlen(th AA codearra%.3en(th P1 GG
:xception;truct607.handlerlen(th AA 18
244260235.doc 389 od 541
i# 5 :xception;truct607.handlero##set C :xception;truct607.handlerlen(th EA
:xception;truct617.handlero##set8
:xception;truct617.oneline A 1<
@
i# 5 :xception;truct.3en(th AA 3 GG :xception;truct607.tr%o##set AA
:xception;truct617.tr%o##set GG :xception;truct607.tr%o##set H :xception;truct627.tr%o##set GG
:xception;truct607.#la(s AA :xception;truct617.#la(s GG :xception;truct627.#la(s AA
:xception;truct617.#la(s GG :xception;truct617.#la(sAA 28
9
:xceptionTable a A :xception;truct607<
:xception;truct607 A :xception;truct627<
:xception;truct627 A a<
@
#or 5 int ii A 0 < ii B :xception;truct.3en(th P 1 < iiCC8
9
int secondtr% A :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th<
int thirdtr% A :xception;truct6iiC17.tr%o##set C :xception;truct6iiC17.tr%len(th<
i# 5 :xception;truct6ii7.tr%o##set H :xception;truct6iiC17.tr%o##set GG secondtr% H thirdtr%8
9
:xceptionTable a A :xception;truct6ii7<
:xception;truct6ii7 A :xception;truct6iiC17<
:xception;truct6iiC17 A a<
@
@

i# 5 methodindex AA P18
9
#or 5int ii A 0 < ii B :xception;truct.3en(th < iiCC8
9
+onsole.!rite3ine5F >la(s 90@ F $ :xception;truct6ii7.#la(s.To;trin(5FK8F88<
+onsole.!rite3ine5F Tr% /##set 90@ 0x91@F $ :xception;truct6ii7.tr%o##set $
:xception;truct6ii7.tr%o##set.To;trin(5FKF88<
+onsole.!rite3ine5F Tr% 3en(th 90@ 0x91@F $ :xception;truct6ii7.tr%len(th $
:xception;truct6ii7.tr%len(th.To;trin(5FKF88<
+onsole.!rite3ine5F 2andler /##set 90@ 0x91@F $ :xception;truct6ii7.handlero##set $
:xception;truct6ii7.handlero##set.To;trin(5FKF8 8<
+onsole.!rite3ine5F 2andler len(th 90@ 0x91@F $ :xception;truct6ii7.handlerlen(th $
:xception;truct6ii7.handlerlen(th.To;trin(5FKF88<
+onsole.!rite3ine5F Toen 90MK@F $ :xception;truct6ii7.toen $ :xception;truct6ii7.handlero##set
C :xception;truct6ii7.handlerlen(th8<
+onsole.!rite3ine5F:ndTr%A90MK@ :ndhandlerA91MK@ codearra%A92MK@ onelineA93@F $
:xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th$ :xception;truct6ii7.handlero##set C
:xception;truct6ii7.handlerlen(th $ codearra%.3en(th $ :xception;truct6ii7.oneline8<
+onsole.!rite3ine58<
@
@
@
public void =ispla%:xceptions 5int instructionnumber$ b%te 67 codearra% 8
9
int ii <
bool endtr% A #alse<
244260235.doc 390 od 541
#or 5 ii A 0 < ii B :xception;truct.3en(th < iiCC8
9
bool sho"tr% A true<
i# 5 ii HA 1 8 II to sho" a tr% or not
9
int #irst A :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th<
int second A :xception;truct6iiP17.tr%o##set C :xception;truct6iiP17.tr%len(th<
i# 5 #irst AA second GG :xception;truct6iiP17.oneline EA 18
sho"tr% A #alse<
else
sho"tr% A true<
@
i# 5 instructionnumber AA :xception;truct6ii7.tr%o##set GG sho"tr% GG
:xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F.tr%F8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr%C spaces#ornested88<
+onsole.!rite5F9UrUnF8<
spaces#ortr% A spaces#ortr% C 2<
@
i# 5 instructionnumber AA :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th GG Eendtr%
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F@ II end .tr%F8<
spaces#ortr% A spaces#ortr% P 2<
endtr%A true<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set GG :xception;truct6ii7.#la(s AA 0
GG :xception;truct6ii7.oneline AA 08
9
int toen A :xception;truct6ii7.toen<
int table A toen HH 24<
int tablero" A toen G 0x######<
strin( t%penameAFF<
i# 5 table AA 28
t%pename A t%pede#names6tablero"7<
i# 5 table AA 18
t%pename A t%pere#names6tablero"7<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5Fcatch 90@ F $ t%pename8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F9F8<
spaces#ortr% A spaces#ortr% C 2<
II+onsole.!rite3ine5F........90@ 91@F $ table$ tablero"8<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set GG :xception;truct6ii7.#la(s AA 2
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
244260235.doc 391 od 541
+onsole.!rite3ine5F#inall%F8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F9F8<
spaces#ortr% A spaces#ortr% C 2<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set GG :xception;truct6ii7.#la(s AA 4
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F#aultF8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F9F8<
spaces#ortr% A spaces#ortr% C 2<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set C :xception;truct6ii7.handlerlen(th
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F@ II end handlerF8<
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested88<
+onsole.!rite5=ispla%:xceptionO%tes5ii88<
spaces#ortr% A spaces#ortr% P 2<
@
@
@
public strin( =ispla%:xceptionO%tes5int i8
9
strin( ss A FII 2:KM F <
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.#la(s8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.tr%o##set8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.tr%len(th8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.handlero##set8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.handlerlen(th8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.toen8<
ss A ss.,emove5ss.3en(thP1$18<
return ss C FUrUnF<
@
public strin( +onvert'nt32To;trin( 5int i8
9
strin( ss A FF<
int b1 A i G 0x##<
int b2 A 5i G 0x##00 8 HH 8<
int b3 A 5i G 0x##0000 8 HH 16<
int b4 A i HH 24<
i# 5 b4 AA P18
b4 A 0x##<
ss A b1.To;trin(5FK2F8 C F F C b2.To;trin(5FK2F8 C F F C b3.To;trin(5FK2F8 C F F C
b4.To;trin(5FK2F8 C F F <
return ss<
@
public void =ispla%:xceptions1 5int instructionnumber $ b%te 67 codearra%$ int t"ob%te 8
244260235.doc 392 od 541
9
int ii <
II+onsole.!rite3ine5F.......90MK@ 91MK@F $ instructionnumber $ codearra%6instructionnumber7 8<
#or 5 ii A 0 < ii B :xception;truct.3en(th < iiCC8
9
int tr%pos A :xception;truct6ii7.tr%o##setC :xception;truct6ii7.tr%len(th <
int handlerpos A :xception;truct6ii7.handlero##setC :xception;truct6ii7.handlerlen(th <
int o##set<
IIdivRi4.exe divRi8.exe
i# 5 tr%pos H handlerpos8
o##set A tr%pos<
else
o##set A handlerpos<
i# 5 instructionnumber AA o##set C t"ob%te GG :xception;truct6ii7.oneline AA 1 8
=ispla%/ne3ineTr%5ii8<
@
@
public void =ispla%/ne3ineTr% 5 int ii8
9
int toen A :xception;truct6ii7.toen<
int table A toen HH 24<
int tablero" A toen G 0x######<
strin( t%penameAFF<
i# 5 table AA 28
t%pename A t%pede#names6tablero"7<
i# 5 table AA 18
t%pename A t%pere#names6tablero"7<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite5F.tr% '3R90@ toF $ :xception;truct6ii7.tr%o##set.To;trin(5Fx4F88<
int end A :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th<
+onsole.!rite5F '3R90@ F $ end.To;trin(5Fx4F88<
i# 5 :xception;truct6ii7.#la(s AA 08
+onsole.!rite5Fcatch 90@ handler F $ t%pename8<
else i# 5 :xception;truct6ii7.#la(s AA 28
+onsole.!rite5F#inall% handler F 8<
else i# 5 :xception;truct6ii7.#la(s AA 48
+onsole.!rite5F#ault handler F 8<
else
+onsole.!rite5F#ilter '3R90@ handler F $ toen.To;trin(5Fx4F88<
+onsole.!rite5F'3R90@ toF$:xception;truct6ii7.handlero##set.To;trin(5Fx4F88<
int end1 A :xception;truct6ii7.handlero##set C :xception;truct6ii7.handlerlen(th<
+onsole.!rite3ine5F '3R90@F $ end1.To;trin(5Fx4F88<
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested C 288<
+onsole.!rite5=ispla%:xceptionO%tes5ii88<
:xception;truct6ii7.oneline A 0<
@

The last ma1or concept that "e have to deal "ith is the issue o# exceptions. !hen "e "rote
pro(rams earlier$ "e "ould call #unctions to do our 1ob. These #unctions normall% did not returns
ans"ers but told us "hether the #unction did its 1ob or there "as an error.

244260235.doc 393 od 541
'# the #unction returned &ero$ normall% that meant that thin(s "ere oa%$ an% other value meant an
error too place. =ependin( upon the error$ a di##erent number "as returned. The problem "ith
this approach "as that i# "e "ere openin( 10 #iles in our application callin( the #open #unction$
"e "ould have to repeat the error chec 10 times and thus "e "ould not even chec #or an error
once.

The other problem "as that "ith the advent o# constructors$ pro(rammers placed a lot o# code in
them and un#ortunatel% the% cannot return an% values. 'n toda%Qs da% and a(e$ methods do not
return error values but "e place all our code in a .tr% directive and catch it in a catch bloc.

Thus all code that "e "ant to chec #or errors no" thro" an exception that is cau(ht b% the catch
bloc. The #inall% bloc is "hat (ets executed at the end o# the tr%. Thus "hen "e "ant code to be
called a#ter the tr% (ets over$ "e place it in the #inall%. '# a method thro"s an exception$ no code
a#ter that in the tr% (ets called.

There are t"o other handler blocs called #ilter and #ault. The tin% #ormat does not support
exceptions and "e #irst need to read all the exceptions that are present #or each #unction. These
exceptions are not stored in tables but immediatel% a#ter the '3 code o# the method.

'n the method =ispla%'nitial0ethod2eader "e cal a #unction ,ead:xceptions onl% i# this method
has exceptions. !e #i(ure this out b% andin( the #irst 12 bits o# the #irst short o# the method
structure. '# this value is 8$ "e no" that this method has exceptions.

!e pass the method ,ead:xceptions the o##set in the #ile$ the si&e o# the code and the method
number. *s "e have read the #irst ei(ht b%tes o# the method structure$ "e mae sure that "e save
the #ile position in variable "here and set it bac to "here it "as as end o# the #unction
,ead:xceptions.

!e no" 1ump to the start o# "here the exceptions are stored on dis. !e (et this value b% addin(
the codesi&e to "here "e are in the method structure and then #urther addin( a value 12. The
exception structures be(in at a 4 b%te boundar% and thus "e add the necessar% paddin(. !e no"
read the #irst b%te o# the exception structure.

This value tells us "hich t%pe o# exception structure "e are dealin( "ith. There are t"o basic
t%pes that store the same basic in#ormation but di##er on the si&e o# the members. These t"o t%pes
are #at or small. '# the #irst b%te does not have a value o# 0x40 or the #i#th bit set$ it belon(s to the
small exception t%pe.

'n this case "e read the next b%te that (ives us the space occupied b% the exceptions that are
present. *s ever%thin( is ali(ned on a 4 b%te boundar%$ the next short is unused. :ach small
exception structure taes up 12 b%tes and the initial header is 4 b%tes. Thus "e subtract 4 #rom
this #irst b%te and "e (et a count o# the exceptions.

!e then read the exceptions that #ollo" in a arra% o# structures structure :xception;truct that "e
set to a si&e o# cnt. The #irst member o# this structure is #la(s that tells us "hether this exception
is a catch or #ault or #inall%. Then "e have the tr% o##set and the tr% len(th.

This is #ollo"ed b% the handler o##set and len(th and #inall% a toen. The oneline member is not
stored in the exception structures on dis and is our o"n creation that "e "ill come to later. The
exception structures are laid out as per the handlers. '# "e have a tr% "ith a catch and a #inall% "e
(et t"o exception structures "ith the same values #or the tr% o##set and len(th #ields.
244260235.doc 394 od 541

This also holds (ood i# "e have three catch handlers #or the same tr%$ "e (et three exception
structures. The #at exception structure starts "ith the #la(s b%te as be#ore and then three b%tes that
tell us the len(th o# the exception structures and not one lie be#ore.

!e thus have to do the multiplication ourselves to (et at the total si&e as three b%tes is no data
t%pe in an% lan(ua(e. !e then subtract 4 the paddin( #rom here and divide b% 24 as this is the si&e
o# the #at exception structure. The onl% problem is that i# it is a number divisible b% 24$ "e then
have no paddin( to subtract.

The onl% di##erence bet"een the #at and the small as mentioned earlier is the si&e o# the
structures. !e once a(ain read these structures into the same :xception arra% o# structures and set
the #ile pointer bac to "here its supposed to be. )o" "e move to the method
=ispla%0ethod'3+ode that displa%s ever% instruction.

Oe#ore "e start the displa% o# each line "e need to set ri(ht the :xception;truct. !e do this
callin( a method +reate:xception*rra% that "e pass t"o parameters$ the methodindex that "e
reall% do not use and the arra% that contains all our code$ codearra%.

't is this #unction that sets the :xception;truct arra% so that "e can displa% our exceptions. The
exception directive is normall% spread over multiple lines b% havin( the tr% and catch on separate
lines. Out at times it (ets displa%ed on one line.

Thus the oneline member is #irst al"a%s set to &ero and then i# it need to be displa%ed on one line$
"e set it to 1 or 2. !e #irst tae those special cases "here there is onl% one exception in our
method and thus onl% one exception structure.

* tr% can be #ollo"ed b% more than one handler but one o# them "ill have a handler o##set that is
e.ual to the tr%o##set plus the len(th. This is because the #irst handler has to #ollo" the #irst tr%. '#
this is not the case$ then the exception must be displa%ed on one line and "e set the oneline
member to 1.

The second case is "hen the handler o##set and handler len(th e.uals the len(th o# the code arra%$
in this case "e have one extra instruction o##set to displa% alon( "ith the tr% on one line.
)ormall% the handler o##set and len(th "ill be one less than the number o# lines in the codearra%
arra%.

Then i# "e have t"o exceptions and both in both o# them "e have the tr% len(th and o##set not
e.ual to the handler o##set$ "e have both exceptions on one line.

This is the same as the earlier one and "e could have placed them in a loop checin( that at least
one exception structure should have a tr% o##set and len(th e.ual to the handler o##set. '# not place
all o# them on one line.

Then "e have another variation. The #irst tr% and handler do not match$ but the second does. Thus
the #irst should be on one line and the second should not.

The #la(s #ield is 0 #or a catch$ 1 #or #ilter$ t"o #or #inall% and 4 #or a #ault. Then "e #ound one
special case "here the condition "as so compels that "e has to place it on t"o lines. This
condition applies to t"o exceptions onl% in a method and i# the condition matches$ "e place the
second exception on one line.
244260235.doc 395 od 541

The #irst is that the t"o tr% o##sets and len(ths must match "hich tells us that the t"o handlers are
associated "ith the same tr%. Then the second handler must be placed at the ver% end o# the
method and the #irst handlers len(th is 1.

*s the second handler does not start a#ter the #irst handler as the #irst handlers o##set and len(th is
not e.ual to the second handlers o##set "hich it should have been i# the% "ere part o# the same
tr%$ "e place the second tr% on a di##erent line. Then "e have one more special case.

'# "e have all three exceptions as a #inall% and the #irst tr% o##set is e.ual to the second tr% o##set
but (reater than the third tr% o##set$ then "e need to interchan(e the #irst and third :xception
structures.

!e do this b% savin( the #irst exception structure in a variable a and then e.uatin( the third "ith
the #irst and then the second to the variable a. Thus "e no" need to interchan(e :xception
structures. This is a special case and the next #or statement taes the same concept #urther.

!e scan the exception structures #rom the start to one less and store in t"o variables the start o#
the handler #or the current and next exception structures b% addin( the tr% o##set and len(th. !e
"ould lie the smallest handlers to come up in the exception structures.

Thus i# the tr%o##set o# the current exception structure is lar(er than the next and the position o#
the handler also is$ "e interchan(e the t"o exception structures. Thus (ets them in a order that
maes it easier #or us to displa%. )o" is the time to displa% the actual exceptions.

'# "e loo at the method =ispla%0ethod'3+ode at the ver% be(innin( be#ore "e displa% a line
"e #irst need to chec "hether "e need to displa% a tr% or an% one o# the handlers. !e as be#ore
chec that "e have exceptions or better still some extra method headers "hich toda% are onl%
exception headers and it is not the tin% #ormat "hich does not support exceptions.

'# all this is true$ "e use the method =ispla%:xceptions to "rite out the exception. This method is
passed the o##set o# the instruction stored in variable arra%o##set and the codearra%. This arra%
o##set variable is "hat "e sue to "rite out the '3R number that #ollo"s.

Thus this #unction is called each time be#ore "e print out an '3 instruction. '# "e have 10
instructions$ "e "ill call the #unction =ispla%:xceptions 10 times and chec i# one o# the #our
#ields o# the exception structure match the variable instructionnumber. This is "h% each time "e
scan all the entire exception arra%.

The #irst problem to resolve is that i# a tr% has t"o catches and one #inall%$ the tr%o##set #ield "ill
be the same #or the three structures and "e need to displa% the directive tr% onl% once. Thus the
#irst time "e displa% the tr% directive$ the second time on"ards #or the same tr%o##set "e do not
displa% it.

Thus "e start "ith main( the sho"tr% variable true and "hen "e come to the second exception
structure on"ards$ "e chec i# the current tr%o##set and tr%len(th are the same as the previous
one. '# it is so$ "e are dealin( "ith the same tr% and hence "e set the variable sho"tr% to #alse.

'# the% are di##erent it onl% means that "e are dealin( "ith a di##erent tr% and hence "e set
sho"tr% to #alse. *ll this assumes that "e not dealin( "ith a tr% that is displa%ed on one line. The
#irst i# statement displa%s #irst checs "hether "e need to displa% the .tr% or not.
244260235.doc 396 od 541

!e #irst chec that the parameter instructionnumber matches the tr%o##set variable and sho"tr%
has to be true "hich means that "e are not displa%in( the same tr% a(ain and the oneline must be
0 that si(ni#ies a multi line tr%. !e "rite out the spaces as be#ore and then the .tr% directive "ith
an enter.

!e then "rite out more spaces and a open bracet "ith an enter. !e no" increase the variable
spaces#ortr% b% 2 as the instructions #ollo"in( this tr% must be indented b% 2. !e no" need to
displa% the endtr% and the next i# statement taes care o# that.

!e #irst need to mae sure that tr%o##set and tr%len(th #ields e.ual the instructionnumber
parameter and also that the end tr% is bein( displa%ed onl% once. 2ere "e use the endtr% variable
"hich is set to #alse once and then a(ain set to true once "e have displa%ed the end tr% once.

2ere "e "rite out the spaces and the endtr% in comments and most important reduce the variable
spaces#ortr% b% 2 as the indentation #rom no" on must stop. !e no" "ould lie to displa% the
catch handler.

>or all handlers "e #irst chec that the handlero##set #ield is e.ual to the parameter
instructionnumber and the #la(s #ield is 0 #or a catch and the oneline #ield is &ero si(ni#%in( a
multi line tr%. The problem "ith the catch is that "e also have a t%pe re#erence to be displa%ed.

The toen #ield is made up o# a table code "hich occupies the topmost 8 bits and a ro" that
occupies the #irst 24 bits. '# the table code is 1$ it is a index into the T%pe,e# table and 2 a
T%pe=e# table. !e have the t%pede#names and t%pere#names arra% that (ive us the t%pe name.

!e "rite out the spaces and then the t%pename and then a enter and a open brace and "e also
increase the spaces#ortr% variable b% 2 as "e need to indent the comin( instructions. The next
handler is the #inall% and hence the i# statement remains the same exceptin( that the #la(s is 2.

>or a #inall% there is no t%pe name. =itto #or the #ault handler that has a #la(s value o# 4. >inall%
"e have the last i# statement that checs #or the handler end that remains the same #or all the three
handlers. !e do "hat "e did be#ore and decrease the spaces#ortr% b% 2 but no" need to "rite out
the b%tes o# the exception structure.

!e use a #unction =ispla%:xceptionO%tes that "rites out the exception structure. This is a simple
#unction as "e "rite out the "ords hex and no" "e need to convert ever% 32 bit #ield into 4
b%tes.

!e have a method +onvert'nt32To;trin( that taes an int32 and extracts the #our b%tes #rom it b%
masin( the relevant out the 24 bits and then ri(ht shi#tin( it. !e remove the last space and add a
enter and return this strin(.

!hen "e #inish displa%in( a instruction$ "e no" need to chec "hether "e need to displa% the
tr% directive on one line or not. The onl% di##erence is that the tr% on a line (ets displa%ed a#ter the
instruction (ets displa%ed not be#ore.

Thus the =ispla%:xceptions1 #unction (ets called a#ter "e have displa%ed the instruction. 'n this
#unction "e scan the entire exception arra% and #irst #i(ure out the tr% end and the handler end b%
addin( the o##set and the len(th.

244260235.doc 397 od 541
!e then set the o##set variable to the lar(er o# the t"o as the tr% directive on line "ill use this
variable to decide "here the displa% should start. The t"ob%te variable is &ero or one dependin(
upon "hether the opcode is a one or t"o b%te instruction. 't is 1 #or a t"o b%te instruction and
&ero #or a one b%te instruction.

The main code is in the #unction =ispla%/ne3ineTr% and here is "here "e displa% the entire tr%
and the handler. !e start b% decodin( the toen and #i(urin( out the t%pe name. !e then "rite
out some spaces and the tr% directive and the tr%o##set alon( "ith the '3R pre#ix.

!e then "rite out the end o# the tr% and then dependin( upon the #la(s variable the respective
handlers. The catch handler needs the name o# the t%pes and the #ault and #inall% need no extra
stu##. The #ault handler displa%s the toen as is. !e then "rite out the handler end and displa% the
individual b%tes.

!e also set the oneline #ield to &ero so that "e do not displa% this tr% a(ain. Thus the
=ispla%:xception1 method handles the one line tr% onl%.

!hen "e leave the method$ "e need to mae one #inal chec. '# the oneline #ield has a value o# 2
and i# %es "e need to #irst "rite out the instruction number that is one lar(er than the codearra%
and then displa% the tr% on one line.
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
>inal pro(ram
usin( ;%stem<
usin( ;%stem.'/<
usin( ;%stem.,e#lection<
usin( ;%stem.,e#lection.:mit<
public struct >ield4trTable
9
public int index<
@
public struct 0ethod4trTable
9
public int index<
@
public struct :xceptionTable
9
public int tr%o##set<
public int #la(s<
public int tr%len(th<
public int handlero##set<
public int handlerlen(th<
public int toen<
public int oneline<
@
public struct :xportedT%peTable
9
public int #la(s <
public int t%pede#index <
public int name <
public int nspace <
public int coded <
244260235.doc 398 od 541
@
public struct )ested+lassTable
9
public int nestedclass<
public int enclosin(class<
@
public struct 0ethod'mpTable
9
public int classindex<
public int codedbod%<
public int codedde#<
@
public struct +lass3a%outTable
9
public short pacin(si&e <
public int classsi&e <
public int parent <
@
public struct 0ani#est,esourceTable
9
public int o##set<
public int #la(s<
public int name<
public int coded<
@
public struct 0odule,e#Table
9
public int name<
@
public struct >ileTable
9
public int #la(s<
public int name<
public int index<
@
public struct :ventTable
9
public short attr<
public int name<
public int coded<
@
public struct :vent0apTable
9
public int index<
public int eindex<
@
public struct 0ethod;emanticsTable
9
public short methodsemanticsattributes<
public int methodindex<
public int association<
244260235.doc 399 od 541
@
public struct 4ropert%0apTable
9
public int parent<
public int propert%list<
@
public struct 4ropert%Table
9
public int #la(s<
public int name<
public int t%pe<
@
public struct +onstantsTable
9
public short dt%pe<
public int parent<
public int value <
@
public struct >ield3a%outTable
9
public int o##set<
public int #ieldindex<
@
public struct >ield,-*Table
9
public int rva <
public int #ieldi<
@
public struct >ield0arshalTable
9
public int coded<
public int index<
@
public struct >ieldTable
9
public int #la(s<
public int name<
public int si(<
@
public struct 4aramTable
9
public short pattr<
public int se.uence<
public int name<
@
public struct T%pe;pecTable
9
public int si(nature<
@
public struct 0ember,e#Table
9
244260235.doc 400 od 541
public int clas<
public int name<
public int si(<
@
public struct ;tand*lone;i(Table
9
public int index<
@
public struct 'nter#ace'mplTable
9
public int classindex<
public int inter#aceindex<
@
public struct T%pe=e#Table
9
public int #la(s<
public int name<
public int nspace<
public int cindex<
public int #index<
public int mindex<
@
public struct +ustom*ttributeTable
9
public int parent<
public int t%pe<
public int value<
@
public struct *ssembl%,e#Table
9
public short ma1or$minor$build$revision<
public int #la(s <
public int publice% <
public int name <
public int culture <
public int hashvalue <
@
public struct *ssembl%Table
9
public int 2ash*l('d<
public int ma1or$ minor$build$revision <
public int #la(s <
public int publice% <
public int name <
public int culture <
@
public struct 0oduleTable
9
public int Deneration<
public int )ame<
public int 0vid<
244260235.doc 401 od 541
public int :nc'd<
public int :ncOase'd<
@
public struct T%pe,e#Table
9
public int resolutionscope<
public int name<
public int nspace<
@
public struct 0ethodTable
9
public int rva<
public int imp#la(s<
public int #la(s<
public int name<
public int si(nature<
public int param<
@
public struct =ecl;ecurit%Table
9
public int action<
public int coded<
public int bindex<
@
public struct 'mpl0apTable
9
public short attr<
public int cindex<
public int name<
public int scope<
@
public class &&&
9
public void =ispla%Tables>or=ebu((in(58
9
IJ
+onsole.!rite3ine5F;trin(s TableM90@F $ strin(s.3en(th8<
#or 5 int o A 0 < o B strin(s.3en(th < oCC8
9
i# 5 strin(s6o7 AA 08
9
+onsole.!rite3ine58<
+onsole.!rite5F90@MF $ oC18<
@
else
+onsole.!rite5F90@F $ 5char8strin(s6o78<
@
JI
IJ
+onsole.!rite3ine5F0odule TableM90@F $ 0odule;truct.3en(th8<
244260235.doc 402 od 541
+onsole.!rite3ine5F)ameA90@ 91@F$ Det;trin(50odule;truct617.)ame8 $
0odule;truct617.)ame.To;trin(5FKF88<
+onsole.!rite3ine5FDenerationA90@ 0vidA91@ :nc'dA92@ :ncOase'dA93@F $
0odule;truct617.Deneration $ 0odule;truct617.0vid $ 0odule;truct617.:nc'd $
0odule;truct617.:ncOase'd8<
JI
IJ
+onsole.!rite3ine5FT%pe,e# TableM90@F $ T%pe,e#;truct.3en(th 8<
#or 5 int o A 1 < o B T%pe,e#;truct.3en(th < oCC8
9
+onsole.!rite3ine5FT%pe 90@F$ o 8<
+onsole.!rite3ine5F,esolotion ;copeA90@ 91@F $
Det,esolution;copeTable5T%pe,e#;truct6o7.resolutionscope8$
Det,esolution;cope-alue5T%pe,e#;truct6o7.resolutionscope88<
+onsole.!rite3ine5F)ame;paceA90@ 91@F $ Det;trin(5T%pe,e#;truct6o7.nspace8 $
T%pe,e#;truct6o7.nspace.To;trin(5FKF88<
+onsole.!rite3ine5F)ameA90@ 91@F $ Det;trin(5T%pe,e#;truct6o7.name8$
T%pe,e#;truct6o7.name.To;trin(5FKF88<
@
JI
IJ
+onsole.!rite3ine5FT%pe=e# TableM90@F $ T%pe=e#;truct.3en(th 8<
#or 5 int o A 1 < o B T%pe=e#;truct.3en(th < oCC8
9
+onsole.!rite3ine5FT%pe 90@ F$ o8 <
+onsole.!rite3ine5F)ameA90@ 91@F $ Det;trin(5T%pe=e#;truct6o7.name8$
T%pe=e#;truct6o7.name.To;trin(5FKF88<
+onsole.!rite3ine5F)ame;paceA90@ 91@F $ Det;trin(5T%pe=e#;truct6o7.nspace8 $
T%pe=e#;truct6o7.nspace.To;trin(5FKF88<
+onsole.!rite3ine5F>ield690@7F$ T%pe=e#;truct6o7.#index8<
+onsole.!rite3ine5F0ethod690@7F$ T%pe=e#;truct6o7.mindex8<
@
JI
IJ
+onsole.!rite3ine5F+ustom*ttributeTableM90@F $ +ustom*ttribute;truct.3en(th 8<
#or 5 int o A 1 < o B +ustom*ttribute;truct.3en(th < oCC8
9
strin( tablenameA Det2as+ustom*ttributeTable5+ustom*ttribute;truct6o7.parent8 <
int index A Det2as+ustom*ttribute-alue5+ustom*ttribute;truct6o7.parent8<
strin( methodde#re# A Det+ustom*ttributeT%peTable5+ustom*ttribute;truct6o7.t%pe8<
int methodde#re#index A Det+ustom*ttributeT%pevalue5+ustom*ttribute;truct6o7.t%pe8<
+onsole.!rite3ine5F,o"A90@ 4arent tablenameA91@ indexA92@ methodde#re#A93@
methodde#re#indexA94@F $ o.To;trin(5FKF8 $ tablename $ index $ methodde#re# $
methodde#re#index8<
@
JI
IJ
+onsole.!rite3ine5F*ssembl%,e#TableM90@F $ *ssembl%,e#;truct.3en(th 8<
#or 5 int o A 1 < o B *ssembl%,e#;truct.3en(th < oCC8
9
@
244260235.doc 403 od 541
JI
@
bool 's0ae*rra%5b%te 67 strin(arra%8
9
int countascii A 0<
int index A 0<
bool maearra% A #alse<
"hile 5 index B strin(arra%.3en(th P 1 8
9
i# 5 strin(arra%6index7 HA 129 8
countasciiCC<
i# 5 strin(arra%6index7 BA 31 GG E5 strin(arra%6index7 AA 0x0d TT strin(arra%6index7 AA 0x0a TT
strin(arra%6index7 AA 0x09 88
countasciiCC<
i# 5 strin(arra%6indexC17 EA 0 8
countasciiCC<
index A index C 2<
@
i# 5 countascii HA 18
maearra% A true<
return maearra%<
@
public void Det>ield+onstant-alue*s;trin(5int tablero" $ int value $ int len8
9
strin( returnstrin( A F A F<
+onsole.!rite5returnstrin(8<
int ho"man%b%tesA0$uncompressedb%te $ count<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ value $ out uncompressedb%te8<
count A uncompressedb%te<
value A value C ho"man%b%tes<
b%te 67 strin(arra% A ne" b%te6count7<
*rra%.+op%5blob $ value $ strin(arra% $ 0 $ count8<
bool maearra% A 's0ae*rra%5strin(arra%8<
i# 5 maearra% GG count EA 08
9
+onsole.!rite5Fb%tearra% 5F8<
=ispla%>ormatted+olumns5valuePho"man%b%tes$ lenC14 $ #alse $ #alse8<
@
else
9
strin( str A FF<
str A Det)ameN5value P ho"man%b%tes$ true $ tablero"8<
returnstrin( A FUFF<
returnstrin( A returnstrin( C =ispla%;trin(0ethod5str$spaces#orrestC spaces#ortr% C
spaces#ornested $ tablero" $ true8<
returnstrin( A returnstrin( C FUFF<
+onsole.!rite3ine5returnstrin(8<
@
return <
@
public strin( =ispla%;trin(0ethod5strin( str$int spaces $ int tablero" $ bool #ield8
244260235.doc 404 od 541
9
bool not#irstline A #alse<
int len A str.3en(th <
int counto#chars A 0<
int totalcount A 0<
int b%tecount A 49<
strin( returnstrin( A FF<
int secondline A 101<
i# 5 #ield 8
9
strin( s A Det>ield*ttributes5tablero"8<
secondline A s.3en(th C #ieldparamarra%6tablero"7.3en(th C
)ame,eserved5Det;trin(5>ield;truct6tablero"7.name88.3en(th C 74<
@
#or 5 int ii A 0 < ii B len < iiCC8
9
i# 5 str6ii7 AA LUtL8
returnstrin( A returnstrin( C FUUtF <
else i# 5 str6ii7 AA LFL8
returnstrin( A returnstrin( C FUUUFF <
else i# 5 str6ii7 AA LUUL8
returnstrin( A returnstrin( C FUUUUF<
else i# 5 str6ii7 AA 138
returnstrin( A returnstrin( C FUUrF<
else i# 5 str6ii7 AA 108
returnstrin( A returnstrin( C FUUnF<
else i# 5 str6ii7 AA LbL8
returnstrin( A returnstrin( C FUUbF<
else
returnstrin( A returnstrin( C str6ii7<
i# 5 str.3en(th HA 50 GG str6497 AA LUUL8
b%tecount A 48<
i# 5 counto#chars AA b%tecount GG Enot#irstline GG E5 len AA 50 TT len AA 51 TT len AA 528 8
9
returnstrin( A returnstrin( C FUFUrUnF C +reate;paces5spaces8 C FC UFF <
not#irstline A true<
counto#chars A 0<
@
else i# 5 not#irstline GG 5counto#chars a secondline8 AA 0 8
9
int charsle#t A len P totalcount <
i# 5 charsle#t HA 48
returnstrin( A returnstrin( C FUFUrUnF C +reate;paces5spaces8 C FC UFF <
counto#chars A 0<
@
totalcountCC<
counto#charsCC<
@
return returnstrin(<
@
public strin( Det)ameN5int startin( $ bool blobtable $ int tablero"8
244260235.doc 405 od 541
9
int ho"man%b%tes $ uncompressedb%te<
i# 5 blobtable 8
ho"man%b%tes A +or;i(Nncompress=ata5blob $ startin( $ out uncompressedb%te8<
else
ho"man%b%tes A +or;i(Nncompress=ata5us $ startin( $ out uncompressedb%te8<
int len A uncompressedb%te<
;%stem.Text.:ncodin( e A ;%stem.Text.:ncodin(.Nnicode<
strin( returnstrin( <
i# 5 blobtable 8
returnstrin( A e.Det;trin(5blob$ startin( C ho"man%b%tes $ len8<
else
returnstrin( A e.Det;trin(5us$ startin( C ho"man%b%tes $ len8<
return returnstrin(<
@

public void =ispla%,85double toen $ b%te 67 codearra% $ int codeindex8
9
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
b%te b5 A codearra%6codeindexC57<
b%te b6 A codearra%6codeindexC67<
b%te b7 A codearra%6codeindexC77<
b%te b8 A codearra%6codeindexC87<
strin( doubles A toen.To;trin(58<
int pos A doubles.'ndex/#5F:PF8<
int d2 A 0<
i# 5 pos EA P18
9
strin( d1 A doubles.;ubstrin(5posC28<
d2 A +onvert.To'nt325d18<
@
II+onsole.!rite3ine5F.......90@ 91@F $ doubles $ toen8<
i# 5 doubles.'ndex/#5F'n#init%F8 EA P1 TT doubles.'ndex/#5F)a)F8 EA P1 TT d2 HA 3088
+onsole.!rite5F590@ 91@ 92@ 93@ 94@ 95@ 96@
97@8F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F8$b5.To;trin(5F
K2F8$b6.To;trin(5FK2F8$b7.To;trin(5FK2F8$b8.To;trin(5FK2F8 8<
else i# 5 toen AA 0 GG b8 AA 0x808
+onsole.!rite5FP0.0F 8<
else i# 5 toen AA 0 GG b8 AA 0x008
+onsole.!rite5F0.0F 8<
else
9
sss s1 A ne" sss58<
strin( ss A s1.,eturn;trin(>or,85toen $ 08<
+onsole.!rite5ss8<
@
@
public void Det>ield+onstant-alue 5int constantro" $ int len 8
244260235.doc 406 od 541
9
int ii<
i# 5 +onstants;truct AA null 8
9
+onsole.!rite3ine58<
return <
@
#or 5 ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
int tablet%pe A +onstants;truct6ii7.parent G 0x03<
i# 5 tablet%pe AA 08
9
int constantro"coded A +onstants;truct6ii7.parent HH 2<
i# 5 constantro"coded AA constantro"8
brea<
@
@
i# 5 ii EA +onstants;truct.3en(th 8
9
i# 5 +onstants;truct6ii7.dt%pe AA 148
Det>ield+onstant-alue*s;trin(5constantro" $ +onstants;truct6ii7.value $ len8<
else
9
strin( ss A =ispla%>rom+onstantsTable5constantro"$0 $F>ield=e#F8<
+onsole.!rite5ss8<
@
@
else
+onsole.!rite3ine58<
@
public strin( =ispla%>rom+onstantsTable5int start $ int end $strin( tablename 8
9
strin( returnstrin( A FF<
i# 5 +onstants;truct AA null8
return FF<
#or 5 int ii A 1 < ii B +onstants;truct.3en(th < iiCC8
9
strin( consttablename A Det2as+onstTable5+onstants;truct6ii7.parent8<
int constindex A Det2as+onst-alue5+onstants;truct6ii7.parent8<
i# 5 consttablename AA tablename 8
9
i# 5 start AA constindex 8
9
i# 5 consttablename AA F4ropert%F TT consttablename AA F>ield=e#F8
returnstrin( A F A F<
else
returnstrin( A F A F<
int value A +onstants;truct6ii7.value<
i# 5 +onstants;truct6ii7.dt%pe AA 2 8
9
bool val A Oit+onverter.ToOoolean5blob $ +onstants;truct6ii7.valueC18<
244260235.doc 407 od 541
i# 5 val 8
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5true8F C FUrUnF<
else
returnstrin( A returnstrin( C DetT%pe5+onstants;truct6ii7.dt%pe8 C F5#alse8FC FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x03 8
9
returnstrin( A returnstrin( C Fchar50xF <
short val A Oit+onverter.To'nt165blob $ valueC18<
returnstrin( A returnstrin( C val.To;trin(5FK4F8<
returnstrin( A returnstrin( C F8UrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x04 TT +onstants;truct6ii7.dt%pe AA 0x058
9
int val A blob6+onstants;truct6ii7.valueC17<
returnstrin( A returnstrin( C DetT%pe50x048 C F50xF C val.To;trin(5FK2F8 C F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x06 TT +onstants;truct6ii7.dt%pe AA 0x07 8
9
short val A Oit+onverter.To'nt165blob $ +onstants;truct6ii7.valueC18<
IIi# 5 val AA P18
IIreturnstrin( A returnstrin( C DetT%pe50x068 C F50x>>>>8F C FUrUnF<
IIelse
returnstrin( A returnstrin( C DetT%pe50x068 C F50xF C val.To;trin(5FK4F8 C F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x08 TT +onstants;truct6ii7.dt%pe AA 0x09 8
9
int val A Oit+onverter.To'nt325blob $ +onstants;truct6ii7.valueC18<
returnstrin( A returnstrin( C DetT%pe50x088 C F50xF C val.To;trin(5FK8F8 C F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x0a TT +onstants;truct6ii7.dt%pe AA 0x0b 8
9
lon( val A Oit+onverter.To'nt645blob $ +onstants;truct6ii7.valueC18<
returnstrin( A returnstrin( C DetT%pe50x0a8 C F50xF C val.To;trin(5FKF8 C F8F C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 12 8
9
returnstrin( A returnstrin( C F#loat325F <
;in(le sin(levalue A Oit+onverter.To;in(le5blob$ valueC18<
int val A Oit+onverter.To'nt325blob $ valueC18<
strin( s A sin(levalue.To;trin(58<
int decimalpoint A s.'ndex/#5F.F8<
i# 5 sin(levalue AA 1.5eC0098
returnstrin( A returnstrin( C F1.5eC009F <
else i# 5 decimalpoint AA P1 GG E5s.'ndex/#5F'n#init%F8 EA P1 TT s.'ndex/#5F)a)F8 EA P188
returnstrin( A returnstrin( C s C F.F <
else
returnstrin( A returnstrin( C F0xF C val.To;trin(5FK8F8<
returnstrin( A returnstrin( C F8UrUnF<
II+onsole.!rite3ine5returnstrin(8<
@
244260235.doc 408 od 541
i# 5 +onstants;truct6ii7.dt%pe AA 138
9
returnstrin( A returnstrin( C F#loat645F <
=ouble val A Oit+onverter.To=ouble5blob $ valueC18<
IIint dumm% A Oit+onverter.To'nt325blob $ valueC18<
sss s1 A ne" sss58<
strin( ss A s1.,eturn;trin(>or,85val $ 18<
returnstrin( A returnstrin( C ss C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0xe 8
9
int len A blob6+onstants;truct6ii7.value7 <
i# 5 len HA 18
9
returnstrin( A returnstrin( C FUFF<
#or 5 int 11 A 1 < 11 B len < 11CC8
9
i# 5 blob6+onstants;truct6ii7.valueC117 EA 08
returnstrin( A returnstrin( C 5char8blob6+onstants;truct6ii7.valueC117<
@
returnstrin( A returnstrin( C FUFUrUnF <
@
else
returnstrin( A returnstrin( C FUFUFF C FUrUnF<
@
i# 5 +onstants;truct6ii7.dt%pe AA 0x12 8
9
returnstrin( A returnstrin( C Fnullre#F C FUrUnF<
@
@
@
@
return returnstrin(<
@
public int =ecode'3'nstrcution2 5/p+ode opcode $ int codeindex $ b%te 67 codearra% $ int
methodindex $ strin( strin(s 8
9
int si&eo#instructiondata A 0<
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nline,8
9
+onsole.!rite5strin(s8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
IIint int32value A Oit+onverter.To'nt325codearra%$ codeindexC18<
;in(le sin(levalue A Oit+onverter.To;in(le5codearra%$ codeindexC18<
strin( s A sin(levalue.To;trin(58<
+onsole.!rite5F90@91@92@
93@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5888<
244260235.doc 409 od 541
+onsole.!rite5F JI 90@ 91@ F$ opcode.)ame $ +reate;paces538 8<
i# 5 sin(levalue AA 0.0156258
+onsole.!rite5F1.5625eP002F8<
else i# 5 sin(levalue AA 1.5eC0098
+onsole.!rite5F1.5eC009F8<
else i# 5 sin(levalue AA 1.5eC0088
+onsole.!rite5F1.5eC008F8<
else i# 5 sin(levalue AA 0 GG b4 AA 0x808
+onsole.!rite5FP0.0F 8<
else i# 5 sin(levalue AA 08
+onsole.!rite5F0.0F 8<
else i# 5 s.:nds!ith5F.5F8 TT s.:nds!ith5F.25F8 TT s.:nds!ith5F.75F8 TT s.:nds!ith5F0625F8 TT
s.:nds!ith5F125F8TT s.:nds!ith5F.375F8 8
+onsole.!rite5s8<
else
9
II+onsole.!rite3ine5F.......*F8<
sss s4 A ne" sss58<
strin( ss A s4.,eturn;trin(>or,45sin(levalue 8<
i# 5 ss AA FF8
+onsole.!rite5F590@ 91@ 92@ 93@8F $ b1.To;trin(5FK2F8$ b2.To;trin(5FK2F8$ b3.To;trin(5FK2F8$
b4.To;trin(5FK2F88<
else
+onsole.!rite5ss8<
@
si&eo#instructiondata A 5<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline,8
9
+onsole.!rite5strin(s8<
double toen A Oit+onverter.To=ouble5 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
b%te b5 A codearra%6codeindexC57<
b%te b6 A codearra%6codeindexC67<
b%te b7 A codearra%6codeindexC77<
b%te b8 A codearra%6codeindexC87<
+onsole.!rite5F90@91@92@93@94@95@96@
97@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F8$b5.To;trin(5FK
2F8$b6.To;trin(5FK2F8$b7.To;trin(5FK2F8$b8.To;trin(5FK2F8 8<
+onsole.!rite5F JI 90@ 91@ F$ opcode.)ame $ +reate;paces5388<
=ispla%,85toen$codearra% $ codeindex8<
si&eo#instructiondata A 9<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline;trin(8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
toen A toen G 0x00######<
244260235.doc 410 od 541
int ho"man%b%tes$ uncompressedb%te5<
ho"man%b%tesA +or;i(Nncompress=ata5us $ toen $ out uncompressedb%te58<
int count A uncompressedb%te5<
IIint count A uncompressedb%te5 P 1<
b%te 67 strin(arra% A ne" b%te6count7<
int startin(pt A toen C ho"man%b%tes<
*rra%.+op%5us $ startin(pt$ strin(arra% $ 0 $ count8<
bool maearra% A 's0ae*rra%5strin(arra%8<
i# 5 maearra% GG count EA 08
9
+onsole.!rite5F570890@ JI 91@ F $ toen.To;trin(5FK6F8 $ opcode.)ame8<
+onsole.!rite5Fb%tearra% 5F8<
=ispla%>ormatted+olumns5toen$ 62 C 5spaces#orrestC2C spaces#ortr% C spaces#ornested8 $ #alse $
true8<
@
else
9
strin( str A Det)ameN5toen $ #alse $ 08<
+onsole.!rite5F570890@ JI 91@ F $ toen.To;trin(5FK6F8 $ opcode.)ame8<
+onsole.!rite5FUFF8<
strin( returnstrin(<
returnstrin( A =ispla%;trin(0ethod5str$spaces#orrestC2C spaces#ortr% C spaces#ornested $ 0 $
#alse8<
+onsole.!rite5returnstrin(8<
+onsole.!rite5FUF IJ 7090@ JIF $ toen.To;trin(5FK6F88<
@
si&eo#instructiondata A 5<
@
i# 5 codearra%.3en(th P 1 AA codeindex GG opcode./perandT%pe AA /perandT%pe.'nline0ethod8
9
+onsole.!rite5strin(s8<
+onsole.!rite5F500802301O JI call 0x2301b F8<
return 1<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline)one8
9
+onsole.!rite5strin(s8<
+onsole.!rite5F90@JI 91@F$+reate;paces5178 $ opcode.)ame8<
i# 5 opcode.)ame AA FretF GG codeindex EA 5codearra%.3en(th P18 8
+onsole.!rite3ine58<
i# 5 opcode.)ame AA Fthro"F GG codeindex EA 5codearra%.3en(th P18 8
+onsole.!rite3ine58<
si&eo#instructiondataA1<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline'8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
244260235.doc 411 od 541
b%te b4 A codearra%6codeindexC47<
+onsole.!rite5F90@91@92@
93@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5888<
+onsole.!rite5F JI 90@ 91@ 0x92@F$ opcode.)ame $ +reate;paces538 $ toen.To;trin(5FxF88<
si&eo#instructiondata A 5<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline'88
9
+onsole.!rite5strin(s8<
lon( toen A Oit+onverter.To'nt645 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
b%te b5 A codearra%6codeindexC57<
b%te b6 A codearra%6codeindexC67<
b%te b7 A codearra%6codeindexC77<
b%te b8 A codearra%6codeindexC87<
+onsole.!rite5F90@91@92@93@94@95@96@
97@F$b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F8$b5.To;trin(5FK
2F8$b6.To;trin(5FK2F8$b7.To;trin(5FK2F8$b8.To;trin(5FK2F8 8<
+onsole.!rite5F JI 90@ 91@ 0x92@F$ opcode.)ame $ +reate;paces538 $ toen.To;trin(5FxF88<
si&eo#instructiondata A 9<
@
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nline'8
9
+onsole.!rite5strin(s8<
int toen A codearra%6codeindexC17<
+onsole.!rite5F90@F$toen.To;trin(5FK2F88<
+onsole.!rite5+reate;paces51488<
i# 5 toen HA 1288
toen A toen P 256<
i# 5 opcode.)ame AA Funali(ned.F 8
+onsole.!rite5F JI 90@ 91@F$ opcode.)ame $ toen.To;trin(588<
else
+onsole.!rite5F JI 90@ 91@F$ opcode.)ame $ toen.To;trin(588<
si&eo#instructiondata A 2<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nlineOrTar(et8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 18<
strin( returnstrin( A FF<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
+onsole.!rite5F90@91@92@93@F $
b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces598 C FJI F8<
244260235.doc 412 od 541
toen A toen C codeindex C 5<
int len A opcode.)ame.3en(th<
returnstrin( A opcode.)ame C F F C +reate;paces59 P len8 C F '3RF C toen.To;trin(5Fx4F8<
+onsole.!rite5returnstrin(8<
i# 5 E 5codearra%.3en(th AA codeindex C 5 88
+onsole.!rite3ine58<
si&eo#instructiondata A 5<
@
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nlineOrTar(et8
9
+onsole.!rite5strin(s8<
int toen A codearra%6codeindex C 17<
strin( returnstrin( A FF<
+onsole.!rite5F90@F $ toen.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5158 C FJI F8<
i# 5 toen HA 1288
9
toen A 0x## P toen <
toen A codeindex C 1 P toen<
@
else
toen A toen C codeindex C 2<
int len A opcode.)ame.3en(th<
returnstrin( A opcode.)ame C F F C +reate;paces59 P len8 C F '3RF C toen.To;trin(5Fx4F8<
+onsole.!rite5returnstrin(8<
i# 5 E 5codearra%.3en(th AA codeindex C 2 88
+onsole.!rite3ine58<
si&eo#instructiondata A 2<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline;"itch8
9
+onsole.!rite5strin(s8<
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
b%te b3 A codearra%6codeindexC37<
b%te b4 A codearra%6codeindexC47<
+onsole.!rite5F90@91@92@93@F $
b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
+onsole.!rite5+reate;paces59 88<
+onsole.!rite5FJI s"itch 5 F8<
i# 5 toen AA 08
+onsole.!rite5F8F8<
else
#or 5 int ii A 1 < ii BA toen < iiCC8
9
+onsole.!rite5FUrUnF C +reate;paces5spaces#orrestC2 C spaces#ortr% C spaces#ornested88<
+onsole.!rite5+reate;paces510 8 C FIJ T F8<
int index A Oit+onverter.To'nt325 codearra% $ codeindex C 1 C iiJ48<
b1 A codearra%6codeindexC1 C iiJ47<
b2 A codearra%6codeindexC2 C iiJ47<
244260235.doc 413 od 541
b3 A codearra%6codeindexC3 C iiJ47<
b4 A codearra%6codeindexC4 C iiJ47<
+onsole.!rite5F90@91@92@93@F $
b1.To;trin(5FK2F8$b2.To;trin(5FK2F8$b3.To;trin(5FK2F8$b4.To;trin(5FK2F88<
int tot A codeindexCindexC1 C toenJ4 C 4<
+onsole.!rite5+reate;paces598 C FJIF C +reate;paces5138 C F'3R90@F $ tot.To;trin(5Fx4F88<
i# 5 ii EA toen8
+onsole.!rite5F$F8<
else
+onsole.!rite5F8F8<
@
si&eo#instructiondata A 5 C toenJ4<
@
i# 5 opcode./perandT%pe AA /perandT%pe.;hort'nline-ar8
9
+onsole.!rite5strin(s8<
int toen A codearra%6codeindexC17<
+onsole.!rite5F90@F $ toen.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5158 C FJI 90@F $ opcode.)ame8<
int len A opcode.)ame.3en(th<
i# 5opcode.)ame AA Fldar(.sF TT opcode.)ame AA Fldar(a.sF TT opcode.)ame AA Fstar(.sF8
9
strin( methodattribute#la(s A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $
methodindex8<
strin( sname A FF<
i# 5 toen H methodde#paramcount6methodindex7 GG methodattribute#la(s.'ndex/#5FstaticF8 EA
P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen H methodde#paramcount6methodindex7C1 GG
methodattribute#la(s.'ndex/#5FinstanceF8 EA P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen AA 0 GG methodattribute#la(s.'ndex/#5FinstanceF8 EA P1 8
sname A F0F<
else
9
i# 5 methodattribute#la(s.'ndex/#5FstaticF8 EA P18
toenCC<
sname A Det4aram)ame>or0ethod5 methodindex $ 0 $ toen8<
@
+onsole.!rite5F90@91@F $ +reate;paces511 P len8 $ sname8<
@
else
+onsole.!rite5F90@-R91@F $ +reate;paces511 P len8 $ toen8<
si&eo#instructiondata A 2<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline-ar8
9
+onsole.!rite5strin(s8<
ushort toen A 5ushort8Oit+onverter.To'nt165codearra% $ codeindex C 18<
244260235.doc 414 od 541
b%te b1 A codearra%6codeindexC17<
b%te b2 A codearra%6codeindexC27<
+onsole.!rite5F90@91@F $ b1.To;trin(5FK2F8$b2.To;trin(5FK2F88<
+onsole.!rite5+reate;paces5138 C FJI 90@F $ opcode.)ame8<
int len A opcode.)ame.3en(th<
i# 5opcode.)ame AA Fldar(F TT opcode.)ame AA Fldar(aF TT opcode.)ame AA Fstar(F8
9
strin( methodattribute#la(s A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $
methodindex8<
strin( sname A FF<
i# 5 toen H methodde#paramcount6methodindex7 GG methodattribute#la(s.'ndex/#5FstaticF8 EA
P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen H methodde#paramcount6methodindex7C1 GG
methodattribute#la(s.'ndex/#5FinstanceF8 EA P18
sname A toen.To;trin(58 C F II :,,/,M invalid ar( index 5HAFC
5methodde#paramcount6methodindex7C18.To;trin(58 C F8F<
else i# 5 toen AA 0 GG methodattribute#la(s.'ndex/#5FinstanceF8 EA P1 8
sname A F0F<
else
9
i# 5 methodattribute#la(s.'ndex/#5FstaticF8 EA P18
toenCC<
sname A Det4aram)ame>or0ethod5 methodindex $ 0 $ toen8<
@
+onsole.!rite5F90@91@F $ +reate;paces511 P len8 $ sname8<
@
else
+onsole.!rite5F90@-R91@F $ +reate;paces511 P len8 $ toen8<
si&eo#instructiondata A 3<
@
i# 5 opcode./perandT%pe AA /perandT%pe.'nline>ield TT opcode./perandT%pe AA
/perandT%pe.'nline0ethod TT opcode./perandT%pe AA /perandT%pe.'nlineT%pe TT
opcode./perandT%pe AA /perandT%pe.'nlineTo TT opcode./perandT%pe AA
/perandT%pe.'nline;i(8
9
int toen A Oit+onverter.To'nt325 codearra% $ codeindex C 1 8<
int seriouserror<
=ecodeToen'35toen $ opcode $ methodindex $ strin(s $ out seriouserror 8 <
int table A 5int85toen G 0x##0000008<
table A table HH 24<
toen A toen G 0x00######<
i# 5 table AA 0x0a8
9
bool b A 2as+ustom*ttribute5F0ember,e#F $ toen 8<
i# 5 b8
9
+onsole.!rite3ine58<
=ispla%+ustom*ttribute5F0ember,e#F $ toen$ 2 C spaces#orrest C spaces#ornested8<
@
244260235.doc 415 od 541
@
i# 5 seriouserror AA 18
si&eo#instructiondata A codearra%.3en(th C 1<
else
si&eo#instructiondata A 5<
@

return si&eo#instructiondata<
@
public void =ispla%+ustom*ttribute 5strin( tname $ int tabindex $ int noo#spaces8
9
i# 5+ustom*ttribute;truct AA null8
return<
#or 5 int ii A 1 < ii B +ustom*ttribute;truct.3en(th < iiCC8
9
strin( parentcodedtablenameA Det2as+ustom*ttributeTable5+ustom*ttribute;truct6ii7.parent8 <
int parentcodedindexA Det2as+ustom*ttribute-alue5+ustom*ttribute;truct6ii7.parent8<
strin( t%pecodetable A Det+ustom*ttributeT%peTable5+ustom*ttribute;truct6ii7.t%pe8 <
int t%pecodedindex A Det+ustom*ttributeT%pevalue5+ustom*ttribute;truct6ii7.t%pe8<
strin( initialspaces<
initialspaces A +reate;paces5noo#spaces8<
int tableindexcode A 0<
int tablenumber A 0<
strin( returnstrin( A FF<
bool custombu( A #alse<
int t%peindex <
strin( t%pename A FF<
strin( returnvaluestrin( A FF<
strin( paramstrin( A FF<
strin( dumm% A FF<
strin( methodname A FF<
strin( onespaceAFF<
i# 5 5tname AA parentcodedtablename GG tabindex AA parentcodedindex8 TT
5parentcodedtablename AA FT%pe,e#F GG tabindex AA 08 8
9
i# 5 t%pecodetable AA F0ethod,e#F 8
9
tableindexcode A 0x0*<
t%peindexA 0ember,e#;truct6t%pecodedindex7.clas HH 3<
t%pename A t%pere#names6t%peindex7 <
returnvaluestrin( A methodre#returnarra%6t%pecodedindex7<
paramstrin( A methodre#paramarra%16t%pecodedindex7<
tablenumber A 1<
methodname A )ame,eserved5Det;trin(50ember,e#;truct6t%pecodedindex7.name88<
onespace A F F<
@
else
9
tableindexcode A 0x06<
t%peindex A DetT%pe>or0ethod5t%pecodedindex8<
t%pename A t%pede#names6t%peindex7 <
244260235.doc 416 od 541
returnvaluestrin( A methodde#returnarra%6t%pecodedindex7<
paramstrin( A methodde#paramarra%16t%pecodedindex7 <
tablenumber A 02<
methodname A )ame,eserved5Det;trin(50ethod;truct6t%pecodedindex7.name88<
@
i# 5t%pename.'ndex/#5F;%stem.=ia(nostics.=ebu((able*ttributeF8 EA P18
custombu( A true<
i# 5 custombu( 8
9
+onsole.!rite5+reate;paces5noo#spaces88<
+onsole.!rite3ine5FII PPP The #ollo"in( custom attribute is added automaticall%$ do not
uncomment PPPPPPPF8<
returnstrin( A returnstrin( C +reate;paces5noo#spaces8 C FIIF<
i# 5 initialspaces AA FF8
returnstrin( A returnstrin( C F F<
@
i# 5 parentcodedtablename AA FT%pe,e#F8
9
returnstrin( A returnstrin( C initialspaces C F.custom IJ0+F C ii.To;trin(5FK6F8 CFJI 5F C
t%pere#names6parentcodedindex7<
returnstrin( A returnstrin( C FIJF C tablenumber.To;trin(5FK2F8 C
parentcodedindex.To;trin(5FK6F8 C FJI 8 F<
@
else
returnstrin( A returnstrin( C initialspaces C F.custom IJ0+F C ii.To;trin(5FK6F8 C FMF C
tableindexcode.To;trin(5FK2F8 C t%pecodedindex.To;trin(5FK6F8 C FJI F<
returnstrin( A returnstrin( C Finstance F C returnvaluestrin( C onespace C t%pename <
returnstrin( A returnstrin( C FMMF C methodname<
returnstrin( A returnstrin( C F5F<
i# 5 noo#spaces AA 08
dumm% A 4aram/n0ultiple3ines5paramstrin( $ returnstrin(.3en(th C 28<
else i# 5 paramstrin( EA null8
dumm% A 4aram/n0ultiple3ines5paramstrin( $ returnstrin(.3en(th8<
i# 5 custombu( 8
9
int ind1 A dumm%.'ndex/#5FUrUnF8<
dumm%A dumm%.'nsert5ind1C2$ +reate;paces5noo#spaces8 C FIIF8<
dumm%A dumm%.,emove5ind1C10$ 48<
@
returnstrin( A returnstrin( C dumm% <
returnstrin( A returnstrin( C F8F<
returnstrin( A returnstrin( C F IJ F C tableindexcode.To;trin(5FK2F8 C
t%pecodedindex.To;trin(5FK6F8 C F JIF<
+onsole.!rite5returnstrin(8<
IIIIIII
int index A +ustom*ttribute;truct6ii7.value<
int ho"man%b%tes$uncompressedb%te <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
i# 5 uncompressedb%te AA 08
9
+onsole.!rite3ine58<
244260235.doc 417 od 541
continue<
@
index A index C ho"man%b%tes<
b%te 67 blobarra% A ne" b%te6uncompressedb%te7<
*rra%.+op%5blob $ index $ blobarra% $ 0 $ uncompressedb%te8<
bool displa%oneline A true<
strin( displa%strin( A FF<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
i# 5 blobarra%6117 B 0x208
displa%oneline A #alse<
i# 5 blobarra%6117 HA 0x7#8
displa%oneline A #alse<
@
i# 5 displa%oneline8
9
displa%strin( A F A UFF<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
displa%strin( A displa%strin( C 5char8blobarra%6117<
@
displa%strin( A displa%strin( C FUFF<
i# 5 tname AA F0ember,e#F8
+onsole.!rite5displa%strin(8<
else
+onsole.!rite3ine5displa%strin(8<
@
else
9
int starto##unctionclosebracet A returnstrin(.3ast'ndex/#5F8F8<
int lastenter A returnstrin(.3ast'ndex/#5FUrUnF8<
i# 5 lastenter AA P18
lastenter A P2<
int di##2 A starto##unctionclosebracet P lastenter C 19<
+onsole.!rite5F A 5 F8<
=ispla%>ormatted+olumns5+ustom*ttribute;truct6ii7.value$di##2 $ #alse $ #alse8<
@
@
@
@
public void abc5strin( 67 ar(s8
9
,ead4:;tructures5ar(s8<
=ispla%4:;tructures58<
,eadand=ispla%'mport*dressTable58<
,eadand=ispla%+3,2eader58<
,ead;treams=ata58<
>illTable;i&es58<
,eadTables'nto;tructures58<
=ispla%Tables>or=ebu((in(58<
,eadand=ispla%-Table>ixup58<
244260235.doc 418 od 541
,eadand=ispla%:xport*ddressTable?umps58<
>ill*rra%58<
>ill/p+ode*rra%58<
+reate;i(natures58<
=ispla%0odule,e#s58<
=ispla%*ssemble%,e#s58<
=ispla%*ssemble%58<
=ispla%>ileTable58<
=ispla%+lass:xtern58<
=ispla%,esources58<
=ispla%0odule*nd0ore58<
=ispal%-t>ixup58<
=ispla%T%pe=e#s58<
=ispla%T%pe=e#s*nd0ethods58<
@
public void =ispla%>ormatted+olumns5 int index $ int startin(spaces $ bool putonespace $ bool
opcode8
9
int ho"man%b%tes$uncompressedb%te <
i# 5 opcode 8
9
ho"man%b%tes A +or;i(Nncompress=ata5us$ index $ out uncompressedb%te8<
uncompressedb%te A uncompressedb%te P 1<
@
else
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
int toen A index<
index A index C ho"man%b%tes<
b%te 67 blobarra% A ne" b%te6uncompressedb%te7<
i# 5 opcode 8
*rra%.+op%5us$ index $ blobarra% $ 0 $ uncompressedb%te8<
else
*rra%.+op%5blob $ index $ blobarra% $ 0 $ uncompressedb%te8<
int maincounter A 0<
"hile 5 maincounter B uncompressedb%te 8
9
strin( #irststrin( A FF<
strin( secondstrin( A FF<
int counter#orascii A 0<
int ii <
bool noascii A #alse<
#or 5 counter#orascii A 0 < counter#orascii B 16 < counter#orasciiCC8
9
i# 5 maincounter AA uncompressedb%te 8
brea<
i# 5 blobarra%6maincounter7 HA 0x20 GG blobarra%6maincounter7 BA 0x7e8
noascii A true<
maincounterCC<
@
maincounter PA counter#orascii<
#or 5 ii A 0 < ii B 16 < iiCC8
244260235.doc 419 od 541
9
i# 5 maincounter AA uncompressedb%te 8
brea<
#irststrin( A #irststrin( C blobarra%6maincounter7.To;trin(5FK2F8 C F F<
i# 5 blobarra%6maincounter7 HA 0x20 GG blobarra%6maincounter7 BA 0x7e8
secondstrin( A secondstrin( C 5char8blobarra%6maincounter7<
else
secondstrin( A secondstrin( C F.F<
maincounterCC<
@
i# 5 maincounter AA uncompressedb%te 8
9
int le#tovers A maincountera 16<
i# 5 le#tovers EA 08
9
le#tovers A 15 P le#tovers<
#irststrin( A #irststrin( C F8F <
int space A le#toversJ3 C 3<
i# 5 noascii 8
#irststrin( A #irststrin( C +reate;paces5space8<
else
#irststrin( A #irststrin( C F F<
@
else
9
#irststrin( A #irststrin( C F8F<
i# 5 putonespace GG uncompressedb%te BA 168
#irststrin( A #irststrin( C F F<
#irststrin( A #irststrin( C +reate;paces508<
@
@
i# 5 maincounter AA uncompressedb%te 8
9
i# 5 noascii 8
#irststrin( A #irststrin( C F II F C secondstrin(<
i# 5 uncompressedb%te AA 16 GG Enoascii GG opcode8
#irststrin( A #irststrin( C F IJ 70F C toen.To;trin(5FK6F8 C F JIF<
else i# 5 opcode 8
#irststrin( A #irststrin( C F IJ 70F C toen.To;trin(5FK6F8 C F JIF<
@
else
9
i# 5 noascii 8
#irststrin( A #irststrin( C F II F C secondstrin(<
@
i# 5 maincounter AA uncompressedb%te GG opcode8
+onsole.!rite5#irststrin(8<
else
+onsole.!rite3ine5#irststrin(8<
i# 5 maincounter EA uncompressedb%te 8
+onsole.!rite5+reate;paces5startin(spaces88<
244260235.doc 420 od 541
@
@
public strin( =ecode0ember,e#Toen 5int toen $ int methodindex $ /p+ode opcode 8
9
strin( returnstrin( A FF<
II+onsole.!rite3ine5F.......90@F $ toen.To;trin(5FKF88<
i# 5 toen HA 0ember,e#;truct.3en(th 8
return F Z0,ZF C toen.To;trin(5FK2F8 C F58 IJ 0*0000F C toen.To;trin(5FK2F8 C F JIF<
int ro" A 0ember,e#;truct6toen7.clas<
strin( codedindextable A Det0ember,e#4arent+oded'ndexTable5ro"8<
int codedindexro" A ro" HH 3<
strin( initialstrin( A FF<
II+onsole.!rite3ine5F.......90@F $ codedindextable8<
i# 5 codedindextable AA F0odule,e#F8
9
initialstrin( A methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
strin( name A )ame,eserved5Det;trin(50odule,e#;truct6codedindexro"7.name88<
initialstrin( A initialstrin( C F6.module F C name C FIJ 1*F C codedindexro".To;trin(5FK6F8 C F
JI7F <
@
i# 5 codedindextable AA FT%pe;pecF8 IIarra%s.exe
9
strin( returnarra% A methodre#returnarra%6toen7<
strin( t%peplusreturn A methodre#t%pearra%6toen7 C returnarra%<
strin( t%pes A +reate;i(nature>orT%pe;pec5codedindexro"8<
t%pes A t%pes.,eplace5F`F$F$F8<
initialstrin( A t%peplusreturn C F F C t%pes <
@
else i# 5 codedindextable AA F0ethod=e#F8
9
initialstrin( A initialstrin( C methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
int t%peindex A DetT%pe>or0ethod5codedindexro"8<
initialstrin( A initialstrin( C t%pede#names6t%peindex7<
@
else i# 5 codedindextable AA FT%pe,e#F8
9
i# 5 opcode.)ame AA FldtoenF8
9
int t%peindex1 A 0<
strin( t%pename A )ame,eserved5Det;trin(5T%pe,e#;truct6codedindexro"7.name88<
strin( t%penamespace A )ame,eserved5Det;trin(5T%pe,e#;truct6codedindexro"7.nspace88<
#or 5 int t%pecnt A 1 < t%pecnt B T%pe=e#;truct.3en(th < t%pecntCC8
9
i# 5 t%pename AA )ame,eserved5Det;trin(5T%pe=e#;truct6t%pecnt7.name88 GG t%penamespace
AA )ame,eserved5Det;trin(5T%pe=e#;truct6t%pecnt7.nspace888
9
t%peindex1 A t%pecnt<
II+onsole.!rite3ine5F...90@F $ t%pename $ 8<
brea<
@
@
244260235.doc 421 od 541
int start $ starto#next<
start A T%pe=e#;truct6t%peindex17.#index <
i# 5 t%peindex1 AA 5T%pe=e#;truct.3en(th P 18 8
starto#nextA >ield;truct.3en(th<
else
starto#next A T%pe=e#;truct6t%peindex1C17.#index <
bool #ound A #alse<
#or 5 int #ieldindex A start < #ieldindex B starto#next < #ieldindexCC8
9
strin( name A )ame,eserved5Det;trin(50ember,e#;truct6toen7.name88<
i# 5 name AA )ame,eserved5Det;trin(5>ield;truct6#ieldindex7.name888
9
#ound A true<
brea<
@
@
i# 5 #ound 8
initialstrin( A F#ield F<
else
initialstrin( A Fmethod F<
@
initialstrin( A initialstrin( C methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
initialstrin( A initialstrin( C t%pere#names6codedindexro"7<
II+onsole.!rite3ine5F......90@ 91@F $ codedindexro" $ t%pere#names6codedindexro"7 8<
@
else i# 5 codedindextable AA FT%pe=e#F8
9
i# 5 opcode.)ame AA FldtoenF8
initialstrin( A F#ield F<
initialstrin( A initialstrin( C methodre#t%pearra%6toen7 C methodre#returnarra%6toen7 C F F<
initialstrin( A initialstrin( C t%pede#names6codedindexro"7<
@
strin( methodparmarra%strin( A methodre#paramarra%16toen7<
strin( nameplusparams A FF<
i# 5 methodparmarra%strin( EA null8
9
nameplusparams A )ame,eserved5Det;trin(50ember,e#;truct6toen7.name88 C F5F<
int len A 51 C spaces#orrestC2C spaces#ortr% C spaces#ornested C nameplusparams.3en(th C
initialstrin(.3en(th C 2<
nameplusparams A nameplusparams C 4aram/n0ultiple3ines5methodparmarra%strin($len8<
nameplusparams A nameplusparams C F8F<
@
else
nameplusparams A )ame,eserved5Det;trin(50ember,e#;truct6toen7.name88 <
returnstrin( A initialstrin( C FMMF C nameplusparams C F IJ 0*F C toen.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
public strin( =ecode0ember=e#Toen 5int toen $ /p+ode opcode8
9
strin( returnstrin( A FF<
i# 5 toen HA 0ethod;truct.3en(th8
244260235.doc 422 od 541
return returnstrin(<
strin( name A )ame,eserved5Det;trin(50ethod;truct6toen7.name88<
strin( methodattributes A Det0ethod*ttribute50ethod;truct6toen7.#la(s $ toen 8<
i# 5 methodattributes.'ndex/#5Fprivatescope F8 EA P18
name A name C FZ4;T06F C toen.To;trin(5FK6F8<
int t%peindex A DetT%pe>or0ethod5toen8<
i# 5 opcode.)ame AA FldtoenF8
returnstrin( A Fmethod F<
returnstrin( A returnstrin( C methodde#t%pearra%6toen7 C methodde#returnarra%6toen7 C
t%pede#names6t%peindex7 <
returnstrin( A returnstrin( C FMMF C name C F5F <
int len A returnstrin(.3en(th C 53 C spaces#orrest C spaces#ortr% C spaces#ornested<
strin( s#inal A methodde#paramarra%16toen7<
returnstrin( A returnstrin( C 4aram/n0ultiple3ines5s#inal $ len 8 C F8F<
returnstrin( A returnstrin( C F F C FIJ 06F C toen.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
public void =ecodeToen'3 5int toen $ /p+ode opcode $ int methodindex $ strin( strin(s $ out int
seriouserror 8
9
seriouserror A 0<
int ori(inaltoen A toen<
int table A 5int85toen G 0x##0000008<
table A table HH 24<
toen A toen G 0x00######<
IIi# 5 opcode.)ame AA FldtoenF8
II+onsole.!rite3ine5F........F8<
i# 5 table AA 4 GG toen H >ield;truct.3en(th 8
9
+onsole.!rite5F JJJJJJJJJ :,,/, =';*;;:0O3')D T2: 0:T2/= '3 +/=:
JJJJJJJJJJJF8<
seriouserror A 1<
return <
@
i# 5 table AA 1 GG toen H T%pe,e#;truct.3en(th 8
9
+onsole.!rite5F JJJJJJJJJ :,,/, =';*;;:0O3')D T2: 0:T2/= '3 +/=:
JJJJJJJJJJJF8<
seriouserror A 1<
return <
@
+onsole.!rite5strin(s8<
i# 5 table AA 08
9
+onsole.!rite5F590@891@ JI 92@93@0x94@ F $ table.To;trin(5FK2F8 $toen.To;trin(5FK6F8$
opcode.)ame$ +reate;paces511Popcode.)ame.3en(th8 $ toen.To;trin(5FK2F8 8<
@
i# 5 table HA 60 TT table B 08
9
b%te dumm%b%te A 5b%te8 table<
strin( returnstrin( A F5F C dumm%b%te.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
244260235.doc 423 od 541
returnstrin( A returnstrin( C F JI F C opcode.)ame <
+onsole.!rite5returnstrin(8<
int len A 31 P returnstrin(.3en(th<
+onsole.!rite5+reate;paces5len88<
+onsole.!rite5FBunno"n toen t%pe 0xF C dumm%b%te.To;trin(5Fx2F8 C FHF8<
@
i# 5table AA 0x018
9
strin( returnstrin( A F5018F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pere#names6toen7<
+onsole.!rite5returnstrin(8<
@
i# 5 table AA 0x028
9
strin( returnstrin( A F5028F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame<
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pede#names6toen7<
+onsole.!rite5returnstrin(8<
@
i# 5table AA 0x068 II0ethod
9
strin( returnstrin( A F5068F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame<
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C =ecode0ember=e#Toen5toen $ opcode8<
+onsole.!rite5returnstrin(8<
@
i# 5 table AA 0x048
9
strin( returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame <
+onsole.!rite5returnstrin(8<
int t%peindex A DetT%pe>or>ield5toen8<
i# 5 opcode.)ame AA FldtoenF 8
+onsole.!rite5F #ield F8<
else
9
int len A opcode.)ame.3en(th<
+onsole.!rite5+reate;paces511Plen88<
@
+onsole.!rite5#ieldparamarra%6toen78<
strin( #inalstrin( A t%pede#names6t%peindex7<
+onsole.!rite5F 90@MMF $ #inalstrin( $ t%peindex.To;trin(5FK6F88<
strin( name A )ame,eserved5Det;trin(5>ield;truct6toen7.name88<
i# 5#ield#la(sarra%6toen7.'ndex/#5Fprivatescope F8 EA P18
name A name C FZ4;T04F C toen.To;trin(5FK6F8<
name A name C F IJ 04F C toen.To;trin(5FK6F8 C F JIF<
+onsole.!rite5name8<
@
i# 5table AA 0x0a8 II0ember,e#
9
244260235.doc 424 od 541
strin( returnstrin( A F50*8F C toen.To;trin(5FK6F8 C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
returnstrin( A returnstrin( C +reate;paces511Plen8 C =ecode0ember,e#Toen5toen $
methodindex $ opcode 8<
+onsole.!rite5returnstrin(8<
@
i# 5 table AA 0x118 II;tand*lonesi(
9
int b1 A toen G 0x##<
int b2 A 5toen G 0x##008 HH 8<
int b3 A 5toen G 0x##00008 HH 16<
strin( returnstrin( A b1.To;trin(5FK2F8 C b2.To;trin(5FK2F8 C b3.To;trin(5FK2F8 C
table.To;trin(5FK2F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame C F F<
strin( dumm% A +reate;i(nature>or+alli5toen8<
int len A opcode.)ame.3en(th<
i# 5 dumm% AA FerrorF8
returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8 C F JI F C
opcode.)ame C +reate;paces511Plen8 C FBunno"n toen t%pe 0xF C table.To;trin(5FK2F8CFHF <
else
returnstrin( A returnstrin( C dumm% C F IJF C ori(inaltoen.To;trin(5FK8F8 C FJIF<
+onsole.!rite5returnstrin(8<
@
i# 5 table AA 0x1b8 II T%pespec
9
strin( returnstrin( A F5F C table.To;trin(5FK2F8 C F8F C toen.To;trin(5FK6F8<
returnstrin( A returnstrin( C F JI F C opcode.)ame <
int len A opcode.)ame.3en(th<
strin( t%pes A +reate;i(nature>orT%pe;pec5toen8<
t%pes A t%pes.,eplace5F`F$F$F8<
returnstrin( A returnstrin( C +reate;paces511Plen8 C t%pes <
+onsole.!rite5returnstrin(8<
@
@
public strin( +reate;i(nature>or+alli5int ro"8
9
int aa A P1<
int ho"man%b%tes$uncompressedb%te $ count<
i# 5 ro" HA ;tand*lone;i(;truct.3en(th8
return FerrorF<
int index A ;tand*lone;i(;truct6ro"7.index <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blobarra% A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blobarra% $ 0 $ count8<
i# 5 ro" AA aa8
9
#or 5 int i A 0 < i B count < iCC8
+onsole.!rite5F90@ F $ blobarra%6i7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
244260235.doc 425 od 541
strin( t%pes A =ecode>irstO%teo#0ethod;i(nature 5 blobarra%607 $ ro"8<
index A 1<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
count A uncompressedb%te<
index A index C ho"man%b%tes <
strin( returnstrin( At%pes<
int dumm%int1<
returnstrin( A returnstrin( C Det:lementT%pe5 index $ blobarra% $ out dumm%int1 $ 0 $ FF8<
index A index C dumm%int1<
returnstrin( A returnstrin( C F5F<
#or 5 int l A 1 < l BA count < lCC8
9
i# 5 blobarra%6index7 AA 0x41 8
9
returnstrin( A returnstrin( C F...$F<
index A index C 1<
@
strin( dumm% A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $0 $ FF8<
returnstrin( A returnstrin( C dumm% <
i# 5 l EA count 8
returnstrin( A returnstrin( C F$F<
index A index C ho"man%b%tes<
@
i# 5 index B blobarra%.3en(th GG blobarra%6index7 AA 0x418
returnstrin( A returnstrin( C F$...F <
returnstrin( A returnstrin( C F8F<
return returnstrin(<
@
public strin( +reate;i(nature>orT%pe;pec5int ro"8
9
strin( returnstrin( A FF<
int ho"man%b%tes$uncompressedb%te $ count<
int index A T%pe;pec;truct6ro"7.si(nature <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blobarra% A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blobarra% $ 0 $ count8<
IJ
+onsole.!rite3ine5F.........90@ 91@ 92@ 93@F $ count $ blob6index7 $blob6indexC17$
blob6indexC27 8<
#or 5 int i A 0 < i B count < iCC8
+onsole.!rite5F90@ F $ blobarra%6i78<
+onsole.!rite3ine58<
JI
returnstrin( A Det:lementT%pe5 0 $ blobarra% $ out ho"man%b%tes $0 $ FF8<
return returnstrin(<
@
public strin( Det4aram)ame>or0ethod5int ro" $ int count $ int l8
9
strin( returnstrin( A FF<
strin( mattributes A Det0ethod*ttribute50ethod;truct6ro"7.#la(s $ ro"8<
244260235.doc 426 od 541
i# 5 4aram;truct AA null8
9
IIisnan.exe
i# 5 mattributes.'ndex/#5FstaticF8 EA P18
lPP<
return F*RF C l.To;trin(58<
@
int start $ starto#nextA0 $ paramcount<
start A 0ethod;truct6ro"7.param <
i# 5 ro" AA 50ethod;truct.3en(th P18 8
starto#nextA 4aram;truct.3en(th<
else
starto#next A 0ethod;truct6ro"C17.param<
paramcount A starto#next P start<
int ind<
bool param#ound A #alse<
#or 5 ind A start < ind B starto#next < indCC8
9
i# 5 4aram;truct6ind7.se.uence AA l8
9
param#ound A true<
brea<
@
@
IIi# 5 ind B paramnames.3en(th GG GG param#ound8
i# 5 param#ound GG paramnames6ind7 EA FF 8
9
returnstrin( A )ame,eserved5paramnames6ind78<
@
else
9
II'nterop.orders.dll
i# 5 mattributes.'ndex/#5FstaticF8 EA P18
lPP<
returnstrin( A F*RF C l.To;trin(58<
@
return returnstrin(<
@
public void >ill/p+ode*rra%58
9
/p+odes*rra% A ne" /p+ode62567<
/p+odes*rra%1 A ne" /p+ode6327<
>ield'n#o67 #ields A t%peo#5/p+odes8.Det>ields5Oindin(>la(s.4ublic T Oindin(>la(s.)on4ublic T
Oindin(>la(s.;tatic T Oindin(>la(s.'nstance T Oindin(>la(s.=eclared/nl%8<
II+onsole.!rite3ine5F)ame -alue /perandT%pe >lo" /p+ode ;i&eF8<
#oreach 5>ield'n#o # in #ields8
9
/p+ode o A 5/p+ode8 #.Det-alue5null8<
IIi# 5 o./perandT%pe AA /perandT%pe.'nline>ield8
II+onsole.!rite3ine5F90$P17@ 91$5@ 92$P20@ 93$P12@ 94$P10@ 95@F $ o.)ame$
o.-alue.To;trin(5FKF8 $ o./perandT%pe $ o.>lo"+ontrol $ o./p+odeT%pe $ o.;i&e8<
244260235.doc 427 od 541
i# 5 o.-alue BA 255 GG o.-alue HA 08
/p+odes*rra%65short8o.-alue7 A o<
/p+odes*rra%165ushort8 0x007 A /p+odes.*r(list<
/p+odes*rra%165ushort8 0x017 A /p+odes.+e.<
/p+odes*rra%165ushort8 0x027 A /p+odes.+(t<
/p+odes*rra%165ushort8 0x037 A /p+odes.+(tRNn<
/p+odes*rra%165ushort8 0x047 A /p+odes.+lt<
/p+odes*rra%165ushort8 0x057 A /p+odes.+ltRNn<
/p+odes*rra%165ushort8 0x067 A /p+odes.3d#tn<
/p+odes*rra%165ushort8 0x077 A /p+odes.3dvirt#tn<
/p+odes*rra%165ushort8 0x097 A /p+odes.3dar(<
/p+odes*rra%165ushort8 0x0*7 A /p+odes.3dar(a<
/p+odes*rra%165ushort8 0x0O7 A /p+odes.;tar(<
/p+odes*rra%165ushort8 0x0+7 A /p+odes.3dloc<
/p+odes*rra%165ushort8 0x0=7 A /p+odes.3dloca<
/p+odes*rra%165ushort8 0x0:7 A /p+odes.;tloc<
/p+odes*rra%165ushort8 0x0>7 A /p+odes.3ocalloc<
/p+odes*rra%165ushort8 0x117 A /p+odes.:nd#ilter<
/p+odes*rra%165ushort8 0x127 A /p+odes.Nnali(ned<
/p+odes*rra%165ushort8 0x137 A /p+odes.-olatile<
/p+odes*rra%165ushort8 0x147 A /p+odes.Tailcall<
/p+odes*rra%165ushort8 0x157 A /p+odes.'nitob1<
/p+odes*rra%165ushort8 0x177 A /p+odes.+pbl<
/p+odes*rra%165ushort8 0x187 A /p+odes.'nitbl<
/p+odes*rra%165ushort8 0x1*7 A /p+odes.,ethro"<
/p+odes*rra%165ushort8 0x1+7 A /p+odes.;i&eo#<
/p+odes*rra%165ushort8 0x1=7 A /p+odes.,e#an%t%pe<
@


@
public void =ispla%*ll0ethods 5int t%peindex8
9
i# 5 T%pe=e#;truct AA null8
return<
i# 5 0ethod;truct AA null8
return<
int start $ starto#nextA0<
start A T%pe=e#;truct6t%peindex7.mindex <
i# 5 t%peindex AA 5T%pe=e#;truct.3en(th P18 8
9
starto#nextA 0ethod;truct.3en(th<
@
else
starto#next A T%pe=e#;truct6t%peindexC17.mindex <
#or 5 int methodindex A start < methodindex B starto#next < methodindexCC8
9
strin( methodstrin( A +reate;paces5spaces#orrest8<
i# 5 'sT%pe)ested5t%peindex88
methodstrin( A methodstrin( C +reate;paces5spaces#ornested8<
methodstrin( A methodstrin( C F.method F<
244260235.doc 428 od 541
methodstrin( A methodstrin( C FIJ06F C methodindex.To;trin(5FK6F8 C FJI F <
strin( methodattribute A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $ methodindex8<
int pos1 A methodattribute.'ndex/#5FinstanceF8<
i# 5 pos1 EA P18
methodattribute A methodattribute.,emove5pos1$ 98<
strin( enter#ormethodattrbute A FF<
strin( enter#orreturnvalue A FF<
strin( enter#ormarshal A FF<
strin( paramattrstrin( A FF<
strin( parammarshalstrin( A FF<
paramattrstrin( A Det4aram*ttr#or0ethod+allin(5methodindex8<
parammarshalstrin( A Det4aram*ttr#or0ethod0arshal5methodindex $ 0 8<
strin( nspaceA FF<
nspaceA )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
int parentt%pe A Det4arent>or)estedT%pe5t%peindex8<
i# 5 parentt%pe EA 08
nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6parentt%pe7.nspace88<
bool cat2return A #alse<
bool cat3returnvaluemarshal A #alse<
bool cat4 A #alse<
int ho"man% A 2o"0an%0ethod*ttributes5methodattribute8<
i# 5 parammarshalstrin( AA FF 8
9
i# 5 methodattribute AA Fpublic static F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF 8 8
cat2return A true<
i# 5 methodattribute AA Fprivate static F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA F#amil% static F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fassembl% static F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF 8
cat2return A true<
i# 5 methodattribute AA Fpublic virtual F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fprivate virtual F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA F#amil% virtual F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fpublic ne"slot F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fprivate ne"slot F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA F#amil% ne"slot F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA Fpublic #inal F 8
cat2return A true<
i# 5 methodattribute AA Fprivate #inal F GG E5'sT%pe)ested5t%peindex8 GG nspace EA FF8 8
cat2return A true<
i# 5 methodattribute AA F#amil% #inal F 8
cat2return A true<
i# 5 methodattribute AA Fpublic abstract F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
244260235.doc 429 od 541
i# 5 methodattribute AA Fprivate abstract F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA F#amil% abstract F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat2return A true<
i# 5 methodattribute AA Fpublic hideb%si( F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF 8
cat2return A true<
i# 5 methodattribute AA F#amil% hideb%si( F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF 8
cat2return A true<
i# 5 methodattribute.'ndex/#5FpinvoeimplF8 AA P18
9
i# 5 ho"man% AA 0 GG methodde#t%pearra%6methodindex7.'ndex/#5Finstance F8 EA P1 8
cat2return A true<
@
@
int aa A 0x00<
i# 5 parammarshalstrin( EA FF 8
9
i# 5 methodattribute AA Fpublic hideb%si( F GG nspace AA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA F#amil% hideb%si( F GG nspace AA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic virtual F GG nspace EA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic virtual F GG nspace AA FF GG E'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic virtual F GG nspace AA FF GG 'sT%pe)ested5t%peindex88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fpublic static F GG E 5'sT%pe)ested5t%peindex8 GG nspace EA FF88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA Fprivate static F GG E 5'sT%pe)ested5t%peindex8 GG nspace EA FF88
cat3returnvaluemarshal A true<
i# 5 methodattribute AA F#amil% static F GG E 5'sT%pe)ested5t%peindex8 GG nspace EA FF88
cat3returnvaluemarshal A true<

i# 5 methodattribute AA Fassembl% static F GG E'sT%pe)ested5t%peindex8 GG nspace AA FF8
cat3returnvaluemarshal A true<
i# 5 ho"man% AA 0 GG methodde#t%pearra%6methodindex7 AA Finstance F 8
cat3returnvaluemarshal A true<
@
i# 5parammarshalstrin( EA FF GG methodattribute.'ndex/#5FpinvoeimplF8 AA P18
9
i# 5 methodattribute AA Fpublic virtual F GG nspace EA FF GG 'sT%pe)ested5t%peindex88
cat4 A true<
i# 5 ho"man% AA 0 GG 'sT%pe)ested5t%peindex8 GG nspace EA FF GG
methodde#t%pearra%6methodindex7 AA FF 8
9
bool problem1 A true<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F....90@ 91@..F $ methodde#returnarra%6methodindex7.3en(th $
methodde#returnarra%6methodindex78<
244260235.doc 430 od 541
i# 5 methodattribute AA Fassembl% static F TT methodattribute AA Fpublic static F TT methodattribute
AA Fprivate static F TT methodattribute AA F#amil% static F 8
9
i# 5 paramattrstrin( AA FF 8
problem1 A #alse<
@
i# 5 problem18
cat4 A true<
@
i# 5 methodattribute.'ndex/#5Fhideb%si(F8 EA P18
9
i# 5 methodattribute.'ndex/#5FpublicF8 EA P1 TT methodattribute.'ndex/#5F#amil%F8 EA P18
9
i# 5 'sT%pe)ested5t%peindex8 TT nspace EA FF 8
cat4 A true<
@
else
cat4 A true<
@
i# 5 ho"man% HA 2 8
cat4 A true<
@
i# 5 cat2return 8
9
enter#ormethodattrbute A FF<
enter#orreturnvalue A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#ormarshal A FF<
@
else i# 5 cat3returnvaluemarshal8
9
enter#ormethodattrbute A FF<
enter#orreturnvalue A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#ormarshal A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
@
else i# 5 cat48
9
enter#ormethodattrbute A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#orreturnvalue A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#ormarshal A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
@
else
9
enter#ormethodattrbute A FUrUnF C +reate;paces5spaces#orrest C 8 C spaces#ornested8<
enter#orreturnvalue A F F<
i# 5parammarshalstrin( EA FF8
enter#ormarshal A F F<
@
methodstrin( A methodstrin( C methodattribute C enter#ormethodattrbute<
methodstrin( A methodstrin( C methodde#t%pearra%6methodindex7 C paramattrstrin( <
methodstrin( A methodstrin( C methodde#returnarra%6methodindex7 C enter#orreturnvalue<
methodstrin( A methodstrin( C parammarshalstrin( C enter#ormarshal <
244260235.doc 431 od 541
i# 5 methodstrin(.3en(th P methodstrin(.3ast'ndex/#5FUrUnF8 HA 44 8
9
methodstrin( A methodstrin(.,emove5methodstrin(.3en(thP1$18<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 8C spaces#ornested8<
@
methodstrin( A methodstrin( C )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 <
i# 5 methodattribute.'ndex/#5FprivatescopeF8 EA P18
methodstrin( A methodstrin( C FZ4;T06F C methodindex.To;trin(5FK6F8<
methodstrin( A methodstrin( C F5F<
int len A 0<
i# 5 methodde#paramarra%6methodindex7 EA null8
9
int indexo#enter A methodstrin(.3ast'ndex/#5FUrUnF8<
int len(tho#strin( A methodstrin(.3en(th <
len A len(tho#strin( P indexo#enter P 2<
methodstrin( A methodstrin( C 4aram/n0ultiple3ines5methodde#paramarra%6methodindex7 $ len
8<
@
methodstrin( A methodstrin( C F8F<
strin( impl#la(s A Det0ethod*ttribute150ethod;truct6methodindex7.imp#la(s8<
methodstrin( A methodstrin( C F F C impl#la(s <
strin( methodsi(nature A Det0ethod;i(natureO%tes5methodindex8<
methodstrin( A methodstrin( C methodsi(nature<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrestC spaces#ornested8 C F9F <
int tablero" A entr%pointtoen G 0x00######<
i# 5 tablero" AA methodindex 8
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C
F.entr%pointF<
+onsole.!rite3ine5methodstrin(8<
=ispla%+ustom*ttribute5F0ethod=e#F $ methodindex $ 2 C spaces#orrest C spaces#ornested8<
=ispla%4arams>or0ethod5methodindex8<
=ispla%*ll;ecurit%5 1 $ methodindex 8<
=ispla%/verride0ethod5methodindex8< II inter#aces.exe
i# 5impl#la(s.'ndex/#5Fcil mana(edF8 AA P1 TT 0ethod;truct6methodindex7.rva AA 08
9
bool problem1 A true<
i# 5 methodattribute.'ndex/#5FpinvoeimplF8 EA P1 8
9
i# 5 methodattribute.'ndex/#5Fpinvoeimpl5IJ )o map JI8F8 EA P18
9
+onsole.!rite3ine5F II :mbedded native codeF8<
+onsole.!rite3ine5F II =isassembl% o# native methods is not supported.F8<
+onsole.!rite3ine5F II 0ana(ed Tar(et,-* A 0x90@F $
0ethod;truct6methodindex7.rva.To;trin(5Fx4F88<
+onsole.!rite3ine5+reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o# (lobal method F
C )ame,eserved5Det;trin(50ethod;truct6methodindex7.name888<
@
else
9
methodstrin( A +reate;paces5spaces#orrestC spaces#ornested8 C F@F <
+onsole.!rite5methodstrin(8<
244260235.doc 432 od 541
@
methodstrin( A FF<
problem1 A #alse<
@
else i# 5impl#la(s.'ndex/#5Fruntime mana(edF8 EA P18
9
methodstrin( A FF<
@
else i# 5impl#la(s.'ndex/#5Fruntime unmana(edF8 EA P18
methodstrin( A F II 0ethod provided b% ,untimeUrUnF<
else i# 5impl#la(s.'ndex/#5Fnative unmana(edF8 EA P18
methodstrin( A F II Nnmana(ed Tar(et,-* A 0xF C
0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
else i# 5 impl#la(s.'ndex/#5FnativeF8 EA P18
9
methodstrin( A F II =isassembl% o# native methods is not supported.F<
methodstrin( A methodstrin( C FUrUn II 0ana(ed Tar(et,-* A 0xF C
0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
@
else i# 5 0ethod;truct6methodindex7.rva AA 0 GG impl#la(s.'ndex/#5Funmana(edF8 AA P1 8
9
methodstrin( A +reate;paces5spaces#orrestC spaces#ornested C 28 C FII 0ethod be(ins at ,-*
0x0UrUnF<
@
else i# 5 impl#la(s.'ndex/#5FoptilF8 EA P1 8
9
methodstrin( A +reate;paces5spaces#orrestC spaces#ornested C 28 C FII 0ethod be(ins at ,-*
0xF C 0ethod;truct6methodindex7.rva.To;trin(5Fx4F8 C FUrUnF<
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested C 28 C FII +ode si&e
0 50x08UrUnF<
@
else
9
methodstrin( A FF<
@
i# 5problem18
methodstrin( A methodstrin( C +reate;paces5spaces#orrestC spaces#ornested8 C F@ II end o#
method F C )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 C FMMF C
)ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C FUrUnF<
+onsole.!rite3ine5methodstrin(8<
continue<
@
strin( vtentr%strin( A Det-tentr%;trin(5methodindex8<
methodstrin( A vtentr%strin(<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII 0ethod
be(ins at ,-* 0xF C 0ethod;truct6methodindex7.rva.To;trin(5Fx4F8<
+onsole.!rite5methodstrin(8<
lon( #ileo##set A +onvert,-*50ethod;truct6methodindex7.rva8<
m#ilestream.;ee5#ileo##set $ ;ee/ri(in.Oe(in8<
=ispla%>at>ormat5)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 $
)ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 $ methodindex 8<
244260235.doc 433 od 541
@
@
public void =ispla%>at>ormat 5 strin( classname $ strin( methodname $ int methodindex 8
9
=ispla%'nitial0ethod2eader5methodindex8<
=ispla%0ethod'3+ode5classname $ methodname $ methodindex 8<
@
public void =ispla%'nitial0ethod2eader 5int methodindex8
9
int tin% A mbinar%reader.,eadO%te58<
i# 5 5tin% G 0x038 AA 0x038
tin%#ormat A #alse<
else
tin%#ormat A true<
m#ilestream.;ee5P1$;ee/ri(in.+urrent8<
strin( methodstrin( A FF<
i# 5 Etin%#ormat 8
9
lon( "here A m#ilestream.4osition<
short #irst A mbinar%reader.,ead'nt1658<
#irst12 A 5short85#irst G 0x0###8<
short #irst4 A 5short85#irst G 0x#0008<
#irst4 A 5short8 5#irst4 HH 128<
short stacsi&e A mbinar%reader.,ead'nt1658<
codesi&e A mbinar%reader.,ead'nt3258<
methodstrin( A FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C FII +ode si&e F C
codesi&e.To;trin(58 C F 50xF C codesi&e.To;trin(5FxF8 C F8UrUnF<
i# 5 5#irst12G0x088 AA 0x08 8
,ead:xceptions5"here $ codesi&e $ methodindex 8<
methodstrin( A methodstrin( C +reate;paces5spaces#orrest C 2C spaces#ornested8 C F.maxstac F
C stacsi&e.To;trin(58<
int standalonesi( A mbinar%reader.,ead'nt3258<
int ro"standalonesi( A standalonesi( G 0x00######<
II+onsole.!rite3ine5F.......90@ F $ ro"standalonesi(8<
i# 5;tand*lone;i(;truct EA null GG standalonesi(arra% AA null8
standalonesi(arra% A ne" strin(6;tand*lone;i(;truct.3en(th7<

i# 5 ro"standalonesi( EA 0 8
9
+reate;i(nature>or:achT%pe55 $ ;tand*lone;i(;truct6ro"standalonesi( 7.index $
ro"standalonesi( 8<
i# 5 standalonesi(arra%6ro"standalonesi( 7 EA FF8
9
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2C spaces#ornested8 C
F.locals IJ11F C ro"standalonesi(.To;trin(5FK6F8 C FJI F<
i# 55#irst12G0x108 AA 0x10 8
methodstrin( A methodstrin( C Finit 5F <
else
methodstrin( A methodstrin( C F5F <
methodstrin( A methodstrin( C standalonesi(arra%6ro"standalonesi( 7<
methodstrin( A methodstrin( C F8F<
244260235.doc 434 od 541
@
@
@
else
9
mbinar%reader.,eadO%te58<
codesi&e A tin% HH 2<
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested 8 C FII
+ode si&e F C codesi&e.To;trin(58 C F 50xF C codesi&e.To;trin(5FxF8 C F8F<
i# 5codesi&e EA 08
methodstrin( A methodstrin( C FUrUnF C +reate;paces5spaces#orrest C 2C spaces#ornested8 C
F.maxstac 8F <
@
+onsole.!rite3ine5methodstrin(8<
@

public strin( =ispla%4arams>or0ethod 5int methodro"8
9
i# 5 4aram;truct AA null8
return FF<
strin( returnstrin( A FF<
int startA0$ endA0<
start A 0ethod;truct6methodro"7.param<
i# 5 methodro" AA 50ethod;truct.3en(th P 188
end A 4aram;truct.3en(th <
else
end A 0ethod;truct6methodro"C17.param<
#or 5 int index A start < index B end < indexCC8
9
int se. A 4aram;truct6index7.se.uence<
returnstrin( A +reate;paces5spaces#orrestC spaces#ornestedC28 C F.param 6F C se..To;trin(58 C
F7F C FIJ08F C index.To;trin(5FK6F8 C FJIF<
strin( str A =ispla%>rom+onstantsTable5index $0 $F4aram=e#F8<
i# 5 str EA FF8
+onsole.!rite5returnstrin( C str 8<
bool b A 2as+ustom*ttribute5F4aram=e#F $ index8<
i# 5 b GG str AA FF8
+onsole.!rite3ine5returnstrin( C F F8<
=ispla%+ustom*ttribute5F4aram=e#F $ index $ spaces#orrestC spaces#ornestedC28<
@
return FF<
@
public int Det+ustom*ttributeT%pevalue5int attributecodedt%pe8
9
return attributecodedt%pe HH 3<
@
public strin( Det+ustom*ttributeT%peTable5 int attributecodedt%pe8
9
strin( returnstrin( A FF<
int ta( A attributecodedt%pe G 0x07<
i# 5 ta( AA 08
244260235.doc 435 od 541
returnstrin( A returnstrin( C F)otNsedF<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F)otNsedF<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 38
returnstrin( A returnstrin( C F0ethod,e#F<
i# 5 ta( AA 48
returnstrin( A returnstrin( C F)otNsedF<
return returnstrin(<
@
public int Det2as+ustom*ttribute-alue5 int attributecodedparent8
9
return attributecodedparent HH 5<
@
public strin( Det2as+ustom*ttributeTable 5 int attributecodedparent8
9
strin( returnstrin( A FF<
int ta( A attributecodedparent G 0x1><
i# 5 ta( AA 08
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F>ield=e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C FT%pe,e#F<
i# 5 ta( AA 38
returnstrin( A returnstrin( C FT%pe=e#F<
i# 5 ta( AA 48
returnstrin( A returnstrin( C F4aram=e#F<
i# 5 ta( AA 58
returnstrin( A returnstrin( C F'nter#ace'mplF<
i# 5 ta( AA 68
returnstrin( A returnstrin( C F0ember,e#F<
i# 5 ta( AA 78
returnstrin( A returnstrin( C F0oduleF<
i# 5 ta( AA 88
returnstrin( A returnstrin( C F=ecl;ecurit%F<
i# 5 ta( AA 98
returnstrin( A returnstrin( C F4ropert%F<
i# 5 ta( AA 108
returnstrin( A returnstrin( C F:ventF<
i# 5 ta( AA 118
returnstrin( A returnstrin( C F;i(natureF<
i# 5 ta( AA 128
returnstrin( A returnstrin( C F0odule,e#F<
i# 5 ta( AA 138
returnstrin( A returnstrin( C FT%pe;pecF<
i# 5 ta( AA 148
returnstrin( A returnstrin( C F*ssembl%F<
i# 5 ta( AA 158
returnstrin( A returnstrin( C F*ssembl%,e#F<
244260235.doc 436 od 541
i# 5 ta( AA 168
returnstrin( A returnstrin( C F>ileF<
i# 5 ta( AA 178
returnstrin( A returnstrin( C F:xportedT%peF<
i# 5 ta( AA 188
returnstrin( A returnstrin( C F0ani#est,esourceF<
return returnstrin(<
@

public void +reate;i(natures 58
9
II;tand*lone;i(
II0ethodTable
i# 50ethod;truct EA null8
9
methodde#returnarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramarra%1 A ne" strin(60ethod;truct.3en(th7<
methodde#t%pearra% A ne" strin(60ethod;truct.3en(th7<
methodde#paramcount A ne" int60ethod;truct.3en(th7<
#or 5 int l A 1 < l B 0ethod;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe51 $ 0ethod;truct6l7.si(nature$ l8<
@
@
II0ethod,e#Table
i# 5 0ember,e#;truct EA null 8
9
methodre#t%pearra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#returnarra% A ne" strin(60ember,e#;truct.3en(th7<
methodre#paramarra%1 A ne" strin(60ember,e#;truct.3en(th7<
#or 5 int l A 1 < l B 0ember,e#;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe52 $ 0ember,e#;truct6l7.si($ l8<
@
@
II#ieldtable
i# 5 >ield;truct EA null 8
9
#ield#la(sarra% A ne" strin(6>ield;truct.3en(th7<
#ieldparamarra% A ne" strin(6>ield;truct.3en(th7<
#or 5 int l A 1 < l B >ield;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe56$ >ield;truct6l7.si($ l8<
@
@
IIpropert%table
i# 5 4ropert%;truct EA null 8
9
propert%parmarra% A ne" strin(64ropert%;truct.3en(th7<
propert%returnarra% A ne" strin(64ropert%;truct.3en(th7<
244260235.doc 437 od 541
propert%t%pearra% A ne" strin(64ropert%;truct.3en(th7<
#or 5 int l A 1 < l B 4ropert%;truct.3en(th < lCC8
9
+reate;i(nature>or:achT%pe57$ 4ropert%;truct6l7.t%pe$ l8<
@
@
@
public void +reate;i(nature>or:achT%pe 5b%te t%pe $ int index $ int ro"8
9
int uncompressedb%te $ count $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
count A uncompressedb%te<
b%te 67 blob1 A ne" b%te6count7<
*rra%.+op%5blob $ index C ho"man%b%tes $ blob1 $ 0 $ count8<
i# 5 t%pe AA 78
+reate4ropert%;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 68
+reate>ield;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 58
+reate3ocal-ar;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 18
+reate0ethod=e#;i(nature5blob1 $ ro"8<
i# 5 t%pe AA 28
+reate0ethod,e#;i(nature5blob1 $ ro"8<
@
public void =ispla%/neT%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%;i&e*nd4ac5t%pede#index8<
=ispla%+ustom*ttribute5FT%pe=e#F $ t%pede#index $ 2 C space#ornamespace C spaces#ornested8<
=ispla%*ll;ecurit%5 0 $ t%pede#index8<
=ispla%)estedT%pes5t%pede#index8<
=ispla%/verride5t%pede#index8<
=ispla%*ll>ields5t%pede#index8<
=ispla%*ll0ethods5t%pede#index8<
=ispla%*ll:vents5t%pede#index8<
=ispla%*ll4roperties5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index 8<
@
public void =ispla%*ll>ields 5int t%peindex8
9
i# 5 >ield;truct AA null 8
return<
int start $ starto#nextA0<
start A T%pe=e#;truct6t%peindex7.#index <
i# 5 t%peindex AA 5T%pe=e#;truct.3en(th P 18 8
starto#nextA >ield;truct.3en(th<
else
starto#next A T%pe=e#;truct6t%peindexC17.#index <
strin( returnstrin( A FF<
#or 5 int #ieldindex A start < #ieldindex B starto#next < #ieldindexCC8
244260235.doc 438 od 541
9
i# 5 )ame,eserved5Det;trin(5>ield;truct6#ieldindex7.name88 AA FR=eletedF8
continue<
i# 5 t%peindex AA 18
returnstrin( A FF<
else
returnstrin( A +reate;paces5spaces#ornested C spaces#orrest8 <
returnstrin( A returnstrin( C F.#ield IJ04F C #ieldindex.To;trin(5FK6F8 C FJIF <
returnstrin( A returnstrin( C F F C #ield#la(sarra%6#ieldindex7 C #ieldparamarra%6#ieldindex7 C F
F C )ame,eserved5Det;trin(5>ield;truct6#ieldindex7.name88 <
i# 5 #ieldindex B #ield#la(sarra%.3en(th GG #ield#la(sarra%6#ieldindex7 EA null GG
#ield#la(sarra%6#ieldindex7.'ndex/#5FprivatescopeF8 EA P1 8
9
strin( ss A Det;trin(5>ield;truct6#ieldindex7.name8<
i# 5 ss.3en(th AA 1 GG 5b%te8ss607 AA 18
9
returnstrin( A returnstrin(.,emove5returnstrin(.3en(thP1$18<
returnstrin( A returnstrin( C FZ4;T04F C #ieldindex.To;trin(5FK6F8 C FLF<
@
else
returnstrin( A returnstrin( C FZ4;T04F C #ieldindex.To;trin(5FK6F8<
@
strin( #ieldrva A Det>ield,-*5#ieldindex8<
i# 5 #ieldrva EA FF8
returnstrin( A returnstrin( C F atF C #ieldrva<
int len A returnstrin(.3en(th<
+onsole.!rite5returnstrin(8<
Det>ield+onstant-alue5#ieldindex $ len 8<
=ispla%+ustom*ttribute5F>ield=e#F $ #ieldindex $ spaces#ornested C spaces#orrest8<
@
@
IIIII

public void =ispla%*ll:vents5int t%peindex8
9
int ii<
i# 5 :vent0ap;truct AA null 8
return<
#or 5 ii A 1 < ii B :vent0ap;truct.3en(th < iiCC8
9
i# 5 t%peindex AA 5:vent0ap;truct6ii7.index 8 8
brea<
@
i# 5 ii AA :vent0ap;truct.3en(th8
return<
int start A :vent0ap;truct6ii7.eindex<
int end<
i# 5 ii AA :vent0ap;truct.3en(th P1 8
end A :vent;truct.3en(th P 1<
else
end A :vent0ap;truct6ii C 17.eindex P1<
244260235.doc 439 od 541
#or 5 int eventro" A start < eventro" BA end < eventro"CC8
9
+onsole.!rite5+reate;paces5spaces#orrest C spaces#ornested88<
+onsole.!rite5F.event IJ1490@JI 91@F $ 5eventro"8.To;trin(5FK6F8 $
Det4ropert%*ttribute5 :vent;truct6eventro"7.attr88<
strin( name A )ame,eserved5Det;trin(5:vent;truct6eventro"7.name88 <
strin( codedtablename A DetT%pe=e#/r,e#Table5:vent;truct6eventro"7.coded8 <
int codedindex A DetT%pe=e#/r,e#-alue5:vent;truct6eventro"7.coded8<
strin( returnstrin( A FF<
i# 5 codedtablename AA FT%pe,e#F8
returnstrin( A t%pere#names6codedindex7 C F IJ01F C codedindex.To;trin(5FK6F8 C FJIF<
i# 5 codedtablename AA FT%pe=e#F8
returnstrin( A t%pede#names6codedindex7 C F IJ02F C codedindex.To;trin(5FK6F8 C FJIF<
+onsole.!rite5returnstrin(8<
+onsole.!rite5F F C name8 <
+onsole.!rite3ine58<
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F:ventF $ eventro" $ spaces#ornested C spaces#orrestC28<
#or 5 int A 1 < B 0ethod;emantics;truct.3en(th < CC8
9
strin( attributes A
Det0ethod;emantics*ttributes50ethod;emantics;truct67.methodsemanticsattributes8<
strin( table A Det2as;emanticsTable50ethod;emantics;truct67.association8<
int eventindex A Det2as;emantics-alue50ethod;emantics;truct67.association8<
int methodindex A 0ethod;emantics;truct67.methodindex<
strin( methodattribute A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $ methodindex8<
i# 5 eventindex AA eventro" GG table AA F:ventF 8
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ornested88<
+onsole.!rite5F90@ 91@92@F$ attributes $ methodde#t%pearra%6methodindex7$
methodde#returnarra%6methodindex7 8<
strin( name1 A )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88<

+onsole.!rite5F90@MM91@592@8F $ t%pede#names6t%peindex7$ name1 $
methodde#paramarra%16methodindex78<
+onsole.!rite3ine5F IJ 0690@ JIF $ 5methodindex8.To;trin(5FK6F88<
@
@
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@ F8<
+onsole.!rite3ine5FII end o# event 90@MM91@F $
)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 $ name8<
@
@

public strin( Det4ropert%*ttribute=e#ault5int #la(s$ int ro"8
9
strin( returnstrin( A FF<
i# 5 5#la(sG0x10008 AA 0x10008
9
244260235.doc 440 od 541
returnstrin( A =ispla%>rom+onstantsTable5 ro" $ 0 $F4ropert%F8<
returnstrin( A returnstrin(.,emove5returnstrin(.3en(thP2$28<
@
return returnstrin(<
@
public void +reate4ropert%;i(nature 5b%te 67 blobarra% $ int ro"8
9
int aa A P1<
i# 5 ro" AA aa8
9
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
int ho"man%b%tes $ uncompressedb%te<
int index A 0<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
i# 5 5uncompressedb%teG0x208 AA 0x208
propert%t%pearra%6ro"7 A Finstance F<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
int count A uncompressedb%te<
strin( t%pestrin( A FF<
strin( returnstrin( A FF<
returnstrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
propert%returnarra%6ro"7 A returnstrin(<
index A index C ho"man%b%tes<
returnstrin( A FF<
#or 5 int l A 1 < l BA count < lCC8
9
t%pestrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
returnstrin( A returnstrin( C t%pestrin(<
index A index C ho"man%b%tes<
i# 5 l EA count8
returnstrin( A returnstrin( C F$F<
@
propert%parmarra%6ro"7 A returnstrin(<
@
public strin( Det4ropert%*ttribute5int #la(s 8
9
strin( returnstrin( A FF<
i# 5 5#la(sG0x2008 AA 0x200 8
returnstrin( A returnstrin( C Fspecialname F<
i# 5 5#la(sG0x4008 AA 0x400 8
returnstrin( A returnstrin( C Frtspecialname F<
return returnstrin( <
@
public void =ispla%*ll4roperties 5int t%peindex8
9
int ii<
244260235.doc 441 od 541
i# 5 4ropert%0ap;truct AA null TT 4ropert%;truct AA null 8
return<
#or 5 ii A 1 < ii B 4ropert%0ap;truct.3en(th < iiCC8
9
i# 5 t%peindex AA 54ropert%0ap;truct6ii7.parent8 8
brea<
@
i# 5 ii AA 4ropert%0ap;truct.3en(th8
return<
int start A 4ropert%0ap;truct6ii7.propert%list<
int end<
i# 5 iiC1 AA 4ropert%0ap;truct.3en(th 8
end A 4ropert%;truct.3en(th P 1<
else
end A 4ropert%0ap;truct6ii C 17.propert%list P1<
#or 5 int propert%ro" A start < propert%ro" BA end < propert%ro"CC8
9
strin( returnstrin( A +reate;paces5spaces#orrest C spaces#ornested8<
returnstrin( A returnstrin( C F.propert% IJ17F C propert%ro".To;trin(5FK6F8 C FJI F<
strin( name A )ame,eserved5Det;trin(54ropert%;truct6propert%ro"7.name88 <
int #la(s A 4ropert%;truct6propert%ro"7.#la(s<
strin( propert%attribute A Det4ropert%*ttribute5#la(s 8<
returnstrin( A returnstrin( C propert%attribute C propert%t%pearra%6propert%ro"7 C
propert%returnarra%6propert%ro"7 <
i# 5 returnstrin(.3en(th HA 41 8
returnstrin( A returnstrin( C FUrUnF C +reate;paces5spaces#orrest C spaces#ornested8C
+reate;paces578<
returnstrin( A returnstrin( C F F C name C F5F <
int len A returnstrin(.3en(th<
int len1 A returnstrin(.3ast'ndex/#5FUrUnF8<
i# 5 len1 AA P18
len1 A P2<
strin( dumm% A 4aram/n0ultiple3ines5propert%parmarra%6propert%ro"7$ lenPlen1P28<
returnstrin( A returnstrin( C dumm% C F8F<
returnstrin( A returnstrin( C Det4ropert%*ttribute=e#ault5#la(s$ propert%ro"8<
+onsole.!rite3ine5returnstrin(8<
+onsole.!rite3ine5+reate;paces5spaces#orrest C spaces#ornested8 C F9F8<
=ispla%+ustom*ttribute5F4ropert%F $ propert%ro" $ 2 C spaces#orrest C spaces#ornested8<
#or 5 int A 1 < B 0ethod;emantics;truct.3en(th < CC8
9
strin( attributes A
Det0ethod;emantics*ttributes50ethod;emantics;truct67.methodsemanticsattributes8<
strin( table A Det2as;emanticsTable50ethod;emantics;truct67.association8<
int propert%index A Det2as;emantics-alue50ethod;emantics;truct67.association8<
int methodindex A 0ethod;emantics;truct67.methodindex<
strin( methodattribute A Det0ethod*ttribute50ethod;truct6methodindex7.#la(s $ methodindex8<
strin( paramstrin( A methodde#paramarra%16methodindex7<
i# 5 propert%index AA propert%ro" GG table AA F4ropert%F 8
9
strin( dumm%1 A +reate;paces5spaces#orrest C 2 C spaces#ornested8<
244260235.doc 442 od 541
dumm%1 A dumm%1 C attributes C F IJ06F C methodindex.To;trin(5FK6F8 C FJI F C
methodde#t%pearra%6methodindex7 C methodde#returnarra%6methodindex7<

strin( name1 A )ame,eserved5Det;trin(50ethod;truct6methodindex7.name88 C F5F<
strin( dumm%2 A dumm%1 C t%pede#names6t%peindex7 C FMMF C name1<
int dumm%int A dumm%2.'ndex/#5F5F8<
strin( dumm%3 A 4aram/n0ultiple3ines5paramstrin( $ dumm%int C 18 <
dumm%3 A dumm%3 C F8F C F IJ 06F C 5methodindex8.To;trin(5FK6F8 C F JIF<
+onsole.!rite3ine5dumm%2 C dumm%38<
@
@
+onsole.!rite5+reate;paces5spaces#orrest C spaces#ornested88<
+onsole.!rite5F@ F8<
+onsole.!rite3ine5FII end o# propert% 90@MM91@F $
)ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88 $ name8<
@
@
public strin( Det2as;emanticsTable5int asscoiationb%te8
9
strin( returnstrin( A FF<
int ta( A asscoiationb%te G 0x01<
i# 5 ta( AA 0 8
returnstrin( A returnstrin( C F:ventF<
i# 5 ta( AA 1 8
returnstrin( A returnstrin( C F4ropert%F<
return returnstrin(<
@
public strin( Det0ethod;emantics*ttributes5short asscoiationb%te8
9
strin( returnstrin( A FF<
i# 5 5asscoiationb%te G 0x018 AA 0x018
returnstrin( A returnstrin( C F.setF<
i# 5 5asscoiationb%te G 0x028 AA 0x028
returnstrin( A returnstrin( C F.(etF<
i# 5 5asscoiationb%te G 0x048 AA 0x048
returnstrin( A returnstrin( C F.otherF<
i# 5 5asscoiationb%te G 0x088 AA 0x088
returnstrin( A returnstrin( C F.addonF<
i# 5 5asscoiationb%te G 0x108 AA 0x108
returnstrin( A returnstrin( C F.removeonF<
i# 5 5asscoiationb%te G 0x208 AA 0x208
returnstrin( A returnstrin( C F.#ireF<
return returnstrin(<
@
public void +reate0ethod,e#;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F+reate0ethod,e#;i(nature )ameA90@ ro"A91@ b.3en(thA92@F $
Det;trin(50ember,e#;truct6ro"7.name8$ ro"$ blobarra%.3en(th8<
int aa A P1<
i# 5 ro" AA aa8
9
244260235.doc 443 od 541
+onsole.!rite3ine5Fro" number 90@ 91@F $ ro" $ Det;trin(50ember,e#;truct6ro"7.name88<
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
int ho"man%b%tes$uncompressedb%te $ index<
index A 0<
ho"man%b%tesA +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
i# 5 uncompressedb%te AA 0x06 8
9
index A index C ho"man%b%tes<
methodre#returnarra%6ro"7 A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8<
return<
@
methodre#t%pearra%6ro"7 A =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<<
index A index C ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
count A uncompressedb%te<
index A index C ho"man%b%tes<
strin( t%pestrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes$ 0 $ FF8<
methodre#returnarra%6ro"7 A t%pestrin(<
index A index C ho"man%b%tes<
strin( returnstrin( A FF <
methodre#paramarra%16ro"7 A FF<
#or 5 int l A 1 < l BA count < lCC8
9
strin( sentinel A FF<
i# 5 blobarra%6index7 AA 0x418
9
sentinel A F...F C F$F <
index A index C 1<
@
t%pestrin( A sentinel C Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
index A index C ho"man%b%tes<
returnstrin( A returnstrin( C t%pestrin(<
i# 5 l EA count8
returnstrin( A returnstrin( C F$F <
@
i# 5 index B blobarra%.3en(th GG blobarra%6index7 AA 0x418
returnstrin( A returnstrin( C F$...F <
methodre#paramarra%16ro"7 A returnstrin(<
@
public void =ispla%/verride 5int t%pede#index8
9
i# 5 0ethod'mp;truct AA null 8
return<
#or 5 int ii A 1 < ii B 0ethod'mp;truct.3en(th < iiCC8
9
i# 5 t%pede#index AA 0ethod'mp;truct6ii7.classindex 8
9
strin( codede#tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedde# 8<
244260235.doc 444 od 541
int codede#index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedde# 8<
strin( codebod%tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedbod%8<
int codebod%index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedbod% 8<
II+onsole.!rite3ine5F...codede#tablenameA90@ codebod%tablenameA91@ codede#indexA92@
codebod%indexA93@ F$codede#tablename $codebod%tablename$codede#index$codebod%index 8<
i# 5 codebod%tablenameAA F0ethod=e#F8
continue<
strin( #inals A FF<
i# 5 codede#tablename AA F0ethod=e#F 8
9
#inals A +reate;paces5spaces#orrest C spaces#ornested8<
#inals A #inals C F.override F <
int t%pede#methodindex A DetT%pe>or0ethod5codede#index8<
#inals A #inals C )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#methodindex 7.name88 <
#inals A #inals C FIJ 02F C t%pede#methodindex.To;trin(5FK6F8 C F JIMMF<
#inals A #inals C )ame,eserved5Det;trin(50ethod;truct6codede#index7.name88 C F "ithF<
@
else
9
#inals A +reate;paces5spaces#orrest C spaces#ornested8<
#inals A #inals C F.override F <
int t%pere#index A DetT%pe,e#>rom0ethod,e#5codede#index8<
#inals A #inals C t%pere#names6t%pere#index7 C FMMF<
#inals A #inals C )ame,eserved5Det;trin(50ember,e#;truct6codede#index7.name88 C F "ithF<
@
int t%pere#index1 A DetT%pe,e#>rom0ethod,e#5codebod%index8<
#inals A #inals C F F C methodre#t%pearra%6codebod%index7<
#inals A #inals C methodre#returnarra%6codebod%index7 C F F <
#inals A #inals C =ispla%T%pe,e#:xtends5t%pere#index18 C FMMF<
#inals A #inals C )ame,eserved5Det;trin(50ember,e#;truct6codebod%index7.name88 C F5F <
int len A #inals.3en(th<
strin( paramstrin( A 4aram/n0ultiple3ines5methodre#paramarra%16codebod%index7$ len8 <
#inals A #inals C paramstrin( C F8 IJ 0*F C codebod%index.To;trin(5FK6F8 C F JIF<
+onsole.!rite3ine5#inals8<
@
@
@
public void ,eadand=ispla%-Table>ixup58
9
II+onsole.!rite3ine5F........90@F $ 0ethod;truct.3en(th 8<
i# 5 0ethod;truct AA null8
return<
methodvtentr%arra% A ne" int60ethod;truct.3en(th C 17<
#or 5 int 11 A 1 < 11 BA 0ethod;truct.3en(th < 11CC8
methodvtentr%arra%6117 A 0<
i# 5 vtablerva EA 08
9
lon( save <
lon( position A +onvert,-*5vtablerva8 <
i# 5 position AA P18
return<
244260235.doc 445 od 541
m#ilestream.4osition A position<
+onsole.!rite3ine5FII -Table>ixup =irector%MF8<
int count1 A vtablesi&eI8<
vt#ixuparra% A ne" strin(6count17<
datavt#ixuparra% A ne" strin(6count17<
#or 5 int ii A 0 < ii B count1 < iiCC8
9
vt#ixuparra%6ii7 A F.vt#ixup F<
datavt#ixuparra%6ii7 A F.data F<
int #ixuprva A mbinar%reader.,ead'nt3258<
+onsole.!rite3ine5FII '0*D:R+/,R-T*O3:>'KN4690@7MF $ ii8<
+onsole.!rite3ine5FII ,-*M 90@F$#ixuprva.To;trin(5Fx8F88<
short count A mbinar%reader.,ead'nt1658<
+onsole.!rite3ine5FII +ountM 90@F$ count.To;trin(5Fx4F88<
short t%pe A mbinar%reader.,ead'nt1658<
+onsole.!rite3ine5FII T%peM 90@F$ t%pe.To;trin(5Fx4F88<
save A m#ilestream.4osition<
m#ilestream.4osition A +onvert,-*5#ixuprva8 <
int i1 <
lon( 67 val A ne" lon(6count7 <
#or 5 i1 A 0 < i1 B count < i1CC8
9
i# 5 5t%peG0x018 AA 0x018
val6i17 A mbinar%reader.,ead'nt3258<
i# 5 5t%peG0x028 AA 0x028
val6i17 A mbinar%reader.,ead'nt6458<
i# 5 5t%peG0x018 AA 0x01 8
+onsole.!rite3ine5FII 690@7 591@8F$i1.To;trin(5Fx4F8 $ val6i17.To;trin(5FK8F88<
i# 5 5t%peG0x028 AA 0x028
+onsole.!rite3ine5FII 690@7 5 91@8F$i1.To;trin(5Fx4F8 $
5val6i17G0x########8.To;trin(5FKF88<
@
m#ilestream.4osition A save<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F6F C 5i18.To;trin(5FKF8 C F7 F<
i# 5 5t%peG0x018 AA 0x018
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fint32 F<
i# 5 5t%peG0x028 AA 0x028
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fint64 F<
i# 5 5t%peG0x048 AA 0x048
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F#romunmana(ed F<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C Fat =RF C #ixuprva.To;trin(5FK8F8<
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F IIF<
#or 5 i1 A 0 < i1 B count < i1CC8
9
i# 5 5t%peG0x018 AA 0x018
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F F C val6i17.To;trin(5FK8F8<
i# 5 5t%peG0x028 AA 0x028
vt#ixuparra%6ii7 A vt#ixuparra%6ii7 C F F C val6i17.To;trin(5FK16F8<
@
lon( index A 0<
i# 5 val EA null8
244260235.doc 446 od 541
index A val607 G 0x######<
methodvtentr%arra%6iiC17 A 5int8index<
IJ
datavt#ixuparra%6ii7 A datavt#ixuparra%6ii7 C F=RF C #ixuprva.To;trin(5FK8F8 C F A b%tearra%
5UrUnF <
strin( dumm% A FF<
datavt#ixuparra%6ii7 A datavt#ixuparra%6ii7 C +reate;paces5178<
#or 5 int 11 A 0 < 11 BA 3< 11CC8
9
lon( value A 5val607 HH 11J88G0x##<
dumm%A dumm% C value.To;trin(5FK2F8 <
i# 5 11 EA 38
dumm% A dumm% C F F<
@
datavt#ixuparra%6ii7 A datavt#ixuparra%6ii7 C dumm% C F8 F<
JI
@
+onsole.!rite3ine58<
@

@
public void =ispal%-t>ixup58
9
i# 5vt#ixuparra% AA null8
return<
#or 5 int ii A 0 < ii B vt#ixuparra%.3en(th < iiCC8
+onsole.!rite3ine5vt#ixuparra%6ii78<
@
public strin( Det-tentr%;trin( 5int methodro"8
9
strin( returnstrin( AFF<
int A Det-tentr%'nte(er5methodro"8<
i# 5 HA 18
returnstrin( A +reate;paces5spaces#orrestC28 C F.vtentr% F C .To;trin(58 C F M 1F C FUrUnF <
return returnstrin(<
@
public int Det-tentr%'nte(er 5int methodro"8
9
int ii <
#or 5 ii A 1 < ii B methodvtentr%arra%.3en(thP1 < iiCC8
9
i# 5 methodvtentr%arra%6ii7 AA methodro"8
brea<
@
i# 5 methodvtentr%arra%6ii7 AA 08
return 0<
else
return ii<
@

public strin( Det*rra%T%pe 5b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
244260235.doc 447 od 541
9
strin( returnstrin( <
int total A 1<
int uncompressedb%te<
int ran<
int numsi&es<
int ho"man%b%tes1<
returnstrin( A Det:lementT%pe5index C1 $ blobarra% $ out ho"man%b%tes $0 $ FF8<
total A total C ho"man%b%tes<
returnstrin( A returnstrin( C F6F<
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
ran A uncompressedb%te<
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
numsi&es A uncompressedb%te<
int 67 si&earra% A ne" int6numsi&es7<
#or 5 int l A 1 < l BA numsi&es < lCC8
9
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
si&earra%6lP17 A uncompressedb%te<
@
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
int bounds A uncompressedb%te<
int 67 boundsarra% A ne" int6bounds7<
II+onsole.!rite3ine5F.....ranA90@ numsi&esA91@ boundsA92@ F $ ran$ numsi&es$bounds8<
i# 5 ran EA 0 GG bounds AA 0 GG numsi&es AA 08
9
#or 5 int i A 1 < i B ran < iCC8
returnstrin( A returnstrin( C F`F<
returnstrin( A returnstrin( C F7F<
ho"man%b%tes A ho"man%b%tes C ranC1<
return returnstrin(<
@
int dots A 0<
#or 5 int l A 1 < l BA bounds < lCC8
9
ho"man%b%tes1 A +or;i(Nncompress=ata5blobarra% $ index C total$ out uncompressedb%te8<
total A total C ho"man%b%tes1<
int ul;i(ned A uncompressedb%te G 0x1<
uncompressedb%te A uncompressedb%te HH 1<
boundsarra%6lP17 A uncompressedb%te <
@
i# 5 numsi&es AA 08
9
#or 5 int l A 0 < l B bounds < lCC8
9
returnstrin( A returnstrin( C boundsarra%6l7 C F...F <
i# 5 l EA 5boundsP18 8
244260235.doc 448 od 541
returnstrin( A returnstrin( C F`F<
@
@
else
9
#or 5 int l A 0 < l B bounds < lCC8
9
i# 5 l B numsi&es 8
9
int upper A boundsarra%6l7 C si&earra%6l7 P 1 <
i# 5 boundsarra%6l7 AA 0 GG si&earra%6l7 EA 0 8
returnstrin( A returnstrin( C si&earra%6l7 <
i# 5boundsarra%6l7 AA 0 GG si&earra%6l7 AA 08
returnstrin( A returnstrin( C F0F <
else i# 5boundsarra%6l7 EA 0 GG si&earra%6l7 EA 08
returnstrin( A returnstrin( C boundsarra%6l7 C F...F C upper.To;trin(58 <
else i# 5boundsarra%6l7 EA 0 GG si&earra%6l7 AA 08
returnstrin( A returnstrin( C boundsarra%6l7 C F...F <
@
else
9
dotsCC<
returnstrin( A returnstrin( C boundsarra%6l7 C F...F <
@
i# 5 l EA bounds P 1 8
returnstrin( A returnstrin( C F`F<
@
@
i# 5 numsi&es EA 08 II method a6
9
int le#tover A ran P numsi&es P dots <
#or 5 int l A 1 < l BA le#tover < lCC8
returnstrin( A returnstrin( C F`F<
@
returnstrin( A returnstrin( C F7F<
ho"man%b%tes A totalP1<
return returnstrin(<
@
public strin( 4aram/n0ultiple3ines 5strin( paramstrin( $ int spaces8
9
i# 5 paramstrin( AA FF8
return FF<
i# 5 paramstrin( AA null8
return FF<
strin( returnstrin( A FF<
i# 5 paramstrin(.'ndex/#5F$F8 AA P1 8
9
paramstrin( A paramstrin(.,eplace5F`F $ F$F8<
return paramstrin(<
@
char 67 chararra% A 9L$L@<
244260235.doc 449 od 541
strin( 67 strin(arra% A paramstrin(.;plit5chararra%8<
returnstrin( A strin(arra%607 C F$F<
#or 5 int ii A 1 < ii B strin(arra%.3en(th < iiCC8
9
returnstrin( A returnstrin( C FUrUnF C +reate;paces5spaces8 C strin(arra%6ii7 <
i# 5 ii EA strin(arra%.3en(th P1 8
returnstrin( A returnstrin( C F$F<
@
returnstrin( A returnstrin(.,eplace5F`F $ F$F8<
return returnstrin(<
@
public int 2o"0an%0ethod*ttributes5strin( methodattribute8
9
int count A 0<
i# 5 methodattribute.'ndex/#5Fhideb%si(F8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5Fne"slotF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FspecialnameF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FrtspecialnameF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5F#inalF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FvirtualF8 EA P18
countCC<
i# 5 methodattribute.'ndex/#5FabstractF8 EA P18
countCC<
return count<
@
public void +reate0ethod=e#;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F+reate0ethod=e#;i(nature *rra% 3en(thA90@ method ro"A91@
nameA92@F $ blobarra%.3en(th $ ro" $ Det;trin(50ethod;truct6ro"7.name88<
int ho"man%b%tes$uncompressedb%te $ count $ index<
index A 0<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
methodde#t%pearra%6ro"7 A =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<
index A index C ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
count A uncompressedb%te<
methodde#paramcount6ro"7 A count<
index A index C ho"man%b%tes<
strin( returnt%pestrin( A FF<
returnt%pestrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ro" $ F0ethodF8 C F
F<
returnt%pestrin( A returnt%pestrin(.,eplace5F`F$F$F8<
index A index C ho"man%b%tes<
methodde#returnarra%6ro"7 A returnt%pestrin(<
strin( returnstrin(1 A FF <
strin( returnstrin(2 A FF<
244260235.doc 450 od 541
strin( t%pestrin( A FF<
#or 5 int l A 1 < l BA count < lCC8
9
t%pestrin( A Det:lementT%pe5 index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8 <
index A index C ho"man%b%tes<
returnstrin(2 A returnstrin(2 C t%pestrin( <
i# 5 l EA count8
returnstrin(2 A returnstrin(2 C F$F<
int ind A Det4aram,o")umber5ro"$ l 8<
strin( paramcallin( A Det4aram*ttr#or4aram+allin(5ind8<
strin( parammarshal A Det4aram*ttr#or4aram0arshal5ind $ 1 8 <
returnstrin(1 A returnstrin(1 C paramcallin( <
returnstrin(1 A returnstrin(1 C t%pestrin( C F F <
returnstrin(1 A returnstrin(1 C parammarshal <
returnstrin(1 A returnstrin(1 C Det4aram)ame>or0ethod5 ro" $ count $ l8<
i# 5 l EA count8
returnstrin(1 A returnstrin(1 C F$F <
methodde#paramarra%6ro"7 A returnstrin(1<
methodde#paramarra%16ro"7 A returnstrin(2<
@
@
int Det4aram,o")umber5 int ro" $ int l 8
9
i# 5 0ethod;truct AA null TT 4aram;truct AA null8
return 0<
int start A 0ethod;truct6ro"7.param <
int end A 0<

i# 5 ro" AA 50ethod;truct.3en(th P18 8
end A 4aram;truct.3en(th<
else
end A 0ethod;truct6ro"C17.param<
endPP<
int i<
#or 5 i A start < i BA end < iCC8
9
i# 5 4aram;truct6i7.se.uence AA l8
return i<
@
return 0<
@
public strin( Det4aram*ttr#or4aram0arshal 5int paramindex $ int tablet%pe8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null 8
return FF<
i# 5paramindex HA 4aram;truct.3en(th 8
return FF<
int pattr A 4aram;truct6paramindex7.pattr<
returnstrin( A =ecode4aram*ttributes 5 pattr $ tablet%pe $ paramindex $ 0x20008<
return returnstrin(<
244260235.doc 451 od 541
@
public strin( Det0od/pt/r0od,e. 5 int index $ b%te 67 blobarra% $ out int b%testaen8
9
strin( returnstrin( A FF<
b%testaen A 0<
int "hileindex A index<
i# 5 blobarra%6index7 AA 0x20 TT blobarra%6index7 AA 0x1#8
9
"hile 5 true 8
9
int noo#b%tes<
strin( toens A DetToenT%pe5blobarra% $ "hileindex $ out noo#b%tes8 <
i# 5 blobarra%6"hileindex7 AA 0x208
toens A Fmodopt5F C toens C F8F<
i# 5 blobarra%6"hileindex7 AA 0x1#8
toens A Fmodre.5F C toens C F8F<
b%testaen A b%testaen C noo#b%tes C 1<
returnstrin( A toens C F F C returnstrin( <
"hileindex A "hileindex C noo#b%tes C 1<
i# 5 E5blobarra%6"hileindex7 AA 0x20 TT blobarra%6"hileindex7 AA 0x1#8 8
brea<
@
@
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin(.,emove5returnstrin(.3en(thP1$18<
return returnstrin(<
@
public strin( Det:lementT%pe 5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes $ int ro" $
strin( name8
9
ho"man%b%tes A 0<
strin( returnstrin( A FF<
strin( modoptstrin( A FF<
int b%testaen<
modoptstrin( A Det0od/pt/r0od,e.5 index $ blobarra% $ out b%testaen8<
index A index C b%testaen<
b%te t%pe A blobarra%6index7<
i# 5 t%pe HA 0x01 GG t%pe BA 0x0e 8
9
returnstrin( A DetT%pe5t%pe8<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x0#8
9
returnstrin( A Det4ointerToen5index$ blobarra% $ out ho"man%b%tes8<
@
else i# 5 t%pe AA 0x108
9
returnstrin( A DetO%re#Toen5index$ blobarra% $ out ho"man%b%tes8<
@
else i# 5 t%pe AA 0x11 TT t%pe AA 0x12 8
244260235.doc 452 od 541
9
int ho"man%b%tes2<
returnstrin( A DetToenT%pe5 blobarra% $ index $ out ho"man%b%tes28<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
else i# 5 t%pe AA 0x13 8
9
returnstrin( A FEF C blobarra%6indexC17.To;trin(58<
ho"man%b%tes A 2<
@
else i# 5 t%pe AA 0x14 8
9
int ho"man%b%tes2<
returnstrin( A Det*rra%T%pe5 blobarra% $ index $ out ho"man%b%tes28<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
else i# 5 t%pe AA 0x15 TT t%pe AA 0x17 TT t%pe AA 0x1e TT t%pe AA 0x21 8
9
returnstrin( A FIJ N)\)/!) TW4: 50xF C t%pe.To;trin(5FKF8 C F8JIF<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x168
9
returnstrin( A Ft%pedre#F<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x188
9
returnstrin( A Fnative intF<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x198
9
returnstrin( A Fnative unsi(ned intF<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x1a8
9
returnstrin( A Fnative #loatF<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x1c8
9
returnstrin( A Fob1ectF<
ho"man%b%tes A 1<
@
else i# 5 t%pe AA 0x1d8
9
returnstrin( A Det;&*rra%5index $ blobarra% $ out ho"man%b%tes8<
@
else i# 5 t%pe AA 0x45 8
244260235.doc 453 od 541
9
int ho"man%b%tes2 <
returnstrin( A Det:lementT%pe5 index C 1 $ blobarra% $ out ho"man%b%tes2 $ 0 $ FF8 C F pinnedF<
ho"man%b%tes A ho"man%b%tes2 C 1<
@
else i# 5 t%pe AA 0x1b8
9
int ho"man%b%tes2 <
returnstrin( A Det4ointerTo>unction;i(nature5 index $ blobarra% $ out ho"man%b%tes2 $ re#
modoptstrin( $ ro" $ name8 <
modoptstrin( A FF<
ho"man%b%tes A ho"man%b%tes2 <
@
ho"man%b%tes A ho"man%b%tes C b%testaen<
i# 5 modoptstrin( EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(<
return returnstrin( <
@
public strin( Det4ointerTo>unction;i(nature5 int index $ b%te 67 blobarra% $ out int ho"man%b%tes
$ re# strin( modoptstrin($ int ro" $ strin( name8
9
int uncompressedb%te<
index A index C 1<
int nob%tes <
int totalb%tes A 1<
strin( returnstrin( A FF<
nob%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
i# 5 ro" EA 0 GG name AA F0ethodF8
9
methodde#t%pearra%6ro"7 A =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<
methodde#t%pearra%6ro"7 A Fmethod F C methodde#t%pearra%6ro"7<
@
else
returnstrin( A Fmethod F C =ecode>irstO%teo#0ethod;i(nature5uncompressedb%te $ ro"8<
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
nob%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
int noo#t%pes A uncompressedb%te<
int b%testaen1<
strin( modoptstrin(1 A Det0od/pt/r0od,e.5 index $ blobarra% $ out b%testaen18<
index A index C b%testaen1<
totalb%tes A totalb%tes C b%testaen1<
returnstrin( A returnstrin( C Det:lementT%pe5index $ blobarra% $ out nob%tes $ 0 $ FF8 <
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
i# 5 modoptstrin(1 EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(1 <
returnstrin( A returnstrin( C F J5F<
i# 5 noo#t%pes AA 08
244260235.doc 454 od 541
returnstrin( A returnstrin( C F8F<
else
#or 5 int i A 1< i BA noo#t%pes < iCC8
9
returnstrin( A returnstrin( C Det:lementT%pe5index $ blobarra% $ out nob%tes $0 $ FF8<
i# 5 i EA noo#t%pes8
returnstrin( A returnstrin( C F$F<
else
returnstrin( A returnstrin( C F8F<
index A index C nob%tes<
totalb%tes A totalb%tes C nob%tes<
@
i# 5 modoptstrin( EA FF8
returnstrin( A returnstrin( C F F C modoptstrin(<
ho"man%b%tes A totalb%tes<
return returnstrin(<
@
public strin( DetTable,e#)ame>or>ill*rra%5 int tablero" $ int t%pero" $ strin( tablename8
9
strin( nameandnamespace A FF<
i# 5 tablename AA F*ssembl%,e#F8
nameandnamespace A )ame,eserved5Det;trin(5*ssembl%,e#;truct6tablero"7.name88 <
i# 5 tablename AA F0odule,e#F8
nameandnamespace A F.module F C
)ame,eserved5Det;trin(50odule,e#;truct6tablero"7.name88 <
strin( strin(namespace A )ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.nspace88 <
strin( strin(nested A FF<
i# 5 strin(namespace EA FF8
strin(namespace A strin(namespace C F.F<
i# 5 tablename AA F*ssembl%,e#F8
strin(nested A F6F C nameandnamespace C FIJ 23F C tablero".To;trin(5FK6F8 C F JI7F C
strin(namespace C )ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.name88<
i# 5 tablename AA F0odule,e#F8
strin(nested A F6F C nameandnamespace C FIJ 1*F C tablero".To;trin(5FK6F8 C F JI7F C
strin(namespace C )ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.name88<
i# 5 tablename AA F0oduleF8
strin(nested A strin(nested C strin(namespace C
)ame,eserved5Det;trin(5T%pe,e#;truct6t%pero"7.name88<
strin(nested A strin(nested C FIJ 01F C t%pero".To;trin(5FK6F8 C F JIIF <
return strin(nested<
@
public strin( DetT%pe,e#>or>illarra%5int 8
9
strin( strin(namespace A )ame,eserved5Det;trin(5T%pe,e#;truct67.nspace88 <
i# 5 strin(namespace EA FF8
strin(namespaceA strin(namespace C F.F<
strin( strin(nested A strin(namespace C )ame,eserved5Det;trin(5T%pe,e#;truct67.name88 <
strin(nested A strin(nested C FIJ 01F C .To;trin(5FK6F8 C F JIF <
return strin(nested<
@
public void >ill*rra% 58
244260235.doc 455 od 541
9
int old A tableo##set<
bool tablehasro"s A tablepresent588<
int o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
paramnames A ne" strin(6ro"s687 C 17<
#or 5 int A 1 < BA ro"s687 < CC8
9
short pattr A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
int se.uence A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
int name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
strin( dumm% A Det;trin(5name8<
paramnames67 A )ame,eserved5dumm%8<
@
@
old A tableo##set<
tablehasro"s A tablepresent518<
o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
t%pere#names A ne" strin(6ro"s617C17<
#or 5 int A 1 < BA ro"s617 < CC8
9
short resolutionscope A Oit+onverter.To'nt16 5metadata $ o##s8<
o##s A o##s C 2<
int name A ,ead;trin('ndex5metadata $ o##s8<
o##s A o##s C o##setstrin(<
int nspace A ,ead;trin('ndex5metadata $ o##s8<
o##s A o##s C o##setstrin(<
strin( strin(name A )ame,eserved5Det;trin(5name88<
strin( strin(t%pe#minusnested A Det;trin(5nspace8 <
i# 5 strin(t%pe#minusnested .3en(th EA 08
strin(t%pe#minusnested A strin(t%pe#minusnested C F.F<
strin(t%pe#minusnested A strin(t%pe#minusnested C strin(name<
strin( strin(nested A FF<
strin( resolutioncodedtable A Det,esolution;copeTable5resolutionscope 8<
int resolutionro" A Det,esolution;cope-alue5resolutionscope 8<
i# 5 resolutioncodedtable AA F0oduleF8
9
strin(t%pe#minusnested A strin(t%pe#minusnested C FIJ 01F C .To;trin(5FK6F8 C F JIF<
@
i# 5 resolutioncodedtable AA F*ssembl%,e#F8
9
strin(nested A F6F C )ame,eserved5Det;trin(5*ssembl%,e#;truct6resolutionro"7.name88 C FIJ
23F C resolutionro".To;trin(5FK6F8 C F JI7F<
244260235.doc 456 od 541
strin(t%pe#minusnested A strin(t%pe#minusnested C FIJ 01F C .To;trin(5FK6F8 C F JIF<
@
i# 5 resolutioncodedtable AA F0odule,e#F8
9
strin(nested A F6.module F C )ame,eserved5Det;trin(50odule,e#;truct6resolutionro"7.name88
C FIJ 1*F C resolutionro".To;trin(5Fx6F8 C F JI7F<
strin(t%pe#minusnested A strin(t%pe#minusnested C FIJ 01F C .To;trin(5FK6F8 C F JIF<
@
i# 5 resolutioncodedtable AA FT%pe,e#F 8
9
strin( resolutioncodedtable1 A
Det,esolution;copeTable5T%pe,e#;truct6resolutionro"7.resolutionscope 8<
int resolutionro"1 A Det,esolution;cope-alue5T%pe,e#;truct6resolutionro"7.resolutionscope 8<
i# 5 resolutioncodedtable1 AA F*ssembl%,e#F TT resolutioncodedtable1 AA F0odule,e#F TT
resolutioncodedtable1 AA F0oduleF8
9
strin(nested A DetTable,e#)ame>or>ill*rra%5resolutionro"1 $ resolutionro" $
resolutioncodedtable18<
strin(nested A strin(nested C DetT%pe,e#>or>illarra%58<
strin(t%pe#minusnested A FF<
@
else
9
strin( tablename A Det,esolution;copeTable5T%pe,e#;truct67.resolutionscope 8<
int ro" A Det,esolution;cope-alue5T%pe,e#;truct67.resolutionscope 8<
int cnt A 0<
"hile 5 tablename AA FT%pe,e#F8
9
ro" A Det,esolution;cope-alue5T%pe,e#;truct6ro"7.resolutionscope 8<
tablename A Det,esolution;copeTable5T%pe,e#;truct6ro"7.resolutionscope 8<
cntCC<
@
int i A 0<
int 67 t%pero"s A ne" int6cnt7<
strin( tablename1 A Det,esolution;copeTable5T%pe,e#;truct67.resolutionscope 8<
int ro"1 A Det,esolution;cope-alue5T%pe,e#;truct67.resolutionscope 8<
"hile 5 i B cnt 8
9
ro"1 A Det,esolution;cope-alue5T%pe,e#;truct6ro"17.resolutionscope 8<
tablename1 A Det,esolution;copeTable5T%pe,e#;truct6ro"17.resolutionscope 8<
t%pero"s6i7 A ro"1<
iCC<
@

int assembl%ro" A Det,esolution;cope-alue5T%pe,e#;truct6ro"7.resolutionscope 8<
int t%pero" A t%pero"s6t%pero"s.3en(thP17<
strin(nested A DetTable,e#)ame>or>ill*rra%5 assembl%ro" $ t%pero" $ tablename8<

i A 0<
strin( dumm% A FF<
"hile 5 i B cntP1 8
244260235.doc 457 od 541
9
dumm% A DetT%pe,e#>or>illarra%5t%pero"s6i78 C FIF C dumm%<
iCC<
@
strin(nested A strin(nested C dumm%<
strin(nested A strin(nested C DetT%pe,e#>or>illarra%5resolutionro"8<
strin(nested A strin(nested C FIF C DetT%pe,e#>or>illarra%58<
strin(t%pe#minusnested A FF<
@
@
t%pere#names67 A strin(nested C strin(t%pe#minusnested <
II+onsole.!rite3ine5F.......90@ 91@ 92@F $ resolutioncodedtable $ t%pere#names67 $ 8<
@
@
old A tableo##set<
tablehasro"s A tablepresent528<
o##s A tableo##set<
tableo##set A old<
i# 5 tablehasro"s 8
9
t%pede#names A ne" strin(6ro"s627C17<
#or 5 int A 1 < BA ro"s627 < CC8
9
int name A T%pe=e#;truct67.name<
o##s CA o##setstrin(<
int nspace A T%pe=e#;truct67.nspace<
o##s CA o##setstrin(<
strin( nestedt%pestrin( A FF<
nestedt%pestrin( A Det)estedT%pe*s;trin(58<
strin( namestrin( A Det;trin(5name8<
strin( namespacestrin( A )ame,eserved5Det;trin(5nspace88<
i# 5 namespacestrin(.3en(th EA 08
namespacestrin( A namespacestrin( C F.F<
namestrin( A )ame,eserved5namestrin( 8<
t%pede#names67 A nestedt%pestrin( C namespacestrin( C namestrin( C FIJ 02F C
.To;trin(5FK6F8 C F JIF<
@
@
@
public strin( =ecodeToen 5int toen $ int t%pe8
9
b%te tablet%pe A 5b%te85toen G 0x038<
int tableindex A toen HH 2<
strin( returnstrin( A FF<
II+onsole.!rite3ine5F.......tablet%peA90@ 91@ 92@F $ tablet%pe $ tableindex $
t%pere#names.3en(th8<
i# 5 tablet%pe AA 08
returnstrin( A t%pede#names6tableindex7<
i# 5 tablet%pe AA 1 8
returnstrin( A t%pere#names6tableindex7 <
return returnstrin(<
244260235.doc 458 od 541
@
public strin( =ecode>irstO%teo#0ethod;i(nature 5int #irstb%te $ int methodro"8
9
strin( returnstrin( A FF<
II+onsole.!rite3ine5F.....90@F $ #irstb%te.To;trin(5FKF88<
i# 5 5#irstb%teG 0x20 8 AA 0x20 8
returnstrin( A Finstance F<
i# 5 5#irstb%te G 0x60 8 AA 0x60 8
returnstrin( A Fexplicit instance F<
int #irstbits A #irstb%te G 0x#<
i# 5 #irstbits AA 0x02 8
returnstrin( A returnstrin( C Funmana(ed stdcall F<
else i# 5 #irstbits AA 0x03 8
returnstrin( A returnstrin( C Funmana(ed thiscall F<
else i# 5 #irstbits AA 0x05 8
returnstrin( A returnstrin( C Fvarar( F<
else i# 5 #irstbits AA 0x01 8
returnstrin( A returnstrin( C Funmana(ed cdecl F<
else i# 5 #irstbits AA 0x04 8
returnstrin( A returnstrin( C Funmana(ed #astcall F<
return returnstrin(<
@
public strin( =ecode4aram*ttributes5int pattr $ int tablet%pe $ int start $ int b%temas8
9
strin( returnstrin( A FF<
i# 5 5pattr G b%temas8 AA b%temas8
9
int ii <
#or 5 ii A 1 < ii BA >ield0arshal;truct.3en(th < iiCC8
9
int coded A >ield0arshal;truct6ii7.coded<
int table A >ield0arshal;truct6ii7.coded G 0x01<
coded A coded HH 1<
i# 5 coded AA start GG tablet%pe AA table8
brea<
@
int blobindex A >ield0arshal;truct6ii7.index<
int len(th $ ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ blobindex$ out len(th8<
II+onsole.!rite3ine5F90@ 91@ 92@ 93@F $blob6blobindex7.To;trin(5FKF8 $
blob6blobindexC17.To;trin(5FKF8$blob6blobindexC27.To;trin(5FKF8$blob6blobindexC37.To;trin(5
FKF8 8<
int blobvalue A blob6blobindexCho"man%b%tes7<
strin( ss1 A Det0arshallT%pe5blob6blobindexCho"man%b%tes7 $ ho"man%b%tes $ blobindex8<
i# 5 ss1 AA F67F TT ss1.'ndex/#5F6 C F8 EA P1 TT ss1 AA FF TT 5 ss1.3en(th HA 2 GG ss1607 AA L6L GG
ss16ss1.3en(thP17 AA L7L 88
returnstrin( A F marshal5F C ss1<
else
returnstrin( A F marshal5 F C ss1<

returnstrin( A returnstrin( C F8F<
244260235.doc 459 od 541
@
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin( C F F<
return returnstrin( <
@
public strin( Det0arshallT%pe 5b%te marshal#la(s $ int ho"man%b%tes $ int blobindex8
9
II+onsole.!rite3ine5F...90@ 91@ 92@ 93@ 94@F $blob6blobindex7 $
blob6blobindexC17.To;trin(5FKF8$ blob6blobindexC27.To;trin(5FKF8$
blob6blobindexC37.To;trin(5FKF8 $ blob6blobindexC47.To;trin(5FKF8 8<
II+onsole.!rite3ine5F.........90@F $ marshal#la(s.To;trin(5FKF88<
i# 5 blob6blobindex7 AA 08
return FF<
i# 5 marshal#la(s AA 0x018
return FvoidF<
i# 5 marshal#la(s AA 0x028
return FboolF<
i# 5 marshal#la(s AA 0x038
return Fint8F<
i# 5 marshal#la(s AA 0x048
return Funsi(ned int8F<
i# 5 marshal#la(s AA 0x058
return Fint16F<
i# 5 marshal#la(s AA 0x068
return Funsi(ned int16F<
i# 5 marshal#la(s AA 0x078
return Fint32F<
i# 5 marshal#la(s AA 0x088
return Funsi(ned int32F<
i# 5 marshal#la(s AA 0x098
return Fint64F<
i# 5 marshal#la(s AA 0x0a8
return Funsi(ned int64F<
i# 5 marshal#la(s AA 0x0b8
return F#loat32F<
i# 5 marshal#la(s AA 0x0c8
return F#loat64F<
i# 5 marshal#la(s AA 0x0=8
return Fs%scharF<
i# 5 marshal#la(s AA 0x0e8
return FvariantF<
i# 5 marshal#la(s AA 0x0#8
return Fcurrenc%F<
i# 5 marshal#la(s AA 0x108
return FJF<
i# 5 marshal#la(s AA 0x118
return FdecimalF<
i# 5 marshal#la(s AA 0x128
return FdateF<
i# 5 marshal#la(s AA 0x138
return FbstrF<
244260235.doc 460 od 541
i# 5 marshal#la(s AA 0x148
return FlpstrF<
i# 5 marshal#la(s AA 0x158
return Flp"strF<
i# 5 marshal#la(s AA 0x168
return FlptstrF<
i# 5 marshal#la(s AA 0x178
9
int uncompressedb%te<
+or;i(Nncompress=ata5blob $ blobindexCho"man%b%tesC1 $ out uncompressedb%te8<
return F#ixed s%sstrin( 6F C uncompressedb%te.To;trin(58 C F7F<
@
i# 5 marshal#la(s AA 0x188
return Fob1ectre#F<
i# 5 marshal#la(s AA 0x198
return Fiunno"nF<
i# 5 marshal#la(s AA 0x1a8
return FidispatchF<
i# 5 marshal#la(s AA 0x1b8
return FstructF<
i# 5 marshal#la(s AA 0x1c8
return Finter#aceF<
i# 5 marshal#la(s AA 0x1d8
9
strin( returnstrin( A Fsa#earra%F<
i# 5 blob6blobindex7 H 18
9
strin( dumm% A Det;a#e*rra%T%pe5blob6blobindexCho"man%b%tesC178<
i# 5 dumm% EA FF8
returnstrin( A returnstrin( C F F C dumm%<
@
int len A blob6blobindex7 P 3<
i# 5 len H 08
9
returnstrin( A returnstrin( C F$ UFF <
#or 5 int iii A 0 < iii B len < iiiCC8
returnstrin( A returnstrin( C 5char8blob6blobindexCiiiCho"man%b%tesC37 <
returnstrin( A returnstrin( C FUFF <
@
return returnstrin(<
@
i# 5 marshal#la(s AA 0x1e8
9
int uncompressedb%te<
+or;i(Nncompress=ata5blob $ blobindexCho"man%b%tesC1 $ out uncompressedb%te8<
return F#ixed arra% 6F C uncompressedb%te.To;trin(58 C F7F<
@
i# 5 marshal#la(s AA 0x1#8
return FintF<
i# 5 marshal#la(s AA 0x208
return Funsi(ned intF<
244260235.doc 461 od 541
i# 5 marshal#la(s AA 0x218
return Fnested structF<
i# 5 marshal#la(s AA 0x228
return Fb%valstrF<
i# 5 marshal#la(s AA 0x238
return Fansi bstrF<
i# 5 marshal#la(s AA 0x248
return FtbstrF<
i# 5 marshal#la(s AA 0x258
return Fvariant boolF<
i# 5 marshal#la(s AA 0x268
return FmethodF<
i# 5 marshal#la(s AA 0x278
return FF<
i# 5 marshal#la(s AA 0x288
return Fas an%F<
i# 5 marshal#la(s AA 0x298
return FF<
i# 5 marshal#la(s AA 0x2a8
9
II+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $blob6blobindex7.To;trin(5FKF8 $
blob6blobindexC17.To;trin(5FKF8$blob6blobindexC27.To;trin(5FKF8$blob6blobindexC37.To;trin(5
FKF8 $blob6blobindexC47.To;trin(5FKF8$blob6blobindexC57.To;trin(5FKF8
$blob6blobindexC67.To;trin(5FKF8 $blob6blobindexC77.To;trin(5FKF8 8<
IJ
#or 5 int i A 0 < i BA blob6blobindex7 < iCC8
+onsole.!rite5F90@ F $ blob6blobindexCi7.To;trin(5FKF88<
+onsole.!rite3ine58<
JI
strin( returnstrin( A FF<
strin( arra%s A F67F<
strin( dumm%1 A FF<
i# 5 blob6blobindex7 AA 38
9
dumm%1 A F F<
arra%s A F6 C F C blob6blobindexC2Cho"man%b%tes7.To;trin(58 C F7F<
@
i# 5 blob6blobindex7 AA 48
9
dumm%1 A FF<
i# 5 blob6blobindexC2Cho"man%b%tes7 EA 08
arra%s A F6F C blob6blobindexC3Cho"man%b%tes7.To;trin(58 C F C F C
blob6blobindexC2Cho"man%b%tes7.To;trin(58 C F7F<
else
arra%s A F6F C blob6blobindexC3Cho"man%b%tes7.To;trin(58 C F7F<
@
i# 5 blob6blobindex7 HA 78
9
int ho"man%t%pes A blob6blobindex7I3<
returnstrin( A Det0arshallT%pe5blob6blobindexCho"man%b%tesCho"man%t%pes7
$ho"man%b%tes $ blobindex8<
244260235.doc 462 od 541
i# 5 blob6blobindexC1Cho"man%b%tesCho"man%t%pes7 EA 08
arra%s A F6F C blob6blobindexC2Cho"man%b%tesCho"man%t%pes7.To;trin(58 C F C F C
blob6blobindexC1Cho"man%b%tesCho"man%t%pes7.To;trin(58 C F7F<
else
arra%s A F6F C blob6blobindexC2Cho"man%b%tesCho"man%t%pes7.To;trin(58 C F7F<
returnstrin( A returnstrin( C arra%s <
#or 5 int i A 1 < i B ho"man%t%pes < iCC8
9
i# 5 blob6blobindexCho"man%b%tesCho"man%t%pesCiJ2C27 AA 08
returnstrin( A returnstrin( C F F C
Det0arshallT%pe5blob6blobindexCho"man%b%tesCho"man%t%pesCiJ2C17 $ho"man%b%tes $
blobindex8<
else
returnstrin( A returnstrin( C F F C
Det0arshallT%pe5blob6blobindexCho"man%b%tesCho"man%t%pesCiJ2C27 $ho"man%b%tes $
blobindex8<
@
return returnstrin(<
@
i# 5 blob6blobindexCho"man%b%tesC17 AA 0x508
returnstrin( A arra%s<
else
returnstrin( A dumm%1 C Det0arshallT%pe5blob6blobindexCho"man%b%tesC17 $ho"man%b%tes $
blobindex8 C arra%s<
return returnstrin(<
@
i# 5 marshal#la(s AA 0x2b8
return FlpstructF<
i# 5 marshal#la(s AA 0x2c8
9
int len A 0<
int ho"man%b%tes1 A 0<
ho"man%b%tes1 A +or;i(Nncompress=ata5blob $ blobindex C ho"man%b%tesC3 $ out len 8<
strin( returnstrin( A Fcustom 5UFF<
#or 5 int ii1 A 0 < ii1 B len < ii1CC8
returnstrin( A returnstrin( C 5char8blob6blobindexC3Cii1Cho"man%b%tesCho"man%b%tes17<
returnstrin( A returnstrin( C FUFF C F$F <
int len1 A len<
int b%tes A 1<
i# 5 len1 HA 1288
b%tes A 2<
ho"man%b%tes1 A +or;i(Nncompress=ata5blob $ blobindex C ho"man%b%tesC3Clen1Cb%tes $
out len 8<
II+onsole.!rite3ine5F..............lenA90@ len1A91@ 92@F $ len $ len1 $ blob6blobindex78<
returnstrin( A returnstrin( C FUFF <
#or 5 int ii1 A 1 < ii1 BA len < ii1CC8
returnstrin( A returnstrin( C
5char8blob6blobindexC3Clen1Cii1Cho"man%b%tesCho"man%b%tes17<
returnstrin( A returnstrin( C FUF8F<
return returnstrin(<
@
244260235.doc 463 od 541
i# 5 marshal#la(s AA 0x2d8
return FerrorF<
return FNnno"nF<
@
public strin( Det;a#e*rra%T%pe 5b%te sa#earra%t%pe8
9
strin( returnstrin( A FF<
II+onsole.!rite3ine5F......90@F $ sa#earra%t%pe.To;trin(5FKF88<
i# 5sa#earra%t%pe AA 08
returnstrin( A FF<
i# 5sa#earra%t%pe AA 18
returnstrin( A FnullF<
i# 5sa#earra%t%pe AA 28
returnstrin( A Fint16F<
i# 5sa#earra%t%pe AA 38
returnstrin( A Fint32F<
i# 5sa#earra%t%pe AA 48
returnstrin( A F#loat32F<
i# 5sa#earra%t%pe AA 58
returnstrin( A F#loat34F<
i# 5sa#earra%t%pe AA 68
returnstrin( A Fcurrenc%F<
i# 5sa#earra%t%pe AA 78
returnstrin( A FdateF<
i# 5sa#earra%t%pe AA 88
returnstrin( A FbstrF<
i# 5sa#earra%t%pe AA 98
returnstrin( A FidispatchF<
i# 5sa#earra%t%pe AA 0x0a8
returnstrin( A FerrorF<
i# 5sa#earra%t%pe AA 0x0b8
returnstrin( A FboolF<
i# 5sa#earra%t%pe AA 0x0c8
returnstrin( A FvariantF<
i# 5sa#earra%t%pe AA 0x0d8
returnstrin( A Fiunno"nF<
i# 5sa#earra%t%pe AA 0x0e8
returnstrin( A FdecimalF<
i# 5sa#earra%t%pe AA 0x0#8
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x108
returnstrin( A Fint8F<
i# 5sa#earra%t%pe AA 0x118
returnstrin( A Funsi(ned int8F<
i# 5sa#earra%t%pe AA 0x128
returnstrin( A Funsi(ned int16F<
i# 5sa#earra%t%pe AA 0x138
returnstrin( A Funsi(ned int32F<
i# 5sa#earra%t%pe AA 0x148
returnstrin( A Fint64F<
i# 5sa#earra%t%pe AA 0x158
244260235.doc 464 od 541
returnstrin( A Funsi(ned int64F<
i# 5sa#earra%t%pe AA 0x168
returnstrin( A FintF<
i# 5sa#earra%t%pe AA 0x178
returnstrin( A Funsi(ned intF<
i# 5sa#earra%t%pe AA 0x188
returnstrin( A FvoidF<
i# 5sa#earra%t%pe AA 0x198
returnstrin( A FhresultF<
i# 5sa#earra%t%pe AA 0x1a8
returnstrin( A FJF<
i# 5sa#earra%t%pe AA 0x1b8
returnstrin( A Fsa#earra%F<
i# 5sa#earra%t%pe AA 0x1c8
returnstrin( A Fcarra%F<
i# 5sa#earra%t%pe AA 0x1d8
returnstrin( A Fuserde#inedF<
i# 5sa#earra%t%pe AA 0x1e8
returnstrin( A FlpstrF<
i# 5sa#earra%t%pe AA 0x1#8
returnstrin( A Flp"strF<
i# 5sa#earra%t%pe AA 0x208
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x218
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x228
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x238
returnstrin( A Fille(alF<
i# 5sa#earra%t%pe AA 0x248
returnstrin( A FrecordF<
i# 5sa#earra%t%pe HA 0x258
returnstrin( A Fille(alF<
return returnstrin(<
@
public strin( Det4aram*ttr#or0ethod0arshal 5int methodindex $ int se. 8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null8
return returnstrin(<
int end<
int start A 0ethod;truct6methodindex7.param<
i# 5 methodindex AA 50ethod;truct.3en(th P 18 8
end A 4aram;truct.3en(th C 1<
else
end A 0ethod;truct6methodindexC17.param<
i# 5 start AA 4aram;truct.3en(th8
return returnstrin(<
i# 5 start AA end8
return returnstrin(<
i# 5 se. AA 0 GG 4aram;truct6start7.se.uence EA 08
244260235.doc 465 od 541
return FF<
int pattr A 4aram;truct6start7.pattr<
returnstrin( A =ecode4aram*ttributes5pattr $ 1 $ start $ 0x20008<
i# 5 returnstrin( EA FF GG returnstrin(607 AA 328
returnstrin( A returnstrin(.,emove50 $ 18<
return returnstrin(<
@
public strin( Det0ethod*ttribute 5int method#la(s $ int methodro"8
9
strin( returnstrin( A FF<
methodaccessattributeAFF <
methodpinvoestrin( A FF<
i# 5 5method#la(s G 0x00068 AA 0x00068
returnstrin( A Fpublic F<
else
i# 5 5method#la(s G 0x00058 AA 0x00058
returnstrin( A F#amorassem F<
else
i# 5 5method#la(s G 0x00038 AA 0x00038
returnstrin( A Fassembl% F<
else
i# 5 5method#la(s G 0x00048 AA 0x00048
returnstrin( A F#amil% F<
else
i# 5 5method#la(s G 0x00018 AA 0x00018
returnstrin( A Fprivate F<
else i# 5 5method#la(s G 0x00028 AA 0x00028
returnstrin( A F#amandassem F<
else
returnstrin( A Fprivatescope F<
methodaccessattribute A returnstrin(<
i# 5 5method#la(s G 0x00808 AA 0x00808
9
returnstrin( A returnstrin( C Fhideb%si( F<
@
i# 5 5method#la(s G 0x01008 AA 0x01008
9
returnstrin( A returnstrin( C Fne"slot F<
@
i# 5 5method#la(s G 0x08008 AA 0x0800 TT 5method#la(s G 0x02008 AA 0x0200 8
9
returnstrin( A returnstrin( C Fspecialname F<
@
i# 5 5method#la(s G 0x10008 AA 0x10008
9
returnstrin( A returnstrin( C Frtspecialname F<
@
i# 5 5method#la(s G 0x00108 AA 0x00108
9
returnstrin( A returnstrin( C Fstatic F<
@
244260235.doc 466 od 541
else
9
returnstrin( A returnstrin( C Finstance F<
@
i# 5 5method#la(s G 0x00208 AA 0x00208
9
returnstrin( A returnstrin( C F#inal F<
@
i# 5 5method#la(s G 0x00408 AA 0x00408
9
returnstrin( A returnstrin( C Fvirtual F<
@
i# 5 5method#la(s G 0x04008 AA 0x04008
9
returnstrin( A returnstrin( C Fabstract F<
@
i# 5 5method#la(s G 0x20008 AA 0x20008
9
returnstrin( A returnstrin( C Fpinvoeimpl5F<
int ii<
i# 5 'mpl0ap;truct AA null8
9
returnstrin( A returnstrin( C FIJ )o map JI8 F<
return returnstrin(<
@
else
9
#or 5 iiA1< ii B 'mpl0ap;truct.3en(th < iiCC8
9
int index A 'mpl0ap;truct6ii7.cindex<
index A index HH 1<
i# 5 index AA methodro" 8
brea<
@
i# 5 ii AA 'mpl0ap;truct.3en(th 8
9
returnstrin( A returnstrin( C FIJ )o map JI8 F<
return returnstrin(<
@
strin( methodname A )ame,eserved5Det;trin(50ethod;truct6methodro"7.name88<
strin( name A )ame,eserved5Det;trin(5'mpl0ap;truct6ii7.name88<
int scope A 'mpl0ap;truct6ii7.scope<
strin( modulename A )ame,eserved5Det;trin(50odule,e#;truct6scope7.name88<
modulename A modulename.,eplace5FUUF $ FUUUUF8<
returnstrin( A returnstrin( C FUFF C modulename C FUFF <
i# 5 ;trin(.+ompare5methodname $ name8 EA 08
returnstrin( A returnstrin( C F as UFF C name C FUFF<
strin( pinvoeattribute1<
strin( pinvoeattribute A Det4invoe*ttributes5'mpl0ap;truct6ii7.attr $ out pinvoeattribute18<
returnstrin( A returnstrin( C pinvoeattribute1<
i# 5pinvoeattribute.'ndex/#5FstdcallF8 AA P18
244260235.doc 467 od 541
returnstrin( A returnstrin( C F F C pinvoeattribute<
returnstrin( A returnstrin( C F8 F<
int index1 A returnstrin(.'ndex/#5FpinvoF8 <
methodpinvoestrin( A returnstrin(.,emove50$ index18<
@
@
i# 5 5method#la(s G 0x088 AA 0x088
9
returnstrin( A returnstrin( C Funmana(edexp F<
@
i# 5 5method#la(s G 0x####80008 AA 0x####80008
9
returnstrin( A returnstrin( C Fre.secob1 F<
@
return returnstrin(<
@
public strin( Det4invoe*ttributes 5int attribute $ out strin( returnattribute8
9
returnattribute A FF<
i# 5 5attribute G 0x0018 AA 0x00018
returnattribute A F noman(leF<
i# 5 5attribute G 0x0068 AA 0x00068
returnattribute A returnattributeC F autocharF<
else i# 5 5attribute G 0x0028 AA 0x00028
returnattribute A returnattribute C F ansiF<
else i# 5 5attribute G 0x0048 AA 0x00048
returnattribute A returnattribute C F unicodeF<
i# 5 5attribute G 0x0408 AA 0x00408
returnattribute A returnattribute C F lasterrF<
strin( returnstrin( A FF<
i# 5 5attribute G 0x05008 AA 0x05008
returnstrin( A returnstrin(C F#astcallF<
else i# 5 5attribute G 0x03008 AA 0x03008
returnstrin(A returnstrin( C FstdcallF<
else i# 5 5attribute G 0x01008 AA 0x01008
returnstrin( A returnstrin( C F"inapiF<
else i# 5 5attribute G 0x02008 AA 0x02008
returnstrin( A returnstrin( C FcdeclF<
else i# 5 5attribute G 0x04008 AA 0x04008
returnstrin( A returnstrin( C FthiscallF<
return returnstrin(<
@
public void =ispla%;i&e*nd4ac 5int t%peindex8
9
i# 5 +lass3a%out;truct AA null8
return<
#or 5 int ii A 1 < ii B +lass3a%out;truct.3en(th < iiCC8
9
i# 5 +lass3a%out;truct6ii7.parent AA t%peindex 8
9
+onsole.!rite5+reate;paces5spaces#ornested C spaces#orrest88<
244260235.doc 468 od 541
+onsole.!rite3ine5F.pac 90@F $ +lass3a%out;truct6ii7.pacin(si&e8<
+onsole.!rite5+reate;paces5spaces#ornested C spaces#orrest88<
+onsole.!rite3ine5F.si&e 90@F $ +lass3a%out;truct6ii7.classsi&e8<
@
@
@
public void =ispla%:nd58
9
strin( nspace A )ame,eserved5Det;trin(5T%pe=e#;truct6T%pe=e#;truct.3en(thP17.nspace88<
i# 5 E placedend8
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
placedend A true<
@
i# 5 nspace AA FF8
=ispla%+ustom*ttribute5FT%pe,e#F $ 0 $ 08<
=ispla%=ata58<
+onsole.!rite3ine5FIIJJJJJJJJJJJ =';*;;:0O3W +/043:T:
JJJJJJJJJJJJJJJJJJJJJJJF8<
i# 5 datadirector%rva627 EA 08
+onsole.!rite3ine5FII !*,)')DM +reated !in32 resource #ile a.resF8<
@
public void =ispla%/neT%pe=e#:nd 5int t%peindex 8
9
strin( dumm% A FF<
i# 5 'sT%pe)ested5t%peindex8 8
dumm% A dumm% C +reate;paces5spaces#ornested8<
dumm% A dumm% C +reate;paces5space#ornamespace8<
dumm% A dumm% C F@ II end o# class F<
strin( classname A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.name88<
dumm% A dumm% C classname <
+onsole.!rite3ine5dumm%8<
strin( namespacename A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
+onsole.!rite3ine58<
i# 5 namespacename EA FF8
9
strin( nspace1 A )ame,eserved5Det;trin(5T%pe=e#;truct6t%peindex7.nspace88<
int ii<
#or 5 ii A t%peindex C 1 < ii B T%pe=e#;truct.3en(th P 1 < iiCC8
9
i# 5 'sT%pe)ested5ii8 8
continue<
brea<
@
strin( nspace2 A FF<
i# 5 ii EA T%pe=e#;truct.3en(th 8
nspace2 A )ame,eserved5Det;trin(5T%pe=e#;truct6ii7.nspace88<
i# 5 nspace1 EA nspace2 8
244260235.doc 469 od 541
9
i# 5 lastt%pedispla%ed AA t%peindex GG notprotot%pe 8
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
placedend A true<
=ispla%+ustom*ttribute5FT%pe,e#F $ 0 $ 28<
@
i# 5lastt%pedispla%ed AA t%peindex GG notprotot%pe 8
=ispla%>inal+ustom*ttributes58<
+onsole.!rite5F@F8<
+onsole.!rite3ine5F II end o# namespace 90@F$ namespacename8<
space#ornamespace A 0<
spaces#orrest A 2<
"ritenamespace A true<
+onsole.!rite3ine58<
@
else
"ritenamespace A #alse<
@
@

public int DetT%pe>or0ethod 5int methodro"8
9
int t%pede#index A 0<
#or 5 t%pede#index A 1 < t%pede#index B T%pe=e#;truct.3en(th P 1 < t%pede#indexCC8
9
int start A T%pe=e#;truct6t%pede#index7.mindex<
int end A T%pe=e#;truct6t%pede#indexC17.mindex P1 <
i# 5 methodro" HA start GG methodro" BA end8
return t%pede#index<
@
return t%pede#index<
@
public void =ispla%T%pe=e#s*nd0ethods 58
9
notprotot%pe A true<
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
@
+onsole.!rite3ine58<
+onsole.!rite3ine5FII AAAAAAAAAAAAAAA D3/O*3 >':3=; *)= 0:T2/=;
AAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
=ispla%Dlobal>ields58<
244260235.doc 470 od 541
=ispla%Dlobal0ethods58<
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine58<
+onsole.!rite3ine58<
+onsole.!rite3ine5FII AAAAAAAAAAAAAAA +3*;; 0:0O:,; =:+3*,*T'/)
AAAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine5FII note that class #la(s$ LextendsL and LimplementsL clausesF8<
+onsole.!rite3ine5FII are provided here #or in#ormation onl%F8<
+onsole.!rite3ine58<
int A T%pe=e#;truct.3en(th <
#or 5 int i A 2 < i B < iCC8
9
i# 5 Det;trin(5T%pe=e#;truct6i7.name8 AA FR=eletedF GG streamnames607 AA FSPF8
continue<
i# 5 E 'sT%pe)ested5i8 8
9
=ispla%/neT%pe5i8<
@
@
@
=ispla%:nd58<
@
public void =ispla%T%pe=e#s 58
9
i# 5 T%pe=e#;truct.3en(th EA 28
9
+onsole.!rite3ine5FIIF8<
+onsole.!rite3ine5FII AAAAAAAAAAAAAA +3*;; ;T,N+TN,: =:+3*,*T'/)
AAAAAAAAAAAAAAAAAAF8<
+onsole.!rite3ine5FIIF8<
"ritenamespace A true<
#or 5 int i A 2 < i B T%pe=e#;truct.3en(th < iCC8
9
i# 5 Det;trin(5T%pe=e#;truct6i7.name8 AA FR=eletedF GG streamnames607 AA FSPF8
9
continue<
@
i# 5 E 'sT%pe)ested5i8 8
9
=ispla%/neT%pe4rotot%pe5i8<
@
@
@
@
public bool 'sT%pe)ested 5int t%peindex8
9
i# 5)ested+lass;truct AA null8
244260235.doc 471 od 541
return #alse<
#or 5 int ii A 1 < iiB )ested+lass;truct.3en(th < iiCC8
9
i# 5 )ested+lass;truct6ii7.nestedclass AA t%peindex8
return true<
@
return #alse<
@
public void =ispla%/neT%pe4rotot%pe 5int t%pede#index8
9
=ispla%/neT%pe=e#;tart5t%pede#index8<
=ispla%)estedT%pes4rotot%pes5t%pede#index8<
=ispla%/neT%pe=e#:nd5t%pede#index8<
@
public void =ispla%/neT%pe=e#;tart 5int t%pero"8
9
strin( namespacename A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pero"7.nspace88<
i# 5 namespacename EA FF8
9
i# 5 "ritenamespace 8
9
+onsole.!rite3ine5F.namespace 90@F $ namespacename 8<
+onsole.!rite3ine5F9F 8<
space#ornamespace A 2<
spaces#orrest A 4<
@
@
strin( t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F.class IJ02F C t%pero".To;trin(5FK6F8 C FJI F<
strin( attribute#la(s A DetT%pe*ttribute>la(s5T%pe=e#;truct6t%pero"7.#la(s $ t%pero"8<
+onsole.!rite3ine5F90@91@92@F $ t%pestrin( $ attribute#la(s $
)ame,eserved5Det;trin(5T%pe=e#;truct6t%pero"7.name888<
strin( tablename A DetT%pe=e#/r,e#Table5T%pe=e#;truct6t%pero"7.cindex8<
int index A DetT%pe=e#/r,e#-alue5T%pe=e#;truct6t%pero"7.cindex8<
strin( t%peextends A FF<
i# 5 tablename AA FT%pe,e#F 8
9
t%peextends A =ispla%T%pe,e#:xtends5index8<
@
i# 5 tablename AA FT%pe=e#F 8
9
t%peextends A Det)estedT%pe*s;trin(5index8 C =ispla%T%pe=e#:xtends5index8<
@
i# 5 t%peextends.3en(th EA 08
9
t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
244260235.doc 472 od 541
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F extends F C t%peextends<
+onsole.!rite3ine5t%pestrin(8<
@
strin( inter#acestrin( A =ispla%*ll'nter#aces5t%pero"8<
i# 5 inter#acestrin(.3en(th EA 08
9
t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F implements F C inter#acestrin(<
+onsole.!rite5t%pestrin(8<
@
t%pestrin( A FF<
i# 5 'sT%pe)ested5t%pero"88
t%pestrin( A t%pestrin( C +reate;paces5spaces#ornested8<
t%pestrin( A t%pestrin( C +reate;paces5space#ornamespace8<
t%pestrin( A t%pestrin( C F9F<
+onsole.!rite3ine5t%pestrin(8<
@
public strin( DetT%pe*ttribute>la(s 5int t%peattribute#la(s $ int t%peindex8
9
strin( returnstrin( A FF<
int visibilt%mas A t%peattribute#la(s G 0x07<
strin( visibilt%masstrin(AFF<
i# 5 visibilt%mas AA 08
visibilt%masstrin( A Fprivate F<
i# 5 visibilt%mas AA 18
visibilt%masstrin( A Fpublic F<
i# 5 visibilt%mas AA 28
visibilt%masstrin( A Fnested public F<
i# 5 visibilt%mas AA 38
visibilt%masstrin( A Fnested private F<
i# 5 visibilt%mas AA 48
visibilt%masstrin( A Fnested #amil% F<
i# 5 visibilt%mas AA 58
visibilt%masstrin( A Fnested assembl% F<
i# 5 visibilt%mas AA 68
visibilt%masstrin( A Fnested #amandassem F<
i# 5 visibilt%mas AA 78
visibilt%masstrin( A Fnested #amorassem F<
int classla%outmas A t%peattribute#la(s G 0x18<
strin( classla%outstrin( A FF<
i# 5 classla%outmas AA 08
classla%outstrin( A Fauto F<
i# 5 classla%outmas AA 0x088
classla%outstrin( A Fse.uential F<
i# 5 classla%outmas AA 0x108
classla%outstrin( A Fexplicit F<
strin( inter#acestrin( A FF<
244260235.doc 473 od 541
i# 5 5t%peattribute#la(s G 0x208 AA 0x208
inter#acestrin( A Finter#ace F<
strin( abstractstrin( A FF<
i# 5 5t%peattribute#la(s G 0x808 AA 0x808
abstractstrin( A Fabstract F<
strin( sealedstrin( A FF<
i# 5 5t%peattribute#la(s G 0x1008 AA 0x1008
sealedstrin( A Fsealed F<
strin( specialnamestrin( A FF<
i# 5 5t%peattribute#la(s G 0x4008 AA 0x4008
specialnamestrin( A Fspecialname F<
strin( importstrin( A FF<
i# 5 5t%peattribute#la(s G 0x10008 AA 0x10008
importstrin( A Fimport F<
strin( seriali&ablestrin( A FF<
i# 5 5t%peattribute#la(s G 0x20008 AA 0x20008
seriali&ablestrin( A Fseriali&able F<
int strin(#ormatmas A t%peattribute#la(s G 0x30000<
strin( strin(#ormastrin( A FF<
i# 5 strin(#ormatmas AA 08
strin(#ormastrin( A Fansi F<
i# 5 strin(#ormatmas AA 0x100008
strin(#ormastrin( A Funicode F<
i# 5 strin(#ormatmas AA 0x200008
strin(#ormastrin( A Fautochar F<
strin( be#ore#ieldinitstrin( A FF<
i# 5 5t%peattribute#la(s G 0x001000008 AA 0x001000008
be#ore#ieldinitstrin( A Fbe#ore#ieldinit F<
IIstrin( rtspecialnamestrin( A FF<
IIi# 5 5t%peattribute#la(s G 0x8008 AA 0x8008
IIrtspecialnamestrin( A Frtspecialname F<
i# 5 'sT%pe)ested5t%peindex8 8
returnstrin( A inter#acestrin( C abstractstrin( C classla%outstrin( C strin(#ormastrin( C
seriali&ablestrin( C sealedstrin( C importstrin( C visibilt%masstrin( C be#ore#ieldinitstrin(<
else
returnstrin( A inter#acestrin( C visibilt%masstrin( C abstractstrin( C classla%outstrin( C
strin(#ormastrin( C importstrin( C seriali&ablestrin( C sealedstrin( C specialnamestrin( C
be#ore#ieldinitstrin( <
return returnstrin(<
@
public strin( =ispla%T%pe=e#:xtends 5int t%pede#index8
9
i# 5 t%pede#index AA 08
return FF<
strin( name A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#index7.name88<
strin( returnstrin( A )ame,eserved5Det;trin(5T%pe=e#;truct6t%pede#index7.nspace88<
i# 5 returnstrin(.3en(th EA 08
returnstrin( A returnstrin( C F.F<
returnstrin( A returnstrin( C name C FIJ 02F C t%pede#index.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
244260235.doc 474 od 541
public strin( Det)estedT%pe*s;trin(5int ro"index8
9
strin( netsedt%pestrin( A FF<
strin( namespaceandnameparent2 A FF<
strin( namespaceandnameparent3A FF<
i# 5 'sT%pe)ested5ro"index8 8
9
int ro"indexparent A Det4arent>or)estedT%pe5ro"index8<
i# 5 'sT%pe)ested5ro"indexparent8 8
9
int ro"indexparentparent A Det4arent>or)estedT%pe5ro"indexparent8<
i# 5 'sT%pe)ested5ro"indexparentparent8 8
9
int ro"indexp3 A Det4arent>or)estedT%pe5ro"indexparentparent8<
strin( nameparent3 A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexp37.name88<
namespaceandnameparent3A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexp37.nspace88<
i# 5 namespaceandnameparent3.3en(th EA 08
namespaceandnameparent3 A namespaceandnameparent3 C F.F<
namespaceandnameparent3A namespaceandnameparent3 C nameparent3 C FIJ 02F C
ro"indexp3.To;trin(5FK6F8 C F JIIF<
@
strin( nameparent2 A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparentparent7.name88<
namespaceandnameparent2 A
)ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparentparent7.nspace88<
i# 5 namespaceandnameparent2.3en(th EA 08
namespaceandnameparent2 A namespaceandnameparent2 C F.F<
namespaceandnameparent2 A namespaceandnameparent3 C namespaceandnameparent2 C
nameparent2 C FIJ 02F C ro"indexparentparent.To;trin(5FK6F8 C F JIIF<
@
strin( nameparent1 A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparent7.name88<
netsedt%pestrin( A )ame,eserved5Det;trin(5T%pe=e#;truct6ro"indexparent7.nspace88<
i# 5 netsedt%pestrin(.3en(th EA 08
netsedt%pestrin( A netsedt%pestrin( C F.F<
netsedt%pestrin( A namespaceandnameparent2 C netsedt%pestrin( C nameparent1 C FIJ 02F C
ro"indexparent.To;trin(5FK6F8 C F JIIF<
@
return netsedt%pestrin(<
@
public int Det4arent>or)estedT%pe 5int t%peindex8
9
int ii A 0<
i# 5 )ested+lass;truct AA null8
return 0<
#or 5 ii A 0 < ii B )ested+lass;truct.3en(th < iiCC8
9
i# 5 t%peindex AA )ested+lass;truct6ii7.nestedclass 8
9
II+onsole.!rite3ine5F............90@ 91@F $ t%peindex $ )ested+lass;truct6ii7.nestedclass8<
return )ested+lass;truct6ii7.enclosin(class<
@
@
244260235.doc 475 od 541
return 0<
@
public strin( =ispla%T%pe,e#:xtends 5int t%pere#index8
9
strin( returnstrin( A FF<
int resolutionscope A T%pe,e#;truct6t%pere#index7.resolutionscope<
strin( resolutionscopetable A Det,esolution;copeTable5resolutionscope8<
int resolutionscopeindex A Det,esolution;cope-alue5resolutionscope8<
strin( dumm% A FF<
i# 5 resolutionscopetable AA F0oduleF8
9
@
i# 5 resolutionscopetable AA F*ssembl%,e#F8
9
returnstrin( A F6F C )ame,eserved5Det;trin(5*ssembl%,e#;truct6resolutionscopeindex7.name88 <
returnstrin( A returnstrin( C FIJ 23F C resolutionscopeindex.To;trin(5FK6F8 C F JI7F<
@
i# 5 resolutionscopetable AA F0odule,e#F8
9
returnstrin( A F6.module F C
)ame,eserved5Det;trin(50odule,e#;truct6resolutionscopeindex7.name88 <
returnstrin( A returnstrin( C FIJ 1*F C resolutionscopeindex.To;trin(5FK6F8 C F JI7F<
@
i# 5 resolutionscopetable AA FT%pe,e#F8
9
int resolutionscopeindex1 A
Det,esolution;cope-alue5T%pe,e#;truct6resolutionscopeindex7.resolutionscope 8<
strin( resolutionscopetable1 A
Det,esolution;copeTable5T%pe,e#;truct6resolutionscopeindex7.resolutionscope 8<
i# 5 resolutionscopetable1 AA F*ssembl%,e#F8
9
dumm% A F6F C )ame,eserved5Det;trin(5*ssembl%,e#;truct6resolutionscopeindex17.name88 C
FIJ 23F C resolutionscopeindex1.To;trin(5FK6F8 C F JI7F<
strin( nspace1 A )ame,eserved5Det;trin(5T%pe,e#;truct6resolutionscopeindex7.nspace88<
i# 5 nspace1 EA FF8
nspace1 A nspace1 C F.F<
dumm% A dumm% C nspace1 C
)ame,eserved5Det;trin(5T%pe,e#;truct6resolutionscopeindex7.name88 C FIJ 01F C
resolutionscopeindex.To;trin(5FK6F8 C F JIIF<
@
@
int namespaceindex A T%pe,e#;truct6t%pere#index7.nspace<
strin( nspace A )ame,eserved5Det;trin(5namespaceindex88<
returnstrin( A returnstrin( C nspace <
i# 5 nspace.3en(th EA 08
returnstrin( A returnstrin( C F.F<
int nameindex A T%pe,e#;truct6t%pere#index7.name<
returnstrin( A dumm% C returnstrin( C )ame,eserved5Det;trin(5nameindex88 C FIJ 01F C
t%pere#index.To;trin(5FK6F8 C F JIF<
return returnstrin(<
@
244260235.doc 476 od 541
public int Det,esolution;cope-alue5int rvalue8
9
return rvalue HH 2<
@
public strin( Det,esolution;copeTable 5int rvalue8
9
strin( returnstrin( A FF<
int ta( A rvalue G 0x03<
i# 5 ta( AA 0 8
returnstrin( A returnstrin( C F0oduleF <
i# 5 ta( AA 1 8
returnstrin( A returnstrin( C F0odule,e#F <
i# 5 ta( AA 2 8
returnstrin( A returnstrin( C F*ssembl%,e#F <
i# 5 ta( AA 3 8
returnstrin( A returnstrin( C FT%pe,e#F <
return returnstrin(<
@
public strin( =ispla%*ll'nter#aces 5int t%peindex8
9
strin( returnstrin( A FF<
i# 5 'nter#ace'mpl;truct AA null 8
return FF<
#or 5 int i A 1 < i B 'nter#ace'mpl;truct.3en(th < iCC8
9
i# 5 t%peindex AA 'nter#ace'mpl;truct6i7.classindex 8
9
strin( codedtablename A DetT%pe=e#/r,e#Table5'nter#ace'mpl;truct6i7.inter#aceindex8<
int inter#aceindex A DetT%pe=e#/r,e#-alue5'nter#ace'mpl;truct6i7.inter#aceindex8<
strin( inter#acename A FF<
i# 5 codedtablename AA FT%pe,e#F 8
inter#acename A =ispla%T%pe,e#:xtends5inter#aceindex8<
i# 5 codedtablename AA FT%pe=e#F 8
inter#acename A Det)estedT%pe*s;trin(5inter#aceindex8 C
=ispla%T%pe=e#:xtends5inter#aceindex8<
returnstrin( A returnstrin( C inter#acename<
bool nextclassindex <
i# 5 i AA 5'nter#ace'mpl;truct.3en(th P 188
nextclassindex A #alse<
else i# 5 t%peindex EA 'nter#ace'mpl;truct6iC17.classindex 8
nextclassindex A #alse<
else
nextclassindex A true<
i# 5 nextclassindex 8
returnstrin( A returnstrin( C F$UrUn F C
+reate;paces5space#ornamespaceCspaces#ornested8<
else
returnstrin( A returnstrin( C FUrUnF<
@
@
return returnstrin(<
244260235.doc 477 od 541
@

public static void 0ain 5strin( 67 ar(s8
9
tr%
9
&&& a A ne" &&&58<
a.abc5ar(s8<
@
catch 5 :xception e8
9
+onsole.!rite3ine5e.To;trin(588<
@
@
public void ,ead4:;tructures5strin( 67 ar(s8
9
#ilename A ar(s607<
m#ilestream A ne" >ile;tream5#ilename $>ile0ode./pen8<
mbinar%reader A ne" Oinar%,eader 5m#ilestream8<
m#ilestream.;ee560$ ;ee/ri(in.Oe(in8<
int starto#peheader A mbinar%reader.,ead'nt3258<
m#ilestream.;ee5starto#peheader$ ;ee/ri(in.Oe(in8<
b%te si(1$si(2$si(3$si(4<
si(1 A mbinar%reader.,eadO%te58<
si(2 A mbinar%reader.,eadO%te58<
si(3 A mbinar%reader.,eadO%te58<
si(4 A mbinar%reader.,eadO%te58<
II>irst ;tructure
short machine A mbinar%reader.,ead'nt1658<
sections A mbinar%reader.,ead'nt1658<
int time A mbinar%reader.,ead'nt3258<
int pointer A mbinar%reader.,ead'nt3258<
int s%mbols A mbinar%reader.,ead'nt3258<
int headersi&eA mbinar%reader.,ead'nt1658<
int characteristics A mbinar%reader.,ead'nt1658<
sectiono##set A m#ilestream.4osition C headersi&e<
II;econd ;tructure
int ma(ic A mbinar%reader.,ead'nt1658<
int ma1or A mbinar%reader.,eadO%te58<
int minor A mbinar%reader.,eadO%te58<
int si&eo#code A mbinar%reader.,ead'nt3258<
int si&eo#data A mbinar%reader.,ead'nt3258<
int si&eo#udata A mbinar%reader.,ead'nt3258<
entr%point A mbinar%reader.,ead'nt3258<
int baseo#code A mbinar%reader.,ead'nt3258<
int baseo#data A mbinar%reader.,ead'nt3258<
'ma(eOase A mbinar%reader.,ead'nt3258<
sectionaA mbinar%reader.,ead'nt3258<
#ilea A mbinar%reader.,ead'nt3258<
int ma1oros A mbinar%reader.,ead'nt1658<
int minoros A mbinar%reader.,ead'nt1658<
244260235.doc 478 od 541
int ma1orima(e A mbinar%reader.,ead'nt1658<
int minorima(e A mbinar%reader.,ead'nt1658<
int ma1orsubs%stemA mbinar%reader.,ead'nt1658<
int minorsubs%stem A mbinar%reader.,ead'nt1658<
int verison A mbinar%reader.,ead'nt3258<
int ima(esi&e A mbinar%reader.,ead'nt3258<
int si&eo#headersA mbinar%reader.,ead'nt3258<
int checsum A mbinar%reader.,ead'nt3258<
subs%stem A mbinar%reader.,ead'nt1658<
int dll#la(s A mbinar%reader.,ead'nt1658<
stacreserve A mbinar%reader.,ead'nt3258<
staccommit A mbinar%reader.,ead'nt3258<
int heapreserve A mbinar%reader.,ead'nt3258<
int heapcommit A mbinar%reader.,ead'nt3258<
int loader A mbinar%reader.,ead'nt3258<
datad A mbinar%reader.,ead'nt3258<
datadirector%rva A ne" int6167<
datadirector%si&e A ne" int6167<
#or 5 int i A 0 < i BA15 < iCC8
9
datadirector%rva6i7 A mbinar%reader.,ead'nt3258<
datadirector%si&e6i7 A mbinar%reader.,ead'nt3258<
@
i# 5 datadirector%si&e6147 AA 08
thro" ne" ;%stem.:xception5F)ot a valid +3, #ileF8<
m#ilestream.4osition A sectiono##set <
;-irtual*ddress A ne" int6sections 7<
;;i&e/#,a"=ata A ne" int6sections 7<
;4ointerTo,a"=ata A ne" int6sections 7<
#or 5 int i A 0 < i B sections < iCC8
9
mbinar%reader.,eadO%tes5128<
;-irtual*ddress6i7 A mbinar%reader.,ead'nt3258<
;;i&e/#,a"=ata6i7 A mbinar%reader.,ead'nt3258<
;4ointerTo,a"=ata6i7 A mbinar%reader.,ead'nt3258<
mbinar%reader.,eadO%tes5168<
@
@
public void =ispla%4:;tructures58
9
+onsole.!rite3ine58<
+onsole.!rite3ine5FII 0icroso#t 5,8 .):T >rame"or '3 =isassembler. -ersion 1.0.3328.4F8<
+onsole.!rite3ine5FII +op%ri(ht 5+8 0icroso#t +orporation 1998P2001. *ll ri(hts reserved.F8<
+onsole.!rite3ine58<
+onsole.!rite3ine5FII 4: 2eaderMF8<
+onsole.!rite3ine5FII ;ubs%stemM 90@F$subs%stem.To;trin(5Fx8F88<
+onsole.!rite3ine5FII )ative entr% point addressM 90@F$entr%point.To;trin(5Fx8F88<
+onsole.!rite3ine5FII 'ma(e baseM 90@F$'ma(eOase.To;trin(5Fx8F88<
+onsole.!rite3ine5FII ;ection ali(nmentM 90@F$sectiona.To;trin(5Fx8F88<
+onsole.!rite3ine5FII >ile ali(nmentM 90@F$#ilea.To;trin(5Fx8F88<
+onsole.!rite3ine5FII ;tac reserve si&eM 90@F$stacreserve.To;trin(5Fx8F88<
244260235.doc 479 od 541
+onsole.!rite3ine5FII ;tac commit si&eM 90@F$staccommit.To;trin(5Fx8F88<
+onsole.!rite3ine5FII =irectoriesM 90@F$datad.To;trin(5Fx8F88<
=ispla%=ata=irector%5datadirector%rva607 $ datadirector%si&e607 $ F:xport =irector%F8<
=ispla%=ata=irector%5datadirector%rva617 $ datadirector%si&e617 $ F'mport =irector%F8<
=ispla%=ata=irector%5datadirector%rva627 $ datadirector%si&e627 $ F,esource =irector%F8<
=ispla%=ata=irector%5datadirector%rva637 $ datadirector%si&e637 $ F:xception =irector%F8<
=ispla%=ata=irector%5datadirector%rva647 $ datadirector%si&e647 $ F;ecurit% =irector%F8<
=ispla%=ata=irector%5datadirector%rva657 $ datadirector%si&e657 $ FOase ,elocation TableF8<
=ispla%=ata=irector%5datadirector%rva667 $ datadirector%si&e667 $ F=ebu( =irector%F8<
=ispla%=ata=irector%5datadirector%rva677 $ datadirector%si&e677 $ F*rchitecture ;peci#icF8<
=ispla%=ata=irector%5datadirector%rva687 $ datadirector%si&e687 $ FDlobal 4ointerF8<
=ispla%=ata=irector%5datadirector%rva697 $ datadirector%si&e697 $ FT3; =irector%F8<
=ispla%=ata=irector%5datadirector%rva6107 $ datadirector%si&e6107 $ F3oad +on#i( =irector%F8<
=ispla%=ata=irector%5datadirector%rva6117 $ datadirector%si&e6117 $ FOound 'mport =irector%F8<
=ispla%=ata=irector%5datadirector%rva6127 $ datadirector%si&e6127 $ F'mport *ddress TableF8<
=ispla%=ata=irector%5datadirector%rva6137 $ datadirector%si&e6137 $ F=ela% 3oad '*TF8<
=ispla%=ata=irector%5datadirector%rva6147 $ datadirector%si&e6147 $ F+3, 2eaderF8<
+onsole.!rite3ine58<
@
public void =ispla%=ata=irector%5int rva$ int si&e $ strin( ss8
9
strin( s#inal A FF<
s#inal A ;trin(.>ormat5FII 90Mx@F $ rva8<
s#inal A s#inal.4ad,i(ht5128<
s#inal A s#inal C ;trin(.>ormat5F690Mx@F $ si&e8<
s#inal A s#inal.4ad,i(ht5218<
s#inal A s#inal C ;trin(.>ormat5F7 address 6si&e7 o# 90@MF $ ss8<
i# 5ss AA F+3, 2eaderF8
s#inal A s#inal.4ad,i(ht5678<
else
s#inal A s#inal.4ad,i(ht5688<
+onsole.!rite3ine5s#inal8<
@
public void ,eadand=ispla%'mport*dressTable58
9
lon( strato#imports A +onvert,-*5datadirector%rva6178<
m#ilestream.4osition A strato#imports<
+onsole.!rite3ine5FII 'mport *ddress TableF8<
int outercount A 0<
"hile 5true8
9
int rvaimportloouptable A mbinar%reader.,ead'nt3258<
i# 5 rvaimportloouptable AA 08
brea<
int datetimestamp A mbinar%reader.,ead'nt3258<
int #or"arderchain A mbinar%reader.,ead'nt3258<
int name A mbinar%reader.,ead'nt3258<
int rvaiat A mbinar%reader.,ead'nt3258<
m#ilestream.4osition A +onvert,-*5name8<
+onsole.!rite5FII F8<
=ispla%;trin(>rom>ile58<
244260235.doc 480 od 541
+onsole.!rite3ine5FII 90@ 'mport *ddress TableF $ rvaiat.To;trin(5Fx8F88<
+onsole.!rite3ine5FII 90@ 'mport )ame TableF $ name.To;trin(5Fx8F88<
+onsole.!rite3ine5FII 90@ time date stampF $ datetimestamp8<
+onsole.!rite3ine5FII 90@ 'ndex o# #irst #or"arder re#erenceF $ #or"arderchain8<
+onsole.!rite3ine5FIIF8<

lon( importtable A +onvert,-*5rvaimportloouptable 8 <
m#ilestream.4osition A importtable<
int nexttable A mbinar%reader.,ead'nt3258<
i# 5 nexttable B 0 8
9
+onsole.!rite3ine5FII >ailed to read import data.F8<
+onsole.!rite3ine58<
outercountCC<
m#ilestream.4osition A strato#imports C outercount J 20<
continue<
@

int innercount A 0<
"hile 5 true 8
9
lon( pos0 A +onvert,-*5rvaimportloouptable 8 C innercount J 4<
m#ilestream.4osition A pos0<
int pos1 A mbinar%reader.,ead'nt3258<
i# 5 pos1 AA 08
brea<
lon( pos2 A +onvert,-*5pos18<
m#ilestream.4osition A pos2<
short hint A mbinar%reader.,ead'nt1658<
+onsole.!rite5FII F8<
i# 5 hint.To;trin(5FKF8.3en(th AA 18
+onsole.!rite5F 90@F $ hint.To;trin(5FxF88<
i# 5 hint.To;trin(5FKF8.3en(th AA 28
+onsole.!rite5F 90@F $ hint.To;trin(5FxF88<
i# 5 hint.To;trin(5FKF8.3en(th AA 38
+onsole.!rite5F90@F $ hint.To;trin(5FxF88<
+onsole.!rite5F F8<
=ispla%;trin(>rom>ile58<
innercountCC<
@
+onsole.!rite3ine58<
outercountCC<
m#ilestream.4osition A strato#imports C outercount J 20<
@
+onsole.!rite3ine5FII =ela% 3oad 'mport *ddress TableF8<
i# 5datadirector%rva6137 AA 08
+onsole.!rite3ine5FII )o data.F8<
i# 5datadirector%rva6137 EA 08
+onsole.!rite3ine5F........................II )o data.F8<
@
public void =ispla%;trin(>rom>ile58
244260235.doc 481 od 541
9
"hile 5 true 8
9
b%te #ileb%te A 5b%te 8m#ilestream.,eadO%te58<
i# 5 #ileb%te AA 08
brea<
+onsole.!rite5F90@F $ 5char8#ileb%te8<
@
+onsole.!rite3ine58<
@
public void ,eadand=ispla%+3,2eader58
9
+onsole.!rite3ine5FII +3, 2eaderMF8<
m#ilestream.4osition A +onvert,-*5datadirector%rva61478<
int si&e A mbinar%reader.,ead'nt3258<
int ma1orruntimeversion A mbinar%reader.,ead'nt1658<
int minorruntimeversion A mbinar%reader.,ead'nt1658<
metadatarva A mbinar%reader.,ead'nt3258<
int metadatasi&e A mbinar%reader.,ead'nt3258<
cor#la(s A mbinar%reader.,ead'nt3258<
entr%pointtoen A mbinar%reader.,ead'nt3258<
int resourcesrva A mbinar%reader.,ead'nt3258<
int resourcessi&e A mbinar%reader.,ead'nt3258<
int stron(namesi(rva A mbinar%reader.,ead'nt3258<
int stron(namesi(si&e A mbinar%reader.,ead'nt3258<
int codemana(errva A mbinar%reader.,ead'nt3258<
int codemana(ersi&e A mbinar%reader.,ead'nt3258<
vtablerva A mbinar%reader.,ead'nt3258<
vtablesi&e A mbinar%reader.,ead'nt3258<
exportaddressrva A mbinar%reader.,ead'nt3258<
exportaddresssi&e A mbinar%reader.,ead'nt3258<
int mana(ednativeheaderrva A mbinar%reader.,ead'nt3258<
int mana(ednativeheadersi&e A mbinar%reader.,ead'nt3258<
i# 5 si&e HA 1008
+onsole.!rite3ine5FII 90@ 2eader ;i&eF$ si&e8<
else
+onsole.!rite3ine5FII 90@ 2eader ;i&eF$ si&e8<
+onsole.!rite3ine5FII 90@ 0a1or ,untime -ersionF$ ma1orruntimeversion8<
+onsole.!rite3ine5FII 90@ 0inor ,untime -ersionF$ minorruntimeversion8<
+onsole.!rite3ine5FII 90@ >la(sF$ cor#la(s.To;trin(5FxF88<
strin( dumm% A FII F C entr%pointtoen.To;trin(5FxF8<
dumm% A dumm%.4ad,i(ht5128 C F:ntr%point ToenF<
+onsole.!rite3ine5dumm%8<
=ispla%=ata=irector%5metadatarva $ metadatasi&e $ F0etadata =irector%F8<
=ispla%=ata=irector%5resourcesrva$ resourcessi&e$ F,esources =irector%F8<
=ispla%=ata=irector%5stron(namesi(rva$ stron(namesi(si&e$ F;tron( )ame ;i(natureF8<
=ispla%=ata=irector%5codemana(errva$ codemana(ersi&e$ F+ode0ana(er TableF8<
=ispla%=ata=irector%5vtablerva$ vtablesi&e$ F-Table>ixups =irector%F8<
=ispla%=ata=irector%5exportaddressrva$ exportaddresssi&e $ F:xport *ddress TableF8<
=ispla%=ata=irector%5mana(ednativeheaderrva$ mana(ednativeheadersi&e$ F4recompile
2eaderF8<
244260235.doc 482 od 541
+onsole.!rite3ine5FII +ode 0ana(er TableMF8<
i# 5 codemana(errva AA 08
+onsole.!rite3ine5FII de#aultF8<
@
public void ,ead;treams=ata58
9
starto#metadata A +onvert,-*5metadatarva8<
i# 5 debu( 8
+onsole.!rite3ine5F;tart o# 0etadata 90@ rvaA91@F $ metadatarva $ starto#metadata 8<
m#ilestream.4osition A starto#metadata <
m#ilestream.;ee54 C 2 C 2 C 4 $ ;ee/ri(in.+urrent8<
int len(tho#strin( A mbinar%reader.,ead'nt3258<
i# 5 debu( 8
+onsole.!rite3ine5F3en(th o# ;trin( 90@F $ len(tho#strin( 8<
m#ilestream.;ee5len(tho#strin( $ ;ee/ri(in.+urrent8<
lon( paddin( A m#ilestream.4osition a 4 <
i# 5 debu( 8
+onsole.!rite3ine5F4addin( 90@F $ paddin( 8<
m#ilestream.;ee52 $ ;ee/ri(in.+urrent8<
int streams A mbinar%reader.,ead'nt1658<
i# 5 debu( 8
+onsole.!rite3ine5F)o o# streams 90@ 4ositionA91@F $ streams $ m#ilestream.4osition8<
streamnames A ne" strin(657<
o##set A ne" int657<
ssi&e A ne" int657<
names A ne" b%te65767<
names607 A ne" b%te6107<
names617 A ne" b%te6107<
names627 A ne" b%te6107<
names637 A ne" b%te6107<
names647 A ne" b%te6107<
int 1 <
#or 5 int i A 0 < i B streams < iCC8
9
i# 5debu(8
+onsole.!rite3ine5F*t ;tart 4ositionA90@ 91@F $ m#ilestream.4osition $ m#ilestream.4osition a
48<
o##set6i7 A mbinar%reader.,ead'nt3258<
ssi&e6i7 A mbinar%reader.,ead'nt3258<
i# 5debu(8
+onsole.!rite3ine5Fo##setA90@ si&eA91@ 4ositionA92@F $ o##set6i7 $ ssi&e6i7 $
m#ilestream.4osition8<
1 A 0<
b%te bb <
"hile 5 true 8
9
bb A mbinar%reader.,eadO%te58<
i# 5 bb AA 08
brea<
names6i7617 A bb<
1CC<
244260235.doc 483 od 541
@
names6i7617 A bb<
streamnames6i7 A Det;tream)ames5names6i78<
"hile 5 true 8
9
i# 5 m#ilestream.4osition a 4 AA 0 8
brea<
b%te b A mbinar%reader.,eadO%te58<
@
i# 5debu(8
+onsole.!rite3ine5F*t :nd 4ositionA90@ 91@F $ m#ilestream.4osition $ m#ilestream.4osition a
48<
@
#or 5 int i A 0 < i B streams < iCC8
9
i# 5 streamnames6i7 AA FSVF TT streamnames6i7 AA FSPF 8
9
metadata A ne" b%te6ssi&e6i77<
m#ilestream.;ee5starto#metadata C o##set6i7 $ ;ee/ri(in.Oe(in8<
#or 5 int A 0 < B ssi&e6i7 < CC8
metadata67 A mbinar%reader.,eadO%te58<
@
i# 5 streamnames6i7 AA FS;trin(sF 8
9
strin(s A ne" b%te6ssi&e6i77<
m#ilestream.;ee5starto#metadata C o##set6i7 $ ;ee/ri(in.Oe(in8<
#or 5 int A 0 < B ssi&e6i7 < CC8
strin(s67 A mbinar%reader.,eadO%te58<
@
i# 5 streamnames6i7 AA FSN;F 8
9
us A ne" b%te6ssi&e6i77<
m#ilestream.;ee5starto#metadata C o##set6i7 $ ;ee/ri(in.Oe(in8<
#or 5 int A 0 < B ssi&e6i7 < CC8
us67 A mbinar%reader.,eadO%te58<
@
i# 5 streamnames6i7 AA FSDN'=F 8
9
(uid A ne" b%te6ssi&e6i77<
m#ilestream.;ee5starto#metadata C o##set6i7 $ ;ee/ri(in.Oe(in8<
#or 5 int A 0 < B ssi&e6i7 < CC8
(uid67 A mbinar%reader.,eadO%te58<
@
i# 5 streamnames6i7 AA FSOlobF 8
9
blob A ne" b%te6ssi&e6i77<
m#ilestream.;ee5starto#metadata C o##set6i7 $ ;ee/ri(in.Oe(in8<
#or 5 int A 0 < B ssi&e6i7 < CC8
blob67 A mbinar%reader.,eadO%te58<
@
@
244260235.doc 484 od 541
i# 5 debu( 8
9
#or 5 int i A 0 < i B streams < iCC8
9
+onsole.!rite3ine5F90@ o##set 91@ si&e 92@F $ streamnames6i7 $ o##set6i7 $ ssi&e6i78<
i# 5 streamnames6i7 AA FSVF TT streamnames6i7 AA FSPF 8
9
#or 5 int ii A 0 < ii BA 9 < iiCC8
+onsole.!rite5F90@ F $ metadata6ii7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
i# 5 streamnames6i7 AA FS;trin(sF8
9
#or 5 int ii A 0 < ii BA 9 < iiCC8
+onsole.!rite5F90@ F $ strin(s6ii7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
i# 5 streamnames6i7 AA FSN;F8
9
#or 5 int ii A 0 < ii BA 9 < iiCC8
+onsole.!rite5F90@ F $ us6ii7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
i# 5 streamnames6i7 AA FSDN'=F8
9
#or 5 int ii A 0 < ii BA 9 < iiCC8
+onsole.!rite5F90@ F $ (uid6ii7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
i# 5 streamnames6i7 AA FSOlobF8
9
#or 5 int ii A 0 < ii BA 9 < iiCC8
+onsole.!rite5F90@ F $ blob6ii7.To;trin(5FKF88<
+onsole.!rite3ine58<
@
@
@
int heapsi&es A metadata667<
i# 5 5heapsi&es G 0x018 AA 0x018
o##setstrin( A 4<
i# 5 5heapsi&es G 0x028 AA 0x028
o##set(uid A 4<
i# 5 5heapsi&es G 0x048 AA 0x048
o##setblob A 4<
valid A Oit+onverter.To'nt645metadata$ 88<
tableo##set A 24<
ro"s A ne" int6647<
*rra%.+lear 5ro"s$ 0$ ro"s.3en(th8<
#or 5 int A 0 < BA 63 < CC8
9
int tablepresent A 5int85valid HH 8 G 1<
244260235.doc 485 od 541
i# 5 tablepresent AA 18
9
ro"s67 A Oit+onverter.To'nt325metadata $ tableo##set8<
tableo##set CA 4<
@
@
i# 5 debu( 8
9
#or 5 int A 62 < HA 0 < PP8
9
int tablepresent A 5int85valid HH 8 G 1<
i# 5 tablepresent AA 18
9
+onsole.!rite3ine5F90@ 91@F $ tablenames67 $ ro"s678<
@
@
@
@
public strin( Det;tream)ames5b%te 67 b8
9
int i A 0<
"hile 5b6i7 EA 0 8
9
iCC<
@
;%stem.Text.:ncodin( e A ;%stem.Text.:ncodin(.NT>8<
strin( dumm% A e.Det;trin(5b $ 0 $ i 8<
return dumm%<
@
public void >illTable;i&es58
9
int modulesi&e A 2 C o##setstrin( C o##set(uid C o##set(uid C o##set(uid <
int t%pere#si&e A Det+oded'ndex;i&e5F,esolution;copeF8 C o##setstrin( C o##setstrin( <
int t%pede#si&e A 4 C o##setstrin( C o##setstrin( C Det+oded'ndex;i&e5FT%pe=e#/r,e#F8 C
DetTable;i&e5F0ethodF8 C DetTable;i&e5F>ieldF8<
int #ieldsi&e A 2 C o##setstrin( C o##setblob <
int methodsi&e A 4 C 2 C 2 C o##setstrin( C o##setblob C DetTable;i&e5F4aramF8<
int paramsi&e A 2 C 2 C o##setstrin(<
int inter#aceimplsi&e A DetTable;i&e5FT%pe=e#F8 C Det+oded'ndex;i&e5FT%pe=e#/r,e#F8<
int memberre#si&e A Det+oded'ndex;i&e5F0ember,e#4arentF8 C o##setstrin( C o##setblob <
int constantsi&e A 2 C Det+oded'ndex;i&e5F2as+onstF8 C o##setblob<
int customattributesi&e A Det+oded'ndex;i&e5F2as+ustom*ttributeF8 C
Det+oded'ndex;i&e5F2as+ustom*ttributeT%peF8 C o##setblob<
int #ieldmarshallsi&e A Det+oded'ndex;i&e5F2as>ield0arshalF8 C o##setblob<
int declsecurit%si&e A 2 C Det+oded'ndex;i&e5F2as=ecl;ecurit%F8 C o##setblob<
int classla%outsi&e A 2 C 4 C DetTable;i&e5FT%pe=e#F8<
int #ieldla%outsi&e A 4 C DetTable;i&e5F>ieldF8<
int stanalonssi(si&e A o##setblob<
int eventmapsi&e A DetTable;i&e5FT%pe=e#F8 C DetTable;i&e5F:ventF8<
int eventsi&e A 2 C o##setstrin( C Det+oded'ndex;i&e5FT%pe=e#/r,e#F8<
int propert%mapsi&e A DetTable;i&e5F4ropertiesF8 C DetTable;i&e5FT%pe=e#F8 <
244260235.doc 486 od 541
int propert%si&e A 2 C o##setstrin( C o##setblob<
int methodsemantics A 2 C DetTable;i&e5F0ethodF8 C Det+oded'ndex;i&e5F2as;emanticsF8<
int methodimplsi&e A DetTable;i&e5FT%pe=e#F8 C Det+oded'ndex;i&e5F0ethod=e#/r,e#F8 C
Det+oded'ndex;i&e5F0ethod=e#/r,e#F8<
int modulere#si&e A o##setstrin(<
int t%pespecsi&e A o##setblob<
int implmapsi&e A 2 C Det+oded'ndex;i&e5F0ember>or"ardedF8 C o##setstrin( C
DetTable;i&e5F0odule,e#F8<
int #ieldrvasi&e A 4 C DetTable;i&e5F>ieldF8<
int assembl%si&e A 4 C 2 C 2 C 2 C 2 C 4 C o##setblob C o##setstrin( C o##setstrin( <
int assembl%re#si&e A 2 C 2 C 2 C 2 C 4 C o##setblob C o##setstrin( C o##setstrin( C o##setblob<
int #ilesi&e A 4 C o##setstrin( C o##setblob<
int exportedt%pe A 4 C 4 C o##setstrin( C o##setstrin( C Det+oded'ndex;i&e5F'mplementationF8<
int mani#estresourcesi&e A 4 C 4 C o##setstrin( C Det+oded'ndex;i&e5F'mplementationF8<
int nestedclasssi&e A DetTable;i&e5FT%pe=e#F8 C DetTable;i&e5FT%pe=e#F8 <
si&es A ne" int679 modulesi&e$ t%pere#si&e $ t%pede#si&e $2$ #ieldsi&e $2$methodsi&e $2$paramsi&e
$inter#aceimplsi&e$memberre#si&e $constantsi&e $customattributesi&e $#ieldmarshallsi&e
$declsecurit%si&e $classla%outsi&e $#ieldla%outsi&e$stanalonssi(si&e $eventmapsi&e $2$eventsi&e
$propert%mapsi&e $2$propert%si&e $methodsemantics $methodimplsi&e $modulere#si&e $t%pespecsi&e
$implmapsi&e $#ieldrvasi&e $2 $ 2 $ assembl%si&e $4$12$assembl%re#si&e $6$14$#ilesi&e
$exportedt%pe $mani#estresourcesi&e $nestedclasssi&e @<
@
public int Det+oded'ndex;i&e5strin( nameo#table8
9
i# 5 nameo#table AA F'mplementationF8
9
i# 5 ro"s60x267 HA 16384 TT ro"s60x237 HA 16384 TT ro"s60x277 HA 16384 8
return 4<
else
return 2<
@
else i# 5 nameo#table AA F0ember>or"ardedF8
9
i# 5 ro"s60x047 HA 32768 TT ro"s60x067 HA 327688
return 4<
else
return 2<
@
else i# 5 nameo#table AA F0ethod=e#/r,e#F8
9
i# 5 ro"s60x067 HA 32768 TT ro"s60x0*7 HA 327688
return 4<
else
return 2<
@
else i# 5 nameo#table AA F2as;emanticsF8
9
i# 5 ro"s60x147 HA 32768 TT ro"s60x177 HA 327688
return 4<
else
return 2<
244260235.doc 487 od 541
@
else i# 5 nameo#table AA F2as=ecl;ecurit%F8
9
i# 5 ro"s60x027 HA 16384 TT ro"s60x067 HA 16384 TT ro"s60x207 HA 163848
return 4<
else
return 2<
@
else i# 5 nameo#table AA F2as>ield0arshalF8
9
i# 5 ro"s60x047 HA 32768TT ro"s60x087 HA 327688
return 4<
else
return 2<
@
else i# 5 nameo#table AA FT%pe=e#/r,e#F8
9
i# 5 ro"s60x027 HA 16384 TT ro"s60x017 HA 16384 TT ro"s60x1O7 HA 16384 8
return 4<
else
return 2<
@
else i# 5 nameo#table AA F,esolution;copeF8
9
i# 5 ro"s60x007 HA 16384 TT ro"s60x1a7 HA 16384 TT ro"s60x237 HA 16384 TT ro"s60x017 HA
16384 8
return 4<
else
return 2<
@
else i# 5 nameo#table AA F2as+onstF8
9
i# 5 ro"s647 HA 16384 TT ro"s687 HA 16384 TT ro"s60x177 HA 16384 8
return 4<
else
return 2<
@
else i# 5 nameo#table AA F0ember,e#4arentF8
9
i# 5 ro"s60x087 HA 8192 TT ro"s60x047 HA 8192 TT ro"s60x177 HA 8192 8
return 4<
else
return 2<
@
else i# 5 nameo#table AA F2as+ustom*ttributeF8
9
i# 5 ro"s60x067 HA 2048 TT ro"s60x047 HA 2048 TT ro"s60x017 HA 2048 TT ro"s60x027 HA 2048 TT
ro"s60x087 HA 2048 TT ro"s60x097 HA 2048 TT ro"s60x0a7 HA 2048 TT ro"s60x007 HA 2048 TT
ro"s60x0e7 HA 2048 TT ro"s60x177 HA 2048 TT ro"s60x147 HA 2048 TT ro"s60x117 HA 2048 TT
ro"s60x1a7 HA 2048 TT ro"s60x1b7 HA 2048 TT ro"s60x207 HA 2048 TT ro"s60x237 HA 2048 TT
ro"s60x267 HA 2048 TT ro"s60x277 HA 2048 TT ro"s60x287 HA 2048 8
244260235.doc 488 od 541
return 4<
else
return 2<
@
else i# 5 nameo#table AA F2as+ustom*ttributeT%peF8
9
i# 5 ro"s627 HA 8192 TT ro"s617 HA 8192 TT ro"s667 HA 8192 TT ro"s60x0a7 HA 8192 8
return 4<
else
return 2<
@
else
return 2<
@
public int ,ead+oded'ndex5b%te 67 metadataarra% $ int o##set $ strin( nameo#table8
9
int returnindex A 0<
int codedindexsi&e A Det+oded'ndex;i&e5nameo#table8<
i# 5 codedindexsi&e AA 28
returnindex A Oit+onverter.ToN'nt16 5metadataarra% $ o##set 8<
i# 5 codedindexsi&e AA 48
returnindex A 5int8Oit+onverter.ToN'nt32 5metadataarra% $ o##set 8<
return returnindex<
@
public void ,eadTables'nto;tructures58
9
i# 5 ro"s657 H 08
+onsole.!rite3ine5F........F8<

II0odule
int old A tableo##set<
bool tablehasro"s A tablepresent508<
int o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0odule Table /##set 90@ ;i&e 91@F $ o##s $ si&es6078<
tableo##set A old<
i# 5 tablehasro"s 8
9
0odule;truct A ne" 0oduleTable6ro"s607 C 17<
#or 5 int A 1 < BA ro"s607 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0odule;truct67.Deneration A Oit+onverter.ToN'nt16 5metadata$ o##s8<
o##s CA 2<
0odule;truct67.)ame A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
244260235.doc 489 od 541
0odule;truct67.0vid A ,eadDuid'ndex5metadata$ o##s8<
o##s CA o##set(uid<
0odule;truct67.:nc'd A ,eadDuid'ndex5metadata$ o##s8<
o##s CA o##set(uid<
0odule;truct67.:ncOase'd A ,eadDuid'ndex5metadata$ o##s8<
o##s CA o##set(uid<
@
@
IIT%pe,e#
old A tableo##set<
tablehasro"s A tablepresent518<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5FT%pe,e# Table /##set 90@ ;i&e 91@F $ o##s $ si&es6178<
tableo##set A old<
i# 5 tablehasro"s 8
9
IIi# 5 debu( 8
II+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
T%pe,e#;truct A ne" T%pe,e#Table6ro"s617 C 17<
#or 5 int A 1 < BAro"s617 < CC8
9
IIi# 5 debu( 8
II+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
T%pe,e#;truct67.resolutionscope A ,ead+oded'ndex5metadata $ o##s $ F,esolution;copeF8<
o##s A o##s C Det+oded'ndex;i&e5F,esolution;copeF8<
T%pe,e#;truct67.name A ,ead;trin('ndex5metadata $ o##s8<
o##s A o##s C o##setstrin(<
T%pe,e#;truct67.nspace A ,ead;trin('ndex5metadata $ o##s8<
o##s A o##s C o##setstrin(<
II+onsole.!rite3ine5F......T%pe,e# 90@F $ Det;trin(5T%pe,e#;truct67.name88<
@
@
IIT%pe=e#
old A tableo##set<
tablehasro"s A tablepresent528<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5FT%pe=e# Table /##set 90@ ;i&e 91@F $ o##s $ si&es6278<
tableo##set A old<
i# 5 tablehasro"s 8
9
T%pe=e#;truct A ne" T%pe=e#Table6ro"s627 C 17<
244260235.doc 490 od 541
#or 5 int A 1 < BA ro"s627 < CC8
9
IIi# 5 debu( 8
II+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@ 98@ 99@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 $
metadata6o##sC97.To;trin(5FKF8 $ metadata6o##sC107.To;trin(5FKF8 8<
T%pe=e#;truct67.#la(s A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
T%pe=e#;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
T%pe=e#;truct67.nspace A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
T%pe=e#;truct67.cindex A ,ead+oded'ndex5metadata $ o##s $ FT%pe=e#/r,e#F8<
o##s CA Det+oded'ndex;i&e5FT%pe=e#/r,e#F8<
T%pe=e#;truct67.#index A ,eadTable'ndex5metadata$ o##s $ F>ieldF8<
o##s CA DetTable;i&e5F>ieldF8<
T%pe=e#;truct67.mindex A ,eadTable'ndex5metadata$ o##s $ F0ethodF8<
o##s CA DetTable;i&e5F0ethodF8<
II+onsole.!rite3ine5F......T%pe=e# 90@F $ Det;trin(5T%pe=e#;truct67.name88<
@
@
II>ield4tr
old A tableo##set<
tablehasro"s A tablepresent538<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F>ield4tr Table /##set 90@ ;i&e 91@F $ o##s $ si&es6378<
tableo##set A old<
i# 5 tablehasro"s 8
9
>ield4tr;truct A ne" >ield4trTable6ro"s637 C 17<
#or 5 int A 1 < BA ro"s637 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
>ield4tr;truct67.index A Oit+onverter.To'nt165metadata$ o##s8<
o##s CA 2<
@
@
II>ield
old A tableo##set<
tablehasro"s A tablepresent548<
o##s A tableo##set<
i# 5 debu( 8
244260235.doc 491 od 541
+onsole.!rite3ine5F>ield Table /##set 90@ ;i&e 91@F $ o##s $ si&es6478<
tableo##set A old<
i# 5 tablehasro"s 8
9
>ield;truct A ne" >ieldTable6ro"s647 C 17<
#or 5 int A 1 < BA ro"s647 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
>ield;truct67.#la(s A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
>ield;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
>ield;truct67.si( A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II0ethod4tr
old A tableo##set<
tablehasro"s A tablepresent558<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0ethod Table /##set 90@ ;i&e 91@F $ o##s $ si&es6578<
tableo##set A old<
i# 5 tablehasro"s 8
9
0ethod4tr;truct A ne" 0ethod4trTable6ro"s657 C 17<
#or 5 int A 1 < BA ro"s657 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0ethod4tr;truct67.index A Oit+onverter.To'nt165metadata$ o##s8<
o##s CA 2<
@
@
II0ethod
old A tableo##set<
tablehasro"s A tablepresent568<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0ethod Table /##set 90@ ;i&e 91@F $ o##s $ si&es6678<
tableo##set A old<
i# 5 tablehasro"s 8
244260235.doc 492 od 541
9
0ethod;truct A ne" 0ethodTable6ro"s667 C 17<
#or 5 int A 1 < BA ro"s667 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0ethod;truct67.rva A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
0ethod;truct67.imp#la(s A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
0ethod;truct67.#la(s A 5int8Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
0ethod;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
0ethod;truct67.si(nature A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
0ethod;truct67.param A ,eadTable'ndex5metadata$ o##s $ F4aramF8<
o##s CA DetTable;i&e5F4aramF8<
II+onsole.!rite3ine5F0ethod nameA90@ 4arm)oA91@F $
Det;trin(50ethod;truct67.name8$0ethod;truct67.param8<
@
@
II4aram
old A tableo##set<
tablehasro"s A tablepresent588<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F4aram Table /##set 90@ ;i&e 91@F $ o##s $ si&es6878<
tableo##set A old<
i# 5 tablehasro"s 8
9
4aram;truct A ne" 4aramTable6ro"s687 C 17<
#or 5 int A 1 < BA ro"s687 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
4aram;truct67.pattr A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
4aram;truct67.se.uence A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
4aram;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
244260235.doc 493 od 541
II+onsole.!rite3ine5F4aram 90@ nameA92@ se.A91@ attrA93@F $$ 4aram;truct67.se.uence $
Det;trin(54aram;truct67.name8 $ 4aram;truct67.pattr8<
@
@
II'nter#ace'mpl
old A tableo##set<
tablehasro"s A tablepresent598<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F'nter#ace'mpl Table /##set 90@ ;i&e 91@F $ o##s $ si&es6978<
tableo##set A old<
i# 5 tablehasro"s 8
9
'nter#ace'mpl;truct A ne" 'nter#ace'mplTable6ro"s697 C 17<
#or 5 int A 1 < BA ro"s697 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
'nter#ace'mpl;truct67.classindex A ,ead+oded'ndex5metadata $ o##s $ FT%pe=e#/r,e#F8<
o##s CA Det+oded'ndex;i&e5FT%pe=e#/r,e#F8<
'nter#ace'mpl;truct67.inter#aceindex A ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
@
@
II0ember,e#
old A tableo##set<
tablehasro"s A tablepresent5108<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0ember,e# Table /##set 90@ ;i&e 91@F $ o##s$ si&es61078<
tableo##set A old<
i# 5 tablehasro"s 8
9
0ember,e#;truct A ne" 0ember,e#Table6ro"s6107 C 17<
#or 5 int A 1 < BA ro"s6107 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0ember,e#;truct67.clas A ,ead+oded'ndex5metadata $ o##s $ F0ember,e#4arentF8<
o##s CA Det+oded'ndex;i&e5F0ember,e#4arentF8<
0ember,e#;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
0ember,e#;truct67.si( A ,eadOlob'ndex5metadata$ o##s8<
244260235.doc 494 od 541
o##s CA o##setblob<
@
@
II+onstants
old A tableo##set<
tablehasro"s A tablepresent5118<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F+onstant Table /##set 90@ ;i&e 91@F $ o##s$ si&es61178<
tableo##set A old<
i# 5 tablehasro"s 8
9
+onstants;truct A ne" +onstantsTable6ro"s6117 C 17<
#or 5 int A 1 < BA ro"s6117 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
+onstants;truct67.dt%pe A metadata6o##s7<
o##s CA 2<
+onstants;truct67.parent A ,ead+oded'ndex5metadata $ o##s $ F2as+onstF8<
o##s CA Det+oded'ndex;i&e5F2as+onstF8<
+onstants;truct67.value A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II+ustom*ttribute
old A tableo##set<
tablehasro"s A tablepresent5128<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F+ustom*ttribute Table /##set 90@ ;i&e 91@F $ o##s $ si&es61278<
tableo##set A old<
i# 5 tablehasro"s 8
9
+ustom*ttribute;truct A ne" +ustom*ttributeTable6ro"s6127 C 17<
#or 5 int A 1 < BA ro"s6127 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
+ustom*ttribute;truct67.parent A ,ead+oded'ndex5metadata $ o##s $ F2as+ustom*ttributeF8<
o##s CA Det+oded'ndex;i&e5F2as+ustom*ttributeF8<
+ustom*ttribute;truct67.t%pe A ,ead+oded'ndex5metadata $ o##s $ F2as+ustom*ttributeT%peF8<
o##s CA Det+oded'ndex;i&e5F2as+ustom*ttributeT%peF8<
244260235.doc 495 od 541
+ustom*ttribute;truct67.value A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II>ield0arshal
old A tableo##set<
tablehasro"s A tablepresent5138<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F>ield0arshal Table /##set 90@ ;i&e 91@F $ o##s $ si&es61378<
tableo##set A old<
i# 5 tablehasro"s 8
9
>ield0arshal;truct A ne" >ield0arshalTable6ro"s6137 C 17<
#or 5 int A 1 < BA ro"s6137 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
>ield0arshal;truct67.coded A ,ead+oded'ndex5metadata $ o##s $ F2as>ield0arshalF8<
o##s CA Det+oded'ndex;i&e5F2as>ield0arshalF8<
>ield0arshal;truct67.index A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II=ecl;ecurit%
old A tableo##set<
tablehasro"s A tablepresent5148<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F=ecl;ecurit% Table /##set 90@ ;i&e 91@F $ o##s $ si&es61478<
tableo##set A old<
i# 5 tablehasro"s 8
9
=ecl;ecurit%;truct A ne" =ecl;ecurit%Table6ro"s6147 C 17<
#or 5 int A 1 < BA ro"s6147 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
=ecl;ecurit%;truct67.action A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
=ecl;ecurit%;truct67.coded A ,ead+oded'ndex5metadata $ o##s $ F2as=ecl;ecurit%F8<
o##s CA Det+oded'ndex;i&e5F2as=ecl;ecurit%F8<
=ecl;ecurit%;truct67.bindex A ,eadOlob'ndex5metadata$ o##s8<
244260235.doc 496 od 541
o##s CA o##setblob<
@
@
II+lass3a%out
old A tableo##set<
tablehasro"s A tablepresent5158<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F+lass3a%out Table /##set 90@ ;i&e 91@F $ o##s$ si&es61578<
tableo##set A old<
i# 5 tablehasro"s 8
9
+lass3a%out;truct A ne" +lass3a%outTable6ro"s6157 C 17<
#or 5 int A 1 < BA ro"s6157 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
+lass3a%out;truct67.pacin(si&e A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
+lass3a%out;truct67.classsi&e A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
+lass3a%out;truct67.parent A ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
@
@
II>ield3a%out
old A tableo##set<
tablehasro"s A tablepresent5168<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F>ield3a%out Table /##set 90@ 91@F $ o##s$ si&es61678<
tableo##set A old<
i# 5 tablehasro"s 8
9
>ield3a%out;truct A ne" >ield3a%outTable6ro"s6167 C 17<
#or 5 int A 1 < BA ro"s6167 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
>ield3a%out;truct67.o##set A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
>ield3a%out;truct67.#ieldindex A ,eadTable'ndex5metadata$ o##s $ F>ieldF8<
o##s CA DetTable;i&e5F>ieldF8<
244260235.doc 497 od 541
@
@
II;tand*lone;i(
old A tableo##set<
tablehasro"s A tablepresent5178<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F;tand*lone;i( Table /##set 90@ ;i&e 91@F $ o##s$ si&es61778<
tableo##set A old<
i# 5 tablehasro"s 8
9
;tand*lone;i(;truct A ne" ;tand*lone;i(Table6ro"s6177 C 17<
#or 5 int A 1 < BA ro"s6177 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
;tand*lone;i(;truct67.index A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II:vent0ap
old A tableo##set <
tablehasro"s A tablepresent5188<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F:vent0ap Table /##set 90@ ;i&e 91@F $ o##s$ si&es61878<
tableo##set A old<
i# 5 tablehasro"s 8
9
:vent0ap;truct A ne" :vent0apTable 6ro"s6187 C 17<
#or 5 int A 1 < BA ro"s6187 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
:vent0ap;truct67.index A ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
:vent0ap;truct67.eindex A ,eadTable'ndex5metadata$ o##s $ F:ventF8<
o##s CA DetTable;i&e5F:ventF8<
@
@
II:vent
old A tableo##set<
tablehasro"s A tablepresent5208<
244260235.doc 498 od 541
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F:vent Table /##set 90@ ;i&e 91@F $ o##s$ si&es62078<
tableo##set A old<
i# 5 tablehasro"s 8
9
:vent;truct A ne" :ventTable6ro"s6207 C 17<
#or 5 int A 1 < BA ro"s6207 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
:vent;truct67.attr A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
:vent;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
:vent;truct67.coded A ,ead+oded'ndex5metadata $ o##s $ FT%pe=e#/r,e#F8<
o##s CA Det+oded'ndex;i&e5FT%pe=e#/r,e#F8<
@
@
II4ropert%0ap
old A tableo##set<
tablehasro"s A tablepresent5218<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F4ropert%0ap Table /##set 90@ ;i&e 91@F $ o##s$ si&es62178<
tableo##set A old<
i# 5 tablehasro"s 8
9
4ropert%0ap;truct A ne" 4ropert%0apTable6ro"s6217 C 17<
#or 5 int A 1 < BA ro"s6217 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
4ropert%0ap;truct67.parent A ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
4ropert%0ap;truct67.propert%list A ,eadTable'ndex5metadata$ o##s $ F4ropertiesF8<
o##s CA DetTable;i&e5F4ropertiesF8<
@
@
II4ropert%
old A tableo##set<
tablehasro"s A tablepresent5238<
o##s A tableo##set<
244260235.doc 499 od 541
i# 5 debu( 8
+onsole.!rite3ine5F4ropert% Table /##set 90@ ;i&e 91@F $ o##s$ si&es62378<
tableo##set A old<
i# 5 tablehasro"s 8
9
4ropert%;truct A ne" 4ropert%Table6ro"s6237 C 17<
#or 5 int A 1 < BA ro"s6237 < CC8
9
IIi# 5 debu( 8
II+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
4ropert%;truct67.#la(s A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
4ropert%;truct67.nameA ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
4ropert%;truct67.t%pe A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
II+onsole.!rite3ine5F...90@ 91@ 92@ 93@F $ $ Det;trin(54ropert%;truct67.name8 $
4ropert%;truct67.#la(s $ 4ropert%;truct67.t%pe8<
@
@
II0ethod;emantics
old A tableo##set <
tablehasro"s A tablepresent5248<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0ethod;emantics Table /##set 90@ ;i&e 91@F $ o##s$ si&es62478<
tableo##set A old<
i# 5 tablehasro"s 8
9
0ethod;emantics;truct A ne" 0ethod;emanticsTable6ro"s6247 C 17<
#or 5 int A 1 < BA ro"s6247 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0ethod;emantics;truct67.methodsemanticsattributes A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
0ethod;emantics;truct67.methodindex A ,eadTable'ndex5metadata$ o##s $ F0ethodF8<
o##s CA DetTable;i&e5F0ethodF8<
0ethod;emantics;truct67.association A ,ead+oded'ndex5metadata $ o##s $ F2as;emanticsF8<
o##s CA Det+oded'ndex;i&e5F2as;emanticsF8<
@
@
II0ethod'mpl
244260235.doc 500 od 541
old A tableo##set<
tablehasro"s A tablepresent5258<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0ethod'mpl Table /##set 90@ 91@F $ o##s$ si&es62578<
tableo##set A old<
i# 5 tablehasro"s 8
9
0ethod'mp;truct A ne" 0ethod'mpTable6ro"s6257 C 17<
#or 5 int A 1 < BA ro"s6257 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0ethod'mp;truct67.classindex A ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
0ethod'mp;truct67.codedbod% A ,ead+oded'ndex5metadata $ o##s $ F0ethod=e#/r,e#F8<
o##s CA Det+oded'ndex;i&e5F0ethod=e#/r,e#F8<
0ethod'mp;truct67.codedde# A ,ead+oded'ndex5metadata $ o##s $ F0ethod=e#/r,e#F8<
o##s CA Det+oded'ndex;i&e5F0ethod=e#/r,e#F8<
@
@
II0odule,e#
old A tableo##set<
tablehasro"s A tablepresent5268<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0odule,e# Table /##set 90@ ;i&e 91@F $ o##s$ si&es62678<
tableo##set A old<
i# 5 tablehasro"s 8
9
0odule,e#;truct A ne" 0odule,e#Table6ro"s6267 C 17<
#or 5 int A 1 < BA ro"s6267 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0odule,e#;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
@
@
IIT%pe;pec
old A tableo##set<
tablehasro"s A tablepresent5278<
o##s A tableo##set<
244260235.doc 501 od 541
i# 5 debu( 8
+onsole.!rite3ine5FT%pe;pec Table /##set 90@ ;i&eA91@F $ o##s $ si&es62778<
tableo##set A old<
i# 5 tablehasro"s 8
9
T%pe;pec;truct A ne" T%pe;pecTable6ro"s6277 C 17<
#or 5 int A 1 < BA ro"s6277 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
T%pe;pec;truct67.si(nature A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II'mpl0ap
old A tableo##set<
tablehasro"s A tablepresent5288<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F'mpl0ap Table /##set o##sA90@ ;i&e 91@F $ o##s $ si&es62878<
tableo##set A old<
i# 5 tablehasro"s 8
9
'mpl0ap;truct A ne" 'mpl0apTable6ro"s6287 C 17<
#or 5 int A 1 < BA ro"s6287 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
'mpl0ap;truct67.attr A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
'mpl0ap;truct67.cindex A ,ead+oded'ndex5metadata $ o##s $ F0ember>or"ardedF8<
o##s CA Det+oded'ndex;i&e5F0ember>or"ardedF8<
'mpl0ap;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
'mpl0ap;truct67.scope A ,eadTable'ndex5metadata$ o##s $ F0odule,e#F8<
o##s CA DetTable;i&e5F0odule,e#F8<
@
@
II>ield,-*
old A tableo##set<
tablehasro"s A tablepresent5298<
o##s A tableo##set<
i# 5 debu( 8
244260235.doc 502 od 541
+onsole.!rite3ine5F>ield,-* Table /##set 90@ ;i&e 91@F $ o##s$ si&es62978<
tableo##set A old<
i# 5 tablehasro"s 8
9
>ield,-*;truct A ne" >ield,-*Table6ro"s6297 C 17<
#or 5 int A 1 < BA ro"s6297 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
>ield,-*;truct67.rva A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
>ield,-*;truct67.#ieldi A ,eadTable'ndex5metadata$ o##s $ F>ieldF8<
o##s CA DetTable;i&e5F>ieldF8<
@
@
II*ssemble%
old A tableo##set<
tablehasro"s A tablepresent5328<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F*ssembl% Table /##set 90@ ;i&e 91@F $ o##s$ si&es63278<
tableo##set A old<
*ssembl%;truct A ne" *ssembl%Table6ro"s6327 C 17<
i# 5 tablehasro"s 8
9
#or 5 int A 1 < BA ro"s6327 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
*ssembl%;truct67.2ash*l('d A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
*ssembl%;truct67.ma1or A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%;truct67.minor A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%;truct67.buildA Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%;truct67.revision A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%;truct67.#la(s A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
*ssembl%;truct67.publice% A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
244260235.doc 503 od 541
*ssembl%;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
*ssembl%;truct67.culture A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
@
@
II*ssembl%,e#
old A tableo##set<
tablehasro"s A tablepresent5358<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F*ssemble%,e# Table /##set 90@ ;i&e 91@F $ o##s$ si&es63578<
tableo##set A old<
i# 5 tablehasro"s 8
9
*ssembl%,e#;truct A ne" *ssembl%,e#Table6ro"s6357 C 17<
#or 5 int A 1 < BA ro"s6357< CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
*ssembl%,e#;truct67.ma1or A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%,e#;truct67.minor A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%,e#;truct67.buildA Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%,e#;truct67.revision A Oit+onverter.To'nt16 5metadata$ o##s8<
o##s CA 2<
*ssembl%,e#;truct67.#la(s A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
*ssembl%,e#;truct67.publice% A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
*ssembl%,e#;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
*ssembl%,e#;truct67.culture A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
*ssembl%,e#;truct67.hashvalue A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II>ile
old A tableo##set<
tablehasro"s A tablepresent5388<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F>ile Table /##set 90@ ;i&e 91@F $ o##s$ si&es63878<
tableo##set A old<
244260235.doc 504 od 541
i# 5 tablehasro"s 8
9
>ile;truct A ne" >ileTable6ro"s6387 C 17<
#or 5 int A 1 < BA ro"s6387 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
>ile;truct67.#la(s A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
>ile;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
>ile;truct67.index A ,eadOlob'ndex5metadata$ o##s8<
o##s CA o##setblob<
@
@
II:xportedT%pe
old A tableo##set<
tablehasro"s A tablepresent5398<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F:xportedT%pe Table /##set 90@ ;i&e 91@F $ o##s$ si&es63978<
tableo##set A old<
i# 5 tablehasro"s 8
9
:xportedT%pe;truct A ne" :xportedT%peTable6ro"s6397 C 17<
#or 5 int A 1 < BA ro"s6397 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 8<
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ F $ metadata6o##sC87.To;trin(5FKF8 $
metadata6o##sC97.To;trin(5FKF8 $ metadata6o##sC107.To;trin(5FKF8
$metadata6o##sC117.To;trin(5FKF8 $metadata6o##sC127.To;trin(5FKF8
$metadata6o##sC137.To;trin(5FKF8 $ metadata6o##sC147.To;trin(5FKF8 8<
:xportedT%pe;truct67.#la(s A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
:xportedT%pe;truct67.t%pede#index A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
:xportedT%pe;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
:xportedT%pe;truct67.nspace A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
:xportedT%pe;truct67.coded A ,ead+oded'ndex 5 metadata$ o##s $ F'mplementationF8<
244260235.doc 505 od 541
o##s CA Det+oded'ndex;i&e5F'mplementationF8<
II+onsole.!rite3ine5F......90@ 91@F $ :xportedT%pe;truct67.coded $
:xportedT%pe;truct67.name 8<
@
@
II0ani#est,esource
old A tableo##set<
tablehasro"s A tablepresent5408<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F0ani#est,esource Table /##set 90@ ;i&e 91@F $ o##s$ si&es64078<
tableo##set A old<
i# 5 tablehasro"s 8
9
0ani#est,esource;truct A ne" 0ani#est,esourceTable6ro"s6407 C 17<
#or 5 int A 1 < BA ro"s6407 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
0ani#est,esource;truct67.o##set A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
0ani#est,esource;truct67.#la(s A Oit+onverter.To'nt32 5metadata$ o##s8<
o##s CA 4<
0ani#est,esource;truct67.name A ,ead;trin('ndex5metadata$ o##s8<
o##s CA o##setstrin(<
0ani#est,esource;truct67.coded A ,ead+oded'ndex5metadata $ o##s $ F'mplementationF8<
o##s CA Det+oded'ndex;i&e5FF8<
@
@
II)ested +lasses
old A tableo##set<
tablehasro"s A tablepresent5418<
o##s A tableo##set<
i# 5 debu( 8
+onsole.!rite3ine5F)ested +lasses /##set 90@ ;i&e 91@F $ o##s$ si&es64178<
tableo##set A old<
i# 5 tablehasro"s 8
9
)ested+lass;truct A ne" )ested+lassTable6ro"s6417 C 17<
#or 5 int A 1 < BA ro"s6417 < CC8
9
i# 5 debu( 8
+onsole.!rite3ine5F90@ 91@ 92@ 93@ 94@ 95@ 96@ 97@F $ metadata6o##s7.To;trin(5FKF8 $
metadata6o##sC17.To;trin(5FKF8 $ metadata6o##sC27.To;trin(5FKF8
$metadata6o##sC37.To;trin(5FKF8 $metadata6o##sC47.To;trin(5FKF8
$metadata6o##sC57.To;trin(5FKF8 $ metadata6o##sC67.To;trin(5FKF8 $
metadata6o##sC77.To;trin(5FKF8 $ metadata6o##sC87.To;trin(5FKF8 8<
244260235.doc 506 od 541
)ested+lass;truct67.nestedclassA ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
)ested+lass;truct67.enclosin(classA ,eadTable'ndex5metadata$ o##s $ FT%pe=e#F8<
o##s CA DetTable;i&e5FT%pe=e#F8<
@
@
int ii <
#or 5 ii A 1 < ii BA T%pe=e#;truct.3en(th P 1 < iiCC8
9
II+onsole.!rite3ine5F........90@ 91@ 92@F $ T%pe=e#;truct.3en(th $ 'sT%pe)ested5ii8 $ ii8<
i# 5 E 'sT%pe)ested5ii8 8
lastt%pedispla%ed A ii<
@
@
public bool tablepresent5b%te tableindex8
9
int tablebit A 5int85valid HH tableindex8 G 1<
#or 5 int 1 A 0 < 1 B tableindex < 1CC8
9
int o A si&es617 J ro"s617<
tableo##set A tableo##set C o<
@
i# 5 tablebit AA 18
return true<
else
return #alse<
@
public void ,eadand=ispla%:xport*ddressTable?umps58
9
+onsole.!rite3ine5FII :xport *ddress Table ?umpsMF8<
i# 5 exportaddressrva AA 08
9
+onsole.!rite3ine5FII )o data.F8<
+onsole.!rite3ine58<
@
@
public void +reate>ield;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F>ield 3en(thA90@ method ro"A91@ nameA92@F $ blobarra%.3en(th $
ro".To;trin(5FKF8 $ Det;trin(5>ield;truct6ro"7.name88<
int aa A P1<
i# 5 ro" AA aa 8
9
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
+onsole.!rite3ine5F3en(th o# arra% is 90@F $ blobarra%.3en(th8<
@
int ho"man%b%tes $ uncompressedb%te<
int index A 0<
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
244260235.doc 507 od 541
index A index C ho"man%b%tes<
strin( returnstrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8<
returnstrin( A returnstrin(.,eplace5F`F$F$F8<
i# 5 ro" AA aa 8
+onsole.!rite3ine5F......returnstrin(A90@F $ returnstrin(8<
IIi# 5 returnstrin( EA FF8
IIreturnstrin( A returnstrin(.,emove5returnstrin(.3en(thP1$ 18<
#ieldparamarra%6ro"7 A returnstrin(<
#ield#la(sarra%6ro"7 A Det>ield*ttributes5ro"8<
@
public void +reate3ocal-ar;i(nature 5b%te 67 blobarra% $ int ro"8
9
II+onsole.!rite3ine5F3ocal -ariable *rra% 3en(thA90@ method ro"A91@ F $ blobarra%.3en(th $
ro" 8<
int aa A P1<
i# 5 blobarra%.3en(th AA 08
return<
i# 5 ro" AA aa8
9
#or 5 int l A 0 < l B blobarra%.3en(th < lCC8
+onsole.!rite5F90@ F $ blobarra%6l7.To;trin(5FKF88<
+onsole.!rite3ine58<
+onsole.!rite3ine5F3en(th o# arra% is 90@F $ blobarra%.3en(th8<
@
int index A 0<
standalonesi(arra%6ro"7 A FF<
i# 5 blobarra%6index7 EA 0x078
return<
indexCC<
int ho"man%b%tes$uncompressedb%te <
ho"man%b%tes A +or;i(Nncompress=ata5blobarra% $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
strin( returnstrin( A FF<
#or 5 int l A 1 < l BA uncompressedb%te < lCC8
9
strin( t%pestrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes $ 0 $ FF8<
t%pestrin( A t%pestrin(.,eplace5F`F$F$F8<
i# 5 ro" AA aa8
+onsole.!rite3ine5F......lA90@ t%pestrin(A91@ indexA92@ ho"man%b%tesA93@ valueA94@F $ l $
t%pestrin( $ index $ ho"man%b%tes $ blobarra%6index7.To;trin(5FKF88<
IIi# 5 t%pestrin( EA FF8
IIt%pestrin( A t%pestrin(.,emove5t%pestrin(.3en(thP1 $ 18<
int variable-index A l P 1 <
returnstrin( A returnstrin( C t%pestrin( C F -RF C variable-index.To;trin(58 <
i# 5 l EA uncompressedb%te8
returnstrin( A returnstrin( C F$UrUnF C +reate;paces5spaces#orrest C 2 C spaces#ornested8 C
+reate;paces598<
index A index C ho"man%b%tes<
@
standalonesi(arra%6ro"7 A returnstrin(<
@
244260235.doc 508 od 541
public strin( Det4ointerToen5int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int ho"man%b%tes2<
returnstrin( A Det:lementT%pe5indexC1 $ blobarra% $ out ho"man%b%tes2 $ 0 $ FF8 C FJF<
ho"man%b%tes A ho"man%b%tes2 C 1<
return returnstrin(<
@
public strin( DetO%re#Toen 5int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int ho"man%b%tes2<
returnstrin( A Det:lementT%pe5indexC1 $ blobarra% $ out ho"man%b%tes2 $ 0 $ FF8 C FGF<
ho"man%b%tes A ho"man%b%tes2 C 1<
return returnstrin(<
@
public strin( Det;&*rra%5int index $ b%te 67 blobarra% $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int i A 1<
returnstrin( A F67F<
"hile 5 true 8
9
b%te next A blobarra%6indexCi7<
i# 5 next EA 0x1d 8
brea<
returnstrin( A returnstrin( C F67F<
i A i C1 <
@
int ho"man%b%tes2<
returnstrin( A Det:lementT%pe5index C i $ blobarra% $ out ho"man%b%tes2$0 $ FF8 C returnstrin(<
ho"man%b%tes A i C ho"man%b%tes2<
return returnstrin(<
@
public strin( DetToenT%pe 5 b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
int uncompressedb%te<
int ho"man%b%tes1 A 0<
ho"man%b%tes1 A ho"man%b%tes1 C +or;i(Nncompress=ata5blobarra% $ index C 1 $ out
uncompressedb%te8<
strin( dumm%1 A =ecodeToen5uncompressedb%te $ blobarra%6index78<
i# 5 blobarra%6index7 AA 0x128
returnstrin( A Fclass F C dumm%1<
else i# 5 blobarra%6index7 AA 0x118
returnstrin( A Fvaluet%pe F C dumm%1<
else
returnstrin( A dumm%1<
ho"man%b%tes A ho"man%b%tes1<
return returnstrin(<
@
244260235.doc 509 od 541
public strin( Det4ointerT%pe 5 b%te 67 blobarra% $ int index $ out int ho"man%b%tes8
9
strin( returnstrin( A FF<
returnstrin( A Det:lementT%pe5index $ blobarra% $ out ho"man%b%tes$0 $ FF8 C FJF <
return returnstrin(<
@
public void =ispla%/verride0ethod 5int methodro"8
9
i# 5 0ethod'mp;truct AA null 8
return<
#or 5 int ii A 1 < ii B 0ethod'mp;truct.3en(th < iiCC8
9
strin( codedde#tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedde# 8<
int codedde#index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedde# 8<
strin( codedbod%tablename A Det0ethod=e#Table50ethod'mp;truct6ii7.codedbod%8<
int codedbod%index A Det0ethod=e#-alue50ethod'mp;truct6ii7.codedbod% 8<
int t%peindex A DetT%pe>or0ethod5codedbod%index8<
i# 5 t%peindex AA 0ethod'mp;truct6ii7.classindex GG codedbod%tablename AA F0ethod=e#F
GG codedbod%index AA methodro"8
9
i# 5 codedde#tablename AA F0ethod,e#F 8
9
+onsole.!rite5+reate;paces5spaces#orrestC2 C spaces#ornested88<
+onsole.!rite5F.override F8<
int t%pere#index A DetT%pe,e#>rom0ethod,e#5codedde#index8<
+onsole.!rite3ine5F90@MM91@ IJ0192@MM0*93@JI F $ t%pere#names6t%pere#index7$
)ame,eserved5Det;trin(50ember,e#;truct6codedde#index7.name88 $ t%pere#index
.To;trin(5FK6F8 $ codedde#index.To;trin(5FK6F88<
@
i# 5 codedde#tablename AA F0ethod=e#F 8
9
+onsole.!rite5+reate;paces5spaces#orrestC2 C spaces#ornested88<
int t%pede#index A DetT%pe>or0ethod5codedde#index8<
+onsole.!rite5F.override 90@MM91@ F $
t%pede#names6t%pede#index7$)ame,eserved5Det;trin(50ethod;truct6codedde#index7.name88 8<
+onsole.!rite3ine5FIJ0290@MM0691@JI F $ t%pede#index.To;trin(5FK6F8 $
codedde#index.To;trin(5FK6F88<
@
@
@
@
public bool 'sDlobal0ethod 5int methodro"8
9
int start $ starto#nextA0<
II+onsole.!rite3ine5F........methodro"A90@ T%pe=e#;truct.3en(thA91@F $ methodro" $
T%pe=e#;truct.3en(th8<
i# 5 T%pe=e#;truct.3en(th AA 28
return true<
start A T%pe=e#;truct617.mindex <
i# 5 T%pe=e#;truct.3en(th AA 1 8
9
244260235.doc 510 od 541
starto#nextA 0ethod;truct.3en(th<
@
else
starto#next A T%pe=e#;truct627.mindex<
i# 5 methodro" HA start GG methodro" B starto#next 8
return true<
else
return #alse<
@
public strin( Det0ethod*ttribute1 5int method#la(s8
9
strin( returnstrin( A FF<
i# 5 5method#la(s G 0x00038 AA 0x00038
returnstrin( A returnstrin( C Fruntime F<
else
i# 5 5method#la(s G 0x00018 AA 0x00018
returnstrin( A returnstrin( C Fnative F<
else
i# 5 5method#la(s G 0x00028 AA 0x00028
returnstrin( A returnstrin( C Foptil F<

else
returnstrin( A returnstrin( C Fcil F<
i# 5 5method#la(s G 0x00048 AA 0x00048
returnstrin( A returnstrin( C Funmana(edF<
else
returnstrin( A returnstrin( C Fmana(edF<
i# 5 5method#la(s G 0x00808 AA 0x00808
returnstrin( A returnstrin( C F preservesi(F<
i# 5 5method#la(s G 0x00108 AA 0x00108
returnstrin( A returnstrin( C F #or"ardre#F<
i# 5 5method#la(s G 0x010008 AA 0x10008
returnstrin( A returnstrin( C F internalcallF<
i# 5 5method#la(s G 0x00208 AA 0x00208
returnstrin( A returnstrin( C F s%nchroni&edF<
i# 5 5method#la(s G 0x00088 AA 0x00088
returnstrin( A returnstrin( C F noinlinin(F<
return returnstrin(<
@
int 67 si&es<
public :xceptionTable 67 :xception;truct<
int codesi&e <
>ile;tream m#ilestream <
Oinar%,eader mbinar%reader <
int subs%stem<
int stacreserve <
int staccommit<
int datad<
int entr%point<
int 'ma(eOase<
int sectiona<
244260235.doc 511 od 541
int #ilea<
int 67 methodvtentr%arra% <
strin( 67 vt#ixuparra%<
strin( 67 datavt#ixuparra%<
/p+ode 67 /p+odes*rra%<
/p+ode 67 /p+odes*rra%1<
int 67 datadirector%rva<
int 67 datadirector%si&e<
lon( sectiono##set<
short sections <
int metadatarva<
int entr%pointtoen<
int 67 ;-irtual*ddress <
int 67 ;;i&e/#,a"=ata<
int 67 ;4ointerTo,a"=ata <
strin( 67 paramnames<
strin( 67 t%pere#names<
strin( 67 t%pede#names<
lon( starto#metadata<
strin( 67 streamnames<
int tableo##set <
int 67 ro"s<
lon( valid <
b%te 67 metadata<
b%te 67 strin(s<
b%te 67 us<
b%te 67 (uid<
b%te 67 blob<
int 67 o##set<
int 67 ssi&e <
b%te 6767 names<
int o##setstrin( A 2<
int o##setblob A 2<
int o##set(uid A 2<
IIint cb<
int count<
int vtablerva<
int vtablesi&e<
int exportaddressrva<
int exportaddresssi&e<
int cor#la(s<
strin( 67 tablenames A ne" ;trin(679F0oduleF $ FT%pe,e#F $FT%pe=e#F $F>ield4trF$F>ieldF$
F0ethod4trF$F0ethodF$F4aram4trF $ F4aramF$ F'nter#ace'mplF$ F0ember,e#F$ F+onstantF$
F+ustom*ttributeF$ F>ield0arshalF$ F=ecl;ecurit%F$ F+lass3a%outF$ F>ield3a%outF$
F;tand*lone;i(F $ F:vent0apF$F:vent4trF$ F:ventF$ F4ropert%0apF$ F4ropert%4trF$
F4ropertiesF$F0ethod;emanticsF$F0ethod'mplF$F0odule,e#F$FT%pe;pecF$F'mpl0apF$F>ield,-*
F$F:)+3o(F$F:)+0apF$F*ssembl%F$F*ssembl%4rocessorF$F*ssembl%/;F$F*ssembl%,e#F$F*ss
embl%,e#4rocessorF$F*ssembl%,e#/;F$F>ileF$F:xportedT%peF$F0ani#est,esourceF$F)ested+las
sF$FT%peT%4arF$F0ethodT%4arF@<
strin( 67 standalonesi(arra%<
strin( 67 propert%t%pearra%<
244260235.doc 512 od 541
strin( 67 propert%returnarra% <
strin( 67 propert%parmarra%<
strin( 67 methodde#paramarra% <
strin( 67 methodde#paramarra%1 <
strin( 67 methodde#returnarra% <
int 67 methodde#paramcount<
strin( 67 methodde#t%pearra% <
strin( 67 methodre#paramarra%1 <
strin( 67 methodre#returnarra% <
strin( 67 methodre#t%pearra%<
strin( 67 #ield#la(sarra% <
strin( 67 #ieldparamarra% <
public *ssembl%Table 67 *ssembl%;truct<
public *ssembl%,e#Table 67 *ssembl%,e#;truct <
public +ustom*ttributeTable 67 +ustom*ttribute;truct<
public 0oduleTable67 0odule;truct<
public T%pe=e#Table 67 T%pe=e#;truct<
public T%pe,e#Table 67 T%pe,e#;truct<
public 'nter#ace'mplTable 67 'nter#ace'mpl;truct<
public >ield4trTable 67 >ield4tr;truct<
public 0ethod4trTable 67 0ethod4tr;truct<
public 0ethodTable 67 0ethod;truct<
public ;tand*lone;i(Table 67 ;tand*lone;i(;truct<
public 0ember,e#Table 67 0ember,e#;truct<
public T%pe;pecTable 67 T%pe;pec;truct<
public 4aramTable 67 4aram;truct<
public >ieldTable 67 >ield;truct<
public >ield0arshalTable 67 >ield0arshal;truct<
public >ield,-*Table 67 >ield,-*;truct<
public >ield3a%outTable 67 >ield3a%out;truct<
public +onstantsTable 67 +onstants;truct<
public 4ropert%0apTable 67 4ropert%0ap;truct<
public 4ropert%Table 67 4ropert%;truct<
public 0ethod;emanticsTable 67 0ethod;emantics;truct<
public :ventTable 67 :vent;truct<
public :vent0apTable 67 :vent0ap;truct<
public >ileTable 67 >ile;truct<
public 0odule,e#Table 67 0odule,e#;truct<
public 0ani#est,esourceTable 67 0ani#est,esource;truct<
public +lass3a%outTable 67 +lass3a%out;truct<
public 0ethod'mpTable 67 0ethod'mp;truct<
public )ested+lassTable 67 )ested+lass;truct<
public :xportedT%peTable 67 :xportedT%pe;truct<
public =ecl;ecurit%Table 67 =ecl;ecurit%;truct<
public 'mpl0apTable 67 'mpl0ap;truct<
strin( methodpinvoestrin( <
int lastt%pedispla%ed<
bool debu( A #alse<
bool tin%#ormat<
int #irst12<
int spaces#ortr%<
244260235.doc 513 od 541
bool placedend A #alse<
bool notprotot%pe A #alse<
bool "ritenamespace<
strin( #ilename<
int spaces#orrest A 2<
int space#ornamespace <
int spaces#ornested<
strin( methodaccessattribute <
public lon( +onvert,-*5lon( rva8
9
int i<
#or 5 i A 0 < i B sections < iCC8
9
i# 5 rva HA ;-irtual*ddress6i7 GG 5 rva B ;-irtual*ddress6i7 C ;;i&e/#,a"=ata6i7 88
brea <
@
return ;4ointerTo,a"=ata6i7 C 5 rva P ;-irtual*ddress6i7 8<
@
public strin( +reate;paces 5int ho"man%spaces8
9
strin( returnstrin( A FF<
#or 5 int 1 A 1 < 1 BA ho"man%spaces < 1CC8
returnstrin( A returnstrin( C F F<
return returnstrin( <
@
public strin( Det0ember,e#4arent+oded'ndexTable5int memberre#parentcodedindex8
9
strin( returnstrin( A FF<
memberre#parentcodedindex A memberre#parentcodedindex G 0x07<
i# 5 memberre#parentcodedindex AA 0 8
returnstrin( A FT%pe=e#F<
i# 5 memberre#parentcodedindex AA 1 8
returnstrin( A FT%pe,e#F<
i# 5 memberre#parentcodedindex AA 2 8
returnstrin( A F0odule,e#F<
i# 5 memberre#parentcodedindex AA 3 8
returnstrin( A F0ethod=e#F<
i# 5 memberre#parentcodedindexAA 4 8
returnstrin( A FT%pe;pecF<
return returnstrin(<
@
public strin( Det;trin( 5int startin(8
9
int endin( A startin(<
II+onsole.!rite3ine5F.........startin(A90@ strin(s.3en(thA91@F $ startin( $ strin(s.3en(th8<
i# 5 startin( B 08
return FF<
i# 5 startin( HA strin(s.3en(th 8
return FF<
"hile 5strin(s6endin(7 EA 0 8
9
244260235.doc 514 od 541
endin(CC<
@
;%stem.Text.:ncodin( e A ;%stem.Text.:ncodin(.NT>8<
strin( returnstrin( A e.Det;trin(5strin(s$ startin( $ endin( P startin( 8<
i# 5 returnstrin(.3en(th AA 08
return FF<
else
return returnstrin(<
@
public int ,eadTable'ndex5b%te 67 metadataarra% $ int arra%o##set $ strin( tablename8
9
int returnindex A 0<
int tablesi&e A DetTable;i&e5tablename8<
i# 5 tablesi&e AA 28
returnindex A Oit+onverter.ToN'nt16 5metadataarra% $ arra%o##set 8<
i# 5 tablesi&e AA 48
returnindex A 5int8Oit+onverter.ToN'nt32 5metadataarra% $ arra%o##set 8<
return returnindex<
@
public int ,ead;trin('ndex5b%te 67 metadataarra% $ int arra%o##set8
9
int returnindex A 0<
i# 5 o##setstrin( AA 28
returnindex A Oit+onverter.ToN'nt16 5metadataarra% $ arra%o##set 8<
i# 5 o##setstrin( AA 48
returnindex A 5int8Oit+onverter.ToN'nt32 5metadataarra% $ arra%o##set 8<
return returnindex<
@
public int ,eadOlob'ndex5b%te 67 metadataarra% $ int arra%o##set8
9
int returnindex A 0<
i# 5 o##setblob AA 28
returnindex A Oit+onverter.ToN'nt16 5metadataarra% $ arra%o##set 8<
i# 5 o##setblob AA 48
returnindex A 5int8Oit+onverter.ToN'nt32 5metadataarra% $ arra%o##set 8<
return returnindex<
@
public int ,eadDuid'ndex5b%te 67 metadataarra% $ int arra%o##set8
9
int returnindex A 0<
i# 5 o##set(uid AA 28
returnindex A Oit+onverter.ToN'nt16 5metadataarra% $ arra%o##set 8<
i# 5 o##set(uid AA 48
returnindex A 5int8Oit+onverter.ToN'nt32 5metadataarra% $ arra%o##set 8<
return returnindex<
@
public void =ispla%Duid 5int (uidindex8
9
+onsole.!rite5F9F8<
244260235.doc 515 od 541
+onsole.!rite5F90@91@92@93@F$ (uid6(uidindexC27.To;trin(5FK2F8 $
(uid6(uidindexC17.To;trin(5FK2F8 $ (uid6(uidindex7.To;trin(5FK2F8 $ (uid6(uidindexP
17.To;trin(5FK2F88<
+onsole.!rite5FP90@91@PF$(uid6(uidindexC47.To;trin(5FK2F8 $
(uid6(uidindexC37.To;trin(5FK2F88<
+onsole.!rite5F90@91@PF$(uid6(uidindexC67.To;trin(5FK2F8 $
(uid6(uidindexC57.To;trin(5FK2F88<
+onsole.!rite5F90@91@PF$(uid6(uidindexC77.To;trin(5FK2F8 $
(uid6(uidindexC87.To;trin(5FK2F88<
+onsole.!rite5F90@91@92@93@94@
95@F$(uid6(uidindexC97.To;trin(5FK2F8$(uid6(uidindexC107.To;trin(5FK2F8$(uid6(uidindexC117.
To;trin(5FK2F8$(uid6(uidindexC127.To;trin(5FK2F8$(uid6(uidindexC137.To;trin(5FK2F8$(uid6(ui
dindexC147.To;trin(5FK2F88<
+onsole.!rite5F@F8<
@
public void =ispla%0odule*nd0ore58
9
+onsole.!rite3ine5F.module 90@F $ )ame,eserved5Det;trin(50odule;truct617.)ame888<
+onsole.!rite5FII 0-'=M F8<
=ispla%Duid50odule;truct617.0vid8<
+onsole.!rite3ine58<
=ispla%+ustom*ttribute5F0oduleF $ 1 $ 08<
+onsole.!rite3ine5F.ima(ebase 0x90@F $ 'ma(eOase.To;trin(5Fx8F88<
+onsole.!rite3ine5F.subs%stem 0x90@F $ subs%stem.To;trin(5FK8F88<
+onsole.!rite3ine5F.#ile ali(nment 90@F $ #ilea8<
+onsole.!rite3ine5F.cor#la(s 0x90@F $ cor#la(s.To;trin(5Fx8F88<
+onsole.!rite3ine5FII 'ma(e baseM 0x03000000F8<
@
public strin( DetT%pe=e#/r,e#Table 5int codedvalue8
9
strin( returnstrin( A FF<
short ta( A 5short85codedvalue G 5short80x038<
i# 5 ta( AA 08
returnstrin( A returnstrin( C FT%pe=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C FT%pe,e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C FT%pe;pecF<
return returnstrin(<
@
public int DetT%pe=e#/r,e#-alue5int codedvalue8
9
return codedvalue HH 2<
@
public strin( Det>ield,-* 5int #ieldro"8
9
strin( returnstrin( A FF<
int ii<
i# 5 >ield,-*;truct AA null 8
return FF<
#or 5 ii A 1 < ii B >ield,-*;truct.3en(th < iiCC8
244260235.doc 516 od 541
9
int 11 A >ield,-*;truct6ii7.#ieldi<
i# 5 11 AA #ieldro" 8
brea<
@
i# 5 ii EA >ield,-*;truct.3en(th 8
9
int rvaA >ield,-*;truct6ii7.rva <
returnstrin( A F =RF C rva.To;trin(5FK8F8 <
@
return returnstrin(<
@
public strin( Det0arshalTable-alue 5int #ieldmarshalro"8
9
int ii<
#or 5 ii A 1 < ii B >ield0arshal;truct.3en(th < iiCC8
9
int #ieldmarshalro"coded A >ield0arshal;truct6ii7.coded HH 1<
i# 5 #ieldmarshalro" AA #ieldmarshalro"coded8
brea<
@
int index A >ield0arshal;truct6ii7.index<
int count A blob6index7<
strin( returnstrin( A Det0arshallT%pe5blob6indexC17 $ count $ 08<
return returnstrin(<
@
public strin( DetT%pe 5int t%peb%te8
9
i# 5 t%peb%te AA 0x018
return FvoidF<
i# 5 t%peb%te AA 0x028
return FboolF<
i# 5 t%peb%te AA 0x038
return FcharF<
i# 5 t%peb%te AA 0x048
return Fint8F<
i# 5 t%peb%te AA 0x058
return Funsi(ned int8F<
i# 5 t%peb%te AA 0x068
return Fint16F<
i# 5 t%peb%te AA 0x078
return Funsi(ned int16F<
i# 5 t%peb%te AA 0x088
return Fint32F<
i# 5 t%peb%te AA 0x098
return Funsi(ned int32F<
i# 5 t%peb%te AA 0x0a8
return Fint64F<
i# 5 t%peb%te AA 0x0b8
return Funsi(ned int64F<
i# 5 t%peb%te AA 0x0c8
244260235.doc 517 od 541
return F#loat32F<
i# 5 t%peb%te AA 0x0d8
return F#loat64F<
i# 5 t%peb%te AA 0x0e8
return Fstrin(F<
return Funno"nF<
@
public void =ispla%Dlobal>ields58
9
int start $ starto#nextA0<
i# 5 T%pe=e#;truct AA null TT >ield;truct AA null8
return<
start A T%pe=e#;truct617.#index <
i# 5 T%pe=e#;truct.3en(th AA 2 8
starto#nextA >ield;truct.3en(th<
else
starto#next A T%pe=e#;truct627.#index <
i# 5 start EA starto#next 8
9
+onsole.!rite3ine5FIIDlobal #ieldsF8<
+onsole.!rite3ine5FIIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVF8<
=ispla%*ll>ields518<
@
@
public void =ispla%Dlobal0ethods58
9
int start $ starto#nextA0<
start A T%pe=e#;truct617.mindex <
i# 5 T%pe=e#;truct AA null TT 0ethod;truct AA null8
return<

i# 5 T%pe=e#;truct.3en(th AA 2 8
starto#nextA 0ethod;truct.3en(th<
else
starto#next A T%pe=e#;truct627.mindex <
i# 5 start EA starto#next 8
9
+onsole.!rite3ine5FIIDlobal methodsF8<
+onsole.!rite3ine5FIIVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVF8<
spaces#orrest A 0<
=ispla%*ll0ethods518<
spaces#orrest A 2<

@
@
public void =ispla%)estedT%pes 5int t%pede#index8
9
i# 5)ested+lass;truct AA null8
return <
244260235.doc 518 od 541
#or 5 int ii A 1 < ii B )ested+lass;truct.3en(th < iiCC8
9
i# 5)ested+lass;truct6ii7.enclosin(class AA t%pede#index8
9
spaces#ornested CA 2<
=ispla%/neT%pe5)ested+lass;truct6ii7.nestedclass 8<
spaces#ornested PA 2<
@
@
@
public void =ispla%)estedT%pes4rotot%pes 5int t%pede#index8
9
i# 5)ested+lass;truct AA null8
return <
#or 5 int ii A 1 < ii B )ested+lass;truct.3en(th < iiCC8
9
i# 5)ested+lass;truct6ii7.enclosin(class AA t%pede#index8
9
spaces#ornested CA 2<
=ispla%/neT%pe4rotot%pe5)ested+lass;truct6ii7.nestedclass 8<
spaces#ornested PA 2<
@
@
@
public strin( Det0ethod;i(natureO%tes 5int methodro"8
9
strin( returnstrin( A FUrUnF C +reate;paces5spaces#orrestC spaces#ornested8 C FII ;'DM F<
int uncompressedb%te<
int si(natureindex A 0ethod;truct6methodro"7.si(nature<
int ho"man%b%tes<
ho"man%b%tes A +or;i(Nncompress=ata5blob $ si(natureindex$ out uncompressedb%te8<
int count A uncompressedb%te<
i# 5 ho"man%b%tes AA 28
countCC<
#or 5int 1 A ho"man%b%tes < 1 BA count < 1CC8
9
returnstrin( A returnstrin( C blob6si(natureindex C 1 7.To;trin(5FK2F8 <
i# 5 1 EA count 8
returnstrin( A returnstrin( C F F<
@
return returnstrin(<
@
public int Det2as;emantics-alue5int asscoiationb%te8
9
return asscoiationb%te HH 1<
@
public strin( Det>ile*ttributes5int #ile#la(s8
9
strin( returnstrin( A FF<
i# 5 #ile#la(s AA 0x008
returnstrin(A FF<
244260235.doc 519 od 541
i# 5 #ile#la(s AA 0x018
returnstrin(A Fnometadata F<
return returnstrin(<
@
public void =ispla%0odule,e#s58
9
i# 5 0odule,e#;truct AA null 8
return<
#or 5 int ii A 1 < ii B 0odule,e#;truct.3en(th < iiCC8
9
strin( dumm% A )ame,eserved5Det;trin(50odule,e#;truct6ii7.name88<
i# 5 dumm% AA F..UUunmana(edUUi386UU"indo"sidentit%.dllF8
+onsole.!rite3ine5F.module extern 90@ IJ1*91@JIF $
FL..UUUUunmana(edUUUUi386UUUU"indo"sidentit%.dllLF $ ii.To;trin(5FK6F88<
else
+onsole.!rite3ine5F.module extern 90@ IJ1*91@JIF $ dumm% $ ii.To;trin(5FK6F88<
@
@
public int Det0ani#est,esource-alue5int mani#iestvalue8
9
return mani#iestvalueHH 2<
@
public strin( Det0ani#est,esourceTable5int mani#iestvalue8
9
strin( returnstrin( A FF<
short ta( A 5short85mani#iestvalue G 5short80x038<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F>ileF<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F*ssembl%,e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F:xportedT%peF<
return returnstrin(<
@
public strin( Det0ani#est,esource*ttributes5int mani#iestvalue8
9
strin( returnstrin(AFF<
i# 5 5mani#iestvalue G 0x0018 AA 0x0018
returnstrin( A returnstrin( C Fpublic F<
i# 5 5mani#iestvalue G 0x0028 AA 0x0028
returnstrin( A returnstrin( C Fprivate F<
return returnstrin(<
@
public void =ispla%,esources58
9
i# 5 0ani#est,esource;truct AA null8
return<
#or 5 int ii A 1 < ii B 0ani#est,esource;truct.3en(th < iiCC8
9
strin( #la(s A Det0ani#est,esource*ttributes50ani#est,esource;truct6ii7.#la(s8<
244260235.doc 520 od 541
+onsole.!rite3ine5F.mresource IJ2890@JI 91@92@F $ ii.To;trin(5FK6F8 $ #la(s$
)ame,eserved5Det;trin(50ani#est,esource;truct6ii7.name88 8<
+onsole.!rite3ine5F9F8<
strin( table A Det0ani#est,esourceTable50ani#est,esource;truct6ii7.coded8<
int index A Det0ani#est,esource-alue50ani#est,esource;truct6ii7.coded8<
i# 5 table AA F*ssembl%,e#F8
+onsole.!rite3ine5F .assembl% extern 90@ IJ2391@JI F $
)ame,eserved5Det;trin(5*ssembl%,e#;truct6index7.name88 $ index.To;trin(5FK6F88<
else i# 5 table AA F>ileF GG index H 08
+onsole.!rite3ine5F .#ile 90@IJ2691@JI at 0x92@F $
)ame,eserved5Det;trin(5>ile;truct6index7.name88 $ index.To;trin(5FK6F8
$0ani#est,esource;truct6ii7.o##set.To;trin(5FK8F8 8<
else
+onsole.!rite3ine5F II !*,)')DM mana(ed resource #ile 90@
createdF$)ame,eserved5Det;trin(50ani#est,esource;truct6ii7.name8 8 8<
+onsole.!rite3ine5F@F8<
@
@
public int Det0ethod=e#-alue5int implcoded8
9
return implcoded HH 1<
@
public strin( Det0ethod=e#Table5int implcoded8
9
strin( returnstrin( A FF<
short ta( A 5short85implcoded G 5short80x018<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F0ethod,e#F<
return returnstrin(<
@
public strin( Det0ember,e#Table5int memberre#codedindex8
9
strin( returnstrin( A FF<
short ta( A 5short85memberre#codedindex G 5short80x078<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F)otNsedF<
i# 5 ta( AA 18
returnstrin( A returnstrin( C FT%pe,e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F0odule,e#F<
i# 5 ta( AA 38
returnstrin( A returnstrin( C F0ethod=e#F<
i# 5 ta( AA 48
returnstrin( A returnstrin( C FT%pe;pecF<
return returnstrin(<
@
public int Det0ember,e#-alue5int memberre#codedindex8
9
return memberre#codedindex HH 3<
244260235.doc 521 od 541
@
public int DetT%pe,e#>rom0ethod,e#5int methodre#ro"8
9
int memberre#codedindex A 0<
memberre#codedindex A 0ember,e#;truct6methodre#ro"7.clas<
strin( tablename A Det0ember,e#Table5memberre#codedindex8<
int t%pere#index A Det0ember,e#-alue5memberre#codedindex8<
return t%pere#index<
@
public void =ispla%+lass:xtern 58
9
i# 5:xportedT%pe;truct AA null8
return<
#or 5 int ii A 1 < ii B :xportedT%pe;truct.3en(th < iiCC8
9
strin( ss1 A DetT%pe*ttribute>la(s>or+lass:xtern5:xportedT%pe;truct6ii7.#la(s 8<
strin( ss A Det;trin(5:xportedT%pe;truct6ii7.nspace8 <
i# 5 ss.3en(th EA 08
ss A ss C F.F<
ss A ss C )ame,eserved5Det;trin(5:xportedT%pe;truct6ii7.name88<
int table A :xportedT%pe;truct6ii7.coded G 0x03<
int index A :xportedT%pe;truct6ii7.coded HH 2<
i# 5 table AA 18
+onsole.!rite3ine5F.............F8<
i# 5 index EA 08
9
+onsole.!rite5F.class extern IJ2790@JI 91@F $ ii.To;trin(5FK6F8 $ ss1 8<
+onsole.!rite3ine5ss8<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F:xportedT%peF $ ii $ 28<
i# 5 table AA 08
9
+onsole.!rite3ine5F .#ile 90@IJ2691@JI F $ )ame,eserved5Det;trin(5>ile;truct6index7.name88 $
index.To;trin(5FK6F88<
@
i# 5 table AA 28
9
+onsole.!rite3ine5F .comt%pe L90@L IJ2791@JI F $
)ame,eserved5Det;trin(5:xportedT%pe;truct6index7.name88 $ index.To;trin(5FK6F88<
@
i# 5 :xportedT%pe;truct6ii7.t%pede#index EA 08
+onsole.!rite3ine5F .class 0x90@F$ :xportedT%pe;truct6ii7.t%pede#index.To;trin(5FK8F88<
+onsole.!rite3ine5F@F8<
@
@
@
public int Det2as+onst-alue5int constcodedindex8
9
return constcodedindex HH 2<
@
public strin( Det2as+onstTable5int constcodedindex8
244260235.doc 522 od 541
9
strin( returnstrin( A FF<
int ta( A constcodedindex G 0x03<
i# 5 ta( AA 08
returnstrin( A returnstrin( C F>ield=e#F<
i# 5 ta( AA 18
returnstrin( A returnstrin( C F4aram=e#F<
i# 5 ta( AA 28
returnstrin( A returnstrin( C F4ropert%F<
return returnstrin(<
@
public void =ispla%=ata 58
9
i# 5 >ield,-*;truct AA null8
return<
#or 5 int ii A 1 < ii B >ield,-*;truct.3en(th < iiCC8
9
+onsole.!rite3ine5F.11data =R90@ A b%tearra% 5F $ >ield,-*;truct6ii7.rva.To;trin(5FK8F88<
i# 5 ii AA 18
9
+onsole.!rite5F90@ vi1a%8319891@II F $ +reate;paces5168 $ +reate;paces53788<
+onsole.!rite5F9F8<
+onsole.!rite3ine5F...F8<
@
else
+onsole.!rite3ine5F90@ 0+ 00 00 008 F $ +reate;paces51688<
@
i# 5datavt#ixuparra% AA null8
return<
#or 5 int ii A 0 < ii B datavt#ixuparra%.3en(th < iiCC8
+onsole.!rite3ine5datavt#ixuparra%6ii78<
@
public strin( )ame,eserved 5strin( name8
9
i# 5 name AA null8
return name<
i# 5 name.3en(th AA 08
return name<
i# 5 name.3en(th HA 2 GG name607 AA 63 GG name617 AA 638
return name <
i# 5 5b%te8name607 AA 7 8
return FLUUaLF<
i# 5 5b%te8name607 AA 8 8
return FLUUbLF<
i# 5 5b%te8name607 AA 98
return FLUUtLF<
i# 5 5b%te8name607 AA 108
return FLUUnLF<
i# 5 5b%te8name607 AA 11 8
return FLUUvLF<
i# 5 5b%te8name607 AA 12 8
244260235.doc 523 od 541
return FLUU#LF<
i# 5 5b%te8name607 AA 13 8
return FLUUrLF<
i# 5 5b%te8name607 AA 32 8
return FL LF<
i# 5 name AA FLF8
return FLUULLF<
i# 5 name AA FUFF8
return FLUUUFLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA 7 8
return FLF C name607 C FUUaLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA 8 8
return FLF C name607 C FUUbLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LUtL 8
return FLF C name607 C FUUtLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LUnL 8
return FLF C name607 C FUUnLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LUvL 8
return FLF C name607 C FUUvLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LU#L 8
return FLF C name607 C FUU#LF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LUrL 8
return FLF C name607 C FUUrLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LFL 8
return FLF C name607 C FUUUFLF<
i# 5 name.3en(th AA 2 GG 5b%te8name617 AA LULL 8
return FLF C name607 C FUUULLF<
i# 5 name.3en(th HA 1 GG name607 AA LULL GG name6name.3en(thP17 AA LULL 8
return name<
int i A 0<
"hile 5 i B name.3en(th 8
9
i# 5 5name6i7 HA L0L GG name6i7 BA L9L8 GG i AA 0 8
return FLF C name C FLF<
i# 5 name6i7 HA 1 GG name6i7 BA 31 8
return FLF C name C FLF<
i# 5 name6i7 HA 127 TT name6i7 AA LBL TT name6i7 AA LCL TT name6i7 AA LPL TT name6i7 AA L L TT name6i7
AA LULL 8
9
int ind A name.'ndex/#5FLF8<
i# 5 ind EA P18
name A name.'nsert5ind $ FUUF8<
return FLF C name C FLF<
@
iCC<
@
strin( 67 namesarra% A
9FvalueF$FblobF$Fob1ectF$FmethodF $FinitF$F.initF$Farra%F$Fpolic%.2.0.m%asmF$Fpolic%.2.0.m%asm.dl
lF$FaddF$ Fassembl%F$ Fseriali&ableF$ FlcidF $ FstreamF $ F#ilterF $ FhandlerF $ FrecordF$ Fre.uestF$
FoptF$ FclsidF$ FhresultF$ Fc#F$ FcustomF $ FtoF$ FretF$ FimportF$ F#ieldF$ FsubF$ Fan%F$ FpopF$ F#inalF$
FremF $ Fstora(eF$ FerrorF$ FnestedF$ FilF $ FinstanceF$ FdateF$ Fiunno"nF$ FliteralF$ FimplementsF$
244260235.doc 524 od 541
FunusedF$ FnotF $ Fali(nmentF$ FunicodeF$ FbstrF$ FautoF$ FretvalF$ FvariantF$ ForF$ F#amil%F$
Far(listF$ FbrF$ F"rapperF$ FdemandF$ F#aultF$ FcallF $ Fal(orithmF$ FnativeF$ F#ixedF$ Fstrin(F$
FcharF $ FdecimalF$ F#loatF $ FintF$ FvoidF$ FpinnedF$ FdivF$ FtrueF $ F#alseF$ Fde#aultF$
FabstractF $ F`F $ FcF$ F9F$ FTF $ F@F$ FVF $ FEF $ FSF $ F5F$ FaF$ FPF $ F8F$ FMF $ F<F$ FAF$ FHF$ FassertF$
Fs%nchroni&edF$ FruntimeF$ F"ithF$ FclassF$ Fne"arrF$ Fldob1F$ FldlocF$ Fstob1F$ FstlocF$ Fstar(F$
Fre#an%F$ FldelemaF$ Fldar(aF$ Fldar(F$ Finitob1F $ FboxF $FdemandF $ Fld#ldF$ Fld#ldaF$ Flds#ldF$
Flds#ldaF$ FvectorF$ FinF $ FoutF$ FandF$ Fint8F$ FxorF $ FasF$ FatF$ FstructF$ F#inall%F $ Finter#aceF $
F.+4mainF$ FenumF$ Fvarar(F$ FmarshalF$
Fpolic%.1.0.0ath3ibrar%F$Fpolic%.1.0.0ath3ibrar%.dllF$F#inalF$
F;%stem.!indo"s.>orms.=esi(n.256R2.bmpF $ F;%stem.!indo"s.>orms.=esi(n.256R1.bmpF@<
#or 5 int ii A 0 < ii B namesarra%.3en(th < iiCC8
9
i# 5 name AA namesarra%6ii78
9
int ind A name.'ndex/#5FLF8<
i# 5 ind EA P18
name A name.'nsert5ind $ FUUF8<
return FLF C name C FLF<
@
@
return name<
@
public strin( Det*ction;ecurit% 5int actionb%te8
9
strin( returnstrin( A FF<
i# 5 actionb%te AA 18
returnstrin( A Fre.uestF<
i# 5 actionb%te AA 28
returnstrin( A FdemandF<
i# 5 actionb%te AA 38
returnstrin( A FassertF<
i# 5 actionb%te AA 48
returnstrin( A Fden%F<
i# 5 actionb%te AA 58
returnstrin( A Fpermitonl%F<
i# 5 actionb%te AA 68
returnstrin( A FlinchecF<
i# 5 actionb%te AA 78
returnstrin( A FinheritchecF<
i# 5 actionb%te AA 88
returnstrin( A Fre.minF<
i# 5 actionb%te AA 98
returnstrin( A Fre.optF<
i# 5 actionb%te AA 108
returnstrin( A Fre.re#useF<
i# 5 actionb%te AA 118
returnstrin( A Fpre1it(rantF<
i# 5 actionb%te AA 128
returnstrin( A Fpre1itden%F<
i# 5 actionb%te AA 138
returnstrin( A FnoncasdemandF<
244260235.doc 525 od 541
i# 5 actionb%te AA 148
returnstrin( A FnoncaslindemandF<
i# 5 actionb%te AA 158
returnstrin( A FnoncasinheritanceF<
return returnstrin(<
@
public int DetT%pe>or>ield 5int #ieldro"8
9
int ii A 0<
#or 5 ii A 1 < ii B T%pe=e#;truct.3en(th P 1 < iiCC8
9
int start A T%pe=e#;truct6ii7.#index<
int end A T%pe=e#;truct6iiC17.#index P 1<
i# 5 ro"s637 HA 18
9
start A >ield4tr;truct6start7.index<
end A >ield4tr;truct6end7.index<
@
i# 5 #ieldro" HA start GG #ieldro" BA end8
return ii<
@
return ii<
@
public int +or;i(Nncompress=ata5 b%te 67 blobarra% $ int index $ out int ans"er8
9
int ho"man%b%tes A 0<
ans"er A 0<
i# 5 5blobarra%6index7 G 0x808 AA 0x008
9
ho"man%b%tes A 1<
ans"er A blobarra%6index7<
@
else i# 5 5blobarra%6index7 G 0x+08 AA 0x808
9
ho"man%b%tes A 2<
ans"er A 55blobarra%6index7 G 0x3#8 BB8 8 T blobarra%6indexC17<
@
else i# 5 5blobarra%6index7 G 0x:08 AA 0x+08
9
ho"man%b%tes A 4<
ans"er A 55blobarra%6index7 G 0x1#8 BB24 8 T 5blobarra%6indexC17 BB 168 T 5blobarra%6indexC27
BB 88 T blobarra%6indexC37<
@
return ho"man%b%tes<
@
public int DetTable;i&e5strin( tablename8
9
int ii<
#or 5 ii A 0 < ii B tablenames.3en(th < iiCC8
9
i# 5 tablename AA tablenames6ii7 8
244260235.doc 526 od 541
brea<
@
i# 5 ro"s6ii7 HA 655358
return 4<
else
return 2<
@
public bool 2as+ustom*ttribute 5 strin( tablename $ int index8
9
i# 5 +ustom*ttribute;truct AA null8
return #alse<
#or 5 int ii A 1 < ii B +ustom*ttribute;truct.3en(th < iiCC8
9
strin( parentcodedtablenameA Det2as+ustom*ttributeTable5+ustom*ttribute;truct6ii7.parent8 <
int parentcodedindexA Det2as+ustom*ttribute-alue5+ustom*ttribute;truct6ii7.parent8<
II+onsole.!rite3ine5F.......90@ 91@ indexA92@F$parentcodedtablename $ parentcodedindex $
index8<
i# 5 parentcodedtablename AA tablename GG parentcodedindex AA index8
return true<
@
return #alse<
@
public strin( DetT%pe*ttribute>la(s>or+lass:xtern5int t%peattribute#la(s 8
9
t%peattribute#la(s A t%peattribute#la(s G 0x07<
strin( visibilt%masstrin(AFF<
i# 5 t%peattribute#la(s AA 18
visibilt%masstrin( A Fpublic F<
i# 5 t%peattribute#la(s AA 28
visibilt%masstrin( A Fnested public F<
return visibilt%masstrin(<
@
public strin( Det4aram*ttr#or4aram+allin( 5int paramindex8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null 8
return FF<
i# 5paramindex HA 4aram;truct.3en(th 8
return FF<
i# 54aram;truct6paramindex7.se.uence AA 08
return returnstrin(<
int pattr A 4aram;truct6paramindex7.pattr<
i# 5 5pattr G 0x018 AA 0x018
returnstrin( A returnstrin( C F6in7F <
i# 5 5pattr G 0x028 AA 0x028
returnstrin( A returnstrin( C F6out7F <
i# 5 5pattr G 0x108 AA 0x108
returnstrin( A returnstrin( C F6opt7F <
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin( C F F<
return returnstrin( <
244260235.doc 527 od 541
@
public strin( Det4aram*ttr#or0ethod+allin( 5int methodindex8
9
strin( returnstrin( A FF<
i# 54aram;truct AA null8
return returnstrin(<
int end<
int start A 0ethod;truct6methodindex7.param<
i# 5 methodindex AA 50ethod;truct.3en(th P18 8
end A 4aram;truct.3en(th C 1<
else
end A 0ethod;truct6methodindexC17.param<
i# 5 start AA 4aram;truct.3en(th8
return returnstrin(<
i# 5 start AA end8
return returnstrin(<
i# 54aram;truct6start7.se.uence EA 08
return FF<
int pattr A 4aram;truct6start7.pattr<
i# 5 5pattr G 0x018 AA 0x018
returnstrin( A returnstrin( C F6in7F <
i# 5 5pattr G 0x028 AA 0x028
returnstrin( A returnstrin( C F6out7F <
i# 5 5pattr G 0x108 AA 0x108
returnstrin( A returnstrin( C F6opt7F <
i# 5 returnstrin( EA FF8
returnstrin( A returnstrin( C F F<
return returnstrin( <
@
public strin( Det>ield*ttributes 5int #ieldro"8
9
int #la(s A >ield;truct6#ieldro"7.#la(s<
strin( returnstrin( A FF<
strin( arra%o##set A FF<
int ii<
i# 5 >ield3a%out;truct EA null8
9
#or 5 ii A 1 < ii B >ield3a%out;truct.3en(th < iiCC8
9
int 11 A >ield3a%out;truct6ii7.#ieldindex <
i# 5 11 AA #ieldro" 8
brea<
@
i# 5 ii EA >ield3a%out;truct.3en(th 8
9
int o##set A >ield3a%out;truct6ii7.o##set <
arra%o##set A F6F C o##set.To;trin(5FF8 C F7 F<
@
@
i# 5 5#la(s G 0x068 AA 0x068
returnstrin( A returnstrin( C Fpublic F<
244260235.doc 528 od 541
else
i# 5 5#la(s G 0x058 AA 0x058
returnstrin( A returnstrin( C F#amorassem F<
else
i# 5 5#la(s G 0x038 AA 0x038
returnstrin( A returnstrin( C Fassembl% F<
else
i# 5 5#la(s G 0x018 AA 0x018
returnstrin( A returnstrin( C Fprivate F<
else
i# 5 5#la(s G 0x028 AA 0x028
returnstrin( A returnstrin( C F#amandassem F<
else
i# 5 5#la(s G 0x048 AA 0x048
returnstrin( A returnstrin( C F#amil% F<
else
returnstrin( A returnstrin( C Fprivatescope F<
i# 5 5#la(s G 0x108 AA 0x108
9
int #irst#ourbits A #la(s G 0x><
i# 5 5#irst#ourbits AA 0x068 TT 5#irst#ourbits AA 0x0188
9
returnstrin( A returnstrin( C Fstatic F <
@
else
returnstrin( A Fstatic F C returnstrin(<
@
returnstrin( A arra%o##set C returnstrin(<
i# 5 5#la(s G 0x208 AA 0x208
returnstrin( A returnstrin( C Finitonl% F<
i# 5 5#la(s G 0x408 AA 0x408
returnstrin( A returnstrin( C Fliteral F<
i# 5 5#la(s G 0x808 AA 0x808
returnstrin( A returnstrin( C Fnotseriali&ed F<
i# 5 5#la(s G 0x2008 AA 0x2008
returnstrin( A returnstrin( C Fspecialname F<
i# 5 5#la(s G 0x4008 AA 0x4008
returnstrin( A returnstrin( C Frtspecialname F<
i# 5 5#la(s G 0x4008 AA 0x4008
returnstrin( A returnstrin( C FF<
returnstrin( A returnstrin( C =ecode4aram*ttributes 5 #la(s $ 0 $ #ieldro" $ 0x10008<
return returnstrin(<
@
public void =ispla%*ll;ecurit% 5int tablet%pe $ int tableindex8
9
i# 5=ecl;ecurit%;truct AA null8
return<
#or 5 int ii A 1 < ii B =ecl;ecurit%;truct.3en(th < iiCC8
9
int coded A =ecl;ecurit%;truct6ii7.coded<
int table A coded G 0x03<
244260235.doc 529 od 541
int ro" A coded HH 2<
i# 5 5table AA tablet%pe GG ro" AA tableindex 8 8
9
strin( returnstrin(<
i# 5 tablet%pe AA 28
returnstrin( A +reate;paces52 8<
else i# 5 tablet%pe AA 08
returnstrin( A +reate;paces5spaces#orrest C spaces#ornested8<
else
returnstrin( A +reate;paces5spaces#orrest C2 C spaces#ornested8<
returnstrin( A returnstrin( C F.permissionset F <
strin( actionname A Det*ction;ecurit%5=ecl;ecurit%;truct6ii7.action8<
returnstrin( A returnstrin( C actionname <
returnstrin( A returnstrin( C F A 5F <
+onsole.!rite5returnstrin(8<
int index A =ecl;ecurit%;truct6ii7.bindex<
i# 5 index AA 08
+onsole.!rite3ine5F8F8<
else
=ispla%>ormatted+olumns5index $returnstrin(.3en(th$ #alse $ #alse8<
@
@
@
public void =ispla%>ileTable 58
9
i# 5 >ile;truct AA null 8
return<
#or 5 int ii A 1 < ii B >ile;truct.3en(th < iiCC8
9
+onsole.!rite3ine5F.#ile IJ2690@JI 91@92@F $ ii.To;trin(5FK6F8 $
Det>ile*ttributes5>ile;truct6ii7.#la(s8 $ )ame,eserved5Det;trin(5>ile;truct6ii7.name888<
int table A entr%pointtoen HH 24<
i# 5 table AA 0x26 8
9
int ro" A entr%pointtoen G 0x00######<
i# 5 ro" AA 5ii8 8
+onsole.!rite3ine5F .entr%pointF8<
@
i# 5 >ile;truct6ii7.index EA 08
9
+onsole.!rite5F .hash A 5F8<
int index A >ile;truct6ii7.index <
=ispla%>ormatted+olumns5index $13 $ #alse $ #alse8<
@
=ispla%+ustom*ttribute5F>ileF $ ii $ 08<
@
@
public void =ispla%*ssemble%,e#s 58
9
i# 5*ssembl%,e#;truct AA null8
return<
244260235.doc 530 od 541
#or 5 int i A 1 < i B *ssembl%,e#;truct.3en(th < iCC8
9
II+onsole.!rite3ine5F...........90@ 91@F $ *ssembl%,e#;truct6i7.name $ strin(s.3en(th8<
+onsole.!rite3ine5F.assembl% extern IJ2390@JI 91@F$ i.To;trin(5FK6F8 $
)ame,eserved5Det;trin(5*ssembl%,e#;truct6i7.name888<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F*ssembl%,e#F $ i $ 2 8<
i# 5*ssembl%,e#;truct6i7.publice% EA 08
9
+onsole.!rite5F .publice%toen A 5F8<
=ispla%>ormatted+olumns5*ssembl%,e#;truct6i7.publice%$22 $ true $ #alse8<
@
i# 5 *ssembl%,e#;truct6i7.hashvalue EA 0 8
9
+onsole.!rite5F .hash A 5F8<
=ispla%>ormatted+olumns5*ssembl%,e#;truct6i7.hashvalue$11 $ #alse $ #alse8<
@
int rev A *ssembl%,e#;truct6i7.revision<
i# 5 rev B 08
rev A 65536 C rev<
+onsole.!rite3ine5F .ver 90@M91@M92@M93@F $ *ssembl%,e#;truct6i7.ma1or$
*ssembl%,e#;truct6i7.minor$*ssembl%,e#;truct6i7.build$rev8<
i# 5 *ssembl%,e#;truct6i7.culture EA 0 8
9
+onsole.!rite5F .locale A 5F8<
int index A *ssembl%,e#;truct6i7.culture<
int cnt A 0<
"hile 5 strin(s6index7 EA 08
9
+onsole.!rite5F90@ 00 F $ strin(s6index7.To;trin(5FKF88<
cntCC<
indexCC<
@
int nos A 64 P 514 C 6 C 56JcntC188<
+onsole.!rite5F00 00F8<
+onsole.!rite5F 890@II F $ +reate;paces5nos88<
index A *ssembl%,e#;truct6i7.culture<
"hile 5 strin(s6index7 EA 08
9
+onsole.!rite5F90@.F $ 5char8strin(s6index78<
indexCC<
@
+onsole.!rite3ine5F..F8<
@
+onsole.!rite3ine5F@F8<
@
@
public void =ispla%*ssemble%58
9
i# 5*ssembl%;truct.3en(th AA 18
return<
244260235.doc 531 od 541
+onsole.!rite3ine5F.assembl% IJ20000001JI 90@F $
)ame,eserved5Det;trin(5*ssembl%;truct617.name888<
+onsole.!rite3ine5F9F8<
=ispla%+ustom*ttribute5F*ssembl%F $ 1 $ 2 C space#ornamespace8<
=ispla%*ll;ecurit%5 2 $ 18<
i# 5 *ssembl%;truct617.publice% EA 08
9
+onsole.!rite5F .publice% A 5F8<
=ispla%>ormatted+olumns5*ssembl%;truct617.publice% $16 $ true $ #alse8<
@
i# 5 *ssembl%;truct617.2ash*l('d EA 08
+onsole.!rite3ine5F .hash al(orithm 0x90@F$*ssembl%;truct617.2ash*l('d.To;trin(5Fx8F88<
int rev A *ssembl%;truct617.revision<
i# 5 rev B 08
rev A 65536 C rev<
+onsole.!rite3ine5F .ver 90@M91@M92@M93@F $ *ssembl%;truct617.ma1or$
*ssembl%;truct617.minor$*ssembl%;truct617.build$rev8<
i# 5 *ssembl%;truct617.culture EA 0 8
9
+onsole.!rite5F .locale A 5F8<
int index A *ssembl%;truct617.culture<
int cnt A 0<
"hile 5 strin(s6index7 EA 08
9
+onsole.!rite5F90@ 00 F $ strin(s6index7.To;trin(5FKF88<
indexCC<
cntCC<
@
+onsole.!rite5F00 00F8<
+onsole.!rite5F 8F8<
int nos A 64 P 515 C cntJ6 C 68<
+onsole.!rite5+reate;paces5nos88<
+onsole.!rite5FII F8<
index A *ssembl%;truct617.culture<
"hile 5 strin(s6index7 EA 08
9
+onsole.!rite5F90@.F $ 5char8strin(s6index78<
indexCC<
@
+onsole.!rite3ine5F..F8<
@
+onsole.!rite3ine5F@F8<
@
public strin( =ispla%:xceptionO%tes5int i8
9
strin( ss A FII 2:KM F <
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.#la(s8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.tr%o##set8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.tr%len(th8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.handlero##set8<
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.handlerlen(th8<
244260235.doc 532 od 541
ss A ss C +onvert'nt32To;trin(5:xception;truct6i7.toen8<
ss A ss.,emove5ss.3en(thP1$18<
return ss C FUrUnF<
@
public strin( +onvert'nt32To;trin(5int i8
9
strin( ss A FF<
int b1 A i G 0x##<
int b2 A 5i G 0x##00 8 HH 8<
int b3 A 5i G 0x##0000 8 HH 16<
int b4 A i HH 24<
i# 5 b4 AA P18
b4 A 0x##<
ss A b1.To;trin(5FK2F8 C F F C b2.To;trin(5FK2F8 C F F C b3.To;trin(5FK2F8 C F F C
b4.To;trin(5FK2F8 C F F <
return ss<
@
public void ,ead:xceptions 5lon( pos$ int codesi&e $ int methodindex 8
9
int aa A P1<
lon( "here A m#ilestream.4osition<
lon( pos1 A pos C codesi&e C 12 <
lon( extra A 0 <
extra A pos1 a 4 <
i# 5 extra EA 0 8
extra A 4 P extra <
lon( ne"pos A pos1 C extra<
m#ilestream.4osition A ne"pos<
int #irst A mbinar%reader.,eadO%te58<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F...........>la(A90@F $ #irst.To;trin(5FKF88<
i# 5 5#irst G 0x408 EA 0x408
9
int second A mbinar%reader.,eadO%te58<
mbinar%reader.,ead'nt1658<
int cnt A 5second P 4 8 I 12<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F................countA90@F $ cnt8<
:xception;truct A ne" :xceptionTable6cnt7<
#or 5 int 11 A 0 < 11 B cnt < 11CC 8
9
:xception;truct6117.#la(s A mbinar%reader.,ead'nt1658<
:xception;truct6117.tr%o##set A mbinar%reader.,ead'nt1658<
:xception;truct6117.tr%len(th A mbinar%reader.,eadO%te58<
:xception;truct6117.handlero##set A mbinar%reader.,ead'nt1658<
:xception;truct6117.handlerlen(th A mbinar%reader.,eadO%te58<
:xception;truct6117.toen A mbinar%reader.,ead'nt3258<
:xception;truct6117.oneline A0<
@
i# 5 methodindex AA aa8
+onsole.!rite3ine5F...........'# /verF 8<
244260235.doc 533 od 541
@
else
9
i# 5 methodindex AA aa8
+onsole.!rite3ine5F............in elseF8<
int a1 A mbinar%reader.,eadO%te58<
int a2 A mbinar%reader.,eadO%te58<
int a3 A mbinar%reader.,eadO%te58<
int second A a1 C a2 J 256 C a3 J 65536<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F............a1A90@ a2A91@ a3A92@ secondA93@F $ a1 $ a2 $ a3 $ second8<
int cnt<
i# 5 second AA 248
cnt A 1<
else i# 5 second AA 488
cnt A 2<
else
cnt A 5second P 4 8 I 24<
:xception;truct A ne" :xceptionTable6cnt7<
i# 5 methodindex AA aa8
+onsole.!rite3ine5F................countA90@F $ cnt8<
#or 5 int 11 A 0 < 11 B cnt < 11CC 8
9
:xception;truct6117.#la(s A mbinar%reader.,ead'nt3258<
:xception;truct6117.tr%o##set A mbinar%reader.,ead'nt3258<
:xception;truct6117.tr%len(th A mbinar%reader.,ead'nt3258<
:xception;truct6117.handlero##set A mbinar%reader.,ead'nt3258<
:xception;truct6117.handlerlen(th A mbinar%reader.,ead'nt3258<
:xception;truct6117.toen A mbinar%reader.,ead'nt3258<
:xception;truct6117.oneline A0<
@
@
m#ilestream.4osition A "here<
@
public void =ispla%0ethod'3+ode5 strin( classname $ strin( methodname $int methodindex 8
9
b%te 67 codearra% A ne" b%te6codesi&e7<
#or 5 int i A 1 < i BA codesi&e < iCC8
9
codearra%6iP17 A mbinar%reader.,eadO%te58<
@
spaces#ortr% A 0<
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
+reate:xception*rra%5methodindex $ codearra% 8<
#or 5 int arra%o##set A 0 < arra%o##set B codesi&e < 8
9
int instructionb%te A codearra%6arra%o##set 7<
/p+ode opcode<
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
=ispla%:xceptions5arra%o##set $ codearra% 8<
strin( strin(s A FF<
244260235.doc 534 od 541
int t"ob%te A 0<
i# 5 instructionb%te AA 0x>:8
9
instructionb%te A codearra%6arra%o##set C17<
opcode A /p+odes*rra%16instructionb%te7 <
strin(s A +reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested8<
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FKF8 C F
T F<
II+onsole.!rite5strin(s8<
arra%o##set A arra%o##set C 1<
t"ob%te A 1<
@
else
9
opcode A /p+odes*rra%6instructionb%te7<
strin(s A +reate;paces5spaces#orrestC2Cspaces#ortr% C spaces#ornested8<
t"ob%te A 0<
i# 5 E 5opcode.-alue AA 0 GG opcode.)ame EA FnopF88
9
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C opcode.-alue.To;trin(5FK2F8 C
F T F<
II+onsole.!rite5strin(s8<
@
@
i# 5 opcode.-alue AA 0 GG opcode.)ame EA FnopF8
9
strin(s A strin(s C F'3RF C arra%o##set .To;trin(5Fx4F8 C FM IJ F C instructionb%te.To;trin(5FK2F8
C F T F<
strin(s A strin(s C +reate;paces5178 C FJI unusedF <
+onsole.!rite3ine5F90@F$ strin(s 8<
arra%o##set A arra%o##set C 1<
@
else
9
int si&eo#instructionanddata A =ecode'3'nstrcution25 opcode $ arra%o##set $ codearra% $
methodindex $ strin(s 8<
+onsole.!rite3ine58<
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
=ispla%:xceptions15arra%o##set $ codearra% $ t"ob%te8<
arra%o##set A arra%o##set C si&eo#instructionanddata<
@
@
i# 5 5#irst12G0x088 AA 0x08 GG Etin%#ormat8
9
i# 5 :xception;truct607.oneline AA 28
9
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested C 2 88<
+onsole.!rite3ine5F'3R90Mx4@M F $ codearra%.3en(th8<
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested C 2 88<
+onsole.!rite3ine5FII :xception count 1F8<
=ispla%/ne3ineTr%508<
244260235.doc 535 od 541
@
@
+onsole.!rite5+reate;paces5spaces#orrestC spaces#ornested88<
+onsole.!rite5F@F8<
i# 5 DetT%pe>or0ethod5methodindex8AA 18
+onsole.!rite3ine5F II end o# (lobal method 90@UrUnF $ methodname8<
else
+onsole.!rite3ine5F II end o# method 90@MM91@UrUnF $ classname $ methodname8<
@
public void +reate:xception*rra%5int methodindex $ b%te 67 codearra%8
9
i# 5:xception;truct AA null8
return<
i# 5 :xception;truct607.handlero##set C :xception;truct607.handlerlen(th AA codearra%.3en(th
GG :xception;truct.3en(th AA 18
:xception;truct607.oneline A 2<
i# 5 :xception;truct607.tr%o##set C :xception;truct607.tr%len(th EA
:xception;truct607.handlero##set GG :xception;truct.3en(th AA 18
:xception;truct607.oneline A 1<
i# 5 :xception;truct.3en(th AA 28
9
bool a A :xception;truct607.tr%o##set C :xception;truct607.tr%len(th EA
:xception;truct607.handlero##set<
bool b A :xception;truct617.tr%o##set C :xception;truct617.tr%len(th EA
:xception;truct617.handlero##set<
i# 5 a GG b8
9
:xception;truct607.oneline A 1<
:xception;truct617.oneline A 1<
@
@
i# 5 :xception;truct.3en(th AA 28
9
bool a A :xception;truct607.tr%o##set C :xception;truct607.tr%len(th EA
:xception;truct607.handlero##set<
bool b A :xception;truct617.tr%o##set C :xception;truct617.tr%len(th AA
:xception;truct617.handlero##set<
i# 5 a GG b8
9
:xception;truct607.oneline A 1<
:xception;truct617.oneline A 0<
@
@
i# 5 :xception;truct.3en(th AA 28
9
i# 5 :xception;truct607.tr%o##set AA :xception;truct617.tr%o##set GG
:xception;truct607.tr%len(th AA :xception;truct617.tr%len(th GG
:xception;truct617.handlero##set C :xception;truct617.handlerlen(th AA codearra%.3en(th P1 GG
:xception;truct607.handlerlen(th AA 18
i# 5 :xception;truct607.handlero##set C :xception;truct607.handlerlen(th EA
:xception;truct617.handlero##set8
244260235.doc 536 od 541
:xception;truct617.oneline A 1<
@
i# 5 :xception;truct.3en(th AA 3 GG :xception;truct607.tr%o##set AA
:xception;truct617.tr%o##set GG :xception;truct607.tr%o##set H :xception;truct627.tr%o##set GG
:xception;truct607.#la(s AA :xception;truct617.#la(s GG :xception;truct627.#la(s AA
:xception;truct617.#la(s GG :xception;truct617.#la(sAA 28
9
:xceptionTable a A :xception;truct607<
:xception;truct607 A :xception;truct627<
:xception;truct627 A a<
@
#or 5 int ii A 0 < ii B :xception;truct.3en(th P 1 < iiCC8
9
int secondtr% A :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th<
int thirdtr% A :xception;truct6iiC17.tr%o##set C :xception;truct6iiC17.tr%len(th<
i# 5 :xception;truct6ii7.tr%o##set H :xception;truct6iiC17.tr%o##set GG secondtr% H thirdtr%8
9
:xceptionTable a A :xception;truct6ii7<
:xception;truct6ii7 A :xception;truct6iiC17<
:xception;truct6iiC17 A a<
@
@
i# 5 methodindex AA P18
9
#or 5int ii A 0 < ii B :xception;truct.3en(th < iiCC8
9
+onsole.!rite3ine5F >la(s 90@ F $ :xception;truct6ii7.#la(s.To;trin(5FK8F88<
+onsole.!rite3ine5F Tr% /##set 90@ 0x91@F $ :xception;truct6ii7.tr%o##set $
:xception;truct6ii7.tr%o##set.To;trin(5FKF88<
+onsole.!rite3ine5F Tr% 3en(th 90@ 0x91@F $ :xception;truct6ii7.tr%len(th $
:xception;truct6ii7.tr%len(th.To;trin(5FKF88<
+onsole.!rite3ine5F 2andler /##set 90@ 0x91@F $ :xception;truct6ii7.handlero##set $
:xception;truct6ii7.handlero##set.To;trin(5FKF8 8<
+onsole.!rite3ine5F 2andler len(th 90@ 0x91@F $ :xception;truct6ii7.handlerlen(th $
:xception;truct6ii7.handlerlen(th.To;trin(5FKF88<
+onsole.!rite3ine5F Toen 90MK@F $ :xception;truct6ii7.toen $ :xception;truct6ii7.handlero##set
C :xception;truct6ii7.handlerlen(th8<
+onsole.!rite3ine5F:ndTr%A90MK@ :ndhandlerA91MK@ codearra%A92MK@ onelineA93@F $
:xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th$ :xception;truct6ii7.handlero##set C
:xception;truct6ii7.handlerlen(th $ codearra%.3en(th $ :xception;truct6ii7.oneline8<
+onsole.!rite3ine58<
@
@
@
public void =ispla%:xceptions 5int instructionnumber $ b%te 67 codearra% 8
9
int ii <
bool endtr% A #alse<
#or 5 ii A 0 < ii B :xception;truct.3en(th < iiCC8
9
bool sho"tr% A true<
244260235.doc 537 od 541
i# 5 ii HA 1 8 II to sho" a tr% or not
9
int #irst A :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th<
int second A :xception;truct6iiP17.tr%o##set C :xception;truct6iiP17.tr%len(th<
i# 5 #irst AA second GG :xception;truct6iiP17.oneline EA 18
sho"tr% A #alse<
else
sho"tr% A true<
@
i# 5 instructionnumber AA :xception;truct6ii7.tr%o##set GG sho"tr% GG
:xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F.tr%F8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr%C spaces#ornested88<
+onsole.!rite5F9UrUnF8<
spaces#ortr% A spaces#ortr% C 2<
@
i# 5 instructionnumber AA :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th GG Eendtr%
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F@ II end .tr%F8<
spaces#ortr% A spaces#ortr% P 2<
endtr%A true<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set GG :xception;truct6ii7.#la(s AA 0
GG :xception;truct6ii7.oneline AA 08
9
int toen A :xception;truct6ii7.toen<
int table A toen HH 24<
int tablero" A toen G 0x######<
strin( t%penameAFF<
i# 5 table AA 28
t%pename A t%pede#names6tablero"7<
i# 5 table AA 18
t%pename A t%pere#names6tablero"7<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5Fcatch 90@ F $ t%pename8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F9F8<
spaces#ortr% A spaces#ortr% C 2<
II+onsole.!rite3ine5F........90@ 91@F $ table$ tablero"8<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set GG :xception;truct6ii7.#la(s AA 2
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F#inall%F8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F9F8<
244260235.doc 538 od 541
spaces#ortr% A spaces#ortr% C 2<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set GG :xception;truct6ii7.#la(s AA 4
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F#aultF8<
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F9F8<
spaces#ortr% A spaces#ortr% C 2<
@
i# 5 instructionnumber AA :xception;truct6ii7.handlero##set C :xception;truct6ii7.handlerlen(th
GG :xception;truct6ii7.oneline AA 08
9
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested88<
+onsole.!rite3ine5F@ II end handlerF8<
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested88<
+onsole.!rite5=ispla%:xceptionO%tes5ii88<
spaces#ortr% A spaces#ortr% P 2<
@
@
@
public void =ispla%:xceptions15int instructionnumber $ b%te 67 codearra%$ int t"ob%te 8
9
int ii <
II+onsole.!rite3ine5F.......90MK@ 91MK@F $ instructionnumber $ codearra%6instructionnumber7 8<
#or 5 ii A 0 < ii B :xception;truct.3en(th < iiCC8
9
int tr%pos A :xception;truct6ii7.tr%o##setC :xception;truct6ii7.tr%len(th <
int handlerpos A :xception;truct6ii7.handlero##setC :xception;truct6ii7.handlerlen(th <
int o##set<
IIdivRi4.exe divRi8.exe
i# 5 tr%pos H handlerpos8
o##set A tr%pos<
else
o##set A handlerpos<

i# 5 instructionnumber AA o##set C t"ob%te GG :xception;truct6ii7.oneline AA 1 8
=ispla%/ne3ineTr%5ii8<
@
@
public void =ispla%/ne3ineTr%5 int ii8
9
int toen A :xception;truct6ii7.toen<
int table A toen HH 24<
int tablero" A toen G 0x######<
strin( t%penameAFF<
i# 5 table AA 28
t%pename A t%pede#names6tablero"7<
i# 5 table AA 18
t%pename A t%pere#names6tablero"7<
244260235.doc 539 od 541
+onsole.!rite5+reate;paces5spaces#orrestC2C spaces#ortr% C spaces#ornested88<
+onsole.!rite5F.tr% '3R90@ toF $ :xception;truct6ii7.tr%o##set.To;trin(5Fx4F88<
int end A :xception;truct6ii7.tr%o##set C :xception;truct6ii7.tr%len(th<
+onsole.!rite5F '3R90@ F $ end.To;trin(5Fx4F88<
i# 5 :xception;truct6ii7.#la(s AA 08
+onsole.!rite5Fcatch 90@ handler F $ t%pename8<
else i# 5 :xception;truct6ii7.#la(s AA 28
+onsole.!rite5F#inall% handler F 8<
else i# 5 :xception;truct6ii7.#la(s AA 48
+onsole.!rite5F#ault handler F 8<
else
+onsole.!rite5F#ilter '3R90@ handler F $ toen.To;trin(5Fx4F88<
+onsole.!rite5F'3R90@ toF$:xception;truct6ii7.handlero##set.To;trin(5Fx4F88<
int end1 A :xception;truct6ii7.handlero##set C :xception;truct6ii7.handlerlen(th<
+onsole.!rite3ine5F '3R90@F $ end1.To;trin(5Fx4F88<
+onsole.!rite5+reate;paces5spaces#orrestCspaces#ortr% C spaces#ornested C 288<
+onsole.!rite5=ispla%:xceptionO%tes5ii88<
:xception;truct6ii7.oneline A 0<
@
public void =ispla%>inalO%tes5int ii $ strin( returnstrin(8
9
int index A +ustom*ttribute;truct6ii7.value<
int ho"man%b%tes$uncompressedb%te <
ho"man%b%tes A +or;i(Nncompress=ata5blob $ index $ out uncompressedb%te8<
index A index C ho"man%b%tes<
b%te 67 blobarra% A ne" b%te6uncompressedb%te7<
*rra%.+op%5blob $ index $ blobarra% $ 0 $ uncompressedb%te8<
bool displa%oneline A true<
strin( displa%strin( A FF<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
i# 5 blobarra%6117 B 0x208
displa%oneline A #alse<
i# 5 blobarra%6117 HA 0x7#8
displa%oneline A #alse<
@
int countascii A 0<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
i# 5 blobarra%6117 HA 0x20 GG blobarra%6117 BA 0x7#8
countasciiCC<
@
i# 5 displa%oneline8
9
displa%strin( A F A UFF<
#or 5 int 11 A 0 < 11 B uncompressedb%te < 11CC8
9
displa%strin( A displa%strin( C 5char8blobarra%6117<
@
displa%strin( A displa%strin( C FUFF<
+onsole.!rite3ine5displa%strin(8<
244260235.doc 540 od 541
@
else
9
int starto##unctionclosebracet A returnstrin(.3ast'ndex/#5F8F8<
int starto#lastopenbracet A returnstrin(.3en(th P 1<
int lastenter A returnstrin(.3ast'ndex/#5FUrUnF8<
int #irstenter A returnstrin(.'ndex/#5FUrUnF8<
int #irstopenbracet A returnstrin(.'ndex/#5F5F8<
i# 5 lastenter AA P18
lastenter A P2<
int di##2 A starto##unctionclosebracet P lastenter C 19<
+onsole.!rite5F A 5 F8<
=ispla%>ormatted+olumns5+ustom*ttribute;truct6ii7.value$di##2 $ #alse $ #alse8<
@
@
public void =ispla%>inal+ustom*ttributes58
9
i# 5 +ustom*ttribute;truct AA null8
return<
#or 5 int ii A 1 < ii B +ustom*ttribute;truct.3en(th < iiCC8
9
strin( parentcodedtablenameA Det2as+ustom*ttributeTable5+ustom*ttribute;truct6ii7.parent8 <
int parentcodedindexA Det2as+ustom*ttribute-alue5+ustom*ttribute;truct6ii7.parent8<
strin( t%pecodetable A Det+ustom*ttributeT%peTable5+ustom*ttribute;truct6ii7.t%pe8 <
int t%pecodedindex A Det+ustom*ttributeT%pevalue5+ustom*ttribute;truct6ii7.t%pe8<
int t%peindexo#method A DetT%pe>or0ethod5parentcodedindex8<
int t%peindex#or#ield A DetT%pe>or>ield5parentcodedindex8<
i# 5 parentcodedtablename AA F4ropert%F 8
9
@
i# 5 parentcodedtablename AA F>ield=e#F GG Det;trin(5T%pe=e#;truct6t%peindex#or#ield7.name8
AA FR=eletedF8
9
strin( returnstrin( AF .custom IJ0+F C ii.To;trin(5FK6F8 C FJI 5N)\)/!)R/!):,IJ040000F
C parentcodedindex.To;trin(5FK2F8<
returnstrin( A returnstrin( C FJI 8 instance void F <
int t%pere#index A 0ember,e#;truct6t%pecodedindex7.clas HH 3<
strin( t%pere#name A t%pere#names6t%pere#index7 <
returnstrin( A returnstrin( C t%pere#name C FMMF C
)ame,eserved5Det;trin(50ember,e#;truct6t%pecodedindex7.name88 C F5F<
returnstrin( A returnstrin( C methodre#paramarra%16t%pecodedindex7 C F8 IJ 0*0000F C
t%pecodedindex.To;trin(5FK2F8 C F JIF<
+onsole.!rite5returnstrin(8<
=ispla%>inalO%tes5ii $ returnstrin(8<
@
i# 5 parentcodedtablename AA FT%pe=e#F GG Det;trin(5T%pe=e#;truct6parentcodedindex7.name8
AA FR=eletedF8
9
strin( returnstrin( A F .custom IJ0+F C ii.To;trin(5FK6F8 C FJI 5F C
Det;trin(5T%pe=e#;truct6parentcodedindex7.nspace8 C F.F C
Det;trin(5T%pe=e#;truct6parentcodedindex7.name8<
244260235.doc 541 od 541
returnstrin( A returnstrin( C FIJ 020000F C parentcodedindex.To;trin(5FK2F8 C F JIIJ020000F C
parentcodedindex.To;trin(5FK2F8 C FJI 8 instance void F<
int t%pere#index A 0ember,e#;truct6t%pecodedindex7.clas HH 3<
strin( t%pere#name A t%pere#names6t%pere#index7 <
returnstrin( A returnstrin( C t%pere#name C FMMF C
)ame,eserved5Det;trin(50ember,e#;truct6t%pecodedindex7.name88 C F58 IJ 0*0000F C
t%pecodedindex.To;trin(5FK2F8 C F JIF<
+onsole.!rite5returnstrin(8<
=ispla%>inalO%tes5ii $ returnstrin(8<
@
i# 5 parentcodedtablename AA F0ethod=e#F GG
Det;trin(5T%pe=e#;truct6t%peindexo#method 7.name8 AA FR=eletedF8
9
strin( methodt%pe A FF<
i# 5 Det;trin(50ethod;truct6parentcodedindex7.name8 EA F0ainF8
methodt%pe A methodde#t%pearra%6t%peindexo#method7<
i# 5 Det;trin(50ethod;truct6parentcodedindex7.name8 AA F'nitiali&e+omponentF8
methodt%pe A Finstance F<
+onsole.!rite5F .custom IJ0+90@JI 5method 91@void F $ ii.To;trin(5FK6F8 $ methodt%pe $
methodde#returnarra%6t%peindexo#method78<
+onsole.!rite5F90@.91@IJ 0292@F $ Det;trin(5T%pe=e#;truct6t%peindexo#method7.nspace8$
Det;trin(5T%pe=e#;truct6t%peindexo#method7.name8 $ t%peindexo#method.To;trin(5FK6F88<
+onsole.!rite5F JIMM90@58 IJ 06000091@ JIIJ06000091@JI 8 F $
Det;trin(50ethod;truct6parentcodedindex7.name8$ parentcodedindex.To;trin(5FK2F88<
int t%pere#index A 0ember,e#;truct6t%pecodedindex7.clas HH 3<
strin( t%pere#name A t%pere#names6t%pere#index7 <
+onsole.!rite5Finstance void 91@MM92@58 IJ 0*000093@ JI A 5 01 00 00 00 8 F$
methodde#returnarra%6t%peindexo#method7 $ t%pere#name $ F.ctorF$
t%pecodedindex.To;trin(5FK2F8 8<
+onsole.!rite3ine58<
@
@
@
@

:ndPPPPPPPPPPPPPPPPPPPPPPPP

Вам также может понравиться