Protecting Files with DRM Version 1

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

When this kind of protection is applied, a DRM version 1 license is generated that is valid only on the machine from which the license request was made. Because no key or key seed is set, there is no way to generate portable licenses for content protected using this technique. However, when using the Windows Media Format SDK 7.1 or later, the licenses are recoverable at the Microsoft License Migration service.

To protect ASF files using DRM version 1, perform the following steps:

  1. Link the WMStubDRM.lib file to your project and, if necessary, unlink wmvcore.lib.

  2. Call the WMCreateWriter function to create the writer. The first argument is reserved and must be set to NULL.

  3. Set a profile for the writer to use by calling IWMWriter::SetProfile or IWMWriter::SetProfileByID. You must set a profile in the writer before setting any DRM attributes. DRM is supported only for profiles that use the Windows Media Audio or Windows Media Video codecs.

  4. Using the IWMHeaderInfo::SetAttribute method, set the following DRM properties. The Use_DRM property instructs the DRM components to protect the content using DRM version 1. The DRM_Flags property specifies the rights to be included in the local license that will be created for the content. The DRM_LEVEL value is also stored in the license; it specifies the minimum level required to access the content. 150 is the recommended level for DRM version 1 content.

    Attribute Value
    Use_DRM TRUE
    DRM_Flags WMT_RIGHT_PLAYBACK | WMT_RIGHT_COPY_TO_NON_SDMI_DEVICE | WMT_RIGHT_COPY_TO_CD
    DRM_LEVEL 150

     

The following example code shows how to create a DRM-enabled writer for DRM version 1 and set the DRM properties. Error checking has been omitted for the sake of clarify.

BOOL  fUseDRM    = TRUE;
// These are the rights we will apply to the file. See WMT_RIGHTS for
// the full set of possible rights.

DWORD dwDRMFlags = WMT_RIGHT_PLAYBACK | 
                   WMT_RIGHT_COPY_TO_NON_SDMI_DEVICE | 
                   WMT_RIGHT_COPY_TO_CD;

// Set the minimum required DRM level low enough
// to allow older players to access the content.
DWORD dwDRMLevel = 150;

IWMDRMWriter*  pWMDRMWriter  = NULL;
HRESULT hr = S_OK;

// Initialize COM.
hr = CoInitialize(NULL);

// Create a writer object.
hr = WMCreateWriter( NULL, &pWMDRMWriter);

// Obtain the IWMHeaderInfo interface.
hr = pWMDRMWriter -> QueryInterface(IID_IWMHeaderInfo, 
                                   (void**) &pWMHeaderInfo);

// Tell the SDK runtime to protect the file using DRM version 1.
hr= pWMHeaderInfo-> SetAttribute(0,
                                 g_wszWMUse_DRM,
                                 WMT_TYPE_BOOL,
                                 (BYTE*)&fUseDRM,
                                 sizeof(BOOL));

// Specify the rights that will be stored in the local license that is
// created automatically for the content.
hr= pWMHeaderInfo->SetAttribute( 0,
                                 g_wszWMDRM_Flags, 
                                 WMT_TYPE_DWORD,
                                 (BYTE *)&dwDRMFlags,
                                 sizeof(DWORD) );

// Set the DRM_Level attribute in the file's DRM header.
hr= pWMHeaderInfo->SetAttribute( 0,
                                 g_wszWMDRM_Level, 
                                 WMT_TYPE_DWORD,
                                 (BYTE *)&dwDRMLevel,
                                 sizeof(DWORD) );