File: Data\ComCallWrapper.cs
Web Access
Project: src\src\runtime\src\native\managed\cdac\Microsoft.Diagnostics.DataContractReader.Contracts\Microsoft.Diagnostics.DataContractReader.Contracts.csproj (Microsoft.Diagnostics.DataContractReader.Contracts)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.


namespace Microsoft.Diagnostics.DataContractReader.Data;

internal sealed class ComCallWrapper : IData<ComCallWrapper>
{
    static ComCallWrapper IData<ComCallWrapper>.Create(Target target, TargetPointer address) => new ComCallWrapper(target, address);
    public ComCallWrapper(Target target, TargetPointer address)
    {
        Target.TypeInfo type = target.GetTypeInfo(DataType.ComCallWrapper);

        Handle = target.ReadPointerField(address, type, nameof(Handle));
        SimpleWrapper = target.ReadPointerField(address, type, nameof(SimpleWrapper));
        Next = target.ReadPointerField(address, type, nameof(Next));

        IPtr = address + (ulong)type.Fields[nameof(IPtr)].Offset;
        int numInterfaces = (int)target.ReadGlobal<uint>(Constants.Globals.CCWNumInterfaces);
        IPtrs = new TargetPointer[numInterfaces];
        for (int i = 0; i < numInterfaces; i++)
        {
            IPtrs[i] = target.ReadPointer(IPtr + (ulong)(i * target.PointerSize));
        }
    }

    public TargetPointer Handle { get; init; }
    public TargetPointer SimpleWrapper { get; init; }
    public TargetPointer IPtr { get; init; }
    public TargetPointer[] IPtrs { get; }
    public TargetPointer Next { get; init; }
}