[RPCRT4] Call WSAStartup in rpcrt4_ip_tcp_get_top_of_tower
authorEric Kohl <eric.kohl@reactos.org>
Mon, 19 Dec 2022 12:39:52 +0000 (13:39 +0100)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 19 Dec 2022 12:39:52 +0000 (13:39 +0100)
This fixes the crash in the rpc winetest.

dll/win32/rpcrt4/rpc_transport.c
dll/win32/rpcrt4/rpcrt4_ros.diff

index be0d052..9edc2ee 100644 (file)
@@ -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)
     {
index 83aaa1e..ff46dad 100644 (file)
@@ -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)
+     {