public MarshalSig GetMarshalSig(uint index) { MarshalSig ms = m_signatures [index] as MarshalSig; if (ms == null) { byte [] data = m_root.Streams.BlobHeap.Read(index); ms = ReadMarshalSig(data); m_signatures [index] = ms; } return(ms); }
void Write(MarshalSig ms) { Write((int)ms.NativeInstrinsic); switch (ms.NativeInstrinsic) { case NativeType.ARRAY: MarshalSig.Array ar = (MarshalSig.Array)ms.Spec; Write((int)ar.ArrayElemType); if (ar.ParamNum != -1) { Write(ar.ParamNum); } if (ar.NumElem != -1) { Write(ar.NumElem); } if (ar.ElemMult != -1) { Write(ar.ElemMult); } break; case NativeType.CUSTOMMARSHALER: MarshalSig.CustomMarshaler cm = (MarshalSig.CustomMarshaler)ms.Spec; Write(cm.Guid); Write(cm.UnmanagedType); Write(cm.ManagedType); Write(cm.Cookie); break; case NativeType.FIXEDARRAY: MarshalSig.FixedArray fa = (MarshalSig.FixedArray)ms.Spec; Write(fa.NumElem); if (fa.ArrayElemType != NativeType.NONE) { Write((int)fa.ArrayElemType); } break; case NativeType.SAFEARRAY: Write((int)((MarshalSig.SafeArray)ms.Spec).ArrayElemType); break; case NativeType.FIXEDSYSSTRING: Write(((MarshalSig.FixedSysString)ms.Spec).Size); break; } }
MarshalSig ReadMarshalSig(byte [] data) { MarshalSig ms = new MarshalSig((NativeType)data[0]); int start = 1; switch (ms.NativeInstrinsic) { case NativeType.ARRAY: MarshalSig.Array ar = new MarshalSig.Array(); ar.ArrayElemType = (NativeType)Utilities.ReadCompressedInteger(data, start, out start); if (start < data.Length) { ar.ParamNum = Utilities.ReadCompressedInteger(data, start, out start); } if (start < data.Length) { ar.NumElem = Utilities.ReadCompressedInteger(data, start, out start); } if (start < data.Length) { ar.ElemMult = Utilities.ReadCompressedInteger(data, start, out start); } ms.Spec = ar; break; case NativeType.CUSTOMMARSHALER: MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler(); cm.Guid = ReadUTF8String(data, start, out start); cm.UnmanagedType = ReadUTF8String(data, start, out start); cm.ManagedType = ReadUTF8String(data, start, out start); cm.Cookie = ReadUTF8String(data, start, out start); ms.Spec = cm; break; case NativeType.FIXEDARRAY: MarshalSig.FixedArray fa = new MarshalSig.FixedArray(); fa.NumElem = Utilities.ReadCompressedInteger(data, start, out start); if (start < data.Length) { fa.ArrayElemType = (NativeType)Utilities.ReadCompressedInteger(data, start, out start); } ms.Spec = fa; break; case NativeType.SAFEARRAY: MarshalSig.SafeArray sa = new MarshalSig.SafeArray(); if (start < data.Length) { sa.ArrayElemType = (VariantType)Utilities.ReadCompressedInteger(data, start, out start); } ms.Spec = sa; break; case NativeType.FIXEDSYSSTRING: MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString(); if (start < data.Length) { fss.Size = Utilities.ReadCompressedInteger(data, start, out start); } ms.Spec = fss; break; } return(ms); }
public uint AddMarshalSig(MarshalSig ms) { m_sigWriter.Empty(); Write(ms); return(GetPointer()); }