IDebugBreakpointChecksumRequest2::GetChecksum
사용할 체크섬 알고리즘의 고유 식별자가 지정된 경우 중단점 요청에 대한 문서 체크섬을 검색합니다.
구문
매개 변수
guidAlgorithm
[in] 체크섬 알고리즘의 고유 식별자입니다.
pChecksumData
[out] 중단점 요청에 대한 문서 체크섬입니다.
Return Value
성공하면 S_OK
를 반환하고, 실패하면 오류 코드를 반환합니다.
예시
다음 예제에서는 바인딩하려고 하는 문서의 체크섬이 UI의 체크섬과 일치하는지 여부를 확인하는 함수를 보여 줍니다.
bool CDebugProgram::DoChecksumsMatch(CDebugPendingBreakpoint *pPending, CDebugCodeContext *pContext)
{
bool fRet = false;
HRESULT hRes;
// Get the checksum for the document we are about to bind to from the pdb side
GUID guidAlgorithmId;
BYTE *pChecksum = NULL;
ULONG cNumBytes = 0;
hRes = pContext->GetDocumentChecksumAndAlgorithmId(&guidAlgorithmId, &pChecksum, &cNumBytes);
if ( S_OK == hRes )
{
// Get checksum data for the document from the UI (request) side
CComPtr<IDebugBreakpointChecksumRequest2> pChecksumRequest;
hRes = pPending->GetChecksumRequest(&pChecksumRequest);
if ( S_OK == hRes )
{
CHECKSUM_DATA data;
hRes = pChecksumRequest->GetChecksum(guidAlgorithmId, &data);
if ( S_OK == hRes )
{
if ( data.ByteCount == cNumBytes && memcmp(data.pBytes, pChecksum, cNumBytes) == 0 )
fRet = true;
else
fRet = false;
// Free up data allocated for checksum data
CoTaskMemFree(data.pBytes);
}
else
fRet = true; // checksums not available - user disabed checksums
}
else
fRet = true; // we couldn't get checksum from UI - default to past behavior
// free up space allocated for checksum from pdb
CoTaskMemFree(pChecksum);
}
else
fRet = true; // we don't have a checksum to compare with.
return ( fRet );
}