2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32 Base API
4 * FILE: dll/win32/kernel32/client/resnotify.c
5 * PURPOSE: Memory Resource Notifications
6 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
9 /* INCLUDES *******************************************************************/
16 /* FUNCTIONS ******************************************************************/
23 CreateMemoryResourceNotification(IN MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType
)
25 UNICODE_STRING EventName
;
26 OBJECT_ATTRIBUTES ObjectAttributes
;
30 if (NotificationType
> HighMemoryResourceNotification
)
32 SetLastError(ERROR_INVALID_PARAMETER
);
36 RtlInitUnicodeString(&EventName
,
38 L
"\\KernelObjects\\HighMemoryCondition" :
39 L
"\\KernelObjects\\LowMemoryCondition");
41 InitializeObjectAttributes(&ObjectAttributes
,
47 Status
= NtOpenEvent(&hEvent
,
48 EVENT_QUERY_STATE
| SYNCHRONIZE
,
50 if (!NT_SUCCESS(Status
))
52 BaseSetLastNTError(Status
);
64 QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle
,
65 OUT PBOOL ResourceState
)
67 EVENT_BASIC_INFORMATION EventInfo
;
70 if ((ResourceNotificationHandle
) &&
71 (ResourceNotificationHandle
!= INVALID_HANDLE_VALUE
) &&
74 Status
= NtQueryEvent(ResourceNotificationHandle
,
75 EventBasicInformation
,
79 if (NT_SUCCESS(Status
))
81 *ResourceState
= (EventInfo
.EventState
== 1);
85 BaseSetLastNTError(Status
);
89 SetLastError(ERROR_INVALID_PARAMETER
);