Skip to main content

Module NATIVE_TYPE

Module NATIVE_TYPE 

Expand description

Native type constants as defined in ECMA-335 II.23.2.9 and CoreCLR extensions.

This module contains byte constants representing all native types used in .NET marshalling descriptors. The constants are organized according to the ECMA-335 specification with additional types from CoreCLR runtime and Windows Runtime (WinRT) support.

§Constant Categories

  • Primitive Types (0x01-0x0c): Basic numeric and boolean types
  • String Types (0x13-0x16, 0x30): Various string encodings and formats
  • COM Types (0x0e-0x12, 0x19-0x1a, 0x2e): COM and OLE automation types
  • Array Types (0x1d-0x1e, 0x2a): Fixed and variable arrays
  • Pointer Types (0x10, 0x2b): Raw and structured pointers
  • Special Types (0x17-0x2d): Structured types, interfaces, and custom marshaling
  • WinRT Types (0x2e-0x30): Windows Runtime specific types

§Usage in Marshalling Descriptors

These constants appear as the first byte(s) in marshalling descriptors, followed by optional parameter data depending on the specific native type requirements.

§Examples

use dotscope::metadata::marshalling::NATIVE_TYPE;

// Simple types have no additional parameters
let simple_descriptor = &[NATIVE_TYPE::I4];

// Complex types may have parameters
let string_descriptor = &[NATIVE_TYPE::LPSTR, 0x05]; // LPSTR with size param 5
let array_descriptor = &[NATIVE_TYPE::ARRAY, NATIVE_TYPE::I4, 0x03]; // Array of I4

Constants§

ANSIBSTR
ANSI BSTR (0x23) - ANSI version of BSTR
ARRAY
Array type (0x2a) - Variable array with element type and optional parameters
ASANY
AsAny type (0x28) - Marshal as any compatible type
BOOLEAN
Boolean type (0x02) - 1-byte boolean value
BSTR
BSTR type (0x13) - OLE automation string (length-prefixed wide string)
BYVALSTR
By-value string (0x22) - Fixed-length string embedded in structure
CURRENCY
Currency type (0x0f) - OLE automation currency (8-byte scaled integer)
CUSTOMMARSHALER
Custom marshaler (0x2c) - User-defined custom marshaling
DATE
Date type (0x12) - OLE automation date (8-byte floating point)
DECIMAL
Decimal type (0x11) - .NET decimal (16-byte scaled integer)
END
End marker (0x00) - Indicates the end of a marshalling descriptor
ERROR
Error type (0x2d) - HRESULT or error code
FIXEDARRAY
Fixed array (0x1e) - Fixed-size array with element count
FIXEDSYSSTRING
Fixed system string (0x17) - Fixed-length character array
FUNC
Function pointer (0x26) - Native function pointer
HSTRING
HSTRING type (0x2f) - Windows Runtime string handle
I1
Signed 8-bit integer (0x03) - sbyte in C#
I2
Signed 16-bit integer (0x05) - short in C#
I4
Signed 32-bit integer (0x07) - int in C#
I8
Signed 64-bit integer (0x09) - long in C#
IDISPATCH
IDispatch interface (0x1a) - COM IDispatch interface pointer
IINSPECTABLE
IInspectable interface (0x2e) - Windows Runtime IInspectable interface
INT
Platform integer (0x1f) - Platform-dependent signed integer (32/64-bit)
INTERFACE
Interface type (0x1c) - COM interface with optional IID parameter
IUNKNOWN
IUnknown interface (0x19) - COM IUnknown interface pointer
LPSTR
LPSTR type (0x14) - Null-terminated ANSI string pointer
LPSTRUCT
Pointer to struct (0x2b) - Pointer to native structure
LPTSTR
LPTSTR type (0x16) - Null-terminated platform string pointer (ANSI/Unicode)
LPUTF8STR
UTF-8 string pointer (0x30) - Null-terminated UTF-8 string pointer
LPWSTR
LPWSTR type (0x15) - Null-terminated Unicode string pointer
MAX
Maximum valid native type (0x50) - Upper bound for validation
NESTEDSTRUCT
Nested struct (0x21) - Nested structure (value type)
OBJECTREF
Object reference (0x18) - Managed object reference
PTR
Pointer type (0x10) - Raw pointer, may have optional target type
R4
32-bit floating point (0x0b) - float in C#
R8
64-bit floating point (0x0c) - double in C#
SAFEARRAY
Safe array (0x1d) - COM safe array with variant type information
STRUCT
Struct type (0x1b) - Native structure with optional packing/size info
SYSCHAR
System character type (0x0d) - Platform-dependent character
TBSTR
TBSTR type (0x24) - Platform-dependent BSTR (ANSI/Unicode)
U1
Unsigned 8-bit integer (0x04) - byte in C#
U2
Unsigned 16-bit integer (0x06) - ushort in C#
U4
Unsigned 32-bit integer (0x08) - uint in C#
U8
Unsigned 64-bit integer (0x0a) - ulong in C#
UINT
Platform unsigned integer (0x20) - Platform-dependent unsigned integer (32/64-bit)
VARIANT
COM VARIANT type (0x0e) - OLE automation variant
VARIANTBOOL
Variant boolean (0x25) - COM VARIANT_BOOL (2-byte boolean)
VOID
Void type (0x01) - Represents no type or void return