Commit 06187462 authored by Alexandre Julliard's avatar Alexandre Julliard

Cleaned up dll startup routines now that we have separate address

spaces.
parent 18a9d741
...@@ -60,7 +60,6 @@ extern void UPDOWN_Unregister(void); ...@@ -60,7 +60,6 @@ extern void UPDOWN_Unregister(void);
HANDLE COMCTL32_hHeap = (HANDLE)NULL; HANDLE COMCTL32_hHeap = (HANDLE)NULL;
DWORD COMCTL32_dwProcessesAttached = 0;
LPSTR COMCTL32_aSubclass = (LPSTR)NULL; LPSTR COMCTL32_aSubclass = (LPSTR)NULL;
HMODULE COMCTL32_hModule = 0; HMODULE COMCTL32_hModule = 0;
LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
...@@ -95,85 +94,75 @@ COMCTL32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -95,85 +94,75 @@ COMCTL32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (COMCTL32_dwProcessesAttached == 0) { COMCTL32_hModule = (HMODULE)hinstDLL;
/* This will be wrong for any other process attching in this address-space! */ /* create private heap */
COMCTL32_hModule = (HMODULE)hinstDLL; COMCTL32_hHeap = HeapCreate (0, 0x10000, 0);
TRACE("Heap created: 0x%x\n", COMCTL32_hHeap);
/* create private heap */
COMCTL32_hHeap = HeapCreate (0, 0x10000, 0); /* add global subclassing atom (used by 'tooltip' and 'updown') */
TRACE("Heap created: 0x%x\n", COMCTL32_hHeap); COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass);
/* add global subclassing atom (used by 'tooltip' and 'updown') */
COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo"); /* create local pattern brush */
TRACE("Subclassing atom added: %p\n", COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA);
COMCTL32_aSubclass); COMCTL32_hPattern55AABrush = CreatePatternBrush (COMCTL32_hPattern55AABitmap);
/* create local pattern brush */ /* register all Win95 common control classes */
COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA); ANIMATE_Register ();
COMCTL32_hPattern55AABrush = CreatePatternBrush (COMCTL32_hPattern55AABitmap); FLATSB_Register ();
HEADER_Register ();
/* register all Win95 common control classes */ HOTKEY_Register ();
ANIMATE_Register (); LISTVIEW_Register ();
FLATSB_Register (); PROGRESS_Register ();
HEADER_Register (); STATUS_Register ();
HOTKEY_Register (); TAB_Register ();
LISTVIEW_Register (); TOOLBAR_Register ();
PROGRESS_Register (); TOOLTIPS_Register ();
STATUS_Register (); TRACKBAR_Register ();
TAB_Register (); TREEVIEW_Register ();
TOOLBAR_Register (); UPDOWN_Register ();
TOOLTIPS_Register (); break;
TRACKBAR_Register ();
TREEVIEW_Register ();
UPDOWN_Register ();
}
COMCTL32_dwProcessesAttached++;
break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
COMCTL32_dwProcessesAttached--; /* unregister all common control classes */
if (COMCTL32_dwProcessesAttached == 0) { ANIMATE_Unregister ();
/* unregister all common control classes */ COMBOEX_Unregister ();
ANIMATE_Unregister (); DATETIME_Unregister ();
COMBOEX_Unregister (); FLATSB_Unregister ();
DATETIME_Unregister (); HEADER_Unregister ();
FLATSB_Unregister (); HOTKEY_Unregister ();
HEADER_Unregister (); IPADDRESS_Unregister ();
HOTKEY_Unregister (); LISTVIEW_Unregister ();
IPADDRESS_Unregister (); MONTHCAL_Unregister ();
LISTVIEW_Unregister (); NATIVEFONT_Unregister ();
MONTHCAL_Unregister (); PAGER_Unregister ();
NATIVEFONT_Unregister (); PROGRESS_Unregister ();
PAGER_Unregister (); REBAR_Unregister ();
PROGRESS_Unregister (); STATUS_Unregister ();
REBAR_Unregister (); TAB_Unregister ();
STATUS_Unregister (); TOOLBAR_Unregister ();
TAB_Unregister (); TOOLTIPS_Unregister ();
TOOLBAR_Unregister (); TRACKBAR_Unregister ();
TOOLTIPS_Unregister (); TREEVIEW_Unregister ();
TRACKBAR_Unregister (); UPDOWN_Unregister ();
TREEVIEW_Unregister ();
UPDOWN_Unregister (); /* delete local pattern brush */
DeleteObject (COMCTL32_hPattern55AABrush);
/* delete local pattern brush */ COMCTL32_hPattern55AABrush = (HANDLE)NULL;
DeleteObject (COMCTL32_hPattern55AABrush); DeleteObject (COMCTL32_hPattern55AABitmap);
COMCTL32_hPattern55AABrush = (HANDLE)NULL; COMCTL32_hPattern55AABitmap = (HANDLE)NULL;
DeleteObject (COMCTL32_hPattern55AABitmap);
COMCTL32_hPattern55AABitmap = (HANDLE)NULL; /* delete global subclassing atom */
GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass));
/* delete global subclassing atom */ TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass);
GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass)); COMCTL32_aSubclass = (LPSTR)NULL;
TRACE("Subclassing atom deleted: %p\n",
COMCTL32_aSubclass); /* destroy private heap */
COMCTL32_aSubclass = (LPSTR)NULL; HeapDestroy (COMCTL32_hHeap);
TRACE("Heap destroyed: 0x%x\n", COMCTL32_hHeap);
/* destroy private heap */ COMCTL32_hHeap = (HANDLE)NULL;
HeapDestroy (COMCTL32_hHeap); break;
TRACE("Heap destroyed: 0x%x\n", COMCTL32_hHeap);
COMCTL32_hHeap = (HANDLE)NULL;
}
break;
} }
return TRUE; return TRUE;
......
...@@ -32,18 +32,7 @@ BOOL WINAPI COMMDLG_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD ...@@ -32,18 +32,7 @@ BOOL WINAPI COMMDLG_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD
switch(Reason) switch(Reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
COMMDLG_Attach++; if (COMMDLG_Attach++) break;
if(COMMDLG_hInstance)
{
ERR("commdlg.dll instantiated twice!\n");
/*
* We should return FALSE here, but that will break
* most apps that use CreateProcess because we do
* not yet support seperate address-spaces.
*/
return TRUE;
}
COMMDLG_hInstance = hInst; COMMDLG_hInstance = hInst;
if(!COMMDLG_hInstance32) if(!COMMDLG_hInstance32)
{ {
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
DEFAULT_DEBUG_CHANNEL(dplay); DEFAULT_DEBUG_CHANNEL(dplay);
static DWORD DPLAYX_dwProcessesAttached = 0;
/* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */ /* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */
DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */ DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */
...@@ -21,33 +19,17 @@ DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */ ...@@ -21,33 +19,17 @@ DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */
BOOL WINAPI DPLAYX_LibMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) BOOL WINAPI DPLAYX_LibMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{ {
TRACE( "(%u,0x%08lx,%p) & 0x%08lx\n", hinstDLL, fdwReason, lpvReserved, DPLAYX_dwProcessesAttached ); TRACE( "(%u,0x%08lx,%p)\n", hinstDLL, fdwReason, lpvReserved );
switch ( fdwReason ) switch ( fdwReason )
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
{
if ( DPLAYX_dwProcessesAttached++ == 0 )
{
/* First instance perform construction of global processor data */ /* First instance perform construction of global processor data */
return DPLAYX_ConstructData(); return DPLAYX_ConstructData();
}
break;
}
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
{
if ( --DPLAYX_dwProcessesAttached == 0 )
{
/* Last instance performs destruction of global processor data */ /* Last instance performs destruction of global processor data */
return DPLAYX_DestructData(); return DPLAYX_DestructData();
}
break;
}
case DLL_THREAD_ATTACH: /* Do nothing */ case DLL_THREAD_ATTACH: /* Do nothing */
case DLL_THREAD_DETACH: /* Do nothing */ case DLL_THREAD_DETACH: /* Do nothing */
......
...@@ -18,7 +18,6 @@ DEFAULT_DEBUG_CHANNEL(imm); ...@@ -18,7 +18,6 @@ DEFAULT_DEBUG_CHANNEL(imm);
#include "imm_private.h" #include "imm_private.h"
static DWORD IMM32_dwProcessAttached = 0;
static HANDLE IMM32_hHeap; static HANDLE IMM32_hHeap;
static DWORD IMM32_dwTLSIndex; static DWORD IMM32_dwTLSIndex;
static CRITICAL_SECTION IMM32_csIMM; static CRITICAL_SECTION IMM32_csIMM;
...@@ -40,13 +39,6 @@ BOOL WINAPI IMM32_DllMain( ...@@ -40,13 +39,6 @@ BOOL WINAPI IMM32_DllMain(
switch ( fdwReason ) switch ( fdwReason )
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if ( IMM32_dwProcessAttached > 0 )
{
ERR( "cannot attach to two or more processes.\n" );
return FALSE;
}
IMM32_dwProcessAttached ++;
IMM32_InitProcessMem(); IMM32_InitProcessMem();
IMM32_RegisterIMEWndClass( hInstDLL ); IMM32_RegisterIMEWndClass( hInstDLL );
break; break;
...@@ -54,8 +46,6 @@ BOOL WINAPI IMM32_DllMain( ...@@ -54,8 +46,6 @@ BOOL WINAPI IMM32_DllMain(
IMM32_UnloadAllIMEs(); IMM32_UnloadAllIMEs();
IMM32_UnregisterIMEWndClass( hInstDLL ); IMM32_UnregisterIMEWndClass( hInstDLL );
IMM32_CleanupProcessMem(); IMM32_CleanupProcessMem();
IMM32_dwProcessAttached --;
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
IMM32_InitThreadData(); IMM32_InitThreadData();
......
...@@ -19,7 +19,6 @@ DEFAULT_DEBUG_CHANNEL(msacm); ...@@ -19,7 +19,6 @@ DEFAULT_DEBUG_CHANNEL(msacm);
/**********************************************************************/ /**********************************************************************/
static DWORD MSACM_dwProcessesAttached = 0;
HINSTANCE MSACM_hInstance32 = 0; HINSTANCE MSACM_hInstance32 = 0;
/*********************************************************************** /***********************************************************************
...@@ -31,21 +30,15 @@ BOOL WINAPI MSACM32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReser ...@@ -31,21 +30,15 @@ BOOL WINAPI MSACM32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReser
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (MSACM_dwProcessesAttached == 0) { MSACM_hHeap = HeapCreate(0, 0x10000, 0);
MSACM_hHeap = HeapCreate(0, 0x10000, 0); MSACM_hInstance32 = hInstDLL;
MSACM_hInstance32 = hInstDLL; MSACM_RegisterAllDrivers();
MSACM_RegisterAllDrivers();
}
MSACM_dwProcessesAttached++;
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
MSACM_dwProcessesAttached--; MSACM_UnregisterAllDrivers();
if (MSACM_dwProcessesAttached == 0) { HeapDestroy(MSACM_hHeap);
MSACM_UnregisterAllDrivers(); MSACM_hHeap = (HANDLE) NULL;
HeapDestroy(MSACM_hHeap); MSACM_hInstance32 = (HINSTANCE)NULL;
MSACM_hHeap = (HANDLE) NULL;
MSACM_hInstance32 = (HINSTANCE)NULL;
}
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
break; break;
......
...@@ -1960,19 +1960,7 @@ BOOL WINAPI COMPOBJ_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD ...@@ -1960,19 +1960,7 @@ BOOL WINAPI COMPOBJ_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD
switch(Reason) switch(Reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
COMPOBJ_Attach++; if (!COMPOBJ_Attach++) COMPOBJ_hInstance = hInst;
if(COMPOBJ_hInstance)
{
ERR("compobj.dll instantiated twice!\n");
/*
* We should return FALSE here, but that will break
* most apps that use CreateProcess because we do
* not yet support seperate address-spaces.
*/
return TRUE;
}
COMPOBJ_hInstance = hInst;
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
DEFAULT_DEBUG_CHANNEL(ole); DEFAULT_DEBUG_CHANNEL(ole);
HINSTANCE OLE32_hInstance = 0; HINSTANCE OLE32_hInstance = 0;
static INT OLE32_RefCount = 0;
/*********************************************************************** /***********************************************************************
* DllEntryPoint (OLE32.@) * DllEntryPoint (OLE32.@)
...@@ -22,15 +21,11 @@ BOOL WINAPI OLE32_DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImp ...@@ -22,15 +21,11 @@ BOOL WINAPI OLE32_DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImp
switch(fdwReason) { switch(fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if(OLE32_hInstance == 0) OLE32_hInstance = hinstDLL;
OLE32_hInstance = hinstDLL;
OLE32_RefCount++;
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
OLE32_RefCount--; OLE32_hInstance = 0;
if(OLE32_RefCount == 0)
OLE32_hInstance = 0;
break; break;
} }
return TRUE; return TRUE;
......
...@@ -490,16 +490,13 @@ static void process_detach(void) { ...@@ -490,16 +490,13 @@ static void process_detach(void) {
*/ */
BOOL WINAPI OpenGL32_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) BOOL WINAPI OpenGL32_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{ {
static int process_count;
switch(reason) { switch(reason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!process_count++) process_attach(); process_attach();
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (!--process_count) process_detach(); process_detach();
break; break;
} }
return TRUE; return TRUE;
} }
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "richedit.h" #include "richedit.h"
extern HMODULE RICHED32_hModule;
extern VOID RICHED32_Register (VOID); extern VOID RICHED32_Register (VOID);
extern VOID RICHED32_Unregister (VOID); extern VOID RICHED32_Unregister (VOID);
......
...@@ -27,9 +27,7 @@ ...@@ -27,9 +27,7 @@
DEFAULT_DEBUG_CHANNEL(richedit); DEFAULT_DEBUG_CHANNEL(richedit);
HANDLE RICHED32_hHeap = (HANDLE)NULL; HANDLE RICHED32_hHeap = (HANDLE)NULL;
DWORD RICHED32_dwProcessesAttached = 0;
/* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */ /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
HMODULE RICHED32_hModule = 0;
/*********************************************************************** /***********************************************************************
* RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'. * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
...@@ -47,39 +45,22 @@ HMODULE RICHED32_hModule = 0; ...@@ -47,39 +45,22 @@ HMODULE RICHED32_hModule = 0;
BOOL WINAPI BOOL WINAPI
RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
switch (fdwReason)
switch (fdwReason) { {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
/* create private heap */
if (RICHED32_dwProcessesAttached == 0) { RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
/* register the Rich Edit class */
/* This will be wrong for any other process attching in this address-space! */ RICHED32_Register ();
RICHED32_hModule = (HMODULE)hinstDLL; break;
/* create private heap */ case DLL_PROCESS_DETACH:
RICHED32_hHeap = HeapCreate (0, 0x10000, 0); /* unregister all common control classes */
RICHED32_Unregister ();
} HeapDestroy (RICHED32_hHeap);
RICHED32_hHeap = (HANDLE)NULL;
/* register the Rich Edit class */ break;
RICHED32_Register ();
RICHED32_dwProcessesAttached++;
break;
case DLL_PROCESS_DETACH:
RICHED32_dwProcessesAttached--;
/* unregister all common control classes */
RICHED32_Unregister ();
if (RICHED32_dwProcessesAttached == 0) {
HeapDestroy (RICHED32_hHeap);
RICHED32_hHeap = (HANDLE)NULL;
}
break;
} }
return TRUE; return TRUE;
} }
......
...@@ -52,18 +52,14 @@ DEFAULT_DEBUG_CHANNEL(ole); ...@@ -52,18 +52,14 @@ DEFAULT_DEBUG_CHANNEL(ole);
* Failure: FALSE * Failure: FALSE
*/ */
static DWORD RPCRT4_dwProcessesAttached = 0;
BOOL WINAPI BOOL WINAPI
RPCRT4_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) RPCRT4_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
RPCRT4_dwProcessesAttached++;
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
RPCRT4_dwProcessesAttached--;
break; break;
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
DEFAULT_DEBUG_CHANNEL(comm); DEFAULT_DEBUG_CHANNEL(comm);
HMODULE SERIALUI_hModule = 0; HMODULE SERIALUI_hModule = 0;
DWORD SERIALUI_dwProcessesAttached = 0;
/*********************************************************************** /***********************************************************************
* SERIALUI_LibMain [Internal] Initializes the internal 'SERIALUI.DLL'. * SERIALUI_LibMain [Internal] Initializes the internal 'SERIALUI.DLL'.
...@@ -50,20 +49,9 @@ SERIALUI_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -50,20 +49,9 @@ SERIALUI_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (SERIALUI_dwProcessesAttached == 0) { SERIALUI_hModule = hinstDLL;
/* This will be wrong for any other process attching in this address-space! */
SERIALUI_hModule = (HMODULE)hinstDLL;
}
SERIALUI_dwProcessesAttached++;
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
SERIALUI_dwProcessesAttached--;
if (SERIALUI_dwProcessesAttached == 0) {
TRACE("Last Process detached\n");
}
break; break;
} }
......
...@@ -61,18 +61,7 @@ BOOL WINAPI SHELL_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, ...@@ -61,18 +61,7 @@ BOOL WINAPI SHELL_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst,
switch(Reason) switch(Reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
SHELL_Attach++; if (SHELL_Attach++) break;
if (SHELL_hInstance)
{
ERR("shell.dll instantiated twice!\n");
/*
* We should return FALSE here, but that will break
* most apps that use CreateProcess because we do
* not yet support seperate address-spaces.
*/
return TRUE;
}
SHELL_hInstance = hInst; SHELL_hInstance = hInst;
if(!SHELL_hInstance32) if(!SHELL_hInstance32)
{ {
......
...@@ -67,16 +67,14 @@ static void process_detach(void) ...@@ -67,16 +67,14 @@ static void process_detach(void)
*/ */
BOOL WINAPI TTYDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) BOOL WINAPI TTYDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{ {
static int process_count;
switch(reason) switch(reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!process_count++) process_attach(); process_attach();
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (!--process_count) process_detach(); process_detach();
break; break;
} }
return TRUE; return TRUE;
......
...@@ -33,7 +33,7 @@ DEFAULT_DEBUG_CHANNEL(aspi); ...@@ -33,7 +33,7 @@ DEFAULT_DEBUG_CHANNEL(aspi);
#ifdef linux #ifdef linux
static ASPI_DEVICE_INFO *ASPI_open_devices = NULL; static ASPI_DEVICE_INFO *ASPI_open_devices = NULL;
static CRITICAL_SECTION ASPI_CritSection; static CRITICAL_SECTION ASPI_CritSection = CRITICAL_SECTION_INIT;
#endif /* defined(linux) */ #endif /* defined(linux) */
...@@ -41,33 +41,20 @@ static CRITICAL_SECTION ASPI_CritSection; ...@@ -41,33 +41,20 @@ static CRITICAL_SECTION ASPI_CritSection;
BOOL WINAPI WNASPI32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) BOOL WINAPI WNASPI32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
{ {
#ifdef linux #ifdef linux
static BOOL bInitDone=FALSE;
#if 0
TRACE("0x%x 0x%1x %p\n", hInstDLL, fdwReason, fImpLoad);
#endif
switch( fdwReason ) switch( fdwReason )
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
/* Create instance data */ SCSI_Init();
if(!bInitDone) break;
{
bInitDone=TRUE;
/* Initialize global stuff just once */
InitializeCriticalSection(&ASPI_CritSection);
SCSI_Init();
}
break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
/* Destroy instance data */ DeleteCriticalSection( &ASPI_CritSection );
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
break; break;
} }
return TRUE;
#else /* defined(linux) */
return TRUE;
#endif /* defined(linux) */ #endif /* defined(linux) */
return TRUE;
} }
......
...@@ -231,13 +231,10 @@ static LOGFONTA DefaultLogFont = { ...@@ -231,13 +231,10 @@ static LOGFONTA DefaultLogFont = {
*/ */
BOOL WINAPI PSDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) BOOL WINAPI PSDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{ {
static int process_count = 0;
TRACE("(0x%4x, 0x%08lx, %p)\n", hinst, reason, reserved); TRACE("(0x%4x, 0x%08lx, %p)\n", hinst, reason, reserved);
switch(reason) { switch(reason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!process_count++) {
/* FIXME: return FALSE if we fail any of these steps */ /* FIXME: return FALSE if we fail any of these steps */
PSDRV_Heap = HeapCreate(0, 0x10000, 0); PSDRV_Heap = HeapCreate(0, 0x10000, 0);
PSDRV_GetFontMetrics(); PSDRV_GetFontMetrics();
...@@ -247,17 +244,14 @@ BOOL WINAPI PSDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) ...@@ -247,17 +244,14 @@ BOOL WINAPI PSDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
DRIVER_RegisterDriver( "WINEPS", &PSDRV_Funcs ); DRIVER_RegisterDriver( "WINEPS", &PSDRV_Funcs );
DRIVER_RegisterDriver( "WINEPS.DLL", &PSDRV_Funcs ); DRIVER_RegisterDriver( "WINEPS.DLL", &PSDRV_Funcs );
DRIVER_RegisterDriver( "WINEPS.DRV", &PSDRV_Funcs ); DRIVER_RegisterDriver( "WINEPS.DRV", &PSDRV_Funcs );
} break;
break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (!--process_count) {
DeleteObject( PSDRV_DefaultFont ); DeleteObject( PSDRV_DefaultFont );
HeapDestroy( PSDRV_Heap ); HeapDestroy( PSDRV_Heap );
DRIVER_UnregisterDriver( "WINEPS" ); DRIVER_UnregisterDriver( "WINEPS" );
DRIVER_UnregisterDriver( "WINEPS.DLL" ); DRIVER_UnregisterDriver( "WINEPS.DLL" );
DRIVER_UnregisterDriver( "WINEPS.DRV" ); DRIVER_UnregisterDriver( "WINEPS.DRV" );
} break;
break;
} }
return TRUE; return TRUE;
......
...@@ -110,20 +110,15 @@ static void MULTIMEDIA_DeleteIData(void) ...@@ -110,20 +110,15 @@ static void MULTIMEDIA_DeleteIData(void)
*/ */
BOOL WINAPI WINMM_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) BOOL WINAPI WINMM_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
{ {
static BOOL bInitDone = FALSE;
TRACE("0x%x 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad); TRACE("0x%x 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad);
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!MULTIMEDIA_CreateIData(hInstDLL)) if (!MULTIMEDIA_CreateIData(hInstDLL))
return FALSE; return FALSE;
if (!bInitDone) { /* to be done only once */ if (!MULTIMEDIA_MciInit() || !MMDRV_Init()) {
if (!MULTIMEDIA_MciInit() || !MMDRV_Init()) { MULTIMEDIA_DeleteIData();
MULTIMEDIA_DeleteIData(); return FALSE;
return FALSE;
}
bInitDone = TRUE;
} }
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
......
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