From bc878ef4d93253f5e8da14f46931ce51f1f2c32b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 12 Sep 2001 17:09:24 +0000 Subject: [PATCH] Convert user handles received from client to full handles. --- server/queue.c | 18 ++++++++++-------- server/user.c | 13 ++++++++++++- server/user.h | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/server/queue.c b/server/queue.c index e5753254e31..2cab8148307 100644 --- a/server/queue.c +++ b/server/queue.c @@ -723,7 +723,7 @@ DECL_HANDLER(send_message) if ((msg = mem_alloc( sizeof(*msg) ))) { msg->type = req->type; - msg->win = req->win; + msg->win = get_user_full_handle( req->win ); msg->msg = req->msg; msg->wparam = req->wparam; msg->lparam = req->lparam; @@ -848,6 +848,7 @@ DECL_HANDLER(get_message) struct timer *timer; struct message *msg; struct msg_queue *queue = get_current_queue(); + user_handle_t get_win = get_user_full_handle( req->get_win ); if (!queue) { @@ -874,7 +875,7 @@ DECL_HANDLER(get_message) queue->changed_bits = 0; /* then check for posted messages */ - if ((msg = find_matching_message( &queue->msg_list[POST_MESSAGE], req->get_win, + if ((msg = find_matching_message( &queue->msg_list[POST_MESSAGE], get_win, req->get_first, req->get_last ))) { return_message_to_app( queue, req, msg, POST_MESSAGE ); @@ -882,7 +883,7 @@ DECL_HANDLER(get_message) } /* then check for cooked hardware messages */ - if ((msg = find_matching_message( &queue->msg_list[COOKED_HW_MESSAGE], req->get_win, + if ((msg = find_matching_message( &queue->msg_list[COOKED_HW_MESSAGE], get_win, req->get_first, req->get_last ))) { return_message_to_app( queue, req, msg, COOKED_HW_MESSAGE ); @@ -913,7 +914,7 @@ DECL_HANDLER(get_message) } /* now check for timer */ - if ((timer = find_expired_timer( queue, req->get_win, req->get_first, + if ((timer = find_expired_timer( queue, get_win, req->get_first, req->get_last, (req->flags & GET_MSG_REMOVE) ))) { req->type = MSG_POSTED; @@ -987,7 +988,7 @@ DECL_HANDLER(get_message_reply) /* cleanup a queue when a window is deleted */ DECL_HANDLER(cleanup_window_queue) { - queue_cleanup_window( current, req->win ); + queue_cleanup_window( current, get_user_full_handle(req->win) ); } @@ -996,15 +997,16 @@ DECL_HANDLER(set_win_timer) { struct timer *timer; struct msg_queue *queue = get_current_queue(); + user_handle_t win = get_user_full_handle( req->win ); if (!queue) return; /* remove it if it existed already */ - if (req->win) kill_timer( queue, req->win, req->msg, req->id ); + if (win) kill_timer( queue, win, req->msg, req->id ); if ((timer = set_timer( queue, req->rate ))) { - timer->win = req->win; + timer->win = win; timer->msg = req->msg; timer->id = req->id; timer->lparam = req->lparam; @@ -1016,6 +1018,6 @@ DECL_HANDLER(kill_win_timer) { struct msg_queue *queue = current->queue; - if (!queue || !kill_timer( queue, req->win, req->msg, req->id )) + if (!queue || !kill_timer( queue, get_user_full_handle(req->win), req->msg, req->id )) set_error( STATUS_INVALID_PARAMETER ); } diff --git a/server/user.c b/server/user.c index ec0584c4191..88c7fd71d58 100644 --- a/server/user.c +++ b/server/user.c @@ -20,7 +20,8 @@ static int nb_handles; static int allocated_handles; #define FIRST_HANDLE 32 /* handle value for first table entry */ -#define MAX_HANDLES (65536-FIRST_HANDLE) +#define LAST_HANDLE (65536 - 16) +#define MAX_HANDLES (LAST_HANDLE - FIRST_HANDLE) static struct user_handle *handle_to_entry( user_handle_t handle ) { @@ -98,6 +99,16 @@ void *get_user_object( user_handle_t handle, enum user_object type ) return entry->ptr; } +/* get the full handle for a possibly truncated handle */ +user_handle_t get_user_full_handle( user_handle_t handle ) +{ + struct user_handle *entry; + + if (handle >> 16) return handle; + if (!(entry = handle_to_entry( handle ))) return handle; + return entry_to_handle( entry ); +} + /* same as get_user_object plus set the handle to the full 32-bit value */ void *get_user_object_handle( user_handle_t *handle, enum user_object type ) { diff --git a/server/user.h b/server/user.h index 810d60c1398..1e331686a62 100644 --- a/server/user.h +++ b/server/user.h @@ -22,6 +22,7 @@ enum user_object extern user_handle_t alloc_user_handle( void *ptr, enum user_object type ); extern void *get_user_object( user_handle_t handle, enum user_object type ); extern void *get_user_object_handle( user_handle_t *handle, enum user_object type ); +extern user_handle_t get_user_full_handle( user_handle_t handle ); extern void *free_user_handle( user_handle_t handle ); extern void *next_user_handle( user_handle_t *handle, enum user_object type );