ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2015
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
13 participants
257 discussions
Start a n
N
ew thread
[cfinck] 68414: [WINSPOOL] Bugfix: hPrinter is a PSPOOLER_HANDLE for all winspool functions. The hPrinter member of a SPOOLER_HANDLE is only passed to RPC calls.
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 15:11:34 2015 New Revision: 68414 URL:
http://svn.reactos.org/svn/reactos?rev=68414&view=rev
Log: [WINSPOOL] Bugfix: hPrinter is a PSPOOLER_HANDLE for all winspool functions. The hPrinter member of a SPOOLER_HANDLE is only passed to RPC calls. Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] Fri Jul 17 15:11:34 2015 @@ -63,7 +63,7 @@ } // Get the size of the job information. - GetJobW(pHandle->hPrinter, pAddJobInfo1->JobId, 1, NULL, 0, &cbNeeded); + GetJobW((HANDLE)pHandle, pAddJobInfo1->JobId, 1, NULL, 0, &cbNeeded); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { dwErrorCode = GetLastError(); @@ -81,7 +81,7 @@ } // Get the job information. - if (!GetJobW(pHandle->hPrinter, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, cbNeeded, &cbNeeded)) + if (!GetJobW((HANDLE)pHandle, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, cbNeeded, &cbNeeded)) { dwErrorCode = GetLastError(); ERR("GetJobW failed with error %lu!\n", dwErrorCode); @@ -93,7 +93,7 @@ pJobInfo1->pDocument = pDocInfo1->pDocName; // Set the new job information. - if (!SetJobW(pHandle->hPrinter, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, 0)) + if (!SetJobW((HANDLE)pHandle, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, 0)) { dwErrorCode = GetLastError(); ERR("SetJobW failed with error %lu!\n", dwErrorCode); @@ -568,7 +568,7 @@ // Try to add a new job. // This only succeeds if the printer is set to do spooled printing. - if (AddJobW(pHandle->hPrinter, 1, (PBYTE)pAddJobInfo1, cbAddJobInfo1, &cbNeeded)) + if (AddJobW((HANDLE)pHandle, 1, (PBYTE)pAddJobInfo1, cbAddJobInfo1, &cbNeeded)) { // Do spooled printing. dwErrorCode = _StartDocPrinterSpooled(pHandle, pDocInfo1, pAddJobInfo1);
9 years, 5 months
1
0
0
0
[cfinck] 68413: [SPOOLSV, WINSPOOL] Add MarshallUp/MarshallDown functions for ADDJOB_INFO_1W as well.
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 15:09:31 2015 New Revision: 68413 URL:
http://svn.reactos.org/svn/reactos?rev=68413&view=rev
Log: [SPOOLSV, WINSPOOL] Add MarshallUp/MarshallDown functions for ADDJOB_INFO_1W as well. Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/jobs.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/jobs.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/jobs.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/jobs.c [iso-8859-1] Fri Jul 17 15:09:31 2015 @@ -6,6 +6,13 @@ */ #include "precomp.h" + +static void +_MarshallDownAddJobInfo(PADDJOB_INFO_1W pAddJobInfo1) +{ + // Replace absolute pointer addresses in the output by relative offsets. + pAddJobInfo1->Path = (PWSTR)((ULONG_PTR)pAddJobInfo1->Path - (ULONG_PTR)pAddJobInfo1); +} static void _MarshallDownJobInfo(PBYTE pJobInfo, DWORD Level) @@ -53,7 +60,6 @@ _RpcAddJob(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE* pAddJob, DWORD cbBuf, DWORD* pcbNeeded) { DWORD dwErrorCode; - PADDJOB_INFO_1W pAddJobInfo1; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -66,11 +72,7 @@ dwErrorCode = GetLastError(); if (dwErrorCode == ERROR_SUCCESS) - { - // Replace absolute pointer addresses in the output by relative offsets. - pAddJobInfo1 = (PADDJOB_INFO_1W)pAddJob; - pAddJobInfo1->Path = (PWSTR)((ULONG_PTR)pAddJobInfo1->Path - (ULONG_PTR)pAddJobInfo1); - } + _MarshallDownAddJobInfo((PADDJOB_INFO_1W)pAddJob); RpcRevertToSelf(); return dwErrorCode; Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c [iso-8859-1] Fri Jul 17 15:09:31 2015 @@ -6,6 +6,13 @@ */ #include "precomp.h" + +static void +_MarshallUpAddJobInfo(PADDJOB_INFO_1W pAddJobInfo1) +{ + // Replace relative offset addresses in the output by absolute pointers. + pAddJobInfo1->Path = (PWSTR)((ULONG_PTR)pAddJobInfo1->Path + (ULONG_PTR)pAddJobInfo1); +} static void _MarshallUpJobInfo(PBYTE pJobInfo, DWORD Level) @@ -60,7 +67,6 @@ AddJobW(HANDLE hPrinter, DWORD Level, PBYTE pData, DWORD cbBuf, PDWORD pcbNeeded) { DWORD dwErrorCode; - PADDJOB_INFO_1W pAddJobInfo1; PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; if (!pHandle) @@ -82,11 +88,7 @@ RpcEndExcept; if (dwErrorCode == ERROR_SUCCESS) - { - // Replace relative offset addresses in the output by absolute pointers. - pAddJobInfo1 = (PADDJOB_INFO_1W)pData; - pAddJobInfo1->Path = (PWSTR)((ULONG_PTR)pAddJobInfo1->Path + (ULONG_PTR)pAddJobInfo1); - } + _MarshallUpAddJobInfo((PADDJOB_INFO_1W)pData); Cleanup: SetLastError(dwErrorCode);
9 years, 5 months
1
0
0
0
[cfinck] 68412: [WINSPOOL] The pDevModeContainer parameter of _RpcOpenPrinter is not optional, but its contents may be null. You can see this in the IDL file (pDevModeContainer is not marked with t...
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 14:34:23 2015 New Revision: 68412 URL:
http://svn.reactos.org/svn/reactos?rev=68412&view=rev
Log: [WINSPOOL] The pDevModeContainer parameter of _RpcOpenPrinter is not optional, but its contents may be null. You can see this in the IDL file (pDevModeContainer is not marked with the "unique" attribute) or refer to
https://msdn.microsoft.com/en-us/library/cc244808.aspx
Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] Fri Jul 17 14:34:23 2015 @@ -436,8 +436,7 @@ HANDLE hPrinter; PSPOOLER_HANDLE pHandle; PWSTR pDatatype = NULL; - WINSPOOL_DEVMODE_CONTAINER DevModeContainer; - WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer = NULL; + WINSPOOL_DEVMODE_CONTAINER DevModeContainer = { 0 }; ACCESS_MASK AccessRequired = 0; // Prepare the additional parameters in the format required by _RpcOpenPrinter @@ -446,14 +445,13 @@ pDatatype = pDefault->pDatatype; DevModeContainer.cbBuf = sizeof(DEVMODEW); DevModeContainer.pDevMode = (BYTE*)pDefault->pDevMode; - pDevModeContainer = &DevModeContainer; AccessRequired = pDefault->DesiredAccess; } // Do the RPC call RpcTryExcept { - dwErrorCode = _RpcOpenPrinter(pPrinterName, &hPrinter, pDatatype, pDevModeContainer, AccessRequired); + dwErrorCode = _RpcOpenPrinter(pPrinterName, &hPrinter, pDatatype, &DevModeContainer, AccessRequired); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) {
9 years, 5 months
1
0
0
0
[cfinck] 68411: [HIVESYS] Add registry entries for all developed printing components along with a dummy printer on LPT1. These entries are enough to boot up the spooler.
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 14:20:12 2015 New Revision: 68411 URL:
http://svn.reactos.org/svn/reactos?rev=68411&view=rev
Log: [HIVESYS] Add registry entries for all developed printing components along with a dummy printer on LPT1. These entries are enough to boot up the spooler. Modified: branches/colins-printing-for-freedom/reactos/boot/bootdata/hivesys.inf Modified: branches/colins-printing-for-freedom/reactos/boot/bootdata/hivesys.inf URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/boot/bootdata/hivesys.inf [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/boot/bootdata/hivesys.inf [iso-8859-1] Fri Jul 17 14:20:12 2015 @@ -1207,13 +1207,37 @@ HKLM,"SYSTEM\CurrentControlSet\Control\PnP\Pci\CardList","Ali",0x00030003,\ 01,00,00,00,b9,10,21,15,00,00,00,00,00,00,00,00 + +; Printing HKLM,"SYSTEM\CurrentControlSet\Control\Print","MajorVersion",0x00010001,2 -HKLM,"SYSTEM\CurrentControlSet\Control\Print","MinorVersion",0x00010003,0 -HKLM,"SYSTEM\CurrentControlSet\Control\Print","PriorityClass",0x00010003,0 -HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments",,0x00000012 -HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors",,0x00000012 -HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port","Driver",2,"localspl.dll" +HKLM,"SYSTEM\CurrentControlSet\Control\Print","MinorVersion",0x00010001,0 +HKLM,"SYSTEM\CurrentControlSet\Control\Print","PriorityClass",0x00010001,0 + +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments",,0x00000010 +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86","Directory",,"W32X86" +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Print Processors",,0x00000010 +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Print Processors\winprint","Driver",,"winprint.dll" + +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors",,0x00000010 +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port","Driver",,"localmon.dll" + HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers",,0x00000012 +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Attributes",0x00010001,0 +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Datatype",,"RAW" +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Description",,"" +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Default DevMode",1,\ +00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ +00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,dc,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ +00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ +00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ +00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Port",,"LPT1:" +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Print Processor",,"winprint" +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Printer Driver",,"Dummy Printer Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers\Dummy Printer On LPT1","Status",0x00010001,0 + +HKLM,"SYSTEM\CurrentControlSet\Control\Print\Providers",,0x00000010 + HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType",2,"ServerNT" HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite",0x00010002,"Terminal Server"
9 years, 5 months
1
0
0
0
[cfinck] 68410: [LOCALSPL] - Bugfix: A cb value includes the terminating null-character, a cch value does not. Fix the conversion. - Bugfix: Properly calculate the required buffer size in LocalGetP...
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 14:18:22 2015 New Revision: 68410 URL:
http://svn.reactos.org/svn/reactos?rev=68410&view=rev
Log: [LOCALSPL] - Bugfix: A cb value includes the terminating null-character, a cch value does not. Fix the conversion. - Bugfix: Properly calculate the required buffer size in LocalGetPrintProcessorDirectory and properly copy the string. Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c [iso-8859-1] Fri Jul 17 14:18:22 2015 @@ -140,8 +140,13 @@ goto Cleanup; } + // LocalGetPrintProcessorDirectory returns the number of copied bytes. Convert this into a number of characters without the terminating null-character. cchPrintProcessorPath /= sizeof(WCHAR); - wszPrintProcessorPath[cchPrintProcessorPath++] = L'\\'; + --cchPrintProcessorPath; + + // Append a trailing backslash. + wszPrintProcessorPath[cchPrintProcessorPath] = L'\\'; + ++cchPrintProcessorPath; // Open the environment registry key. dwErrorCode = _OpenEnvironment(NULL, &hKey); @@ -612,14 +617,15 @@ * A more specific error code can be obtained through GetLastError. */ BOOL WINAPI -LocalGetPrintProcessorDirectory(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded) +LocalGetPrintProcessorDirectory(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded) { const WCHAR wszPath[] = L"\\PRTPROCS\\"; const DWORD cchPath = _countof(wszPath) - 1; - DWORD cbDataWritten; + DWORD cbDirectoryName; DWORD dwErrorCode; HKEY hKey = NULL; + PWSTR pwszDirectory = (PWSTR)pPrintProcessorInfo; // Sanity checks if (Level != 1) @@ -644,15 +650,14 @@ } // Determine the size of the required buffer. - dwErrorCode = (DWORD)RegQueryValueExW(hKey, L"Directory", NULL, NULL, NULL, pcbNeeded); + dwErrorCode = (DWORD)RegQueryValueExW(hKey, L"Directory", NULL, NULL, NULL, &cbDirectoryName); if (dwErrorCode != ERROR_SUCCESS) { ERR("RegQueryValueExW failed with status %lu!\n", dwErrorCode); goto Cleanup; } - *pcbNeeded += cchSpoolDirectory; - *pcbNeeded += cchPath; + *pcbNeeded = (cchSpoolDirectory + cchPath) * sizeof(WCHAR) + cbDirectoryName; // Is the supplied buffer large enough? if (cbBuf < *pcbNeeded) @@ -662,11 +667,11 @@ } // Copy the path to the "prtprocs" directory into pPrintProcessorInfo - CopyMemory(pPrintProcessorInfo, wszSpoolDirectory, cchSpoolDirectory * sizeof(WCHAR)); - CopyMemory(&pPrintProcessorInfo[cchSpoolDirectory], wszPath, cchPath * sizeof(WCHAR)); + CopyMemory(pwszDirectory, wszSpoolDirectory, cchSpoolDirectory * sizeof(WCHAR)); + CopyMemory(&pwszDirectory[cchSpoolDirectory], wszPath, cchPath * sizeof(WCHAR)); // Get the directory name from the registry. - dwErrorCode = (DWORD)RegQueryValueExW(hKey, L"Directory", NULL, NULL, &pPrintProcessorInfo[cchSpoolDirectory + cchPath], &cbDataWritten); + dwErrorCode = (DWORD)RegQueryValueExW(hKey, L"Directory", NULL, NULL, (PBYTE)&pwszDirectory[cchSpoolDirectory + cchPath], &cbDirectoryName); if (dwErrorCode != ERROR_SUCCESS) { ERR("RegQueryValueExW failed with status %lu!\n", dwErrorCode);
9 years, 5 months
1
0
0
0
[cfinck] 68409: [LOCALSPL] Report any error that occured inside _OpenEnvironment.
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 13:00:49 2015 New Revision: 68409 URL:
http://svn.reactos.org/svn/reactos?rev=68409&view=rev
Log: [LOCALSPL] Report any error that occured inside _OpenEnvironment. Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.c [iso-8859-1] Fri Jul 17 13:00:49 2015 @@ -146,7 +146,10 @@ // Open the environment registry key. dwErrorCode = _OpenEnvironment(NULL, &hKey); if (dwErrorCode != ERROR_SUCCESS) - goto Cleanup; + { + ERR("_OpenEnvironment failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } // Open the "Print Processors" subkey. dwErrorCode = (DWORD)RegOpenKeyExW(hKey, L"Print Processors", 0, KEY_READ, &hSubKey); @@ -477,7 +480,10 @@ // We use the registry and not the PrintProcessorList here, because the caller may request information about a different environment. dwErrorCode = _OpenEnvironment(pEnvironment, &hKey); if (dwErrorCode != ERROR_SUCCESS) - goto Cleanup; + { + ERR("_OpenEnvironment failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } // Open the "Print Processors" subkey. dwErrorCode = (DWORD)RegOpenKeyExW(hKey, L"Print Processors", 0, KEY_READ, &hSubKey); @@ -632,7 +638,10 @@ // Verify pEnvironment and open its registry key. dwErrorCode = _OpenEnvironment(pEnvironment, &hKey); if (dwErrorCode != ERROR_SUCCESS) - goto Cleanup; + { + ERR("_OpenEnvironment failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } // Determine the size of the required buffer. dwErrorCode = (DWORD)RegQueryValueExW(hKey, L"Directory", NULL, NULL, NULL, pcbNeeded);
9 years, 5 months
1
0
0
0
[cfinck] 68408: [SPOOLSV, WINSPOOL] - Add RPC calls, proper marshalling and exports for all implemented functions. - Move the spoolsv stubs into categories, so that future implementations in winspo...
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jul 17 10:57:10 2015 New Revision: 68408 URL:
http://svn.reactos.org/svn/reactos?rev=68408&view=rev
Log: [SPOOLSV, WINSPOOL] - Add RPC calls, proper marshalling and exports for all implemented functions. - Move the spoolsv stubs into categories, so that future implementations in winspool, spoolsv, spoolss and localspl can follow a consistent naming scheme. Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/forms.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/notifications.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdata.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdrivers.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printproviders.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/xcv.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/monitors.c (with props) branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/ports.c (with props) Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/monitors.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/ports.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printers.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printprocessors.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/rpcstubs.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/CMakeLists.txt branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printprocessors.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/winspool.spec Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -3,16 +3,22 @@ add_rpc_files(server ${REACTOS_SOURCE_DIR}/include/reactos/idl/winspool.idl) list(APPEND SOURCE + forms.c init.c jobs.c main.c monitors.c + notifications.c ports.c + precomp.h + printerdata.c + printerdrivers.c printers.c printprocessors.c - precomp.h + printproviders.c rpcserver.c rpcstubs.c + xcv.c ${CMAKE_CURRENT_BINARY_DIR}/winspool_s.c) add_executable(spoolsv ${SOURCE} spoolsv.rc) Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/forms.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/forms.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/forms.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,43 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Forms + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD +_RpcAddForm(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER* pFormInfoContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeleteForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pFormName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcEnumForms(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE* pForm, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pFormName, DWORD Level, BYTE* pForm, DWORD cbBuf, DWORD* pcbNeeded) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcSetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pFormName, WINSPOOL_FORM_CONTAINER* pFormInfoContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/forms.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/monitors.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/monitors.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/monitors.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -7,10 +7,41 @@ #include "precomp.h" +static void +_MarshallDownMonitorInfo(PBYTE pMonitorInfo, DWORD Level) +{ + PMONITOR_INFO_2W pMonitorInfo2 = (PMONITOR_INFO_2W)pMonitorInfo; // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W + + // Replace absolute pointer addresses in the output by relative offsets. + pMonitorInfo2->pName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pName - (ULONG_PTR)pMonitorInfo2); + + if (Level == 2) + { + pMonitorInfo2->pDLLName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pDLLName - (ULONG_PTR)pMonitorInfo2); + pMonitorInfo2->pEnvironment = (PWSTR)((ULONG_PTR)pMonitorInfo2->pEnvironment - (ULONG_PTR)pMonitorInfo2); + } +} + +DWORD +_RpcAddMonitor(WINSPOOL_HANDLE pName, WINSPOOL_MONITOR_CONTAINER* pMonitorContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeleteMonitor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pMonitorName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + DWORD _RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pMonitor, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; + DWORD i; + PBYTE p = pMonitor; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -22,6 +53,20 @@ EnumMonitorsW(pName, Level, pMonitor, cbBuf, pcbNeeded, pcReturned); dwErrorCode = GetLastError(); + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace absolute pointer addresses in the output by relative offsets. + for (i = 0; i < *pcReturned; i++) + { + _MarshallDownMonitorInfo(p, Level); + + if (Level == 1) + p += sizeof(MONITOR_INFO_1W); + else if (Level == 2) + p += sizeof(MONITOR_INFO_2W); + } + } + RpcRevertToSelf(); return dwErrorCode; } Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/notifications.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/notifications.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/notifications.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,92 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Printer Configuration Data + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD +_RpcClientFindFirstPrinterChangeNotification() +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcFindClosePrinterChangeNotification() +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcFindNextPrinterChangeNotification() +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcRemoteFindFirstPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR* pszLocalMachine, DWORD dwPrinterLocal, DWORD cbBuffer, BYTE* pBuffer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcRemoteFindFirstPrinterChangeNotificationEx(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR* pszLocalMachine, DWORD dwPrinterLocal, WINSPOOL_V2_NOTIFY_OPTIONS* pOptions) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcReplyClosePrinter(WINSPOOL_PRINTER_HANDLE* phNotify) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcReplyOpenPrinter(WINSPOOL_HANDLE pMachine, WINSPOOL_PRINTER_HANDLE* phPrinterNotify, DWORD dwPrinterRemote, DWORD dwType, DWORD cbBuffer, BYTE* pBuffer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcRouterFindFirstPrinterChangeNotificationOld() +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcRouterRefreshPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwColor, WINSPOOL_V2_NOTIFY_OPTIONS* pOptions, WINSPOOL_V2_NOTIFY_INFO** ppInfo) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcRouterReplyPrinter(WINSPOOL_PRINTER_HANDLE hNotify, DWORD fdwFlags, DWORD cbBuffer, BYTE* pBuffer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcRouterReplyPrinterEx(WINSPOOL_PRINTER_HANDLE hNotify, DWORD dwColor, DWORD fdwFlags, DWORD* pdwResult, DWORD dwReplyType, WINSPOOL_V2_UREPLY_PRINTER Reply) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcWaitForPrinterChange(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Flags, DWORD* pFlags) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/notifications.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/ports.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/ports.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/ports.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -7,10 +7,55 @@ #include "precomp.h" +static void +_MarshallDownPortInfo(PBYTE pPortInfo, DWORD Level) +{ + PPORT_INFO_2W pPortInfo2 = (PPORT_INFO_2W)pPortInfo; // PORT_INFO_1W is a subset of PORT_INFO_2W + + // Replace absolute pointer addresses in the output by relative offsets. + pPortInfo2->pPortName = (PWSTR)((ULONG_PTR)pPortInfo2->pPortName - (ULONG_PTR)pPortInfo2); + + if (Level == 2) + { + pPortInfo2->pDescription = (PWSTR)((ULONG_PTR)pPortInfo2->pDescription - (ULONG_PTR)pPortInfo2); + pPortInfo2->pMonitorName = (PWSTR)((ULONG_PTR)pPortInfo2->pMonitorName - (ULONG_PTR)pPortInfo2); + } +} + +DWORD +_RpcAddPort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR* pMonitorName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcAddPortEx(WINSPOOL_HANDLE pName, WINSPOOL_PORT_CONTAINER* pPortContainer, WINSPOOL_PORT_VAR_CONTAINER* pPortVarContainer, WCHAR* pMonitorName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcConfigurePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR* pPortName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeletePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR* pPortName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + DWORD _RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pPort, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; + DWORD i; + PBYTE p = pPort; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -22,6 +67,27 @@ EnumPortsW(pName, Level, pPort, cbBuf, pcbNeeded, pcReturned); dwErrorCode = GetLastError(); + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace absolute pointer addresses in the output by relative offsets. + for (i = 0; i < *pcReturned; i++) + { + _MarshallDownPortInfo(p, Level); + + if (Level == 1) + p += sizeof(PORT_INFO_1W); + else if (Level == 2) + p += sizeof(PORT_INFO_2W); + } + } + RpcRevertToSelf(); return dwErrorCode; } + +DWORD +_RpcSetPort(WINSPOOL_HANDLE pName, WCHAR* pPortName, WINSPOOL_PORT_CONTAINER* pPortContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdata.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdata.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdata.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,78 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Printer Configuration Data + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD +_RpcDeletePrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pValueName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeletePrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, const WCHAR* pValueName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeletePrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcEnumPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwIndex, WCHAR* pValueName, DWORD cbValueName, DWORD* pcbValueName, DWORD* pType, BYTE* pData, DWORD cbData, DWORD* pcbData) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcEnumPrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, WCHAR* pSubkey, DWORD cbSubkey, DWORD* pcbSubkey) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcEnumPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, BYTE* pEnumValues, DWORD cbEnumValues, DWORD* pcbEnumValues, DWORD* pnEnumValues) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pValueName, DWORD* pType, BYTE* pData, DWORD nSize, DWORD* pcbNeeded) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, const WCHAR* pValueName, DWORD* pType, BYTE* pData, DWORD nSize, DWORD* pcbNeeded) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcSetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pValueName, DWORD Type, BYTE* pData, DWORD cbData) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcSetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, const WCHAR* pValueName, DWORD Type, BYTE* pData, DWORD cbData) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdata.c ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdrivers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdrivers.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdrivers.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,64 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Printer Drivers + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD +_RpcAddPrinterDriver(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER* pDriverContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER* pDriverContainer, DWORD dwFileCopyFlags) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDrivers, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD* pdwServerMaxVersion, DWORD* pdwServerMinVersion) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDriverDirectory, DWORD cbBuf, DWORD* pcbNeeded) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printerdrivers.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printers.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printers.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -7,8 +7,68 @@ #include "precomp.h" -DWORD -_RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter) +static void +_MarshallDownPrinterInfo(PBYTE pPrinterInfo, DWORD Level) +{ + PPRINTER_INFO_1W pPrinterInfo1; + PPRINTER_INFO_2W pPrinterInfo2; + + // Replace absolute pointer addresses in the output by relative offsets. + if (Level == 1) + { + pPrinterInfo1 = (PPRINTER_INFO_1W)pPrinterInfo; + + pPrinterInfo1->pName = (PWSTR)((ULONG_PTR)pPrinterInfo1->pName - (ULONG_PTR)pPrinterInfo1); + pPrinterInfo1->pDescription = (PWSTR)((ULONG_PTR)pPrinterInfo1->pDescription - (ULONG_PTR)pPrinterInfo1); + pPrinterInfo1->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo1->pComment - (ULONG_PTR)pPrinterInfo1); + } + else if (Level == 2) + { + pPrinterInfo2 = (PPRINTER_INFO_2W)pPrinterInfo; + + pPrinterInfo2->pPrinterName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrinterName - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pShareName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pShareName - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pPortName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPortName - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pDriverName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDriverName - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo2->pComment - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pLocation = (PWSTR)((ULONG_PTR)pPrinterInfo2->pLocation - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pDevMode = (PDEVMODEW)((ULONG_PTR)pPrinterInfo2->pDevMode - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pSepFile = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSepFile - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pPrintProcessor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrintProcessor - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pDatatype = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDatatype - (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pParameters = (PWSTR)((ULONG_PTR)pPrinterInfo2->pParameters - (ULONG_PTR)pPrinterInfo2); + + if (pPrinterInfo2->pServerName) + pPrinterInfo2->pServerName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pServerName - (ULONG_PTR)pPrinterInfo2); + + if (pPrinterInfo2->pSecurityDescriptor) + pPrinterInfo2->pSecurityDescriptor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSecurityDescriptor - (ULONG_PTR)pPrinterInfo2); + } +} + +DWORD +_RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcAddPrinter(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER* pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, WINSPOOL_SECURITY_CONTAINER* pSecurityContainer, WINSPOOL_PRINTER_HANDLE* pHandle) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcAddPrinterEx(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER* pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, WINSPOOL_SECURITY_CONTAINER* pSecurityContainer, WINSPOOL_SPLCLIENT_CONTAINER* pClientInfo, WINSPOOL_PRINTER_HANDLE* pHandle) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcClosePrinter(WINSPOOL_PRINTER_HANDLE* phPrinter) { DWORD dwErrorCode; @@ -29,6 +89,13 @@ } DWORD +_RpcDeletePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD _RpcEndDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter) { DWORD dwErrorCode; @@ -70,6 +137,8 @@ _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; + DWORD i; + PBYTE p = pPrinterEnum; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -81,8 +150,36 @@ EnumPrintersW(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned); dwErrorCode = GetLastError(); - RpcRevertToSelf(); - return dwErrorCode; + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace absolute pointer addresses in the output by relative offsets. + for (i = 0; i < *pcReturned; i++) + { + _MarshallDownPrinterInfo(p, Level); + + if (Level == 1) + p += sizeof(PRINTER_INFO_1W); + else if (Level == 2) + p += sizeof(PRINTER_INFO_2W); + } + } + + RpcRevertToSelf(); + return dwErrorCode; +} + +DWORD +_RpcFlushPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcWritten, DWORD cSleep) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcGetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE* pPrinter, DWORD cbBuf, DWORD* pcbNeeded) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; } DWORD @@ -110,7 +207,14 @@ } DWORD -_RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcNoBytesRead) +_RpcOpenPrinterEx(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* pHandle, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, DWORD AccessRequired, WINSPOOL_SPLCLIENT_CONTAINER* pClientInfo) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcNoBytesRead) { DWORD dwErrorCode; @@ -129,6 +233,34 @@ } DWORD +_RpcResetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcResetPrinterEx() +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcSeekPrinter() +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcSetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_PRINTER_CONTAINER* pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, WINSPOOL_SECURITY_CONTAINER* pSecurityContainer, DWORD Command) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD _RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_DOC_INFO_CONTAINER* pDocInfoContainer, DWORD* pJobId) { DWORD dwErrorCode; @@ -167,7 +299,7 @@ } DWORD -_RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcWritten) +_RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcWritten) { DWORD dwErrorCode; Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printprocessors.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printprocessors.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printprocessors.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -7,17 +7,40 @@ #include "precomp.h" +static void +_MarshallDownDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1) +{ + // Replace absolute pointer addresses in the output by relative offsets. + pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName - (ULONG_PTR)pDatatypesInfo1); +} + +static void +_MarshallDownPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1) +{ + // Replace absolute pointer addresses in the output by relative offsets. + pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName - (ULONG_PTR)pPrintProcessorInfo1); +} + DWORD -_RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPathName, WCHAR *pPrintProcessorName) +_RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPathName, WCHAR* pPrintProcessorName) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; } DWORD -_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR *pPrintProcessorName, DWORD Level, BYTE *pDatatypes, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) +_RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProcessorName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR* pPrintProcessorName, DWORD Level, BYTE* pDatatypes, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; + DWORD i; + PBYTE p = pDatatypes; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -29,14 +52,26 @@ EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned); dwErrorCode = GetLastError(); + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace absolute pointer addresses in the output by relative offsets. + for (i = 0; i < *pcReturned; i++) + { + _MarshallDownDatatypesInfo((PDATATYPES_INFO_1W)p); + p += sizeof(DATATYPES_INFO_1W); + } + } + RpcRevertToSelf(); return dwErrorCode; } DWORD -_RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorInfo, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) +_RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorInfo, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; + DWORD i; + PBYTE p = pPrintProcessorInfo; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -48,12 +83,22 @@ EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned); dwErrorCode = GetLastError(); + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace absolute pointer addresses in the output by relative offsets. + for (i = 0; i < *pcReturned; i++) + { + _MarshallDownPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p); + p += sizeof(PRINTPROCESSOR_INFO_1W); + } + } + RpcRevertToSelf(); return dwErrorCode; } DWORD -_RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorDirectory, DWORD cbBuf, DWORD *pcbNeeded) +_RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorDirectory, DWORD cbBuf, DWORD* pcbNeeded) { DWORD dwErrorCode; Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printproviders.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printproviders.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printproviders.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,22 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Print Providers + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD +_RpcAddPrintProvidor(WINSPOOL_HANDLE pName, WINSPOOL_PROVIDOR_CONTAINER* pProvidorContainer) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} + +DWORD +_RpcDeletePrintProvidor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProviderName) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/printproviders.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/rpcstubs.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/rpcstubs.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/rpcstubs.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -8,168 +8,21 @@ #include "precomp.h" DWORD -_RpcAddPrinter(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, WINSPOOL_PRINTER_HANDLE *pHandle) +_RpcCreatePrinterIC(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_GDI_HANDLE* pHandle, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; } DWORD -_RpcDeletePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) +_RpcPlayGdiScriptOnPrinterIC(WINSPOOL_GDI_HANDLE hPrinterIC, BYTE* pIn, DWORD cIn, BYTE* pOut, DWORD cOut, DWORD ul) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; } DWORD -_RpcSetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, DWORD Command) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcGetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pPrinter, DWORD cbBuf, DWORD *pcbNeeded) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPrinterDriver(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDrivers, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDriverDirectory, DWORD cbBuf, DWORD *pcbNeeded) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcGetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pValueName, DWORD *pType, BYTE *pData, DWORD nSize, DWORD *pcbNeeded) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcSetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pValueName, DWORD Type, BYTE *pData, DWORD cbData) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcWaitForPrinterChange(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Flags, DWORD *pFlags) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddForm(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER *pFormInfoContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeleteForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcGetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcSetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, WINSPOOL_FORM_CONTAINER *pFormInfoContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEnumForms(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pMonitorName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcConfigurePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcCreatePrinterIC(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_GDI_HANDLE *pHandle, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcPlayGdiScriptOnPrinterIC(WINSPOOL_GDI_HANDLE hPrinterIC, BYTE *pIn, DWORD cIn, BYTE *pOut, DWORD cOut, DWORD ul) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrinterIC(WINSPOOL_GDI_HANDLE *phPrinterIC) +_RpcDeletePrinterIC(WINSPOOL_GDI_HANDLE* phPrinterIC) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; @@ -190,147 +43,7 @@ } DWORD -_RpcPrinterMessageBox(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Error, ULONG_PTR hWnd, WCHAR *pText, WCHAR *pCaption, DWORD dwType) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddMonitor(WINSPOOL_HANDLE pName, WINSPOOL_MONITOR_CONTAINER *pMonitorContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeleteMonitor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pMonitorName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPrintProcessorName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPrintProvidor(WINSPOOL_HANDLE pName, WINSPOOL_PROVIDOR_CONTAINER *pProvidorContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrintProvidor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPrintProviderName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcResetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pDatatype, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD *pdwServerMaxVersion, DWORD *pdwServerMinVersion) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcClientFindFirstPrinterChangeNotification() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcFindNextPrinterChangeNotification() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcFindClosePrinterChangeNotification() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcRouterFindFirstPrinterChangeNotificationOld() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcReplyOpenPrinter(WINSPOOL_HANDLE pMachine, WINSPOOL_PRINTER_HANDLE *phPrinterNotify, DWORD dwPrinterRemote, DWORD dwType, DWORD cbBuffer, BYTE *pBuffer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcRouterReplyPrinter(WINSPOOL_PRINTER_HANDLE hNotify, DWORD fdwFlags, DWORD cbBuffer, BYTE *pBuffer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcReplyClosePrinter(WINSPOOL_PRINTER_HANDLE *phNotify) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPortEx(WINSPOOL_HANDLE pName, WINSPOOL_PORT_CONTAINER *pPortContainer, WINSPOOL_PORT_VAR_CONTAINER *pPortVarContainer, WCHAR *pMonitorName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcRemoteFindFirstPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR *pszLocalMachine, DWORD dwPrinterLocal, DWORD cbBuffer, BYTE *pBuffer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcResetPrinterEx() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcRemoteFindFirstPrinterChangeNotificationEx(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR *pszLocalMachine, DWORD dwPrinterLocal, WINSPOOL_V2_NOTIFY_OPTIONS *pOptions) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcRouterReplyPrinterEx(WINSPOOL_PRINTER_HANDLE hNotify, DWORD dwColor, DWORD fdwFlags, DWORD *pdwResult, DWORD dwReplyType, WINSPOOL_V2_UREPLY_PRINTER Reply) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcRouterRefreshPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwColor, WINSPOOL_V2_NOTIFY_OPTIONS *pOptions, WINSPOOL_V2_NOTIFY_INFO **ppInfo) +_RpcPrinterMessageBox(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Error, ULONG_PTR hWnd, WCHAR* pText, WCHAR* pCaption, DWORD dwType) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; @@ -338,41 +51,6 @@ DWORD _RpcSetAllocFailCount() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcOpenPrinterEx(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE *pHandle, WCHAR *pDatatype, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, DWORD AccessRequired, WINSPOOL_SPLCLIENT_CONTAINER *pClientInfo) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPrinterEx(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, WINSPOOL_SPLCLIENT_CONTAINER *pClientInfo, WINSPOOL_PRINTER_HANDLE *pHandle) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcSetPort(WINSPOOL_HANDLE pName, WCHAR *pPortName, WINSPOOL_PORT_CONTAINER *pPortContainer) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEnumPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwIndex, WCHAR *pValueName, DWORD cbValueName, DWORD *pcbValueName, DWORD *pType, BYTE *pData, DWORD cbData, DWORD *pcbData) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pValueName) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; @@ -400,91 +78,21 @@ } DWORD -_RpcSetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, const WCHAR *pValueName, DWORD Type, BYTE *pData, DWORD cbData) +_RpcAddPerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR* pPrinterName, const WCHAR* pPrintServer, const WCHAR* pProvider) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; } DWORD -_RpcGetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, const WCHAR *pValueName, DWORD *pType, BYTE *pData, DWORD nSize, DWORD *pcbNeeded) +_RpcDeletePerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR* pPrinterName) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; } DWORD -_RpcEnumPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, BYTE *pEnumValues, DWORD cbEnumValues, DWORD *pcbEnumValues, DWORD *pnEnumValues) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEnumPrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, WCHAR *pSubkey, DWORD cbSubkey, DWORD *pcbSubkey) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, const WCHAR *pValueName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcSeekPrinter() -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR *pPrinterName, const WCHAR *pPrintServer, const WCHAR *pProvider) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcDeletePerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR *pPrinterName) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEnumPerMachineConnections(WINSPOOL_HANDLE pServer, BYTE *pPrinterEnum, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcXcvData(WINSPOOL_PRINTER_HANDLE hXcv, const WCHAR *pszDataName, BYTE *pInputData, DWORD cbInputData, BYTE *pOutputData, DWORD cbOutputData, DWORD *pcbOutputNeeded, DWORD *pdwStatus) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer, DWORD dwFileCopyFlags) +_RpcEnumPerMachineConnections(WINSPOOL_HANDLE pServer, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; @@ -519,14 +127,7 @@ } DWORD -_RpcFlushPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcWritten, DWORD cSleep) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcSendRecvBidiData(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pAction, WINSPOOL_BIDI_REQUEST_CONTAINER *pReqData, WINSPOOL_BIDI_RESPONSE_CONTAINER **ppRespData) +_RpcSendRecvBidiData(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pAction, WINSPOOL_BIDI_REQUEST_CONTAINER* pReqData, WINSPOOL_BIDI_RESPONSE_CONTAINER** ppRespData) { UNIMPLEMENTED; return ERROR_INVALID_FUNCTION; Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/xcv.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/xcv.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/xcv.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,15 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Xcv* functions + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD +_RpcXcvData(WINSPOOL_PRINTER_HANDLE hXcv, const WCHAR* pszDataName, BYTE* pInputData, DWORD cbInputData, BYTE* pOutputData, DWORD cbOutputData, DWORD* pcbOutputNeeded, DWORD* pdwStatus) +{ + UNIMPLEMENTED; + return ERROR_INVALID_FUNCTION; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolsv/xcv.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/CMakeLists.txt [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/CMakeLists.txt [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -6,6 +6,8 @@ list(APPEND SOURCE jobs.c main.c + monitors.c + ports.c precomp.h printers.c printprocessors.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -13,7 +13,7 @@ PJOB_INFO_1W pJobInfo1; PJOB_INFO_2W pJobInfo2; - // Replace absolute pointer addresses in the output by relative offsets. + // Replace relative offset addresses in the output by absolute pointers. if (Level == 1) { pJobInfo1 = (PJOB_INFO_1W)pJobInfo; Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/monitors.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/monitors.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/monitors.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,60 @@ +/* + * PROJECT: ReactOS Spooler API + * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Print Monitors + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +static void +_MarshallUpMonitorInfo(PBYTE pMonitorInfo, DWORD Level) +{ + PMONITOR_INFO_2W pMonitorInfo2 = (PMONITOR_INFO_2W)pMonitorInfo; // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W + + // Replace relative offset addresses in the output by absolute pointers. + pMonitorInfo2->pName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pName + (ULONG_PTR)pMonitorInfo2); + + if (Level == 2) + { + pMonitorInfo2->pDLLName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pDLLName + (ULONG_PTR)pMonitorInfo2); + pMonitorInfo2->pEnvironment = (PWSTR)((ULONG_PTR)pMonitorInfo2->pEnvironment + (ULONG_PTR)pMonitorInfo2); + } +} + +BOOL WINAPI +EnumMonitorsW(PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) +{ + DWORD dwErrorCode; + DWORD i; + PBYTE p = pMonitors; + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcEnumMonitors(pName, Level, pMonitors, cbBuf, pcbNeeded, pcReturned); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEnumPorts failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace relative offset addresses in the output by absolute pointers. + for (i = 0; i < *pcReturned; i++) + { + _MarshallUpMonitorInfo(p, Level); + + if (Level == 1) + p += sizeof(MONITOR_INFO_1W); + else if (Level == 2) + p += sizeof(MONITOR_INFO_2W); + } + } + + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/monitors.c ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/ports.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/ports.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/ports.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -0,0 +1,60 @@ +/* + * PROJECT: ReactOS Spooler API + * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Ports + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +static void +_MarshallUpPortInfo(PBYTE pPortInfo, DWORD Level) +{ + PPORT_INFO_2W pPortInfo2 = (PPORT_INFO_2W)pPortInfo; // PORT_INFO_1W is a subset of PORT_INFO_2W + + // Replace relative offset addresses in the output by absolute pointers. + pPortInfo2->pPortName = (PWSTR)((ULONG_PTR)pPortInfo2->pPortName + (ULONG_PTR)pPortInfo2); + + if (Level == 2) + { + pPortInfo2->pDescription = (PWSTR)((ULONG_PTR)pPortInfo2->pDescription + (ULONG_PTR)pPortInfo2); + pPortInfo2->pMonitorName = (PWSTR)((ULONG_PTR)pPortInfo2->pMonitorName + (ULONG_PTR)pPortInfo2); + } +} + +BOOL WINAPI +EnumPortsW(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) +{ + DWORD dwErrorCode; + DWORD i; + PBYTE p = pPorts; + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcEnumPorts(pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEnumPorts failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace relative offset addresses in the output by absolute pointers. + for (i = 0; i < *pcReturned; i++) + { + _MarshallUpPortInfo(p, Level); + + if (Level == 1) + p += sizeof(PORT_INFO_1W); + else if (Level == 2) + p += sizeof(PORT_INFO_2W); + } + } + + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/ports.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -7,6 +7,45 @@ #include "precomp.h" +static void +_MarshallUpPrinterInfo(PBYTE pPrinterInfo, DWORD Level) +{ + PPRINTER_INFO_1W pPrinterInfo1; + PPRINTER_INFO_2W pPrinterInfo2; + + // Replace relative offset addresses in the output by absolute pointers. + if (Level == 1) + { + pPrinterInfo1 = (PPRINTER_INFO_1W)pPrinterInfo; + + pPrinterInfo1->pName = (PWSTR)((ULONG_PTR)pPrinterInfo1->pName + (ULONG_PTR)pPrinterInfo1); + pPrinterInfo1->pDescription = (PWSTR)((ULONG_PTR)pPrinterInfo1->pDescription + (ULONG_PTR)pPrinterInfo1); + pPrinterInfo1->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo1->pComment + (ULONG_PTR)pPrinterInfo1); + } + else if (Level == 2) + { + pPrinterInfo2 = (PPRINTER_INFO_2W)pPrinterInfo; + + pPrinterInfo2->pPrinterName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrinterName + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pShareName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pShareName + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pPortName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPortName + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pDriverName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDriverName + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo2->pComment + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pLocation = (PWSTR)((ULONG_PTR)pPrinterInfo2->pLocation + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pDevMode = (PDEVMODEW)((ULONG_PTR)pPrinterInfo2->pDevMode + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pSepFile = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSepFile + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pPrintProcessor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrintProcessor + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pDatatype = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDatatype + (ULONG_PTR)pPrinterInfo2); + pPrinterInfo2->pParameters = (PWSTR)((ULONG_PTR)pPrinterInfo2->pParameters + (ULONG_PTR)pPrinterInfo2); + + if (pPrinterInfo2->pServerName) + pPrinterInfo2->pServerName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pServerName + (ULONG_PTR)pPrinterInfo2); + + if (pPrinterInfo2->pSecurityDescriptor) + pPrinterInfo2->pSecurityDescriptor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSecurityDescriptor + (ULONG_PTR)pPrinterInfo2); + } +} + static DWORD _StartDocPrinterSpooled(PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1, PADDJOB_INFO_1W pAddJobInfo1) { @@ -96,33 +135,6 @@ } BOOL WINAPI -EnumPrintersA(DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) -{ - return FALSE; -} - -BOOL WINAPI -EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) -{ - DWORD dwErrorCode; - - // Do the RPC call - RpcTryExcept - { - dwErrorCode = _RpcEnumPrinters(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - dwErrorCode = RpcExceptionCode(); - ERR("_RpcEnumPrinters failed with exception code %lu!\n", dwErrorCode); - } - RpcEndExcept; - - SetLastError(dwErrorCode); - return (dwErrorCode == ERROR_SUCCESS); -} - -BOOL WINAPI ClosePrinter(HANDLE hPrinter) { DWORD dwErrorCode; @@ -271,6 +283,49 @@ } Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); +} + +BOOL WINAPI +EnumPrintersA(DWORD Flags, PSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) +{ + return FALSE; +} + +BOOL WINAPI +EnumPrintersW(DWORD Flags, PWSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) +{ + DWORD dwErrorCode; + DWORD i; + PBYTE p = pPrinterEnum; + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcEnumPrinters(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEnumPrinters failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace relative offset addresses in the output by absolute pointers. + for (i = 0; i < *pcReturned; i++) + { + _MarshallUpPrinterInfo(p, Level); + + if (Level == 1) + p += sizeof(PRINTER_INFO_1W); + else if (Level == 2) + p += sizeof(PRINTER_INFO_2W); + } + } + SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); } Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printprocessors.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printprocessors.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printprocessors.c [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -7,58 +7,94 @@ #include "precomp.h" +static void +_MarshallUpDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1) +{ + // Replace relative offset addresses in the output by absolute pointers. + pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName + (ULONG_PTR)pDatatypesInfo1); +} + +static void +_MarshallUpPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1) +{ + // Replace relative offset addresses in the output by absolute pointers. + pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName + (ULONG_PTR)pPrintProcessorInfo1); +} + BOOL WINAPI -EnumPrintProcessorDatatypesA(LPSTR pName, LPSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) +EnumPrintProcessorDatatypesA(PSTR pName, LPSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { return FALSE; } BOOL WINAPI -EnumPrintProcessorDatatypesW(LPWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) +EnumPrintProcessorDatatypesW(PWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { - BOOL bReturnValue = FALSE; DWORD dwErrorCode; + DWORD i; + PBYTE p = pDatatypes; // Do the RPC call RpcTryExcept { dwErrorCode = _RpcEnumPrintProcessorDatatypes(pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned); - SetLastError(dwErrorCode); - bReturnValue = (dwErrorCode == ERROR_SUCCESS); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { - ERR("_RpcEnumPrintProcessorDatatypes failed with exception code %lu!\n", RpcExceptionCode()); + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEnumPrintProcessorDatatypes failed with exception code %lu!\n", dwErrorCode); } RpcEndExcept; - return bReturnValue; + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace relative offset addresses in the output by absolute pointers. + for (i = 0; i < *pcReturned; i++) + { + _MarshallUpDatatypesInfo((PDATATYPES_INFO_1W)p); + p += sizeof(DATATYPES_INFO_1W); + } + } + + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI -EnumPrintProcessorsW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) +EnumPrintProcessorsW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { - BOOL bReturnValue = FALSE; DWORD dwErrorCode; + DWORD i; + PBYTE p = pPrintProcessorInfo; // Do the RPC call RpcTryExcept { dwErrorCode = _RpcEnumPrintProcessors(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned); - SetLastError(dwErrorCode); - bReturnValue = (dwErrorCode == ERROR_SUCCESS); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { - ERR("_RpcEnumPrintProcessors failed with exception code %lu!\n", RpcExceptionCode()); + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEnumPrintProcessors failed with exception code %lu!\n", dwErrorCode); } RpcEndExcept; - return bReturnValue; + if (dwErrorCode == ERROR_SUCCESS) + { + // Replace relative offset addresses in the output by absolute pointers. + for (i = 0; i < *pcReturned; i++) + { + _MarshallUpPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p); + p += sizeof(PRINTPROCESSOR_INFO_1W); + } + } + + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI -GetPrintProcessorDirectoryW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded) +GetPrintProcessorDirectoryW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded) { BOOL bReturnValue = FALSE; DWORD dwErrorCode; Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/winspool.spec URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/winspool.spec [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/winspool.spec [iso-8859-1] Fri Jul 17 10:57:10 2015 @@ -86,9 +86,9 @@ 185 stdcall EnumJobsA(long long long long ptr long ptr ptr) 186 stdcall EnumJobsW(long long long long ptr long ptr ptr) 187 stub EnumMonitorsA -188 stub EnumMonitorsW +188 stdcall EnumMonitorsW(wstr long ptr long ptr ptr) 189 stub EnumPortsA -190 stub EnumPortsW +190 stdcall EnumPortsW(wstr long ptr long ptr ptr) 191 stdcall EnumPrintProcessorDatatypesA(ptr ptr long ptr long ptr ptr) 192 stdcall EnumPrintProcessorDatatypesW(ptr ptr long ptr long ptr ptr) 193 stub EnumPrintProcessorsA
9 years, 5 months
1
0
0
0
[cfinck] 68407: [FORMATTING] Tabs -> Spaces
by cfinck@svn.reactos.org
Author: cfinck Date: Thu Jul 16 15:24:40 2015 New Revision: 68407 URL:
http://svn.reactos.org/svn/reactos?rev=68407&view=rev
Log: [FORMATTING] Tabs -> Spaces Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c [iso-8859-1] Thu Jul 16 15:24:40 2015 @@ -76,7 +76,7 @@ { case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hinstDLL); - hProcessHeap = GetProcessHeap(); + hProcessHeap = GetProcessHeap(); break; }
9 years, 5 months
1
0
0
0
[cfinck] 68406: Merge r67713 and r67936 (Eric's parport driver) from trunk
by cfinck@svn.reactos.org
Author: cfinck Date: Thu Jul 16 15:12:50 2015 New Revision: 68406 URL:
http://svn.reactos.org/svn/reactos?rev=68406&view=rev
Log: Merge r67713 and r67936 (Eric's parport driver) from trunk Added: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/fdo.c - copied, changed from r67713, trunk/reactos/drivers/parallel/parport/fdo.c branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/hardware.h - copied unchanged from r67936, trunk/reactos/drivers/parallel/parport/hardware.h branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/misc.c - copied, changed from r67713, trunk/reactos/drivers/parallel/parport/misc.c branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/pdo.c - copied, changed from r67713, trunk/reactos/drivers/parallel/parport/pdo.c Modified: branches/colins-printing-for-freedom/ (props changed) branches/colins-printing-for-freedom/reactos/ (props changed) branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/CMakeLists.txt branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.c branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.h Propchange: branches/colins-printing-for-freedom/ ------------------------------------------------------------------------------ svn:mergeinfo = /trunk:67713,67936 Propchange: branches/colins-printing-for-freedom/reactos/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jul 16 15:12:50 2015 @@ -20,3 +20,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 +/trunk/reactos:67713,67936 Modified: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/CMakeLists.txt [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/CMakeLists.txt [iso-8859-1] Thu Jul 16 15:12:50 2015 @@ -1,5 +1,16 @@ -add_library(parport SHARED parport.c parport.rc) +list(APPEND SOURCE + fdo.c + misc.c + pdo.c + parport.c + parport.h) + +add_library(parport SHARED + ${SOURCE} + parport.rc) + set_module_type(parport kernelmodedriver) +add_pch(parport parport.h SOURCE) add_importlibs(parport ntoskrnl hal) add_cd_file(TARGET parport DESTINATION reactos/system32/drivers FOR all) Copied: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/fdo.c (from r67713, trunk/reactos/drivers/parallel/parport/fdo.c) URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- trunk/reactos/drivers/parallel/parport/fdo.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/fdo.c [iso-8859-1] Thu Jul 16 15:12:50 2015 @@ -6,37 +6,6 @@ */ #include "parport.h" - -/* - * The following constants describe the various signals of the printer port - * hardware. Note that the hardware inverts some signals and that some - * signals are active low. An example is LP_STROBE, which must be programmed - * with 1 for being active and 0 for being inactive, because the strobe signal - * gets inverted, but it is also active low. - */ - -/* - * bit defines for 8255 status port - * base + 1 - * accessed with LP_S(minor), which gets the byte... - */ -#define LP_PBUSY 0x80 /* inverted input, active high */ -#define LP_PACK 0x40 /* unchanged input, active low */ -#define LP_POUTPA 0x20 /* unchanged input, active high */ -#define LP_PSELECD 0x10 /* unchanged input, active high */ -#define LP_PERRORP 0x08 /* unchanged input, active low */ - -/* - * defines for 8255 control port - * base + 2 - * accessed with LP_C(minor) - */ -#define LP_PINTEN 0x10 -#define LP_PSELECP 0x08 /* inverted output, active low */ -#define LP_PINITP 0x04 /* unchanged output, active low */ -#define LP_PAUTOLF 0x02 /* inverted output, active low */ -#define LP_PSTROBE 0x01 /* inverted output, active low */ - /* FUNCTIONS ****************************************************************/ @@ -86,11 +55,7 @@ DeviceExtension->Common.IsFDO = TRUE; DeviceExtension->Common.PnpState = dsStopped; - DeviceExtension->ParallelPortNumber = IoGetConfigurationInformation()->ParallelCount++; - if (pLptPortNumber == NULL) - DeviceExtension->LptPort = DeviceExtension->ParallelPortNumber + 1; - else - DeviceExtension->LptPort = *pLptPortNumber; + DeviceExtension->PortNumber = IoGetConfigurationInformation()->ParallelCount++; DeviceExtension->Pdo = Pdo; Status = IoAttachDeviceToDeviceStackSafe(Fdo, @@ -141,127 +106,185 @@ IN PCM_RESOURCE_LIST ResourceListTranslated) { PFDO_DEVICE_EXTENSION DeviceExtension; + ULONG i; +// ULONG Vector = 0; +// KIRQL Dirql = 0; +// KAFFINITY Affinity = 0; +// KINTERRUPT_MODE InterruptMode = Latched; +// BOOLEAN ShareInterrupt = TRUE; + + DPRINT("FdoStartDevice ()\n"); + + DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + ASSERT(DeviceExtension); + ASSERT(DeviceExtension->Common.IsFDO == TRUE); + + if (!ResourceList) + { + DPRINT1("No allocated resources sent to driver\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + if (ResourceList->Count != 1) + { + DPRINT1("Wrong number of allocated resources sent to driver\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + if ((ResourceList->List[0].PartialResourceList.Version != 1) || + (ResourceList->List[0].PartialResourceList.Revision != 1) || + (ResourceListTranslated->List[0].PartialResourceList.Version != 1) || + (ResourceListTranslated->List[0].PartialResourceList.Revision != 1)) + { + DPRINT1("Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n", + ResourceList->List[0].PartialResourceList.Version, + ResourceList->List[0].PartialResourceList.Revision, + ResourceListTranslated->List[0].PartialResourceList.Version, + ResourceListTranslated->List[0].PartialResourceList.Revision); + return STATUS_REVISION_MISMATCH; + } + + DeviceExtension->BaseAddress = 0; + + for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++) + { + PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i]; + PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorTranslated = &ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[i]; + + switch (PartialDescriptor->Type) + { + case CmResourceTypePort: + DPRINT("Port: BaseAddress 0x%lx Length %lu\n", + PartialDescriptor->u.Port.Start.u.LowPart, + PartialDescriptor->u.Port.Length); + + if (DeviceExtension->BaseAddress == 0) + { + if (PartialDescriptor->u.Port.Length < 8) + return STATUS_INSUFFICIENT_RESOURCES; + + DeviceExtension->BaseAddress = PartialDescriptor->u.Port.Start.u.LowPart; + } + break; + + case CmResourceTypeInterrupt: + DPRINT("Interrupt: Level %lu Vector %lu\n", + PartialDescriptorTranslated->u.Interrupt.Level, + PartialDescriptorTranslated->u.Interrupt.Vector); + +// Dirql = (KIRQL)PartialDescriptorTranslated->u.Interrupt.Level; +// Vector = PartialDescriptorTranslated->u.Interrupt.Vector; +// Affinity = PartialDescriptorTranslated->u.Interrupt.Affinity; + +// if (PartialDescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED) +// InterruptMode = Latched; +// else +// InterruptMode = LevelSensitive; + +// ShareInterrupt = (PartialDescriptorTranslated->ShareDisposition == CmResourceShareShared); + break; + + default: + DPRINT1("Other ressource: \n"); + break; + } + } + + DPRINT("New LPT port: Base 0x%lx\n", + DeviceExtension->BaseAddress); + + if (!DeviceExtension->BaseAddress) + return STATUS_INSUFFICIENT_RESOURCES; + +#if 0 + if (!Dirql) + return STATUS_INSUFFICIENT_RESOURCES; +#endif + + DeviceExtension->Common.PnpState = dsStarted; + + + /* We don't really care if the call succeeded or not... */ + + return STATUS_SUCCESS; +} + + +static +NTSTATUS +FdoCreateRawParallelPdo( + IN PDEVICE_OBJECT DeviceObject) +{ + PFDO_DEVICE_EXTENSION FdoDeviceExtension; + PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL; + PDEVICE_OBJECT Pdo = NULL; WCHAR DeviceNameBuffer[32]; WCHAR LinkNameBuffer[32]; WCHAR LptPortBuffer[32]; UNICODE_STRING DeviceName; UNICODE_STRING LinkName; UNICODE_STRING LptPort; - ULONG i; -// ULONG Vector = 0; -// KIRQL Dirql = 0; -// KAFFINITY Affinity = 0; -// KINTERRUPT_MODE InterruptMode = Latched; -// BOOLEAN ShareInterrupt = TRUE; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName; HANDLE KeyHandle; NTSTATUS Status; - DPRINT("FdoStartDevice ()\n"); - - DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - ASSERT(DeviceExtension); - ASSERT(DeviceExtension->Common.IsFDO == TRUE); - - if (!ResourceList) - { - DPRINT1("No allocated resources sent to driver\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - if (ResourceList->Count != 1) - { - DPRINT1("Wrong number of allocated resources sent to driver\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - if ((ResourceList->List[0].PartialResourceList.Version != 1) || - (ResourceList->List[0].PartialResourceList.Revision != 1) || - (ResourceListTranslated->List[0].PartialResourceList.Version != 1) || - (ResourceListTranslated->List[0].PartialResourceList.Revision != 1)) - { - DPRINT1("Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n", - ResourceList->List[0].PartialResourceList.Version, - ResourceList->List[0].PartialResourceList.Revision, - ResourceListTranslated->List[0].PartialResourceList.Version, - ResourceListTranslated->List[0].PartialResourceList.Revision); - return STATUS_REVISION_MISMATCH; - } - - DeviceExtension->BaseAddress = 0; - - for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++) - { - PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i]; - PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorTranslated = &ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[i]; - - switch (PartialDescriptor->Type) - { - case CmResourceTypePort: - DPRINT("Port: BaseAddress 0x%lx Length %lu\n", - PartialDescriptor->u.Port.Start.u.LowPart, - PartialDescriptor->u.Port.Length); - - if (DeviceExtension->BaseAddress == 0) - { - if (PartialDescriptor->u.Port.Length < 8) - return STATUS_INSUFFICIENT_RESOURCES; - - DeviceExtension->BaseAddress = PartialDescriptor->u.Port.Start.u.LowPart; - } - break; - - case CmResourceTypeInterrupt: - DPRINT("Interrupt: Level %lu Vector %lu\n", - PartialDescriptorTranslated->u.Interrupt.Level, - PartialDescriptorTranslated->u.Interrupt.Vector); - -// Dirql = (KIRQL)PartialDescriptorTranslated->u.Interrupt.Level; -// Vector = PartialDescriptorTranslated->u.Interrupt.Vector; -// Affinity = PartialDescriptorTranslated->u.Interrupt.Affinity; - -// if (PartialDescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED) -// InterruptMode = Latched; -// else -// InterruptMode = LevelSensitive; - -// ShareInterrupt = (PartialDescriptorTranslated->ShareDisposition == CmResourceShareShared); - break; - - default: - DPRINT1("Other ressource: \n"); - break; - } - } - - DPRINT("New LPT port: Base 0x%lx\n", - DeviceExtension->BaseAddress); - - if (!DeviceExtension->BaseAddress) - return STATUS_INSUFFICIENT_RESOURCES; - -#if 0 - if (!Dirql) - return STATUS_INSUFFICIENT_RESOURCES; -#endif - - /* Create link \DosDevices\LPTX -> \Device\ParallelPortX */ - swprintf(DeviceNameBuffer, L"\\Device\\ParallelPort%lu", DeviceExtension->ParallelPortNumber); - swprintf(LinkNameBuffer, L"\\DosDevices\\LPT%lu", DeviceExtension->LptPort); - swprintf(LptPortBuffer, L"LPT%lu", DeviceExtension->LptPort); - RtlInitUnicodeString(&DeviceName, DeviceNameBuffer); + DPRINT("FdoCreateRawParallelPdo()\n"); + + FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* Create new device object */ + swprintf(DeviceNameBuffer, + L"\\Device\\Parallel%lu", + FdoDeviceExtension->PortNumber); + RtlInitUnicodeString(&DeviceName, + DeviceNameBuffer); + + Status = IoCreateDevice(DeviceObject->DriverObject, + sizeof(PDO_DEVICE_EXTENSION), + &DeviceName, + FILE_DEVICE_CONTROLLER, + 0, + FALSE, + &Pdo); + if (!NT_SUCCESS(Status)) + { + DPRINT1("IoCreateDevice() failed with status 0x%08x\n", Status); + goto done; + } + + Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE; + Pdo->Flags |= DO_POWER_PAGABLE; + + PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension; + RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION)); + + PdoDeviceExtension->Common.IsFDO = FALSE; + PdoDeviceExtension->Common.PnpState = dsStopped; + + Pdo->StackSize = DeviceObject->StackSize + 1; + + FdoDeviceExtension->AttachedRawPdo = Pdo; + PdoDeviceExtension->AttachedFdo = DeviceObject; + + PdoDeviceExtension->PortNumber = FdoDeviceExtension->PortNumber; + PdoDeviceExtension->LptPort = PdoDeviceExtension->PortNumber + 1; + + + /* Create link \DosDevices\LPTX -> \Device\ParallelY */ + swprintf(LinkNameBuffer, L"\\DosDevices\\LPT%lu", PdoDeviceExtension->LptPort); RtlInitUnicodeString(&LinkName, LinkNameBuffer); - RtlInitUnicodeString(&LptPort, LptPortBuffer); Status = IoCreateSymbolicLink(&LinkName, &DeviceName); if (!NT_SUCCESS(Status)) { DPRINT1("IoCreateSymbolicLink() failed with status 0x%08x\n", Status); - return Status; - } - + goto done; + } + + swprintf(LptPortBuffer, L"LPT%lu", PdoDeviceExtension->LptPort); + RtlInitUnicodeString(&LptPort, LptPortBuffer); /* Write an entry value under HKLM\HARDWARE\DeviceMap\PARALLEL PORTS. */ /* This step is not mandatory, so do not exit in case of error. */ @@ -292,10 +315,66 @@ ZwClose(KeyHandle); } - DeviceExtension->Common.PnpState = dsStarted; - - - /* We don't really care if the call succeeded or not... */ + Pdo->Flags |= DO_BUFFERED_IO; + Pdo->Flags &= ~DO_DEVICE_INITIALIZING; + +done: + if (!NT_SUCCESS(Status)) + { + if (Pdo) + { + ASSERT(PdoDeviceExtension); + IoDeleteDevice(Pdo); + } + } + + return Status; +} + + +static +NTSTATUS +FdoQueryBusRelations( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + PIO_STACK_LOCATION IrpSp) +{ + PFDO_DEVICE_EXTENSION DeviceExtension; + PDEVICE_RELATIONS DeviceRelations; + ULONG Size; + ULONG i; + ULONG PdoCount = 0; + NTSTATUS Status; + + UNREFERENCED_PARAMETER(IrpSp); + + DPRINT("FdoQueryBusRelations()\n"); + + DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + ASSERT(DeviceExtension->Common.IsFDO); + + /* TODO: Enumerate parallel devices and create their PDOs */ + + Status = FdoCreateRawParallelPdo(DeviceObject); + if (!NT_SUCCESS(Status)) + return Status; + + PdoCount++; + + /* Allocate a buffer for the device relations */ + Size = sizeof(DEVICE_RELATIONS) + sizeof(PDEVICE_OBJECT) * (PdoCount - 1); + DeviceRelations = ExAllocatePoolWithTag(PagedPool, Size, PARPORT_TAG); + if (DeviceRelations == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Fill the buffer */ + i = 0; + ObReferenceObject(DeviceExtension->AttachedRawPdo); + DeviceRelations->Objects[i] = DeviceExtension->AttachedRawPdo; + + Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations; + + DPRINT("Done\n"); return STATUS_SUCCESS; } @@ -345,7 +424,7 @@ goto done; } - DPRINT("Open LPT%lu: successful\n", DeviceExtension->LptPort); + DPRINT("Open parallel port %lu: successful\n", DeviceExtension->PortNumber); DeviceExtension->OpenCount++; done: @@ -397,68 +476,11 @@ FdoWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - PFDO_DEVICE_EXTENSION DeviceExtension; - PIO_STACK_LOCATION IoStack; - PUCHAR Buffer; - ULONG i; - UCHAR PortStatus; - ULONG ulCount; - DPRINT("FdoWrite()\n"); - - DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - IoStack = IoGetCurrentIrpStackLocation(Irp); - - Buffer = GetUserBuffer(Irp); - DPRINT("Length: %lu\n", IoStack->Parameters.Write.Length); - DPRINT("Buffer: %p\n", Buffer); - - if (Buffer != NULL) - { - DPRINT("%s\n", Buffer); - } - - for (i = 0; i < IoStack->Parameters.Write.Length; i++) - { - DPRINT("%lu: %c\n", i, Buffer[i]); - - ulCount = 0; - - do - { - KeStallExecutionProcessor(10); - PortStatus = READ_PORT_UCHAR((PUCHAR)(DeviceExtension->BaseAddress + 1)); - ulCount++; - } - while (ulCount < 500000 && !(PortStatus & LP_PBUSY)); - - if (ulCount == 500000) - { - DPRINT1("Timed out\n"); - - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_TIMEOUT; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - - return STATUS_TIMEOUT; - } - - /* Write character */ - WRITE_PORT_UCHAR((PUCHAR)DeviceExtension->BaseAddress, Buffer[i]); - - KeStallExecutionProcessor(10); - - WRITE_PORT_UCHAR((PUCHAR)(DeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP | LP_PSTROBE)); - - KeStallExecutionProcessor(10); - - WRITE_PORT_UCHAR((PUCHAR)(DeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP)); - } Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_SUCCESS; } @@ -524,26 +546,29 @@ switch (Stack->Parameters.QueryDeviceRelations.Type) { case BusRelations: - DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n"); + DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n"); + Status = FdoQueryBusRelations(DeviceObject, Irp, Stack); + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; + + case RemovalRelations: + DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n"); return ForwardIrpAndForget(DeviceObject, Irp); - case RemovalRelations: - DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n"); - return ForwardIrpAndForget(DeviceObject, Irp); - default: - DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n", + DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n", Stack->Parameters.QueryDeviceRelations.Type); return ForwardIrpAndForget(DeviceObject, Irp); } break; case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: /* (optional) 0xd */ - DPRINT1("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"); + DPRINT("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"); return ForwardIrpAndForget(DeviceObject, Irp); default: - DPRINT1("Unknown minor function 0x%x\n", MinorFunction); + DPRINT("Unknown minor function 0x%x\n", MinorFunction); return ForwardIrpAndForget(DeviceObject, Irp); } Copied: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/misc.c (from r67713, trunk/reactos/drivers/parallel/parport/misc.c) URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- trunk/reactos/drivers/parallel/parport/misc.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/misc.c [iso-8859-1] Thu Jul 16 15:12:50 2015 @@ -61,7 +61,10 @@ { PDEVICE_OBJECT LowerDevice; - LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; + else + LowerDevice = ((PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->AttachedFdo; ASSERT(LowerDevice); IoSkipCurrentIrpStackLocation(Irp); Modified: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.c [iso-8859-1] Thu Jul 16 15:12:50 2015 @@ -7,7 +7,15 @@ #include "parport.h" static DRIVER_UNLOAD DriverUnload; +static DRIVER_DISPATCH DispatchCreate; +static DRIVER_DISPATCH DispatchClose; +static DRIVER_DISPATCH DispatchCleanup; +static DRIVER_DISPATCH DispatchPnp; +static DRIVER_DISPATCH DispatchPower; DRIVER_INITIALIZE DriverEntry; + + +/* FUNCTIONS ****************************************************************/ static VOID @@ -17,14 +25,109 @@ DPRINT("Parport DriverUnload\n"); } + +static +NTSTATUS +NTAPI +DispatchCreate(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + return FdoCreate(DeviceObject, Irp); + else + return PdoCreate(DeviceObject, Irp); +} + + +static +NTSTATUS +NTAPI +DispatchClose(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + return FdoClose(DeviceObject, Irp); + else + return PdoClose(DeviceObject, Irp); +} + + +static +NTSTATUS +NTAPI +DispatchCleanup(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + return FdoCleanup(DeviceObject, Irp); + else + return PdoCleanup(DeviceObject, Irp); +} + + +static +NTSTATUS +NTAPI +DispatchWrite(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + return FdoWrite(DeviceObject, Irp); + else + return PdoWrite(DeviceObject, Irp); +} + + +static +NTSTATUS +NTAPI +DispatchPnp(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + return FdoPnp(DeviceObject, Irp); + else + return PdoPnp(DeviceObject, Irp); +} + + +static +NTSTATUS +NTAPI +DispatchPower(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) + return FdoPower(DeviceObject, Irp); + else + return PdoPower(DeviceObject, Irp); +} + + NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath) { + ULONG i; + DPRINT("Parport DriverEntry\n"); DriverObject->DriverUnload = DriverUnload; + DriverObject->DriverExtension->AddDevice = AddDevice; + + for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) + DriverObject->MajorFunction[i] = ForwardIrpAndForget; + + DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose; + DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup; +// DriverObject->MajorFunction[IRP_MJ_READ] = DispatchRead; + DriverObject->MajorFunction[IRP_MJ_WRITE] = DispatchWrite; +// DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl; +// DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = DispatchQueryInformation; + DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp; + DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower; return STATUS_SUCCESS; } Modified: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.h URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.h [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/parport.h [iso-8859-1] Thu Jul 16 15:12:50 2015 @@ -1,6 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: Parallel Port Function Driver + * FILE: drivers/parallel/parport/parport.h * PURPOSE: Parport driver header */ @@ -8,9 +9,143 @@ #define _PARPORT_PCH_ #include <ntddk.h> -#include <ntddser.h> +#include <ndk/haltypes.h> +#include <ntddpar.h> +#include <stdio.h> + +#include "hardware.h" //#define NDEBUG #include <debug.h> +typedef enum +{ + dsStopped, + dsStarted, + dsPaused, + dsRemoved, + dsSurpriseRemoved +} DEVICE_STATE; + +typedef struct _COMMON_DEVICE_EXTENSION +{ + BOOLEAN IsFDO; + DEVICE_STATE PnpState; +} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION; + +typedef struct _FDO_DEVICE_EXTENSION +{ + COMMON_DEVICE_EXTENSION Common; + + PDEVICE_OBJECT Pdo; + PDEVICE_OBJECT LowerDevice; + + PDEVICE_OBJECT AttachedRawPdo; + PDEVICE_OBJECT AttachedPdo[2]; + + ULONG PortNumber; + + ULONG OpenCount; + + ULONG BaseAddress; + PKINTERRUPT Interrupt; + +} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION; + +typedef struct _PDO_DEVICE_EXTENSION +{ + COMMON_DEVICE_EXTENSION Common; + + PDEVICE_OBJECT AttachedFdo; + + ULONG PortNumber; + ULONG LptPort; + + ULONG OpenCount; + +} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; + +#define PARPORT_TAG 'trpP' + +/* fdo.c */ + +DRIVER_ADD_DEVICE AddDevice; + +NTSTATUS +NTAPI +FdoCreate(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +FdoClose(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +FdoCleanup(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +FdoWrite(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +FdoPnp(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +FdoPower(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + + +/* misc.c */ + +NTSTATUS +ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +DRIVER_DISPATCH ForwardIrpAndForget; + +PVOID +GetUserBuffer(IN PIRP Irp); + +//KSERVICE_ROUTINE ParportInterruptService; + + +/* pdo.c */ + +NTSTATUS +NTAPI +PdoCreate(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +PdoClose(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +PdoCleanup(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +PdoWrite(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +PdoPnp(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +NTAPI +PdoPower(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + #endif /* _PARPORT_PCH_ */ Copied: branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/pdo.c (from r67713, trunk/reactos/drivers/parallel/parport/pdo.c) URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- trunk/reactos/drivers/parallel/parport/pdo.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/drivers/parallel/parport/pdo.c [iso-8859-1] Thu Jul 16 15:12:50 2015 @@ -14,12 +14,31 @@ PdoCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + PPDO_DEVICE_EXTENSION DeviceExtension; + PIO_STACK_LOCATION Stack; + NTSTATUS Status = STATUS_SUCCESS; + DPRINT("PdoCreate()\n"); + Stack = IoGetCurrentIrpStackLocation(Irp); + DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE) + { + DPRINT1("Not a directory\n"); + Status = STATUS_NOT_A_DIRECTORY; + goto done; + } + + DPRINT("Open LPT%lu: successful\n", DeviceExtension->LptPort); + DeviceExtension->OpenCount++; + +done: + Irp->IoStatus.Status = Status; Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_SUCCESS; + + return Status; } @@ -28,11 +47,17 @@ PdoClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + PPDO_DEVICE_EXTENSION pDeviceExtension; + DPRINT("PdoClose()\n"); + + pDeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + pDeviceExtension->OpenCount--; Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; } @@ -56,7 +81,66 @@ PdoWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + PPDO_DEVICE_EXTENSION PdoDeviceExtension; + PFDO_DEVICE_EXTENSION FdoDeviceExtension; + PIO_STACK_LOCATION IoStack; + PUCHAR Buffer; + ULONG i; + UCHAR PortStatus; + ULONG ulCount; + DPRINT("PdoWrite()\n"); + + PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->AttachedFdo->DeviceExtension; + + IoStack = IoGetCurrentIrpStackLocation(Irp); + + Buffer = GetUserBuffer(Irp); + DPRINT("Length: %lu\n", IoStack->Parameters.Write.Length); + DPRINT("Buffer: %p\n", Buffer); + + if (Buffer != NULL) + { + DPRINT("%s\n", Buffer); + } + + for (i = 0; i < IoStack->Parameters.Write.Length; i++) + { + DPRINT("%lu: %c\n", i, Buffer[i]); + + ulCount = 0; + + do + { + KeStallExecutionProcessor(10); + PortStatus = READ_PORT_UCHAR((PUCHAR)(FdoDeviceExtension->BaseAddress + 1)); + ulCount++; + } + while (ulCount < 500000 && !(PortStatus & LP_PBUSY)); + + if (ulCount == 500000) + { + DPRINT("Timed out\n"); + + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_TIMEOUT; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return STATUS_TIMEOUT; + } + + /* Write character */ + WRITE_PORT_UCHAR((PUCHAR)FdoDeviceExtension->BaseAddress, Buffer[i]); + + KeStallExecutionProcessor(10); + + WRITE_PORT_UCHAR((PUCHAR)(FdoDeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP | LP_PSTROBE)); + + KeStallExecutionProcessor(10); + + WRITE_PORT_UCHAR((PUCHAR)(FdoDeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP)); + } Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS;
9 years, 5 months
1
0
0
0
[cfinck] 68405: [LOCALSPL, WINSPOOL] Partially implement the whole StartDocPrinter, StartPagePrinter, ReadPrinter, WritePrinter, EndPagePrinter, EndDocPrinter, ClosePrinter group of functions. They...
by cfinck@svn.reactos.org
Author: cfinck Date: Thu Jul 16 15:03:47 2015 New Revision: 68405 URL:
http://svn.reactos.org/svn/reactos?rev=68405&view=rev
Log: [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 :) Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printingthread.c (with props) Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/precomp.h branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/CMakeLists.txt branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/jobs.c branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/main.c branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/ports.c branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/precomp.h branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printers.c Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/jobs.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -61,11 +61,18 @@ { DWORD dwErrorCode; PADDJOB_INFO_1W pAddJobInfo1; - - // Do the RPC call - RpcTryExcept - { - dwErrorCode = _RpcAddJob(hPrinter, Level, pData, cbBuf, pcbNeeded); + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcAddJob(pHandle->hPrinter, Level, pData, cbBuf, pcbNeeded); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { @@ -81,6 +88,7 @@ pAddJobInfo1->Path = (PWSTR)((ULONG_PTR)pAddJobInfo1->Path + (ULONG_PTR)pAddJobInfo1); } +Cleanup: SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); } @@ -98,11 +106,18 @@ DWORD dwErrorCode; DWORD i; PBYTE p = pJob; - - // Do the RPC call - RpcTryExcept - { - dwErrorCode = _RpcEnumJobs(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned); + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcEnumJobs(pHandle->hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { @@ -125,6 +140,7 @@ } } +Cleanup: SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); } @@ -140,11 +156,18 @@ GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJob, DWORD cbBuf, PDWORD pcbNeeded) { DWORD dwErrorCode; - - // Do the RPC call - RpcTryExcept - { - dwErrorCode = _RpcGetJob(hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded); + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcGetJob(pHandle->hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { @@ -159,6 +182,7 @@ _MarshallUpJobInfo(pJob, Level); } +Cleanup: SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); } @@ -167,19 +191,27 @@ ScheduleJob(HANDLE hPrinter, DWORD dwJobID) { DWORD dwErrorCode; - - // Do the RPC call - RpcTryExcept - { - dwErrorCode = _RpcScheduleJob(hPrinter, dwJobID); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - dwErrorCode = RpcExceptionCode(); - ERR("_RpcSetJob failed with exception code %lu!\n", dwErrorCode); - } - RpcEndExcept; - + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcScheduleJob(pHandle->hPrinter, dwJobID); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcScheduleJob failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + +Cleanup: SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); } @@ -195,7 +227,14 @@ SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJobInfo, DWORD Command) { DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; WINSPOOL_JOB_CONTAINER JobContainer; + + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } // pJobContainer->JobInfo is a union of pointers, so we can just set any element to our BYTE pointer. JobContainer.Level = Level; @@ -204,7 +243,7 @@ // Do the RPC call RpcTryExcept { - dwErrorCode = _RpcSetJob(hPrinter, JobId, &JobContainer, Command); + dwErrorCode = _RpcSetJob(pHandle->hPrinter, JobId, &JobContainer, Command); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { @@ -213,6 +252,7 @@ } RpcEndExcept; - SetLastError(dwErrorCode); - return (dwErrorCode == ERROR_SUCCESS); -} +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); +} Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/main.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -6,6 +6,10 @@ */ #include "precomp.h" + +// Global Variables +HANDLE hProcessHeap; + handle_t __RPC_USER WINSPOOL_HANDLE_bind(WINSPOOL_HANDLE wszName) @@ -56,13 +60,27 @@ void __RPC_FAR* __RPC_USER midl_user_allocate(SIZE_T len) { - return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); + return HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, len); } void __RPC_USER midl_user_free(void __RPC_FAR* ptr) { - HeapFree(GetProcessHeap(), 0, ptr); + HeapFree(hProcessHeap, 0, ptr); +} + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + hProcessHeap = GetProcessHeap(); + break; + } + + return TRUE; } BOOL WINAPI Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/precomp.h URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/precomp.h [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/precomp.h [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -19,4 +19,20 @@ #include <wine/debug.h> WINE_DEFAULT_DEBUG_CHANNEL(winspool); +// Structures +/* + * Describes a handle returned by OpenPrinterW. + */ +typedef struct _SPOOLER_HANDLE +{ + BOOL bStartedDoc : 1; + DWORD dwJobID; + HANDLE hPrinter; + HANDLE hSPLFile; +} +SPOOLER_HANDLE, *PSPOOLER_HANDLE; + +// main.c +extern HANDLE hProcessHeap; + #endif Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -7,6 +7,94 @@ #include "precomp.h" +static DWORD +_StartDocPrinterSpooled(PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1, PADDJOB_INFO_1W pAddJobInfo1) +{ + DWORD cbNeeded; + DWORD dwErrorCode; + PJOB_INFO_1W pJobInfo1 = NULL; + + // Create the spool file. + pHandle->hSPLFile = CreateFileW(pAddJobInfo1->Path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL); + if (pHandle->hSPLFile == INVALID_HANDLE_VALUE) + { + dwErrorCode = GetLastError(); + ERR("CreateFileW failed for \"%S\" with error %lu!\n", pAddJobInfo1->Path, dwErrorCode); + goto Cleanup; + } + + // Get the size of the job information. + GetJobW(pHandle->hPrinter, pAddJobInfo1->JobId, 1, NULL, 0, &cbNeeded); + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + { + dwErrorCode = GetLastError(); + ERR("GetJobW failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + // Allocate enough memory for the returned job information. + pJobInfo1 = HeapAlloc(hProcessHeap, 0, cbNeeded); + if (!pJobInfo1) + { + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("HeapAlloc failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + // Get the job information. + if (!GetJobW(pHandle->hPrinter, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, cbNeeded, &cbNeeded)) + { + dwErrorCode = GetLastError(); + ERR("GetJobW failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + // Add our document information. + pJobInfo1->pDatatype = pDocInfo1->pDatatype; + pJobInfo1->pDocument = pDocInfo1->pDocName; + + // Set the new job information. + if (!SetJobW(pHandle->hPrinter, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, 0)) + { + dwErrorCode = GetLastError(); + ERR("SetJobW failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + // We were successful! + pHandle->dwJobID = pAddJobInfo1->JobId; + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + if (pJobInfo1) + HeapFree(hProcessHeap, 0, pJobInfo1); + + return dwErrorCode; +} + +static DWORD +_StartDocPrinterWithRPC(PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1) +{ + DWORD dwErrorCode; + WINSPOOL_DOC_INFO_CONTAINER DocInfoContainer; + + DocInfoContainer.Level = 1; + DocInfoContainer.DocInfo.pDocInfo1 = (WINSPOOL_DOC_INFO_1*)pDocInfo1; + + RpcTryExcept + { + dwErrorCode = _RpcStartDocPrinter(pHandle->hPrinter, &DocInfoContainer, &pHandle->dwJobID); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcStartDocPrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + + return dwErrorCode; +} + BOOL WINAPI EnumPrintersA(DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) { @@ -16,29 +104,60 @@ BOOL WINAPI EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) { - BOOL bReturnValue = FALSE; DWORD dwErrorCode; // Do the RPC call RpcTryExcept { dwErrorCode = _RpcEnumPrinters(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned); - SetLastError(dwErrorCode); - bReturnValue = (dwErrorCode == ERROR_SUCCESS); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { - ERR("_RpcEnumPrinters failed with exception code %lu!\n", RpcExceptionCode()); + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEnumPrinters failed with exception code %lu!\n", dwErrorCode); } RpcEndExcept; - return bReturnValue; + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI ClosePrinter(HANDLE hPrinter) { - return FALSE; + DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call. + RpcTryExcept + { + dwErrorCode = _RpcClosePrinter(pHandle->hPrinter); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcClosePrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + + // Close any open file handle. + if (pHandle->hSPLFile != INVALID_HANDLE_VALUE) + CloseHandle(pHandle->hSPLFile); + + // Free the memory for the handle. + HeapFree(hProcessHeap, 0, pHandle); + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); + } DWORD WINAPI @@ -68,13 +187,92 @@ BOOL WINAPI EndDocPrinter(HANDLE hPrinter) { - return FALSE; + DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + if (pHandle->hSPLFile != INVALID_HANDLE_VALUE) + { + // For spooled jobs, the document is finished by calling _RpcScheduleJob. + RpcTryExcept + { + dwErrorCode = _RpcScheduleJob(pHandle->hPrinter, pHandle->dwJobID); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcScheduleJob failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + + // Close the spool file handle. + CloseHandle(pHandle->hSPLFile); + } + else + { + // In all other cases, just call _RpcEndDocPrinter. + RpcTryExcept + { + dwErrorCode = _RpcEndDocPrinter(pHandle->hPrinter); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEndDocPrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + } + + // A new document can now be started again. + pHandle->bStartedDoc = FALSE; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI EndPagePrinter(HANDLE hPrinter) { - return FALSE; + DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + if (pHandle->hSPLFile != INVALID_HANDLE_VALUE) + { + // For spooled jobs, we don't need to do anything. + dwErrorCode = ERROR_SUCCESS; + } + else + { + // In all other cases, just call _RpcEndPagePrinter. + RpcTryExcept + { + dwErrorCode = _RpcEndPagePrinter(pHandle->hPrinter); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcEndPagePrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + } + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI @@ -127,7 +325,7 @@ // Convert pPrinterName to a Unicode string pwszPrinterName StringLength = strlen(pPrinterName) + 1; - pwszPrinterName = HeapAlloc(GetProcessHeap(), 0, StringLength * sizeof(WCHAR)); + pwszPrinterName = HeapAlloc(hProcessHeap, 0, StringLength * sizeof(WCHAR)); if (!pwszPrinterName) { ERR("HeapAlloc failed for pwszPrinterName with last error %lu!\n", GetLastError()); @@ -146,7 +344,7 @@ // Convert pDefault->pDatatype to a Unicode string pwszDatatype that later becomes wDefault.pDatatype StringLength = strlen(pDefault->pDatatype) + 1; - pwszDatatype = HeapAlloc(GetProcessHeap(), 0, StringLength * sizeof(WCHAR)); + pwszDatatype = HeapAlloc(hProcessHeap, 0, StringLength * sizeof(WCHAR)); if (!pwszDatatype) { ERR("HeapAlloc failed for pwszDatatype with last error %lu!\n", GetLastError()); @@ -165,13 +363,13 @@ Cleanup: if (wDefault.pDevMode) - HeapFree(GetProcessHeap(), 0, wDefault.pDevMode); + HeapFree(hProcessHeap, 0, wDefault.pDevMode); if (pwszPrinterName) - HeapFree(GetProcessHeap(), 0, pwszPrinterName); + HeapFree(hProcessHeap, 0, pwszPrinterName); if (pwszDatatype) - HeapFree(GetProcessHeap(), 0, pwszDatatype); + HeapFree(hProcessHeap, 0, pwszDatatype); return bReturnValue; } @@ -179,8 +377,9 @@ BOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault) { - BOOL bReturnValue = FALSE; - DWORD dwErrorCode; + DWORD dwErrorCode; + HANDLE hPrinter; + PSPOOLER_HANDLE pHandle; PWSTR pDatatype = NULL; WINSPOOL_DEVMODE_CONTAINER DevModeContainer; WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer = NULL; @@ -199,41 +398,235 @@ // Do the RPC call RpcTryExcept { - dwErrorCode = _RpcOpenPrinter(pPrinterName, phPrinter, pDatatype, pDevModeContainer, AccessRequired); - SetLastError(dwErrorCode); - bReturnValue = (dwErrorCode == ERROR_SUCCESS); + dwErrorCode = _RpcOpenPrinter(pPrinterName, &hPrinter, pDatatype, pDevModeContainer, AccessRequired); } RpcExcept(EXCEPTION_EXECUTE_HANDLER) { - ERR("_RpcOpenPrinter failed with exception code %lu!\n", RpcExceptionCode()); + dwErrorCode = RpcExceptionCode(); + ERR("_RpcOpenPrinter failed with exception code %lu!\n", dwErrorCode); } RpcEndExcept; - return bReturnValue; + if (dwErrorCode == ERROR_SUCCESS) + { + // Create a new SPOOLER_HANDLE structure. + pHandle = HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, sizeof(SPOOLER_HANDLE)); + if (!pHandle) + { + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("HeapAlloc failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + pHandle->hPrinter = hPrinter; + pHandle->hSPLFile = INVALID_HANDLE_VALUE; + + // Return it as phPrinter. + *phPrinter = (HANDLE)pHandle; + } + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI ReadPrinter(HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pNoBytesRead) { - return FALSE; + DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcReadPrinter(pHandle->hPrinter, pBuf, cbBuf, pNoBytesRead); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcReadPrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } DWORD WINAPI -StartDocPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo) -{ - return 0; +StartDocPrinterW(HANDLE hPrinter, DWORD Level, PBYTE pDocInfo) +{ + DWORD cbAddJobInfo1; + DWORD cbNeeded; + DWORD dwErrorCode; + PADDJOB_INFO_1W pAddJobInfo1 = NULL; + PDOC_INFO_1W pDocInfo1 = (PDOC_INFO_1W)pDocInfo; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + if (!pDocInfo1) + { + dwErrorCode = ERROR_INVALID_PARAMETER; + goto Cleanup; + } + + if (Level != 1) + { + dwErrorCode = ERROR_INVALID_LEVEL; + goto Cleanup; + } + + if (pHandle->bStartedDoc) + { + dwErrorCode = ERROR_INVALID_PRINTER_STATE; + goto Cleanup; + } + + // Check if we want to redirect output into a file. + if (pDocInfo1->pOutputFile) + { + // Do a StartDocPrinter RPC call in this case. + dwErrorCode = _StartDocPrinterWithRPC(pHandle, pDocInfo1); + } + else + { + // Allocate memory for the ADDJOB_INFO_1W structure and a path. + cbAddJobInfo1 = sizeof(ADDJOB_INFO_1W) + MAX_PATH * sizeof(WCHAR); + pAddJobInfo1 = HeapAlloc(hProcessHeap, 0, cbAddJobInfo1); + if (!pAddJobInfo1) + { + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("HeapAlloc failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + // Try to add a new job. + // This only succeeds if the printer is set to do spooled printing. + if (AddJobW(pHandle->hPrinter, 1, (PBYTE)pAddJobInfo1, cbAddJobInfo1, &cbNeeded)) + { + // Do spooled printing. + dwErrorCode = _StartDocPrinterSpooled(pHandle, pDocInfo1, pAddJobInfo1); + } + else if (GetLastError() == ERROR_INVALID_ACCESS) + { + // ERROR_INVALID_ACCESS is returned when the printer is set to do direct printing. + // In this case, we do a StartDocPrinter RPC call. + dwErrorCode = _StartDocPrinterWithRPC(pHandle, pDocInfo1); + } + else + { + dwErrorCode = GetLastError(); + ERR("AddJobW failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + } + + if (dwErrorCode == ERROR_SUCCESS) + pHandle->bStartedDoc = TRUE; + +Cleanup: + if (pAddJobInfo1) + HeapFree(hProcessHeap, 0, pAddJobInfo1); + + SetLastError(dwErrorCode); + return pHandle->dwJobID; } BOOL WINAPI StartPagePrinter(HANDLE hPrinter) { - return FALSE; -} - -BOOL WINAPI -WritePrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten) -{ - return FALSE; + DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcStartPagePrinter(pHandle->hPrinter); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcStartPagePrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); +} + +BOOL WINAPI +WritePrinter(HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pcWritten) +{ + DWORD dwErrorCode; + PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + if (!pHandle->bStartedDoc) + { + dwErrorCode = ERROR_SPL_NO_STARTDOC; + goto Cleanup; + } + + if (pHandle->hSPLFile != INVALID_HANDLE_VALUE) + { + // Write to the spool file. This doesn't need an RPC request. + if (!WriteFile(pHandle->hSPLFile, pBuf, cbBuf, pcWritten, NULL)) + { + dwErrorCode = GetLastError(); + ERR("WriteFile failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + dwErrorCode = ERROR_SUCCESS; + } + else + { + // TODO: This case (for direct printing or remote printing) has bad performance if multiple small-sized WritePrinter calls are performed. + // We may increase performance by writing into a buffer and only doing a single RPC call when the buffer is full. + + // Do the RPC call + RpcTryExcept + { + dwErrorCode = _RpcWritePrinter(pHandle->hPrinter, pBuf, cbBuf, pcWritten); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwErrorCode = RpcExceptionCode(); + ERR("_RpcWritePrinter failed with exception code %lu!\n", dwErrorCode); + } + RpcEndExcept; + } + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/CMakeLists.txt [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/CMakeLists.txt [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -10,6 +10,7 @@ ports.c precomp.h printers.c + printingthread.c printprocessors.c tools.c) Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/jobs.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/jobs.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/jobs.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -13,6 +13,27 @@ // Local Variables static DWORD _dwLastJobID; + +static BOOL +_GetNextJobID(PDWORD dwJobID) +{ + ++_dwLastJobID; + + while (LookupElementSkiplist(&GlobalJobList, &_dwLastJobID, NULL)) + { + // This ID is already taken. Try the next one. + ++_dwLastJobID; + } + + if (!IS_VALID_JOB_ID(_dwLastJobID)) + { + ERR("Job ID %lu isn't valid!\n", _dwLastJobID); + return FALSE; + } + + *dwJobID = _dwLastJobID; + return TRUE; +} /** * @name _GlobalJobListCompareRoutine @@ -81,25 +102,23 @@ return 0; } -BOOL -GetNextJobID(PDWORD dwJobID) -{ - ++_dwLastJobID; - - while (LookupElementSkiplist(&GlobalJobList, &_dwLastJobID, NULL)) - { - // This ID is already taken. Try the next one. - ++_dwLastJobID; - } - - if (!IS_VALID_JOB_ID(_dwLastJobID)) - { - ERR("Job ID %lu isn't valid!\n", _dwLastJobID); - return FALSE; - } - - *dwJobID = _dwLastJobID; - return TRUE; +DWORD +GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput) +{ + const WCHAR wszPrintersPath[] = L"\\PRINTERS\\"; + const DWORD cchPrintersPath = _countof(wszPrintersPath) - 1; + const DWORD cchSpoolerFile = sizeof("?????.") - 1; + const DWORD cchExtension = sizeof("SPL") - 1; // pwszExtension may be L"SPL" or L"SHD", same length for both! + + if (pwszOutput) + { + CopyMemory(pwszOutput, wszSpoolDirectory, cchSpoolDirectory); + CopyMemory(&pwszOutput[cchSpoolDirectory], wszPrintersPath, cchPrintersPath); + swprintf(&pwszOutput[cchSpoolDirectory + cchPrintersPath], L"%05lu.", dwJobID); + CopyMemory(&pwszOutput[cchSpoolDirectory + cchPrintersPath + cchSpoolerFile], pwszExtension, (cchExtension + 1) * sizeof(WCHAR)); + } + + return (cchSpoolDirectory + cchPrintersPath + cchSpoolerFile + cchExtension + 1) * sizeof(WCHAR); } BOOL @@ -107,8 +126,6 @@ { const WCHAR wszPath[] = L"\\PRINTERS\\?????.SHD"; const DWORD cchPath = _countof(wszPath) - 1; - const DWORD cchFolders = sizeof("\\PRINTERS\\") - 1; - const DWORD cchPattern = sizeof("?????") - 1; DWORD dwErrorCode; DWORD dwJobID; @@ -118,7 +135,7 @@ WCHAR wszFullPath[MAX_PATH]; WIN32_FIND_DATAW FindData; - // This one is incremented in GetNextJobID. + // This one is incremented in _GetNextJobID. _dwLastJobID = 0; // Initialize an empty list for all jobs of all local printers. @@ -145,6 +162,7 @@ continue; // Extract the Job ID and verify the file name format at the same time. + // This includes all valid names (like "00005.SHD") and excludes invalid ones (like "10ABC.SHD"). dwJobID = wcstoul(FindData.cFileName, &p, 10); if (!IS_VALID_JOB_ID(dwJobID)) continue; @@ -153,7 +171,7 @@ continue; // This shadow file has a valid name. Construct the full path and try to load it. - CopyMemory(&wszFullPath[cchSpoolDirectory + cchFolders], FindData.cFileName, cchPattern); + GetJobFilePath(L"SHD", dwJobID, wszFullPath); pJob = ReadJobShadowFile(wszFullPath); if (!pJob) continue; @@ -195,78 +213,31 @@ InitializeSkiplist(&pPrinter->JobList, DllAllocSplMem, _PrinterJobListCompareRoutine, (PSKIPLIST_FREE_ROUTINE)DllFreeSplMem); } -BOOL WINAPI -LocalAddJob(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcbNeeded) +DWORD WINAPI +CreateJob(PLOCAL_PRINTER_HANDLE pPrinterHandle) { const WCHAR wszDoubleBackslash[] = L"\\"; const DWORD cchDoubleBackslash = _countof(wszDoubleBackslash) - 1; - const WCHAR wszPrintersPath[] = L"\\PRINTERS\\"; - const DWORD cchPrintersPath = _countof(wszPrintersPath) - 1; - const DWORD cchSpl = _countof("?????.SPL") - 1; - - ADDJOB_INFO_1W AddJobInfo1; + DWORD cchMachineName; DWORD cchUserName; DWORD dwErrorCode; - PBYTE p; - PLOCAL_HANDLE pHandle; PLOCAL_JOB pJob; - PLOCAL_PRINTER_HANDLE pPrinterHandle; RPC_BINDING_HANDLE hServerBinding = NULL; RPC_WSTR pwszBinding = NULL; RPC_WSTR pwszMachineName = NULL; - // Check if this is a printer handle. - pHandle = (PLOCAL_HANDLE)hPrinter; - if (pHandle->HandleType != HandleType_Printer) - { - dwErrorCode = ERROR_INVALID_HANDLE; - goto Cleanup; - } - - pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; - - // This handle must not have started a job yet! - if (pPrinterHandle->pStartedJob) - { - dwErrorCode = ERROR_INVALID_HANDLE; - goto Cleanup; - } - - // Check if this is the right structure level. - if (Level != 1) - { - dwErrorCode = ERROR_INVALID_LEVEL; - goto Cleanup; - } - - // Check if the printer is set to do direct printing. - // The Job List isn't used in this case. - if (pPrinterHandle->pPrinter->dwAttributes & PRINTER_ATTRIBUTE_DIRECT) - { - dwErrorCode = ERROR_INVALID_ACCESS; - goto Cleanup; - } - - // Check if the supplied buffer is large enough. - *pcbNeeded = sizeof(ADDJOB_INFO_1W) + (cchSpoolDirectory + cchPrintersPath + cchSpl + 1) * sizeof(WCHAR); - if (cbBuf < *pcbNeeded) - { - dwErrorCode = ERROR_INSUFFICIENT_BUFFER; - goto Cleanup; - } - // Create a new job. pJob = DllAllocSplMem(sizeof(LOCAL_JOB)); if (!pJob) { - dwErrorCode = GetLastError(); - ERR("DllAllocSplMem failed with error %lu!\n", dwErrorCode); + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("DllAllocSplMem failed with error %lu!\n", GetLastError()); goto Cleanup; } // Reserve an ID for this job. - if (!GetNextJobID(&pJob->dwJobID)) + if (!_GetNextJobID(&pJob->dwJobID)) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; goto Cleanup; @@ -339,21 +310,18 @@ goto Cleanup; } - // Return a proper ADDJOB_INFO_1W structure. - AddJobInfo1.JobId = pJob->dwJobID; - AddJobInfo1.Path = (PWSTR)(pData + sizeof(ADDJOB_INFO_1W)); - p = pData; - CopyMemory(p, &AddJobInfo1, sizeof(ADDJOB_INFO_1W)); - p += sizeof(ADDJOB_INFO_1W); - CopyMemory(p, wszSpoolDirectory, cchSpoolDirectory); - p += cchSpoolDirectory; - CopyMemory(p, wszPrintersPath, cchPrintersPath); - p += cchPrintersPath; - swprintf((PWSTR)p, L"%05lu.SPL", pJob->dwJobID); - + // We were successful! + pPrinterHandle->bStartedDoc = TRUE; + pPrinterHandle->pJob = pJob; dwErrorCode = ERROR_SUCCESS; + // Don't let the cleanup routine free this. + pJob = NULL; + Cleanup: + if (pJob) + DllFreeSplMem(pJob); + if (pwszMachineName) RpcStringFreeW(&pwszMachineName); @@ -363,6 +331,72 @@ if (hServerBinding) RpcBindingFree(&hServerBinding); + return dwErrorCode; +} + +BOOL WINAPI +LocalAddJob(HANDLE hPrinter, DWORD Level, PBYTE pData, DWORD cbBuf, PDWORD pcbNeeded) +{ + ADDJOB_INFO_1W AddJobInfo1; + DWORD dwErrorCode; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + PLOCAL_PRINTER_HANDLE pPrinterHandle; + + // Check if this is a printer handle. + if (pHandle->HandleType != HandleType_Printer) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // This handle must not have started a job yet! + if (pPrinterHandle->pJob) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Check if this is the right structure level. + if (Level != 1) + { + dwErrorCode = ERROR_INVALID_LEVEL; + goto Cleanup; + } + + // Check if the printer is set to do direct printing. + // The Job List isn't used in this case. + if (pPrinterHandle->pPrinter->dwAttributes & PRINTER_ATTRIBUTE_DIRECT) + { + dwErrorCode = ERROR_INVALID_ACCESS; + goto Cleanup; + } + + // Check if the supplied buffer is large enough. + *pcbNeeded = sizeof(ADDJOB_INFO_1W) + GetJobFilePath(L"SPL", 0, NULL); + if (cbBuf < *pcbNeeded) + { + dwErrorCode = ERROR_INSUFFICIENT_BUFFER; + goto Cleanup; + } + + // All requirements are met - create a new job. + dwErrorCode = CreateJob(pPrinterHandle); + if (dwErrorCode != ERROR_SUCCESS) + goto Cleanup; + + // Mark that this job was started with AddJob (so that it can be scheduled for printing with ScheduleJob). + pPrinterHandle->pJob->bAddedJob = TRUE; + + // Return a proper ADDJOB_INFO_1W structure. + AddJobInfo1.JobId = pPrinterHandle->pJob->dwJobID; + AddJobInfo1.Path = (PWSTR)(pData + sizeof(ADDJOB_INFO_1W)); + + CopyMemory(pData, &AddJobInfo1, sizeof(ADDJOB_INFO_1W)); + GetJobFilePath(L"SPL", AddJobInfo1.JobId, AddJobInfo1.Path); + +Cleanup: SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); } @@ -842,9 +876,6 @@ BOOL WINAPI LocalSetJob(HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJobInfo, DWORD Command) { - const WCHAR wszFolder[] = L"\\PRINTERS\\"; - const DWORD cchFolder = _countof(wszFolder) - 1; - DWORD dwErrorCode; PLOCAL_HANDLE pHandle; PLOCAL_JOB pJob; @@ -883,18 +914,34 @@ if (dwErrorCode != ERROR_SUCCESS) goto Cleanup; - // Construct the full path to the shadow file. - CopyMemory(wszFullPath, wszSpoolDirectory, cchSpoolDirectory * sizeof(WCHAR)); - CopyMemory(&wszFullPath[cchSpoolDirectory], wszFolder, cchFolder * sizeof(WCHAR)); - swprintf(&wszFullPath[cchSpoolDirectory + cchFolder], L"%05lu.SHD", JobId); - - // Write the job data into the shadow file. - WriteJobShadowFile(wszFullPath, pJob); + // If we do spooled printing, the job information is written down into a shadow file. + if (!(pPrinterHandle->pPrinter->dwAttributes & PRINTER_ATTRIBUTE_DIRECT)) + { + // Write the job data into the shadow file. + GetJobFilePath(L"SHD", JobId, wszFullPath); + WriteJobShadowFile(wszFullPath, pJob); + } // Perform an additional command if desired. if (Command) { - // TODO + if (Command == JOB_CONTROL_SENT_TO_PRINTER) + { + // This indicates the end of the Print Job. + + // Cancel the Job at the Print Processor. + if (pJob->hPrintProcessor) + pJob->pPrintProcessor->pfnControlPrintProcessor(pJob->hPrintProcessor, JOB_CONTROL_CANCEL); + + FreeJob(pJob); + + // TODO: All open handles associated with the job need to be invalidated. + // This certainly needs handle tracking... + } + else + { + ERR("Unimplemented SetJob Command: %lu!\n", Command); + } } dwErrorCode = ERROR_SUCCESS; @@ -1003,18 +1050,15 @@ BOOL WINAPI LocalScheduleJob(HANDLE hPrinter, DWORD dwJobID) { - const WCHAR wszFolder[] = L"\\PRINTERS\\"; - const DWORD cchFolder = _countof(wszFolder) - 1; - DWORD dwAttributes; DWORD dwErrorCode; - PLOCAL_HANDLE pHandle; + HANDLE hThread; PLOCAL_JOB pJob; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle; WCHAR wszFullPath[MAX_PATH]; // Check if this is a printer handle. - pHandle = (PLOCAL_HANDLE)hPrinter; if (pHandle->HandleType != HandleType_Printer) { dwErrorCode = ERROR_INVALID_HANDLE; @@ -1031,10 +1075,15 @@ goto Cleanup; } + // Check if this Job was started with AddJob. + if (!pJob->bAddedJob) + { + dwErrorCode = ERROR_SPL_NO_ADDJOB; + goto Cleanup; + } + // Construct the full path to the spool file. - CopyMemory(wszFullPath, wszSpoolDirectory, cchSpoolDirectory * sizeof(WCHAR)); - CopyMemory(&wszFullPath[cchSpoolDirectory], wszFolder, cchFolder * sizeof(WCHAR)); - swprintf(&wszFullPath[cchSpoolDirectory + cchFolder], L"%05lu.SPL", dwJobID); + GetJobFilePath(L"SPL", dwJobID, wszFullPath); // Check if it exists. dwAttributes = GetFileAttributesW(wszFullPath); @@ -1052,6 +1101,19 @@ wcscpy(wcsrchr(wszFullPath, L'.'), L".SHD"); WriteJobShadowFile(wszFullPath, pJob); + // Create the thread for performing the printing process. + hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PrintingThreadProc, pJob, 0, NULL); + if (!hThread) + { + dwErrorCode = GetLastError(); + ERR("CreateThread failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + // We don't need the thread handle. Keeping it open blocks the thread from terminating. + CloseHandle(hThread); + + // ScheduleJob has done its job. The rest happens inside the thread. dwErrorCode = ERROR_SUCCESS; Cleanup: @@ -1134,7 +1196,7 @@ pJob->dwPriority = pShadowFile->dwPriority; pJob->dwStartTime = pShadowFile->dwStartTime; pJob->dwTotalPages = pShadowFile->dwTotalPages; - pJob->dwUntilTime = pShadowFile->dwUntilTime; + pJob->dwUntilTime = pShadowFile->dwUntilTime; pJob->pPrinter = pPrinter; pJob->pPrintProcessor = pPrintProcessor; pJob->pDevMode = DuplicateDevMode((PDEVMODEW)((ULONG_PTR)pShadowFile + pShadowFile->offDevMode)); @@ -1148,6 +1210,9 @@ pJob->pwszUserName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offUserName)); CopyMemory(&pJob->stSubmitted, &pShadowFile->stSubmitted, sizeof(SYSTEMTIME)); + + // Jobs read from shadow files were always added using AddJob. + pJob->bAddedJob = TRUE; pReturnValue = pJob; @@ -1303,15 +1368,38 @@ return bReturnValue; } -BOOL +void FreeJob(PLOCAL_JOB pJob) { - ////////// TODO ///////// - /// Add some checks + PWSTR pwszSHDFile; + + // Remove the Job from both Job Lists. + DeleteElementSkiplist(&pJob->pPrinter->JobList, pJob); + DeleteElementSkiplist(&GlobalJobList, pJob); + + // Try to delete the corresponding .SHD file. + pwszSHDFile = DllAllocSplMem(GetJobFilePath(L"SHD", 0, NULL)); + if (pwszSHDFile && GetJobFilePath(L"SHD", pJob->dwJobID, pwszSHDFile)) + DeleteFileW(pwszSHDFile); + + // Free memory for the mandatory fields. + DllFreeSplMem(pJob->pDevMode); DllFreeSplStr(pJob->pwszDatatype); DllFreeSplStr(pJob->pwszDocumentName); - DllFreeSplStr(pJob->pwszOutputFile); + DllFreeSplStr(pJob->pwszMachineName); + DllFreeSplStr(pJob->pwszNotifyName); + DllFreeSplStr(pJob->pwszUserName); + + // Free memory for the optional fields if they are present. + if (pJob->pwszOutputFile) + DllFreeSplStr(pJob->pwszOutputFile); + + if (pJob->pwszPrintProcessorParameters) + DllFreeSplStr(pJob->pwszPrintProcessorParameters); + + if (pJob->pwszStatus) + DllFreeSplStr(pJob->pwszStatus); + + // Finally free the job structure itself. DllFreeSplMem(pJob); - - return TRUE; -} +} Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/main.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/main.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/main.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -59,7 +59,7 @@ LocalWritePrinter, // fpWritePrinter LocalEndPagePrinter, // fpEndPagePrinter NULL, // fpAbortPrinter - NULL, // fpReadPrinter + LocalReadPrinter, // fpReadPrinter LocalEndDocPrinter, // fpEndDocPrinter LocalAddJob, // fpAddJob LocalScheduleJob, // fpScheduleJob Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/ports.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/ports.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/ports.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -11,8 +11,8 @@ static LIST_ENTRY _PortList; -PLOCAL_PRINT_MONITOR -FindPrintMonitorByPort(PCWSTR pwszName) +PLOCAL_PORT +FindPort(PCWSTR pwszName) { PLIST_ENTRY pEntry; PLOCAL_PORT pPort; @@ -22,7 +22,7 @@ pPort = CONTAINING_RECORD(pEntry, LOCAL_PORT, Entry); if (_wcsicmp(pPort->pwszName, pwszName) == 0) - return pPort->pPrintMonitor; + return pPort; } return NULL; Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/precomp.h URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/precomp.h [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/precomp.h [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -49,6 +49,32 @@ typedef LPMONITOR2(WINAPI *PInitializePrintMonitor2)(PMONITORINIT, PHANDLE); // Structures +/** + * Describes a Print Monitor. + */ +typedef struct _LOCAL_PRINT_MONITOR +{ + LIST_ENTRY Entry; + PWSTR pwszName; /** Name of the Print Monitor as read from the registry. */ + PWSTR pwszFileName; /** DLL File Name of the Print Monitor. */ + BOOL bIsLevel2; /** Whether this Print Monitor supplies an InitializePrintMonitor2 API (preferred) instead of InitializePrintMonitor. */ + PVOID pMonitor; /** For bIsLevel2 == TRUE: LPMONITOR2 pointer returned by InitializePrintMonitor2. + For bIsLevel2 == FALSE: LPMONITOREX pointer returned by InitializePrintMonitor. */ + HANDLE hMonitor; /** Only used when bIsLevel2 == TRUE: Handle returned by InitializePrintMonitor2. */ +} +LOCAL_PRINT_MONITOR, *PLOCAL_PRINT_MONITOR; + +/** + * Describes a Port handled by a Print Monitor. + */ +typedef struct _LOCAL_PORT +{ + LIST_ENTRY Entry; + PWSTR pwszName; /** The name of the port (including the trailing colon). */ + PLOCAL_PRINT_MONITOR pPrintMonitor; /** The Print Monitor handling this port. */ +} +LOCAL_PORT, *PLOCAL_PORT; + /** * Describes a Print Processor. */ @@ -83,6 +109,7 @@ PWSTR pwszDefaultDatatype; PDEVMODEW pDefaultDevMode; PLOCAL_PRINT_PROCESSOR pPrintProcessor; + PLOCAL_PORT pPort; SKIPLIST JobList; } LOCAL_PRINTER, *PLOCAL_PRINTER; @@ -94,26 +121,28 @@ typedef struct _LOCAL_JOB { // This sort key must be the first element for LookupElementSkiplist to work! - DWORD dwJobID; // Internal and external ID of this Job - - PLOCAL_PRINTER pPrinter; // Associated Printer to this Job - PLOCAL_PRINT_PROCESSOR pPrintProcessor; // Associated Print Processor to this Job - DWORD dwPriority; // Priority of this Job from MIN_PRIORITY to MAX_PRIORITY, default being DEF_PRIORITY - SYSTEMTIME stSubmitted; // Time of the submission of this Job - PWSTR pwszUserName; // User that submitted the Job - PWSTR pwszNotifyName; // User that shall be notified about the status of the Job - PWSTR pwszDocumentName; // Name of the Document that is printed - PWSTR pwszDatatype; // Datatype of the Document - PWSTR pwszOutputFile; // Output File to spool the Job to - PWSTR pwszPrintProcessorParameters; // Optional; Parameters for the chosen Print Processor - PWSTR pwszStatus; // Optional; a Status Message for the Job - DWORD dwTotalPages; // Total pages of the Document - DWORD dwPagesPrinted; // Number of pages that have already been printed - DWORD dwStartTime; // Earliest time in minutes since 12:00 AM UTC when this document can be printed - DWORD dwUntilTime; // Latest time in minutes since 12:00 AM UTC when this document can be printed - DWORD dwStatus; // JOB_STATUS_* flags of the Job - PWSTR pwszMachineName; // Name of the machine that submitted the Job (prepended with two backslashes) - PDEVMODEW pDevMode; // Associated Device Mode to this Job + DWORD dwJobID; /** Internal and external ID of this Job */ + + BOOL bAddedJob : 1; /** Whether AddJob has already been called on this Job. */ + HANDLE hPrintProcessor; /** Handle returned by OpenPrintProcessor while the Job is printing. */ + PLOCAL_PRINTER pPrinter; /** Associated Printer to this Job */ + PLOCAL_PRINT_PROCESSOR pPrintProcessor; /** Associated Print Processor to this Job */ + DWORD dwPriority; /** Priority of this Job from MIN_PRIORITY to MAX_PRIORITY, default being DEF_PRIORITY */ + SYSTEMTIME stSubmitted; /** Time of the submission of this Job */ + PWSTR pwszUserName; /** User that submitted the Job */ + PWSTR pwszNotifyName; /** User that shall be notified about the status of the Job */ + PWSTR pwszDocumentName; /** Name of the Document that is printed */ + PWSTR pwszDatatype; /** Datatype of the Document */ + PWSTR pwszOutputFile; /** Output File to spool the Job to */ + PWSTR pwszPrintProcessorParameters; /** Optional; Parameters for the chosen Print Processor */ + PWSTR pwszStatus; /** Optional; a Status Message for the Job */ + DWORD dwTotalPages; /** Total pages of the Document */ + DWORD dwPagesPrinted; /** Number of pages that have already been printed */ + DWORD dwStartTime; /** Earliest time in minutes since 12:00 AM UTC when this document can be printed */ + DWORD dwUntilTime; /** Latest time in minutes since 12:00 AM UTC when this document can be printed */ + DWORD dwStatus; /** JOB_STATUS_* flags of the Job */ + PWSTR pwszMachineName; /** Name of the machine that submitted the Job (prepended with two backslashes) */ + PDEVMODEW pDevMode; /** Associated Device Mode to this Job */ } LOCAL_JOB, *PLOCAL_JOB; @@ -126,8 +155,10 @@ */ typedef struct _LOCAL_PRINTER_HANDLE { + BOOL bStartedDoc : 1; /** Whether StartDocPrinter has already been called. */ + HANDLE hSPLFile; /** Handle to an opened SPL file for Printer Job handles. */ PLOCAL_PRINTER pPrinter; - PLOCAL_JOB pStartedJob; + PLOCAL_JOB pJob; PWSTR pwszDatatype; PDEVMODEW pDevMode; } @@ -148,32 +179,6 @@ PVOID pSpecificHandle; } LOCAL_HANDLE, *PLOCAL_HANDLE; - -/** - * Describes a Print Monitor. - */ -typedef struct _LOCAL_PRINT_MONITOR -{ - LIST_ENTRY Entry; - PWSTR pwszName; /** Name of the Print Monitor as read from the registry. */ - PWSTR pwszFileName; /** DLL File Name of the Print Monitor. */ - BOOL bIsLevel2; /** Whether this Print Monitor supplies an InitializePrintMonitor2 API (preferred) instead of InitializePrintMonitor. */ - PVOID pMonitor; /** For bIsLevel2 == TRUE: LPMONITOR2 pointer returned by InitializePrintMonitor2. - For bIsLevel2 == FALSE: LPMONITOREX pointer returned by InitializePrintMonitor. */ - HANDLE hMonitor; /** Only used when bIsLevel2 == TRUE: Handle returned by InitializePrintMonitor2. */ -} -LOCAL_PRINT_MONITOR, *PLOCAL_PRINT_MONITOR; - -/** - * Describes a Port handled by a Print Monitor. - */ -typedef struct _LOCAL_PORT -{ - LIST_ENTRY Entry; - PWSTR pwszName; /** The name of the port (including the trailing colon). */ - PLOCAL_PRINT_MONITOR pPrintMonitor; /** The Print Monitor handling this port. */ -} -LOCAL_PORT, *PLOCAL_PORT; /** * Describes the header of a print job serialized into a shadow file (.SHD) @@ -213,10 +218,11 @@ } SHD_HEADER, *PSHD_HEADER; - // jobs.c extern SKIPLIST GlobalJobList; -BOOL GetNextJobID(PDWORD dwJobID); +DWORD WINAPI CreateJob(PLOCAL_PRINTER_HANDLE pPrinterHandle); +void FreeJob(PLOCAL_JOB pJob); +DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput); BOOL InitializeGlobalJobList(); void InitializePrinterJobList(PLOCAL_PRINTER pPrinter); BOOL WINAPI LocalAddJob(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcbNeeded); @@ -242,7 +248,7 @@ BOOL WINAPI LocalEnumMonitors(PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned); // ports.c -PLOCAL_PRINT_MONITOR FindPrintMonitorByPort(PCWSTR pwszName); +PLOCAL_PORT FindPort(PCWSTR pwszName); BOOL InitializePortList(); BOOL WINAPI LocalEnumPorts(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned); @@ -251,12 +257,16 @@ BOOL InitializePrinterList(); BOOL WINAPI LocalEnumPrinters(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned); BOOL WINAPI LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDefault); +BOOL WINAPI LocalReadPrinter(HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pNoBytesRead); DWORD WINAPI LocalStartDocPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo); BOOL WINAPI LocalStartPagePrinter(HANDLE hPrinter); BOOL WINAPI LocalWritePrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten); BOOL WINAPI LocalEndPagePrinter(HANDLE hPrinter); BOOL WINAPI LocalEndDocPrinter(HANDLE hPrinter); BOOL WINAPI LocalClosePrinter(HANDLE hPrinter); + +// printingthread.c +DWORD WINAPI PrintingThreadProc(PLOCAL_JOB pJob); // printprocessors.c BOOL FindDatatype(const PLOCAL_PRINT_PROCESSOR pPrintProcessor, PCWSTR pwszDatatype); Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printers.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printers.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printers.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -45,8 +45,10 @@ DWORD i; HKEY hKey = NULL; HKEY hSubKey = NULL; + PLOCAL_PORT pPort; PLOCAL_PRINTER pPrinter = NULL; PLOCAL_PRINT_PROCESSOR pPrintProcessor; + PWSTR pwszPort = NULL; PWSTR pwszPrintProcessor = NULL; WCHAR wszPrinterName[MAX_PRINTER_NAME + 1]; @@ -138,6 +140,19 @@ if (!pPrintProcessor) { ERR("Invalid Print Processor \"%S\" for Printer \"%S\"!\n", pwszPrintProcessor, wszPrinterName); + continue; + } + + // Get the Port. + pwszPort = AllocAndRegQueryWSZ(hSubKey, L"Port"); + if (!pwszPort) + continue; + + // Try to find it in the Port List. + pPort = FindPort(pwszPort); + if (!pPort) + { + ERR("Invalid Port \"%S\" for Printer \"%S\"!\n", pwszPort, wszPrinterName); continue; } @@ -488,10 +503,12 @@ PWSTR pwszSecondParameter = NULL; PLOCAL_JOB pJob; PLOCAL_HANDLE pHandle = NULL; + PLOCAL_PORT pPort; PLOCAL_PRINT_MONITOR pPrintMonitor; PLOCAL_PRINTER pPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle = NULL; WCHAR wszComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + WCHAR wszFullPath[MAX_PATH]; // TODO: lpPrinterName == NULL is supported and means access to the local printer server. // Not sure yet if that is passed down to localspl.dll or processed in advance. @@ -502,6 +519,8 @@ dwErrorCode = ERROR_INVALID_PARAMETER; goto Cleanup; } + + *phPrinter = NULL; // Skip any server name in the first parameter. // Does lpPrinterName begin with two backslashes to indicate a server name? @@ -592,13 +611,15 @@ // "\\COMPUTERNAME\LPT1:, Port" // Look for this port in our Print Monitor Port list. - pPrintMonitor = FindPrintMonitorByPort(pwszFirstParameter); - if (!pPrintMonitor) + pPort = FindPort(pwszFirstParameter); + if (!pPort) { // The supplied port is unknown to all our Print Monitors. dwErrorCode = ERROR_INVALID_PRINTER_NAME; goto Cleanup; } + + pPrintMonitor = pPort->pPrintMonitor; // Call the monitor's OpenPort function. if (pPrintMonitor->bIsLevel2) @@ -649,13 +670,15 @@ pwszSecondParameter += 5; // Look for this port in our Print Monitor Port list. - pPrintMonitor = FindPrintMonitorByPort(pwszSecondParameter); - if (!pPrintMonitor) + pPort = FindPort(pwszFirstParameter); + if (!pPort) { // The supplied port is unknown to all our Print Monitors. dwErrorCode = ERROR_INVALID_PRINTER_NAME; goto Cleanup; } + + pPrintMonitor = pPort->pPrintMonitor; } else { @@ -706,6 +729,7 @@ goto Cleanup; } + pPrinterHandle->hSPLFile = INVALID_HANDLE_VALUE; pPrinterHandle->pPrinter = pPrinter; // Check if a datatype was given. @@ -732,7 +756,7 @@ else pPrinterHandle->pDevMode = DuplicateDevMode(pPrinter->pDefaultDevMode); - // Check if the caller wants a handle to an existing job. + // Check if the caller wants a handle to an existing Print Job. if (pwszSecondParameter) { // The "Job " string has to follow now. @@ -767,7 +791,19 @@ goto Cleanup; } - pPrinterHandle->pStartedJob = pJob; + // Try to open its SPL file. + GetJobFilePath(L"SPL", dwJobID, wszFullPath); + pPrinterHandle->hSPLFile = CreateFileW(wszFullPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + if (pPrinterHandle->hSPLFile == INVALID_HANDLE_VALUE) + { + dwErrorCode = GetLastError(); + ERR("CreateFileW failed with error %lu for \"%S\"!", dwErrorCode, wszFullPath); + goto Cleanup; + } + + // Associate the job to our Printer Handle, but don't set bStartedDoc. + // This prevents the caller from doing further StartDocPrinter, WritePrinter, etc. calls on it. + pPrinterHandle->pJob = pJob; } // Return the Printer handle through our general handle. @@ -805,38 +841,82 @@ return (dwErrorCode == ERROR_SUCCESS); } +BOOL WINAPI +LocalReadPrinter(HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pNoBytesRead) +{ + DWORD dwErrorCode; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + PLOCAL_PRINTER_HANDLE pPrinterHandle; + + // Sanity checks. + if (!pHandle || pHandle->HandleType != HandleType_Printer) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // ReadPrinter needs an opened SPL file to work. + // This only works if a Printer Job Handle was requested in OpenPrinter. + if (pPrinterHandle->hSPLFile == INVALID_HANDLE_VALUE) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // Pass the parameters to ReadFile. + if (!ReadFile(pPrinterHandle->hSPLFile, pBuf, cbBuf, pNoBytesRead, NULL)) + { + dwErrorCode = GetLastError(); + ERR("ReadFile failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); +} + DWORD WINAPI -LocalStartDocPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo) +LocalStartDocPrinter(HANDLE hPrinter, DWORD Level, PBYTE pDocInfo) { DWORD dwErrorCode; DWORD dwReturnValue = 0; - PDOC_INFO_1W pDocumentInfo1; - PLOCAL_HANDLE pHandle; - PLOCAL_JOB pJob; + PDOC_INFO_1W pDocInfo1 = (PDOC_INFO_1W)pDocInfo; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle; - // Sanity checks - if (!pDocInfo) + // Sanity checks. + if (!pDocInfo1) { dwErrorCode = ERROR_INVALID_PARAMETER; goto Cleanup; } - if (!hPrinter) + if (!pHandle || pHandle->HandleType != HandleType_Printer) { dwErrorCode = ERROR_INVALID_HANDLE; goto Cleanup; } - // Check if this is a printer handle. - pHandle = (PLOCAL_HANDLE)hPrinter; - if (pHandle->HandleType != HandleType_Printer) - { - dwErrorCode = ERROR_INVALID_HANDLE; - goto Cleanup; - } - pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // pJob may already be occupied if this is a Print Job handle. In this case, StartDocPrinter has to fail. + if (pPrinterHandle->pJob) + { + dwErrorCode = ERROR_INVALID_PARAMETER; + goto Cleanup; + } + + // Check the validity of the datatype if we got one. + if (pDocInfo1->pDatatype && !FindDatatype(pPrinterHandle->pJob->pPrintProcessor, pDocInfo1->pDatatype)) + { + dwErrorCode = ERROR_INVALID_DATATYPE; + goto Cleanup; + } // Check if this is the right document information level. if (Level != 1) @@ -845,68 +925,30 @@ goto Cleanup; } - pDocumentInfo1 = (PDOC_INFO_1W)pDocInfo; - - // Create a new job. - pJob = DllAllocSplMem(sizeof(LOCAL_JOB)); - pJob->pPrinter = pPrinterHandle->pPrinter; - pJob->dwPriority = DEF_PRIORITY; - - // Check if a datatype was given. - if (pDocumentInfo1->pDatatype) - { - // Use the datatype if it's valid. - if (!FindDatatype(pJob->pPrintProcessor, pDocumentInfo1->pDatatype)) - { - dwErrorCode = ERROR_INVALID_DATATYPE; - goto Cleanup; - } - - pJob->pwszDatatype = AllocSplStr(pDocumentInfo1->pDatatype); - } - else - { - // Use the printer handle datatype. - pJob->pwszDatatype = AllocSplStr(pPrinterHandle->pwszDatatype); - } - - // Copy over printer defaults. - pJob->pDevMode = DuplicateDevMode(pPrinterHandle->pDevMode); - - // Copy over supplied information. - if (pDocumentInfo1->pDocName) - pJob->pwszDocumentName = AllocSplStr(pDocumentInfo1->pDocName); - - if (pDocumentInfo1->pOutputFile) - pJob->pwszOutputFile = AllocSplStr(pDocumentInfo1->pOutputFile); - - // Get an ID for the new job. - if (!GetNextJobID(&pJob->dwJobID)) + // All requirements are met - create a new job. + dwErrorCode = CreateJob(pPrinterHandle); + if (dwErrorCode != ERROR_SUCCESS) + goto Cleanup; + + // Use any given datatype. + if (pDocInfo1->pDatatype && !ReallocSplStr(&pPrinterHandle->pJob->pwszDatatype, pDocInfo1->pDatatype)) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; - goto Cleanup; - } - - // Add the job to the Global Job List. - if (!InsertElementSkiplist(&GlobalJobList, pJob)) + ERR("ReallocSplStr failed, last error is %lu!\n", GetLastError()); + goto Cleanup; + } + + // Use any given document name. + if (pDocInfo1->pDocName && !ReallocSplStr(&pPrinterHandle->pJob->pwszDocumentName, pDocInfo1->pDocName)) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; - ERR("InsertElementSkiplist failed for job %lu for the GlobalJobList!\n", pJob->dwJobID); - goto Cleanup; - } - - // Add the job at the end of the Printer's Job List. - // As all new jobs are created with default priority, we can be sure that it would always be inserted at the end. - if (!InsertTailElementSkiplist(&pJob->pPrinter->JobList, pJob)) - { - dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; - ERR("InsertTailElementSkiplist failed for job %lu for the Printer's Job List!\n", pJob->dwJobID); - goto Cleanup; - } - - pPrinterHandle->pStartedJob = pJob; + ERR("ReallocSplStr failed, last error is %lu!\n", GetLastError()); + goto Cleanup; + } + + // We were successful! dwErrorCode = ERROR_SUCCESS; - dwReturnValue = pJob->dwJobID; + dwReturnValue = pPrinterHandle->pJob->dwJobID; Cleanup: SetLastError(dwErrorCode); @@ -916,48 +958,170 @@ BOOL WINAPI LocalStartPagePrinter(HANDLE hPrinter) { - ///////////// TODO ///////////////////// - return FALSE; + DWORD dwErrorCode; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + PLOCAL_PRINTER_HANDLE pPrinterHandle; + + // Sanity checks. + if (!pHandle || pHandle->HandleType != HandleType_Printer) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // We require StartDocPrinter or AddJob to be called first. + if (!pPrinterHandle->bStartedDoc) + { + dwErrorCode = ERROR_SPL_NO_STARTDOC; + goto Cleanup; + } + + // Increase the page count. + ++pPrinterHandle->pJob->dwTotalPages; + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI LocalWritePrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten) { - ///////////// TODO ///////////////////// - return FALSE; + DWORD dwErrorCode; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + PLOCAL_PRINTER_HANDLE pPrinterHandle; + + // Sanity checks. + if (!pHandle || pHandle->HandleType != HandleType_Printer) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // We require StartDocPrinter or AddJob to be called first. + if (!pPrinterHandle->bStartedDoc) + { + dwErrorCode = ERROR_SPL_NO_STARTDOC; + goto Cleanup; + } + + // TODO: This function is only called when doing non-spooled printing. + // This needs to be investigated further. We can't just use pPrinterHandle->hSPLFile here, because that's currently reserved for Printer Job handles (see LocalReadPrinter). +#if 0 + // Pass the parameters to WriteFile. + if (!WriteFile(SOME_SPOOL_FILE_HANDLE, pBuf, cbBuf, pcWritten, NULL)) + { + dwErrorCode = GetLastError(); + ERR("WriteFile failed with error %lu!\n", GetLastError()); + goto Cleanup; + } +#endif + + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI LocalEndPagePrinter(HANDLE hPrinter) { - ///////////// TODO ///////////////////// - return FALSE; + DWORD dwErrorCode; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + + // Sanity checks. + if (!pHandle || pHandle->HandleType != HandleType_Printer) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + // This function doesn't do anything else for now. + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI LocalEndDocPrinter(HANDLE hPrinter) { - ///////////// TODO ///////////////////// - return FALSE; + DWORD dwErrorCode; + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + PLOCAL_PRINTER_HANDLE pPrinterHandle; + + // Sanity checks. + if (!pHandle || pHandle->HandleType != HandleType_Printer) + { + dwErrorCode = ERROR_INVALID_HANDLE; + goto Cleanup; + } + + pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // We require StartDocPrinter or AddJob to be called first. + if (!pPrinterHandle->bStartedDoc) + { + dwErrorCode = ERROR_SPL_NO_STARTDOC; + goto Cleanup; + } + + // TODO: Something like ScheduleJob + + // Finish the job. + pPrinterHandle->bStartedDoc = FALSE; + pPrinterHandle->pJob = NULL; + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + SetLastError(dwErrorCode); + return (dwErrorCode == ERROR_SUCCESS); } BOOL WINAPI LocalClosePrinter(HANDLE hPrinter) { - PLOCAL_HANDLE pHandle; - - if (!hPrinter) + PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + PLOCAL_PRINTER_HANDLE pPrinterHandle; + + if (!pHandle) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - pHandle = (PLOCAL_HANDLE)hPrinter; - - ///////////// TODO ///////////////////// - /// Check the handle type, do thoroughful checks on all data fields and clean them. - //////////////////////////////////////// - + if (pHandle->HandleType == HandleType_Port) + { + // TODO + } + else if (pHandle->HandleType == HandleType_Printer) + { + pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; + + // Terminate any started job. + if (pPrinterHandle->pJob) + FreeJob(pPrinterHandle->pJob); + + // Free memory for the fields. + DllFreeSplMem(pPrinterHandle->pDevMode); + DllFreeSplStr(pPrinterHandle->pwszDatatype); + + // Free memory for the printer handle itself. + DllFreeSplMem(pPrinterHandle); + } + else if (pHandle->HandleType == HandleType_Xcv) + { + // TODO + } + + // Free memory for the handle itself. DllFreeSplMem(pHandle); return TRUE; Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printingthread.c URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printingthread.c (added) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printingthread.c [iso-8859-1] Thu Jul 16 15:03:47 2015 @@ -0,0 +1,119 @@ +/* + * PROJECT: ReactOS Local Spooler + * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation + * PURPOSE: Implementation of the Thread that actually performs the printing process + * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + */ + +#include "precomp.h" + +DWORD WINAPI +PrintingThreadProc(PLOCAL_JOB pJob) +{ + const DWORD cchMaxJobIdDigits = 5; // Job ID is limited to 5 decimal digits, see IS_VALID_JOB_ID + const WCHAR wszJobAppendix[] = L", Job "; + const DWORD cchJobAppendix = _countof(wszJobAppendix) - 1; + const WCHAR wszPortAppendix[] = L", Port"; + + DWORD cchPortName; + DWORD cchPrinterName; + DWORD dwErrorCode; + HANDLE hPrintProcessor = NULL; + PLOCAL_PRINT_PROCESSOR pPrintProcessor = pJob->pPrintProcessor; + PRINTPROCESSOROPENDATA OpenData; + PWSTR pwszPrinterAndJob = NULL; + PWSTR pwszPrinterPort = NULL; + PWSTR pwszSPLFile = NULL; + + // Prepare the pPrinterName parameter. + // This is the string for LocalOpenPrinter to open a port (e.g. "LPT1:, Port"). + cchPortName = wcslen(pJob->pPrinter->pPort->pwszName); + pwszPrinterPort = DllAllocSplMem(cchPortName * sizeof(WCHAR) + sizeof(wszPortAppendix)); + if (!pwszPrinterPort) + { + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("DllAllocSplMem failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + CopyMemory(pwszPrinterPort, pJob->pPrinter->pPort->pwszName, cchPortName * sizeof(WCHAR)); + CopyMemory(&pwszPrinterPort[cchPortName], wszPortAppendix, sizeof(wszPortAppendix)); + + // Prepare the pPrintProcessorOpenData parameter. + OpenData.JobId = pJob->dwJobID; + OpenData.pDatatype = pJob->pwszDatatype; + OpenData.pDevMode = pJob->pDevMode; + OpenData.pDocumentName = pJob->pwszDocumentName; + OpenData.pOutputFile = NULL; + OpenData.pParameters = pJob->pwszPrintProcessorParameters; + OpenData.pPrinterName = pJob->pPrinter->pwszPrinterName; + + // Open a handle to the Print Processor. + hPrintProcessor = pPrintProcessor->pfnOpenPrintProcessor(pwszPrinterPort, &OpenData); + if (!hPrintProcessor) + { + dwErrorCode = GetLastError(); + ERR("OpenPrintProcessor failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + // Let other functions use the Print Processor as well while it's opened. + pJob->hPrintProcessor = hPrintProcessor; + + // Prepare the pDocumentName parameter. + cchPrinterName = wcslen(OpenData.pPrinterName); + pwszPrinterAndJob = DllAllocSplMem((cchPrinterName + cchJobAppendix + cchMaxJobIdDigits + 1) * sizeof(WCHAR)); + if (!pwszPrinterAndJob) + { + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("DllAllocSplMem failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + CopyMemory(pwszPrinterAndJob, OpenData.pPrinterName, cchPrinterName * sizeof(WCHAR)); + CopyMemory(&pwszPrinterAndJob[cchPrinterName], wszJobAppendix, cchJobAppendix * sizeof(WCHAR)); + _ultow(OpenData.JobId, &pwszPrinterAndJob[cchPrinterName + cchJobAppendix], 10); + + // Print the document. + // Note that pJob is freed after this function, so we may not access it anymore. + if (!pPrintProcessor->pfnPrintDocumentOnPrintProcessor(hPrintProcessor, pwszPrinterAndJob)) + { + dwErrorCode = GetLastError(); + ERR("PrintDocumentOnPrintProcessor failed with error %lu!\n", dwErrorCode); + goto Cleanup; + } + + // Close the Print Processor. + pPrintProcessor->pfnClosePrintProcessor(hPrintProcessor); + hPrintProcessor = NULL; + + // Delete the spool file. + pwszSPLFile = DllAllocSplMem(GetJobFilePath(L"SPL", 0, NULL)); + if (!pwszSPLFile) + { + dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + ERR("DllAllocSplMem failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + GetJobFilePath(L"SPL", OpenData.JobId, pwszSPLFile); + DeleteFileW(pwszSPLFile); + + // We were successful! + dwErrorCode = ERROR_SUCCESS; + +Cleanup: + if (hPrintProcessor) + pPrintProcessor->pfnClosePrintProcessor(hPrintProcessor); + + if (pwszPrinterPort) + DllFreeSplMem(pwszPrinterPort); + + if (pwszPrinterAndJob) + DllFreeSplMem(pwszPrinterAndJob); + + if (pwszSPLFile) + DllFreeSplMem(pwszSPLFile); + + return dwErrorCode; +} Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printingthread.c ------------------------------------------------------------------------------ svn:eol-style = native
9 years, 5 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
26
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Results per page:
10
25
50
100
200