ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

spoolss_main.c
Go to the documentation of this file.
00001 /*
00002  * Implementation of the Spooler-Service helper DLL
00003  *
00004  * Copyright 2006 Detlef Riekenberg
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <stdarg.h>
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "winerror.h"
00026 #include "winreg.h"
00027 
00028 #include "wingdi.h"
00029 #include "winspool.h"
00030 #include "ddk/winsplp.h"
00031 #include "spoolss.h"
00032 
00033 #include "wine/debug.h"
00034 
00035 WINE_DEFAULT_DEBUG_CHANNEL(spoolss);
00036 
00037 /* ################################ */
00038 
00039 static HMODULE hwinspool;
00040 
00041 static const WCHAR winspooldrvW[] = {'w','i','n','s','p','o','o','l','.','d','r','v',0};
00042 
00043 /******************************************************************************
00044  *
00045  */
00046 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
00047 {
00048     TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
00049 
00050     switch (fdwReason) {
00051         case DLL_WINE_PREATTACH:
00052             return FALSE;  /* prefer native version */
00053         case DLL_PROCESS_ATTACH: {
00054             DisableThreadLibraryCalls(hinstDLL);
00055             break;
00056 
00057         case DLL_PROCESS_DETACH:
00058             backend_unload_all();
00059             break;
00060         }
00061     }
00062     return TRUE;
00063 }
00064 
00065 /******************************************************************
00066  *   AllocSplStr   [SPOOLSS.@]
00067  *
00068  * Create a copy from the String on the Spooler-Heap
00069  *
00070  * PARAMS
00071  *  pwstr [I] PTR to the String to copy
00072  *
00073  * RETURNS
00074  *  Failure: NULL
00075  *  Success: PTR to the copied String
00076  *
00077  */
00078 LPWSTR WINAPI AllocSplStr(LPCWSTR pwstr)
00079 {
00080     LPWSTR  res = NULL;
00081     DWORD   len;
00082 
00083     TRACE("(%s)\n", debugstr_w(pwstr));
00084     if (!pwstr) return NULL;
00085 
00086     len = (lstrlenW(pwstr) + 1) * sizeof(WCHAR);
00087     res = HeapAlloc(GetProcessHeap(), 0, len);
00088     if (res) lstrcpyW(res, pwstr);
00089         
00090     TRACE("returning %p\n", res);
00091     return res;
00092 }
00093 
00094 /******************************************************************
00095  *   BuildOtherNamesFromMachineName   [SPOOLSS.@]
00096  */
00097 BOOL WINAPI BuildOtherNamesFromMachineName(LPVOID * ptr1, LPVOID * ptr2)
00098 {
00099     FIXME("(%p, %p) stub\n", ptr1, ptr2);
00100 
00101     *ptr1 = NULL;
00102     *ptr2 = NULL;
00103     return FALSE;
00104 }
00105 
00106 /******************************************************************
00107  *   DllAllocSplMem   [SPOOLSS.@]
00108  *
00109  * Allocate cleared memory from the spooler heap
00110  *
00111  * PARAMS
00112  *  size [I] Number of bytes to allocate
00113  *
00114  * RETURNS
00115  *  Failure: NULL
00116  *  Success: PTR to the allocated memory
00117  *
00118  * NOTES
00119  *  We use the process heap (Windows use a separate spooler heap)
00120  *
00121  */
00122 LPVOID WINAPI DllAllocSplMem(DWORD size)
00123 {
00124     LPVOID  res;
00125 
00126     res = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
00127     TRACE("(%d) => %p\n", size, res);
00128     return res;
00129 }
00130 
00131 /******************************************************************
00132  *   DllFreeSplMem   [SPOOLSS.@]
00133  *
00134  * Free the allocated spooler memory
00135  *
00136  * PARAMS
00137  *  memory [I] PTR to the memory allocated by DllAllocSplMem
00138  *
00139  * RETURNS
00140  *  Failure: FALSE
00141  *  Success: TRUE
00142  *
00143  * NOTES
00144  *  We use the process heap (Windows use a separate spooler heap)
00145  *
00146  */
00147 
00148 BOOL WINAPI DllFreeSplMem(LPBYTE memory)
00149 {
00150     TRACE("(%p)\n", memory);
00151     return HeapFree(GetProcessHeap(), 0, memory);
00152 }
00153 
00154 /******************************************************************
00155  *   DllFreeSplStr   [SPOOLSS.@]
00156  *
00157  * Free the allocated Spooler-String
00158  *
00159  * PARAMS
00160  *  pwstr [I] PTR to the WSTR, allocated by AllocSplStr
00161  *
00162  * RETURNS
00163  *  Failure: FALSE
00164  *  Success: TRUE
00165  *
00166  */
00167 
00168 BOOL WINAPI DllFreeSplStr(LPWSTR pwstr)
00169 {
00170     TRACE("(%s) PTR: %p\n", debugstr_w(pwstr), pwstr);
00171     return HeapFree(GetProcessHeap(), 0, pwstr);
00172 }
00173 
00174 
00175 /******************************************************************
00176  *   ImpersonatePrinterClient   [SPOOLSS.@]
00177  */
00178 BOOL WINAPI ImpersonatePrinterClient(HANDLE hToken)
00179 {
00180     FIXME("(%p) stub\n", hToken);
00181     return TRUE;
00182 }
00183 
00184 /******************************************************************
00185  *   InitializeRouter   [SPOOLSS.@]
00186  */
00187 BOOL WINAPI InitializeRouter(void)
00188 {
00189     TRACE("()\n");
00190     return backend_load_all();
00191 }
00192 
00193 /******************************************************************
00194  *   IsLocalCall    [SPOOLSS.@]
00195  */
00196 BOOL WINAPI IsLocalCall(void)
00197 {
00198     FIXME("() stub\n");
00199     return TRUE;
00200 }
00201 
00202 /******************************************************************
00203  *   RevertToPrinterSelf   [SPOOLSS.@]
00204  */
00205 HANDLE WINAPI RevertToPrinterSelf(void)
00206 {
00207     FIXME("() stub\n");
00208     return (HANDLE) 0xdead0947;
00209 }
00210 
00211 /******************************************************************
00212  *   SplInitializeWinSpoolDrv   [SPOOLSS.@]
00213  *
00214  * Dynamic load "winspool.drv" and fill an array with some function-pointer
00215  *
00216  * PARAMS
00217  *  table  [I] array of function-pointer to fill
00218  *
00219  * RETURNS
00220  *  Success: TRUE
00221  *  Failure: FALSE
00222  *
00223  * NOTES
00224  *  Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
00225  *  We implement the XP-Version (The table has only 9 Pointer)
00226  *
00227  */
00228 BOOL WINAPI SplInitializeWinSpoolDrv(LPVOID * table)
00229 {
00230     DWORD res;
00231 
00232     TRACE("(%p)\n", table);
00233 
00234     hwinspool = LoadLibraryW(winspooldrvW);
00235     if (!hwinspool) return FALSE;
00236 
00237     table[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
00238     table[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
00239     table[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
00240     table[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
00241     table[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
00242     table[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212);  /* LoadPrinterDriver */
00243     table[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213);  /* RefCntLoadDriver */
00244     table[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214);  /* RefCntUnloadDriver */
00245     table[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215);  /* ForceUnloadDriver */
00246 
00247     for (res = 0; res < 9; res++) {
00248         if (table[res] == NULL) return FALSE;
00249     }
00250 
00251     return TRUE;
00252 
00253 }
00254 
00255 /******************************************************************
00256  *   SplIsUpgrade   [SPOOLSS.@]
00257  */
00258 BOOL WINAPI SplIsUpgrade(void)
00259 {
00260     FIXME("() stub\n");
00261     return FALSE;
00262 }
00263 
00264 /******************************************************************
00265  *   SpoolerHasInitialized  [SPOOLSS.@]
00266  */
00267 BOOL WINAPI SpoolerHasInitialized(void)
00268 {
00269     FIXME("() stub\n");
00270     return TRUE;
00271 }
00272 
00273 /******************************************************************
00274  *   SpoolerInit   [SPOOLSS.@]
00275  */
00276 BOOL WINAPI SpoolerInit(void)
00277 {
00278     FIXME("() stub\n");
00279     return TRUE;
00280 }
00281 
00282 /******************************************************************
00283  *   WaitForSpoolerInitialization   [SPOOLSS.@]
00284  */
00285 BOOL WINAPI WaitForSpoolerInitialization(void)
00286 {
00287     FIXME("() stub\n");
00288     return TRUE;
00289 }

Generated on Wed May 23 2012 04:24:29 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.