2002-06-01 01:06:46 +02:00
|
|
|
/*
|
1999-11-04 03:17:03 +01:00
|
|
|
* DPLAYX.DLL LibMain
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Copyright 1999,2000 - Peter Hunnisett
|
1999-11-04 03:17:03 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-09-27 04:23:44 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* o DPMSGCMD_ENUMSESSIONSREPLY & DPMSGCMD_ENUMSESSIONSREQUEST
|
|
|
|
* Have most fields understood, but not all. Everything seems to work.
|
|
|
|
* o DPMSGCMD_REQUESTNEWPLAYERID & DPMSGCMD_NEWPLAYERIDREPLY
|
2008-04-02 22:10:47 +02:00
|
|
|
* Barely works. This needs to be completed for sessions to start.
|
2003-09-27 04:23:44 +02:00
|
|
|
* o A small issue will be the fact that DirectX 6.1(ie. DirectPlay4)
|
|
|
|
* introduces a layer of functionality inside the DP objects which
|
|
|
|
* provide guaranteed protocol delivery. This is even if the native
|
|
|
|
* protocol, IPX or modem for instance, doesn't guarantee it. I'm going
|
|
|
|
* to leave this kind of implementation to as close to the end as
|
|
|
|
* possible. However, I will implement an abstraction layer, where
|
|
|
|
* possible, for this functionality. It will do nothing to start, but
|
2008-04-02 22:10:47 +02:00
|
|
|
* will require only the implementation of the guarantee to give
|
2003-09-27 04:23:44 +02:00
|
|
|
* final implementation.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* - Implement mutual exclusion on object data for existing functions
|
|
|
|
* - Ensure that all dll stubs are present and the ordinals are correct
|
|
|
|
* - Addition of DirectX 7.0 functionality for direct play
|
|
|
|
* - Implement some WineLib test programs using sdk programs as a skeleton
|
|
|
|
* - Change RegEnumKeyEx enumeration pattern to allow error handling and to
|
|
|
|
* share registry implementation (or at least simplify).
|
|
|
|
* - Add in appropriate RegCloseKey calls for all the opening we're doing...
|
|
|
|
* - Fix all the buffer sizes for registry calls. They're off by one -
|
|
|
|
* but in a safe direction.
|
|
|
|
* - Fix race condition on interface destruction
|
|
|
|
* - Handles need to be correctly reference counted
|
|
|
|
* - Check if we need to deallocate any list objects when destroying
|
|
|
|
* a dplay interface
|
|
|
|
* - RunApplication process spawning needs to have correct syncronization.
|
|
|
|
* - Need to get inter lobby messages working.
|
|
|
|
* - Decypher dplay messages between applications and implement...
|
|
|
|
* - Need to implement lobby session spawning.
|
|
|
|
* - Improve footprint and realtime blocking by setting up a separate data share
|
|
|
|
* between lobby application and client since there can be multiple apps per
|
|
|
|
* client. Also get rid of offset dependency by making data offset independent
|
|
|
|
* somehow.
|
1999-11-04 03:17:03 +01:00
|
|
|
*/
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2000-08-25 23:58:05 +02:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-11-04 03:17:03 +01:00
|
|
|
#include "winbase.h"
|
2010-12-07 12:52:05 +01:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "rpcproxy.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-11-04 03:17:03 +01:00
|
|
|
#include "dplayx_global.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dplay);
|
1999-11-04 03:17:03 +01:00
|
|
|
|
2010-12-07 12:52:05 +01:00
|
|
|
static HINSTANCE instance;
|
|
|
|
|
2000-08-25 23:58:05 +02:00
|
|
|
/* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */
|
|
|
|
DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */
|
|
|
|
|
|
|
|
|
2002-11-05 00:53:41 +01:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
1999-11-04 03:17:03 +01:00
|
|
|
{
|
2000-05-30 22:08:32 +02:00
|
|
|
|
2006-10-10 01:07:17 +02:00
|
|
|
TRACE( "(%p,%d,%p)\n", hinstDLL, fdwReason, lpvReserved );
|
2000-05-30 22:08:32 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
switch ( fdwReason )
|
1999-11-04 03:17:03 +01:00
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2010-12-07 12:52:05 +01:00
|
|
|
instance = hinstDLL;
|
2003-06-30 22:53:48 +02:00
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
2002-06-01 01:06:46 +02:00
|
|
|
/* First instance perform construction of global processor data */
|
2000-07-10 15:19:28 +02:00
|
|
|
return DPLAYX_ConstructData();
|
1999-11-04 03:17:03 +01:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2000-07-10 15:19:28 +02:00
|
|
|
/* Last instance performs destruction of global processor data */
|
2002-06-01 01:06:46 +02:00
|
|
|
return DPLAYX_DestructData();
|
1999-11-04 03:17:03 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
default:
|
1999-11-04 03:17:03 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-25 23:58:05 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2005-08-10 15:02:43 +02:00
|
|
|
* DllCanUnloadNow (DPLAYX.@)
|
2000-08-25 23:58:05 +02:00
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2000-08-25 23:58:05 +02:00
|
|
|
{
|
|
|
|
HRESULT hr = ( gdwDPlaySPRefCount > 0 ) ? S_FALSE : S_OK;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* FIXME: Should I be putting a check in for class factory objects
|
2008-04-02 22:10:47 +02:00
|
|
|
* as well?
|
2000-08-25 23:58:05 +02:00
|
|
|
*/
|
|
|
|
|
2006-10-10 01:07:17 +02:00
|
|
|
TRACE( ": returning 0x%08x\n", hr );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-25 23:58:05 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2010-12-07 12:52:05 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (DPLAYX.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
|
|
|
return __wine_register_resources( instance, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (DPLAYX.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
|
|
|
return __wine_unregister_resources( instance, NULL );
|
|
|
|
}
|