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