Share via


ICorProfilerInfo2::GetClassLayout Method

Gets information about the layout, in memory, of the fields defined by the specified class. That is, this method gets the offsets of the class's fields.

HRESULT GetClassLayout(
    [in]  ClassID classID,
    [in, out] COR_FIELD_OFFSET rFieldOffset[],
    [in]  ULONG cFieldOffset,
    [out] ULONG *pcFieldOffset,
    [out] ULONG *pulClassSize);

Parameters

  • classID
    [in] The ID of the class for which the layout will be retrieved.

  • rFieldOffset
    [in, out] An array of COR_FIELD_OFFSET structures, each of which contains the tokens and offsets of the class's fields.

  • cFieldOffset
    [in] The size of the rFieldOffset array.

  • pcFieldOffset
    [out] A pointer to the total number of available elements. If cFieldOffset is 0, this value indicates the number of elements needed.

  • pulClassSize
    [out] A pointer to a location that contains the size, in bytes, of the class.

Remarks

The GetClassLayout method returns only the fields defined by the class itself. If the class's parent class has defined fields as well, the profiler must call GetClassLayout on the parent class to obtain those fields.

If you use GetClassLayout with string classes, the method will fail with error code E_INVALIDARG. Use ICorProfilerInfo2::GetStringLayout to get information about the layout of a string. GetClassLayout will also fail when called with an array class.

After GetClassLayout returns, you must verify that the rFieldOffset buffer was large enough to contain all the available COR_FIELD_OFFSET structures. To do this, compare the value that pcFieldOffset points to with the size of rFieldOffset divided by the size of a COR_FIELD_OFFSET structure. If rFieldOffset is not large enough, allocate a larger rFieldOffset buffer, update cFieldOffset with the new, larger size, and call GetClassLayout again.

Alternatively, you can first call GetClassLayout with a zero-length rFieldOffset buffer to obtain the correct buffer size. You can then set the buffer size to the value returned in pcFieldOffset and call GetClassLayout again.

For more information about these two approaches, see Profiling API Method Conventions.

Requirements

Platforms: See .NET Framework System Requirements.

Header: CorProf.idl, CorProf.h

Library: CorGuids.lib

.NET Framework Versions: 4, 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0

See Also

Reference

ICorProfilerInfo Interface

ICorProfilerInfo2 Interface

Other Resources

Profiling Interfaces

Profiling (Unmanaged API Reference)