This book on MetaData Tables is a heady cocktail of the esoteric and mysterious details pertaining to the internals of an executable file, which gets created by the compiler of any .Net product.


It is an intricate book, which would appear formidable to those uninitiated to the world of C#. It is replete with programs written using the C# language, and is predicated on the presumption that you possess adequate knowledge of this language.


In the .Net world, when the compiler processes the source code, it creates an IL file. This IL file is inherently capable of comprehending object types. It is equipped with instructions that do the following: create and initialize objects, call methods, raise and catch exceptions, etc. This IL file is thereafter converted into an executable or a DLL file, i.e. PE file, after the compiler has firmly embedded the MetaData information in it. It is the repository of information that relates to the types and the methods that have been employed in the file.


Earlier, Microsoft had extended its original DOS format and had incorporated the PE file format in order to buttress the execution of files on the Windows platform. However, with the introduction of .Net, Microsoft remolded its PE file format and instituted a header to store the MetaData information. Specifically, one of the structures in the optional header has been used for the CLR header.


MetaData is a key component that casts a significant shadow on the .NET architecture. It renders the Runtime with vital information about assemblies, classes, methods and scores of other significant details. Thus, MetaData represents data, which is exacting, comprehensive, and most importantly, language-independent. This results in a common format for exposing the information contained in a file or an assembly, thereby introducing flexibility and code sharing between applications that use disparate languages. Finally, the MetaData facilitates remote method calls in the .Net Framework.


Our book on 'MetaData Tables' delineates how the MetaData is laid out after being read into memory from a PE file. The MetaData is stored in either tables or streams. There are five streams in all. One of the streams comprises of tables that store the relevant data. The remaining four are String, Blob, UserString and Guid. There exists an awesome amount of interdependence between these streams.


All MetaData is stored internally in the form of tables. There exist about 43 assorted table types in the realm of MetaData, each of which stores specific information. For instance, all the types are stored in one table, all the methods are stored in another table, all the parameters are stored in yet another table, and so on. Each table is assigned one bit in one of the MetaData fields. Contingent upon the status of this bit field, the presence of a particular table can be ascertained.


Every table has been assigned a name and a number. The table that is assigned the number 0 is known as 'Module', while the table that is assigned the number 1 is called TypeRef, and so on. Moreover, Microsoft has extensively utilized the features of coded indexes to enhance efficiency and to restrict the byte-consumption, thereby avoiding dissipation of memory space.


The captivating feature of this book is its remarkably simplistic approach. Firstly, we get you well acquainted with the PE file format, where we introduce you to the relevant details of the file. Then, we focus our attention on the Metadata header.


Next, we plough our way ahead, scrutinizing every Metadata table meticulously, one at a time. On certain occasions, we have replicated some portions of the code, in order to facilitate ease of understanding. Further, to expound every table, miniature snippets of code have been provided, using either IL or the C# language. An independent chapter has been devoted to the topic of Blob Signatures, since they unravel an altogether unique class of information.

At times, we have undertaken discursive diversions at crucial junctures to explain specific concepts, which may not be directly related to the main topic. This has been done to provide a holistic panorama of the .Net architecture.


Tables have been drawn and screen shots have been provided to reinforce the assumptions and to illustrate the concepts that have been proffered.


Finally, since no cross-connections could be established between these tables while exploring each of them, we chose to dedicate the last chapter to the display of all the linkages and to provide values to the data stored in the table.


Although we are aware that there is scope for extensive enhancement to make this book exhaustive, we chose to wrap it up at this stage. This is because we hope that by the time you reach the end of this book, you would have developed a penchant for Metadata tables and would be in a position to explore the subject further by yourself.


In addition to the samples, Microsoft has also offered a program called Metainfo, which provides a dump of the Metadata. Another program utility that can be used is the disassembler, known as the ILDASM. These two utilities can be used to verify and validate the output of our program.


We take immense pleasure in proclaiming the fact that we are the pioneers in employing the C# language while writing our metadata program. We are convinced that even the tools have not been written in C#. Since our primary focus has been on the task of discerning the tables and their contents, the chores of alignment and the formatting have taken a back seat.


In order to serve up all this information to you, we have scrutinized the Web in its entirety, and have extracted meaningful inputs from it. Further, we have probed the unfathomable depths of the 'uncomplicated' technical documentation provided by Microsoft.



Towards the latter part of this book, we have inspected the intricacies of each and every bit, and have investigated all the formatting issues. Once more, a program written in C# comports itself like the ILDASM utility, providing substantial information about every table and its field attributes.


In conclusion, we reiterate that this is a path-breaking book, which delves into the internals of the .Net architecture, which is a virgin territory. We hope that you enjoy your journey into this exotic domain and put the knowledge gained from this book to good use. We are confident that this book will pave the way to sculpt you into an aficionado of the .Net architecture. We wish you good luck and happy reading!



Minimum Requirements


The software requirements to successfully run all the programs in this book are


Operating System - Windows 2000, Windows XP

Visual Studio.Net or .Net Framework SDK

UltraEdit-32 (can be downloaded from






I wish to thank a number of people who gave me their support, new ideas and inspiration while writing this book.


First and foremost, thanks to Manish Jain, BPB Publications for publishing the book.


Special thanks to my co-authors, Akash and Sonal, who have put in their very best in the work assigned to them as without them and their efforts the book would have never seen the light of day.


Thanks to Tanuja Sodhi, an ex-naval officer from the first batch of lady officers and an MBA from JBIMS for editing the book. She is presently freelancing as a creative writer.


Thanks to my cover designers, Altaf Hemani and Kishore Rohra, for designing the cover.


Thanks to Manish Purohit for putting in all the time he had to verify the code with the explanations and then giving the book a good look and feel.


To Shivanand Shetty, who made it simple for me and my co-authors to come up with the book. He has always been a source of inspiration and encouragement.


A long list of friends need a mention here for their patience and cooperation on this book while it was being written.



-Vijay Mukhi