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); + if (server != NULL && *server != 0) + { + /* Trim any leading UNC server prefix. */ + if (server[0] == '\\' && server[1] == '\\') + server += 2; - GetComputerNameA(ComputerName, &bufLen); - - 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));