Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 2.64 KB

ii.23.2.3-standalonemethodsig.md

File metadata and controls

31 lines (20 loc) · 2.64 KB

II.23.2.3 StandAloneMethodSig

A StandAloneMethodSig is indexed by the StandAloneSig.Signature column. It is typically created as preparation for executing a calli instruction. It is similar to a MethodRefSig, in that it represents a call site signature, but its calling convention can specify an unmanaged target (the calli instruction invokes either managed, or unmanaged code). Its syntax diagram is:

This diagram uses the following abbreviations (§II.15.3):

  • HASTHIS for 0x20
  • EXPLICITTHIS for 0x40
  • DEFAULT for 0x0
  • VARARG for 0x5
  • C for 0x1
  • STDCALL for 0x2
  • THISCALL for 0x3
  • FASTCALL for 0x4
  • SENTINEL for 0x41 (§II.23.1.16 and §II.15.3)

The first byte of the Signature holds bits for HASTHIS, EXPLICITTHIS and calling convention – DEFAULT, VARARG, C, STDCALL, THISCALL, or FASTCALL. These are OR'd together.

ParamCount is an unsigned integer that holds the number of non-vararg and vararg parameters, combined. It can be any number between 0 and 0x1FFFFFFF. The compiler compresses it (see §15) – before storing into the blob (ParamCount counts just the method parameters – it does not include the method's return type)

The RetType item describes the type of the method's return value (§II.23.2.11)

The first Param item describes the type of each of the method's non-vararg parameters. The (optional) second Param item describes the type of each of the method's vararg parameters. There shall be ParamCount instances of ParamII.23.2.10).

This is the most complex of the various method signatures. Two separate diagrams have been combined into one in this diagram, using shading to distinguish between them. Thus, for the following calling conventions: DEFAULT (managed), STDCALL, THISCALL and FASTCALL (unmanaged), the signature ends just before the SENTINEL item (these are all non vararg signatures). However, for the managed and unmanaged vararg calling conventions:

VARARG (managed) and C (unmanaged), the signature can include the SENTINEL and final Param items (they are not required, however). These options are indicated by the shading of boxes in the syntax diagram.

In the unusual case that a call site supplies no extra arguments, the signature shall not include a SENTINEL (this is the route shown by the lower arrow that bypasses SENTINEL and goes to the end of the StandAloneMethodSig definition).