[PATCH 4/5] user32: Implement GetRawInputBuffer.
Alexandre Julliard
julliard at winehq.org
Tue Jun 30 03:24:39 CDT 2020
Rémi Bernon <rbernon at codeweavers.com> writes:
> +DECL_HANDLER(get_rawinput_buffer)
> +{
> + struct thread_input *input = current->queue->input;
> + data_size_t size = 0, next_size = 0;
> + struct list *ptr;
> + char *buf, *cur;
> + int count = 0;
> +
> + if (!req->buffer_size) buf = NULL;
> + else if (!(buf = mem_alloc( get_reply_max_size() )))
> + return;
> +
> + cur = buf;
> + ptr = list_head( &input->msg_list );
> + while (ptr)
> + {
> + struct message *msg = LIST_ENTRY( ptr, struct message, entry );
> + struct hardware_msg_data *data = msg->data;
> +
> + ptr = list_next( &input->msg_list, ptr );
> + if (msg->msg != WM_INPUT) continue;
> +
> + next_size = req->rawinput_size;
> + if (size + next_size > req->buffer_size) break;
> + if (cur + sizeof(*data) > buf + get_reply_max_size()) break;
> +
> + memcpy(cur, data, sizeof(*data));
> + list_remove( &msg->entry );
> + free_message( msg );
> +
> + size += next_size;
> + cur += sizeof(*data);
> + count++;
> + }
> +
> + reply->next_size = next_size;
> + reply->count = count;
> + set_reply_data_ptr( buf, cur - buf );
> +}
Since you are simply returning an array of hardware_msg_data it would be
better to code it that way, using appropriate types instead of char* and
explicit sizes. Also it seems the server shouldn't need to worry about
the size of the client-side structures.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list