擷取代表指定行位移之函式內的位址。
語法
int GetFunctionLineOffset(
IDebugAddress pAddress,
uint dwLine,
out IDebugAddress ppNewAddress
);
參數
pAddress
[in]代表函式的位址。
dwLine
[in]函數開頭的線條位移。
ppNewAddress
[out]新位址,表示函式開頭的行位移。
傳回值
如果成功,則會傳回 S_OK;否則,會傳回錯誤碼。
範例
下列範例示範如何針對公開 IDebugComPlusSymbolProvider 介面的 CDebugSymbolProvider 物件實作這個方法。
HRESULT CDebugSymbolProvider::GetFunctionLineOffset(
IDebugAddress *pAddress,
DWORD dwLine,
IDebugAddress **ppNewAddress
)
{
HRESULT hr = S_OK;
CDEBUG_ADDRESS address;
CComPtr<CModule> pModule;
DWORD dwOffset;
CDebugAddress* paddr = NULL;
METHOD_ENTRY(CDebugSymbolProvider::GetFunctionLineOffset);
IfFalseGo( pAddress, S_FALSE );
IfFailGo( pAddress->GetAddress( &address ) );
ASSERT(address.addr.dwKind == ADDRESS_KIND_METADATA_METHOD);
IfFalseGo( address.addr.dwKind == ADDRESS_KIND_METADATA_METHOD, S_FALSE );
IfFailGo( GetModule( address.GetModule(), &pModule) );
// Find the first offset for dwLine in the function
IfFailGo( pModule->GetFunctionLineOffset( address.addr.addr.addrMethod.tokMethod,
address.addr.addr.addrMethod.dwVersion,
dwLine,
&dwOffset ) );
// Create the new Address
address.addr.addr.addrMethod.dwOffset = dwOffset;
IfNullGo( paddr = new CDebugAddress(address), E_OUTOFMEMORY );
IfFailGo( paddr->QueryInterface( __uuidof(IDebugAddress),
(void**) ppNewAddress ) );
Error:
METHOD_EXIT(CDebugSymbolProvider::GetFunctionLineOffset, hr);
RELEASE( paddr );
return hr;
}