ntdll: Implement NtQueryEvent.

This commit is contained in:
Andrew Cook 2013-08-26 19:52:51 +10:00 committed by Alexandre Julliard
parent 4654d871b2
commit cdfee68be1
7 changed files with 127 additions and 9 deletions

View File

@ -390,15 +390,34 @@ NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
/******************************************************************************
* NtQueryEvent (NTDLL.@)
*/
NTSTATUS WINAPI NtQueryEvent (
IN HANDLE EventHandle,
IN EVENT_INFORMATION_CLASS EventInformationClass,
OUT PVOID EventInformation,
IN ULONG EventInformationLength,
OUT PULONG ReturnLength)
NTSTATUS WINAPI NtQueryEvent( HANDLE handle, EVENT_INFORMATION_CLASS class,
void *info, ULONG len, ULONG *ret_len )
{
FIXME("(%p)\n", EventHandle);
return STATUS_NOT_IMPLEMENTED;
NTSTATUS ret;
EVENT_BASIC_INFORMATION *out = info;
if (class != EventBasicInformation)
{
FIXME("(%p, %d, %d) Unknown class\n",
handle, class, len);
return STATUS_INVALID_INFO_CLASS;
}
if (len != sizeof(EVENT_BASIC_INFORMATION)) return STATUS_INFO_LENGTH_MISMATCH;
SERVER_START_REQ( query_event )
{
req->handle = wine_server_obj_handle( handle );
if (!(ret = wine_server_call( req )))
{
out->EventType = reply->manual_reset ? NotificationEvent : SynchronizationEvent;
out->EventState = reply->state;
if (ret_len) *ret_len = sizeof(EVENT_BASIC_INFORMATION);
}
}
SERVER_END_REQ;
return ret;
}
/*

View File

@ -30,6 +30,9 @@ static NTSTATUS (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, LPC
static VOID (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING, LPCWSTR );
static VOID (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
static NTSTATUS (WINAPI *pNtCreateEvent) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, BOOLEAN, BOOLEAN);
static NTSTATUS (WINAPI *pNtOpenEvent) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES);
static NTSTATUS (WINAPI *pNtPulseEvent) ( HANDLE, PULONG );
static NTSTATUS (WINAPI *pNtQueryEvent) ( HANDLE, EVENT_INFORMATION_CLASS, PVOID, ULONG, PULONG );
static NTSTATUS (WINAPI *pNtCreateMutant)( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, BOOLEAN );
static NTSTATUS (WINAPI *pNtOpenMutant) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES );
static NTSTATUS (WINAPI *pNtCreateSemaphore)( PHANDLE, ACCESS_MASK,const POBJECT_ATTRIBUTES,LONG,LONG );
@ -798,6 +801,44 @@ static void test_type_mismatch(void)
pNtClose( h );
}
static void test_event(void)
{
HANDLE Event;
HANDLE Event2;
NTSTATUS status;
UNICODE_STRING str;
OBJECT_ATTRIBUTES attr;
EVENT_BASIC_INFORMATION info;
static const WCHAR eventName[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t','E','v','e','n','t',0};
pRtlInitUnicodeString(&str, eventName);
InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, 1, 0);
ok( status == STATUS_SUCCESS, "NtCreateEvent failed %08x\n", status );
status = pNtPulseEvent(Event, NULL);
ok( status == STATUS_SUCCESS, "NtPulseEvent failed %08x\n", status );
status = pNtQueryEvent(Event, EventBasicInformation, &info, sizeof(info), NULL);
ok( status == STATUS_SUCCESS, "NtQueryEvent failed %08x\n", status );
ok( info.EventType == 1 && info.EventState == 0,
"NtQueryEvent failed, expected 1 0, got %d %d\n", info.EventType, info.EventState );
status = pNtOpenEvent(&Event2, GENERIC_ALL, &attr);
ok( status == STATUS_SUCCESS, "NtOpenEvent failed %08x\n", status );
status = pNtClose(Event);
status = pNtQueryEvent(Event2, EventBasicInformation, &info, sizeof(info), NULL);
ok( status == STATUS_SUCCESS, "NtQueryEvent failed %08x\n", status );
ok( info.EventType == 1 && info.EventState == 0,
"NtQueryEvent failed, expected 1 0, got %d %d\n", info.EventType, info.EventState );
status = pNtClose(Event2);
}
START_TEST(om)
{
HMODULE hntdll = GetModuleHandleA("ntdll.dll");
@ -815,6 +856,9 @@ START_TEST(om)
pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
pNtCreateEvent = (void *)GetProcAddress(hntdll, "NtCreateEvent");
pNtCreateMutant = (void *)GetProcAddress(hntdll, "NtCreateMutant");
pNtOpenEvent = (void *)GetProcAddress(hntdll, "NtOpenEvent");
pNtQueryEvent = (void *)GetProcAddress(hntdll, "NtQueryEvent");
pNtPulseEvent = (void *)GetProcAddress(hntdll, "NtPulseEvent");
pNtOpenMutant = (void *)GetProcAddress(hntdll, "NtOpenMutant");
pNtOpenFile = (void *)GetProcAddress(hntdll, "NtOpenFile");
pNtClose = (void *)GetProcAddress(hntdll, "NtClose");
@ -838,4 +882,5 @@ START_TEST(om)
test_symboliclink();
test_query_object();
test_type_mismatch();
test_event();
}

View File

@ -1103,6 +1103,17 @@ struct event_op_reply
};
enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
struct query_event_request
{
struct request_header __header;
obj_handle_t handle;
};
struct query_event_reply
{
struct reply_header __header;
int manual_reset;
int state;
};
struct open_event_request
@ -5017,6 +5028,7 @@ enum request
REQ_select,
REQ_create_event,
REQ_event_op,
REQ_query_event,
REQ_open_event,
REQ_create_keyed_event,
REQ_open_keyed_event,
@ -5275,6 +5287,7 @@ union generic_request
struct select_request select_request;
struct create_event_request create_event_request;
struct event_op_request event_op_request;
struct query_event_request query_event_request;
struct open_event_request open_event_request;
struct create_keyed_event_request create_keyed_event_request;
struct open_keyed_event_request open_keyed_event_request;
@ -5531,6 +5544,7 @@ union generic_reply
struct select_reply select_reply;
struct create_event_reply create_event_reply;
struct event_op_reply event_op_reply;
struct query_event_reply query_event_reply;
struct open_event_reply open_event_reply;
struct create_keyed_event_reply create_keyed_event_reply;
struct open_keyed_event_reply open_keyed_event_reply;
@ -5757,6 +5771,6 @@ union generic_reply
struct set_suspend_context_reply set_suspend_context_reply;
};
#define SERVER_PROTOCOL_VERSION 442
#define SERVER_PROTOCOL_VERSION 443
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -335,6 +335,19 @@ DECL_HANDLER(event_op)
release_object( event );
}
/* return details about the event */
DECL_HANDLER(query_event)
{
struct event *event;
if (!(event = get_event_obj( current->process, req->handle, EVENT_QUERY_STATE ))) return;
reply->manual_reset = event->manual_reset;
reply->state = event->signaled;
release_object( event );
}
/* create a keyed event */
DECL_HANDLER(create_keyed_event)
{

View File

@ -953,6 +953,12 @@ struct rawinput_device
@END
enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
@REQ(query_event)
obj_handle_t handle; /* handle to event */
@REPLY
int manual_reset; /* manual reset event */
int state; /* current state of the event */
@END
/* Open an event */
@REQ(open_event)

View File

@ -133,6 +133,7 @@ DECL_HANDLER(open_thread);
DECL_HANDLER(select);
DECL_HANDLER(create_event);
DECL_HANDLER(event_op);
DECL_HANDLER(query_event);
DECL_HANDLER(open_event);
DECL_HANDLER(create_keyed_event);
DECL_HANDLER(open_keyed_event);
@ -390,6 +391,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_select,
(req_handler)req_create_event,
(req_handler)req_event_op,
(req_handler)req_query_event,
(req_handler)req_open_event,
(req_handler)req_create_keyed_event,
(req_handler)req_open_keyed_event,
@ -832,6 +834,11 @@ 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 query_event_request, handle) == 12 );
C_ASSERT( sizeof(struct query_event_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct query_event_reply, manual_reset) == 8 );
C_ASSERT( FIELD_OFFSET(struct query_event_reply, state) == 12 );
C_ASSERT( sizeof(struct query_event_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct open_event_request, access) == 12 );
C_ASSERT( FIELD_OFFSET(struct open_event_request, attributes) == 16 );
C_ASSERT( FIELD_OFFSET(struct open_event_request, rootdir) == 20 );

View File

@ -1391,6 +1391,17 @@ static void dump_event_op_request( const struct event_op_request *req )
fprintf( stderr, ", op=%d", req->op );
}
static void dump_query_event_request( const struct query_event_request *req )
{
fprintf( stderr, " handle=%04x", req->handle );
}
static void dump_query_event_reply( const struct query_event_reply *req )
{
fprintf( stderr, " manual_reset=%d", req->manual_reset );
fprintf( stderr, ", state=%d", req->state );
}
static void dump_open_event_request( const struct open_event_request *req )
{
fprintf( stderr, " access=%08x", req->access );
@ -4032,6 +4043,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_select_request,
(dump_func)dump_create_event_request,
(dump_func)dump_event_op_request,
(dump_func)dump_query_event_request,
(dump_func)dump_open_event_request,
(dump_func)dump_create_keyed_event_request,
(dump_func)dump_open_keyed_event_request,
@ -4286,6 +4298,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_select_reply,
(dump_func)dump_create_event_reply,
NULL,
(dump_func)dump_query_event_reply,
(dump_func)dump_open_event_reply,
(dump_func)dump_create_keyed_event_reply,
(dump_func)dump_open_keyed_event_reply,
@ -4540,6 +4553,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"select",
"create_event",
"event_op",
"query_event",
"open_event",
"create_keyed_event",
"open_keyed_event",