CLR and the Windows Loader in Visual Studio .NET

Creation QR Code JIS X 0510 in Visual Studio .NET CLR and the Windows Loader
CLR and the Windows Loader
QR Code ISO/IEC18004 Encoder In .NET
Using Barcode printer for VS .NET Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications.
Applications that are written natively for Windows can be launched via a number of different mechanisms Windows handles all the work associated with setting up the process address space, loading the executable, and directing the processor to start executing When the processor starts executing the native instructions, it continues to do so on its own until the process exits As discussed earlier in the chapter, a NET application does not contain native instructions Rather, an intermediate language must be translated to native instructions before the processor can execute them Even in light of this difference, a NET application can still be launched in the exact same way as a native application How is this possible Does the Windows loader have specific knowledge of NET applications and automatically bootstrap the CLR The answer lies in a file format that has been around since the early days and is understood by Windows: the Portable Executable (PE) file format Figure 2-3 illustrates, at a high level, the general structure of a PE image file To support execution of PE images, the PE header includes a field called AddressOfEntryPoint This field indicates the location of the entry point for the PE file In the case of a NET assembly, it points to a small piece of stub code located
Decode QR Code In .NET Framework
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in VS .NET applications.
CLR and the Windows Loader
Bar Code Printer In Visual Studio .NET
Using Barcode drawer for .NET framework Control to generate, create barcode image in VS .NET applications.
PE File Format
Barcode Reader In .NET Framework
Using Barcode reader for VS .NET Control to read, scan read, scan image in VS .NET applications.
NET Related Content
QR Code Generator In C#.NET
Using Barcode creator for Visual Studio .NET Control to generate, create QR image in .NET framework applications.
MS-DOS Header PE Header Data Directories Section Headers text Section idata Section PE Sections data Section Other Sections COFF related data Assembly Metadata/MSIL and Unmanaged startup stub Reference to image entry point
Create QR In VS .NET
Using Barcode creation for ASP.NET Control to generate, create Quick Response Code image in ASP.NET applications.
Directory entry 15: COR_CLR_20_Header
Painting QR Code ISO/IEC18004 In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create QR Code JIS X 0510 image in .NET framework applications.
2 CLR FUNDAMENTALS
Encoding European Article Number 13 In .NET
Using Barcode creator for VS .NET Control to generate, create EAN / UCC - 13 image in VS .NET applications.
Figure 2-3 High-level overview of the PE file format
Data Matrix ECC200 Maker In .NET Framework
Using Barcode printer for .NET framework Control to generate, create DataMatrix image in Visual Studio .NET applications.
in the text section The next field of importance is in the data directories When any given NET compiler produces an assembly, it adds a data directory entry to the PE file More specifically, the data directory entry is at index 15 and contains the location and size of the CLR header The CLR header is then located in the next part of interest in the PE file, namely the text section The CLR header consists of a structure named the IMAGE_COR20_HEADER This structure contains information such as the managed code application entry point, the major and minor version of the target CLR, and the strong name signature of the assembly You can view this data structure as containing information needed to know which CLR to load and the most basic data about the assembly itself Other parts of the text section include the assembly metadata tables, the MSIL, and the unmanaged startup stub The unmanaged startup stub simply contains the code that will be executed by the Windows loader to bootstrap the execution of the PE file In the next few sections, we will take a look at how the Windows loader loads both native images as well as NET assemblies
UPC-A Supplement 2 Creator In .NET Framework
Using Barcode creator for VS .NET Control to generate, create UPC-A image in .NET applications.
2
Barcode Creation In .NET Framework
Using Barcode maker for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.
CLR Fundamentals
Planet Generator In Visual Studio .NET
Using Barcode creation for .NET framework Control to generate, create Planet image in .NET framework applications.
Loading Native Images
Draw EAN 13 In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create EAN-13 Supplement 5 image in ASP.NET applications.
To better understand the loading of NET assemblies, we ll start by looking at how the Windows loader loads native PE images Let s use good old notepadexe as the example executable (running on Windows Vista Enterprise) Please note that when dealing with PE files there are two important terms used:
Generate Data Matrix ECC200 In Java
Using Barcode creation for Java Control to generate, create DataMatrix image in Java applications.
File offset: This is the offset within the PE file of any given location Relative Virtual Address (RVA): This value is applicable only when the PE image has been loaded and is the relative address within the virtual address space of the process For example, an RVA of 0x200 means 0x200 bytes from the image base address once loaded into memory
Bar Code Generator In Visual C#
Using Barcode maker for VS .NET Control to generate, create bar code image in VS .NET applications.
Using your favorite hex editor, go to file offset 0x108 where you will find the AddressOfEntryPoint field (remember that this field gives control of execution to this code) with the RVA 0x31F8 Next, load an instance of notepadexe under the debugger and unassemble the code that is located at <base image address>+0x31F8 as illustrated in Listing 2-1 Listing 2-1 Finding the start address of notepadexe
Print Barcode In VB.NET
Using Barcode creator for .NET Control to generate, create bar code image in .NET framework applications.
Microsoft (R) Windows Debugger Version 6800040 X86 Copyright (c) Microsoft Corporation All rights reserved CommandLine: notepadexe Symbol search path is: *** Invalid *** **************************************************************************** * Symbol loading may be unreliable without a symbol search path * * Use symfix to have the debugger choose a symbol path * * After setting your symbol path, use reload to refresh symbol locations * **************************************************************************** Executable search path is: ModLoad: 000b0000 000d8000 notepadexe ModLoad: 773c0000 774de000 ntdlldll ModLoad: 77180000 77258000 C:\Windows\system32\kernel32dll ModLoad: 770c0000 7717f000 C:\Windows\system32\ADVAPI32dll ModLoad: 76cc0000 76d83000 C:\Windows\system32\RPCRT4dll ModLoad: 75f20000 75f6b000 C:\Windows\system32\GDI32dll ModLoad: 77560000 775fe000 C:\Windows\system32\USER32dll ModLoad: 75c80000 75d2a000 C:\Windows\system32\msvcrtdll ModLoad: 75dc0000 75e34000 C:\Windows\system32\COMDLG32dll ModLoad: 77500000 77555000 C:\Windows\system32\SHLWAPIdll
Encoding GTIN - 12 In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create GTIN - 12 image in ASP.NET applications.
Data Matrix 2d Barcode Creation In VB.NET
Using Barcode maker for Visual Studio .NET Control to generate, create Data Matrix image in VS .NET applications.
Draw Bar Code In Java
Using Barcode encoder for Java Control to generate, create bar code image in Java applications.