https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d01de6dc8b892027f3d284973af8c8eca41c65f9

commit d01de6dc8b892027f3d284973af8c8eca41c65f9
Author:     Eric Kohl <[email protected]>
AuthorDate: Mon Dec 19 13:39:52 2022 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Mon Dec 19 13:39:52 2022 +0100

    [RPCRT4] Call WSAStartup in rpcrt4_ip_tcp_get_top_of_tower
    
    This fixes the crash in the rpc winetest.
---
 dll/win32/rpcrt4/rpc_transport.c | 12 ++++++++++++
 dll/win32/rpcrt4/rpcrt4_ros.diff | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/dll/win32/rpcrt4/rpc_transport.c b/dll/win32/rpcrt4/rpc_transport.c
index be0d052bef3..9edc2ee718d 100644
--- a/dll/win32/rpcrt4/rpc_transport.c
+++ b/dll/win32/rpcrt4/rpc_transport.c
@@ -1257,6 +1257,18 @@ static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned 
char *tower_data,
     hints.ai_canonname      = NULL;
     hints.ai_next           = NULL;
 
+#ifdef __REACTOS__
+    static BOOL wsa_inited;
+    if (!wsa_inited)
+    {
+        WSADATA wsadata;
+        WSAStartup(MAKEWORD(2, 2), &wsadata);
+        /* Note: WSAStartup can be called more than once so we don't bother 
with
+         * making accesses to wsa_inited thread-safe */
+        wsa_inited = TRUE;
+    }
+#endif
+
     ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
     if (ret)
     {
diff --git a/dll/win32/rpcrt4/rpcrt4_ros.diff b/dll/win32/rpcrt4/rpcrt4_ros.diff
index 83aaa1ec610..ff46dad36aa 100644
--- a/dll/win32/rpcrt4/rpcrt4_ros.diff
+++ b/dll/win32/rpcrt4/rpcrt4_ros.diff
@@ -257,3 +257,22 @@ diff -pudN e:\wine\dlls\rpcrt4/rpc_transport.c 
e:\reactos\dll\win32\rpcrt4/rpc_t
                  break;
              }
          }
+@@ -1257,6 +1257,18 @@ static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned 
char *tower_data,
+     hints.ai_canonname      = NULL;
+     hints.ai_next           = NULL;
+ 
++#ifdef __REACTOS__
++    static BOOL wsa_inited;
++    if (!wsa_inited)
++    {
++        WSADATA wsadata;
++        WSAStartup(MAKEWORD(2, 2), &wsadata);
++        /* Note: WSAStartup can be called more than once so we don't bother 
with
++         * making accesses to wsa_inited thread-safe */
++        wsa_inited = TRUE;
++    }
++#endif
++
+     ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
+     if (ret)
+     {

Reply via email to