From: Patrick Hibbs hibbsncc1701@yahoo.com
Ensure the heap doesn't run out of space, and return the proper status codes.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47433 Signed-off-by: Patrick Hibbs hibbsncc1701@yahoo.com --- v2: Fix status code based on tests, make mismatched message a trace. --- dlls/wtsapi32/wtsapi32.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c index dccd5ec1a1..8bc7348fca 100644 --- a/dlls/wtsapi32/wtsapi32.c +++ b/dlls/wtsapi32/wtsapi32.c @@ -451,12 +451,35 @@ BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd) }
/************************************************************ - * WTSUnRegisterSessionNotification (WTSAPI32.@) + * WTSUnRegisterSessionNotificationEx (WTSAPI32.@) */ BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd) { - FIXME("Stub %p %p\n", hServer, hWnd); - return FALSE; + BOOL found = FALSE; + WTSAPI32InternalRegMNGTStr *mgntStr, *cursor2; + FIXME("Simi-Stub %p %p\n", hServer, hWnd); + + /* Only deregister a window if it was registered previously. + */ + LIST_FOR_EACH_ENTRY_SAFE(mgntStr, cursor2, &RegisteredWindowsToNotifiy, + WTSAPI32InternalRegMNGTStr, entry) + { + if ((mgntStr != NULL) && (mgntStr->hServer == hServer) && (mgntStr->hWnd == hWnd)) + { + found = TRUE; + list_remove(&mgntStr->entry); + HeapFree(GetProcessHeap(), 0, mgntStr); + } + } + + /* Log mismatched UnRegister calls. + */ + if (!found) + { + TRACE("Mismatched WTSUnRegisterSessionNotification\n"); + } + + return TRUE; }