Do not hold the GDI lock while 16-bit ExtDeviceMode is called.

diff --git a/dlls/gdi/driver.c b/dlls/gdi/driver.c
index 43c9b9b..a0fd1a8 100644
--- a/dlls/gdi/driver.c
+++ b/dlls/gdi/driver.c
@@ -378,6 +378,7 @@
     HDC hdc;
     DC *dc;
     INT ret = -1;
+    INT (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
 
     TRACE("(%04x, %p, %s, %s, %p, %s, %ld)\n",
           hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
@@ -388,10 +389,11 @@
 
     if ((dc = DC_GetDCPtr( hdc )))
     {
-        if (dc->funcs->pExtDeviceMode)
-            ret = dc->funcs->pExtDeviceMode(buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
+	pExtDeviceMode = dc->funcs->pExtDeviceMode;
+	GDI_ReleaseObj( hdc );
+	if (pExtDeviceMode)
+	    ret = pExtDeviceMode(buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
                                             lpdmInput, lpszProfile, fwMode);
-        GDI_ReleaseObj( hdc );
     }
     DeleteDC( hdc );
     return ret;