This is a better patch which shows the source of the problem and implements the correct behaviour of GetDepthStencilSurface. But there is a problem in function IWineD3DDeviceImpl_GetDepthStencilSurface. This couldn't return the value which we need (see test cases). So anyone a suggestion?
Reset sets a flag when it fails. In this state, the device is essentially broken, and all you can do is release objects and attempt to call reset again(or destroy the device altogether). We currently implement a few Reset failure conditions and set a flag if Reset fails. I think this is done in d3d9 only right now, but a flag could be set in wined3d too, or d3d9's GetDepthStencilSurface could check the flag and return a different error value.