BUG: Exception in Windows Media Player When You Use Source Plug-In with WMCreateStreamForURL (320630)



The information in this article applies to:

  • Microsoft Windows Media Format SDK 7.0

This article was previously published under Q320630

SYMPTOMS

A Windows Media source plug-in is a DLL file that developers can use to provide their own storage system for Windows Media files. A source plug-in makes this possible through the implementation of a COM interface that is called an IStream. An IStream is a standard interface for providing data, and is passed to the Windows Media Format SDK from the WMCreateStreamForURL function call. When you use the Windows Media Format SDK in any program that uses the Windows Media Format SDK (such as Microsoft Windows Media Player) to play streams that are accessed through your source plug-in, you may experience the following symptoms:
  • The playback may stop.
  • You may receive the following error message:
    Unhandled exception in wmplayer.exe (wmvcore.dll):0xc0000005: access violation.

CAUSE

This problem occurs because the Windows Media Format SDK issues one too many FreeLibrary calls and prematurely un-loads the DLL file that implements the source plug-in. Because the DLL is unloaded, a later call to the IStream::Read method that is implemented by your DLL causes an access violation error message to occur.

RESOLUTION

To work around this problem, add the following code to the WMCreateStreamForURL function. The LoadLibrary call will increment the reference count on the source plug-in DLL and prevent the Windows Media Format SDK from prematurely freeing the DLL.
HMODULE hModLib;
HRESULT WINAPI WMCreateStreamForURL( 
                /* [in] */  LPCWSTR pwszURL,
                /* [out] */ BOOL *pfCorrectSource,
                /* [out] */ IStream **ppStream )
{
    // if pwszURL is something my source plug-in can handle...
    *pfCorrectSource = TRUE;
    hModLib =  LoadLibrary("source.dll");
    //source.dll is the DLL that implements the source plug-in
    //Rest of the implementation 
    //...
    //...
    //...
}
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Modification Type:MajorLast Reviewed:2/11/2004
Keywords:kbDSWMM2003Swept kbbug kbenv kberrmsg kbnofix KB320630