mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[LOCALSPL]
Bugfix: Copy the full DevMode including the extra data by the driver. svn path=/branches/colins-printing-for-freedom/; revision=68379
This commit is contained in:
parent
b83f56253b
commit
7ed643eb9c
4 changed files with 64 additions and 20 deletions
|
@ -279,7 +279,7 @@ LocalAddJob(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcb
|
||||||
pJob->dwStatus = JOB_STATUS_SPOOLING;
|
pJob->dwStatus = JOB_STATUS_SPOOLING;
|
||||||
pJob->pwszDatatype = AllocSplStr(pPrinterHandle->pwszDatatype);
|
pJob->pwszDatatype = AllocSplStr(pPrinterHandle->pwszDatatype);
|
||||||
pJob->pwszDocumentName = AllocSplStr(wszDefaultDocumentName);
|
pJob->pwszDocumentName = AllocSplStr(wszDefaultDocumentName);
|
||||||
CopyMemory(&pJob->DevMode, &pPrinterHandle->DevMode, sizeof(DEVMODEW));
|
pJob->pDevMode = DuplicateDevMode(pPrinterHandle->pDevMode);
|
||||||
GetSystemTime(&pJob->stSubmitted);
|
GetSystemTime(&pJob->stSubmitted);
|
||||||
|
|
||||||
// Get the user name for the Job.
|
// Get the user name for the Job.
|
||||||
|
@ -440,6 +440,7 @@ static DWORD
|
||||||
_LocalGetJobLevel2(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE* ppStart, PBYTE* ppEnd, DWORD cbBuf, PDWORD pcbNeeded)
|
_LocalGetJobLevel2(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE* ppStart, PBYTE* ppEnd, DWORD cbBuf, PDWORD pcbNeeded)
|
||||||
{
|
{
|
||||||
DWORD cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR);
|
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 = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR);
|
||||||
DWORD cbDriverName = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR);
|
DWORD cbDriverName = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR);
|
||||||
DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR);
|
DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR);
|
||||||
|
@ -464,7 +465,7 @@ _LocalGetJobLevel2(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE*
|
||||||
cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR);
|
cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR);
|
||||||
|
|
||||||
// Check if the supplied buffer is large enough.
|
// Check if the supplied buffer is large enough.
|
||||||
*pcbNeeded += sizeof(JOB_INFO_2W) + cbDatatype + sizeof(DEVMODEW) + cbDocumentName + cbDriverName + cbMachineName + cbNotifyName + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbStatus + cbUserName;
|
*pcbNeeded += sizeof(JOB_INFO_2W) + cbDatatype + cbDevMode + cbDocumentName + cbDriverName + cbMachineName + cbNotifyName + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbStatus + cbUserName;
|
||||||
if (cbBuf < *pcbNeeded)
|
if (cbBuf < *pcbNeeded)
|
||||||
{
|
{
|
||||||
dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
|
dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
@ -476,9 +477,9 @@ _LocalGetJobLevel2(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE*
|
||||||
JobInfo2.pDatatype = (PWSTR)*ppEnd;
|
JobInfo2.pDatatype = (PWSTR)*ppEnd;
|
||||||
CopyMemory(*ppEnd, pJob->pwszDatatype, cbDatatype);
|
CopyMemory(*ppEnd, pJob->pwszDatatype, cbDatatype);
|
||||||
|
|
||||||
*ppEnd -= sizeof(DEVMODEW);
|
*ppEnd -= cbDevMode;
|
||||||
JobInfo2.pDevMode = (PDEVMODEW)*ppEnd;
|
JobInfo2.pDevMode = (PDEVMODEW)*ppEnd;
|
||||||
CopyMemory(*ppEnd, &pJob->DevMode, sizeof(DEVMODEW));
|
CopyMemory(*ppEnd, pJob->pDevMode, cbDevMode);
|
||||||
|
|
||||||
*ppEnd -= cbDocumentName;
|
*ppEnd -= cbDocumentName;
|
||||||
JobInfo2.pDocument = (PWSTR)*ppEnd;
|
JobInfo2.pDocument = (PWSTR)*ppEnd;
|
||||||
|
@ -1136,6 +1137,7 @@ ReadJobShadowFile(PCWSTR pwszFilePath)
|
||||||
pJob->dwUntilTime = pShadowFile->dwUntilTime;
|
pJob->dwUntilTime = pShadowFile->dwUntilTime;
|
||||||
pJob->pPrinter = pPrinter;
|
pJob->pPrinter = pPrinter;
|
||||||
pJob->pPrintProcessor = pPrintProcessor;
|
pJob->pPrintProcessor = pPrintProcessor;
|
||||||
|
pJob->pDevMode = DuplicateDevMode((PDEVMODEW)((ULONG_PTR)pShadowFile + pShadowFile->offDevMode));
|
||||||
pJob->pwszDatatype = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDatatype));
|
pJob->pwszDatatype = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDatatype));
|
||||||
pJob->pwszDocumentName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDocumentName));
|
pJob->pwszDocumentName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offDocumentName));
|
||||||
pJob->pwszMachineName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offMachineName));
|
pJob->pwszMachineName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offMachineName));
|
||||||
|
@ -1145,9 +1147,7 @@ ReadJobShadowFile(PCWSTR pwszFilePath)
|
||||||
pJob->pwszPrintProcessorParameters = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offPrintProcessorParameters));
|
pJob->pwszPrintProcessorParameters = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offPrintProcessorParameters));
|
||||||
|
|
||||||
pJob->pwszUserName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offUserName));
|
pJob->pwszUserName = AllocSplStr((PCWSTR)((ULONG_PTR)pShadowFile + pShadowFile->offUserName));
|
||||||
|
|
||||||
CopyMemory(&pJob->stSubmitted, &pShadowFile->stSubmitted, sizeof(SYSTEMTIME));
|
CopyMemory(&pJob->stSubmitted, &pShadowFile->stSubmitted, sizeof(SYSTEMTIME));
|
||||||
CopyMemory(&pJob->DevMode, (PDEVMODEW)((ULONG_PTR)pShadowFile + pShadowFile->offDevMode), sizeof(DEVMODEW));
|
|
||||||
|
|
||||||
pReturnValue = pJob;
|
pReturnValue = pJob;
|
||||||
|
|
||||||
|
@ -1166,6 +1166,7 @@ WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob)
|
||||||
{
|
{
|
||||||
BOOL bReturnValue = FALSE;
|
BOOL bReturnValue = FALSE;
|
||||||
DWORD cbDatatype;
|
DWORD cbDatatype;
|
||||||
|
DWORD cbDevMode;
|
||||||
DWORD cbDocumentName;
|
DWORD cbDocumentName;
|
||||||
DWORD cbFileSize;
|
DWORD cbFileSize;
|
||||||
DWORD cbMachineName;
|
DWORD cbMachineName;
|
||||||
|
@ -1191,6 +1192,7 @@ WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob)
|
||||||
|
|
||||||
// Compute the total size of the shadow file.
|
// Compute the total size of the shadow file.
|
||||||
cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR);
|
cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR);
|
||||||
|
cbDevMode = pJob->pDevMode->dmSize + pJob->pDevMode->dmDriverExtra;
|
||||||
cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR);
|
cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR);
|
||||||
cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR);
|
cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR);
|
||||||
cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR);
|
cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR);
|
||||||
|
@ -1203,7 +1205,7 @@ WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob)
|
||||||
if (pJob->pwszPrintProcessorParameters)
|
if (pJob->pwszPrintProcessorParameters)
|
||||||
cbPrintProcessorParameters = (wcslen(pJob->pwszPrintProcessorParameters) + 1) * sizeof(WCHAR);
|
cbPrintProcessorParameters = (wcslen(pJob->pwszPrintProcessorParameters) + 1) * sizeof(WCHAR);
|
||||||
|
|
||||||
cbFileSize = sizeof(SHD_HEADER) + cbDatatype + cbDocumentName + sizeof(DEVMODEW) + cbMachineName + cbNotifyName + cbPrinterDriver + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbUserName;
|
cbFileSize = sizeof(SHD_HEADER) + cbDatatype + cbDocumentName + cbDevMode + cbMachineName + cbNotifyName + cbPrinterDriver + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbUserName;
|
||||||
|
|
||||||
// Allocate memory for it.
|
// Allocate memory for it.
|
||||||
pShadowFile = DllAllocSplMem(cbFileSize);
|
pShadowFile = DllAllocSplMem(cbFileSize);
|
||||||
|
@ -1243,9 +1245,9 @@ WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob)
|
||||||
pShadowFile->offDocumentName = dwCurrentOffset;
|
pShadowFile->offDocumentName = dwCurrentOffset;
|
||||||
dwCurrentOffset += cbDocumentName;
|
dwCurrentOffset += cbDocumentName;
|
||||||
|
|
||||||
CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, &pJob->DevMode, sizeof(DEVMODEW));
|
CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pDevMode, cbDevMode);
|
||||||
pShadowFile->offDevMode = dwCurrentOffset;
|
pShadowFile->offDevMode = dwCurrentOffset;
|
||||||
dwCurrentOffset += sizeof(DEVMODEW);
|
dwCurrentOffset += cbDevMode;
|
||||||
|
|
||||||
// offDriverName is only written, but automatically determined through offPrinterName when reading.
|
// offDriverName is only written, but automatically determined through offPrinterName when reading.
|
||||||
CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pPrinter->pwszPrinterDriver, cbPrinterDriver);
|
CopyMemory((PBYTE)pShadowFile + dwCurrentOffset, pJob->pPrinter->pwszPrinterDriver, cbPrinterDriver);
|
||||||
|
|
|
@ -81,7 +81,7 @@ typedef struct _LOCAL_PRINTER
|
||||||
PWSTR pwszPrinterDriver;
|
PWSTR pwszPrinterDriver;
|
||||||
PWSTR pwszDescription;
|
PWSTR pwszDescription;
|
||||||
PWSTR pwszDefaultDatatype;
|
PWSTR pwszDefaultDatatype;
|
||||||
DEVMODEW DefaultDevMode;
|
PDEVMODEW pDefaultDevMode;
|
||||||
PLOCAL_PRINT_PROCESSOR pPrintProcessor;
|
PLOCAL_PRINT_PROCESSOR pPrintProcessor;
|
||||||
SKIPLIST JobList;
|
SKIPLIST JobList;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ typedef struct _LOCAL_JOB
|
||||||
DWORD dwUntilTime; // Latest 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
|
DWORD dwStatus; // JOB_STATUS_* flags of the Job
|
||||||
PWSTR pwszMachineName; // Name of the machine that submitted the Job (prepended with two backslashes)
|
PWSTR pwszMachineName; // Name of the machine that submitted the Job (prepended with two backslashes)
|
||||||
DEVMODEW DevMode; // Associated Device Mode to this Job
|
PDEVMODEW pDevMode; // Associated Device Mode to this Job
|
||||||
}
|
}
|
||||||
LOCAL_JOB, *PLOCAL_JOB;
|
LOCAL_JOB, *PLOCAL_JOB;
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ typedef struct _LOCAL_PRINTER_HANDLE
|
||||||
PLOCAL_PRINTER pPrinter;
|
PLOCAL_PRINTER pPrinter;
|
||||||
PLOCAL_JOB pStartedJob;
|
PLOCAL_JOB pStartedJob;
|
||||||
PWSTR pwszDatatype;
|
PWSTR pwszDatatype;
|
||||||
DEVMODEW DevMode;
|
PDEVMODEW pDevMode;
|
||||||
}
|
}
|
||||||
LOCAL_PRINTER_HANDLE, *PLOCAL_PRINTER_HANDLE;
|
LOCAL_PRINTER_HANDLE, *PLOCAL_PRINTER_HANDLE;
|
||||||
|
|
||||||
|
@ -249,5 +249,6 @@ BOOL WINAPI LocalGetPrintProcessorDirectory(LPWSTR pName, LPWSTR pEnvironment, D
|
||||||
|
|
||||||
// tools.c
|
// tools.c
|
||||||
PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName);
|
PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName);
|
||||||
|
PDEVMODEW DuplicateDevMode(PDEVMODEW pInput);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,6 +81,9 @@ InitializePrinterList()
|
||||||
|
|
||||||
if (pPrinter)
|
if (pPrinter)
|
||||||
{
|
{
|
||||||
|
if (pPrinter->pDefaultDevMode)
|
||||||
|
DllFreeSplMem(pPrinter->pDefaultDevMode);
|
||||||
|
|
||||||
if (pPrinter->pwszDefaultDatatype)
|
if (pPrinter->pwszDefaultDatatype)
|
||||||
DllFreeSplStr(pPrinter->pwszDefaultDatatype);
|
DllFreeSplStr(pPrinter->pwszDefaultDatatype);
|
||||||
|
|
||||||
|
@ -173,12 +176,28 @@ InitializePrinterList()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the default DevMode.
|
// Determine the size of the DevMode.
|
||||||
cbData = sizeof(DEVMODEW);
|
dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Default DevMode", NULL, NULL, NULL, &cbData);
|
||||||
dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Default DevMode", NULL, NULL, (PBYTE)&pPrinter->DefaultDevMode, &cbData);
|
if (dwErrorCode != ERROR_SUCCESS)
|
||||||
if (dwErrorCode != ERROR_SUCCESS || cbData != sizeof(DEVMODEW))
|
|
||||||
{
|
{
|
||||||
ERR("Couldn't query a valid DevMode for Printer \"%S\", status is %lu, cbData is %lu!\n", wszPrinterName, dwErrorCode, cbData);
|
ERR("Couldn't query the size of the DevMode for Printer \"%S\", status is %lu, cbData is %lu!\n", wszPrinterName, dwErrorCode, cbData);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate enough memory for the DevMode.
|
||||||
|
pPrinter->pDefaultDevMode = DllAllocSplMem(cbData);
|
||||||
|
if (!pPrinter->pDefaultDevMode)
|
||||||
|
{
|
||||||
|
dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
ERR("DllAllocSplMem failed with error %lu!\n", GetLastError());
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the default DevMode.
|
||||||
|
dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Default DevMode", NULL, NULL, (PBYTE)pPrinter->pDefaultDevMode, &cbData);
|
||||||
|
if (dwErrorCode != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
ERR("Couldn't query a DevMode for Printer \"%S\", status is %lu, cbData is %lu!\n", wszPrinterName, dwErrorCode, cbData);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +239,9 @@ Cleanup:
|
||||||
|
|
||||||
if (pPrinter)
|
if (pPrinter)
|
||||||
{
|
{
|
||||||
|
if (pPrinter->pDefaultDevMode)
|
||||||
|
DllFreeSplMem(pPrinter->pDefaultDevMode);
|
||||||
|
|
||||||
if (pPrinter->pwszDefaultDatatype)
|
if (pPrinter->pwszDefaultDatatype)
|
||||||
DllFreeSplStr(pPrinter->pwszDefaultDatatype);
|
DllFreeSplStr(pPrinter->pwszDefaultDatatype);
|
||||||
|
|
||||||
|
@ -567,9 +589,9 @@ LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDef
|
||||||
|
|
||||||
// Check if a DevMode was given, otherwise use the default.
|
// Check if a DevMode was given, otherwise use the default.
|
||||||
if (pDefault && pDefault->pDevMode)
|
if (pDefault && pDefault->pDevMode)
|
||||||
CopyMemory(&pPrinterHandle->DevMode, pDefault->pDevMode, sizeof(DEVMODEW));
|
pPrinterHandle->pDevMode = DuplicateDevMode(pDefault->pDevMode);
|
||||||
else
|
else
|
||||||
CopyMemory(&pPrinterHandle->DevMode, &pPrinter->DefaultDevMode, sizeof(DEVMODEW));
|
pPrinterHandle->pDevMode = DuplicateDevMode(pPrinter->pDefaultDevMode);
|
||||||
|
|
||||||
// Did we have a comma? Then the user may want a handle to an existing job instead of creating a new job.
|
// Did we have a comma? Then the user may want a handle to an existing job instead of creating a new job.
|
||||||
if (p)
|
if (p)
|
||||||
|
@ -753,7 +775,7 @@ LocalStartDocPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy over printer defaults.
|
// Copy over printer defaults.
|
||||||
CopyMemory(&pJob->DevMode, &pPrinterHandle->DevMode, sizeof(DEVMODEW));
|
pJob->pDevMode = DuplicateDevMode(pPrinterHandle->pDevMode);
|
||||||
|
|
||||||
// Copy over supplied information.
|
// Copy over supplied information.
|
||||||
if (pDocumentInfo1->pDocName)
|
if (pDocumentInfo1->pDocName)
|
||||||
|
|
|
@ -56,3 +56,22 @@ AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName)
|
||||||
|
|
||||||
return pwszValue;
|
return pwszValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PDEVMODEW
|
||||||
|
DuplicateDevMode(PDEVMODEW pInput)
|
||||||
|
{
|
||||||
|
PDEVMODEW pOutput;
|
||||||
|
|
||||||
|
// Allocate a buffer for this DevMode.
|
||||||
|
pOutput = DllAllocSplMem(pInput->dmSize + pInput->dmDriverExtra);
|
||||||
|
if (!pOutput)
|
||||||
|
{
|
||||||
|
ERR("DllAllocSplMem failed with error %lu!\n", GetLastError());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy it.
|
||||||
|
CopyMemory(pOutput, pInput, pInput->dmSize + pInput->dmDriverExtra);
|
||||||
|
|
||||||
|
return pOutput;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue