2015-06-22 14:31:47 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Print Spooler Service
|
2017-09-29 17:18:19 +00:00
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
2015-06-22 14:31:47 +00:00
|
|
|
* PURPOSE: Functions related to Print Processors
|
2018-01-17 11:52:12 +00:00
|
|
|
* COPYRIGHT: Copyright 2015-2018 Colin Finck (colin@reactos.org)
|
2015-06-22 14:31:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
2018-01-17 11:52:12 +00:00
|
|
|
#include <marshalling/printprocessors.h>
|
2015-07-17 10:57:10 +00:00
|
|
|
|
|
|
|
DWORD
|
|
|
|
_RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPathName, WCHAR* pPrintProcessorName)
|
|
|
|
{
|
2020-08-26 22:12:20 +00:00
|
|
|
DWORD dwErrorCode;
|
|
|
|
|
|
|
|
dwErrorCode = RpcImpersonateClient(NULL);
|
|
|
|
if (dwErrorCode != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
|
|
|
|
return dwErrorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!AddPrintProcessorW(pName, pEnvironment, pPathName, pPrintProcessorName))
|
|
|
|
dwErrorCode = GetLastError();
|
|
|
|
|
|
|
|
RpcRevertToSelf();
|
|
|
|
return dwErrorCode;
|
2015-07-17 10:57:10 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 14:31:47 +00:00
|
|
|
DWORD
|
2015-07-17 10:57:10 +00:00
|
|
|
_RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProcessorName)
|
2015-06-22 14:31:47 +00:00
|
|
|
{
|
2020-08-26 22:12:20 +00:00
|
|
|
DWORD dwErrorCode;
|
|
|
|
|
|
|
|
dwErrorCode = RpcImpersonateClient(NULL);
|
|
|
|
if (dwErrorCode != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
|
|
|
|
return dwErrorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DeletePrintProcessorW(pName, pEnvironment, pPrintProcessorName))
|
|
|
|
dwErrorCode = GetLastError();
|
|
|
|
|
|
|
|
RpcRevertToSelf();
|
|
|
|
return dwErrorCode;
|
2015-06-22 14:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD
|
2015-07-17 10:57:10 +00:00
|
|
|
_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR* pPrintProcessorName, DWORD Level, BYTE* pDatatypes, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
|
2015-06-22 14:31:47 +00:00
|
|
|
{
|
|
|
|
DWORD dwErrorCode;
|
2017-06-27 07:25:04 +00:00
|
|
|
PBYTE pDatatypesAligned;
|
2015-06-22 14:31:47 +00:00
|
|
|
|
|
|
|
dwErrorCode = RpcImpersonateClient(NULL);
|
|
|
|
if (dwErrorCode != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
|
|
|
|
return dwErrorCode;
|
|
|
|
}
|
|
|
|
|
2017-06-27 07:25:04 +00:00
|
|
|
pDatatypesAligned = AlignRpcPtr(pDatatypes, &cbBuf);
|
2015-06-22 14:31:47 +00:00
|
|
|
|
2017-06-27 07:25:04 +00:00
|
|
|
if (EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypesAligned, cbBuf, pcbNeeded, pcReturned))
|
2015-07-17 10:57:10 +00:00
|
|
|
{
|
|
|
|
// Replace absolute pointer addresses in the output by relative offsets.
|
2018-01-17 11:52:12 +00:00
|
|
|
MarshallDownStructuresArray(pDatatypesAligned, *pcReturned, DatatypesInfo1Marshalling.pInfo, DatatypesInfo1Marshalling.cbStructureSize, TRUE);
|
2017-06-27 07:25:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwErrorCode = GetLastError();
|
2015-07-17 10:57:10 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 13:46:14 +00:00
|
|
|
RpcRevertToSelf();
|
2017-06-27 07:25:04 +00:00
|
|
|
UndoAlignRpcPtr(pDatatypes, pDatatypesAligned, cbBuf, pcbNeeded);
|
|
|
|
|
2015-06-23 13:46:14 +00:00
|
|
|
return dwErrorCode;
|
2015-06-22 14:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD
|
2015-07-17 10:57:10 +00:00
|
|
|
_RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorInfo, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
|
2015-06-22 14:31:47 +00:00
|
|
|
{
|
|
|
|
DWORD dwErrorCode;
|
2017-07-05 15:29:13 +00:00
|
|
|
PBYTE pPrintProcessorInfoAligned;
|
2015-06-22 14:31:47 +00:00
|
|
|
|
|
|
|
dwErrorCode = RpcImpersonateClient(NULL);
|
|
|
|
if (dwErrorCode != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
|
|
|
|
return dwErrorCode;
|
|
|
|
}
|
|
|
|
|
2017-07-05 15:29:13 +00:00
|
|
|
pPrintProcessorInfoAligned = AlignRpcPtr(pPrintProcessorInfo, &cbBuf);
|
2015-06-22 14:31:47 +00:00
|
|
|
|
2017-07-05 15:29:13 +00:00
|
|
|
if (EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfoAligned, cbBuf, pcbNeeded, pcReturned))
|
2015-07-17 10:57:10 +00:00
|
|
|
{
|
|
|
|
// Replace absolute pointer addresses in the output by relative offsets.
|
2018-01-17 11:52:12 +00:00
|
|
|
MarshallDownStructuresArray(pPrintProcessorInfoAligned, *pcReturned, PrintProcessorInfo1Marshalling.pInfo, PrintProcessorInfo1Marshalling.cbStructureSize, TRUE);
|
2015-07-17 10:57:10 +00:00
|
|
|
}
|
2017-07-05 15:29:13 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dwErrorCode = GetLastError();
|
|
|
|
}
|
2015-07-17 10:57:10 +00:00
|
|
|
|
2015-06-23 13:46:14 +00:00
|
|
|
RpcRevertToSelf();
|
2017-07-05 15:29:13 +00:00
|
|
|
UndoAlignRpcPtr(pPrintProcessorInfo, pPrintProcessorInfoAligned, cbBuf, pcbNeeded);
|
|
|
|
|
2015-06-23 13:46:14 +00:00
|
|
|
return dwErrorCode;
|
2015-06-22 14:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD
|
2015-07-17 10:57:10 +00:00
|
|
|
_RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorDirectory, DWORD cbBuf, DWORD* pcbNeeded)
|
2015-06-22 14:31:47 +00:00
|
|
|
{
|
|
|
|
DWORD dwErrorCode;
|
|
|
|
|
|
|
|
dwErrorCode = RpcImpersonateClient(NULL);
|
|
|
|
if (dwErrorCode != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
|
|
|
|
return dwErrorCode;
|
|
|
|
}
|
|
|
|
|
2017-07-05 15:29:13 +00:00
|
|
|
if (!GetPrintProcessorDirectoryW(pName, pEnvironment, Level, pPrintProcessorDirectory, cbBuf, pcbNeeded))
|
|
|
|
dwErrorCode = GetLastError();
|
2015-06-22 14:31:47 +00:00
|
|
|
|
2015-06-23 13:46:14 +00:00
|
|
|
RpcRevertToSelf();
|
|
|
|
return dwErrorCode;
|
2015-06-22 14:31:47 +00:00
|
|
|
}
|