1 diff -pudN e:\wine\dlls\rpcrt4/cproxy.c e:\reactos\dll\win32\rpcrt4/cproxy.c
2 --- e:\wine\dlls\rpcrt4/cproxy.c 2016-11-16 17:29:34 +0100
3 +++ e:\reactos\dll\win32\rpcrt4/cproxy.c 2015-08-27 22:03:34 +0100
4 @@ -150,6 +150,30 @@ static inline void init_thunk( struct th
5 thunk->call_stubless = call_stubless_func;
8 +#elif defined(__arm__)
10 +extern void call_stubless_func(void);
11 +__ASM_GLOBAL_FUNC(call_stubless_func,
12 + "DCD 0xDEFC\n\t" // _assertfail
15 +#include "pshpack1.h"
22 +static const struct thunk thunk_template =
24 + { 0xDEFC } /* _assertfail */
27 +static inline void init_thunk( struct thunk *thunk, unsigned int index )
29 + *thunk = thunk_template;
34 #warning You must implement stubless proxies for your CPU
35 diff -pudN e:\wine\dlls\rpcrt4/cstub.c e:\reactos\dll\win32\rpcrt4/cstub.c
36 --- e:\wine\dlls\rpcrt4/cstub.c 2016-11-16 17:29:34 +0100
37 +++ e:\reactos\dll\win32\rpcrt4/cstub.c 2016-05-20 23:26:31 +0100
38 @@ -156,6 +156,13 @@ typedef struct
40 static const BYTE opcodes[16] = { 0x48, 0x8b, 0x49, 0x20, 0x48, 0x8b, 0x01,
41 0xff, 0xa0, 0, 0, 0, 0, 0x48, 0x8d, 0x36 };
42 +#elif defined(__arm__)
47 +static const BYTE opcodes[1];
51 #warning You must implement delegated proxies/stubs for your CPU
53 diff -pudN e:\wine\dlls\rpcrt4/rpc_epmap.c e:\reactos\dll\win32\rpcrt4/rpc_epmap.c
54 --- e:\wine\dlls\rpcrt4/rpc_epmap.c 2016-11-16 17:29:34 +0100
55 +++ e:\reactos\dll\win32\rpcrt4/rpc_epmap.c 2016-11-17 12:09:06 +0100
56 @@ -171,7 +173,7 @@ static RPC_STATUS get_epm_handle_server(
58 static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr)
60 - switch (GetExceptionCode())
61 + switch (__eptr->ExceptionRecord->ExceptionCode)
63 case EXCEPTION_ACCESS_VIOLATION:
64 case EXCEPTION_ILLEGAL_INSTRUCTION:
65 diff -pudN e:\wine\dlls\rpcrt4/rpc_transport.c e:\reactos\dll\win32\rpcrt4/rpc_transport.c
66 --- e:\wine\dlls\rpcrt4/rpc_transport.c 2016-11-16 17:33:13 +0100
67 +++ e:\reactos\dll\win32\rpcrt4/rpc_transport.c 2016-11-17 00:00:46 +0100
70 #define DEFAULT_NCACN_HTTP_TIMEOUT (60 * 1000)
73 #define ARRAYSIZE(a) (sizeof((a)) / sizeof((a)[0]))
75 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
76 @@ -94,31 +92,41 @@ typedef struct _RpcConnection_np
80 - HANDLE listen_thread;
85 static RpcConnection *rpcrt4_conn_np_alloc(void)
87 RpcConnection_np *npc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcConnection_np));
91 + memset(&npc->ovl, 0, sizeof(npc->ovl));
92 + npc->listening = FALSE;
97 -static DWORD CALLBACK listen_thread(void *arg)
98 +static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc)
100 - RpcConnection_np *npc = arg;
101 + if (npc->listening)
104 + npc->listening = TRUE;
107 - if (ConnectNamedPipe(npc->pipe, NULL))
108 + if (ConnectNamedPipe(npc->pipe, &npc->ovl))
111 switch(GetLastError())
113 case ERROR_PIPE_CONNECTED:
114 + SetEvent(npc->ovl.hEvent);
116 + case ERROR_IO_PENDING:
117 + /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */
119 - case ERROR_HANDLES_CLOSED:
120 - /* connection closed during listen */
121 - return RPC_S_NO_CONTEXT_AVAILABLE;
122 case ERROR_NO_DATA_DETECTED:
123 /* client has disconnected, retry */
124 DisconnectNamedPipe( npc->pipe );
125 @@ -131,6 +139,7 @@ static DWORD CALLBACK listen_thread(void
130 static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc)
133 @@ -146,13 +155,14 @@ static RPC_STATUS rpcrt4_conn_listen_pip
139 static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pname)
141 RpcConnection_np *npc = (RpcConnection_np *) Connection;
142 TRACE("listening on %s\n", pname);
144 - npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX,
145 + npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
146 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
147 PIPE_UNLIMITED_INSTANCES,
148 RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
149 @@ -164,6 +174,9 @@ static RPC_STATUS rpcrt4_conn_create_pip
150 return RPC_S_CANT_CREATE_ENDPOINT;
153 + memset(&npc->ovl, 0, sizeof(npc->ovl));
154 + npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
156 /* Note: we don't call ConnectNamedPipe here because it must be done in the
157 * server thread as the thread must be alertable */
159 @@ -210,6 +223,9 @@ static RPC_STATUS rpcrt4_conn_open_pipe(
160 if (err == ERROR_PIPE_BUSY) {
161 TRACE("connection failed, error=%x\n", err);
162 return RPC_S_SERVER_TOO_BUSY;
163 + } else if (err == ERROR_BAD_NETPATH) {
164 + TRACE("connection failed, error=%x\n", err);
165 + return RPC_S_SERVER_UNAVAILABLE;
167 if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
168 err = GetLastError();
169 @@ -219,9 +235,11 @@ static RPC_STATUS rpcrt4_conn_open_pipe(
173 + memset(&npc->ovl, 0, sizeof(npc->ovl));
174 /* pipe is connected; change to message-read mode. */
175 dwMode = PIPE_READMODE_MESSAGE;
176 SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
177 + npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
181 @@ -304,15 +322,64 @@ static char *ncacn_pipe_name(const char
182 static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
184 RpcConnection_np *npc = (RpcConnection_np *) Connection;
185 + static const char prefix[] = "\\\\";
186 + static const char local[] = ".";
187 + BOOL bUseLocalName = TRUE;
188 + CHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
189 + DWORD bufLen = sizeof(ComputerName)/sizeof(ComputerName[0]);
195 /* already connected? */
199 - pname = ncacn_pipe_name(Connection->Endpoint);
200 - r = rpcrt4_conn_open_pipe(Connection, pname, FALSE);
201 + /* protseq=ncacn_np: named pipes */
202 + size = strlen(prefix);
204 + if (Connection->NetworkAddr == NULL || strlen(Connection->NetworkAddr) == 0)
206 + bUseLocalName = TRUE;
207 + size += strlen(local);
211 + NetworkAddr = Connection->NetworkAddr;
212 + if (NetworkAddr[0] == '\\' && NetworkAddr[1] == '\\')
215 + if (GetComputerNameA(ComputerName, &bufLen))
217 + if (stricmp(ComputerName, NetworkAddr) == 0)
219 + bUseLocalName = TRUE;
220 + size += strlen(local);
224 + bUseLocalName = FALSE;
225 + size += strlen(NetworkAddr);
230 + bUseLocalName = FALSE;
231 + size += strlen(NetworkAddr);
235 + size += strlen(Connection->Endpoint) + 1;
237 + pname = I_RpcAllocate(size);
238 + strcpy(pname, prefix);
240 + strcat(pname, local);
242 + strcat(pname, NetworkAddr);
243 + strcat(pname, Connection->Endpoint);
244 + r = rpcrt4_conn_open_pipe(Connection, pname, TRUE);
248 @@ -358,9 +425,9 @@ static void rpcrt4_conn_np_handoff(RpcCo
249 * to the child, then reopen the server binding to continue listening */
251 new_npc->pipe = old_npc->pipe;
252 - new_npc->listen_thread = old_npc->listen_thread;
253 + new_npc->ovl = old_npc->ovl;
255 - old_npc->listen_thread = 0;
256 + memset(&old_npc->ovl, 0, sizeof(old_npc->ovl));
257 old_npc->listening = FALSE;
260 @@ -444,20 +511,29 @@ static int rpcrt4_conn_np_read(RpcConnec
261 void *buffer, unsigned int count)
263 RpcConnection_np *npc = (RpcConnection_np *) Connection;
264 - IO_STATUS_BLOCK io_status;
267 unsigned int bytes_left = count;
271 + ZeroMemory(&ovl, sizeof(ovl));
272 + ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
276 - status = NtReadFile(npc->pipe, NULL, NULL, NULL, &io_status, buf, bytes_left, NULL, NULL);
277 - if (status && status != STATUS_BUFFER_OVERFLOW)
279 - bytes_left -= io_status.Information;
280 - buf += io_status.Information;
282 + ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &ovl);
283 + if (!ret && GetLastError() == ERROR_IO_PENDING)
284 + ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_read, TRUE);
285 + if (!ret && GetLastError() == ERROR_MORE_DATA)
287 + if (!ret || !bytes_read)
289 + bytes_left -= bytes_read;
293 + CloseHandle(ovl.hEvent);
294 + return ret ? count : -1;
297 static int rpcrt4_conn_np_write(RpcConnection *Connection,
298 @@ -467,16 +543,23 @@ static int rpcrt4_conn_np_write(RpcConne
299 const char *buf = buffer;
301 unsigned int bytes_left = count;
304 + ZeroMemory(&ovl, sizeof(ovl));
305 + ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
310 - ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, NULL);
311 + ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &ovl);
312 + if (!ret && GetLastError() == ERROR_IO_PENDING)
313 + ret = GetOverlappedResult(npc->pipe, &ovl, &bytes_written, TRUE);
314 if (!ret || !bytes_written)
316 bytes_left -= bytes_written;
317 buf += bytes_written;
319 + CloseHandle(ovl.hEvent);
320 return ret ? count : -1;
323 @@ -488,9 +571,9 @@ static int rpcrt4_conn_np_close(RpcConne
324 CloseHandle(npc->pipe);
327 - if (npc->listen_thread) {
328 - CloseHandle(npc->listen_thread);
329 - npc->listen_thread = 0;
330 + if (npc->ovl.hEvent) {
331 + CloseHandle(npc->ovl.hEvent);
332 + npc->ovl.hEvent = 0;
336 @@ -694,7 +777,7 @@ static void *rpcrt4_protseq_np_get_wait_
337 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
339 rpcrt4_conn_listen_pipe(conn);
340 - if (conn->listen_thread)
341 + if (conn->ovl.hEvent)
343 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
345 @@ -715,7 +798,7 @@ static void *rpcrt4_protseq_np_get_wait_
347 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
349 - if ((objs[*count] = conn->listen_thread))
350 + if ((objs[*count] = conn->ovl.hEvent))
352 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
354 @@ -762,18 +845,12 @@ static int rpcrt4_protseq_np_wait_for_ne
355 EnterCriticalSection(&protseq->cs);
356 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
358 - if (b_handle == conn->listen_thread) break;
359 + if (b_handle == conn->ovl.hEvent) break;
360 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
366 - if (GetExitCodeThread(conn->listen_thread, &exit_code) && exit_code == RPC_S_OK)
367 - RPCRT4_SpawnConnection(&cconn, &conn->common);
368 - CloseHandle(conn->listen_thread);
369 - conn->listen_thread = 0;
371 + RPCRT4_SpawnConnection(&cconn, &conn->common);
373 ERR("failed to locate connection for handle %p\n", b_handle);
374 LeaveCriticalSection(&protseq->cs);