2 using System.Runtime.InteropServices;
3 using System.Runtime.CompilerServices;
6 internal static class RuntimeMarshal {
7 internal static string PtrToUtf8String (IntPtr ptr)
10 return new String ((sbyte*)ptr);
14 internal static SafeStringMarshal MarshalString (string str)
16 return new SafeStringMarshal (str);
19 static int DecodeBlobSize (IntPtr in_ptr, out IntPtr out_ptr)
23 byte *ptr = (byte*)in_ptr;
25 if ((*ptr & 0x80) == 0) {
26 size = (uint)(ptr [0] & 0x7f);
28 } else if ((*ptr & 0x40) == 0){
29 size = (uint)(((ptr [0] & 0x3f) << 8) + ptr [1]);
32 size = (uint)(((ptr [0] & 0x1f) << 24) +
38 out_ptr = (IntPtr)ptr;
44 internal static byte[] DecodeBlobArray (IntPtr ptr)
47 int size = DecodeBlobSize (ptr, out out_ptr);
48 byte[] res = new byte [size];
49 Marshal.Copy (out_ptr, res, 0, size);
53 internal static int AsciHexDigitValue (int c)
55 if (c >= '0' && c <= '9')
57 if (c >= 'a' && c <= 'f')
62 [MethodImpl (MethodImplOptions.InternalCall)]
63 internal static extern void FreeAssemblyName (ref MonoAssemblyName name);