Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenresntfy.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS Win32 Base API 00004 * FILE: dll/win32/kernel32/client/resnotify.c 00005 * PURPOSE: Memory Resource Notifications 00006 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com> 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <k32.h> 00012 00013 #define NDEBUG 00014 #include <debug.h> 00015 00016 /* FUNCTIONS ******************************************************************/ 00017 00018 /* 00019 * @implemented 00020 */ 00021 HANDLE 00022 WINAPI 00023 CreateMemoryResourceNotification(IN MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType) 00024 { 00025 UNICODE_STRING EventName; 00026 OBJECT_ATTRIBUTES ObjectAttributes; 00027 HANDLE hEvent; 00028 NTSTATUS Status; 00029 00030 if (NotificationType > HighMemoryResourceNotification) 00031 { 00032 SetLastError(ERROR_INVALID_PARAMETER); 00033 return NULL; 00034 } 00035 00036 RtlInitUnicodeString(&EventName, 00037 NotificationType ? 00038 L"\\KernelObjects\\HighMemoryCondition" : 00039 L"\\KernelObjects\\LowMemoryCondition"); 00040 00041 InitializeObjectAttributes(&ObjectAttributes, 00042 &EventName, 00043 0, 00044 BaseGetNamedObjectDirectory(), 00045 NULL); 00046 00047 Status = NtOpenEvent(&hEvent, 00048 EVENT_QUERY_STATE | SYNCHRONIZE, 00049 &ObjectAttributes); 00050 if (!NT_SUCCESS(Status)) 00051 { 00052 BaseSetLastNTError(Status); 00053 return NULL; 00054 } 00055 00056 return hEvent; 00057 } 00058 00059 /* 00060 * @implemented 00061 */ 00062 BOOL 00063 WINAPI 00064 QueryMemoryResourceNotification(IN HANDLE ResourceNotificationHandle, 00065 OUT PBOOL ResourceState) 00066 { 00067 EVENT_BASIC_INFORMATION EventInfo; 00068 NTSTATUS Status; 00069 00070 if ((ResourceNotificationHandle) && 00071 (ResourceNotificationHandle != INVALID_HANDLE_VALUE) && 00072 (ResourceState)) 00073 { 00074 Status = NtQueryEvent(ResourceNotificationHandle, 00075 EventBasicInformation, 00076 &EventInfo, 00077 sizeof(EventInfo), 00078 NULL); 00079 if (NT_SUCCESS(Status)) 00080 { 00081 *ResourceState = (EventInfo.EventState == 1); 00082 return TRUE; 00083 } 00084 00085 BaseSetLastNTError(Status); 00086 } 00087 else 00088 { 00089 SetLastError(ERROR_INVALID_PARAMETER); 00090 } 00091 00092 return FALSE; 00093 } 00094 00095 /* EOF */ Generated on Sun May 27 2012 04:24:30 for ReactOS by
1.7.6.1
|