MarshalSig ReadMarshalSig(byte [] data)
        {
            int        start;
            MarshalSig ms = new MarshalSig((NativeType)Utilities.ReadCompressedInteger(data, 0, out start));

            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);
        }
예제 #2
0
        public MarshalSig GetMarshalSig(MarshalDesc mSpec)
        {
            MarshalSig ms = new MarshalSig (mSpec.NativeIntrinsic);

            if (mSpec is ArrayMarshalDesc) {
                ArrayMarshalDesc amd = mSpec as ArrayMarshalDesc;
                MarshalSig.Array ar = new MarshalSig.Array ();
                ar.ArrayElemType = amd.ElemType;
                ar.NumElem = amd.NumElem;
                ar.ParamNum = amd.ParamNum;
                ar.ElemMult = amd.ElemMult;
                ms.Spec = ar;
            } else if (mSpec is CustomMarshalerDesc) {
                CustomMarshalerDesc cmd = mSpec as CustomMarshalerDesc;
                MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler ();
                cm.Guid = cmd.Guid.ToString ();
                cm.UnmanagedType = cmd.UnmanagedType;
                cm.ManagedType = cmd.ManagedType;
                cm.Cookie = cmd.Cookie;
                ms.Spec = cm;
            } else if (mSpec is FixedArrayDesc) {
                FixedArrayDesc fad = mSpec as FixedArrayDesc;
                MarshalSig.FixedArray fa = new MarshalSig.FixedArray ();
                fa.ArrayElemType  = fad.ElemType;
                fa.NumElem = fad.NumElem;
                ms.Spec = fa;
            } else if (mSpec is FixedSysStringDesc) {
                MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString ();
                fss.Size = (mSpec as FixedSysStringDesc).Size;
                ms.Spec = fss;
            } else if (mSpec is SafeArrayDesc) {
                MarshalSig.SafeArray sa = new MarshalSig.SafeArray ();
                sa.ArrayElemType = (mSpec as SafeArrayDesc).ElemType;
                ms.Spec = sa;
            }

            return ms;
        }
예제 #3
0
 MarshalSig ReadMarshalSig(byte [] data)
 {
     int start;
     MarshalSig ms = new MarshalSig ((NativeType) Utilities.ReadCompressedInteger (data, 0, out start));
     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;
 }