server: Add a helper function to validate a window handle.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c6f12bd9cc
commit
70dd64cf97
|
@ -258,15 +258,11 @@ static int get_seqno( struct clipboard *clipboard )
|
||||||
DECL_HANDLER(open_clipboard)
|
DECL_HANDLER(open_clipboard)
|
||||||
{
|
{
|
||||||
struct clipboard *clipboard = get_process_clipboard();
|
struct clipboard *clipboard = get_process_clipboard();
|
||||||
user_handle_t win = req->window;
|
user_handle_t win = 0;
|
||||||
|
|
||||||
if (!clipboard) return;
|
if (!clipboard) return;
|
||||||
|
if (req->window && !(win = get_valid_window_handle( req->window ))) return;
|
||||||
|
|
||||||
if (win && !get_user_object_handle( &win, USER_WINDOW ))
|
|
||||||
{
|
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (clipboard->open_thread && clipboard->open_win != win)
|
if (clipboard->open_thread && clipboard->open_win != win)
|
||||||
{
|
{
|
||||||
set_error( STATUS_INVALID_LOCK_SEQUENCE );
|
set_error( STATUS_INVALID_LOCK_SEQUENCE );
|
||||||
|
@ -363,21 +359,11 @@ DECL_HANDLER(get_clipboard_info)
|
||||||
DECL_HANDLER(set_clipboard_viewer)
|
DECL_HANDLER(set_clipboard_viewer)
|
||||||
{
|
{
|
||||||
struct clipboard *clipboard = get_process_clipboard();
|
struct clipboard *clipboard = get_process_clipboard();
|
||||||
user_handle_t viewer = req->viewer;
|
user_handle_t viewer = 0, previous = 0;
|
||||||
user_handle_t previous = req->previous;
|
|
||||||
|
|
||||||
if (!clipboard) return;
|
if (!clipboard) return;
|
||||||
|
if (req->viewer && !(viewer = get_valid_window_handle( req->viewer ))) return;
|
||||||
if (viewer && !get_user_object_handle( &viewer, USER_WINDOW ))
|
if (req->previous && !(previous = get_valid_window_handle( req->previous ))) return;
|
||||||
{
|
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (previous && !get_user_object_handle( &previous, USER_WINDOW ))
|
|
||||||
{
|
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
reply->old_viewer = clipboard->viewer;
|
reply->old_viewer = clipboard->viewer;
|
||||||
reply->owner = clipboard->owner_win;
|
reply->owner = clipboard->owner_win;
|
||||||
|
@ -393,15 +379,10 @@ DECL_HANDLER(set_clipboard_viewer)
|
||||||
DECL_HANDLER(add_clipboard_listener)
|
DECL_HANDLER(add_clipboard_listener)
|
||||||
{
|
{
|
||||||
struct clipboard *clipboard = get_process_clipboard();
|
struct clipboard *clipboard = get_process_clipboard();
|
||||||
user_handle_t win = req->window;
|
user_handle_t win;
|
||||||
|
|
||||||
if (!clipboard) return;
|
if (!clipboard) return;
|
||||||
|
if (!(win = get_valid_window_handle( req->window ))) return;
|
||||||
if (!get_user_object_handle( &win, USER_WINDOW ))
|
|
||||||
{
|
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_listener( clipboard, win );
|
add_listener( clipboard, win );
|
||||||
}
|
}
|
||||||
|
@ -411,15 +392,10 @@ DECL_HANDLER(add_clipboard_listener)
|
||||||
DECL_HANDLER(remove_clipboard_listener)
|
DECL_HANDLER(remove_clipboard_listener)
|
||||||
{
|
{
|
||||||
struct clipboard *clipboard = get_process_clipboard();
|
struct clipboard *clipboard = get_process_clipboard();
|
||||||
user_handle_t win = req->window;
|
user_handle_t win;
|
||||||
|
|
||||||
if (!clipboard) return;
|
if (!clipboard) return;
|
||||||
|
if (!(win = get_valid_window_handle( req->window ))) return;
|
||||||
if (!get_user_object_handle( &win, USER_WINDOW ))
|
|
||||||
{
|
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!remove_listener( clipboard, win )) set_error( STATUS_INVALID_PARAMETER );
|
if (!remove_listener( clipboard, win )) set_error( STATUS_INVALID_PARAMETER );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2685,10 +2685,9 @@ DECL_HANDLER(register_hotkey)
|
||||||
|
|
||||||
if (win_handle)
|
if (win_handle)
|
||||||
{
|
{
|
||||||
if (!get_user_object_handle( &win_handle, USER_WINDOW ))
|
if (!(win_handle = get_valid_window_handle( win_handle )))
|
||||||
{
|
{
|
||||||
release_object( desktop );
|
release_object( desktop );
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2754,10 +2753,9 @@ DECL_HANDLER(unregister_hotkey)
|
||||||
|
|
||||||
if (win_handle)
|
if (win_handle)
|
||||||
{
|
{
|
||||||
if (!get_user_object_handle( &win_handle, USER_WINDOW ))
|
if (!(win_handle = get_valid_window_handle( win_handle )))
|
||||||
{
|
{
|
||||||
release_object( desktop );
|
release_object( desktop );
|
||||||
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,4 +207,12 @@ static inline int intersect_rect( rectangle_t *dst, const rectangle_t *src1, con
|
||||||
return (dst->left < dst->right && dst->top < dst->bottom);
|
return (dst->left < dst->right && dst->top < dst->bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* validate a window handle and return the full handle */
|
||||||
|
static inline user_handle_t get_valid_window_handle( user_handle_t win )
|
||||||
|
{
|
||||||
|
if (get_user_object_handle( &win, USER_WINDOW )) return win;
|
||||||
|
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __WINE_SERVER_USER_H */
|
#endif /* __WINE_SERVER_USER_H */
|
||||||
|
|
Loading…
Reference in New Issue