From: Detlef Riekenberg Subject: [PATCH 2/2] localspl: Support loading modern Print Monitors (InitializePrintMonitor2) Message-Id: <1480957925-18297-2-git-send-email-wine.dev@web.de> Date: Mon, 5 Dec 2016 18:12:05 +0100 In-Reply-To: <1480957925-18297-1-git-send-email-wine.dev@web.de> References: <1480957925-18297-1-git-send-email-wine.dev@web.de> This is a step for bug 3864 InitializePrintMonitor2 is required since XP -- bye bye ... Detlef Signed-off-by: Detlef Riekenberg --- dlls/localspl/provider.c | 173 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 166 insertions(+), 7 deletions(-) diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c index f359b73..add4fc8 100644 --- a/dlls/localspl/provider.c +++ b/dlls/localspl/provider.c @@ -1,7 +1,7 @@ /* * Implementation of the Local Printprovider * - * Copyright 2006-2009 Detlef Riekenberg + * Copyright 2006-2009, 2015-2016 Detlef Riekenberg * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -66,6 +66,9 @@ typedef struct { LPWSTR dllname; PMONITORUI monitorUI; LPMONITOR monitor; + LPMONITOR2 monitor2; + MONITORINIT monitorinit; + HANDLE hmonitor; HMODULE hdll; DWORD refcount; DWORD dwMonitorSize; @@ -310,6 +313,135 @@ static LPCWSTR get_basename_from_name(LPCWSTR name) return name; } + +/****************************************************************** + * fpCreateKey for MONITORREG [internal] + * + */ +static LONG WINAPI fpCreateKey(HANDLE rootkey, LPCWSTR name, DWORD options, REGSAM access, + PSECURITY_ATTRIBUTES sa, PHANDLE resultkey, PDWORD disposition, HANDLE spooler) +{ + + TRACE("%p_CreateKey(%p, %s, ...)\n", spooler, rootkey, debugstr_w(name)); + return RegCreateKeyExW(rootkey, name, 0, NULL, options, access, sa, (PHKEY)resultkey, disposition); + +} + +/****************************************************************** + * fpOpenKey for MONITORREG [internal] + * + */ +static LONG WINAPI fpOpenKey(HANDLE rootkey, LPCWSTR name, REGSAM access, PHANDLE resultkey, HANDLE spooler) +{ + TRACE("%p_OpenKey(%p, %s, ...)\n", spooler, rootkey, debugstr_w(name)); + return RegOpenKeyExW(rootkey, name, 0, access, (PHKEY)resultkey); +} + +/****************************************************************** + * fpCloseKey for MONITORREG [internal] + * + */ +static LONG WINAPI fpCloseKey(HANDLE key, HANDLE spooler) +{ + TRACE("%p_CLoseKey(%p)\n", spooler, key); + return RegCloseKey(key); +} + +/****************************************************************** + * fpDeleteKey for MONITORREG [internal] + * + */ +static LONG WINAPI fpDeleteKey(HANDLE key, LPCWSTR name, HANDLE spooler) +{ + TRACE("%p_DeleteKey(%p, %s)\n", spooler, key, debugstr_w(name)); + return RegDeleteKeyW(key, name); +} + +/****************************************************************** + * fpEnumKey for MONITORREG [internal] + * + */ +static LONG WINAPI fpEnumKey(HANDLE key, DWORD index, LPWSTR res_name, PDWORD len, PFILETIME plastwritetime, HANDLE spooler) +{ + TRACE("%p_EnumKey(%p, %d, ...)\n", spooler, key, index); + return RegEnumKeyExW(key, index, res_name, len, 0, NULL, NULL, plastwritetime); +} + +/****************************************************************** + * fpQueryInfoKey for MONITORREG [internal] + * + */ +static LONG WINAPI fpQueryInfoKey(HANDLE key, PDWORD pcSubKeys, PDWORD pcbKey, + PDWORD pcValues, PDWORD pcbValue, PDWORD pcbData, + PDWORD pcbSecurityDescriptor, PFILETIME plastwritetime, HANDLE spooler) +{ + TRACE("%p_QueryInfoKey(%p, ...)\n", spooler, key); + return RegQueryInfoKeyW(key, NULL, NULL, 0, pcSubKeys, pcbKey, NULL, + pcValues, pcbValue, pcbData, pcbSecurityDescriptor, plastwritetime); +} + +/****************************************************************** + * fpSetValue for MONITORREG [internal] + * + */ +static LONG WINAPI fpSetValue(HANDLE key, LPCWSTR name, DWORD type, const BYTE* data, DWORD len, HANDLE spooler) +{ + TRACE("%p_SetValue(%p, %s, %d, %p, %d)\n", spooler, key, debugstr_w(name), type, data, len); + return RegSetValueExW(key, name, 0, type, data, len); +} + +/****************************************************************** + * fpDeleteValue for MONITORREG [internal] + * + */ +static LONG WINAPI fpDeleteValue(HANDLE key, LPCWSTR name, HANDLE spooler) +{ + TRACE("%p_DeleteValue(%p, %s)\n", spooler, key, debugstr_w(name)); + return RegDeleteValueW(key, name); +} + +/****************************************************************** + * fpEnumValue for MONITORREG [internal] + * + */ +static LONG WINAPI fpEnumValue(HANDLE key, DWORD index, LPWSTR res_value, PDWORD pcbValue, PDWORD pType, PBYTE data, PDWORD pcbData, HANDLE spooler) +{ + TRACE("%p_EnumValue(%p, %d, ...)\n", spooler, key, index); + return RegEnumValueW(key, index, res_value, pcbValue, NULL, pType, data, pcbData); +} + +/****************************************************************** + * fpQueryValue for MONITORREG [internal] + * + */ +static LONG WINAPI fpQueryValue(HANDLE key, LPCWSTR res_value, PDWORD type, PBYTE data, PDWORD len, HANDLE spooler) +{ + TRACE("%p_QueryValue(%p, ...)\n", spooler, key); + return RegQueryValueExW(key, res_value, 0, type, data, len); +} + +/***************************************************** + * setup_monitorreg [internal] + */ +MONITORREG * setup_monitorreg(void) +{ + static MONITORREG monitorreg = { + sizeof(MONITORREG), + fpCreateKey, + fpOpenKey, + fpCloseKey, + fpDeleteKey, + fpEnumKey, + fpQueryInfoKey, + fpSetValue, + fpDeleteValue, + fpEnumValue, + fpQueryValue + }; + + return &monitorreg; +} + /****************************************************************** * monitor_unload [internal] * @@ -326,6 +458,11 @@ static void monitor_unload(monitor_t * pm) if (pm->refcount) pm->refcount--; if (pm->refcount == 0) { + if (pm->monitor2 && pm->monitor2->pfnShutdown) { + TRACE("call pfnShutDown(%p)\n", pm->hmonitor); + pm->monitor2->pfnShutdown(pm->hmonitor); + } + RegCloseKey(pm->monitorinit.hckRegistryRoot); list_remove(&pm->entry); FreeLibrary(pm->hdll); heap_free(pm->name); @@ -471,7 +608,32 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname) } } - if (pInitializePrintMonitor && regroot) { + if (pInitializePrintMonitor2 && regroot) { + HKEY rootkey; + + pm->monitorinit.cbSize = sizeof(MONITORINIT); + pm->monitorinit.hSpooler = pm; + + if (RegCreateKeyW(HKEY_LOCAL_MACHINE, regroot, &rootkey) != ERROR_SUCCESS) { + WARN("failed to create %s\n", debugstr_w(regroot)); + goto cleanup; + } + + TRACE("using %p for %s\n", rootkey, debugstr_w(regroot)); + + pm->monitorinit.hckRegistryRoot = rootkey; + pm->monitorinit.pMonitorReg = setup_monitorreg(); + pm->monitorinit.bLocal = TRUE; + pm->monitorinit.pszServerName = NULL; + + pm->monitor2 = pInitializePrintMonitor2(&pm->monitorinit, &pm->hmonitor); + TRACE("%p: LPMONITOR2 from %s,InitializePrintMonitor2(%p, %p)\n", + pm->monitor2, debugstr_w(driver), &pm->monitorinit, &pm->hmonitor); + + } + + + if (!pm->monitor2 && pInitializePrintMonitor && regroot) { pmonitorEx = pInitializePrintMonitor(regroot); TRACE("%p: LPMONITOREX from %s,InitializePrintMonitor(%s)\n", pmonitorEx, debugstr_w(driver), debugstr_w(regroot)); @@ -487,10 +649,7 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname) } - if (!pm->monitor && regroot) { - if (pInitializePrintMonitor2 != NULL) { - FIXME("%s,InitializePrintMonitor2 not implemented\n", debugstr_w(driver)); - } + if (!pm->monitor2 && !pm->monitor && regroot) { if (pInitializeMonitorEx != NULL) { FIXME("%s,InitializeMonitorEx not implemented\n", debugstr_w(driver)); } @@ -498,7 +657,7 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname) FIXME("%s,InitializeMonitor not implemented\n", debugstr_w(driver)); } } - if (!pm->monitor && !pm->monitorUI) { + if (!pm->monitor2 && !pm->monitor && !pm->monitorUI) { monitor_unload(pm); SetLastError(ERROR_PROC_NOT_FOUND); pm = NULL; -- 2.7.4