From 15b935ba7c0d2e9805db2765ce54ee312b2134be Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 6 Oct 2000 22:54:58 +0000 Subject: [PATCH] Implemented NtPulseEvent() and NtQueryEvent() svn path=/trunk/; revision=1384 --- reactos/include/ddk/iodef.h | 19 +++- reactos/include/ddk/iotypes.h | 7 +- reactos/include/ddk/zw.h | 191 ++++++++++++++++++++-------------- reactos/include/ddk/zwtypes.h | 12 ++- reactos/include/ntos/synch.h | 1 + reactos/include/ntos/types.h | 45 +++++--- reactos/ntoskrnl/nt/ntevent.c | 68 ++++++++++-- 7 files changed, 230 insertions(+), 113 deletions(-) diff --git a/reactos/include/ddk/iodef.h b/reactos/include/ddk/iodef.h index e51e288d348..2e24936096f 100644 --- a/reactos/include/ddk/iodef.h +++ b/reactos/include/ddk/iodef.h @@ -235,7 +235,24 @@ enum #define IRP_MN_VERIFY_VOLUME 0x02 #define IRP_MN_LOAD_FILE_SYSTEM 0x03 -#define IO_DISK_INCREMENT 4 +/* + * Priority increments + */ +#define EVENT_INCREMENT 1 +#define IO_NO_INCREMENT 0 +#define IO_CD_ROM_INCREMENT 1 +#define IO_DISK_INCREMENT 4 +#define IO_KEYBOARD_INCREMENT 6 +#define IO_MAILSLOT_INCREMENT 2 +#define IO_MOUSE_INCREMENT 6 +#define IO_NAMED_PIPE_INCREMENT 2 +#define IO_NETWORK_INCREMENT 2 +#define IO_PARALLEL_INCREMENT 1 +#define IO_SERIAL_INCREMENT 2 +#define IO_SOUND_INCREMENT 8 +#define IO_VIDEO_INCREMENT 1 +#define SEMAPHORE_INCREMENT 1 + #define FILE_WORD_ALIGNMENT 0x0001 diff --git a/reactos/include/ddk/iotypes.h b/reactos/include/ddk/iotypes.h index 5da0dd7629f..fa3c24a90cf 100644 --- a/reactos/include/ddk/iotypes.h +++ b/reactos/include/ddk/iotypes.h @@ -1,4 +1,4 @@ -/* $Id: iotypes.h,v 1.19 2000/09/12 10:12:10 jean Exp $ +/* $Id: iotypes.h,v 1.20 2000/10/06 22:53:21 ekohl Exp $ * */ @@ -705,9 +705,4 @@ VOID ); #endif // (_WIN32_WINNT >= 0x0400) -enum -{ - IO_NO_INCREMENT, -}; - #endif __INCLUDE_DDK_IOTYPES_H diff --git a/reactos/include/ddk/zw.h b/reactos/include/ddk/zw.h index f9447482bfe..069b678ce58 100644 --- a/reactos/include/ddk/zw.h +++ b/reactos/include/ddk/zw.h @@ -1,5 +1,5 @@ -/* $Id: zw.h,v 1.35 2000/09/08 22:52:17 ekohl Exp $ +/* $Id: zw.h,v 1.36 2000/10/06 22:53:22 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -2574,20 +2574,43 @@ ZwPulseEvent( * RETURNS: Status */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtQueryAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, IN PVOID Buffer ); -NTSTATUS -STDCALL +NTSTATUS +STDCALL ZwQueryAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, IN PVOID Buffer ); +/* + * FUNCTION: Queries the default locale id + * ARGUMENTS: + * UserProfile = Type of locale id + * TRUE: thread locale id + * FALSE: system locale id + * DefaultLocaleId = Caller supplies storage for the locale id + * RETURNS: Status + */ + +NTSTATUS +STDCALL +NtQueryDefaultLocale( + IN BOOLEAN UserProfile, + OUT PLCID DefaultLocaleId + ); + +NTSTATUS +STDCALL +ZwQueryDefaultLocale( + IN BOOLEAN UserProfile, + OUT PLCID DefaultLocaleId + ); /* * FUNCTION: Queries a directory file. @@ -2614,8 +2637,8 @@ ZwQueryAttributesFile( * STATUS_INVALID_INFO_CLASS, STATUS_NO_SUCH_FILE, STATUS_NO_MORE_FILES ] */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtQueryDirectoryFile( IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, @@ -2630,8 +2653,8 @@ NtQueryDirectoryFile( IN BOOLEAN RestartScan ); -NTSTATUS -STDCALL +NTSTATUS +STDCALL ZwQueryDirectoryFile( IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, @@ -2645,7 +2668,7 @@ ZwQueryDirectoryFile( IN PUNICODE_STRING FileName OPTIONAL, IN BOOLEAN RestartScan ); - + /* * FUNCTION: Query information about the content of a directory object * ARGUMENTS: @@ -2724,6 +2747,7 @@ ZwQueryEaFile( IN PULONG EaIndex OPTIONAL, IN BOOLEAN RestartScan ); + /* * FUNCTION: Queries an event * ARGUMENTS: @@ -2737,35 +2761,33 @@ ZwQueryEaFile( * ReturnLength = Data written * RETURNS: Status */ - - NTSTATUS STDCALL NtQueryEvent( IN HANDLE EventHandle, - IN CINT EventInformationClass, - OUT PVOID EventInformation, - IN ULONG EventInformationLength, - OUT PULONG ReturnLength - ); - -NTSTATUS -STDCALL -ZwQueryEvent( - IN HANDLE EventHandle, - IN CINT EventInformationClass, + IN EVENT_INFORMATION_CLASS EventInformationClass, OUT PVOID EventInformation, IN ULONG EventInformationLength, OUT PULONG ReturnLength ); NTSTATUS -STDCALL +STDCALL +ZwQueryEvent( + IN HANDLE EventHandle, + IN EVENT_INFORMATION_CLASS EventInformationClass, + OUT PVOID EventInformation, + IN ULONG EventInformationLength, + OUT PULONG ReturnLength + ); + +NTSTATUS +STDCALL NtQueryFullAttributesFile( IN HANDLE FileHandle, IN PVOID Attributes ); NTSTATUS -STDCALL +STDCALL ZwQueryFullAttributesFile( IN HANDLE FileHandle, IN PVOID Attributes @@ -2774,21 +2796,21 @@ ZwQueryFullAttributesFile( NTSTATUS STDCALL NtQueryInformationAtom( - IN HANDLE AtomHandle, + IN RTL_ATOM Atom, IN CINT AtomInformationClass, OUT PVOID AtomInformation, IN ULONG AtomInformationLength, OUT PULONG ReturnLength - ); + ); NTSTATUS STDCALL NtQueryInformationAtom( - IN HANDLE AtomHandle, + IN RTL_ATOM Atom, IN CINT AtomInformationClass, OUT PVOID AtomInformation, IN ULONG AtomInformationLength, OUT PULONG ReturnLength - ); + ); @@ -3953,6 +3975,7 @@ ZwSaveKey( IN HANDLE KeyHandle, IN HANDLE FileHandle ); + /* * FUNCTION: Sets the context of a specified thread. * ARGUMENTS: @@ -3974,28 +3997,53 @@ ZwSetContextThread( IN PCONTEXT Context ); +/* + * FUNCTION: Sets the default locale id + * ARGUMENTS: + * UserProfile = Type of locale id + * TRUE: thread locale id + * FALSE: system locale id + * DefaultLocaleId = Locale id + * RETURNS: Status + */ + +NTSTATUS +STDCALL +NtSetDefaultLocale( + IN BOOLEAN UserProfile, + IN LCID DefaultLocaleId + ); + +NTSTATUS +STDCALL +ZwSetDefaultLocale( + IN BOOLEAN UserProfile, + IN LCID DefaultLocaleId + ); + /* * FUNCTION: Sets the default hard error port - * ARGUMENTS: + * ARGUMENTS: * PortHandle = Handle to the port * NOTE: The hard error port is used for first change exception handling * RETURNS: Status */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtSetDefaultHardErrorPort( IN HANDLE PortHandle ); -NTSTATUS -STDCALL +NTSTATUS +STDCALL ZwSetDefaultHardErrorPort( IN HANDLE PortHandle ); + /* * FUNCTION: Sets the extended attributes of a file. - * ARGUMENTS: + * ARGUMENTS: * FileHandle = Handle to the file - * IoStatusBlock = Storage for a resulting status and information + * IoStatusBlock = Storage for a resulting status and information * on the current operation. * EaBuffer = Extended Attributes buffer. * EaBufferSize = Size of the extended attributes buffer @@ -4005,16 +4053,16 @@ NTSTATUS STDCALL NtSetEaFile( IN HANDLE FileHandle, - IN PIO_STATUS_BLOCK IoStatusBlock, - PVOID EaBuffer, + IN PIO_STATUS_BLOCK IoStatusBlock, + PVOID EaBuffer, ULONG EaBufferSize ); NTSTATUS STDCALL ZwSetEaFile( IN HANDLE FileHandle, - IN PIO_STATUS_BLOCK IoStatusBlock, - PVOID EaBuffer, + IN PIO_STATUS_BLOCK IoStatusBlock, + PVOID EaBuffer, ULONG EaBufferSize ); @@ -4508,6 +4556,7 @@ ZwSetTimer( IN ULONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL ); + /* * FUNCTION: Sets the frequency of the system timer * ARGUMENTS: @@ -4530,6 +4579,7 @@ ZwSetTimerResolution( IN BOOL SetOrUnset, OUT PULONG ActualResolution ); + /* * FUNCTION: Sets the value of a registry key * ARGUMENTS: @@ -4573,9 +4623,10 @@ ZwSetValueKey( IN PVOID Data, IN ULONG DataSize ); + /* - * FUNCTION: Sets the volume information of a file. - * ARGUMENTS: + * FUNCTION: Sets the volume information of a file. + * ARGUMENTS: * FileHandle = Handle to the file * VolumeInformationClass = specifies the particular volume information to set * VolumeInformation = pointer to a structure containing the new volume information @@ -4599,16 +4650,36 @@ ZwSetVolumeInformationFile( PVOID VolumeInformation, ULONG Length ); + +/* + * FUNCTION: Shuts the system down + * ARGUMENTS: + * Action = Specifies the type of shutdown, it can be one of the following values: + * ShutdownNoReboot, ShutdownReboot, ShutdownPowerOff + * RETURNS: Status + */ +NTSTATUS +STDCALL +NtShutdownSystem( + IN SHUTDOWN_ACTION Action + ); + +NTSTATUS +STDCALL +ZwShutdownSystem( + IN SHUTDOWN_ACTION Action + ); + + /* --- PROFILING --- */ /* * FUNCTION: Starts profiling * ARGUMENTS: * ProfileHandle = Handle to the profile - * RETURNS: Status + * RETURNS: Status */ - NTSTATUS STDCALL NtStartProfile( @@ -5148,20 +5219,6 @@ NtGetPlugPlayEvent ( VOID ); -/* --- NATIONAL LANGUAGE SUPPORT (NLS) --- */ - -NTSTATUS -STDCALL -NtQueryDefaultLocale ( - VOID - ); - -NTSTATUS -STDCALL -NtSetDefaultLocale ( - VOID - ); - /* --- POWER MANAGEMENT --- */ NTSTATUS @@ -5244,24 +5301,6 @@ NtSetLdtEntries ( PULONG Entries ); -/* - * FUNCTION: Shuts the system down - * ARGUMENTS: - * Action: Specifies the type of shutdown, it can be one of the following values: - ShutdownNoReboot, ShutdownReboot, ShutdownPowerOff - * RETURNS: Status - */ -NTSTATUS -STDCALL -NtShutdownSystem( - IN SHUTDOWN_ACTION Action - ); - -NTSTATUS -STDCALL -ZwShutdownSystem( - IN SHUTDOWN_ACTION Action - ); NTSTATUS STDCALL diff --git a/reactos/include/ddk/zwtypes.h b/reactos/include/ddk/zwtypes.h index 0404642a001..49526d151cb 100644 --- a/reactos/include/ddk/zwtypes.h +++ b/reactos/include/ddk/zwtypes.h @@ -87,7 +87,10 @@ extern ULONG IMPORTED NtBuildNumber; // event information -#define EventBasicInformation 0 +typedef enum _EVENT_INFORMATION_CLASS +{ + EventBasicInformation = 0 +} EVENT_INFORMATION_CLASS; // system information // {Nt|Zw}{Query|Set}SystemInformation @@ -1186,9 +1189,10 @@ typedef struct _SEMAPHORE_BASIC_INFORMATION typedef struct _EVENT_BASIC_INFORMATION { - BOOL AutomaticReset; - BOOL Signaled; -} EVENT_BASIC_INFORMATION, *PEVENT_INFORMATION; + EVENT_TYPE EventType; + LONG EventState; +} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION; + //typedef enum _TIMER_TYPE //{ diff --git a/reactos/include/ntos/synch.h b/reactos/include/ntos/synch.h index 6a4927db521..4389dee136e 100644 --- a/reactos/include/ntos/synch.h +++ b/reactos/include/ntos/synch.h @@ -19,6 +19,7 @@ #define SEMAPHORE_MODIFY_STATE (2) #define EVENT_ALL_ACCESS (0x1f0003L) #define EVENT_MODIFY_STATE (2) +#define EVENT_QUERY_STATE (1) #endif /* __INCLUDE_PS_H */ diff --git a/reactos/include/ntos/types.h b/reactos/include/ntos/types.h index e80482d8f5b..70df4deac2c 100644 --- a/reactos/include/ntos/types.h +++ b/reactos/include/ntos/types.h @@ -68,6 +68,11 @@ typedef union _LARGE_INTEGER DWORD LowPart; LONG HighPart; } u; + struct + { + DWORD LowPart; + LONG HighPart; + }; LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; @@ -78,6 +83,11 @@ typedef union _ULARGE_INTEGER DWORD LowPart; DWORD HighPart; } u; + struct + { + DWORD LowPart; + DWORD HighPart; + }; ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; @@ -264,14 +274,14 @@ typedef struct value_ent { #define EXCEPTION_MAXIMUM_PARAMETERS (15) -typedef struct _EXCEPTION_RECORD { - DWORD ExceptionCode; - DWORD ExceptionFlags; - struct _EXCEPTION_RECORD *ExceptionRecord; - PVOID ExceptionAddress; - DWORD NumberParameters; - DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; -} EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD; +typedef struct _EXCEPTION_RECORD { + DWORD ExceptionCode; + DWORD ExceptionFlags; + struct _EXCEPTION_RECORD *ExceptionRecord; + PVOID ExceptionAddress; + DWORD NumberParameters; + DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +} EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD; typedef long *PLONG; @@ -281,6 +291,7 @@ typedef BYTE *LPBYTE; typedef BYTE *PBYTE; typedef DWORD LCID; +typedef DWORD *PLCID; typedef const char *LPCSTR; @@ -289,15 +300,15 @@ typedef char *LPSTR; typedef const unsigned short *LPCWSTR; typedef struct _COORD { - SHORT X; - SHORT Y; -} COORD; + SHORT X; + SHORT Y; +} COORD; -typedef struct _SMALL_RECT { - SHORT Left; - SHORT Top; - SHORT Right; - SHORT Bottom; -} SMALL_RECT, *PSMALL_RECT; +typedef struct _SMALL_RECT { + SHORT Left; + SHORT Top; + SHORT Right; + SHORT Bottom; +} SMALL_RECT, *PSMALL_RECT; #endif /* __INCLUDE_TYPES_H */ diff --git a/reactos/ntoskrnl/nt/ntevent.c b/reactos/ntoskrnl/nt/ntevent.c index 7b2ed40de28..73a38583317 100644 --- a/reactos/ntoskrnl/nt/ntevent.c +++ b/reactos/ntoskrnl/nt/ntevent.c @@ -14,6 +14,7 @@ #include #include #include +#include #define NDEBUG #include @@ -92,11 +93,11 @@ NTSTATUS STDCALL NtClearEvent (IN HANDLE EventHandle) } -NTSTATUS STDCALL NtCreateEvent (OUT PHANDLE EventHandle, +NTSTATUS STDCALL NtCreateEvent (OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN ManualReset, - IN BOOLEAN InitialState) + IN BOOLEAN ManualReset, + IN BOOLEAN InitialState) { PKEVENT Event; @@ -113,7 +114,7 @@ NTSTATUS STDCALL NtCreateEvent (OUT PHANDLE EventHandle, } -NTSTATUS STDCALL NtOpenEvent (OUT PHANDLE EventHandle, +NTSTATUS STDCALL NtOpenEvent (OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes) { @@ -147,17 +148,66 @@ NTSTATUS STDCALL NtOpenEvent (OUT PHANDLE EventHandle, NTSTATUS STDCALL NtPulseEvent(IN HANDLE EventHandle, IN PULONG PulseCount OPTIONAL) { - UNIMPLEMENTED; + PKEVENT Event; + NTSTATUS Status; + + DPRINT("NtPulseEvent(EventHandle %x PulseCount %x)\n", + EventHandle, PulseCount); + + Status = ObReferenceObjectByHandle(EventHandle, + EVENT_MODIFY_STATE, + ExEventObjectType, + UserMode, + (PVOID*)&Event, + NULL); + if (!NT_SUCCESS(Status)) + return(Status); + + KePulseEvent(Event,EVENT_INCREMENT,FALSE); + + ObDereferenceObject(Event); + return(STATUS_SUCCESS); } NTSTATUS STDCALL NtQueryEvent (IN HANDLE EventHandle, - IN CINT EventInformationClass, + IN EVENT_INFORMATION_CLASS EventInformationClass, OUT PVOID EventInformation, IN ULONG EventInformationLength, OUT PULONG ReturnLength) { - UNIMPLEMENTED; + PEVENT_BASIC_INFORMATION Info; + PKEVENT Event; + NTSTATUS Status; + + Info = (PEVENT_BASIC_INFORMATION)EventInformation; + + if (EventInformationClass > EventBasicInformation) + return STATUS_INVALID_INFO_CLASS; + + if (EventInformationLength < sizeof(EVENT_BASIC_INFORMATION)) + return STATUS_INFO_LENGTH_MISMATCH; + + Status = ObReferenceObjectByHandle(EventHandle, + EVENT_QUERY_STATE, + ExEventObjectType, + UserMode, + (PVOID*)&Event, + NULL); + if (!NT_SUCCESS(Status)) + return Status; + + if (Event->Header.Type == InternalNotificationEvent) + Info->EventType = NotificationEvent; + else + Info->EventType = SynchronizationEvent; + Info->EventState = KeReadStateEvent(Event); + + *ReturnLength = sizeof(EVENT_BASIC_INFORMATION); + + ObDereferenceObject(Event); + + return STATUS_SUCCESS; } @@ -186,7 +236,7 @@ NTSTATUS STDCALL NtResetEvent(HANDLE EventHandle, NTSTATUS STDCALL NtSetEvent(IN HANDLE EventHandle, - PULONG NumberOfThreadsReleased) + OUT PULONG NumberOfThreadsReleased) { PKEVENT Event; NTSTATUS Status; @@ -203,7 +253,7 @@ NTSTATUS STDCALL NtSetEvent(IN HANDLE EventHandle, { return(Status); } - KeSetEvent(Event,IO_NO_INCREMENT,FALSE); + KeSetEvent(Event,EVENT_INCREMENT,FALSE); ObDereferenceObject(Event);