Debugging Tools for Windows

GetFieldOffset

The GetFieldOffset and GetFieldOffsetWide methods return the offset of a field from the base address of an instance of a type.

HRESULT
  IDebugSymbols::GetFieldOffset(
    IN ULONG64  Module,
    IN ULONG  TypeId,
    IN PCSTR  Field,
    OUT PULONG  Offset
    );

HRESULT
  IDebugSymbols3::GetFieldOffsetWide(
    IN ULONG64  Module,
    IN ULONG  TypeId,
    IN PCWSTR  Field,
    OUT PULONG  Offset
    );

#ifdef UNICODE
#define GetFieldOffsetT GetFieldOffsetWide
#else
#define GetFieldOffsetT GetFieldOffset
#endif

Parameters

Module
Specifies the module containing the types of both the container and the field.
TypeId
Specifies the type ID of the type containing the field.
Field
Specifies the name of the field whose offset is requested. Subfields may be specified by using a dot-separated path.
Offset
Receives the offset of the specified field from the base memory location of an instance of the type.

Return Value

S_OK
The method was successful.
E_NOINTERFACE
The field Field could not be found in the type specified by TypeId.

This method may also return error values. See Return Values for more details.

Interface Version

GetFieldOffset is available in all versions of IDebugSymbols. GetFieldOffsetWide is available in IDebugSymbols3 and later versions.

Comments

An example of a dot-separated path for the Field parameter is as follows. Suppose the MyStruct structure contains a field MyField of type MySubStruct, and the MySubStruct structure contains the field MySubField. Then the location of this field relative to the location of MyStruct structure can be found by setting the Field parameter to "MyField.MySubField".

For more information about types, see Types.

Requirements

Headers: Defined in Dbgeng.h. Include Dbgeng.h.

Build machine: CAPEBUILD