ReactOS 0.4.15-dev-7918-g2a2556c
resntfy.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32 Base API
4 * FILE: dll/win32/kernel32/client/resntfy.c
5 * PURPOSE: Memory Resource Notifications
6 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <k32.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* FUNCTIONS ******************************************************************/
17
18/*
19 * @implemented
20 */
23CreateMemoryResourceNotification(IN MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType)
24{
25 UNICODE_STRING EventName;
29
30 if (NotificationType > HighMemoryResourceNotification)
31 {
33 return NULL;
34 }
35
36 RtlInitUnicodeString(&EventName,
38 L"\\KernelObjects\\HighMemoryCondition" :
39 L"\\KernelObjects\\LowMemoryCondition");
40
42 &EventName,
43 0,
44 NULL,
45 NULL);
46
50 if (!NT_SUCCESS(Status))
51 {
53 return NULL;
54 }
55
56 return hEvent;
57}
58
59/*
60 * @implemented
61 */
62BOOL
64QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle,
65 OUT PBOOL ResourceState)
66{
69
70 if ((ResourceNotificationHandle) &&
71 (ResourceNotificationHandle != INVALID_HANDLE_VALUE) &&
72 (ResourceState))
73 {
74 Status = NtQueryEvent(ResourceNotificationHandle,
76 &EventInfo,
77 sizeof(EventInfo),
78 NULL);
79 if (NT_SUCCESS(Status))
80 {
81 *ResourceState = (EventInfo.EventState == 1);
82 return TRUE;
83 }
84
86 }
87 else
88 {
90 }
91
92 return FALSE;
93}
94
95/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
#define EVENT_QUERY_STATE
Definition: security.c:53
static HANDLE hEvent
Definition: comm.c:54
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
@ EventBasicInformation
Definition: extypes.h:357
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtOpenEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: event.c:181
NTSTATUS NTAPI NtQueryEvent(IN HANDLE EventHandle, IN EVENT_INFORMATION_CLASS EventInformationClass, OUT PVOID EventInformation, IN ULONG EventInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: event.c:313
#define L(x)
Definition: ntvdm.h:50
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
HANDLE WINAPI CreateMemoryResourceNotification(IN MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType)
Definition: resntfy.c:23
BOOL WINAPI QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle, OUT PBOOL ResourceState)
Definition: resntfy.c:64
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
Definition: wdfdevice.h:1024
BOOL * PBOOL
Definition: windef.h:161
#define WINAPI
Definition: msvc.h:6