From c39a5f0dbae4964f6a796fab467bed20ba4bbc85 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Tue, 21 Mar 2006 16:18:24 +0100
Subject: [PATCH] Added DLL_WINE_PREATTACH handling in a number of stub-only
 dlls.

---
 dlls/activeds/activeds_main.c | 10 ++++++++-
 dlls/cfgmgr32/main.c          | 16 +++++++++++++++
 dlls/cryptdll/cryptdll.c      |  2 ++
 dlls/d3dim/d3dim_main.c       | 38 ++++++++++++++++++++++++++++++++++-
 dlls/d3drm/d3drm_main.c       | 22 +++++++++++++++++---
 dlls/msnet32/msnet_main.c     | 21 +++++++++++++++++++
 dlls/snmpapi/main.c           |  2 ++
 dlls/url/url_main.c           | 38 ++++++++++++++++++++++++++++++++++-
 dlls/vdmdbg/vdmdbg.c          | 38 ++++++++++++++++++++++++++++++++++-
 dlls/winnls32/winnls.c        | 16 +++++++++++++++
 dlls/wintrust/wintrust_main.c | 17 ++++++++++++++++
 11 files changed, 213 insertions(+), 7 deletions(-)

diff --git a/dlls/activeds/activeds_main.c b/dlls/activeds/activeds_main.c
index d010a766dfa..b29674236ed 100644
--- a/dlls/activeds/activeds_main.c
+++ b/dlls/activeds/activeds_main.c
@@ -48,7 +48,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(activeds);
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
     TRACE("(%p, %ld, %p)\n",hinstDLL, fdwReason, lpvReserved);
-    /* For the moment, do nothing here. */
+
+    switch(fdwReason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( hinstDLL );
+        break;
+    }
     return TRUE;
 }
 
diff --git a/dlls/cfgmgr32/main.c b/dlls/cfgmgr32/main.c
index 10757d6fa2e..03129005ec4 100644
--- a/dlls/cfgmgr32/main.c
+++ b/dlls/cfgmgr32/main.c
@@ -29,6 +29,22 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(cfgmgr32);
 
+/***********************************************************************
+ *		DllMain  (CFGMGR32.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
+
 CONFIGRET WINAPI CM_Get_Device_ID_ListA( 
     PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags )
 {
diff --git a/dlls/cryptdll/cryptdll.c b/dlls/cryptdll/cryptdll.c
index fcb8589c753..9c9b6d7efdf 100644
--- a/dlls/cryptdll/cryptdll.c
+++ b/dlls/cryptdll/cryptdll.c
@@ -32,6 +32,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
 
     switch (fdwReason) {
+        case DLL_WINE_PREATTACH:
+            return FALSE;  /* prefer native version */
         case DLL_PROCESS_ATTACH:
         {
             DisableThreadLibraryCalls(hinstDLL);
diff --git a/dlls/d3dim/d3dim_main.c b/dlls/d3dim/d3dim_main.c
index 67a01ed518c..0c0f022619e 100644
--- a/dlls/d3dim/d3dim_main.c
+++ b/dlls/d3dim/d3dim_main.c
@@ -1 +1,37 @@
-/* nothing here yet */
+/*
+ * Copyright 2006 Alexandre Julliard
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+
+/***********************************************************************
+ *		DllMain  (D3DIM.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
diff --git a/dlls/d3drm/d3drm_main.c b/dlls/d3drm/d3drm_main.c
index ecb71916e1d..caa0f901b4f 100644
--- a/dlls/d3drm/d3drm_main.c
+++ b/dlls/d3drm/d3drm_main.c
@@ -16,6 +16,22 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "wine/debug.h"
- 
-WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+
+/***********************************************************************
+ *		DllMain  (D3DRM.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
diff --git a/dlls/msnet32/msnet_main.c b/dlls/msnet32/msnet_main.c
index 40e9dc4ee61..bc92f453b3b 100644
--- a/dlls/msnet32/msnet_main.c
+++ b/dlls/msnet32/msnet_main.c
@@ -16,10 +16,31 @@
 
 #include "config.h"
 
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msnet);
 
+
+/***********************************************************************
+ *		DllMain  (MSNET32.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
+
 /***********************************************************************
  *		@  (MSNET32.57)
  */
diff --git a/dlls/snmpapi/main.c b/dlls/snmpapi/main.c
index 326e6bc37bf..fda8f354aab 100644
--- a/dlls/snmpapi/main.c
+++ b/dlls/snmpapi/main.c
@@ -39,6 +39,8 @@ BOOL WINAPI DllMain(
     TRACE("(%p,%ld,%p)\n", hInstDLL, fdwReason, lpvReserved);
 
     switch(fdwReason) {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
     case DLL_PROCESS_ATTACH:
         DisableThreadLibraryCalls(hInstDLL);
         break;
diff --git a/dlls/url/url_main.c b/dlls/url/url_main.c
index 67a01ed518c..b85e204c12f 100644
--- a/dlls/url/url_main.c
+++ b/dlls/url/url_main.c
@@ -1 +1,37 @@
-/* nothing here yet */
+/*
+ * Copyright 2006 Alexandre Julliard
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+
+/***********************************************************************
+ *		DllMain  (URL.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
diff --git a/dlls/vdmdbg/vdmdbg.c b/dlls/vdmdbg/vdmdbg.c
index 67a01ed518c..3d272c0eb45 100644
--- a/dlls/vdmdbg/vdmdbg.c
+++ b/dlls/vdmdbg/vdmdbg.c
@@ -1 +1,37 @@
-/* nothing here yet */
+/*
+ * Copyright 2006 Alexandre Julliard
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+
+/***********************************************************************
+ *		DllMain  (VDMDBG.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
diff --git a/dlls/winnls32/winnls.c b/dlls/winnls32/winnls.c
index 4172fc2f915..892ec1c5ef2 100644
--- a/dlls/winnls32/winnls.c
+++ b/dlls/winnls32/winnls.c
@@ -22,6 +22,22 @@
 #include "winbase.h"
 #include "wine/winuser16.h"
 
+/***********************************************************************
+ *		DllMain  (WINNLS.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
+
 /***********************************************************************
  *		WINNLSEnableIME (WINNLS.16)
  */
diff --git a/dlls/wintrust/wintrust_main.c b/dlls/wintrust/wintrust_main.c
index 3d7ac5c2508..09ddfedfdfb 100644
--- a/dlls/wintrust/wintrust_main.c
+++ b/dlls/wintrust/wintrust_main.c
@@ -32,6 +32,23 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
 
+
+/***********************************************************************
+ *		DllMain  (WINTRUST.@)
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE;  /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls( inst );
+        break;
+    }
+    return TRUE;
+}
+
 /***********************************************************************
  *		CryptCATAdminAcquireContext (WINTRUST.@)
  */
-- 
GitLab