ReactOS  0.4.14-dev-552-g2fad488
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  */
21 HANDLE
22 WINAPI
23 CreateMemoryResourceNotification(IN MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType)
24 {
25  UNICODE_STRING EventName;
27  HANDLE hEvent;
29 
30  if (NotificationType > HighMemoryResourceNotification)
31  {
33  return NULL;
34  }
35 
36  RtlInitUnicodeString(&EventName,
37  NotificationType ?
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  */
62 BOOL
63 WINAPI
64 QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle,
65  OUT PBOOL ResourceState)
66 {
67  EVENT_BASIC_INFORMATION EventInfo;
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 */
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
HANDLE WINAPI CreateMemoryResourceNotification(IN MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType)
Definition: resntfy.c:23
LONG NTSTATUS
Definition: precomp.h:26
#define EVENT_QUERY_STATE
Definition: security.c:53
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
static HANDLE hEvent
Definition: comm.c:54
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtQueryEvent(IN HANDLE EventHandle, IN EVENT_INFORMATION_CLASS EventInformationClass, OUT PVOID EventInformation, IN ULONG EventInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: event.c:317
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
BOOL * PBOOL
Definition: windef.h:161
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define WINAPI
Definition: msvc.h:8
#define SetLastError(x)
Definition: compat.h:417
static const WCHAR L[]
Definition: oid.c:1250
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSTATUS NTAPI NtOpenEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: event.c:185
Status
Definition: gdiplustypes.h:24
#define OUT
Definition: typedefs.h:39
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
BOOL WINAPI QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle, OUT PBOOL ResourceState)
Definition: resntfy.c:64