⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resnotify.c

📁 这是一个开放源代码的与WINNT/WIN2K/WIN2003兼容的操作系统
💻 C
字号:
/* $Id: resnotify.c 22520 2006-06-22 23:40:50Z ion $
 *
 * COPYRIGHT:            See COPYING in the top level directory
 * PROJECT:              ReactOS kernel
 * FILE:                 lib/kernel32/mem/resnotify.c
 * PURPOSE:              Memory Resource Notification
 * PROGRAMMER:           Thomas Weidenmueller <w3seek@reactos.com>
 */

/* INCLUDES ******************************************************************/

#include <k32.h>

#define NDEBUG
#include "../include/debug.h"

/* 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;
    }

    InitializeObjectAttributes(&ObjectAttributes,
                               &EventName,
                               0,
                               hBaseDir,
                               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;
    NTSTATUS Status;

    if(ResourceState != NULL)
    {
      Status = NtQueryEvent(ResourceNotificationHandle,
                            EventBasicInformation,
                            &ebi,
                            sizeof(ebi),
                            NULL);
      if(NT_SUCCESS(Status))
      {
        *ResourceState = ebi.EventState;
        return TRUE;
      }

      SetLastErrorByStatus(Status);
    }
    else /* ResourceState == NULL */
    {
      SetLastError(ERROR_INVALID_PARAMETER);
    }

    return FALSE;
}

/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -