2 ===================================================================
3 --- epm_towers.h (working copy)
4 +++ epm_towers.h (working copy)
6 * License along with this library; if not, write to the Free Software
7 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
14 #define EPM_PROTOCOL_DNET_NSP 0x04
15 #define EPM_PROTOCOL_OSI_TP4 0x05
16 #define EPM_PROTOCOL_OSI_CLNS 0x06
17 #define EPM_PROTOCOL_TCP 0x07
19 ===================================================================
20 --- rpc_epmap.c (working copy)
21 +++ rpc_epmap.c (working copy)
24 #include "wine/debug.h"
25 #include "wine/exception.h"
27 #include "rpc_binding.h"
30 #include "epm_towers.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(ole);
34 /* The "real" RPC portmapper endpoints that I know of are:
36 ===================================================================
37 --- rpc_server.c (working copy)
38 +++ rpc_server.c (working copy)
39 @@ -1040,22 +1040,28 @@
40 /***********************************************************************
41 * RpcMgmtServerWaitListen (RPCRT4.@)
43 RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
46 + RpcServerProtseq *cps;
48 EnterCriticalSection(&listen_cs);
51 LeaveCriticalSection(&listen_cs);
52 return RPC_S_NOT_LISTENING;
56 LeaveCriticalSection(&listen_cs);
57 + LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
58 + WaitForSingleObject(cps->server_ready_event, INFINITE);
60 - FIXME("not waiting for server calls to finish\n");
61 + EnterCriticalSection(&listen_cs);
62 + } while (!std_listen);
64 + LeaveCriticalSection(&listen_cs);
69 /***********************************************************************
70 Index: rpc_transport.c
71 ===================================================================
72 --- rpc_transport.c (working copy)
73 +++ rpc_transport.c (working copy)
75 # include <sys/poll.h>
77 # define closesocket close
78 #endif /* defined(__MINGW32__) || defined (_MSC_VER) */
80 +#include <winsock2.h>
81 +#include <ws2tcpip.h>
89 #include "rpc_binding.h"
90 #include "rpc_message.h"
91 #include "rpc_server.h"
92 #include "epm_towers.h"
94 +#include "unix_func.h"
97 # define SOL_TCP IPPROTO_TCP
100 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
103 typedef struct _RpcConnection_np
105 RpcConnection common;
112 static RpcConnection *rpcrt4_conn_np_alloc(void)
114 @@ -118,17 +123,17 @@
117 npc->listening = TRUE;
120 - if (ConnectNamedPipe(npc->pipe, &npc->ovl))
121 + if (ConnectNamedPipe(npc->pipe, &npc->ovl[0]))
124 switch(GetLastError())
126 case ERROR_PIPE_CONNECTED:
127 - SetEvent(npc->ovl.hEvent);
128 + SetEvent(npc->ovl[0].hEvent);
130 case ERROR_IO_PENDING:
131 /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */
133 case ERROR_NO_DATA_DETECTED:
134 @@ -146,11 +151,11 @@
135 static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pname)
137 RpcConnection_np *npc = (RpcConnection_np *) Connection;
138 TRACE("listening on %s\n", pname);
140 - npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX,
141 + npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
142 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
143 PIPE_UNLIMITED_INSTANCES,
144 RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
145 if (npc->pipe == INVALID_HANDLE_VALUE) {
146 WARN("CreateNamedPipe failed with error %d\n", GetLastError());
147 @@ -159,11 +164,12 @@
149 return RPC_S_CANT_CREATE_ENDPOINT;
152 memset(&npc->ovl, 0, sizeof(npc->ovl));
153 - npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
154 + npc->ovl[0].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
155 + npc->ovl[1].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
157 /* Note: we don't call ConnectNamedPipe here because it must be done in the
158 * server thread as the thread must be alertable */
161 @@ -220,11 +226,12 @@
163 memset(&npc->ovl, 0, sizeof(npc->ovl));
164 /* pipe is connected; change to message-read mode. */
165 dwMode = PIPE_READMODE_MESSAGE;
166 SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
167 - npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
168 + npc->ovl[0].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
169 + npc->ovl[1].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
175 @@ -326,11 +333,12 @@
177 /* because of the way named pipes work, we'll transfer the connected pipe
178 * to the child, then reopen the server binding to continue listening */
180 new_npc->pipe = old_npc->pipe;
181 - new_npc->ovl = old_npc->ovl;
182 + new_npc->ovl[0] = old_npc->ovl[0];
183 + new_npc->ovl[1] = old_npc->ovl[1];
185 memset(&old_npc->ovl, 0, sizeof(old_npc->ovl));
186 old_npc->listening = FALSE;
189 @@ -377,13 +385,18 @@
190 unsigned int bytes_left = count;
195 - ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, NULL);
196 - if (!ret || !bytes_read)
197 + ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &npc->ovl[0]);
198 + if ((!ret || !bytes_read) && (GetLastError() != ERROR_IO_PENDING))
201 + ret = GetOverlappedResult(npc->pipe, &npc->ovl[0], &bytes_read, TRUE);
202 + if (!ret && (GetLastError() != ERROR_MORE_DATA))
205 bytes_left -= bytes_read;
208 return ret ? count : -1;
210 @@ -397,13 +410,18 @@
211 unsigned int bytes_left = count;
216 - ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, NULL);
217 - if (!ret || !bytes_written)
218 + ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &npc->ovl[1]);
219 + if ((!ret || !bytes_written) && (GetLastError() != ERROR_IO_PENDING))
222 + ret = GetOverlappedResult(npc->pipe, &npc->ovl[1], &bytes_written, TRUE);
223 + if (!ret && (GetLastError() != ERROR_MORE_DATA))
226 bytes_left -= bytes_written;
227 buf += bytes_written;
229 return ret ? count : -1;
231 @@ -414,13 +432,17 @@
233 FlushFileBuffers(npc->pipe);
234 CloseHandle(npc->pipe);
237 - if (npc->ovl.hEvent) {
238 - CloseHandle(npc->ovl.hEvent);
239 - npc->ovl.hEvent = 0;
240 + if (npc->ovl[0].hEvent) {
241 + CloseHandle(npc->ovl[0].hEvent);
242 + npc->ovl[0].hEvent = 0;
244 + if (npc->ovl[1].hEvent) {
245 + CloseHandle(npc->ovl[1].hEvent);
246 + npc->ovl[1].hEvent = 0;
251 static void rpcrt4_conn_np_cancel_call(RpcConnection *Connection)
252 @@ -579,11 +601,11 @@
253 /* open and count connections */
255 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
257 rpcrt4_conn_listen_pipe(conn);
258 - if (conn->ovl.hEvent)
259 + if (conn->ovl[0].hEvent)
261 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
264 /* make array of connections */
265 @@ -600,11 +622,11 @@
267 objs[0] = npps->mgr_event;
269 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
271 - if ((objs[*count] = conn->ovl.hEvent))
272 + if ((objs[*count] = conn->ovl[0].hEvent))
274 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
276 LeaveCriticalSection(&protseq->cs);
278 @@ -647,11 +669,11 @@
279 b_handle = objs[res - WAIT_OBJECT_0];
280 /* find which connection got a RPC */
281 EnterCriticalSection(&protseq->cs);
282 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
284 - if (b_handle == conn->ovl.hEvent) break;
285 + if (b_handle == conn->ovl[0].hEvent) break;
286 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
290 RPCRT4_SpawnConnection(&cconn, &conn->common);