[PATCH v2 resend 2/6] wtsapi32: Make WTSRegisterSessionNotificationEx() keep track of registered windows.

Patrick Hibbs hibbsncc1701 at gmail.com
Sat Jul 13 20:13:21 CDT 2019


From: Patrick Hibbs <hibbsncc1701 at yahoo.com>

Callers expect valid status codes even from stubs.
Keeping track of window registrations is required to do that.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47433
Signed-off-by: Patrick Hibbs <hibbsncc1701 at yahoo.com>
---
v2: Fix return status based on tests.
---
 dlls/wtsapi32/wtsapi32.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c
index 3d944943b4..8ece1d2b37 100644
--- a/dlls/wtsapi32/wtsapi32.c
+++ b/dlls/wtsapi32/wtsapi32.c
@@ -316,8 +316,44 @@ BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
  */
 BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags)
 {
-    FIXME("Stub %p %p 0x%08x\n", hServer, hWnd, dwFlags);
-    return FALSE;
+    BOOL ret = TRUE;
+    BOOL found = FALSE;
+    WTSAPI32InternalRegMNGTStr *mgntStr;
+
+    FIXME("Simi-Stub %p %p 0x%08x\n", hServer, hWnd, dwFlags);
+
+    /* Keep track of the registration attempts.
+     */
+    LIST_FOR_EACH_ENTRY(mgntStr, &RegisteredWindowsToNotifiy, WTSAPI32InternalRegMNGTStr, entry)
+    {
+        /* MSDN says that if the window is already registered,
+         * the dwFlags value is ignored.
+         */
+        if ((mgntStr != NULL) && (mgntStr->hServer == hServer) && (mgntStr->hWnd == hWnd))
+        {
+            found = TRUE;
+        }
+    }
+
+    /* Only create the registration if needed. */
+    if (!found)
+    {
+        mgntStr = NULL;
+        mgntStr = HeapAlloc(GetProcessHeap(),0, sizeof(WTSAPI32InternalRegMNGTStr));
+        if (mgntStr != NULL)
+        {
+            mgntStr->hServer = hServer;
+            mgntStr->hWnd = hWnd;
+            mgntStr->dwFlags = dwFlags;
+            list_add_head( &RegisteredWindowsToNotifiy, &mgntStr->entry );
+        }
+        else
+        {
+            ret = FALSE;
+        }
+    }
+
+    return ret;
 }
 
 
-- 
2.22.0




More information about the wine-devel mailing list