コード例 #1
0
        private void ReadTypes(IntPtr midl_type_pickling_info_ptr, IntPtr midl_stub_desc_ptr, bool deref_stub_desc, Func <IMemoryReader, IntPtr, IEnumerable <int> > get_offsets)
        {
            if (midl_type_pickling_info_ptr == IntPtr.Zero)
            {
                throw new ArgumentException("Must specify a MIDL_TYPE_PICKLING_INFO pointer");
            }

            if (midl_stub_desc_ptr == IntPtr.Zero)
            {
                throw new ArgumentException($"Must specify a {(deref_stub_desc ? "MIDL_STUBLESS_PROXY_INFO" : "MIDL_STUB_DESC")} pointer");
            }

            if (deref_stub_desc)
            {
                midl_stub_desc_ptr = _reader.ReadIntPtr(midl_stub_desc_ptr);
            }

            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 get_offsets(_reader, stub_desc.pFormatTypes))
            {
                NdrBaseTypeReference.Read(context, i);
            }
        }
コード例 #2
0
        internal static T[] EnumeratePointerList <T>(this IMemoryReader reader, IntPtr p, Func <IntPtr, T> load_type)
        {
            List <T> ret = new List <T>();

            if (p == IntPtr.Zero)
            {
                return(new T[0]);
            }

            IntPtr curr  = p;
            IntPtr value = IntPtr.Zero;

            while ((value = reader.ReadIntPtr(curr)) != IntPtr.Zero)
            {
                ret.Add(load_type(value));
                curr += reader.PointerSize;
            }
            return(ret.ToArray());
        }
コード例 #3
0
        internal static T[] ReadPointerArray <T>(this IMemoryReader reader, IntPtr p, int count, Func <IntPtr, T> load_type)
        {
            T[] ret = new T[count];
            if (p == IntPtr.Zero)
            {
                return(ret);
            }

            for (int i = 0; i < count; ++i)
            {
                IntPtr curr = reader.ReadIntPtr(p + i * reader.PointerSize);
                if (curr == IntPtr.Zero)
                {
                    ret[i] = default(T);
                }
                else
                {
                    ret[i] = load_type(curr);
                }
            }
            return(ret);
        }
コード例 #4
0
        private static IEnumerable <int> GetPicklingTableOffsets(IMemoryReader reader, IntPtr type_pickling_offset_table, IEnumerable <int> type_index)
        {
            var table = reader.ReadIntPtr(type_pickling_offset_table);

            return(type_index.Select(i => reader.ReadInt32(table + i * 4)));
        }