diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index e172e577046..e397f1d0a04 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.84 2004/08/24 17:21:10 navaraf Exp $ +# $Id: makefile,v 1.85 2004/09/21 19:17:26 weiden Exp $ PATH_TO_TOP = ../.. @@ -45,7 +45,7 @@ FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \ file/cnotify.o file/hardlink.o file/bintype.o MEM_OBJECTS = mem/global.o mem/heap.o mem/isbad.o mem/local.o \ - mem/procmem.o mem/section.o mem/virtual.o + mem/procmem.o mem/resnotify.o mem/section.o mem/virtual.o NLS_OBJECTS = diff --git a/reactos/lib/kernel32/mem/resnotify.c b/reactos/lib/kernel32/mem/resnotify.c new file mode 100644 index 00000000000..6186b11f92e --- /dev/null +++ b/reactos/lib/kernel32/mem/resnotify.c @@ -0,0 +1,105 @@ +/* $Id: resnotify.c,v 1.1 2004/09/21 19:17:26 weiden Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/kernel32/mem/resnotify.c + * PURPOSE: Memory Resource Notification + * PROGRAMMER: Thomas Weidenmueller + */ + +/* INCLUDES ******************************************************************/ + +#include + +/* stolen from include/ntos/synch.h */ +#define EVENT_QUERY_STATE (1) + +/* FUNCTIONS *****************************************************************/ + +/* + * @implemented + */ +HANDLE +STDCALL +CreateMemoryResourceNotification( + MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType + ) +{ + UNICODE_STRING EventName; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE hEvent; + NTSTATUS Status; + + switch(NotificationType) + { + case LowMemoryResourceNotification: + RtlInitUnicodeString(&EventName, L"\\KernelObjects\\LowMemoryCondition"); + break; + + case HighMemoryResourceNotification: + RtlInitUnicodeString(&EventName, L"\\KernelObjects\\HighMemoryCondition"); + break; + + default: + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); + ObjectAttributes.RootDirectory = hBaseDir; + ObjectAttributes.ObjectName = &EventName; + ObjectAttributes.Attributes = 0; + ObjectAttributes.SecurityDescriptor = NULL; + ObjectAttributes.SecurityQualityOfService = NULL; + + Status = NtOpenEvent(&hEvent, + EVENT_QUERY_STATE | SYNCHRONIZE, + &ObjectAttributes); + if(!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return NULL; + } + + return hEvent; +} + + +/* + * @implemented + */ +BOOL +STDCALL +QueryMemoryResourceNotification( + HANDLE ResourceNotificationHandle, + PBOOL ResourceState + ) +{ + EVENT_BASIC_INFORMATION ebi; + ULONG RetLen; + NTSTATUS Status; + + if(ResourceState != NULL) + { + Status = NtQueryEvent(ResourceNotificationHandle, + EventBasicInformation, + &ebi, + sizeof(ebi), + &RetLen); + if(NT_SUCCESS(Status)) + { + *ResourceState = ebi.EventState; + return TRUE; + } + + SetLastErrorByStatus(Status); + } + else /* ResourceState == NULL */ + { + SetLastError(ERROR_INVALID_PARAMETER); + } + + return FALSE; +} + +/* EOF */ diff --git a/reactos/lib/kernel32/misc/stubs.c b/reactos/lib/kernel32/misc/stubs.c index 8a8dbf1b062..7a8ad64a804 100644 --- a/reactos/lib/kernel32/misc/stubs.c +++ b/reactos/lib/kernel32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.83 2004/09/21 17:41:24 weiden Exp $ +/* $Id: stubs.c,v 1.84 2004/09/21 19:17:26 weiden Exp $ * * KERNEL32.DLL stubs (unimplemented functions) * Remove from this file, if you implement them. @@ -662,19 +662,6 @@ CreateJobSet ( return 0; } -/* - * @unimplemented - */ -HANDLE -STDCALL -CreateMemoryResourceNotification( - MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - /* * @unimplemented */ @@ -1028,20 +1015,6 @@ QueryInformationJobObject( return 0; } -/* - * @unimplemented - */ -BOOL -STDCALL -QueryMemoryResourceNotification( - HANDLE ResourceNotificationHandle, - PBOOL ResourceState - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - /* * @unimplemented */