[SHLWAPI] Improvements for SHCreateWorkerWindowW/A() prototypes + fix x64-bit compati...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 12 Feb 2018 23:10:09 +0000 (00:10 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 12 Feb 2018 23:13:47 +0000 (00:13 +0100)
[SHLWAPI] Refactor the SHCreateWorkerWindowW() prototype to match its ANSI SHCreateWorkerWindowA() counterpart.

The last parameter is really to be understood as an extra window data, and not a "message result" (as it would be the case for dialog window procedure).
That is why I also remove the mention of "DWLP_MSGRESULT" in the SetWindowLongPtrW() call.
SHCreateWorkerWindowA() had it OK but SHCreateWorkerWindowW() did not.

------------------

[SHLWAPI] Make SHCreateWorkerWindowA() and SHCreateWorkerWindowW() x64-compatible.

The first parameter of these functions is a pointer to a window procedure, having a definite prototype, so employ a correct typedef WNDPROC,
which ensures both correct pointer size and parameter type enforcement.
This also ensures that we use instead a correct pointer size, since otherwise LONG remains 32-bits for Windows compatibility on x64 platforms.
The wndProc parameter is thus casted to LONG_PTR to comply with the SetWindowLongPtrA/W calls.

In SHCreateWorkerWindowW(), the last "wnd_extra" parameter should also be LONG_PTR to be able to pass 64-bit data pointer on x64 platforms.
Therefore fix also setting the wc.cbWndExtra size. One should note that the ANSI SHCreateWorkerWindowA() function had everything OK already.

dll/win32/shlwapi/ordinal.c
dll/win32/shlwapi/shlwapi.spec
sdk/include/reactos/shlwapi_undoc.h

index b2543d4..d81adbb 100644 (file)
@@ -2555,8 +2555,13 @@ HRESULT WINAPI IUnknown_GetSite(LPUNKNOWN lpUnknown, REFIID iid, PVOID *lppSite)
  *  Success: The window handle of the newly created window.
  *  Failure: 0.
  */
  *  Success: The window handle of the newly created window.
  *  Failure: 0.
  */
+#ifndef __REACTOS__
 HWND WINAPI SHCreateWorkerWindowA(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
                                   DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra)
 HWND WINAPI SHCreateWorkerWindowA(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
                                   DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra)
+#else
+HWND WINAPI SHCreateWorkerWindowA(WNDPROC wndProc, HWND hWndParent, DWORD dwExStyle,
+                                  DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra)
+#endif
 {
   static const char szClass[] = "WorkerA";
   WNDCLASSA wc;
 {
   static const char szClass[] = "WorkerA";
   WNDCLASSA wc;
@@ -2584,8 +2589,12 @@ HWND WINAPI SHCreateWorkerWindowA(LONG wndProc, HWND hWndParent, DWORD dwExStyle
   if (hWnd)
   {
     SetWindowLongPtrW(hWnd, 0, wnd_extra);
   if (hWnd)
   {
     SetWindowLongPtrW(hWnd, 0, wnd_extra);
+#ifndef __REACTOS__
 
     if (wndProc) SetWindowLongPtrA(hWnd, GWLP_WNDPROC, wndProc);
 
     if (wndProc) SetWindowLongPtrA(hWnd, GWLP_WNDPROC, wndProc);
+#else
+    if (wndProc) SetWindowLongPtrA(hWnd, GWLP_WNDPROC, (LONG_PTR)wndProc);
+#endif
   }
 
   return hWnd;
   }
 
   return hWnd;
@@ -2844,28 +2853,45 @@ DWORD WINAPI WhichPlatform(void)
  *
  * Unicode version of SHCreateWorkerWindowA.
  */
  *
  * Unicode version of SHCreateWorkerWindowA.
  */
+#ifndef __REACTOS__
 HWND WINAPI SHCreateWorkerWindowW(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
                         DWORD dwStyle, HMENU hMenu, LONG msg_result)
 HWND WINAPI SHCreateWorkerWindowW(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
                         DWORD dwStyle, HMENU hMenu, LONG msg_result)
+#else
+HWND WINAPI SHCreateWorkerWindowW(WNDPROC wndProc, HWND hWndParent, DWORD dwExStyle,
+                                  DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra)
+#endif
 {
   static const WCHAR szClass[] = { 'W', 'o', 'r', 'k', 'e', 'r', 'W', 0 };
   WNDCLASSW wc;
   HWND hWnd;
 
   TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x)\n",
 {
   static const WCHAR szClass[] = { 'W', 'o', 'r', 'k', 'e', 'r', 'W', 0 };
   WNDCLASSW wc;
   HWND hWnd;
 
   TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x)\n",
+#ifndef __REACTOS__
          wndProc, hWndParent, dwExStyle, dwStyle, hMenu, msg_result);
          wndProc, hWndParent, dwExStyle, dwStyle, hMenu, msg_result);
+#else
+         wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
+#endif
 
   /* If our OS is natively ANSI, use the ANSI version */
   if (GetVersion() & 0x80000000)  /* not NT */
   {
     TRACE("fallback to ANSI, ver 0x%08x\n", GetVersion());
 
   /* If our OS is natively ANSI, use the ANSI version */
   if (GetVersion() & 0x80000000)  /* not NT */
   {
     TRACE("fallback to ANSI, ver 0x%08x\n", GetVersion());
+#ifndef __REACTOS__
     return SHCreateWorkerWindowA(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, msg_result);
     return SHCreateWorkerWindowA(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, msg_result);
+#else
+    return SHCreateWorkerWindowA(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
+#endif
   }
 
   /* Create Window class */
   wc.style         = 0;
   wc.lpfnWndProc   = DefWindowProcW;
   wc.cbClsExtra    = 0;
   }
 
   /* Create Window class */
   wc.style         = 0;
   wc.lpfnWndProc   = DefWindowProcW;
   wc.cbClsExtra    = 0;
+#ifndef __REACTOS__
   wc.cbWndExtra    = 4;
   wc.cbWndExtra    = 4;
+#else
+  wc.cbWndExtra    = sizeof(LONG_PTR);
+#endif
   wc.hInstance     = shlwapi_hInstance;
   wc.hIcon         = NULL;
   wc.hCursor       = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
   wc.hInstance     = shlwapi_hInstance;
   wc.hIcon         = NULL;
   wc.hCursor       = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
@@ -2879,9 +2905,14 @@ HWND WINAPI SHCreateWorkerWindowW(LONG wndProc, HWND hWndParent, DWORD dwExStyle
                          hWndParent, hMenu, shlwapi_hInstance, 0);
   if (hWnd)
   {
                          hWndParent, hMenu, shlwapi_hInstance, 0);
   if (hWnd)
   {
+#ifndef __REACTOS__
     SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, msg_result);
 
     if (wndProc) SetWindowLongPtrW(hWnd, GWLP_WNDPROC, wndProc);
     SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, msg_result);
 
     if (wndProc) SetWindowLongPtrW(hWnd, GWLP_WNDPROC, wndProc);
+#else
+    SetWindowLongPtrW(hWnd, 0, wnd_extra);
+    if (wndProc) SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)wndProc);
+#endif
   }
 
   return hWnd;
   }
 
   return hWnd;
index e49c87e..b706017 100644 (file)
 254 stub -noname StopWatchExW
 255 stub -noname EventTraceHandler
 256 stdcall -noname IUnknown_GetSite(ptr ptr ptr)
 254 stub -noname StopWatchExW
 255 stub -noname EventTraceHandler
 256 stdcall -noname IUnknown_GetSite(ptr ptr ptr)
-257 stdcall -noname SHCreateWorkerWindowA(long ptr long long ptr long)
+257 stdcall -noname SHCreateWorkerWindowA(ptr ptr long long ptr long)
 258 stub -noname SHRegisterWaitForSingleObject
 259 stub -noname SHUnregisterWait
 260 stdcall -noname SHQueueUserWorkItem(long long long long long long long)
 258 stub -noname SHRegisterWaitForSingleObject
 259 stub -noname SHUnregisterWait
 260 stdcall -noname SHQueueUserWorkItem(long long long long long long long)
 275 stub -noname RegisterGlobalHotkeyA
 276 stdcall -noname WhichPlatform()
 277 stub -noname SHDialogBox
 275 stub -noname RegisterGlobalHotkeyA
 276 stdcall -noname WhichPlatform()
 277 stub -noname SHDialogBox
-278 stdcall -noname SHCreateWorkerWindowW(long long long long long long)
+278 stdcall -noname SHCreateWorkerWindowW(ptr ptr long long ptr long)
 279 stdcall -noname SHInvokeDefaultCommand(ptr ptr ptr)
 280 stdcall -noname SHRegGetIntW(ptr wstr long)
 281 stdcall -noname SHPackDispParamsV(ptr ptr long ptr)
 279 stdcall -noname SHInvokeDefaultCommand(ptr ptr ptr)
 280 stdcall -noname SHRegGetIntW(ptr wstr long)
 281 stdcall -noname SHPackDispParamsV(ptr ptr long ptr)
index 3fb4b21..27000e3 100644 (file)
@@ -92,11 +92,11 @@ HRESULT WINAPI SHGetPerScreenResName(OUT LPWSTR lpResName,
 
 HRESULT WINAPI SHPropertyBag_ReadStream(IPropertyBag*,LPCWSTR,IStream**);
 
 
 HRESULT WINAPI SHPropertyBag_ReadStream(IPropertyBag*,LPCWSTR,IStream**);
 
-HWND WINAPI SHCreateWorkerWindowA(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
-                        DWORD dwStyle, HMENU hMenu, LONG z);
+HWND WINAPI SHCreateWorkerWindowA(WNDPROC wndProc, HWND hWndParent, DWORD dwExStyle,
+                                  DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra);
 
 
-HWND WINAPI SHCreateWorkerWindowW(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
-                        DWORD dwStyle, HMENU hMenu, LONG z);
+HWND WINAPI SHCreateWorkerWindowW(WNDPROC wndProc, HWND hWndParent, DWORD dwExStyle,
+                                  DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra);
 #ifdef UNICODE
 #define SHCreateWorkerWindow SHCreateWorkerWindowW
 #else
 #ifdef UNICODE
 #define SHCreateWorkerWindow SHCreateWorkerWindowW
 #else