ReactOS 0.4.15-dev-7842-g558ab78
monitors.c File Reference
#include "precomp.h"
#include <marshalling/monitors.h>
Include dependency graph for monitors.c:

Go to the source code of this file.

Functions

DWORD _RpcAddMonitor (WINSPOOL_HANDLE pName, WINSPOOL_MONITOR_CONTAINER *pMonitorContainer)
 
DWORD _RpcDeleteMonitor (WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pMonitorName)
 
DWORD _RpcEnumMonitors (WINSPOOL_HANDLE pName, DWORD Level, BYTE *pMonitor, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
 

Function Documentation

◆ _RpcAddMonitor()

DWORD _RpcAddMonitor ( WINSPOOL_HANDLE  pName,
WINSPOOL_MONITOR_CONTAINER pMonitorContainer 
)

Definition at line 12 of file monitors.c.

13{
14 DWORD dwErrorCode;
15
16 dwErrorCode = RpcImpersonateClient(NULL);
17 if (dwErrorCode != ERROR_SUCCESS)
18 {
19 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
20 return dwErrorCode;
21 }
22
23 if (!AddMonitorW(pName, pMonitorContainer->Level, (PBYTE)pMonitorContainer->MonitorInfo.pMonitorInfo2))
24 dwErrorCode = GetLastError();
25
27 return dwErrorCode;
28}
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPSTR pName
Definition: security.c:75
BYTE * PBYTE
Definition: pedump.c:66
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
WINSPOOL_MONITOR_INFO_2 * pMonitorInfo2
Definition: winspool.idl:656
union _WINSPOOL_MONITOR_CONTAINER::@3439 MonitorInfo
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
WINBOOL WINAPI AddMonitorW(LPWSTR pName, DWORD Level, LPBYTE pMonitorInfo)

Referenced by AddMonitorW(), and pointer_default().

◆ _RpcDeleteMonitor()

DWORD _RpcDeleteMonitor ( WINSPOOL_HANDLE  pName,
WCHAR pEnvironment,
WCHAR pMonitorName 
)

Definition at line 31 of file monitors.c.

32{
33 DWORD dwErrorCode;
34
35 dwErrorCode = RpcImpersonateClient(NULL);
36 if (dwErrorCode != ERROR_SUCCESS)
37 {
38 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
39 return dwErrorCode;
40 }
41
42 if (!DeleteMonitorW( pName, pEnvironment, pMonitorName ))
43 dwErrorCode = GetLastError();
44
46 return dwErrorCode;
47}
WINBOOL WINAPI DeleteMonitorW(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMonitorName)

Referenced by DeleteMonitorW(), and pointer_default().

◆ _RpcEnumMonitors()

DWORD _RpcEnumMonitors ( WINSPOOL_HANDLE  pName,
DWORD  Level,
BYTE pMonitor,
DWORD  cbBuf,
DWORD pcbNeeded,
DWORD pcReturned 
)

Definition at line 50 of file monitors.c.

51{
52 DWORD dwErrorCode;
53 PBYTE pMonitorAligned;
54
55 dwErrorCode = RpcImpersonateClient(NULL);
56 if (dwErrorCode != ERROR_SUCCESS)
57 {
58 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
59 return dwErrorCode;
60 }
61
62 pMonitorAligned = AlignRpcPtr(pMonitor, &cbBuf);
63
64 if(EnumMonitorsW(pName, Level, pMonitorAligned, cbBuf, pcbNeeded, pcReturned))
65 {
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);
69 }
70 else
71 {
72 dwErrorCode = GetLastError();
73 }
74
76 UndoAlignRpcPtr(pMonitor, pMonitorAligned, cbBuf, pcbNeeded);
77
78 return dwErrorCode;
79}
#define TRUE
Definition: types.h:120
BOOL WINAPI MarshallDownStructuresArray(PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:91
#define ASSERT(a)
Definition: mode.c:44
static const MARSHALLING * pMonitorInfoMarshalling[]
Definition: monitors.h:26
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:239
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
WINBOOL WINAPI EnumMonitorsW(LPWSTR pName, DWORD Level, LPBYTE pMonitor, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

Referenced by EnumMonitorsW(), and pointer_default().