COPPKeyExchange function
The sample COPPKeyExchange function retrieves the digital certificate used by the graphics hardware.
Syntax
HRESULT COPPKeyExchange(
_In_ COPP_DeviceData pThis,
_Out_ GUID *pRandom,
_Out_ BYTE *pGHCertificate
);
Parameters
pThis [in]
- Pointer to the COPP DirectX VA device object.
pRandom [out]
- Pointer to a variable that receives a 128-bit random number.
pGHCertificate [out]
- Pointer to a list of bytes that receives the graphics hardware certificate.
Return value
Returns zero (S_OK or DD_OK) if successful; otherwise, returns an error code.
Remarks
A COPP DirectX VA device should provide the size of the graphics hardware certificate to the VMR before receiving a call to its COPPKeyExchange function. That is, the COPPGetCertificateLength function should be called before COPPKeyExchange. If COPPKeyExchange is called before COPPGetCertificateLength, COPPKeyExchange should return E_UNEXPECTED.
Mapping RenderMoComp to COPPKeyExchange
The sample COPPKeyExchange function maps directly to a call to the RenderMoComp member of the DD_MOTIONCOMPCALLBACKS structure. The RenderMoComp member points to the display driver-supplied DdMoCompRender callback function that references the DD_RENDERMOCOMPDATA structure.
The RenderMoComp callback function is called without the display driver-supplied BeginMoCompFrame or EndMoCompFrame function being called first.
The DD_RENDERMOCOMPDATA structure is filled as follows.
Member | Value |
---|---|
dwNumBuffers | Number of buffers at lpBufferInfo. The value is 1. |
lpBufferInfo | Pointer to a single RGB32 system memory surface that contains the space required to hold the hardware certificate. The required length of the surface was returned in the call to COPPGetCertificateLength. Note that a system memory surface is used to return the certificate because the size of the certificate can exceed the size of the maximum buffer passed via the lpOutputData parameter. |
dwFunction | DXVA_COPPKeyExchangeFnCode constant (defined in dxva.h). |
lpInputData | NULL. |
lpOutputData | Pointer to a 128-bit random number generated by the driver. |
Example Code
The following code provides an example of how you can implement your COPPKeyExchange function:
DWORD
COPP_Generate128BitRandomNumber()
{
GUID RandNum;
DWORD* pdw = (DWORD*)&RandNum;
pdw[0] = rand();
pdw[1] = rand();
pdw[2] = rand();
pdw[3] = rand();
return RandNum;
}
HRESULT
COPPKeyExchange(
COPP_DeviceData* pThis,
GUID* pRandNumber,
BYTE* pGHCertificate
)
{
if (pThis->m_COPPDevState != COPP_CERT_LENGTH_RETURNED) {
return E_UNEXPECTED;
}
memcpy(pGHCertificate, (LPVOID)&TestCert, sizeof(TestCert));
pThis->m_rGraphicsDriver = *pRandNumber = COPP_Generate128BitRandomNumber();
pThis->m_COPPDevState = COPP_KEY_EXCHANGED;
return NO_ERROR;
}
Requirements
Target platform | Version |
---|---|
Desktop | This function applies only to Windows Server 2003 with SP1 and later, and Windows XP with SP2 and later. |