Type Metadata in Visual Studio .NET

Make Denso QR Bar Code in Visual Studio .NET Type Metadata
Type Metadata
Making QR Code 2d Barcode In .NET Framework
Using Barcode encoder for VS .NET Control to generate, create Denso QR Bar Code image in .NET applications.
This concludes our introduction to the sync block table In 6, we will see, in depth, how the sync block information can be utilized to track down synchronization problems The next interesting field in Figure 2-8 is the type handle field, which is described next
Decoding Denso QR Bar Code In .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Type Handle
Bar Code Creator In .NET
Using Barcode printer for Visual Studio .NET Control to generate, create bar code image in Visual Studio .NET applications.
All instances of type reference get put on the managed heap controlled by the GC All instances contain what is known as a type handle Simply put, the type handle points to what is known as the method table for that particular type The method table contains metadata that fully describe the particular type Figure 2-9 illustrates the overall layout of the method table The type handle is the glue of the CLR type system and associates the object instance with all of its relevant type data The type handle of an object instance stored on the managed heap is a pointer to what is known as a method table The method table contains a lot of information about the type of the object itself, including pointers to other key CLR data structures (such as the EEClass) The very first category of data that the type handle points to contains some miscellaneous information about the type itself Table 2-2 illustrates the fields in this category Table 2-2 Fields in the Miscellaneous Part of the Method Table
Recognizing Barcode In .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET framework applications.
Type Handle Offset Name Description
Quick Response Code Generator In C#
Using Barcode maker for .NET Control to generate, create QR-Code image in Visual Studio .NET applications.
2 CLR FUNDAMENTALS
Creating QR Code ISO/IEC18004 In .NET
Using Barcode creator for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
Flags
QR Drawer In VB.NET
Using Barcode creation for .NET Control to generate, create QR Code 2d barcode image in Visual Studio .NET applications.
Base Size
GS1 128 Maker In .NET
Using Barcode maker for VS .NET Control to generate, create UCC - 12 image in VS .NET applications.
+8 +10 +12 +14 +16
Generating Barcode In .NET Framework
Using Barcode creation for .NET Control to generate, create barcode image in VS .NET applications.
Flags2 NumMethods NumVirtMethods NumInterfaces Parent
Code39 Creation In .NET
Using Barcode encoder for Visual Studio .NET Control to generate, create Code 3/9 image in Visual Studio .NET applications.
Bitmask that provides information about the type itself For example, 0x00040000 indicates that the type is a class but not an array This is the size in bytes of an instance of the type when allocated on the managed heap Additional type information Indicates the total number of methods that the type contains Indicates the number of virtual methods that the type contains Indicates the number of interfaces that the type implements Pointer to the parent method table
Bar Code Generation In VS .NET
Using Barcode creation for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
2
Postnet Generation In .NET Framework
Using Barcode maker for .NET framework Control to generate, create Delivery Point Barcode (DPBC) image in VS .NET applications.
CLR Fundamentals
Code-39 Creator In Java
Using Barcode encoder for Java Control to generate, create Code 39 Full ASCII image in Java applications.
Type Handle
Code128 Printer In VB.NET
Using Barcode generator for .NET framework Control to generate, create USS Code 128 image in .NET applications.
Syncblk
UCC - 12 Drawer In Java
Using Barcode encoder for Java Control to generate, create UPC-A image in Java applications.
Object Instance
Code 128A Creator In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create Code 128 image in ASP.NET applications.
Managed Heap Execution Engine Memory
Printing Data Matrix 2d Barcode In C#.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in Visual Studio .NET applications.
Method Table GCInfo
Recognize Bar Code In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Syncblk Table SyncBlk Entry 1 SyncBlk Entry 2
Data Matrix Reader In .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Basic Type Info (flags, size, method count, parent-method table) EEClass EEClass
Bar Code Generator In VB.NET
Using Barcode printer for VS .NET Control to generate, create bar code image in VS .NET applications.
Module
Module Info
Interface V-Table SyncBlk Entry x Virtual Method 1
Virtual Method 2
Virtual Method X
Method 1
Method 2
Method X
Figure 2-9 Managed heap object instances and method tables
Let s take a look at what a method table looks like in the debugger We will again use the 02TypeSampleexe sample application After you ve launched the application under the debugger, set a breakpoint at line 41 and continue execution until the breakpoint hits Listing 2-8 shows the debug conversation
Type Metadata
Listing 2-8 Dumping the method table in the debuggers
0:000> load sosexdll 0:000> !bpsc 02typesamplecs 41 0:000> g ModLoad: 76680000 7673f000 C:\Windows\system32\ADVAPI32dll ModLoad: 763b0000 76473000 C:\Windows\system32\RPCRT4dll ModLoad: 76570000 765c5000 C:\Windows\system32\SHLWAPIdll ModLoad: 77b90000 77bdb000 C:\Windows\system32\GDI32dll ModLoad: 765e0000 7667e000 C:\Windows\system32\USER32dll ModLoad: 77870000 7791a000 C:\Windows\system32\msvcrtdll ModLoad: 76520000 7653e000 C:\Windows\system32\IMM32DLL ModLoad: 77710000 777d7000 C:\Windows\system32\MSCTFdll ModLoad: 765d0000 765d9000 C:\Windows\system32\LPKDLL ModLoad: 76330000 763ad000 C:\Windows\system32\USP10dll ModLoad: 75390000 75524000 C:\Windows\WinSxS\x86_microsoftwindowscommoncontrols_6595b64144ccf1df_60600020533_none_4634c4a021 ModLoad: 79e70000 7a3ff000 C:\Windows\MicrosoftNET\Framework \v2050727\mscorwksdll ModLoad: 75630000 756cb000 C:\Windows\WinSxS\x86_microsoftvc80 crt_1fc8b3b9a1e18e3b_8050727762_none_10b2f55f9bffb8f8\MSVCR80d ModLoad: 76b90000 7765e000 C:\Windows\system32\shell32dll ModLoad: 77920000 77a64000 C:\Windows\system32\ole32dll ModLoad: 790c0000 79bf6000 C:\Windows\assembly \NativeImages_v2050727_32\mscorlib\32e6f703c114f3a971cbe706586e3655\ mscorlibnidl ModLoad: 79060000 790b6000 C:\Windows\MicrosoftNET\Framework \v2050727\mscorjitdll (21102740): CLR notification exception - code e0444143 (first chance) Breakpoint 0 hit eax=0000000a ebx=0025f42c ecx=0163588c edx=0000000a esi=0163588c edi=0163588c eip=003400a7 esp=0025f3f8 ebp=0025f410 iopl=0 nv up ei pl zr na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 003400a7 8bcf mov ecx,edi 0:000> loadby sosdll mscorwks 0:000> !ClrStack -a OS Thread Id: 0x2740 (0) ESP EIP 0025f3f8 003400a7 AdvancedNETDebugging2TypeSampleMain(SystemString[]) PARAMETERS: args = 0x0163587c LOCALS: <CLR reg> = 0x0163588c 0025f618 79e7c74b [GCFrame: 0025f618]
2 CLR FUNDAMENTALS
(continues)
2
CLR Fundamentals
Listing 2-8 Dumping the method table in the debuggers (continued)
0:000> dd 0163588c 0163589c 016358ac 016358bc 016358cc 016358dc 016358ec 016358fc 0:000> dd 002930b0 002930c0 002930d0 002930e0 002930f0 00293100 00293110 00293120 0:000>
0x0163588c 002930b0 0000000a 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 002930b0 00040000 00000014 790fd0f0 00292c3c 00000000 00000000 7936b3d0 793624d0 00340070 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000005 00000000 00000000 00000000 00000000 00000000 00000000 00000000
0000000a 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00070402 002930f8 79371278 003400c8 00000080 00000000 00000000 00000000
00000004 00291244 7936b3b0 0029c015 00000000 00000000 00000000 00000000
In Listing 2-8, we used the ClrStack extension command to find the local variable on the Main frame The local variable is a pointer to an instance of type TypeSample located on the managed heap Next, we dump out the instance and notice that the first field has a value of 0x002930b0, which corresponds to the type handle To find more information about the type handle (which points to the method table), we dump out the contents of the type handle The first field displayed (0x00040000) corresponds to the flags field and indicates that the type is a class (non array) The next field indicates the base size of the instance, which in this case is 0x14 bytes (20 decimal) From the source code in Listing 2-5 we can see that the TypeSample class consists of a structure with 4 integers equaling a size of 16 (4*sizeof(DWORD)) The remaining 4 bytes are allocated for the type handle value The next field of interest is the Flags2 field (WORD) and its value is 0x0402 This bitmask tells the CLR that the type does not need any special class initialization logic as well as the fact that the class does not have any security properties The next WORD-sized field contains the value 0x0007 and indicates that the class has a total of seven methods If we look at the source code in Listing 2-5, we can see that the class only has two explicit methods, namely Main and AddCoordinates What are these other five methods The first thing to remember is that even though we did not explicitly define any constructors, the C# compiler automatically generated a default constructor for us The second thing to remember is that all classes are