Commit 7ba361b4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntdll: Add support for returning previous state argument in event functions.

parent d3660e59
......@@ -405,14 +405,12 @@ NTSTATUS WINAPI NtOpenEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_AT
NTSTATUS WINAPI NtSetEvent( HANDLE handle, LONG *prev_state )
{
NTSTATUS ret;
/* FIXME: set NumberOfThreadsReleased */
SERVER_START_REQ( event_op )
{
req->handle = wine_server_obj_handle( handle );
req->op = SET_EVENT;
ret = wine_server_call( req );
if (!ret && prev_state) *prev_state = reply->state;
}
SERVER_END_REQ;
return ret;
......@@ -424,15 +422,12 @@ NTSTATUS WINAPI NtSetEvent( HANDLE handle, LONG *prev_state )
NTSTATUS WINAPI NtResetEvent( HANDLE handle, LONG *prev_state )
{
NTSTATUS ret;
/* resetting an event can't release any thread... */
if (prev_state) *prev_state = 0;
SERVER_START_REQ( event_op )
{
req->handle = wine_server_obj_handle( handle );
req->op = RESET_EVENT;
ret = wine_server_call( req );
if (!ret && prev_state) *prev_state = reply->state;
}
SERVER_END_REQ;
return ret;
......@@ -464,6 +459,7 @@ NTSTATUS WINAPI NtPulseEvent( HANDLE handle, LONG *prev_state )
req->handle = wine_server_obj_handle( handle );
req->op = PULSE_EVENT;
ret = wine_server_call( req );
if (!ret && prev_state) *prev_state = reply->state;
}
SERVER_END_REQ;
return ret;
......
......@@ -1622,7 +1622,6 @@ static void test_event(void)
status = pNtPulseEvent(Event, &prev_state);
ok( status == STATUS_SUCCESS, "NtPulseEvent failed %08x\n", status );
todo_wine
ok( !prev_state, "prev_state = %x\n", prev_state );
status = pNtQueryEvent(Event, EventBasicInformation, &info, sizeof(info), NULL);
......@@ -1643,17 +1642,14 @@ static void test_event(void)
status = pNtSetEvent( Event, &prev_state );
ok( status == STATUS_SUCCESS, "NtSetEvent failed: %08x\n", status );
todo_wine
ok( !prev_state, "prev_state = %x\n", prev_state );
status = pNtSetEvent( Event, &prev_state );
ok( status == STATUS_SUCCESS, "NtSetEvent failed: %08x\n", status );
todo_wine
ok( prev_state == 1, "prev_state = %x\n", prev_state );
status = pNtResetEvent( Event, &prev_state );
ok( status == STATUS_SUCCESS, "NtSetEvent failed: %08x\n", status );
todo_wine
ok( prev_state == 1, "prev_state = %x\n", prev_state );
status = pNtResetEvent( Event, &prev_state );
......@@ -1670,7 +1666,6 @@ static void test_event(void)
status = pNtPulseEvent( Event, &prev_state );
ok( status == STATUS_SUCCESS, "NtPulseEvent failed %08x\n", status );
todo_wine
ok( prev_state == 1, "prev_state = %x\n", prev_state );
pNtClose(Event);
......
......@@ -1247,6 +1247,8 @@ struct event_op_request
struct event_op_reply
{
struct reply_header __header;
int state;
char __pad_12[4];
};
enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
......@@ -6554,6 +6556,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
#define SERVER_PROTOCOL_VERSION 572
#define SERVER_PROTOCOL_VERSION 573
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -311,6 +311,7 @@ DECL_HANDLER(event_op)
struct event *event;
if (!(event = get_event_obj( current->process, req->handle, EVENT_MODIFY_STATE ))) return;
reply->state = event->signaled;
switch(req->op)
{
case PULSE_EVENT:
......
......@@ -1080,6 +1080,8 @@ struct rawinput_device
@REQ(event_op)
obj_handle_t handle; /* handle to event */
int op; /* event operation (see below) */
@REPLY
int state; /* previous state */
@END
enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
......
......@@ -931,6 +931,8 @@ C_ASSERT( sizeof(struct create_event_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct event_op_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct event_op_request, op) == 16 );
C_ASSERT( sizeof(struct event_op_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct event_op_reply, state) == 8 );
C_ASSERT( sizeof(struct event_op_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct query_event_request, handle) == 12 );
C_ASSERT( sizeof(struct query_event_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct query_event_reply, manual_reset) == 8 );
......
......@@ -1594,6 +1594,11 @@ static void dump_event_op_request( const struct event_op_request *req )
fprintf( stderr, ", op=%d", req->op );
}
static void dump_event_op_reply( const struct event_op_reply *req )
{
fprintf( stderr, " state=%d", req->state );
}
static void dump_query_event_request( const struct query_event_request *req )
{
fprintf( stderr, " handle=%04x", req->handle );
......@@ -4865,7 +4870,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_open_thread_reply,
(dump_func)dump_select_reply,
(dump_func)dump_create_event_reply,
NULL,
(dump_func)dump_event_op_reply,
(dump_func)dump_query_event_reply,
(dump_func)dump_open_event_reply,
(dump_func)dump_create_keyed_event_reply,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment