ReactOS 0.4.15-dev-7934-g1dc8d80
ports.c File Reference
#include "precomp.h"
#include <marshalling/ports.h>
Include dependency graph for ports.c:

Go to the source code of this file.

Functions

DWORD _RpcAddPort (WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pMonitorName)
 
DWORD _RpcAddPortEx (WINSPOOL_HANDLE pName, WINSPOOL_PORT_CONTAINER *pPortContainer, WINSPOOL_PORT_VAR_CONTAINER *pPortVarContainer, WCHAR *pMonitorName)
 
DWORD _RpcConfigurePort (WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName)
 
DWORD _RpcDeletePort (WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName)
 
DWORD _RpcEnumPorts (WINSPOOL_HANDLE pName, DWORD Level, BYTE *pPort, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
 
DWORD _RpcSetPort (WINSPOOL_HANDLE pName, WCHAR *pPortName, WINSPOOL_PORT_CONTAINER *pPortContainer)
 

Function Documentation

◆ _RpcAddPort()

DWORD _RpcAddPort ( WINSPOOL_HANDLE  pName,
ULONG_PTR  hWnd,
WCHAR pMonitorName 
)

Definition at line 12 of file ports.c.

13{
14 DWORD dwErrorCode;
15
16 FIXME("AddPort(%S, %p, %s)\n", pName, hWnd, debugstr_w(pMonitorName));
17
18 dwErrorCode = RpcImpersonateClient(NULL);
19 if (dwErrorCode != ERROR_SUCCESS)
20 {
21 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
22 return dwErrorCode;
23 }
24
25 if (!AddPortW( pName, (HWND)hWnd, pMonitorName ))
26 dwErrorCode = GetLastError();
27
29 return dwErrorCode;
30}
HWND hWnd
Definition: settings.c:17
#define FIXME(fmt,...)
Definition: debug.h:111
#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
#define debugstr_w
Definition: kernel32.h:32
static LPSTR pName
Definition: security.c:75
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
WINBOOL WINAPI AddPortW(LPWSTR pName, HWND hWnd, LPWSTR pMonitorName)

Referenced by AddPortW(), and pointer_default().

◆ _RpcAddPortEx()

DWORD _RpcAddPortEx ( WINSPOOL_HANDLE  pName,
WINSPOOL_PORT_CONTAINER pPortContainer,
WINSPOOL_PORT_VAR_CONTAINER pPortVarContainer,
WCHAR pMonitorName 
)

Definition at line 33 of file ports.c.

34{
35 DWORD dwErrorCode, Level = pPortContainer->Level;
36 WINSPOOL_PORT_INFO_FF PortInfoFF;
38
39 FIXME("AddPortEx(%S, %lu, %s)\n", pName, Level, debugstr_w(pMonitorName));
40
41 switch (Level)
42 {
43 case 1:
44 lpBuffer = (PBYTE)pPortContainer->PortInfo.pPortInfo1;
45 break;
46
47 case 0xFFFFFFFF:
48 PortInfoFF.pPortName = pPortContainer->PortInfo.pPortInfoFF->pPortName;
49 PortInfoFF.cbMonitorData = pPortVarContainer->cbMonitorData;
50 PortInfoFF.pMonitorData = pPortVarContainer->pMonitorData;
51 lpBuffer = (PBYTE)&PortInfoFF;
52 break;
53
54 default:
55 ERR("Level = %d, unsupported!\n", Level);
57 }
58
59 dwErrorCode = RpcImpersonateClient(NULL);
60 if (dwErrorCode != ERROR_SUCCESS)
61 {
62 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
63 return dwErrorCode;
64 }
65
66 if (!AddPortExW(pName, Level, lpBuffer, pMonitorName ))
67 dwErrorCode = GetLastError();
68
70 return dwErrorCode;
71}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
BYTE * PBYTE
Definition: pedump.c:66
WINSPOOL_PORT_INFO_FF * pPortInfoFF
Definition: winspool.idl:676
WINSPOOL_PORT_INFO_1 * pPortInfo1
Definition: winspool.idl:670
union _WINSPOOL_PORT_CONTAINER::@3445 PortInfo
BOOL WINAPI AddPortExW(PWSTR pName, DWORD Level, PBYTE lpBuffer, PWSTR lpMonitorName)
Definition: ports.c:11
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

Referenced by AddPortExW(), and pointer_default().

◆ _RpcConfigurePort()

DWORD _RpcConfigurePort ( WINSPOOL_HANDLE  pName,
ULONG_PTR  hWnd,
WCHAR pPortName 
)

Definition at line 74 of file ports.c.

75{
76 DWORD dwErrorCode;
77
78 dwErrorCode = RpcImpersonateClient(NULL);
79 if (dwErrorCode != ERROR_SUCCESS)
80 {
81 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
82 return dwErrorCode;
83 }
84
85 if (!ConfigurePortW( pName, (HWND)hWnd, pPortName ))
86 dwErrorCode = GetLastError();
87
89 return dwErrorCode;
90}
WINBOOL WINAPI ConfigurePortW(LPWSTR pName, HWND hWnd, LPWSTR pPortName)

Referenced by ConfigurePortW(), and pointer_default().

◆ _RpcDeletePort()

DWORD _RpcDeletePort ( WINSPOOL_HANDLE  pName,
ULONG_PTR  hWnd,
WCHAR pPortName 
)

Definition at line 93 of file ports.c.

94{
95 DWORD dwErrorCode;
96
97 dwErrorCode = RpcImpersonateClient(NULL);
98 if (dwErrorCode != ERROR_SUCCESS)
99 {
100 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
101 return dwErrorCode;
102 }
103
104 if (!DeletePortW( pName, (HWND)hWnd, pPortName ))
105 dwErrorCode = GetLastError();
106
108 return dwErrorCode;
109}
WINBOOL WINAPI DeletePortW(LPWSTR pName, HWND hWnd, LPWSTR pPortName)

Referenced by DeletePortW(), and pointer_default().

◆ _RpcEnumPorts()

DWORD _RpcEnumPorts ( WINSPOOL_HANDLE  pName,
DWORD  Level,
BYTE pPort,
DWORD  cbBuf,
DWORD pcbNeeded,
DWORD pcReturned 
)

Definition at line 112 of file ports.c.

113{
114 DWORD dwErrorCode;
115 PBYTE pPortAligned;
116
117 dwErrorCode = RpcImpersonateClient(NULL);
118 if (dwErrorCode != ERROR_SUCCESS)
119 {
120 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
121 return dwErrorCode;
122 }
123
124 pPortAligned = AlignRpcPtr(pPort, &cbBuf);
125
126 if (EnumPortsW(pName, Level, pPortAligned, cbBuf, pcbNeeded, pcReturned))
127 {
128 // Replace absolute pointer addresses in the output by relative offsets.
129 ASSERT(Level >= 1 && Level <= 2);
130 MarshallDownStructuresArray(pPortAligned, *pcReturned, pPortInfoMarshalling[Level]->pInfo, pPortInfoMarshalling[Level]->cbStructureSize, TRUE);
131 }
132 else
133 {
134 dwErrorCode = GetLastError();
135 }
136
138 UndoAlignRpcPtr(pPort, pPortAligned, cbBuf, pcbNeeded);
139
140 return dwErrorCode;
141}
#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
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
static const MARSHALLING * pPortInfoMarshalling[]
Definition: ports.h:28
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
WINBOOL WINAPI EnumPortsW(LPWSTR pName, DWORD Level, LPBYTE pPorts, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)

Referenced by EnumPortsW(), and pointer_default().

◆ _RpcSetPort()

DWORD _RpcSetPort ( WINSPOOL_HANDLE  pName,
WCHAR pPortName,
WINSPOOL_PORT_CONTAINER pPortContainer 
)

Definition at line 144 of file ports.c.

145{
146 DWORD dwErrorCode;
147
148 dwErrorCode = RpcImpersonateClient(NULL);
149 if (dwErrorCode != ERROR_SUCCESS)
150 {
151 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
152 return dwErrorCode;
153 }
154
155 if (!SetPortW(pName, pPortName, pPortContainer->Level, (PBYTE)pPortContainer->PortInfo.pPortInfo3))
156 dwErrorCode = GetLastError();
157
159 return dwErrorCode;
160}
WINSPOOL_PORT_INFO_3 * pPortInfo3
Definition: winspool.idl:674
WINBOOL WINAPI SetPortW(LPWSTR pName, LPWSTR pPortName, DWORD dwLevel, LPBYTE pPortInfo)

Referenced by pointer_default(), and SetPortW().