MANAGED AND UNMANAGED CODE INTEROPERATION in Visual Basic .NET

Maker PDF 417 in Visual Basic .NET MANAGED AND UNMANAGED CODE INTEROPERATION

CHAPTER 18 MANAGED AND UNMANAGED CODE INTEROPERATION
PDF-417 2d Barcode Drawer In Visual Basic .NET
Using Barcode generator for .NET framework Control to generate, create PDF 417 image in .NET framework applications.
www.OnBarcode.com
PDF 417 Decoder In Visual Basic .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
For example: ... .vtfixup [1] int32 fromunmanaged at VT_01 ... .vtfixup [1] int32 at VT_02 ... .data VT_01 = int32(0x0600001A) .data VT_02 = int32(0x0600001B) ... The actual data representing the method tokens is automatically generated by the IL assembler and placed in designated v-table slots. To achieve that, it is necessary to indicate which method is represented by which v-table slot. ILAsm provides the .vtentry directive for this purpose: .vtentry <entry_number> : <slot_number> where <entry_number> and <slot_number> are 1-based integer constants. The .vtentry directive is placed within the respective method s scope, as shown in the following code: ... .vtfixup [1] int32 fromunmanaged at VT_01 ... .method public static void Foo() { .vtentry 1:1 // Entry 1, slot 1 ... } ... .data VT_01 = int32(0) // The slot will be filled automatically. ...
USS Code 39 Generator In Visual Basic .NET
Using Barcode generation for Visual Studio .NET Control to generate, create Code 39 image in VS .NET applications.
www.OnBarcode.com
PDF-417 2d Barcode Creation In VB.NET
Using Barcode printer for Visual Studio .NET Control to generate, create PDF 417 image in .NET applications.
www.OnBarcode.com
Export Table Group
Paint Data Matrix In VB.NET
Using Barcode drawer for VS .NET Control to generate, create Data Matrix ECC200 image in .NET framework applications.
www.OnBarcode.com
USS Code 128 Creator In VB.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Code 128B image in Visual Studio .NET applications.
www.OnBarcode.com
The export table group (in managed and unmanaged modules) consists of five tables: The Export Address table (EAT), containing the RVA of the exported unmanaged functions. The Export Name table (ENT), containing the names of the exported functions. The Name Pointer table (NPT) and the Ordinal table (OT), together forming a lookup table that rearranges the exported functions in lexical order of their names. In special cases when an unmanaged module exports its methods exclusively by ordinal, ENT, NPT, and OT may be missing. Managed modules always export their methods by name. The Export Directory table, containing the location and size information about the other four tables.
Barcode Creator In Visual Basic .NET
Using Barcode drawer for Visual Studio .NET Control to generate, create Barcode image in VS .NET applications.
www.OnBarcode.com
4-State Customer Barcode Generation In Visual Basic .NET
Using Barcode generation for VS .NET Control to generate, create OneCode image in .NET applications.
www.OnBarcode.com
CHAPTER 18 MANAGED AND UNMANAGED CODE INTEROPERATION
Create PDF417 In None
Using Barcode printer for Online Control to generate, create PDF417 image in Online applications.
www.OnBarcode.com
Encoding PDF-417 2d Barcode In Java
Using Barcode generation for BIRT reports Control to generate, create PDF-417 2d barcode image in Eclipse BIRT applications.
www.OnBarcode.com
Location and size information concerning the Export Directory table itself resides in the first of 16 data directories in the PE header. Figure 18-2 shows the structure of the export table group.
Printing USS Code 128 In None
Using Barcode encoder for Microsoft Excel Control to generate, create Code 128B image in Excel applications.
www.OnBarcode.com
Making Code-128 In None
Using Barcode generator for Online Control to generate, create Code 128C image in Online applications.
www.OnBarcode.com
PE Header
Encode DataMatrix In Objective-C
Using Barcode creator for iPhone Control to generate, create Data Matrix image in iPhone applications.
www.OnBarcode.com
Barcode Reader In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Export Data Directory
Code 128A Encoder In None
Using Barcode printer for Font Control to generate, create Code 128 Code Set A image in Font applications.
www.OnBarcode.com
UCC - 12 Reader In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Export Directory Table
Barcode Generator In C#.NET
Using Barcode drawer for VS .NET Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
Making Barcode In None
Using Barcode generation for Office Excel Control to generate, create Barcode image in Office Excel applications.
www.OnBarcode.com
EAT 0:Addr.of Yabba() 1:Addr.of Dabba() 2:Addr.of Doo()
Decode PDF-417 2d Barcode In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Generating Barcode In Objective-C
Using Barcode creator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
OT 1 2 0
NPT Yabba Dabba Doo
Figure 18-2. The structure of the export table group In an unmanaged PE file, the EAT contains the RVA of the exported unmanaged methods. In a managed PE file, the picture is more complicated. The EAT cannot contain the RVA of the managed methods because it s not the managed methods that are exported rather, it s their marshaling thunks, generated at run time. The only way to address a yet-to-be-created thunk is to define a slot in a v-table entry for the exported managed method and a VTableFixup descriptor for this entry, carrying the fromunmanaged flag. In this case, the contents of the v-table slot (a token of the exported method) are replaced at run time with the address of the marshaling thunk. (If the fromunmanaged flag is not specified, the thunk is not created, and the method token is replaced with this method s address; but this is outside the scenario being discussed.) For each exported method, the IL assembler creates a tiny native stub yes, you ve caught me: the IL assembler does produce embedded native code after all consisting of the
CHAPTER 18 MANAGED AND UNMANAGED CODE INTEROPERATION
x86 command jump indirect (0x25FF) followed by the RVA of the v-table slot allocated for the exported method. The native stubs produced by version 2.0 of the IL assembler for X64 or Itanium targets look, of course, different but are functionally similar: they execute an indirect jump. The EAT contains the RVA of these tiny stubs. The generation of the jump stubs renders the module strictly platform specific, but we ve already made our module platform specific when we chose the width of the v-table slots (4 or 8 bytes). The tiny stubs are necessary because the EAT must contain solid addresses of the exported methods as soon as the operating system loads the PE file. Otherwise, the unmanaged client won t be able to match the entries of its Import Address table (IAT) to the entries of the managed module s EAT. The addresses of the methods or their thunks don t exist at the moment the file is loaded. But the tiny stubs exist and have solid addresses. It s true that at that moment they cannot perform any meaningful jumps, because the v-table slots they are referencing contain method tokens instead of addresses. But by the time the stubs are called, the methods and thunks will have been generated and the v-table slots will be fixed up, with the method tokens replaced with thunk addresses. Figure 18-3 illustrates this scenario.
EAT 0:Addr.of Yabba() 1:Addr.of Dabba() 2:Addr.of Doo() Jump Stubs 0x25FF 0x25FF 0x25FF V-Table 0x06000001 0x06000002 0x06000003
VT Fixup Table void Yabba() (0x06000001) int32 from unmanaged int32 from unmanaged void Dabba() (0x06000002) int32 from unmanaged
void Doo() (0x06000003)
Copyright © OnBarcode.com . All rights reserved.