private void ReadTypes(IntPtr midl_type_pickling_info_ptr, IntPtr midl_stub_desc_ptr, IEnumerable <int> fmt_offsets) { if (midl_type_pickling_info_ptr == IntPtr.Zero) { throw new ArgumentException("Must specify the MIDL_TYPE_PICKLING_INFO pointer"); } if (midl_stub_desc_ptr == IntPtr.Zero) { throw new ArgumentException("Must specify the MIDL_STUB_DESC pointer"); } var pickle_info = _reader.ReadStruct <MIDL_TYPE_PICKLING_INFO>(midl_type_pickling_info_ptr); if (pickle_info.Version != 0x33205054) { throw new ArgumentException($"Unsupported picking type version {pickle_info.Version:X}"); } var flags = pickle_info.Flags.HasFlag(MidlTypePicklingInfoFlags.NewCorrDesc) ? NdrInterpreterOptFlags2.HasNewCorrDesc : 0; MIDL_STUB_DESC stub_desc = _reader.ReadStruct <MIDL_STUB_DESC>(midl_stub_desc_ptr); NdrParseContext context = new NdrParseContext(_type_cache, null, stub_desc, stub_desc.pFormatTypes, stub_desc.GetExprDesc(_reader), flags, _reader, NdrParserFlags.IgnoreUserMarshal); foreach (var i in fmt_offsets) { NdrBaseTypeReference.Read(context, i); } }
internal NdrProcedureParameter(NdrParseContext context, BinaryReader reader) { Attributes = (NdrParamAttributes)reader.ReadUInt16(); Offset = reader.ReadUInt16(); if ((Attributes & NdrParamAttributes.IsBasetype) == 0) { int type_ofs = reader.ReadUInt16(); Type = NdrBaseTypeReference.Read(context, type_ofs); } else { Type = new NdrBaseTypeReference((NdrFormatCharacter)reader.ReadByte()); // Remove padding. reader.ReadByte(); } }
internal NdrProcedureParameter(NdrParseContext context, BinaryReader reader) { ushort attr = reader.ReadUInt16(); Attributes = (NdrParamAttributes)(attr & ~ServerAllocSizeMask); ServerAllocSize = (attr & ServerAllocSizeMask) >> 10; Offset = reader.ReadUInt16(); if ((Attributes & NdrParamAttributes.IsBasetype) == 0) { int type_ofs = reader.ReadUInt16(); Type = NdrBaseTypeReference.Read(context, type_ofs); } else { Type = new NdrBaseTypeReference((NdrFormatCharacter)reader.ReadByte()); // Remove padding. reader.ReadByte(); } }
private void ReadTypes(IntPtr midl_type_pickling_info_ptr, IntPtr fmt_str_ptr, IEnumerable <int> fmt_offsets) { var pickle_info = _reader.ReadStruct <MIDL_TYPE_PICKLING_INFO>(midl_type_pickling_info_ptr); if (pickle_info.Version != 0x33205054) { throw new ArgumentException($"Unsupported picking type version {pickle_info.Version:X}"); } int desc_size = 4; if ((pickle_info.Flags & MidlTypePicklingInfoFlags.NewCorrDesc) != 0) { desc_size = 6; // TODO: Might need to support extended correlation descriptors. } NdrParseContext context = new NdrParseContext(_type_cache, null, new MIDL_STUB_DESC(), fmt_str_ptr, desc_size, _reader, NdrParserFlags.IgnoreUserMarshal); foreach (var i in fmt_offsets) { NdrBaseTypeReference.Read(context, i); } }
internal static NdrBaseTypeReference ReadArmType(NdrParseContext context, BinaryReader reader) { ushort type = reader.ReadUInt16(); if ((type & 0x8F00) == 0x8000) { return(new NdrSimpleTypeReference((NdrFormatCharacter)(type & 0xFF))); } else if (type == 0) { return(new NdrSimpleTypeReference(NdrFormatCharacter.FC_ZERO)); } else if (type == 0xFFFF) { return(null); } else { reader.BaseStream.Position = reader.BaseStream.Position - 2; return(NdrBaseTypeReference.Read(context, NdrBaseTypeReference.ReadTypeOffset(reader))); } }
internal NdrPointerInfoInstance(NdrParseContext context, BinaryReader reader) { OffsetInMemory = reader.ReadInt16(); OffsetInBuffer = reader.ReadInt16(); PointerType = NdrBaseTypeReference.Read(context, reader) as NdrPointerTypeReference; }