Module: wine Branch: refs/heads/master Commit: 698a8a0b86348149f60e7352bbe6857048712ae0 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=698a8a0b86348149f60e7352...
Author: Detlef Riekenberg wine.dev@web.de Date: Fri Jun 16 10:01:31 2006 +0200
winspool: AddMonitor: Test the driver entry before return an error.
---
dlls/winspool.drv/info.c | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index 9d6e1c0..05df47a 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -1480,10 +1480,23 @@ BOOL WINAPI AddMonitorW(LPWSTR pName, DW return FALSE; }
- if(RegCreateKeyExW(hroot, mi2w->pName, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_WRITE, NULL, &hentry, &disposition) == ERROR_SUCCESS) { - - if (disposition == REG_OPENED_EXISTING_KEY) { + if(RegCreateKeyExW( hroot, mi2w->pName, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE | KEY_QUERY_VALUE, NULL, &hentry, + &disposition) == ERROR_SUCCESS) { + + /* Some installers set options for the port before calling AddMonitor. + We query the "Driver" entry to verify that the monitor is installed, + before we return an error. + When a user installs two print monitors at the same time with the + same name but with a different driver DLL and a task switch comes + between RegQueryValueExW and RegSetValueExW, a race condition + is possible but silently ignored. */ + + DWORD namesize = 0; + + if ((disposition == REG_OPENED_EXISTING_KEY) && + (RegQueryValueExW(hentry, DriverW, NULL, NULL, NULL, + &namesize) == ERROR_SUCCESS)) { TRACE("monitor %s already exists\n", debugstr_w(mi2w->pName)); /* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006) 9x: ERROR_ALREADY_EXISTS (183) */