Commit db003d4a authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

dpnet: Initialize winsock.

parent eef69511
MODULE = dpnet.dll MODULE = dpnet.dll
IMPORTLIB = dpnet IMPORTLIB = dpnet
IMPORTS = dxguid uuid ole32 advapi32 IMPORTS = dxguid uuid ole32 advapi32 ws2_32
C_SRCS = \ C_SRCS = \
address.c \ address.c \
......
...@@ -115,6 +115,8 @@ static HRESULT WINAPI IDirectPlay8ClientImpl_Initialize(IDirectPlay8Client *ifac ...@@ -115,6 +115,8 @@ static HRESULT WINAPI IDirectPlay8ClientImpl_Initialize(IDirectPlay8Client *ifac
This->msghandler = pfn; This->msghandler = pfn;
This->flags = dwFlags; This->flags = dwFlags;
init_winsock();
return DPN_OK; return DPN_OK;
} }
...@@ -443,6 +445,8 @@ static HRESULT WINAPI lobbyclient_Initialize(IDirectPlay8LobbyClient *iface, voi ...@@ -443,6 +445,8 @@ static HRESULT WINAPI lobbyclient_Initialize(IDirectPlay8LobbyClient *iface, voi
This->msghandler = msghandler; This->msghandler = msghandler;
This->flags = flags; This->flags = flags;
init_winsock();
return DPN_OK; return DPN_OK;
} }
......
...@@ -40,15 +40,46 @@ WINE_DEFAULT_DEBUG_CHANNEL(dpnet); ...@@ -40,15 +40,46 @@ WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
static HINSTANCE instance; static HINSTANCE instance;
static BOOL winsock_loaded = FALSE;
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **context)
{
WSADATA wsa_data;
DWORD res;
res = WSAStartup(MAKEWORD(1,1), &wsa_data);
if(res == ERROR_SUCCESS)
winsock_loaded = TRUE;
else
ERR("WSAStartup failed: %u\n", res);
return TRUE;
}
void init_winsock(void)
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
InitOnceExecuteOnce(&init_once, winsock_startup, NULL, NULL);
}
/* At process attach */ /* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
TRACE("%p,%x,%p\n", hInstDLL, fdwReason, lpvReserved); TRACE("%p,%x,%p\n", hInstDLL, fdwReason, lpvReserved);
if (fdwReason == DLL_PROCESS_ATTACH) {
instance = hInstDLL; switch(fdwReason)
DisableThreadLibraryCalls(hInstDLL); {
} case DLL_PROCESS_ATTACH:
return TRUE; instance = hInstDLL;
DisableThreadLibraryCalls(hInstDLL);
break;
case DLL_PROCESS_DETACH:
if (lpvReserved) break;
if(winsock_loaded)
WSACleanup();
break;
}
return TRUE;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#endif #endif
#include <wine/list.h> #include <wine/list.h>
#include "winsock2.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "dplay8.h" #include "dplay8.h"
...@@ -135,6 +136,7 @@ extern HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN ...@@ -135,6 +136,7 @@ extern HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN
extern HRESULT DPNET_CreateDirectPlay8LobbyClient(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppobj) DECLSPEC_HIDDEN; extern HRESULT DPNET_CreateDirectPlay8LobbyClient(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppobj) DECLSPEC_HIDDEN;
extern void init_dpn_sp_caps(DPN_SP_CAPS *dpnspcaps) DECLSPEC_HIDDEN; extern void init_dpn_sp_caps(DPN_SP_CAPS *dpnspcaps) DECLSPEC_HIDDEN;
extern void init_winsock(void) DECLSPEC_HIDDEN;
/* used for generic dumping (copied from ddraw) */ /* used for generic dumping (copied from ddraw) */
typedef struct { typedef struct {
......
...@@ -101,6 +101,8 @@ static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_Initialize(IDirectPlay8 ...@@ -101,6 +101,8 @@ static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_Initialize(IDirectPlay8
This->usercontext = pvUserContext; This->usercontext = pvUserContext;
This->connection = pdpnhConnection; This->connection = pdpnhConnection;
init_winsock();
return DPN_OK; return DPN_OK;
} }
......
...@@ -122,6 +122,8 @@ static HRESULT WINAPI IDirectPlay8PeerImpl_Initialize(IDirectPlay8Peer *iface, ...@@ -122,6 +122,8 @@ static HRESULT WINAPI IDirectPlay8PeerImpl_Initialize(IDirectPlay8Peer *iface,
This->msghandler = pfn; This->msghandler = pfn;
This->flags = dwFlags; This->flags = dwFlags;
init_winsock();
return DPN_OK; return DPN_OK;
} }
......
...@@ -118,6 +118,8 @@ static HRESULT WINAPI IDirectPlay8ServerImpl_Initialize(IDirectPlay8Server *ifac ...@@ -118,6 +118,8 @@ static HRESULT WINAPI IDirectPlay8ServerImpl_Initialize(IDirectPlay8Server *ifac
This->msghandler = pfn; This->msghandler = pfn;
This->flags = dwFlags; This->flags = dwFlags;
init_winsock();
return DPN_OK; return DPN_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment