https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5274857da98c5b1a4f602…
commit 5274857da98c5b1a4f6021f54ef8cbe1c3218376
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Apr 2 18:25:44 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Apr 2 18:35:39 2020 +0200
[RPCRT4] Addendum to support for remote pipes names in ncacn_pipe_name() (24cd7bbe).
CORE-6561 CORE-13442
- Call GetComputerNameA() only when a non-empty server name has been
provided, thus slightly improving speed for the most common case when
local calls (with an empty server name) are done.
- When a server name is passed, trim any leading UNC server prefix since
the latter will be restored when building the pipe name string.
---
dll/win32/rpcrt4/rpc_transport.c | 21 +++++++++++++++++----
dll/win32/rpcrt4/rpcrt4_ros.diff | 20 +++++++++++++++++---
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/dll/win32/rpcrt4/rpc_transport.c b/dll/win32/rpcrt4/rpc_transport.c
index aee897644c9..e77cb287be9 100644
--- a/dll/win32/rpcrt4/rpc_transport.c
+++ b/dll/win32/rpcrt4/rpc_transport.c
@@ -262,18 +262,31 @@ static char *ncacn_pipe_name(const char *endpoint)
static const char prefix[] = "\\\\";
static const char local[] = ".";
char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+ DWORD bufLen = ARRAY_SIZE(ComputerName);
#else
static const char prefix[] = "\\\\.";
#endif
char *pipe_name;
#ifdef __REACTOS__
- DWORD bufLen = ARRAYSIZE(ComputerName);
-
- GetComputerNameA(ComputerName, &bufLen);
+ if (server != NULL && *server != 0)
+ {
+ /* Trim any leading UNC server prefix. */
+ if (server[0] == '\\' && server[1] == '\\')
+ server += 2;
- if (server == NULL || *server == 0 || stricmp(ComputerName, server) == 0)
+ /* If the server represents the local computer, use instead
+ * the local prefix to avoid a round in UNC name resolution. */
+ if (GetComputerNameA(ComputerName, &bufLen) &&
+ (stricmp(ComputerName, server) == 0))
+ {
server = local;
+ }
+ }
+ else
+ {
+ server = local;
+ }
#endif
/* protseq=ncacn_np: named pipes */
diff --git a/dll/win32/rpcrt4/rpcrt4_ros.diff b/dll/win32/rpcrt4/rpcrt4_ros.diff
index ea7412c191c..c1ae133a864 100644
--- a/dll/win32/rpcrt4/rpcrt4_ros.diff
+++ b/dll/win32/rpcrt4/rpcrt4_ros.diff
@@ -129,13 +129,27 @@ diff -pudN e:\wine\dlls\rpcrt4/rpc_transport.c
e:\reactos\dll\win32\rpcrt4/rpc_t
+ static const char prefix[] = "\\\\";
+ static const char local[] = ".";
+ char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
++ DWORD bufLen = ARRAY_SIZE(ComputerName);
char *pipe_name;
-+ DWORD bufLen = ARRAYSIZE(ComputerName);
+
-+ GetComputerNameA(ComputerName, &bufLen);
++ if (server != NULL && *server != 0)
++ {
++ /* Trim any leading UNC server prefix. */
++ if (server[0] == '\\' && server[1] == '\\')
++ server += 2;
+
-+ if (server == NULL || *server == 0 || stricmp(ComputerName, server) == 0)
++ /* If the server represents the local computer, use instead
++ * the local prefix to avoid a round in UNC name resolution. */
++ if (GetComputerNameA(ComputerName, &bufLen) &&
++ (stricmp(ComputerName, server) == 0))
++ {
+ server = local;
++ }
++ }
++ else
++ {
++ server = local;
++ }
/* protseq=ncacn_np: named pipes */
- pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));