|
|
 |

 |
|
Inside Microsoft® .NET IL Assembler
|
|
 |
Author |
 |
Serge Lidin
|
 |
|
Pages |
496
|
|
Disk |
1 Companion CD(s)
|
|
Level |
All Levels
|
|
Published |
02/06/2002
|
|
ISBN |
9780735615472
|
|
ISBN-10 |
0-7356-1547-0
|
|
Price(USD) |
$49.99
To see this book's discounted price, select a reseller below.
|
|
|
|
|
 |
|
|
Index
Send feedback about this index to mspindex@microsoft.com
Symbols and Numbers
#~ compressed (optimized) metadata stream, 80, 81, 82-83
#- uncompressed (unoptimized) metadata stream, 81, 82-83, 94
A
abstract classes, 126
access permissions, 333-37
accessor methods, 300
actions, 331-32
add instruction, 247
add.ovf and add.ovf.un instructions, 249
addressing arguments and local variables
local block allocation, 256
local variables
loading, 255
reference loading, 256
storing, 256
method arguments
address loading, 254
list, 255
loading, 254
storing, 255
prefix instructions, 257
addressing classes and value types, 261-65
addressing fields, 257-58
AddressOfEntryPoint field, 60
/ADVANCED disassembler option, 380, 381
ansi keyword, 11
appDomain-bound objects, 101
application base (AppBase), 107, 108
application domains, 99-101
ArgumentException exception, 284
arithmetical instructions
arithmetical operations, 247-48
bitwise operations, 249-50
block operations, 253-54
constant loading, 245
conversion operations, 250-51
indirect loading, 246
indirect storing, 246
logical condition check, 252-53
overflow arithmetical operations, 248-49
overflow conversion operations, 251-52
shift operations, 250
stack manipulation, 244-45
arithmetical operations, 247-48
array marshaling, 363-64
arrays, 160-62
ArrayTypeMismatchException exception, 284
assemblies
application domains, 99-101
interop, 356
introduced, 5, 97
loader in search of, 107-9
main, 112
manifests
assembly metadata table, 103-4, 120
AssemblyRef metadata table, 104-6, 120
ExportedType metadata table, 115-16, 122-23
File metadata table, 110-12, 121-22
introduced, 101-2
managed resource metadata, 112-15, 122
metadata validity rules, 119-23
Module metadata table, 109-10, 121
ModuleRef metadata table, 110, 121
order of declarations in ILAsm, 117-18
single-module and multimode assemblies, 118-19
private and shared, 98-99
satellite, 112
Assembly declarations (.assembly), 9-10, 13, 20, 21, 103-4, 117, 118, 387
.assembly extern directive, 105-7, 117, 387
assembly language. See ILAsm
assembly linker, 323-24
assembly metadata table, 103-4, 120
Assembly References (AssemblyRefs), 9-10
AssemblyCultureAttribute attribute, 324
AssemblyDelaySignAttribute attribute, 324
AssemblyKeyFileAttribute attribute, 324
AssemblyKeyNameAttribute attribute, 324
AssemblyRef declarations (.assembly extern), 105-7, 117, 387
AssemblyRef metadata table, 104-6, 120
AssemblyVersionAttribute attribute, 324
Assert action, 332
AsyncCallback delegate, 145
asynchronous calls, 145
attributes. See custom attributes; security attributes
AttributeUsageAttribute attribute, 316
auto keyword, 11
autochar keyword, 11
B
BadImageFormatException exception, 284
BeginInvoke method, 145, 146
beq and beq.s instructions, 241
bge and bge.s instructions, 241
bge.un and bge.un.s instructions, 241
bgt and bgt.s instructions, 241
bgt.un and bgt.un.s instructions, 242
bitwise operations, 249-50
ble and ble.s instructions, 242
ble.un and ble.un.s instructions, 242
blittable types, 358
blob heaps, 78-79
#Blob metadata stream, 80, 81, 82
block operations, 253-54
blt and blt.s instructions, 242
blt.un and blt.un.s instructions, 242
bne.un and bne.un.s instructions, 241
box instruction, 264
boxing, 142
br and br.s instructions, 19, 240
branching instructions
comparative, 240-42
conditional, 240
unconditional, 239-40
break instruction, 243
brfalse and brfalse.s instructions, 18, 19, 240
brtrue and brtrue.s instructions, 240
bytearray keyword, 22
/BYTES disassembler option, 381
C
call instruction, 16, 226, 259
callbacks, managed methods as callback for unman.aged, 365-68
calli instruction, 174, 260
calling methods
direct calls, 259-60
indirect calls, 260-61
tail calls, 261
calling unmanaged code, 23-24
callvirt instruction, 259-60
castclass instruction, 263
catch type of EH clause, 33, 274
.cctor (class constructor), 195-96, 197-98, 206-7, 224, 226, 229
cdecl keyword, 23
ceq instruction, 253
cgt and cgt.un instructions, 253
CIL (common intermediate language), 5
cil keyword, 14, 23, 24
ckfinite instruction, 253
class amendments, 12
class attributes
class layout information, 140
class references, 138
flags
layout, 136
reserved, 137
semantics pseudoflags, 137
string formatting, 137
type implementation, 136
type semantics, 136
visibility, 135-36
interface implementations, 139-40
parents of types, 138-39
class augmentation, 149-51, 385-86
class constructor (.cctor), 195-96, 197-98, 206-7, 224, 226, 229
class declaration, 10-12, 23
class layout information, 140
class leafs, 379
class marshaling, 363
class metadata
ClassLayout metadata table, 130
InterfaceImpl metadata table, 129
introduced, 127-28
NestedClass metadata table, 130
TypeDef metadata table, 128
TypeRef metadata table, 129
class references, 138
classes. See also types
abstract, 126
addressing, 261-65
CultureInfo, 112
enclosing, 20
Even, 11
forward declaration of, 25-26
full class names, 133-34
generic, 160
implementing interfaces, 126
[mscorlib]System.Attribute, 310
[mscorlib]System.Exception, 283, 287
[mscorlib]System.MulticastDelegate, 144, 292-95
[mscorlib]System.Security.NamedPermissionSet, 343
[mscorlib]System.Security.PermissionSet, 343
nested, 20, 147-49
PermissionSet, 343
private, 147
public, 133
RegionInfo, 112
representing, in signatures, 170-71
System.Enum, 11
System.Object, 11, 126
System.Resources.ResourceManager, 115
System.ValueType, 11
WaitHandle, 294
ClassInterfaceAttribute attribute, 318
ClassLayout metadata table, 130, 154
/CLASSLIST disassembler option, 380
CLS (Common Language Specification), 4-5, 325
CLSComplianceAttribute attribute, 325
clt and clt.un instructions, 253
code base (CodeBase), 107, 108
code interoperation
data marshaling
array marshaling, 363-64
blittable types, 358
class marshaling, 363
delegate marshaling, 364
In/Out parameters, 358-59
introduced, 357
object marshaling, 361-62
string marshaling, 359-60
introduced, 349-50
managed methods as unmanaged exports, 369-75
providing managed methods as callback for unman.aged, 365-68
thunks and wrappers
COM callable wrappers, 354-55
IJW thunks, 353-54
implementation map metadata and validity rules, 353
P/Invoke thunks, 351-52
runtime callable wrappers, 355-57
code verification, 93, 268-69
CodeAccessSecurityAttribute attribute, 321
coded tokens, 89-93
COFF header, 42-47
COM callable wrappers, 354-55
ComAliasNameAttribute attribute, 318
Combine method, 293, 294
CombineImpl method, 292-94
ComConversionLossAttribute attribute, 318
COMIMAGE_FLAGS_* values in the .NET common language runtime header, 58-59
common intermediate language (CIL), 5
common language runtime. See .NET common language runtime entries
Common Language Specification (CLS), 4-5, 325
comparative branching instructions, 240-42
compiling in debug mode, 388-92
compressed (optimized) metadata, 76-77
ComRegisterFunctionAttribute attribute, 318
ComSourceInterfacesAttribute attribute, 318-19
ComUnregisterFunctionAttribute attribute, 318
ComVisibleAttribute attribute, 319
conditional branching instructions, 240
constant loading instructions, 245
Constant metadata table, 184-85, 198, 200
Constant records, 187
constructors vs. data constants, 195-98
context-bound objects, 101
conv.* instructions, 251
conversion operations, 250-51
conv.ovf.* instructions, 252
CorCallingConvention enumeration, 171
CorElementType enumeration, 156
CorFieldAttr enumeration, 181
CorMethodAttr enumeration, 204
CorMethodImpl enumeration, 207
CorParamAttr enumeration, 208
CorSerializationType enumeration, 310
CorUnmanagedCallingConvention enumeration, 174
COR_VTABLE_* values in the VTableFixups field, 60-61
cpblk instruction, 253
cpobj instruction, 262
.ctor (instance constructor), 144, 145, 195, 206-7, 224- 26
CultureInfo class, 112
cultures, 112
custom attributes
classification of
assembly linker, 323-24
common language specification (CLS) compliance, 325
execution engine and JIT compiler, 317-18
interoperation subsystem, 318-20
introduced, 315-17
pseudocustom attributes, 325-27
remoting subsystem, 322-23
security, 320-22
Visual Studio .NET debugger, 323
CustomAttribute metadata table, 309-10
declaration, 312-15
introduced, 307-9
metadata validity rules, 327
value encoding, 310-12
.custom directive, 312-15
custom permissions, 340-43
CustomAttribute metadata table, 309-10, 327
D
data constants
constructors vs., 195-98
declaration, 189-91
data declaration, 22, 188-90
.data directive, 22, 189-90
data directory table, 42, 51-53
data marshaling
array marshaling, 363-64
blittable types, 358
class marshaling, 363
delegate marshaling, 364
In/Out parameters, 358-59
introduced, 137, 357
object marshaling, 361-62
string marshaling, 359-60
data pointer types, 157-59
data sections (.sdata)
data constants, 65-66
TLS, 68-69
unmanaged export tables, 66-68
V-table, 66
data structures, 141-42
data types, primitive, 156-57
/DEBUG compiler option, 383, 392
debug mode, compiling in, 388-92
debugger in Visual Studio .NET, 323
DebuggerHiddenAttribute attribute, 323
DebuggerStepThroughAttribute attribute, 323
declarative actions, 331-32
declarative security
advantages and disadvantages, 330
introduced, 330
metadata, 343-45
metadata validity rules, 346
DeclSecurity metadata table, 320, 343-45, 346
default values for fields, 184-87
delegate marshaling, 364
delegates, 144-46, 291-94
Demand action, 332
Deny action, 332
DispIdAttribute attribute, 319
div and div.un instructions, 247
/DLL compiler option, 383
DLL Hell, 98
DllMain function, 59
DllNotFoundException exception, 286
dotted names, 132, 134
dup instruction, 244
DynamicInvoke method, 364
E
embedded security requirements, 330
enclosers, 20
enclosing classes, 20
endfault (endfinally) instruction, 244, 274, 275, 281-82
endfilter instruction, 243, 274, 288
endfinally (endfault) instruction, 244, 274, 275, 281-82
EndInvoke method, 145, 146
.entrypoint directive, 15, 111, 387
EntryPointToken field in the .NET common language runtime header, 59-60
enumerations, pseudoflags to declare, 12
enumerators (enumeration types, enums), 143-44
EnvironmentPermission permission, 334
EnvironmentPermissionAttribute attribute, 321
evaluation stack type system, 268
.event directive, 297-300, 387
Event metadata table, 295-96, 304
EventMap metadata table, 296, 304
events
declaration, 297-300, 387
delegates and, 291-94
firing (raising), 292
metadata
Event table, 295-96
EventMap table, 296
introduced, 294-95
MethodSemantics table, 296-97
metadata validity rules, 304
publishers (sources) of, 292
subscribers (listeners, sinks) of, 292
example. See Simple example
exceptions. See also SEH
ArgumentException, 284
ArrayTypeMismatchException, 284
BadImageFormatException, 284
DllNotFoundException, 286
ExecutionEngineException, 285
FieldAccessException, 285
InvalidCast, 362
InvalidProgramException, 284
MarshalDirectiveException, 286
MethodAccessException, 285
NullReferenceException, 285
OutOfMemoryException, 284
Overflow, 251-52
processing, 281-83
RankException, 285
Runtime.InteropServices.SEHException, 286
Threading.SynchronizationLockException, 285
TypeInitializationException, 285
TypeLoadException, 21, 188, 189, 192, 193, 215, 284
types
execution engine exceptions, 284-85
interoperability exceptions, 286
JIT compiler exceptions, 284
loader exceptions, 283-84
subclassing, 286-87
unmanaged exception mapping, 287
UnauthorizedAccessException, 284
Unexpected Type, 16
VerificationException, 284
executable files, managed. See PE/COFF files
execution engine
custom attributes, 317-18
exceptions, 284-85
ExecutionEngineException exception, 285
explicit keyword, 23, 172
explicit layouts, 191-93
explicit method overriding, 216-20
explicit sequential keyword, 11
export tables, unmanaged, 66-68
ExportedType declarations (.class extern), 116, 117, 118
ExportedType metadata table, 115-16, 122-23
.extends directive, 11, 12, 23, 26
extends leafs, 379
extern keyword, 9-10
F
famandassem keyword, 13, 20
family keyword, 13, 20
famorassem keyword, 13, 20
fat method headers, 220, 221, 222
fault type of EH clause, 275, 278, 281-82, 287, 288
field declaration, 13-14, 19, 21, 22, 181, 187-88, 387
Field Definitions (FieldDefs), 13-14
field metadata, 180-84
Field metadata table, 198-99
field signatures, 172
FieldAccessException exception, 285
FieldLayout metadata table, 191, 198, 199
FieldLayout records, 191-93
FieldMarshal metadata table, 198, 199-200
FieldRVA metadata table, 198, 199
fields
addressing, 257-58
default values, 184-87
global, 194-95
initonly, 226
instance, 184
mapped, 21, 187-89
metadata validity rules, 198-200
static, 184
File declarations (.file), 111-12, 117
File metadata table, 110-12, 121-22
file pointers, PE/COFF files, 40
FileDialogPermission permission, 334
FileDialogPermissionAttribute attribute, 321
FileIOPermission permission, 334
FileIOPermissionAttribute attribute, 321
filter type of EH clause, 274, 280, 288
finalizers, instance, 226-27
finally type of EH clause, 274-75, 276, 278, 281-82, 287, 288
firing (raising) events, 292
Flags field of .NET common language runtime header, 58-59
flow control instructions
break, 243
comparative branching, 240-42
conditional branching, 240
ret, 244
SEH block ending, 243-44
SEH block exiting, 243
switch, 242-43
unconditional branching, 239-40
forward declaration of classes, 25-26
full class names, 133-34
function pointer types, 160
G
generic class, 160
getters, 300
global fields, 194-95
global items, 19-21
global methods, 229-30
globally unique identifiers (GUIDs), 308-9
guarded block, 35
GUID heaps, 78
#GUID metadata stream, 80, 81, 82, 94
GuidAttribute attribute, 319
GUIDs (globally unique identifiers), 308-9
H
handler block, 33-34
.hash directive, 111
heaps, metadata, 78-79
I
IConvertible interface, 361
identifiers, 131
identity permissions, 338-40
IDispatch interface, 355, 361, 363
IEnumerable interface, 314
IJW thunks, 353-54
IL, 5, 6
assembly language. See ILAsm
IL Disassembler (ILDASM), 378-82
ILAsm
compiler options, 383-84
naming conventions, 131-32
order of manifest declarations in, 117-18
ILDASM (IL Disassembler), 378-82
image files. See PE/COFF files
IMAGE_COR20_HEADER structure, 56-57
_IMAGE_COR_VTABLEFIXUP structure, 60-61
_IMAGE_DATA_DIRECTORY structure, 51
_IMAGE_EXPORT_DIRECTORY structure, 67
IMAGE_FILE_* characteristics values in COFF head.ers, 45-47
_IMAGE_FILE_HEADER structure, 43
IMAGE_FILE_MACHINE_* values in COFF headers, 43-44
_IMAGE_OPTIONAL_HEADER structure, 47-51
IMAGE_REL_BASED_* relocation types, 62-63
_IMAGE_RESOURCE_DATA_ENTRY structure, 72
_IMAGE_RESOURCE_DIRECTORY structure, 71
_IMAGE_RESOURCE_DIRECTORY_ENTRY structure, 71
IMAGE_SCN_* characteristics values in section head.ers, 55
_IMAGE_SECTION_HEADER structure, 53-54
_IMAGE_TLS_DIRECTORY structure, 68-69
imperative security, 330
implementation map metadata, 353
implements keyword, 12, 26
implements leafs, 379
implicit virtual method overriding, 216
ImplMap metadata table, 353
ImportedFromTypeLibAttribute attribute, 319
indirect call signatures, 174-75
indirect loading instructions, 246
indirect storing instructions, 246
Inheritance Demand action, 331
init keyword, 15, 221-23
initblk instruction, 253-54
initobj instruction, 263
initonly fields, 226
In/Out parameters, 358-59
install-time code generation, 7
instance constructor (.ctor), 144, 145, 195, 206-7, 224- 26
instance fields, 184
instance finalizers, 226-27
instance keyword, 172, 213
instance members of value types, 142-43
instance methods, 212-16
instance pointer (this), 142-43, 147
instruction parameters, 239
instructions
addressing arguments and local variables
local block allocation, 256
local variable loading, 255
local variable reference loading, 256
local variable storing, 256
method argument address loading, 254
method argument list, 255
method argument loading, 254
method argument storing, 255
prefix instructions, 257
addressing classes and value types, 261-65
addressing fields, 257-58
arithmetical
arithmetical operations, 247-48
bitwise operations, 249-50
block operations, 253-54
constant loading, 245
conversion operations, 250-51
indirect loading, 246
indirect storing, 246
logical condition check, 252-53
overflow arithmetical operations, 248-49
overflow conversion operations, 251-52
shift operations, 250
stack manipulation, 244-45
calling methods
direct calls, 258-60
indirect calls, 260-61
tail calls, 261
code verifiability, 268-69
flow control
break instruction, 243
comparative branching instructions, 240-42
conditional branching instructions, 240
ret instruction, 244
SEH block ending instructions, 243-44
SEH block exiting instructions, 243
switch instruction, 242-43
unconditional branching instructions, 239-40
long-parameter, 239
short-parameter, 239
vector
element address loading, 266
element loading, 266-67
element storing, 267
vector creation, 265-66
int8* keyword, 23
int32 keyword, 14, 15, 17, 23
int32[ , ] specification, 162
int32[][] specification, 162
int64 keyword, 22
interface implementations, 139-40
InterfaceImpl metadata table, 129, 153-54
InterfaceImpls metadata item, 315
interfaces, 140, 141
classes implementing, 126
InterfaceTypeAttribute attribute, 319
intermediate language. See IL
interop assemblies, 356
interoperability exceptions, 286
interoperation. See code interoperation
interoperation subsystem custom attributes, 318-20
InvalidCast exception, 362
InvalidProgramException exception, 284
Invoke method, 144, 145, 292, 293
IPermission interface, 343
isinst instruction, 263-64
IsolatedStorageFilePermission permission, 335
IsolatedStorageFilePermissionAttribute attribute, 321
/ITEM disassembler option, 381, 382
IUnknown interface, 355, 361, 363
J
JIT compiler
custom attributes, 317-18
exceptions, 284
jmp instruction, 259
just-in-time compiler. See JIT compiler
K
/KEY compiler option, 383-84
L
label form of SEH clause declaration, 275-78
labels, 15
Lame Linker tool, 386, 387
.language directive, 388, 392
ldarga and ldarga.s instructions, 254
ldc.* instructions, 19, 245
ldelem.* instructions, 266-67
ldelema instruction, 266
ldfld instruction, 184, 258
ldflda instruction, 184, 198, 258
ldftn instruction, 225, 260
ldind.* instructions, 246
ldlen instruction, 266
ldloc and ldloc.s instructions, 18, 255
ldloc.0, ldloc.1, ldloc.2, and ldloc.3 instructions, 255
ldloca and ldloca.s instructions, 256
ldnull instruction, 261
ldobj instruction, 261-62
ldsfld instruction, 19, 184, 187, 258
ldsflda instruction, 17, 184, 198, 258
ldstr instruction, 262
ldstr keyword, 16, 19, 22
ldtoken instruction, 183, 264-65
ldvirtftn instruction, 260
leave and leave.s instructions, 32-35, 243, 275
.line directive, 388, 392
/LINENUM disassembler option, 382, 389, 392
Link Demand action, 332
linker, 323-24
listeners (sinks, subscribers) of events, 292
literal fields, 144
literals, single-quoted, 132
loader
exceptions, 283-84
in search of assemblies, 107-9
local block allocation, 256
local variable loading, 255
local variable reference loading, 256
local variable storing, 256
local variables, 221-24. See also addressing arguments and local variables
local variables signatures, 175
locales, 112
localization of applications, 112
localloc instruction, 256
.locals directive, 15
logical condition check instructions, 252-53
long-parameter instructions, 239
M
Machine types in COFF headers, 43-44
main assembly, 112
managed code, 5
unmanaged code and. See code interoperation
managed executable files, 5, 7, See PE/COFF files
managed keyword, 23, 24
managed methods
callback for unmanaged, 365-68
unmanaged exports, 369-75
managed pointers, 157-59
managed resource declarations (.mresource), 114, 117
managed resource metadata, 112-15, 122
ManifestResource declarations (.mresource), 387
ManifestResource metadata table, 114, 122
manifests
assembly metadata table, 103-4, 120
AssemblyRef metadata table, 104-6, 120
ExportedType metadata table, 115-16, 122-23
File metadata table, 110-12, 121-22
introduced, 101-2
managed resource metadata, 112-15, 122
metadata validity rules, 119-23
Module metadata table, 109-10, 121
ModuleRef metadata table, 110, 121
order of declarations in ILAsm, 117-18
single-module and multimodule assemblies, 118-19
mapped fields, 21, 187-89
MarshalDirectiveException exception, 286
marshaling. See data marshaling
.maxstack directive, 224, 238
mdt* token types, 87-88, 180, 202, 295, 301, 309
Member References (MemberRefs), 16, 210
MemberRef metadata table, 198, 200
MemberRef signatures, 174
metadata
classes
ClassLayout metadata table, 130
InterfaceImpl metadata table, 129
NestedClass metadata table, 130
type metadata, 127
TypeDef metadata table, 128
TypeRef metadata table, 129
declarative security, 343-45
defined, 75-76
events
Event table, 295-96
EventMap table, 296
introduced, 294-95
MethodSemantics table, 296-97
fields, 180-84
headers, 79-82
heaps, 78-79
implementation map, 353
manifests
assembly metadata table, 103-4, 120
AssemblyRef metadata table, 104-6, 120
ExportedType metadata table, 115-16, 122-23
File metadata table, 110-12, 121-22
introduced, 101-2
managed resource metadata, 112-15, 122
Module metadata table, 109-10, 121
ModuleRef metadata table, 110, 121
validity rules, 119-23
methods
method flags, 204-6
method implementation flags, 207-8
method implementation metadata, 211
method name, 206-7
method parameters, 208-10
Method table record entries, 202-3
referencing the methods, 210-11
optimized (compressed), 76-77
PEVerify tool for, 94
properties, 300-302
Property table, 301-2
PropertyMap table, 302
record identifiers (RIDs) in, 87
schema, 83
tablestags in, 89-90
tokens
coded, 89-93
external, 87-89
unoptimized (uncompressed), 77-78
validation, 93-94
metadata streams
#~ compressed (optimized) metadata stream, 80, 81, 82-83
#- uncompressed (unoptimized), 81, 82-83, 94
#Blob, 80, 81, 82
#GUID, 80, 81, 82, 94
#Strings, 80, 81, 82
#US, 80, 81, 82, 88-89
metadata table streams, 82-87
metadata validity rules
custom attributes, 327
declarative security, 346
events, 304
fields, 198-200
methods, 230-33, 305-6
properties, 304-5
types, 151-54
/METAINFO disassembler option, 380, 382
method argument address loading, 254
method argument list, 255
method argument loading, 254
method argument storing, 255
method declaration, 14-19, 23, 387
Method Definitions (MethodDefs), 14-19, 210
Method metadata table, 202-3, 230-32
method signatures, 173
MethodAccessException exception, 285
MethodImpl metadata table, 230, 233
methods
calling, 258-261
direct calls, 259-60
indirect calls, 260-61
tail calls, 261
class constructors (.cctors), 224, 226
explicit method overriding, 216-20
global, 229-30
header attributes, 220-21, 222
implicit virtual method overriding, 216
instance, 212-16
instance constructors (.ctors), 224-26
instance finalizers, 226-27
local variables, 221-24
metadata
introduced, 202
method flags, 204-6
method implementation flags, 207-8
method implementation metadata, 211
method name, 206-7
method parameters, 208-10
Method table record entries, 202-3
referencing the methods, 210-11
metadata validity rules, 230-33, 305-6
nonvirtual, 213, 215
static, 212
variable argument lists (vararg), 227-29
virtual, 213-16
MethodSemantics metadata table, 296-97, 304, 305-6
Microsoft intermediate language. See MSIL
mkrefany instruction, 264
modifiers for primitive types, 162-65
modopt modifier, 163-64
modreq modifier, 163-64
module entry point declarations (.entrypoint), 15, 111, 387
.module extern directive, 110, 117
module keyword, 10
module linking through round-tripping, 386-88
Module metadata table, 109-10, 121
ModuleRef declarations (.module extern), 110, 117
ModuleRef metadata table, 110, 121
modules. See assemblies
.mresource directive, 114, 117, 387
[mscorlib]System.Attribute class, 310
[mscorlib]System.Diagnostics.Debuggable-Attribute attribute, 388
[mscorlib]System.Exception class, 283, 287
[mscorlib]System.MulticastDelegate class, 144, 292-95
[mscorlib]System.Security.NamedPermissionSet class, 343
[mscorlib]System.Security.PermissionSet class, 343
MS-DOS stub, 42
MSIL, 5
assembly language. See ILAsm
mul instruction, 247
mul.ovf and mul.ovf.un instructions, 249
multilanguage projects
class augmentation, 385-86
compiling in debug mode, 388-92
creative round-tripping, 384-85
IL Disassembler (ILDASM), 378-82
module linking through round-tripping, 386-88
principles of round-tripping, 383-84
multimodule assemblies, 118-19
N
names, full class, 133-34
.namespace directive, 10-12, 132-33
namespaces, 132-33
naming conventions, 131-32
native keyword, 14
native types, 165-68
neg instruction, 248
nested classes, 20
nested types, 20, 147-49
NestedClass metadata table, 130, 154
.NET common language runtime basics, 4-7
.NET common language runtime header
EntryPointToken field, 59-60
Flags field, 58-59
StrongNameSignature field, 61
structure, 56-57
VTableFixups field, 60-61
neutral cultures, 112
newarr instruction, 160, 162, 265-66
newobj instruction, 176, 224-25, 226, 263
/NOBAR disassembler option, 382
/NOIL disassembler option, 381, 382
nonvirtual methods, 213, 215
nop instruction, 244
nullref keyword, 185
NullReferenceException exception, 285
O
object marshaling, 361-62
ObsoleteAttribute attribute, 325
operation codes (opcodes), 239
optimized (compressed) metadata, 76-77
/OUT compiler option, 383
/OUT disassembler option, 378, 382
OutOfMemoryException exception, 284
overflow arithmetical operations, 248-49
overflow conversion operations, 251-52
Overflow exception, 251-52
.override directive, 219-20
P
P/Invoke (platform invocation), 23-24
.pack directive, 140
Param metadata table, 230, 232-33
parameter marshaling, 23-24
parameters in instructions, 239
parents of types, 138-39
PE header, 42, 47-53
PE signature, 42
PE/COFF files
data sections (.sdata)
data constants, 65-66
TLS, 68-69
unmanaged export tables, 66-68
V-table, 66
file pointers, 40
headers
COFF header, 42-47
MS-DOS stub, 42
PE header, 42, 47-53
PE signature, 42
section headers, 42, 53-56
.NET common language runtime header
EntryPointToken field, 59-60
Flags field, 58-59
StrongNameSignature field, 61
structure, 56-57
VTableFixups field, 60-61
relative virtual addresses (RVAs), 40
relocation (.reloc) section, 61-63
resources (.rsrc)
managed, 72
unmanaged, 70-72
sections, 41
structure, 39-41
summarized, 73-74
.text section, 63-65
virtual addresses (VAs), 41
.permission directive, 345-46
permission sets, 343
permissions, defined, 331
PermissionSet class, 343
.permissionset directive, 346
PermissionSetAttribute attribute, 321
Permit Only action, 332
PEVerify tool, 94
pinned modifier, 164-65
P/Invoke thunks, 351-52
pinvokeimpl keyword, 23
placeholders, value types as, 22-23
platform invocation (P/Invoke), 23-24
polling from the main thread, 145
pop instruction, 245
Portable Executable and Common Object File Format. See PE/COFF files
prefix instructions, 257
prime module, 97
primitive types
arrays, 160-62
data, 156-57
data pointer, 157-59
function pointer, 160
modifiers for, 162-65
native, 165-68
variant, 168-70
vectors, 160-62
PrincipalPermissionAttribute attribute, 321
private assemblies, 98-99
private classes, 147
private keyword, 11, 13, 20, 21
privatescope keyword, 13-14, 20, 21
ProgIdAttribute attribute, 319
program header, 9-10
properties
declaration, 302-3, 387
metadata, 300-301
Property table, 301-2
PropertyMap table, 302
metadata validity rules, 304-5
Property metadata table, 301-2, 304-5
property signatures, 173
PropertyMap metadata table, 302, 304, 305
protected block, 34
pseudocustom attributes, 325-27
public classes, 133
public keyword, 11, 13, 14, 19, 20, 21, 22, 23
PublisherIdentityPermission permission, 339-40
PublisherIdentityPermissionAttribute attribute, 321
publishers (sources) of events, 292
R
raising (firing) events, 292
RankException exception, 285
/RAWEH disassembler option, 381
record identifiers (RIDs), 87
refanytype instruction, 264
refanyval instruction, 264
reference types, 125-26
Reflection methods, 186-87
ReflectionPermission permission, 335
ReflectionPermissionAttribute attribute, 321
RegionInfo class, 112
regions, 112
RegistryPermission permission, 336
RegistryPermissionAttribute attribute, 321
relative virtual addresses (RVAs), 40, 113
relocation (.reloc) section of PE/COFF files, 61-63
rem and rem.un instructions, 247-48
remoting subsystem custom attributes, 322-23
Remove method, 293, 294
RemoveImpl method, 292-94
Request Minimum action, 331
Request Optional action, 331
Request Refuse action, 331
/RES compiler option, 383
resources (.rsrc)
managed, 72
unmanaged, 70-72
Resources data directory, 113
ret instruction, 19, 244
rethrow instruction, 265, 283
RIDs (record identifiers), 87
round-tripping
creative, 384-85
module linking through, 386-88
principles of, 383-84
runtime. See .NET common language runtime entries
runtime callable wrappers, 355-57
run-time validation and verification, 93
Runtime.InteropServices.SEHException exception, 286
RVAs (relative virtual addresses), 40, 113
S
satellite assemblies, 112
schema, 83
scope form of SEH clause declaration, 278-81
sealed types, 138, 141
section headers, 42, 53-56
sections of PE/COFF files, 41
security
declarative
advantages and disadvantages, 330
metadata, 343-45
metadata validity rules, 346
imperative, 330
security attributes
declaration, 345-46
declarative actions, 331-32
security custom attributes, 320-22
security permissions
access permissions, 333-37
custom permissions, 340-43
identity permissions, 338-40
permission sets, 343
security policies, 329
security requirements, embedded, 330
SecurityAttribute attribute, 321
SecurityPermission permission, 336-37
SecurityPermissionAttribute attribute, 321
SEH. See also exceptions
block ending instructions, 243-44
block exiting instructions, 243
catch type of EH clause, 33, 274
clauses
internal representation, 272-73
label form of declaration, 275-78
scope form of declaration, 278-81
structuring rules, 287-88
types, 274-75
fault type of EH clause, 275, 278, 281-82, 287, 288
filter type of EH clause, 274, 280, 288
finally type of EH clause, 274-75, 276, 278, 281-82, 287, 288
guarded block, 35
handler block, 33-34
introduced, 271-72
leave keyword, 32-35
protected block, 34
Simple example (Simple.exe), 31-35
throw instruction, 265, 282-83
.try keyword, 32, 34-35, 275-81
sentinels, 18
sequential layout, 193
SET encoding, 172
setters, 300
shared assemblies, 98-99
shift operations, 250
shl instruction, 250
shr and shr.un instructions, 250
signatures
calling conventions, 171-72
defined, 155
field, 172
indirect call, 174-75
local variables, 175
MemberRef, 174
method, 173
property, 173
representing classes in, 170-71
type specifications (TypeSpecs), 175-76
validity rules, 176-78
single-module assemblies, 118-19
single-quoted literals, 132
sinks (listeners, subscribers) of events, 292
SiteIdentityPermission permission, 340
SiteIdentityPermissionAttribute attribute, 321
.size directive, 23, 140
sizeof instruction, 265
sources (publishers) of events, 292
sscanf function, 17, 18, 23, 24, 27, 29, 30, 33-35
stack manipulation instructions, 244-45
StandAloneSigs metadata item, 315
static fields, 184
static keyword, 13, 14, 19, 21, 22, 23, 213
static methods, 212
/STATISTICS disassembler option, 380
stelem.* instructions, 267
stfld instruction, 184, 198, 258
stind.* instructions, 246
stloc and stloc.s instructions, 18, 256
stobj instruction, 262
string heaps, 78
string keyword, 17, 23
string marshaling, 359-60
#Strings metadata stream, 80, 81, 82
strong names, 98, 99
StrongNameIdentityPermission permission, 339
StrongNameIdentityPermissionAttribute attribute, 322
StrongNameSignature field in the .NET common lan.guage runtime header, 61
structured exception handling. See SEH
structures, 141-42
stsfld instruction, 184, 198, 258
stubs. See thunks
sub instruction, 247
sub.ovf and sub.ovf.un instructions, 249
subscribers (listeners, sinks) of events, 292
SuppressUnmanagedCodeSecurityAttribute attribute, 320
switch instruction, 242-43
synchronous calls, 145
[System.DirectoryServices]System.Directory-Services.DirectoryServicesPermission permission, 333
System namespace, 325
System.AttributeUsageAttribute attribute, 316
System.Diagnostics namespace, 323
System.Diagnostics.DebuggableAttribute attribute, 317
System.Enum class, 11
System.NonSerializedAttribute attribute, 326
System.Object class, 11, 126
System.Reflection class library, 92
System.Reflection namespace, 324
System.Reflection.Emit class library, 92
System.Resources.ResourceManager class, 115
System.Runtime.CompilerServices.MethodImpl-Attribute attribute, 326
System.Runtime.InteropServices namespace, 318
System.Runtime.InteropServices.ComImport-Attribute attribute, 325
System.Runtime.InteropServices.DllImport-Attribute attribute, 325-26
System.Runtime.InteropServices.FieldOffset-Attribute attribute, 326
System.Runtime.InteropServices.GuidAttribute attribute, 309
System.Runtime.InteropServices.InAttribute attribute, 326
System.Runtime.InteropServices.MarshalAs-Attribute attribute, 326
System.Runtime.InteropServices.Optional-Attribute attribute, 326
System.Runtime.InteropServices.OutAttribute attribute, 326
System.Runtime.InteropServices.PreserveSig-Attribute attribute, 326
System.Runtime.InteropServices.StructLayout-Attribute attribute, 326
System.Runtime.InteropServices.UnmanagedType enumerator, 165
System.Runtime.Remoting.Activation.UrlAttribute attribute, 323
System.Runtime.Remoting.Contexts.Context-Attribute attribute, 322
System.Runtime.Remoting.Contexts.Synchronization.Attribute attribute, 322-23
System.Security namespace, 320
System.Security.DynamicSecurityMethodAttribute attribute, 326
System.Security.Permissions namespace, 320, 333, 338
System.Security.UnverifiableCodeAttribute attribute, 317
System.SerializableAttribute attribute, 326
[System]System.Net.DnsPermission permission, 334
System.Theading namespace, 294
System.ThreadStaticAttribute attribute, 318
System.ValueType class, 11
T
tags in metadata tables, 89-90
tail. instruction, 261
targets, 331
/TEXT disassembler option, 378, 382
.text section of PE/COFF files, 63-65
this (instance pointer), 142-43, 147
thread local storage (TLS), 68-69
Threading.SynchronizationLockException exception, 285
throw instruction, 265, 282-83
thunks. See also wrappers
IJW, 353-54
P/Invoke, 351-52
tiny method headers, 220, 222
TLS (thread local storage), 68-69
/TOKENS disassembler option, 381
tokens, metadata
coded, 89-93
external, 87-89
.try directive, 32, 34-35, 275-81
type conversions, evaluation stack, 268
Type Definitions (TypeDefs), 10-12, 20, 127, 128
Type References (TypeRefs), 127, 128
type specifications (TypeSpecs), 175-76
TypeDef metadata table, 128, 151-53
TypeInitializationException exception, 285
TypeLibFuncAttribute attribute, 320
TypeLibTypeAttribute attribute, 320
TypeLibVarAttribute attribute, 320
TypeLoadException exception, 21, 188, 189, 192, 193, 215, 284
TypeRef metadata table, 129, 153
types. See also classes
blittable, 358
data constants, 190-91
delegates, 144-46
enumerators (enumeration types, enums), 143-44
interfaces, 140-41
metadata validity rules, 151-54
nested, 20, 147-49
parents of, 138-39
primitive
arrays, 160-62
data, 156-57
data pointer, 157-59
function pointer, 160
modifiers for, 162-65
native, 165-68
variant, 168-70
vectors, 160-62
reference, 125-26
sealed, 138, 141
values
addressing, 261-65
boxed and unboxed values, 142
derivation of, 143
instance members of, 142-43
as placeholders, 22-23
pseudoflags to declare, 12
types, 11, 126, 141-42
U
UIPermissionAttribute attribute, 322
unaligned. prefix, 257
UnauthorizedAccessException exception, 284
unbound objects, 101
unbox instruction, 264
unboxing, 142
uncompressed (unoptimized) metadata, 77-78
unconditional branching instructions, 239-40
Unexpected Type exception, 16
Unicode, user-defined strings, 88-89
/UNICODE disassembler option, 381
unicode keyword, 11
union declaration, 192-93
unmanaged code
calling, 23-24
managed code and. See code interoperation
unmanaged export tables, 66-68
unmanaged keyword, 14
unmanaged methods
managed methods as callback for, 365-68
managed methods as unmanaged exports, 369-75
unmanaged pointers, 157-59
unoptimized (uncompressed) metadata, 77-78
UrlIdentityPermission permission, 340
UrlIdentityPermissionAttribute attribute, 322
#US metadata stream, 80, 81, 82, 88-89
/UTF8 disassembler option, 381
V
validation of metadata, 93-94
value types. See values
valuetype keyword, 17, 19, 21, 22
vararg (variable argument lists), 227-29
vararg keyword, 17-18, 23, 172
vararg method, 164, 174
VARENUM enumeration, 168
variable argument lists (vararg), 227-29
variant types, 168-70
VAs (virtual addresses), 41
vector instructions
element address loading, 266
element loading, 266-67
element storing, 267
vector creation, 265-66
vectors, 160-62
VerificationException exception, 284
virtual addresses (VAs), 41
virtual methods, 213-16
/VISIBILITY disassembler option, 381, 382
Visual Studio .NET debugger, 323
void keyword, 14, 16, 19
volatile. prefix, 257
V-table, 66
VTableFixups field in the .NET common language runtime header, 60-61
.vtentry directive, 370, 373-74
.vtfixup directive, 369, 370, 373-74
W
WaitHandle class, 294
wrappers. See also thunks
COM callable, 354-55
defined, 350
runtime callable, 355-57
X
xor instruction, 250
Z
ZoneIdentityPermission permission, 338
ZoneIdentityPermissionAttribute attribute, 322
Last Updated: January 22, 2002
|