2015-07-16 13:59:20 +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-07-16 13:59:20 +00:00
|
|
|
* PURPOSE: Functions related to Print Monitors
|
2018-01-17 11:52:12 +00:00
|
|
|
* COPYRIGHT: Copyright 2015-2018 Colin Finck (colin@reactos.org)
|
2015-07-16 13:59:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
2018-01-17 11:52:12 +00:00
|
|
|
#include <marshalling/monitors.h>
|
2015-07-17 10:57:10 +00:00
|
|
|
|
|
|
|
DWORD
|
|
|
|
_RpcAddMonitor(WINSPOOL_HANDLE pName, WINSPOOL_MONITOR_CONTAINER* pMonitorContainer)
|
|
|
|
{
|
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 (!AddMonitorW(pName, pMonitorContainer->Level, (PBYTE)pMonitorContainer->MonitorInfo.pMonitorInfo2))
|
|
|
|
dwErrorCode = GetLastError();
|
|
|
|
|
|
|
|
RpcRevertToSelf();
|
|
|
|
return dwErrorCode;
|
2015-07-17 10:57:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD
|
|
|
|
_RpcDeleteMonitor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pMonitorName)
|
|
|
|
{
|
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 (!DeleteMonitorW( pName, pEnvironment, pMonitorName ))
|
|
|
|
dwErrorCode = GetLastError();
|
|
|
|
|
|
|
|
RpcRevertToSelf();
|
|
|
|
return dwErrorCode;
|
2015-07-17 10:57:10 +00:00
|
|
|
}
|
|
|
|
|
2015-07-16 13:59:20 +00:00
|
|
|
DWORD
|
|
|
|
_RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pMonitor, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
|
|
|
|
{
|
|
|
|
DWORD dwErrorCode;
|
2017-07-05 15:29:13 +00:00
|
|
|
PBYTE pMonitorAligned;
|
2015-07-16 13:59:20 +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
|
|
|
pMonitorAligned = AlignRpcPtr(pMonitor, &cbBuf);
|
2015-07-16 13:59:20 +00:00
|
|
|
|
2017-07-05 15:29:13 +00:00
|
|
|
if(EnumMonitorsW(pName, Level, pMonitorAligned, 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
|
|
|
ASSERT(Level >= 1 && Level <= 2);
|
|
|
|
MarshallDownStructuresArray(pMonitorAligned, *pcReturned, pMonitorInfoMarshalling[Level]->pInfo, pMonitorInfoMarshalling[Level]->cbStructureSize, TRUE);
|
2017-07-05 15:29:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwErrorCode = GetLastError();
|
2015-07-17 10:57:10 +00:00
|
|
|
}
|
|
|
|
|
2015-07-16 13:59:20 +00:00
|
|
|
RpcRevertToSelf();
|
2017-07-05 15:29:13 +00:00
|
|
|
UndoAlignRpcPtr(pMonitor, pMonitorAligned, cbBuf, pcbNeeded);
|
|
|
|
|
2015-07-16 13:59:20 +00:00
|
|
|
return dwErrorCode;
|
|
|
|
}
|