예제 #1
0
        public void WriteMarshalInfo(MarshalInfo marshal_info)
        {
            this.WriteNativeType(marshal_info.native);
            NativeType native = marshal_info.native;

            if (native == NativeType.FixedSysString)
            {
                FixedSysStringMarshalInfo info4 = (FixedSysStringMarshalInfo)marshal_info;
                if (info4.size > -1)
                {
                    base.WriteCompressedUInt32((uint)info4.size);
                }
            }
            else
            {
                switch (native)
                {
                case NativeType.SafeArray:
                {
                    SafeArrayMarshalInfo info2 = (SafeArrayMarshalInfo)marshal_info;
                    if (info2.element_type != VariantType.None)
                    {
                        this.WriteVariantType(info2.element_type);
                    }
                    return;
                }

                case NativeType.FixedArray:
                {
                    FixedArrayMarshalInfo info3 = (FixedArrayMarshalInfo)marshal_info;
                    if (info3.size > -1)
                    {
                        base.WriteCompressedUInt32((uint)info3.size);
                    }
                    if (info3.element_type != NativeType.None)
                    {
                        this.WriteNativeType(info3.element_type);
                    }
                    return;
                }
                }
                switch (native)
                {
                case NativeType.Array:
                {
                    ArrayMarshalInfo info = (ArrayMarshalInfo)marshal_info;
                    if (info.element_type != NativeType.None)
                    {
                        this.WriteNativeType(info.element_type);
                    }
                    if (info.size_parameter_index > -1)
                    {
                        base.WriteCompressedUInt32((uint)info.size_parameter_index);
                    }
                    if (info.size > -1)
                    {
                        base.WriteCompressedUInt32((uint)info.size);
                    }
                    if (info.size_parameter_multiplier > -1)
                    {
                        base.WriteCompressedUInt32((uint)info.size_parameter_multiplier);
                    }
                    return;
                }

                case NativeType.LPStruct:
                    break;

                case NativeType.CustomMarshaler:
                {
                    CustomMarshalInfo info5 = (CustomMarshalInfo)marshal_info;
                    this.WriteUTF8String((info5.guid != Guid.Empty) ? info5.guid.ToString() : string.Empty);
                    this.WriteUTF8String(info5.unmanaged_type);
                    this.WriteTypeReference(info5.managed_type);
                    this.WriteUTF8String(info5.cookie);
                    break;
                }

                default:
                    return;
                }
            }
        }
예제 #2
0
        public void WriteMarshalInfo(MarshalInfo marshal_info)
        {
            this.WriteNativeType(marshal_info.native);
            NativeType marshalInfo = marshal_info.native;

            if (marshalInfo <= NativeType.SafeArray)
            {
                if (marshalInfo == NativeType.FixedSysString)
                {
                    FixedSysStringMarshalInfo fixedSysStringMarshalInfo = (FixedSysStringMarshalInfo)marshal_info;
                    if (fixedSysStringMarshalInfo.size > -1)
                    {
                        base.WriteCompressedUInt32((uint)fixedSysStringMarshalInfo.size);
                    }
                    return;
                }
                if (marshalInfo != NativeType.SafeArray)
                {
                    return;
                }
                SafeArrayMarshalInfo safeArrayMarshalInfo = (SafeArrayMarshalInfo)marshal_info;
                if (safeArrayMarshalInfo.element_type != VariantType.None)
                {
                    this.WriteVariantType(safeArrayMarshalInfo.element_type);
                }
                return;
            }
            if (marshalInfo == NativeType.FixedArray)
            {
                FixedArrayMarshalInfo fixedArrayMarshalInfo = (FixedArrayMarshalInfo)marshal_info;
                if (fixedArrayMarshalInfo.size > -1)
                {
                    base.WriteCompressedUInt32((uint)fixedArrayMarshalInfo.size);
                }
                if (fixedArrayMarshalInfo.element_type != NativeType.None)
                {
                    this.WriteNativeType(fixedArrayMarshalInfo.element_type);
                }
                return;
            }
            if (marshalInfo != NativeType.Array)
            {
                if (marshalInfo != NativeType.CustomMarshaler)
                {
                    return;
                }
                CustomMarshalInfo customMarshalInfo = (CustomMarshalInfo)marshal_info;
                this.WriteUTF8String((customMarshalInfo.guid != Guid.Empty ? customMarshalInfo.guid.ToString() : string.Empty));
                this.WriteUTF8String(customMarshalInfo.unmanaged_type);
                this.WriteTypeReference(customMarshalInfo.managed_type);
                this.WriteUTF8String(customMarshalInfo.cookie);
                return;
            }
            ArrayMarshalInfo arrayMarshalInfo = (ArrayMarshalInfo)marshal_info;

            if (arrayMarshalInfo.element_type != NativeType.None)
            {
                this.WriteNativeType(arrayMarshalInfo.element_type);
            }
            if (arrayMarshalInfo.size_parameter_index > -1)
            {
                base.WriteCompressedUInt32((uint)arrayMarshalInfo.size_parameter_index);
            }
            if (arrayMarshalInfo.size > -1)
            {
                base.WriteCompressedUInt32((uint)arrayMarshalInfo.size);
            }
            if (arrayMarshalInfo.size_parameter_multiplier > -1)
            {
                base.WriteCompressedUInt32((uint)arrayMarshalInfo.size_parameter_multiplier);
            }
        }
예제 #3
0
        public MarshalInfo ReadMarshalInfo()
        {
            NativeType nativeType = this.ReadNativeType();

            if (nativeType > NativeType.SafeArray)
            {
                if (nativeType == NativeType.FixedArray)
                {
                    FixedArrayMarshalInfo fixedArrayMarshalInfo = new FixedArrayMarshalInfo();
                    if (this.CanReadMore())
                    {
                        fixedArrayMarshalInfo.size = (int)base.ReadCompressedUInt32();
                    }
                    if (this.CanReadMore())
                    {
                        fixedArrayMarshalInfo.element_type = this.ReadNativeType();
                    }
                    return(fixedArrayMarshalInfo);
                }
                if (nativeType == NativeType.Array)
                {
                    ArrayMarshalInfo arrayMarshalInfo = new ArrayMarshalInfo();
                    if (this.CanReadMore())
                    {
                        arrayMarshalInfo.element_type = this.ReadNativeType();
                    }
                    if (this.CanReadMore())
                    {
                        arrayMarshalInfo.size_parameter_index = (int)base.ReadCompressedUInt32();
                    }
                    if (this.CanReadMore())
                    {
                        arrayMarshalInfo.size = (int)base.ReadCompressedUInt32();
                    }
                    if (this.CanReadMore())
                    {
                        arrayMarshalInfo.size_parameter_multiplier = (int)base.ReadCompressedUInt32();
                    }
                    return(arrayMarshalInfo);
                }
                if (nativeType == NativeType.CustomMarshaler)
                {
                    CustomMarshalInfo customMarshalInfo = new CustomMarshalInfo();
                    string            str = this.ReadUTF8String();
                    customMarshalInfo.guid           = (!string.IsNullOrEmpty(str) ? new Guid(str) : Guid.Empty);
                    customMarshalInfo.unmanaged_type = this.ReadUTF8String();
                    customMarshalInfo.managed_type   = this.ReadTypeReference();
                    customMarshalInfo.cookie         = this.ReadUTF8String();
                    return(customMarshalInfo);
                }
            }
            else
            {
                if (nativeType == NativeType.FixedSysString)
                {
                    FixedSysStringMarshalInfo fixedSysStringMarshalInfo = new FixedSysStringMarshalInfo();
                    if (this.CanReadMore())
                    {
                        fixedSysStringMarshalInfo.size = (int)base.ReadCompressedUInt32();
                    }
                    return(fixedSysStringMarshalInfo);
                }
                if (nativeType == NativeType.SafeArray)
                {
                    SafeArrayMarshalInfo safeArrayMarshalInfo = new SafeArrayMarshalInfo();
                    if (this.CanReadMore())
                    {
                        safeArrayMarshalInfo.element_type = this.ReadVariantType();
                    }
                    return(safeArrayMarshalInfo);
                }
            }
            return(new MarshalInfo(nativeType));
        }
예제 #4
0
        public MarshalInfo ReadMarshalInfo()
        {
            NativeType nativeType = ReadNativeType();

            switch (nativeType)
            {
            case NativeType.Array:
            {
                ArrayMarshalInfo arrayMarshalInfo = new ArrayMarshalInfo();
                if (CanReadMore())
                {
                    arrayMarshalInfo.element_type = ReadNativeType();
                }
                if (CanReadMore())
                {
                    arrayMarshalInfo.size_parameter_index = (int)base.ReadCompressedUInt32();
                }
                if (CanReadMore())
                {
                    arrayMarshalInfo.size = (int)base.ReadCompressedUInt32();
                }
                if (CanReadMore())
                {
                    arrayMarshalInfo.size_parameter_multiplier = (int)base.ReadCompressedUInt32();
                }
                return(arrayMarshalInfo);
            }

            case NativeType.SafeArray:
            {
                SafeArrayMarshalInfo safeArrayMarshalInfo = new SafeArrayMarshalInfo();
                if (CanReadMore())
                {
                    safeArrayMarshalInfo.element_type = ReadVariantType();
                }
                return(safeArrayMarshalInfo);
            }

            case NativeType.FixedArray:
            {
                FixedArrayMarshalInfo fixedArrayMarshalInfo = new FixedArrayMarshalInfo();
                if (CanReadMore())
                {
                    fixedArrayMarshalInfo.size = (int)base.ReadCompressedUInt32();
                }
                if (CanReadMore())
                {
                    fixedArrayMarshalInfo.element_type = ReadNativeType();
                }
                return(fixedArrayMarshalInfo);
            }

            case NativeType.FixedSysString:
            {
                FixedSysStringMarshalInfo fixedSysStringMarshalInfo = new FixedSysStringMarshalInfo();
                if (CanReadMore())
                {
                    fixedSysStringMarshalInfo.size = (int)base.ReadCompressedUInt32();
                }
                return(fixedSysStringMarshalInfo);
            }

            case NativeType.CustomMarshaler:
            {
                CustomMarshalInfo customMarshalInfo = new CustomMarshalInfo();
                string            text = ReadUTF8String();
                customMarshalInfo.guid           = ((!string.IsNullOrEmpty(text)) ? new Guid(text) : Guid.Empty);
                customMarshalInfo.unmanaged_type = ReadUTF8String();
                customMarshalInfo.managed_type   = ReadTypeReference();
                customMarshalInfo.cookie         = ReadUTF8String();
                return(customMarshalInfo);
            }

            default:
                return(new MarshalInfo(nativeType));
            }
        }
예제 #5
0
        public MarshalInfo ReadMarshalInfo()
        {
            NativeType native = this.ReadNativeType();
            NativeType type2  = native;

            if (type2 == NativeType.FixedSysString)
            {
                FixedSysStringMarshalInfo info4 = new FixedSysStringMarshalInfo();
                if (this.CanReadMore())
                {
                    info4.size = (int)base.ReadCompressedUInt32();
                }
                return(info4);
            }
            switch (type2)
            {
            case NativeType.SafeArray:
            {
                SafeArrayMarshalInfo info2 = new SafeArrayMarshalInfo();
                if (this.CanReadMore())
                {
                    info2.element_type = this.ReadVariantType();
                }
                return(info2);
            }

            case NativeType.FixedArray:
            {
                FixedArrayMarshalInfo info3 = new FixedArrayMarshalInfo();
                if (this.CanReadMore())
                {
                    info3.size = (int)base.ReadCompressedUInt32();
                }
                if (this.CanReadMore())
                {
                    info3.element_type = this.ReadNativeType();
                }
                return(info3);
            }
            }
            switch (type2)
            {
            case NativeType.Array:
            {
                ArrayMarshalInfo info = new ArrayMarshalInfo();
                if (this.CanReadMore())
                {
                    info.element_type = this.ReadNativeType();
                }
                if (this.CanReadMore())
                {
                    info.size_parameter_index = (int)base.ReadCompressedUInt32();
                }
                if (this.CanReadMore())
                {
                    info.size = (int)base.ReadCompressedUInt32();
                }
                if (this.CanReadMore())
                {
                    info.size_parameter_multiplier = (int)base.ReadCompressedUInt32();
                }
                return(info);
            }

            case NativeType.CustomMarshaler:
            {
                CustomMarshalInfo info5 = new CustomMarshalInfo();
                string            str   = this.ReadUTF8String();
                info5.guid           = !string.IsNullOrEmpty(str) ? new Guid(str) : Guid.Empty;
                info5.unmanaged_type = this.ReadUTF8String();
                info5.managed_type   = this.ReadTypeReference();
                info5.cookie         = this.ReadUTF8String();
                return(info5);
            }
            }
            return(new MarshalInfo(native));
        }
예제 #6
0
        public void WriteMarshalInfo(MarshalInfo marshal_info)
        {
            WriteNativeType(marshal_info.native);
            switch (marshal_info.native)
            {
            case NativeType.Array:
            {
                ArrayMarshalInfo arrayMarshalInfo = (ArrayMarshalInfo)marshal_info;
                if (arrayMarshalInfo.element_type != NativeType.None)
                {
                    WriteNativeType(arrayMarshalInfo.element_type);
                }
                if (arrayMarshalInfo.size_parameter_index > -1)
                {
                    base.WriteCompressedUInt32((uint)arrayMarshalInfo.size_parameter_index);
                }
                if (arrayMarshalInfo.size > -1)
                {
                    base.WriteCompressedUInt32((uint)arrayMarshalInfo.size);
                }
                if (arrayMarshalInfo.size_parameter_multiplier > -1)
                {
                    base.WriteCompressedUInt32((uint)arrayMarshalInfo.size_parameter_multiplier);
                }
                break;
            }

            case NativeType.SafeArray:
            {
                SafeArrayMarshalInfo safeArrayMarshalInfo = (SafeArrayMarshalInfo)marshal_info;
                if (safeArrayMarshalInfo.element_type != 0)
                {
                    WriteVariantType(safeArrayMarshalInfo.element_type);
                }
                break;
            }

            case NativeType.FixedArray:
            {
                FixedArrayMarshalInfo fixedArrayMarshalInfo = (FixedArrayMarshalInfo)marshal_info;
                if (fixedArrayMarshalInfo.size > -1)
                {
                    base.WriteCompressedUInt32((uint)fixedArrayMarshalInfo.size);
                }
                if (fixedArrayMarshalInfo.element_type != NativeType.None)
                {
                    WriteNativeType(fixedArrayMarshalInfo.element_type);
                }
                break;
            }

            case NativeType.FixedSysString:
            {
                FixedSysStringMarshalInfo fixedSysStringMarshalInfo = (FixedSysStringMarshalInfo)marshal_info;
                if (fixedSysStringMarshalInfo.size > -1)
                {
                    base.WriteCompressedUInt32((uint)fixedSysStringMarshalInfo.size);
                }
                break;
            }

            case NativeType.CustomMarshaler:
            {
                CustomMarshalInfo customMarshalInfo = (CustomMarshalInfo)marshal_info;
                WriteUTF8String((customMarshalInfo.guid != Guid.Empty) ? customMarshalInfo.guid.ToString() : string.Empty);
                WriteUTF8String(customMarshalInfo.unmanaged_type);
                WriteTypeReference(customMarshalInfo.managed_type);
                WriteUTF8String(customMarshalInfo.cookie);
                break;
            }
            }
        }