IDebugHostType::GetBitField 方法 (dbgmodel.h)

如果数据结构的给定成员是位域(例如:ULONG MyBits:8),则字段的类型信息附带有关位域放置的信息。 GetBitField 方法可用于检索该信息。 此方法在不是位域的任何类型上都将失败。 这是该方法将失败的唯一原因。 只需调用此方法并查看成功/失败即可将位字段与非位字段区分开来。

如果给定类型确实是位字段,则字段位置由半打开集(lsbOfField + lengthOfField : lsbOfField] 定义)

语法

HRESULT GetBitField(
  ULONG *lsbOfField,
  ULONG *lengthOfField
);

参数

lsbOfField

指示字段的最小有效位(其中 0 定义为包含类型的最小有效位)。 根据 lengthOfField 参数指定的长度,将位字段定义为利用从此点到包含类型最有效位的位。

lengthOfField

字段中的位数。 这至少是包含类型的一个位数,并且不超过位数。 根据此处返回的位数,位字段从 lsbOfField 参数中指定的位向上占用到包含值的最有效位。

返回值

此方法返回指示成功或失败的 HRESULT。

言论

示例代码

ComPtr<IDebugHostType> spType; /* get the type of a field which is a bitmap */

ULONG lsb;
ULONG length;
if (SUCCEEDED(spType->GetBitField(&lsb, &length)))
{
    // spType refers to a bitfield.  The field is [lsb, lsb + length) in 
    // bit positions.  Were you to read memory at the location/size specified 
    // by an object of this type, you would need to mask off bits at and 
    // above 'lsb + length' and shift right by 'lsb'
    //
    // Note that IModelObject::GetRawObject will automatically do this for you. 
    // So will creating an object with this type spType via CreateTypedObject.
}

要求

要求 价值
标头 dbgmodel.h

另请参阅

IDebugHostType 接口