Hermes Belusca-Maito : atl: Fix the ATL_WNDCLASSINFOW::m_szAutoName member definition and construction.

Alexandre Julliard julliard at winehq.org
Mon Feb 10 16:32:44 CST 2020


Module: wine
Branch: master
Commit: 5608682dc9c0f30cca0bfb24705e9b82b6a7aecc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5608682dc9c0f30cca0bfb24705e9b82b6a7aecc

Author: Hermes Belusca-Maito <hermes.belusca at sfr.fr>
Date:   Wed Jan 15 02:09:33 2020 +0100

atl: Fix the ATL_WNDCLASSINFOW::m_szAutoName member definition and construction.

Signed-off-by: Hermes Belusca-Maito <hermes.belusca at sfr.fr>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/atl/atl30.c        |  9 ++++-----
 dlls/atl/tests/module.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/atlwin.h        |  4 ++--
 3 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/dlls/atl/atl30.c b/dlls/atl/atl30.c
index 29b29d4cbe..b015ea4b74 100644
--- a/dlls/atl/atl30.c
+++ b/dlls/atl/atl30.c
@@ -313,7 +313,7 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA
 
         if (!wci->m_wc.lpszClassName)
         {
-            sprintf(wci->m_szAutoName, "ATL%08x", PtrToUint(wci));
+            sprintf(wci->m_szAutoName, "ATL:%p", wci);
             TRACE("auto-generated class name %s\n", wci->m_szAutoName);
             wci->m_wc.lpszClassName = wci->m_szAutoName;
         }
@@ -350,8 +350,8 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA
  * NOTES
  *  Can be called multiple times without error, unlike RegisterClassEx().
  *
- *  If the class name is NULL, then a class with a name of "ATLxxxxxxxx" is
- *  registered, where the 'x's represent a unique value.
+ *  If the class name is NULL, then a class with a name of "ATL:xxxxxxxx" is
+ *  registered, where 'xxxxxxxx' represents a unique hexadecimal value.
  *
  */
 ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW *wci, WNDPROC *pProc)
@@ -372,8 +372,7 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW
 
         if (!wci->m_wc.lpszClassName)
         {
-            static const WCHAR szFormat[] = {'A','T','L','%','0','8','x',0};
-            swprintf(wci->m_szAutoName, ARRAY_SIZE(wci->m_szAutoName), szFormat, PtrToUint(wci));
+            swprintf(wci->m_szAutoName, ARRAY_SIZE(wci->m_szAutoName), L"ATL:%p", wci);
             TRACE("auto-generated class name %s\n", debugstr_w(wci->m_szAutoName));
             wci->m_wc.lpszClassName = wci->m_szAutoName;
         }
diff --git a/dlls/atl/tests/module.c b/dlls/atl/tests/module.c
index 6250f9b2cb..db8bd28742 100644
--- a/dlls/atl/tests/module.c
+++ b/dlls/atl/tests/module.c
@@ -25,6 +25,7 @@
 #define COBJMACROS
 
 #include <atlbase.h>
+#include <atlwin.h>
 
 #include <wine/test.h>
 
@@ -113,6 +114,55 @@ static void test_winmodule(void)
     ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
 }
 
+static void test_winclassinfo(void)
+{
+    _ATL_MODULEW winmod;
+    HRESULT hres;
+    int len, expectedLen;
+    ATOM atom;
+    WNDPROC wndProc;
+    _ATL_WNDCLASSINFOW wci =
+    {
+        /* .m_wc = */
+        {
+            sizeof(WNDCLASSEXW),
+            CS_VREDRAW | CS_HREDRAW,
+            DefWindowProcW,
+            0,
+            0,
+            NULL,
+            NULL,
+            LoadCursorW(NULL, (LPCWSTR)IDC_ARROW),
+            (HBRUSH)(COLOR_BTNFACE + 1),
+            NULL,
+            NULL,   /* LPCSTR lpszClassName; <-- We force ATL class name generation */
+            NULL
+        },
+        /* .m_lpszOrigName  = */ NULL,
+        /* .pWndProc        = */ NULL,
+        /* .m_lpszCursorID  = */ (LPCWSTR)IDC_ARROW,
+        /* .m_bSystemCursor = */ TRUE,
+        /* .m_atom          = */ 0,
+        /* .m_szAutoName    = */ L""
+    };
+
+    winmod.cbSize = sizeof(winmod);
+    winmod.m_pCreateWndList = (void*)0xdeadbeef;
+    hres = AtlModuleInit(&winmod, NULL, NULL);
+    ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
+    ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
+
+    atom = AtlModuleRegisterWndClassInfoW(&winmod, &wci, &wndProc);
+    ok(atom, "AtlModuleRegisterWndClassInfoA failed: %08x\n", atom);
+    ok(atom == wci.m_atom, "(atom = %08x) is != than (wci.m_atom = %08x)\n", atom, wci.m_atom);
+
+    ok(wcsncmp(wci.m_szAutoName, L"ATL:", 4) == 0, "wci.m_szAutoName = '%ls', expected starting with 'ATL:'\n", wci.m_szAutoName);
+
+    len = wcslen(wci.m_szAutoName);
+    expectedLen = sizeof("ATL:") + sizeof(void *) * 2 - 1;
+    ok(len == expectedLen, "wci.m_szAutoName has length %d, expected length %d\n", len, expectedLen);
+}
+
 static DWORD_PTR cb_val;
 
 static void WINAPI term_callback(DWORD_PTR dw)
@@ -159,5 +209,6 @@ START_TEST(module)
 {
     test_StructSize();
     test_winmodule();
+    test_winclassinfo();
     test_term();
 }
diff --git a/include/atlwin.h b/include/atlwin.h
index 386177ba61..de31f403ba 100644
--- a/include/atlwin.h
+++ b/include/atlwin.h
@@ -29,7 +29,7 @@ typedef struct _ATL_WNDCLASSINFOA_TAG
     LPCSTR m_lpszCursorID;
     BOOL m_bSystemCursor;
     ATOM m_atom;
-    CHAR m_szAutoName[14];
+    CHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2];
 } _ATL_WNDCLASSINFOA;
 
 typedef struct _ATL_WNDCLASSINFOW_TAG
@@ -40,7 +40,7 @@ typedef struct _ATL_WNDCLASSINFOW_TAG
     LPCWSTR m_lpszCursorID;
     BOOL m_bSystemCursor;
     ATOM m_atom;
-    WCHAR m_szAutoName[14];
+    WCHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2];
 } _ATL_WNDCLASSINFOW;
 
 ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA *wci, WNDPROC *pProc);




More information about the wine-cvs mailing list