Microsoft KB Archive/330248

= PRB: Calling the EngModifySurface Function or the EngAssociateSurface Function in DrvEnableSurface Causes Stop Error =

Article ID: 330248

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows 2000 Standard Edition
 * Microsoft Windows XP Professional

-



This article was previously published under Q330248



SYMPTOMS
When hardware acceleration is turned off completely, the user may experience a kernel-mode Stop error message, which is also known as a bugcheck. The bugcheck code and parameters may vary. The bugcheck appears on the display driver when doing operations such as the following:
 * Changing the display resolution when certain applications are running, particularly D3D applications.
 * Opening a command prompt window, making it full-screen, and then restoring it to its original size.
 * Going into a low power mode.
 * Switching to a different user.



CAUSE
The display driver is called through the DrvCopyBits function for a destination surface object (SURFOBJ) that references the driver's physical device (PDEV or DHPDEV), which this driver did not create. This results in an undefined behavior and, most likely, a bugcheck.



RESOLUTION
To work around this issue, the display driver must follow this simple rule:

After a call to DrvEnableSurface completes successfully, never call EngModifySurface or EngAssociateSurface on the surface that is returned by DrvEnableSurface.



MORE INFORMATION
It is acceptable for a display driver to call EngModifySurface or EngAssociateSurface as frequently as necessary inside its call to DrvEnableSurface. However, after the driver returns the primary surface to Graphics Device Interface (GDI), it must not call EngModifySurface or EngAssociateSurface on the primary surface again. The display driver may, however, call EngModifySurface or EngAssociateSurface for other surfaces. // // Primary Surface creation //

HSURF DrvEnableSurface (   DHPDEV dhpdev   ); {  HSURF hSurfScreen;

hSurfScreen = EngCreateDeviceSurface(...);

EngModifySurface(hSurfScreen, ...);       // OK to call

EngAssociateSurface(hSurfScreen, ...);    // OK to call

return hSurfScreen; }

After the call to DrvEnableSurface succeeds and returns the hSurfScreen, the driver cannot call EngModifySurface or EngAssociateSurface for that surface handle. Doing this sometimes causes a bugcheck.

