[PRINTING] The first argument to PackStrings can be const.

This commit is contained in:
Mark Jansen 2019-01-06 12:18:40 +01:00
parent d272866550
commit 2e4457f223
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
11 changed files with 43 additions and 43 deletions

View file

@ -32,7 +32,7 @@ START_TEST(MarshallDownStructuresArray)
PPORT_INFO_2W pPortInfo2Copy;
PPORT_INFO_2W pPortInfo2Test;
PBYTE pPortInfoEnd;
PWSTR pwszStrings[] = { L"PortName", L"MonitorName", L"Description" };
PCWSTR pwszStrings[] = { L"PortName", L"MonitorName", L"Description" };
DWORD cbPortInfo2Size = cElements * (sizeof(PORT_INFO_2W) + (wcslen(pwszStrings[0]) + 1 + wcslen(pwszStrings[1]) + 1 + wcslen(pwszStrings[2]) + 1) * sizeof(WCHAR));
DWORD fPortType = 1337;
DWORD Reserved = 42;

View file

@ -21,8 +21,8 @@ EXAMPLE_STRUCT, *PEXAMPLE_STRUCT;
START_TEST(PackStrings)
{
PWSTR Source1[] = { L"Test", L"String" };
PWSTR Source2[] = { L"Test", NULL };
PCWSTR Source1[] = { L"Test", L"String" };
PCWSTR Source2[] = { L"Test", NULL };
BYTE Buffer[50];
PBYTE pEnd;

View file

@ -36,7 +36,7 @@
* The strings are copied in reverse order, so this pointer will point to the last copied string of pSource.
*/
PBYTE WINAPI
PackStrings(PWSTR* pSource, PBYTE pDest, const DWORD* DestOffsets, PBYTE pEnd)
PackStrings(PCWSTR* pSource, PBYTE pDest, const DWORD* DestOffsets, PBYTE pEnd)
{
DWORD cbString;
ULONG_PTR StringAddress;

View file

@ -63,7 +63,7 @@ PVOID WINAPI DllAllocSplMem(DWORD dwBytes);
BOOL WINAPI DllFreeSplMem(PVOID pMem);
BOOL WINAPI DllFreeSplStr(PWSTR pwszString);
BOOL WINAPI InitializeRouter(HANDLE SpoolerStatusHandle);
PBYTE WINAPI PackStrings(PWSTR* pSource, PBYTE pDest, const DWORD* DestOffsets, PBYTE pEnd);
PBYTE WINAPI PackStrings(PCWSTR* pSource, PBYTE pDest, const DWORD* DestOffsets, PBYTE pEnd);
PVOID WINAPI ReallocSplMem(PVOID pOldMem, DWORD cbOld, DWORD cbNew);
BOOL WINAPI ReallocSplStr(PWSTR* ppwszString, PCWSTR pwszInput);
BOOL WINAPI SplInitializeWinSpoolDrv(PVOID* pTable);

View file

@ -374,7 +374,7 @@ static void
_LocalmonGetPortLevel1(PLOCALMON_PORT pPort, PPORT_INFO_1W* ppPortInfo, PBYTE* ppPortInfoEnd, PDWORD pcbNeeded)
{
DWORD cbPortName;
PWSTR pwszStrings[1];
PCWSTR pwszStrings[1];
// Calculate the string lengths.
if (!ppPortInfo)
@ -397,7 +397,7 @@ static void
_LocalmonGetPortLevel2(PLOCALMON_PORT pPort, PPORT_INFO_2W* ppPortInfo, PBYTE* ppPortInfoEnd, PDWORD pcbNeeded)
{
DWORD cbPortName;
PWSTR pwszStrings[3];
PCWSTR pwszStrings[3];
// Calculate the string lengths.
if (!ppPortInfo)

View file

@ -8,7 +8,7 @@
#include "precomp.h"
// Local Constants
static PWSTR _pwszDatatypes[] = {
static PCWSTR _pwszDatatypes[] = {
L"RAW",
0
};
@ -113,7 +113,7 @@ EnumPrintProcessorDatatypesW(PWSTR pName, PWSTR pPrintProcessorName, DWORD Level
DWORD cbDatatype;
DWORD dwDatatypeCount = 0;
DWORD dwOffsets[_countof(_pwszDatatypes)];
PWSTR* pCurrentDatatype;
PCWSTR* pCurrentDatatype;
PDWORD pCurrentOffset = dwOffsets;
TRACE("EnumPrintProcessorDatatypesW(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);

View file

@ -455,7 +455,7 @@ _LocalGetJobLevel1(PLOCAL_JOB pJob, PJOB_INFO_1W* ppJobInfo, PBYTE* ppJobInfoEnd
DWORD cbPrinterName;
DWORD cbStatus = 0;
DWORD cbUserName = 0;
PWSTR pwszStrings[6];
PCWSTR pwszStrings[6];
// Calculate the string lengths.
if (!ppJobInfo)
@ -536,7 +536,7 @@ _LocalGetJobLevel2(PLOCAL_JOB pJob, PJOB_INFO_2W* ppJobInfo, PBYTE* ppJobInfoEnd
DWORD cbUserName = 0;
FILETIME ftNow;
FILETIME ftSubmitted;
PWSTR pwszStrings[10];
PCWSTR pwszStrings[10];
ULARGE_INTEGER uliNow;
ULARGE_INTEGER uliSubmitted;

View file

@ -24,7 +24,7 @@ const DWORD dwSpoolerMinorVersion = 0;
const WCHAR wszDefaultDocumentName[] = L"Local Downlevel Document";
PWSTR wszPrintProviderInfo[3] = {
PCWSTR wszPrintProviderInfo[3] = {
L"Windows NT Local Print Providor", // Name
L"Locally connected Printers", // Comment
L"Windows NT Local Printers" // Description

View file

@ -257,7 +257,7 @@ static void
_LocalGetMonitorLevel1(PLOCAL_PRINT_MONITOR pPrintMonitor, PMONITOR_INFO_1W* ppMonitorInfo, PBYTE* ppMonitorInfoEnd, PDWORD pcbNeeded)
{
DWORD cbMonitorName;
PWSTR pwszStrings[1];
PCWSTR pwszStrings[1];
// Calculate the string lengths.
if (!ppMonitorInfo)
@ -281,7 +281,7 @@ _LocalGetMonitorLevel2(PLOCAL_PRINT_MONITOR pPrintMonitor, PMONITOR_INFO_2W* ppM
{
DWORD cbFileName;
DWORD cbMonitorName;
PWSTR pwszStrings[3];
PCWSTR pwszStrings[3];
// Calculate the string lengths.
if (!ppMonitorInfo)

View file

@ -264,7 +264,7 @@ extern const DWORD dwSpoolerMinorVersion;
extern const WCHAR wszDefaultDocumentName[];
extern HKEY hPrintKey;
extern HKEY hPrintersKey;
extern PWSTR wszPrintProviderInfo[3];
extern PCWSTR wszPrintProviderInfo[3];
extern WCHAR wszJobDirectory[MAX_PATH];
extern DWORD cchJobDirectory;
extern WCHAR wszSpoolDirectory[MAX_PATH];

View file

@ -491,8 +491,8 @@ static void
_LocalGetPrinterLevel0(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_STRESS* ppPrinterInfo, PBYTE* ppPrinterInfoEnd, PDWORD pcbNeeded, DWORD cchComputerName, PCWSTR wszComputerName)
{
size_t cbName;
PWSTR p;
PWSTR pwszStrings[1];
PWSTR p, Allocation;
PCWSTR pwszStrings[1];
SYSTEM_INFO SystemInfo;
// Calculate the string lengths.
@ -521,8 +521,8 @@ _LocalGetPrinterLevel0(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_STRESS* ppPrinterI
(*ppPrinterInfo)->wProcessorLevel = SystemInfo.wProcessorLevel;
// Copy the Printer Name.
pwszStrings[0] = DllAllocSplMem(cbName);
p = pwszStrings[0];
p = Allocation = DllAllocSplMem(cbName);
pwszStrings[0] = Allocation;
StringCbCopyExW(p, cbName, wszComputerName, &p, &cbName, 0);
StringCbCopyExW(p, cbName, pPrinter->pwszPrinterName, &p, &cbName, 0);
@ -531,7 +531,7 @@ _LocalGetPrinterLevel0(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_STRESS* ppPrinterI
(*ppPrinterInfo)++;
// Free the memory for temporary strings.
DllFreeSplMem(pwszStrings[0]);
DllFreeSplMem(Allocation);
}
static void
@ -542,8 +542,8 @@ _LocalGetPrinterLevel1(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_1W* ppPrinterInfo,
size_t cbName;
size_t cbComment;
size_t cbDescription;
PWSTR p;
PWSTR pwszStrings[3];
PWSTR p, Allocation1, Allocation2;
PCWSTR pwszStrings[3];
// Calculate the string lengths.
// Attention: pComment equals the "Description" registry value while pDescription is concatenated out of several strings.
@ -562,8 +562,8 @@ _LocalGetPrinterLevel1(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_1W* ppPrinterInfo,
(*ppPrinterInfo)->Flags = PRINTER_ENUM_ICON8;
// Copy the Printer Name.
pwszStrings[0] = DllAllocSplMem(cbName);
p = pwszStrings[0];
p = Allocation1 = DllAllocSplMem(cbName);
pwszStrings[0] = Allocation1;
StringCbCopyExW(p, cbName, wszComputerName, &p, &cbName, 0);
StringCbCopyExW(p, cbName, pPrinter->pwszPrinterName, &p, &cbName, 0);
@ -571,8 +571,8 @@ _LocalGetPrinterLevel1(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_1W* ppPrinterInfo,
pwszStrings[1] = pPrinter->pwszDescription;
// Copy the description, which for PRINTER_INFO_1W has the form "Name,Printer Driver,Location"
pwszStrings[2] = DllAllocSplMem(cbDescription);
p = pwszStrings[2];
p = Allocation2 = DllAllocSplMem(cbDescription);
pwszStrings[2] = Allocation2;
StringCbCopyExW(p, cbDescription, wszComputerName, &p, &cbDescription, 0);
StringCbCopyExW(p, cbDescription, pPrinter->pwszPrinterName, &p, &cbDescription, 0);
StringCbCopyExW(p, cbDescription, wszComma, &p, &cbDescription, 0);
@ -585,8 +585,8 @@ _LocalGetPrinterLevel1(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_1W* ppPrinterInfo,
(*ppPrinterInfo)++;
// Free the memory for temporary strings.
DllFreeSplMem(pwszStrings[0]);
DllFreeSplMem(pwszStrings[2]);
DllFreeSplMem(Allocation1);
DllFreeSplMem(Allocation2);
}
static void
@ -605,8 +605,8 @@ _LocalGetPrinterLevel2(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_2W* ppPrinterInfo,
size_t cbPrintProcessor;
size_t cbDatatype;
size_t cbParameters;
PWSTR p;
PWSTR pwszStrings[10];
PWSTR p, Allocation;
PCWSTR pwszStrings[10];
// Calculate the string lengths.
cbDevMode = pPrinter->pDefaultDevMode->dmSize + pPrinter->pDefaultDevMode->dmDriverExtra;
@ -641,8 +641,8 @@ _LocalGetPrinterLevel2(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_2W* ppPrinterInfo,
(*ppPrinterInfo)->pDevMode = (PDEVMODEW)(*ppPrinterInfoEnd);
// Set the pPrinterName field.
pwszStrings[0] = DllAllocSplMem(cbPrinterName);
p = pwszStrings[0];
p = Allocation = DllAllocSplMem(cbPrinterName);
pwszStrings[0] = Allocation;
StringCbCopyExW(p, cbPrinterName, wszComputerName, &p, &cbPrinterName, 0);
StringCbCopyExW(p, cbPrinterName, pPrinter->pwszPrinterName, &p, &cbPrinterName, 0);
@ -678,7 +678,7 @@ _LocalGetPrinterLevel2(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_2W* ppPrinterInfo,
(*ppPrinterInfo)++;
// Free the memory for temporary strings.
DllFreeSplMem(pwszStrings[0]);
DllFreeSplMem(Allocation);
}
static void
@ -707,8 +707,8 @@ static void
_LocalGetPrinterLevel4(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_4W* ppPrinterInfo, PBYTE* ppPrinterInfoEnd, PDWORD pcbNeeded, DWORD cchComputerName, PCWSTR wszComputerName)
{
size_t cbPrinterName;
PWSTR p;
PWSTR pwszStrings[1];
PWSTR p, Allocation;
PCWSTR pwszStrings[1];
// Calculate the string lengths.
cbPrinterName = (cchComputerName + wcslen(pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR);
@ -724,8 +724,8 @@ _LocalGetPrinterLevel4(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_4W* ppPrinterInfo,
(*ppPrinterInfo)->Attributes = pPrinter->dwAttributes;
// Set the pPrinterName field.
pwszStrings[0] = DllAllocSplMem(cbPrinterName);
p = pwszStrings[0];
p = Allocation = DllAllocSplMem(cbPrinterName);
pwszStrings[0] = Allocation;
StringCbCopyExW(p, cbPrinterName, wszComputerName, &p, &cbPrinterName, 0);
StringCbCopyExW(p, cbPrinterName, pPrinter->pwszPrinterName, &p, &cbPrinterName, 0);
@ -734,7 +734,7 @@ _LocalGetPrinterLevel4(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_4W* ppPrinterInfo,
(*ppPrinterInfo)++;
// Free the memory for temporary strings.
DllFreeSplMem(pwszStrings[0]);
DllFreeSplMem(Allocation);
}
static void
@ -742,8 +742,8 @@ _LocalGetPrinterLevel5(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_5W* ppPrinterInfo,
{
size_t cbPrinterName;
size_t cbPortName;
PWSTR p;
PWSTR pwszStrings[2];
PWSTR p, Allocation;
PCWSTR pwszStrings[2];
// Calculate the string lengths.
cbPrinterName = (cchComputerName + wcslen(pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR);
@ -762,8 +762,8 @@ _LocalGetPrinterLevel5(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_5W* ppPrinterInfo,
(*ppPrinterInfo)->TransmissionRetryTimeout = dwTransmissionRetryTimeout;
// Set the pPrinterName field.
pwszStrings[0] = DllAllocSplMem(cbPrinterName);
p = pwszStrings[0];
p = Allocation = DllAllocSplMem(cbPrinterName);
pwszStrings[0] = Allocation;
StringCbCopyExW(p, cbPrinterName, wszComputerName, &p, &cbPrinterName, 0);
StringCbCopyExW(p, cbPrinterName, pPrinter->pwszPrinterName, &p, &cbPrinterName, 0);
@ -775,7 +775,7 @@ _LocalGetPrinterLevel5(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_5W* ppPrinterInfo,
(*ppPrinterInfo)++;
// Free the memory for temporary strings.
DllFreeSplMem(pwszStrings[0]);
DllFreeSplMem(Allocation);
}
static void