From: Patrick Hibbs Subject: [PATCH 2/6] wtsapi32: Make WTSRegisterSessionNotificationEx() keep track of registered windows. Message-Id: <20190713230002.20340-2-hibbsncc1701@yahoo.com> Date: Sat, 13 Jul 2019 18:59:58 -0400 In-Reply-To: <20190713230002.20340-1-hibbsncc1701@yahoo.com> References: <20190713230002.20340-1-hibbsncc1701@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 --- 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