Author: cfinck Date: Mon Jul 20 15:21:03 2015 New Revision: 68471
URL: http://svn.reactos.org/svn/reactos?rev=68471&view=rev Log: It's bugfixing time!
[LOCALSPL] - A Print Job has more optional fields than I thought. Only do a wcslen on them if they are not NULL. - Make the code for checking changed fields more robust. Add checks for NULL to the Find and Compare functions. - Fix some wrong parameters given to CopyMemory. - Set the pPort field of a LOCAL_PRINTER structure.
[WINSPOOL] Only pass the datatype from the DOC_INFO_1W structure of StartDocPrinterW to SetJobW if it's not NULL. For StartDocPrinterW, this means that the datatype shall not be changed while SetJobW would return ERROR_INVALID_DATATYPE if none was passed.
Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/winspool/printers.c branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/jobs.c branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/monitors.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 branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/printprocessors.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/reac... ============================================================================== --- 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] Mon Jul 20 15:21:03 2015 @@ -89,7 +89,9 @@ }
// Add our document information. - pJobInfo1->pDatatype = pDocInfo1->pDatatype; + if (pDocInfo1->pDatatype) + pJobInfo1->pDatatype = pDocInfo1->pDatatype; + pJobInfo1->pDocument = pDocInfo1->pDocName;
// Set the new job information.
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/reac... ============================================================================== --- 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] Mon Jul 20 15:21:03 2015 @@ -13,6 +13,36 @@ // Local Variables static DWORD _dwLastJobID;
+ +/** + * @name _EqualStrings + * + * Returns whether two strings are equal. + * Unlike wcscmp, this function also works with NULL strings. + * + * @param pwszA + * First string to compare. + * + * @param pwszB + * Second string to compare. + * + * @return + * TRUE if the strings are equal, FALSE if they differ. + */ +static __inline BOOL +_EqualStrings(PCWSTR pwszA, PCWSTR pwszB) +{ + if (!pwszA && !pwszB) + return TRUE; + + if (pwszA && !pwszB) + return FALSE; + + if (!pwszA && pwszB) + return FALSE; + + return (wcscmp(pwszA, pwszB) == 0); +}
static BOOL _GetNextJobID(PDWORD dwJobID) @@ -112,8 +142,8 @@
if (pwszOutput) { - CopyMemory(pwszOutput, wszSpoolDirectory, cchSpoolDirectory); - CopyMemory(&pwszOutput[cchSpoolDirectory], wszPrintersPath, cchPrintersPath); + CopyMemory(pwszOutput, wszSpoolDirectory, cchSpoolDirectory * sizeof(WCHAR)); + CopyMemory(&pwszOutput[cchSpoolDirectory], wszPrintersPath, cchPrintersPath * sizeof(WCHAR)); swprintf(&pwszOutput[cchSpoolDirectory + cchPrintersPath], L"%05lu.", dwJobID); CopyMemory(&pwszOutput[cchSpoolDirectory + cchPrintersPath + cchSpoolerFile], pwszExtension, (cchExtension + 1) * sizeof(WCHAR)); } @@ -291,7 +321,7 @@ cchMachineName = wcslen(pwszMachineName); pJob->pwszMachineName = DllAllocSplMem((cchMachineName + cchDoubleBackslash + 1) * sizeof(WCHAR)); CopyMemory(pJob->pwszMachineName, wszDoubleBackslash, cchDoubleBackslash * sizeof(WCHAR)); - CopyMemory(pJob->pwszMachineName + cchDoubleBackslash, pwszMachineName, (cchMachineName + 1) * sizeof(WCHAR)); + CopyMemory(&pJob->pwszMachineName[cchDoubleBackslash], pwszMachineName, (cchMachineName + 1) * sizeof(WCHAR));
// Add the job to the Global Job List. if (!InsertElementSkiplist(&GlobalJobList, pJob)) @@ -406,17 +436,23 @@ _LocalGetJobLevel1(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE* ppStart, PBYTE* ppEnd, DWORD cbBuf, PDWORD pcbNeeded) { DWORD cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); - DWORD cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + DWORD cbDocumentName = 0; DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); DWORD cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); DWORD cbStatus = 0; - DWORD cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); + DWORD cbUserName = 0; DWORD dwErrorCode; JOB_INFO_1W JobInfo1 = { 0 };
- // A Status Message is optional. + // Calculate the lengths of the optional values. + if (pJob->pwszDocumentName) + cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + if (pJob->pwszStatus) cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR); + + if (pJob->pwszUserName) + cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR);
// Check if the supplied buffer is large enough. *pcbNeeded += sizeof(JOB_INFO_1W) + cbDatatype + cbDocumentName + cbMachineName + cbPrinterName + cbStatus + cbUserName; @@ -431,10 +467,6 @@ JobInfo1.pDatatype = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pwszDatatype, cbDatatype);
- *ppEnd -= cbDocumentName; - JobInfo1.pDocument = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszDocumentName, cbDocumentName); - *ppEnd -= cbMachineName; JobInfo1.pMachineName = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pwszMachineName, cbMachineName); @@ -443,6 +475,14 @@ JobInfo1.pPrinterName = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pPrinter->pwszPrinterName, cbPrinterName);
+ // Copy the optional values. + if (cbDocumentName) + { + *ppEnd -= cbDocumentName; + JobInfo1.pDocument = (PWSTR)*ppEnd; + CopyMemory(*ppEnd, pJob->pwszDocumentName, cbDocumentName); + } + if (cbStatus) { *ppEnd -= cbStatus; @@ -450,9 +490,12 @@ CopyMemory(*ppEnd, pJob->pwszStatus, cbStatus); }
- *ppEnd -= cbUserName; - JobInfo1.pUserName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszUserName, cbUserName); + if (cbUserName) + { + *ppEnd -= cbUserName; + JobInfo1.pUserName = (PWSTR)*ppEnd; + CopyMemory(*ppEnd, pJob->pwszUserName, cbUserName); + }
// Fill the rest of the structure. JobInfo1.JobId = pJob->dwJobID; @@ -475,15 +518,15 @@ { DWORD cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); DWORD cbDevMode = pJob->pDevMode->dmSize + pJob->pDevMode->dmDriverExtra; - DWORD cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + DWORD cbDocumentName = 0; DWORD cbDriverName = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR); DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); - DWORD cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR); + DWORD cbNotifyName = 0; DWORD cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); DWORD cbPrintProcessor = (wcslen(pJob->pPrintProcessor->pwszName) + 1) * sizeof(WCHAR); DWORD cbPrintProcessorParameters = 0; DWORD cbStatus = 0; - DWORD cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); + DWORD cbUserName = 0; DWORD dwErrorCode; FILETIME ftNow; FILETIME ftSubmitted; @@ -491,12 +534,21 @@ ULARGE_INTEGER uliNow; ULARGE_INTEGER uliSubmitted;
- // Print Processor Parameters and Status Message are optional. + // Calculate the lengths of the optional values. + if (pJob->pwszDocumentName) + cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + + if (pJob->pwszNotifyName) + cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR); + if (pJob->pwszPrintProcessorParameters) cbPrintProcessorParameters = (wcslen(pJob->pwszPrintProcessorParameters) + 1) * sizeof(WCHAR);
if (pJob->pwszStatus) cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR); + + if (pJob->pwszUserName) + cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR);
// Check if the supplied buffer is large enough. *pcbNeeded += sizeof(JOB_INFO_2W) + cbDatatype + cbDevMode + cbDocumentName + cbDriverName + cbMachineName + cbNotifyName + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbStatus + cbUserName; @@ -515,10 +567,6 @@ JobInfo2.pDevMode = (PDEVMODEW)*ppEnd; CopyMemory(*ppEnd, pJob->pDevMode, cbDevMode);
- *ppEnd -= cbDocumentName; - JobInfo2.pDocument = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszDocumentName, cbDocumentName); - *ppEnd -= cbDriverName; JobInfo2.pDriverName = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pPrinter->pwszPrinterDriver, cbDriverName); @@ -527,10 +575,6 @@ JobInfo2.pMachineName = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pwszMachineName, cbMachineName);
- *ppEnd -= cbNotifyName; - JobInfo2.pNotifyName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszNotifyName, cbNotifyName); - *ppEnd -= cbPrinterName; JobInfo2.pPrinterName = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pPrinter->pwszPrinterName, cbPrinterName); @@ -539,6 +583,21 @@ JobInfo2.pPrintProcessor = (PWSTR)*ppEnd; CopyMemory(*ppEnd, pJob->pPrintProcessor->pwszName, cbPrintProcessor);
+ // Copy the optional values. + if (cbDocumentName) + { + *ppEnd -= cbDocumentName; + JobInfo2.pDocument = (PWSTR)*ppEnd; + CopyMemory(*ppEnd, pJob->pwszDocumentName, cbDocumentName); + } + + if (cbNotifyName) + { + *ppEnd -= cbNotifyName; + JobInfo2.pNotifyName = (PWSTR)*ppEnd; + CopyMemory(*ppEnd, pJob->pwszNotifyName, cbNotifyName); + } + if (cbPrintProcessorParameters) { *ppEnd -= cbPrintProcessorParameters; @@ -553,9 +612,12 @@ CopyMemory(*ppEnd, pJob->pwszStatus, cbStatus); }
- *ppEnd -= cbUserName; - JobInfo2.pUserName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszUserName, cbUserName); + if (cbUserName) + { + *ppEnd -= cbUserName; + JobInfo2.pUserName = (PWSTR)*ppEnd; + CopyMemory(*ppEnd, pJob->pwszUserName, cbUserName); + }
// Time in JOB_INFO_2W is the number of milliseconds elapsed since the job was submitted. Calculate this time. if (!SystemTimeToFileTime(&pJob->stSubmitted, &ftSubmitted)) @@ -658,7 +720,7 @@ }
// Check if the datatype has changed. - if (wcscmp(pJob->pwszDatatype, pJobInfo->pDatatype) != 0) + if (!_EqualStrings(pJob->pwszDatatype, pJobInfo->pDatatype)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszDatatype, pJobInfo->pDatatype)) @@ -669,8 +731,8 @@ } }
- // Check if the document name has changed. - if (wcscmp(pJob->pwszDocumentName, pJobInfo->pDocument) != 0) + // Check if the document name has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszDocumentName, pJobInfo->pDocument)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszDocumentName, pJobInfo->pDocument)) @@ -681,8 +743,8 @@ } }
- // Check if the status message has changed. - if ((!pJob->pwszStatus && pJobInfo->pStatus) || wcscmp(pJob->pwszStatus, pJobInfo->pStatus) != 0) + // Check if the status message has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszStatus, pJobInfo->pStatus)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszStatus, pJobInfo->pStatus)) @@ -693,8 +755,8 @@ } }
- // Check if the user name has changed. - if (wcscmp(pJob->pwszUserName, pJobInfo->pUserName) != 0) + // Check if the user name has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszUserName, pJobInfo->pUserName) != 0) { // The new user name doesn't need to exist, so no additional verification is required.
@@ -763,7 +825,7 @@ }
// Check if the datatype has changed. - if (wcscmp(pJob->pwszDatatype, pJobInfo->pDatatype) != 0) + if (!_EqualStrings(pJob->pwszDatatype, pJobInfo->pDatatype)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszDatatype, pJobInfo->pDatatype)) @@ -774,8 +836,8 @@ } }
- // Check if the document name has changed. - if (wcscmp(pJob->pwszDocumentName, pJobInfo->pDocument) != 0) + // Check if the document name has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszDocumentName, pJobInfo->pDocument)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszDocumentName, pJobInfo->pDocument)) @@ -786,8 +848,8 @@ } }
- // Check if the notify name has changed. - if (wcscmp(pJob->pwszNotifyName, pJobInfo->pNotifyName) != 0) + // Check if the notify name has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszNotifyName, pJobInfo->pNotifyName)) { // The new notify name doesn't need to exist, so no additional verification is required.
@@ -800,8 +862,8 @@ } }
- // Check if the (optional) Print Processor Parameters have changed. - if ((!pJob->pwszPrintProcessorParameters && pJobInfo->pParameters) || wcscmp(pJob->pwszPrintProcessorParameters, pJobInfo->pParameters) != 0) + // Check if the Print Processor Parameters have changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszPrintProcessorParameters, pJobInfo->pParameters)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszPrintProcessorParameters, pJobInfo->pParameters)) @@ -812,8 +874,8 @@ } }
- // Check if the (optional) Status Message has changed. - if ((!pJob->pwszStatus && pJobInfo->pStatus) || wcscmp(pJob->pwszStatus, pJobInfo->pStatus) != 0) + // Check if the Status Message has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszStatus, pJobInfo->pStatus)) { // Use the new value. if (!ReallocSplStr(&pJob->pwszStatus, pJobInfo->pStatus)) @@ -824,8 +886,8 @@ } }
- // Check if the user name has changed. - if (wcscmp(pJob->pwszUserName, pJobInfo->pUserName) != 0) + // Check if the user name has changed. An empty string is permitted here! + if (!_EqualStrings(pJob->pwszUserName, pJobInfo->pUserName)) { // The new user name doesn't need to exist, so no additional verification is required.
@@ -1201,15 +1263,21 @@ pJob->pPrintProcessor = pPrintProcessor; pJob->pDevMode = DuplicateDevMode((PDEVMODEW)((ULONG_PTR)pShadowFile + pShadowFile->offDevMode)); pJob->pwszDatatype = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDatatype)); - pJob->pwszDocumentName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDocumentName)); pJob->pwszMachineName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offMachineName)); - pJob->pwszNotifyName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offNotifyName)); + CopyMemory(&pJob->stSubmitted, &pShadowFile->stSubmitted, sizeof(SYSTEMTIME)); + + // Copy the optional values. + if (pShadowFile->offDocumentName) + pJob->pwszDocumentName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDocumentName)); + + if (pShadowFile->offNotifyName) + pJob->pwszNotifyName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offNotifyName));
if (pShadowFile->offPrintProcessorParameters) pJob->pwszPrintProcessorParameters = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offPrintProcessorParameters));
- pJob->pwszUserName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offUserName)); - CopyMemory(&pJob->stSubmitted, &pShadowFile->stSubmitted, sizeof(SYSTEMTIME)); + if (pShadowFile->offUserName) + pJob->pwszUserName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offUserName));
// Jobs read from shadow files were always added using AddJob. pJob->bAddedJob = TRUE; @@ -1230,17 +1298,17 @@ WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob) { BOOL bReturnValue = FALSE; - DWORD cbDatatype; - DWORD cbDevMode; - DWORD cbDocumentName; + DWORD cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); + DWORD cbDevMode = pJob->pDevMode->dmSize + pJob->pDevMode->dmDriverExtra; + DWORD cbDocumentName = 0; DWORD cbFileSize; - DWORD cbMachineName; - DWORD cbNotifyName; - DWORD cbPrinterDriver; - DWORD cbPrinterName; - DWORD cbPrintProcessor; + DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); + DWORD cbNotifyName = 0; + DWORD cbPrinterDriver = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR); + DWORD cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); + DWORD cbPrintProcessor = (wcslen(pJob->pPrintProcessor->pwszName) + 1) * sizeof(WCHAR); DWORD cbPrintProcessorParameters = 0; - DWORD cbUserName; + DWORD cbUserName = 0; DWORD cbWritten; DWORD dwCurrentOffset; HANDLE hSHDFile = INVALID_HANDLE_VALUE; @@ -1255,20 +1323,18 @@ goto Cleanup; }
- // Compute the total size of the shadow file. - cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); - cbDevMode = pJob->pDevMode->dmSize + pJob->pDevMode->dmDriverExtra; - cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); - cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); - cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR); - cbPrinterDriver = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR); - cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); - cbPrintProcessor = (wcslen(pJob->pPrintProcessor->pwszName) + 1) * sizeof(WCHAR); - cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); - - // Print Processor Parameters are optional. + // Calculate the lengths of the optional values and the total size of the shadow file. + if (pJob->pwszDocumentName) + cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + + if (pJob->pwszNotifyName) + cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR); + if (pJob->pwszPrintProcessorParameters) cbPrintProcessorParameters = (wcslen(pJob->pwszPrintProcessorParameters) + 1) * sizeof(WCHAR); + + if (pJob->pwszUserName) + cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR);
cbFileSize = sizeof(SHD_HEADER) + cbDatatype + cbDocumentName + cbDevMode + cbMachineName + cbNotifyName + cbPrinterDriver + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbUserName;
@@ -1306,10 +1372,6 @@ pShadowFile->offDatatype = dwCurrentOffset; dwCurrentOffset += cbDatatype;
- CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszDocumentName, cbDocumentName); - pShadowFile->offDocumentName = dwCurrentOffset; - dwCurrentOffset += cbDocumentName; - CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pDevMode, cbDevMode); pShadowFile->offDevMode = dwCurrentOffset; dwCurrentOffset += cbDevMode; @@ -1323,10 +1385,6 @@ pShadowFile->offMachineName = dwCurrentOffset; dwCurrentOffset += cbMachineName;
- CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszNotifyName, cbNotifyName); - pShadowFile->offNotifyName = dwCurrentOffset; - dwCurrentOffset += cbNotifyName; - CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pPrinter->pwszPrinterName, cbPrinterName); pShadowFile->offPrinterName = dwCurrentOffset; dwCurrentOffset += cbPrinterName; @@ -1335,6 +1393,21 @@ pShadowFile->offPrintProcessor = dwCurrentOffset; dwCurrentOffset += cbPrintProcessor;
+ // Copy the optional values. + if (cbDocumentName) + { + CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszDocumentName, cbDocumentName); + pShadowFile->offDocumentName = dwCurrentOffset; + dwCurrentOffset += cbDocumentName; + } + + if (cbNotifyName) + { + CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszNotifyName, cbNotifyName); + pShadowFile->offNotifyName = dwCurrentOffset; + dwCurrentOffset += cbNotifyName; + } + if (cbPrintProcessorParameters) { CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszPrintProcessorParameters, cbPrintProcessorParameters); @@ -1342,9 +1415,12 @@ dwCurrentOffset += cbPrintProcessorParameters; }
- CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszUserName, cbUserName); - pShadowFile->offUserName = dwCurrentOffset; - dwCurrentOffset += cbUserName; + if (cbUserName) + { + CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pwszUserName, cbUserName); + pShadowFile->offUserName = dwCurrentOffset; + dwCurrentOffset += cbUserName; + }
// Write the file. if (!WriteFile(hSHDFile, pShadowFile, cbFileSize, &cbWritten, NULL))
Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/monitors.c URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/reac... ============================================================================== --- branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/monitors.c [iso-8859-1] (original) +++ branches/colins-printing-for-freedom/reactos/win32ss/printing/providers/localspl/monitors.c [iso-8859-1] Mon Jul 20 15:21:03 2015 @@ -16,6 +16,9 @@ { PLIST_ENTRY pEntry; PLOCAL_PRINT_MONITOR pPrintMonitor; + + if (!pwszName) + return NULL;
for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink) {
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/reac... ============================================================================== --- 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] Mon Jul 20 15:21:03 2015 @@ -16,6 +16,9 @@ { PLIST_ENTRY pEntry; PLOCAL_PORT pPort; + + if (!pwszName) + return NULL;
for (pEntry = _PortList.Flink; pEntry != &_PortList; pEntry = pEntry->Flink) {
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/reac... ============================================================================== --- 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] Mon Jul 20 15:21:03 2015 @@ -129,9 +129,9 @@ 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 pwszUserName; /** Optional; User that submitted the Job */ + PWSTR pwszNotifyName; /** Optional; User that shall be notified about the status of the Job */ + PWSTR pwszDocumentName; /** Optional; 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 */
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/reac... ============================================================================== --- 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] Mon Jul 20 15:21:03 2015 @@ -167,6 +167,7 @@
pPrinter->pwszPrinterName = AllocSplStr(wszPrinterName); pPrinter->pPrintProcessor = pPrintProcessor; + pPrinter->pPort = pPort; InitializePrinterJobList(pPrinter);
// Get the printer driver.
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/reac... ============================================================================== --- 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] Mon Jul 20 15:21:03 2015 @@ -78,6 +78,9 @@ DWORD i; PDATATYPES_INFO_1W pCurrentDatatype = pPrintProcessor->pDatatypesInfo1;
+ if (!pwszDatatype) + return FALSE; + for (i = 0; i < pPrintProcessor->dwDatatypeCount; i++) { if (wcsicmp(pCurrentDatatype->pName, pwszDatatype) == 0) @@ -94,6 +97,9 @@ { PLIST_ENTRY pEntry; PLOCAL_PRINT_PROCESSOR pPrintProcessor; + + if (!pwszName) + return NULL;
for (pEntry = _PrintProcessorList.Flink; pEntry != &_PrintProcessorList; pEntry = pEntry->Flink) {