The ImplMap table holds information about unmanaged methods that can be reached from managed code, using PInvoke dispatch. Each row of the ImplMap table associates a row in the MethodDef table (MemberForwarded) with the name of a routine (ImportName) in some unmanaged DLL (ImportScope).
[Note: A typical example would be: associate the managed Method stored in row N of the Method table (so MemberForwarded would have the value N) with the routine called "GetEnvironmentVariable
" (the string indexed by ImportName) in the DLL called "kernel32
" (the string in the ModuleRef table indexed by ImportScope). The CLI intercepts calls to managed Method number N, and instead forwards them as calls to the unmanaged routine called "GetEnvironmentVariable
" in "kernel32.dll
" (including marshalling any arguments, as required)
The CLI does not support this mechanism to access fields that are exported from a DLL, only methods. end note]
The ImplMap table has the following columns:
-
MappingFlags (a 2-byte bitmask of type PInvokeAttributes, §23.1.8)
-
MemberForwarded (an index into the Field or MethodDef table; more precisely, a MemberForwarded (§II.24.2.6) coded index). However, it only ever indexes the MethodDef table, since Field export is not supported.
-
ImportName (an index into the String heap)
-
ImportScope (an index into the ModuleRef table)
A row is entered in the ImplMap table for each parent Method (§II.15.5) that is defined with a .pinvokeimpl interoperation attribute specifying the MappingFlags, ImportName, and ImportScope.
This contains informative text only.
-
ImplMap can contain zero or more rows
-
MappingFlags shall have only those values set that are specified [ERROR]
-
MemberForwarded shall index a valid row in the MethodDef table [ERROR]
-
The MappingFlags.
CharSetMask
(§II.23.1.7) in the row of the MethodDef table indexed by MemberForwarded shall have at most one of the following bits set:CharSetAnsi
,CharSetUnicode
, orCharSetAuto
(if none is set, the default isCharSetNotSpec
) [ERROR] -
ImportName shall index a non-empty string in the String heap [ERROR]
-
ImportScope shall index a valid row in the ModuleRef table [ERROR]
-
The row indexed in the MethodDef table by MemberForwarded shall have its Flags.
PinvokeImpl
= 1, and Flags.Static
= 1 [ERROR]
End informative text.