2 * PROJECT: ReactOS Print Spooler Service
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Functions related to Print Monitors
5 * COPYRIGHT: Copyright 2015-2018 Colin Finck (colin@reactos.org)
9 #include <marshalling/monitors.h>
12 _RpcAddMonitor(WINSPOOL_HANDLE pName
, WINSPOOL_MONITOR_CONTAINER
* pMonitorContainer
)
16 dwErrorCode
= RpcImpersonateClient(NULL
);
17 if (dwErrorCode
!= ERROR_SUCCESS
)
19 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
23 if (!AddMonitorW(pName
, pMonitorContainer
->Level
, (PBYTE
)pMonitorContainer
->MonitorInfo
.pMonitorInfo2
))
24 dwErrorCode
= GetLastError();
31 _RpcDeleteMonitor(WINSPOOL_HANDLE pName
, WCHAR
* pEnvironment
, WCHAR
* pMonitorName
)
35 dwErrorCode
= RpcImpersonateClient(NULL
);
36 if (dwErrorCode
!= ERROR_SUCCESS
)
38 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
42 if (!DeleteMonitorW( pName
, pEnvironment
, pMonitorName
))
43 dwErrorCode
= GetLastError();
50 _RpcEnumMonitors(WINSPOOL_HANDLE pName
, DWORD Level
, BYTE
* pMonitor
, DWORD cbBuf
, DWORD
* pcbNeeded
, DWORD
* pcReturned
)
53 PBYTE pMonitorAligned
;
55 dwErrorCode
= RpcImpersonateClient(NULL
);
56 if (dwErrorCode
!= ERROR_SUCCESS
)
58 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
62 pMonitorAligned
= AlignRpcPtr(pMonitor
, &cbBuf
);
64 if(EnumMonitorsW(pName
, Level
, pMonitorAligned
, cbBuf
, pcbNeeded
, pcReturned
))
66 // Replace absolute pointer addresses in the output by relative offsets.
67 ASSERT(Level
>= 1 && Level
<= 2);
68 MarshallDownStructuresArray(pMonitorAligned
, *pcReturned
, pMonitorInfoMarshalling
[Level
]->pInfo
, pMonitorInfoMarshalling
[Level
]->cbStructureSize
, TRUE
);
72 dwErrorCode
= GetLastError();
76 UndoAlignRpcPtr(pMonitor
, pMonitorAligned
, cbBuf
, pcbNeeded
);