The CreateCryptoSession function creates a crypto session that the Direct3D runtime uses to manage a session key and to perform crypto operations into and out of protected memory.


PFND3DDDI_CREATECRYPTOSESSION Pfnd3dddiCreatecryptosession;

HRESULT Pfnd3dddiCreatecryptosession(
  HANDLE hDevice,



A handle to the display device (graphics context).


pData [in, out]

A pointer to a D3DDDIARG_CREATECRYPTOSESSION structure. On input, this structure contains information that the driver can use. On output, the driver specifies information in the structure that the Microsoft Direct3D runtime can use.

Return Value

CreateCryptoSession returns one of the following values:

Return code Description
S_OK The crypto session is successfully created.
E_OUTOFMEMORY CreateCryptoSession could not allocate the required memory for it to complete.
D3DDDIERR_NOTAVAILABLE The driver does not support the GUID that is specified in the CryptoTypemember of the D3DDDIARG_CREATECRYPTOSESSION structure or the NULL_GUID (all zeros) is specified in the CryptoTypemember.
D3DDDIERR_UNSUPPORTEDCRYPTO The driver does not support the crypto type for the specified decode type.


If the DecodeProfile member of the D3DDDIARG_CREATECRYPTOSESSION structure is NULL_GUID, the crypto session will not be used for DirectX Video Acceleration (DirectX VA) decoding. If DecodeProfile is not NULL GUID, the driver should fail with D3DDDIERR_UNSUPPORTEDCRYPTO if the crypto type in the CryptoType member is not supported by the decode profile.

The driver returns a handle for the crypto session in the hCryptoSession member of D3DDDIARG_CREATECRYPTOSESSION that the runtime passes in all subsequent crypto session calls (for example, CryptoSessionKeyExchange).

The driver must keep track of the display device (hDevice) that was used to create the crypto session. The driver should fail all subsequent calls that use this created crypto session if the display device that is specified in those calls is different from the display device that was used to create the crypto session.


Minimum supported client Supported starting with Windows 7.
Target Platform Desktop
Header d3dumddi.h (include D3dumddi.h)

See Also