nt.h revision 751a35d04fb11f94562583ad77bc0a1382957f49
/* $Id$ */
/** @file
* IPRT - Header for code using the Native NT API.
*/
/*
* Copyright (C) 2010-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___iprt_nt_nt_h___
#define ___iprt_nt_nt_h___
/** @def IPRT_NT_MAP_TO_ZW
* Map Nt calls to Zw calls. In ring-0 the Zw calls let you pass kernel memory
* to the APIs (takes care of the previous context checks).
*/
#ifdef DOXYGEN_RUNNING
# define IPRT_NT_MAP_TO_ZW
#endif
#ifdef IPRT_NT_MAP_TO_ZW
# define NtCreateFile ZwCreateFile
# define NtReadFile ZwReadFile
# define NtWriteFile ZwWriteFile
/** @todo this is very incomplete! */
#endif
#include <ntstatus.h>
/*
* Hacks common to both base header sets.
*/
#ifdef IPRT_NT_USE_WINTERNL
/*
* Use Winternl.h.
*/
# define SystemProcessorPerformanceInformation IncompleteWinternl_SystemProcessorPerformanceInformation
# define WIN32_NO_STATUS
# include <windef.h>
# include <winnt.h>
# include <winternl.h>
# include <ntstatus.h>
#else
/*
*/
# ifdef RT_ARCH_X86
# endif
# include <ntifs.h>
# include <wdm.h>
# ifdef RT_ARCH_X86
# pragma warning(default : 4163)
# endif
# define IPRT_NT_NEED_API_GROUP_NTIFS
#endif
/** @name Useful macros
* @{ */
/** Indicates that we're targetting native NT in the current source. */
#define RTNT_USE_NATIVE_NT 1
/** Initializes a IO_STATUS_BLOCK. */
/** Similar to INVALID_HANDLE_VALUE in the Windows environment. */
/** @} */
/** @name IPRT helper functions for NT
* @{ */
RTDECL(int) RTNtPathOpen(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs, ULONG fShareAccess,
RTDECL(int) RTNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions,
/** @} */
/** @name NT API delcarations.
* @{ */
/** @name Process access rights missing in ntddk headers
* @{ */
#ifndef PROCESS_TERMINATE
#endif
#ifndef PROCESS_CREATE_THREAD
#endif
#ifndef PROCESS_SET_SESSIONID
#endif
#ifndef PROCESS_VM_OPERATION
#endif
#ifndef PROCESS_VM_READ
#endif
#ifndef PROCESS_VM_WRITE
#endif
#ifndef PROCESS_DUP_HANDLE
#endif
#ifndef PROCESS_CREATE_PROCESS
#endif
#ifndef PROCESS_SET_QUOTA
#endif
#ifndef PROCESS_SET_INFORMATION
#endif
#ifndef PROCESS_QUERY_INFORMATION
#endif
#ifndef PROCESS_SUSPEND_RESUME
#endif
#endif
#ifndef PROCESS_SET_LIMITED_INFORMATION
#endif
#ifndef PROCESS_ALL_ACCESS
#endif
/** @} */
/** @name Thread access rights missing in ntddk headers
* @{ */
#ifndef THREAD_QUERY_INFORMATION
#endif
#ifndef THREAD_SET_THREAD_TOKEN
#endif
#ifndef THREAD_IMPERSONATE
#endif
#ifndef THREAD_DIRECT_IMPERSONATION
#endif
#ifndef THREAD_RESUME
#endif
/** @} */
/** @name Special handle values.
* @{ */
#ifndef NtCurrentProcess
#endif
#ifndef NtCurrentThread
#endif
#ifndef ZwCurrentProcess
# define ZwCurrentProcess() NtCurrentProcess()
#endif
#ifndef ZwCurrentThread
# define ZwCurrentThread() NtCurrentThread()
#endif
/** @} */
/** @name Directory object access rights.
* @{ */
#ifndef DIRECTORY_QUERY
#endif
#ifndef DIRECTORY_TRAVERSE
#endif
#ifndef DIRECTORY_CREATE_OBJECT
#endif
#ifndef DIRECTORY_CREATE_SUBDIRECTORY
#endif
#ifndef DIRECTORY_ALL_ACCESS
#endif
/** @} */
#ifdef IPRT_NT_USE_WINTERNL
typedef struct _CLIENT_ID
{
} CLIENT_ID;
typedef CLIENT_ID *PCLIENT_ID;
NTSYSAPI NTSTATUS NTAPI NtCreateSection(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PLARGE_INTEGER, ULONG, ULONG, HANDLE);
typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
{
typedef enum _FSINFOCLASS
{
typedef FS_INFORMATION_CLASS *PFS_INFORMATION_CLASS;
NTSYSAPI NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS);
typedef struct _FILE_BOTH_DIR_INFORMATION
{
typedef struct _FILE_STANDARD_INFORMATION
{
typedef struct _FILE_NAME_INFORMATION
{
typedef FILE_NAME_INFORMATION *PFILE_NAME_INFORMATION;
typedef enum _FILE_INFORMATION_CLASS
{
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FILE_INFORMATION_CLASS);
NTSYSAPI NTSTATUS NTAPI NtQueryDirectoryFile(HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, PIO_STATUS_BLOCK, PVOID, ULONG,
typedef struct _MEMORY_SECTION_NAME
{
#ifdef IPRT_NT_USE_WINTERNL
typedef struct _PROCESS_BASIC_INFORMATION
{
#endif
typedef enum _PROCESSINFOCLASS
{
typedef enum _THREADINFOCLASS
{
NTSYSAPI NTSTATUS NTAPI NtQueryInformationToken(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, ULONG, PULONG);
NTSYSAPI NTSTATUS NTAPI NtReadFile(HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, PULONG);
NTSYSAPI NTSTATUS NTAPI NtWriteFile(HANDLE, HANDLE, PIO_APC_ROUTINE, void const *, PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, PULONG);
#endif /* IPRT_NT_USE_WINTERNL */
typedef enum _OBJECT_INFORMATION_CLASS
{
#ifdef IN_RING0
# define NtQueryObject ZwQueryObject
#endif
NTSYSAPI NTSTATUS NTAPI NtDuplicateObject(HANDLE, HANDLE, HANDLE, PHANDLE, ACCESS_MASK, ULONG, ULONG);
typedef struct _OBJECT_DIRECTORY_INFORMATION
{
NTSYSAPI NTSTATUS NTAPI NtQueryDirectoryObject(HANDLE, PVOID, ULONG, BOOLEAN, BOOLEAN, PULONG, PULONG);
/** @name ProcessDefaultHardErrorMode bit definitions.
* @{ */
/** @} */
/** Retured by ProcessImageInformation as well as NtQuerySection. */
typedef struct _SECTION_IMAGE_INFORMATION
{
union
{
struct
{
};
};
union /**< Since Vista, used to be a spare BOOLEAN. */
{
struct
{
};
};
typedef enum _SECTION_INFORMATION_CLASS
{
#ifndef SEC_FILE
#endif
#ifndef SEC_IMAGE
#endif
#ifndef SEC_PROTECTED_IMAGE
#endif
#ifndef SEC_NOCACHE
#endif
#ifndef MEM_ROTATE
#endif
typedef enum _MEMORY_INFORMATION_CLASS
{
#ifdef IN_RING0
typedef struct _MEMORY_BASIC_INFORMATION
{
# define NtQueryVirtualMemory ZwQueryVirtualMemory
#endif
NTSYSAPI NTSTATUS NTAPI NtQueryVirtualMemory(HANDLE, void const *, MEMORY_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
typedef enum _SYSTEM_INFORMATION_CLASS
{
SystemLoadGdiDriverInformation, /* 26 */
SystemUnloadGdiDriverInformation, /* 27 */
SystemExtendedHandleInformation, /* 64 */
/** @todo fill gap. they've added a whole bunch of things */
SystemPolicyInformation = 134,
#ifdef IPRT_NT_USE_WINTERNL
typedef struct _VM_COUNTERS
{
} VM_COUNTERS;
typedef VM_COUNTERS *PVM_COUNTERS;
#endif
#if 0
typedef struct _IO_COUNTERS
{
} IO_COUNTERS;
typedef IO_COUNTERS *PIO_COUNTERS;
#endif
typedef struct _RTNT_SYSTEM_PROCESS_INFORMATION
{
/* After this follows the threads, then the ProcessName.Buffer. */
#ifndef IPRT_NT_USE_WINTERNL
#endif
typedef struct _SYSTEM_HANDLE_ENTRY_INFO
{
/** Returned by SystemHandleInformation */
typedef struct _SYSTEM_HANDLE_INFORMATION
{
/** Extended handle information entry.
* @remarks 3 x PVOID + 4 x ULONG = 28 bytes on 32-bit / 40 bytes on 64-bit */
typedef struct _SYSTEM_HANDLE_ENTRY_INFO_EX
{
/** Returned by SystemExtendedHandleInformation. */
typedef struct _SYSTEM_HANDLE_INFORMATION_EX
{
/** Input to SystemSessionProcessInformation. */
typedef struct _SYSTEM_SESSION_PROCESS_INFORMATION
{
/** Return buffer, SYSTEM_PROCESS_INFORMATION entries. */
typedef struct _CURDIR
{
} CURDIR;
typedef struct _RTL_DRIVE_LETTER_CURDIR
{
typedef struct _RTL_USER_PROCESS_PARAMETERS
{
#define RTL_USER_PROCESS_PARAMS_FLAG_NORMALIZED 1
typedef struct _RTL_USER_PROCESS_INFORMATION
{
NTSYSAPI NTSTATUS NTAPI RtlCreateUserProcess(PUNICODE_STRING, ULONG, PRTL_USER_PROCESS_PARAMETERS, PSECURITY_DESCRIPTOR,
NTSYSAPI NTSTATUS NTAPI RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *, PUNICODE_STRING ImagePathName,
/** @} */
#if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
/** @name NT Kernel APIs
* @{ */
NTSYSAPI BOOLEAN NTAPI ObFindHandleForObject(PEPROCESS pProcess, PVOID pvObject, POBJECT_TYPE pObjectType,
NTSYSAPI NTSTATUS NTAPI ObReferenceObjectByName(PUNICODE_STRING pObjectPath, ULONG fAttributes, PACCESS_STATE pAccessState,
extern DECLIMPORT(POBJECT_TYPE *) LpcPortObjectType; /**< In vista+ this is the ALPC port object type. */
extern DECLIMPORT(POBJECT_TYPE *) LpcWaitablePortObjectType; /**< In vista+ this is the ALPC port object type. */
/** @ */
#endif /* IN_RING0 */
#endif