1999-11-04 03:17:03 +01:00
|
|
|
/*
|
|
|
|
* DPLAYX.DLL LibMain
|
|
|
|
*
|
2000-07-10 15:19:28 +02:00
|
|
|
* Copyright 1999,2000 - Peter Hunnisett
|
1999-11-04 03:17:03 +01:00
|
|
|
*
|
|
|
|
* contact <hunnise@nortelnetworks.com>
|
|
|
|
*/
|
2000-08-25 23:58:05 +02:00
|
|
|
#include "winerror.h"
|
1999-11-04 03:17:03 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "debugtools.h"
|
|
|
|
#include "dplayx_global.h"
|
|
|
|
|
2000-08-03 06:22:35 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(dplay);
|
1999-11-04 03:17:03 +01:00
|
|
|
|
|
|
|
static DWORD DPLAYX_dwProcessesAttached = 0;
|
|
|
|
|
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? */
|
|
|
|
|
|
|
|
|
1999-11-04 03:17:03 +01:00
|
|
|
BOOL WINAPI DPLAYX_LibMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
|
|
|
{
|
2000-05-30 22:08:32 +02:00
|
|
|
|
2000-07-10 15:19:28 +02:00
|
|
|
TRACE( "(%u,0x%08lx,%p) & 0x%08lx\n", hinstDLL, fdwReason, lpvReserved, DPLAYX_dwProcessesAttached );
|
2000-05-30 22:08:32 +02:00
|
|
|
|
1999-11-04 03:17:03 +01:00
|
|
|
switch ( fdwReason )
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
{
|
|
|
|
|
2000-07-10 15:19:28 +02:00
|
|
|
if ( DPLAYX_dwProcessesAttached++ == 0 )
|
1999-11-04 03:17:03 +01: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
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
{
|
|
|
|
|
2000-07-10 15:19:28 +02:00
|
|
|
if ( --DPLAYX_dwProcessesAttached == 0 )
|
1999-11-04 03:17:03 +01:00
|
|
|
{
|
2000-07-10 15:19:28 +02:00
|
|
|
/* Last instance performs destruction of global processor data */
|
|
|
|
return DPLAYX_DestructData();
|
1999-11-04 03:17:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DLL_THREAD_ATTACH: /* Do nothing */
|
|
|
|
case DLL_THREAD_DETACH: /* Do nothing */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-25 23:58:05 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllCanUnloadNow (DPLAYX.10)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DPLAYX_DllCanUnloadNow(void)
|
|
|
|
{
|
|
|
|
HRESULT hr = ( gdwDPlaySPRefCount > 0 ) ? S_FALSE : S_OK;
|
|
|
|
|
|
|
|
/* FIXME: Should I be putting a check in for class factory objects
|
|
|
|
* as well
|
|
|
|
*/
|
|
|
|
|
|
|
|
TRACE( ": returning 0x%08lx\n", hr );
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|