[PATCH] winspool & localspl native driver dll calls
Marcel Partap
mpartap at gmx.net
Sat Mar 29 22:13:16 CDT 2008
---
dlls/localspl/localspl_main.c | 16 ++++++-
dlls/winspool.drv/info.c | 97 +++++++++++++++++++++++++++++++---------
include/ddk/winddiui.h | 17 +++++++
3 files changed, 107 insertions(+), 23 deletions(-)
diff --git a/dlls/localspl/localspl_main.c b/dlls/localspl/localspl_main.c
index 77fb730..30628bd 100644
--- a/dlls/localspl/localspl_main.c
+++ b/dlls/localspl/localspl_main.c
@@ -29,6 +29,7 @@
#include "winreg.h"
#include "winspool.h"
#include "ddk/winsplp.h"
+#include "ddk/winddiui.h"
#include "winuser.h"
#include "wine/debug.h"
@@ -62,6 +63,7 @@ HINSTANCE LOCALSPL_hInstance = NULL;
static const PRINTPROVIDOR * pp = NULL;
+static PFN_DrvDriverEvent pDrvDriverEvent = NULL;
static const WCHAR backslashW[] = {'\\',0};
static const WCHAR configuration_fileW[] = {'C','o','n','f','i','g','u','r','a','t','i','o','n',' ','F','i','l','e',0};
@@ -408,6 +410,7 @@ static BOOL WINAPI myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD d
DWORD disposition;
DWORD len;
LONG lres;
+ HINSTANCE hcfgdll;
/* we need to set all entries in the Registry, independent from the Level of
DRIVER_INFO, that the caller supplied */
@@ -525,7 +528,18 @@ static BOOL WINAPI myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD d
if (level > 5) TRACE("level %u for Driver %s is incomplete\n", level, debugstr_w(di.pName));
RegCloseKey(hdrv);
- TRACE("### DrvDriverEvent(...,DRIVEREVENT_INITIALIZE) not implemented yet\n");
+
+ apd.dst[apd.dstlen] = '\0';
+ lstrcatW(apd.dst, di.pConfigFile);
+ hcfgdll = LoadLibraryW(apd.dst);
+ if (hcfgdll) {
+ pDrvDriverEvent = (void*)GetProcAddress(hcfgdll, "DrvDriverEvent");
+ if (pDrvDriverEvent) {
+ lres = pDrvDriverEvent(DRIVER_EVENT_INITIALIZE, 3, (LPBYTE)&di, (LPARAM)NULL);
+ TRACE("DrvDriverEvent returned %d\n", lres);
+ }
+ FreeLibrary(hcfgdll);
+ }
TRACE("=> TRUE with %u\n", GetLastError());
return TRUE;
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index dadc61f..6229d41 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -56,6 +56,7 @@
#include "wine/debug.h"
#include "wine/list.h"
#include "winnls.h"
+#include "ddk/winddiui.h"
#include "ddk/winsplp.h"
#include "wspool.h"
@@ -147,6 +148,7 @@ static INT (WINAPI *GDI_CallExtDeviceMode16)( HWND hwnd, LPDEVMODEA lpdmOutput,
LPSTR lpszDevice, LPSTR lpszPort,
LPDEVMODEA lpdmInput, LPSTR lpszProfile,
DWORD fwMode );
+static PFN_DrvDocumentPropertySheets pDrvDocumentPropertySheets = NULL;
static const WCHAR DriversW[] = { 'S','y','s','t','e','m','\\',
'C','u', 'r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
@@ -2136,6 +2138,49 @@ LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter,
return ret;
}
+/*****************************************************************************
+ * WINSPOOL_CallDrvDocumentProperties (internal)
+ * calls native driver's DrvDocumentProperties
+ */
+static LONG WINSPOOL_CallDrvDocumentProperties(HANDLE hPrinter, LPWSTR pDeviceName,
+ LPDEVMODEW pdmOut, LPDEVMODEW pdmIn,
+ DWORD fMode)
+{
+ DRIVER_INFO_2W *di;
+ DWORD needed;
+ HINSTANCE hcfgdll;
+ DOCUMENTPROPERTYHEADER dph;
+ LONG lres;
+
+ GetPrinterDriverW(hPrinter, NULL, 2, NULL, 0, &needed);
+ di = HeapAlloc(GetProcessHeap(), 0, needed);
+ if (!GetPrinterDriverW(hPrinter, NULL, 2, di, needed, &needed)) {
+ ERR("GetPrinterDriver failed on %p\n", hPrinter);
+ return -1;
+ }
+ hcfgdll = LoadLibraryW(di->pConfigFile);
+ if (!hcfgdll) {
+ ERR("LoadLibrary failed on %s\n", debugstr_w(di->pConfigFile));
+ return -1;
+ }
+ pDrvDocumentPropertySheets = (void*)GetProcAddress(hcfgdll, "DrvDocumentPropertySheets");
+ if (!pDrvDocumentPropertySheets) {
+ ERR("GetProcAddress could not find DrvDocumentPropertySheets in %s\n", debugstr_w(di->pConfigFile));
+ return -1;
+ }
+ TRACE("hcfgdll=%p pDrvDocumentPropertySheets=%p\n", hcfgdll, pDrvDocumentPropertySheets);
+ memset(&dph, 0, sizeof(dph));
+ dph.cbSize = sizeof(dph);
+ dph.hPrinter = hPrinter;
+ dph.pszPrinterName = pDeviceName;
+ dph.pdmIn = pdmIn;
+ dph.pdmOut = pdmOut;
+ dph.fMode = fMode;
+ lres = pDrvDocumentPropertySheets(NULL, &dph);
+ TRACE("returning %d needed = %d\n", lres, dph.cbOut);
+ FreeLibrary(hcfgdll);
+ return lres;
+}
/*****************************************************************************
* DocumentPropertiesW (WINSPOOL.@)
@@ -2158,15 +2203,24 @@ LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter,
fMode);
if(pDevModeOutput) {
ret = DocumentPropertiesA(hWnd, hPrinter, pDeviceNameA, NULL, NULL, 0);
- if(ret < 0) return ret;
- pDevModeOutputA = HeapAlloc(GetProcessHeap(), 0, ret);
+ if(ret > 0) pDevModeOutputA = HeapAlloc(GetProcessHeap(), 0, ret);
}
ret = DocumentPropertiesA(hWnd, hPrinter, pDeviceNameA, pDevModeOutputA,
pDevModeInputA, fMode);
- if(pDevModeOutput) {
+ if(pDevModeOutputA) {
DEVMODEcpyAtoW(pDevModeOutput, pDevModeOutputA);
HeapFree(GetProcessHeap(),0,pDevModeOutputA);
}
+
+ /* handle native 32-bit drivers (only unicode/W) */
+ if (ret <= 0) {
+ if (!hPrinter) {
+ OpenPrinterW(pDeviceName, &hPrinter, NULL);
+ }
+ ret = WINSPOOL_CallDrvDocumentProperties(hPrinter, pDeviceName, pDevModeOutput,
+ pDevModeInput, fMode);
+ }
+
if(fMode == 0 && ret > 0)
ret += (CCHDEVICENAME + CCHFORMNAME);
HeapFree(GetProcessHeap(),0,pDevModeInputA);
@@ -3073,6 +3127,24 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
RegSetValueExW(hkeyPrinter, attributesW, 0, REG_DWORD,
(LPBYTE)&pi->Attributes, sizeof(DWORD));
set_reg_szW(hkeyPrinter, DatatypeW, pi->pDatatype);
+ set_reg_szW(hkeyPrinter, DescriptionW, pi->pComment);
+ set_reg_szW(hkeyPrinter, LocationW, pi->pLocation);
+ set_reg_szW(hkeyPrinter, NameW, pi->pPrinterName);
+ set_reg_szW(hkeyPrinter, ParametersW, pi->pParameters);
+
+ set_reg_szW(hkeyPrinter, PortW, pi->pPortName);
+ set_reg_szW(hkeyPrinter, Print_ProcessorW, pi->pPrintProcessor);
+ set_reg_szW(hkeyPrinter, Printer_DriverW, pi->pDriverName);
+ RegSetValueExW(hkeyPrinter, priorityW, 0, REG_DWORD,
+ (LPBYTE)&pi->Priority, sizeof(DWORD));
+ set_reg_szW(hkeyPrinter, Separator_FileW, pi->pSepFile);
+ set_reg_szW(hkeyPrinter, Share_NameW, pi->pShareName);
+ RegSetValueExW(hkeyPrinter, start_timeW, 0, REG_DWORD,
+ (LPBYTE)&pi->StartTime, sizeof(DWORD));
+ RegSetValueExW(hkeyPrinter, statusW, 0, REG_DWORD,
+ (LPBYTE)&pi->Status, sizeof(DWORD));
+ RegSetValueExW(hkeyPrinter, until_timeW, 0, REG_DWORD,
+ (LPBYTE)&pi->UntilTime, sizeof(DWORD));
/* See if we can load the driver. We may need the devmode structure anyway
*
@@ -3119,25 +3191,6 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
if(!pi->pDevMode)
HeapFree(GetProcessHeap(), 0, dmW);
}
- set_reg_szW(hkeyPrinter, DescriptionW, pi->pComment);
- set_reg_szW(hkeyPrinter, LocationW, pi->pLocation);
- set_reg_szW(hkeyPrinter, NameW, pi->pPrinterName);
- set_reg_szW(hkeyPrinter, ParametersW, pi->pParameters);
-
- set_reg_szW(hkeyPrinter, PortW, pi->pPortName);
- set_reg_szW(hkeyPrinter, Print_ProcessorW, pi->pPrintProcessor);
- set_reg_szW(hkeyPrinter, Printer_DriverW, pi->pDriverName);
- RegSetValueExW(hkeyPrinter, priorityW, 0, REG_DWORD,
- (LPBYTE)&pi->Priority, sizeof(DWORD));
- set_reg_szW(hkeyPrinter, Separator_FileW, pi->pSepFile);
- set_reg_szW(hkeyPrinter, Share_NameW, pi->pShareName);
- RegSetValueExW(hkeyPrinter, start_timeW, 0, REG_DWORD,
- (LPBYTE)&pi->StartTime, sizeof(DWORD));
- RegSetValueExW(hkeyPrinter, statusW, 0, REG_DWORD,
- (LPBYTE)&pi->Status, sizeof(DWORD));
- RegSetValueExW(hkeyPrinter, until_timeW, 0, REG_DWORD,
- (LPBYTE)&pi->UntilTime, sizeof(DWORD));
-
RegCloseKey(hkeyPrinter);
RegCloseKey(hkeyPrinters);
if(!OpenPrinterW(pi->pPrinterName, &retval, NULL)) {
diff --git a/include/ddk/winddiui.h b/include/ddk/winddiui.h
index 7c6e775..0650416 100644
--- a/include/ddk/winddiui.h
+++ b/include/ddk/winddiui.h
@@ -22,6 +22,7 @@
#define __WINE_WINDDIUI_H
#include <ddk/compstui.h>
+#include <wingdi.h>
#ifdef __cplusplus
extern "C" {
@@ -40,9 +41,25 @@ extern "C" {
#define PRINTER_EVENT_FLAG_NO_UI 1
+typedef struct _DOCUMENTPROPERTYHEADER {
+ WORD cbSize;
+ WORD Reserved;
+ HANDLE hPrinter;
+ LPWSTR pszPrinterName;
+ PDEVMODEW pdmIn;
+ PDEVMODEW pdmOut;
+ DWORD cbOut;
+ DWORD fMode;
+} DOCUMENTPROPERTYHEADER, *PDOCUMENTPROPERTYHEADER;
+
+LONG WINAPI DrvDocumentPropertySheets(PPROPSHEETUI_INFO, LPARAM);
BOOL WINAPI DrvDriverEvent(DWORD, DWORD, LPBYTE, LPARAM);
BOOL WINAPI DrvPrinterEvent(LPWSTR, INT, DWORD, LPARAM);
+typedef LONG WINAPI (*PFN_DrvDocumentPropertySheets)(PPROPSHEETUI_INFO, LPARAM);
+typedef BOOL WINAPI (*PFN_DrvDriverEvent)(DWORD, DWORD, LPBYTE, LPARAM);
+typedef BOOL WINAPI (*PFN_DrvPrinterEvent)(LPWSTR, INT, DWORD, LPARAM);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
--
1.5.4.4
--------------040200000709000007010901--
More information about the wine-devel
mailing list