2015-05-06 12:47:20 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Spooler API
|
2017-09-29 17:18:19 +00:00
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
2015-05-06 12:47:20 +00:00
|
|
|
* PURPOSE: Main functions
|
2017-12-09 11:00:09 +00:00
|
|
|
* COPYRIGHT: Copyright 2015-2017 Colin Finck (colin@reactos.org)
|
2015-05-06 12:47:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
[LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.
So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.
Also make some more comments Doxygen-aware :)
svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
|
|
|
// Global Variables
|
|
|
|
HANDLE hProcessHeap;
|
2020-08-04 02:07:58 +00:00
|
|
|
HINSTANCE hinstWinSpool = NULL;
|
|
|
|
CRITICAL_SECTION rtlCritSec;
|
[LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.
So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.
Also make some more comments Doxygen-aware :)
svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
|
|
|
|
2015-05-06 12:47:20 +00:00
|
|
|
handle_t __RPC_USER
|
|
|
|
WINSPOOL_HANDLE_bind(WINSPOOL_HANDLE wszName)
|
|
|
|
{
|
|
|
|
handle_t hBinding;
|
|
|
|
PWSTR wszStringBinding;
|
|
|
|
RPC_STATUS Status;
|
|
|
|
|
|
|
|
// Get us a string binding handle from the supplied connection information
|
2015-07-18 14:31:20 +00:00
|
|
|
Status = RpcStringBindingComposeW(NULL, L"ncalrpc", NULL, L"spoolss", NULL, &wszStringBinding);
|
2015-05-06 12:47:20 +00:00
|
|
|
if (Status != RPC_S_OK)
|
|
|
|
{
|
Time to commit some Work-In-Progress stuff before my diff gets too large..
[LOCALSPL]
- Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor.
- Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors.
Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List.
- Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases.
Currently working on LocalStartDocPrinter.
- Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files.
[WINPRINT]
Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW.
[WINSPOOL_APITEST]
Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW.
TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss.
[SPOOLSS]
Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there.
This function should later also initialize further Print Providers.
[SPOOLSV]
Call InitializeRouter when starting up the service.
[WINSPOOL]
Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW.
[All modules]
Fix printf format specifiers for errors (%lu) and statuses (%ld).
svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
|
|
|
ERR("RpcStringBindingComposeW failed with status %ld!\n", Status);
|
2015-05-06 12:47:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get a handle_t binding handle from the string binding handle
|
|
|
|
Status = RpcBindingFromStringBindingW(wszStringBinding, &hBinding);
|
|
|
|
if (Status != RPC_S_OK)
|
|
|
|
{
|
Time to commit some Work-In-Progress stuff before my diff gets too large..
[LOCALSPL]
- Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor.
- Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors.
Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List.
- Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases.
Currently working on LocalStartDocPrinter.
- Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files.
[WINPRINT]
Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW.
[WINSPOOL_APITEST]
Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW.
TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss.
[SPOOLSS]
Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there.
This function should later also initialize further Print Providers.
[SPOOLSV]
Call InitializeRouter when starting up the service.
[WINSPOOL]
Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW.
[All modules]
Fix printf format specifiers for errors (%lu) and statuses (%ld).
svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
|
|
|
ERR("RpcBindingFromStringBindingW failed with status %ld!\n", Status);
|
2015-05-06 12:47:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Free the string binding handle
|
|
|
|
Status = RpcStringFreeW(&wszStringBinding);
|
|
|
|
if (Status != RPC_S_OK)
|
|
|
|
{
|
Time to commit some Work-In-Progress stuff before my diff gets too large..
[LOCALSPL]
- Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor.
- Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors.
Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List.
- Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases.
Currently working on LocalStartDocPrinter.
- Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files.
[WINPRINT]
Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW.
[WINSPOOL_APITEST]
Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW.
TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss.
[SPOOLSS]
Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there.
This function should later also initialize further Print Providers.
[SPOOLSV]
Call InitializeRouter when starting up the service.
[WINSPOOL]
Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW.
[All modules]
Fix printf format specifiers for errors (%lu) and statuses (%ld).
svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
|
|
|
ERR("RpcStringFreeW failed with status %ld!\n", Status);
|
2015-05-06 12:47:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hBinding;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_USER
|
|
|
|
WINSPOOL_HANDLE_unbind(WINSPOOL_HANDLE wszName, handle_t hBinding)
|
|
|
|
{
|
|
|
|
RPC_STATUS Status;
|
|
|
|
|
|
|
|
Status = RpcBindingFree(&hBinding);
|
|
|
|
if (Status != RPC_S_OK)
|
|
|
|
{
|
Time to commit some Work-In-Progress stuff before my diff gets too large..
[LOCALSPL]
- Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor.
- Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors.
Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List.
- Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases.
Currently working on LocalStartDocPrinter.
- Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files.
[WINPRINT]
Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW.
[WINSPOOL_APITEST]
Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW.
TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss.
[SPOOLSS]
Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there.
This function should later also initialize further Print Providers.
[SPOOLSV]
Call InitializeRouter when starting up the service.
[WINSPOOL]
Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW.
[All modules]
Fix printf format specifiers for errors (%lu) and statuses (%ld).
svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
|
|
|
ERR("RpcBindingFree failed with status %ld!\n", Status);
|
2015-05-06 12:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_FAR* __RPC_USER
|
|
|
|
midl_user_allocate(SIZE_T len)
|
|
|
|
{
|
[LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.
So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.
Also make some more comments Doxygen-aware :)
svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
|
|
|
return HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, len);
|
2015-05-06 12:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_USER
|
|
|
|
midl_user_free(void __RPC_FAR* ptr)
|
|
|
|
{
|
[LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.
So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.
Also make some more comments Doxygen-aware :)
svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
|
|
|
HeapFree(hProcessHeap, 0, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
2017-12-09 11:00:09 +00:00
|
|
|
TRACE("DllMain(%p, %lu, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
|
|
|
|
[LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.
So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.
Also make some more comments Doxygen-aware :)
svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
2015-07-16 15:24:40 +00:00
|
|
|
hProcessHeap = GetProcessHeap();
|
2020-08-04 02:07:58 +00:00
|
|
|
hinstWinSpool = hinstDLL;
|
|
|
|
InitializeCriticalSection(&rtlCritSec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
DeleteCriticalSection(&rtlCritSec);
|
[LOCALSPL, WINSPOOL]
Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions.
They behave very differently based on whether spooled printing is enabled, whether it's a local or remote call, etc. Most information was gained by observing callchains under Windows.
So far, only the spooled path is implemented, the others need more investigation first.
Many other TODOs remain as well, see the comments.
Also make some more comments Doxygen-aware :)
svn path=/branches/colins-printing-for-freedom/; revision=68405
2015-07-16 15:03:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2015-05-06 12:47:20 +00:00
|
|
|
}
|
|
|
|
|
2015-05-12 14:43:25 +00:00
|
|
|
BOOL WINAPI
|
2017-10-28 12:46:11 +00:00
|
|
|
SpoolerInit(VOID)
|
2015-05-12 14:43:25 +00:00
|
|
|
{
|
2015-06-23 13:46:14 +00:00
|
|
|
BOOL bReturnValue = FALSE;
|
|
|
|
DWORD dwErrorCode;
|
2015-05-12 14:43:25 +00:00
|
|
|
|
2017-12-09 11:00:09 +00:00
|
|
|
TRACE("SpoolerInit()\n");
|
|
|
|
|
2015-05-12 14:43:25 +00:00
|
|
|
// Nothing to initialize here yet, but pass this call to the Spool Service as well.
|
|
|
|
RpcTryExcept
|
|
|
|
{
|
2015-06-23 13:46:14 +00:00
|
|
|
dwErrorCode = _RpcSpoolerInit();
|
|
|
|
SetLastError(dwErrorCode);
|
|
|
|
bReturnValue = (dwErrorCode == ERROR_SUCCESS);
|
2015-05-12 14:43:25 +00:00
|
|
|
}
|
|
|
|
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
Time to commit some Work-In-Progress stuff before my diff gets too large..
[LOCALSPL]
- Begin work on the Local Spooler. Return a structure with function pointers in InitializePrintProvidor.
- Design and document internal structures for managing LocalSpl Handles, Printer Handles, Printers, Print Jobs and Print Processors.
Manage Printers and Print Processors in Generic Tables, with one Job Queue per Printer managed as a Doubly Linked List.
- Implement LocalOpenPrinter, LocalEnumPrintProcessorDatatypes, LocalEnumPrintProcessors, LocalGetPrintProcessorDirectory, with focus on catching all corner cases.
Currently working on LocalStartDocPrinter.
- Build upon the documentation at http://www.undocprint.org/formats/winspool/shd to read and write .SHD files.
[WINPRINT]
Begin work on the Standard Print Processor. Implement EnumPrintProcessorDatatypesW.
[WINSPOOL_APITEST]
Add an API Test for winspool.drv, currently testing some corner cases of ClosePrinter, EnumPrintProcessorDatatypesW, GetPrintProcessorDirectoryW, OpenPrinterW, StartDocPrinterW.
TODO: Find a way to actually test the localspl.dll functions instead of only winspool.drv. This DLL doesn't like to be tested standalone under Windows, e.g. without being used through spoolsv/spoolss.
[SPOOLSS]
Implement InitializeRouter by calling the InitializePrintProvidor function of localspl there.
This function should later also initialize further Print Providers.
[SPOOLSV]
Call InitializeRouter when starting up the service.
[WINSPOOL]
Add dummy functions for EnumPrintProcessorDatatypesA/EnumPrintProcessorDatatypesW.
[All modules]
Fix printf format specifiers for errors (%lu) and statuses (%ld).
svn path=/branches/colins-printing-for-freedom/; revision=67847
2015-05-22 15:29:07 +00:00
|
|
|
ERR("_RpcSpoolerInit failed with exception code %lu!\n", RpcExceptionCode());
|
2015-05-12 14:43:25 +00:00
|
|
|
}
|
|
|
|
RpcEndExcept;
|
|
|
|
|
2015-06-23 13:46:14 +00:00
|
|
|
return bReturnValue;
|
2015-05-12 14:43:25 +00:00
|
|
|
}
|