[ATL30] Fix m_szAutoName definition and construction in Wine's ATL30 dll.
[reactos.git] / dll / win32 / atl / atl30.c
index 536f2b0..254dbad 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include <precomp.h>
-
 #include <stdio.h>
-#include <rpcproxy.h>
+
+#define COBJMACROS
+
+#include "objidl.h"
+#include "rpcproxy.h"
+#include "wine/atlbase.h"
+#include "wine/atlwin.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(atl);
 
 extern HINSTANCE atl_instance;
 
@@ -305,7 +313,11 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA
 
         if (!wci->m_wc.lpszClassName)
         {
-            snprintf(wci->m_szAutoName, sizeof(wci->m_szAutoName), "ATL%08lx", (UINT_PTR)wci);
+#ifdef __REACTOS__
+            sprintf(wci->m_szAutoName, "ATL:%p", wci);
+#else
+            sprintf(wci->m_szAutoName, "ATL%08lx", (UINT_PTR)wci);
+#endif
             TRACE("auto-generated class name %s\n", wci->m_szAutoName);
             wci->m_wc.lpszClassName = wci->m_szAutoName;
         }
@@ -364,8 +376,12 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW
 
         if (!wci->m_wc.lpszClassName)
         {
+#ifdef __REACTOS__
+            static const WCHAR szFormat[] = {'A','T','L',':','%','p',0};
+#else
             static const WCHAR szFormat[] = {'A','T','L','%','0','8','l','x',0};
-            snprintfW(wci->m_szAutoName, sizeof(wci->m_szAutoName)/sizeof(WCHAR), szFormat, (UINT_PTR)wci);
+#endif
+            swprintf(wci->m_szAutoName, szFormat, (UINT_PTR)wci);
             TRACE("auto-generated class name %s\n", debugstr_w(wci->m_szAutoName));
             wci->m_wc.lpszClassName = wci->m_szAutoName;
         }
@@ -508,6 +524,7 @@ static const IClassFactoryVtbl IRegistrarCFVtbl = {
 
 static IClassFactory RegistrarCF = { &IRegistrarCFVtbl };
 
+#ifdef __REACTOS__
 static HRESULT do_register_dll_server(IRegistrar *pRegistrar, LPCOLESTR wszDll,
                                       LPCOLESTR wszId, BOOL do_register,
                                       const struct _ATL_REGMAP_ENTRY* pMapEntries)
@@ -554,7 +571,7 @@ static HRESULT do_register_server(BOOL do_register)
     StringFromGUID2(&CLSID_Registrar, clsid_str, sizeof(clsid_str)/sizeof(WCHAR));
     return do_register_dll_server(NULL, atl_dllW, MAKEINTRESOURCEW(101), do_register, reg_map);
 }
-
+#endif
 
 /**************************************************************
  * DllGetClassObject (ATL.2)
@@ -575,8 +592,12 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, LPVOID *ppvObject)
  */
 HRESULT WINAPI DllRegisterServer(void)
 {
+#ifdef __REACTOS__
     /* Note: we can't use __wine_register_server here because it uses CLSID_Registrar which isn't registred yet */
     return do_register_server(TRUE);
+#else
+    return __wine_register_resources( atl_instance );
+#endif
 }
 
 /***********************************************************************
@@ -584,7 +605,11 @@ HRESULT WINAPI DllRegisterServer(void)
  */
 HRESULT WINAPI DllUnregisterServer(void)
 {
+#ifdef __REACTOS__
     return do_register_server(FALSE);
+#else
+    return __wine_unregister_resources( atl_instance );
+#endif
 }
 
 /***********************************************************************