2 * PROJECT: ReactOS Spooler API
3 * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
4 * PURPOSE: Functions related to Print Monitors
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
11 _MarshallUpMonitorInfo(PBYTE pMonitorInfo
, DWORD Level
)
13 PMONITOR_INFO_2W pMonitorInfo2
= (PMONITOR_INFO_2W
)pMonitorInfo
; // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W
15 // Replace relative offset addresses in the output by absolute pointers.
16 pMonitorInfo2
->pName
= (PWSTR
)((ULONG_PTR
)pMonitorInfo2
->pName
+ (ULONG_PTR
)pMonitorInfo2
);
20 pMonitorInfo2
->pDLLName
= (PWSTR
)((ULONG_PTR
)pMonitorInfo2
->pDLLName
+ (ULONG_PTR
)pMonitorInfo2
);
21 pMonitorInfo2
->pEnvironment
= (PWSTR
)((ULONG_PTR
)pMonitorInfo2
->pEnvironment
+ (ULONG_PTR
)pMonitorInfo2
);
26 EnumMonitorsW(PWSTR pName
, DWORD Level
, PBYTE pMonitors
, DWORD cbBuf
, PDWORD pcbNeeded
, PDWORD pcReturned
)
35 dwErrorCode
= _RpcEnumMonitors(pName
, Level
, pMonitors
, cbBuf
, pcbNeeded
, pcReturned
);
37 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
39 dwErrorCode
= RpcExceptionCode();
40 ERR("_RpcEnumPorts failed with exception code %lu!\n", dwErrorCode
);
44 if (dwErrorCode
== ERROR_SUCCESS
)
46 // Replace relative offset addresses in the output by absolute pointers.
47 for (i
= 0; i
< *pcReturned
; i
++)
49 _MarshallUpMonitorInfo(p
, Level
);
52 p
+= sizeof(MONITOR_INFO_1W
);
54 p
+= sizeof(MONITOR_INFO_2W
);
58 SetLastError(dwErrorCode
);
59 return (dwErrorCode
== ERROR_SUCCESS
);