From a2b70095f6a7fdb968761900181afb9b67638adc Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev@web.de>
Date: Wed, 3 Oct 2007 00:55:55 +0200
Subject: [PATCH] spoolss: Implement SplInitializeWinSpoolDrv.

---
 dlls/spoolss/spoolss.spec   |  2 +-
 dlls/spoolss/spoolss_main.c | 48 +++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/dlls/spoolss/spoolss.spec b/dlls/spoolss/spoolss.spec
index 4afa9bf10e7..b7fc0bd455f 100644
--- a/dlls/spoolss/spoolss.spec
+++ b/dlls/spoolss/spoolss.spec
@@ -121,7 +121,7 @@
 @ stub SplCommitSpoolData
 @ stub SplDriverUnloadComplete
 @ stub SplGetSpoolFileInfo
-@ stub SplInitializeWinSpoolDrv
+@ stdcall SplInitializeWinSpoolDrv(ptr)
 @ stub SplIsUpgrade
 @ stub SplProcessPnPEvent
 @ stub SplReadPrinter
diff --git a/dlls/spoolss/spoolss_main.c b/dlls/spoolss/spoolss_main.c
index c368fe5b318..52365c7bacf 100644
--- a/dlls/spoolss/spoolss_main.c
+++ b/dlls/spoolss/spoolss_main.c
@@ -27,6 +27,10 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(spoolss);
 
+/* ################################ */
+
+static HMODULE hwinspool;
+static const WCHAR winspooldrvW[] = {'w','i','n','s','p','o','o','l','.','d','r','v',0};
 
 /******************************************************************
  *
@@ -161,3 +165,47 @@ HANDLE WINAPI RevertToPrinterSelf(void)
     FIXME("() stub\n");
     return NULL;
 }
+
+/******************************************************************
+ *   SplInitializeWinSpoolDrv   [SPOOLSS.@]
+ *
+ * Dynamic load "winspool.drv" and fill an array with some function-pointer
+ *
+ * PARAMS
+ *  table  [I] array of function-pointer to fill
+ *
+ * RETURNS
+ *  Success: TRUE
+ *  Failure: FALSE
+ *
+ * NOTES
+ *  Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
+ *  We implement the XP-Version (The table has only 9 Pointer)
+ *
+ */
+BOOL WINAPI SplInitializeWinSpoolDrv(LPVOID * table)
+{
+    DWORD res;
+
+    TRACE("(%p)\n", table);
+
+    hwinspool = LoadLibraryW(winspooldrvW);
+    if (!hwinspool) return FALSE;
+
+    table[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
+    table[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
+    table[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
+    table[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
+    table[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
+    table[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212);  /* LoadPrinterDriver */
+    table[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213);  /* RefCntLoadDriver */
+    table[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214);  /* RefCntUnloadDriver */
+    table[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215);  /* ForceUnloadDriver */
+
+    for (res = 0; res < 9; res++) {
+        if (table[res] == NULL) return FALSE;
+    }
+
+    return TRUE;
+
+}
-- 
GitLab