reactos/include/ndk/lpctypes.h

279 lines
5.5 KiB
C
Raw Normal View History

/*++ NDK Version: 0098
Copyright (c) Alex Ionescu. All rights reserved.
Header Name:
lpctypes.h
Abstract:
Type definitions for the Loader.
Author:
Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
--*/
#ifndef _LPCTYPES_H
#define _LPCTYPES_H
//
// Dependencies
//
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
#include <umtypes.h>
//#include <pstypes.h>
//
// Internal helper macro
//
#define N_ROUND_UP(x,s) \
(((ULONG)(x)+(s)-1) & ~((ULONG)(s)-1))
//
// Maximum message size that can be sent through an LPC Port without a section
//
#define PORT_MAXIMUM_MESSAGE_LENGTH 256
//
// Port Object Access Masks
//
#define PORT_CONNECT 0x1
#define PORT_ALL_ACCESS 0x1
//
// Port Object Flags
//
#define LPCP_CONNECTION_PORT 0x00000001
#define LPCP_UNCONNECTED_PORT 0x00000002
#define LPCP_COMMUNICATION_PORT 0x00000003
#define LPCP_CLIENT_PORT 0x00000004
#define LPCP_PORT_TYPE_MASK 0x0000000F
#define LPCP_PORT_DELETED 0x10000000
#define LPCP_WAITABLE_PORT 0x20000000
#define LPCP_NAME_DELETED 0x40000000
#define LPCP_SECURITY_DYNAMIC 0x80000000
//
// LPC Message Types
//
typedef enum _LPC_TYPE
{
LPC_NEW_MESSAGE,
LPC_REQUEST,
LPC_REPLY,
LPC_DATAGRAM,
LPC_LOST_REPLY,
LPC_PORT_CLOSED,
LPC_CLIENT_DIED,
LPC_EXCEPTION,
LPC_DEBUG_EVENT,
LPC_ERROR_EVENT,
LPC_CONNECTION_REQUEST,
LPC_CONNECTION_REFUSED,
LPC_MAXIMUM
} LPC_TYPE;
//
// Information Classes for NtQueryInformationPort
//
typedef enum _PORT_INFORMATION_CLASS
{
PortNoInformation
} PORT_INFORMATION_CLASS;
#ifdef NTOS_MODE_USER
//
// Portable LPC Types for 32/64-bit compatibility
//
#ifdef USE_LPC6432
#define LPC_CLIENT_ID CLIENT_ID64
#define LPC_SIZE_T ULONGLONG
#define LPC_PVOID ULONGLONG
#define LPC_HANDLE ULONGLONG
#else
#define LPC_CLIENT_ID CLIENT_ID
#define LPC_SIZE_T SIZE_T
#define LPC_PVOID PVOID
#define LPC_HANDLE HANDLE
#endif
//
// LPC Port Message
//
typedef struct _PORT_MESSAGE
{
union
{
struct
{
CSHORT DataLength;
CSHORT TotalLength;
} s1;
ULONG Length;
} u1;
union
{
struct
{
CSHORT Type;
CSHORT DataInfoOffset;
} s2;
ULONG ZeroInit;
} u2;
union
{
LPC_CLIENT_ID ClientId;
double DoNotUseThisField;
};
ULONG MessageId;
union
{
LPC_SIZE_T ClientViewSize;
ULONG CallbackId;
};
} PORT_MESSAGE, *PPORT_MESSAGE;
//
// Local and Remove Port Views
//
typedef struct _PORT_VIEW
{
ULONG Length;
LPC_HANDLE SectionHandle;
ULONG SectionOffset;
LPC_SIZE_T ViewSize;
LPC_PVOID ViewBase;
LPC_PVOID ViewRemoteBase;
} PORT_VIEW, *PPORT_VIEW;
typedef struct _REMOTE_PORT_VIEW
{
ULONG Length;
LPC_SIZE_T ViewSize;
LPC_PVOID ViewBase;
} REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW;
//
// LPC Kernel-Mode Message Structures defined for size only
//
typedef struct _LPCP_MESSAGE
{
UCHAR Data[0x14];
PORT_MESSAGE Request;
} LPCP_MESSAGE;
typedef struct _LPCP_CONNECTION_MESSAGE
{
UCHAR Data[0x2C];
} LPCP_CONNECTION_MESSAGE;
#else
//
// LPC Paged and Non-Paged Port Queues
//
typedef struct _LPCP_NONPAGED_PORT_QUEUE
{
KSEMAPHORE Semaphore;
struct _LPCP_PORT_OBJECT *BackPointer;
} LPCP_NONPAGED_PORT_QUEUE, *PLPCP_NONPAGED_PORT_QUEUE;
typedef struct _LPCP_PORT_QUEUE
{
PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue;
PKSEMAPHORE Semaphore;
LIST_ENTRY ReceiveHead;
} LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE;
//
// LPC Port Object
//
typedef struct _LPCP_PORT_OBJECT
{
struct _LPCP_PORT_OBJECT *ConnectionPort;
struct _LPCP_PORT_OBJECT *ConnectedPort;
LPCP_PORT_QUEUE MsgQueue;
CLIENT_ID Creator;
PVOID ClientSectionBase;
PVOID ServerSectionBase;
PVOID PortContext;
PETHREAD ClientThread;
SECURITY_QUALITY_OF_SERVICE SecurityQos;
SECURITY_CLIENT_CONTEXT StaticSecurity;
LIST_ENTRY LpcReplyChainHead;
LIST_ENTRY LpcDataInfoChainHead;
PEPROCESS ServerProcess;
PEPROCESS MappingProcess;
ULONG MaxMessageLength;
ULONG MaxConnectionInfoLength;
ULONG Flags;
KEVENT WaitEvent;
} LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT;
//
// LPC Kernel-Mode Message Structures
//
typedef struct _LPCP_MESSAGE
{
union
{
LIST_ENTRY Entry;
struct
{
SINGLE_LIST_ENTRY FreeEntry;
ULONG Reserved0;
};
};
PLPCP_PORT_OBJECT SenderPort;
PETHREAD RepliedToThread;
PVOID PortContext;
PORT_MESSAGE Request;
} LPCP_MESSAGE, *PLPCP_MESSAGE;
typedef struct _LPCP_CONNECTION_MESSAGE
{
PORT_VIEW ClientView;
PLPCP_PORT_OBJECT ClientPort;
PVOID SectionToMap;
REMOTE_PORT_VIEW ServerView;
} LPCP_CONNECTION_MESSAGE, *PLPCP_CONNECTION_MESSAGE;
#endif
//
// Client Died LPC Message
//
typedef struct _CLIENT_DIED_MSG
{
PORT_MESSAGE h;
LARGE_INTEGER CreateTime;
} CLIENT_DIED_MSG, *PCLIENT_DIED_MSG;
//
// Maximum total Kernel-Mode LPC Message Structure Size
//
#define LPCP_MAX_MESSAGE_SIZE \
N_ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
sizeof(LPCP_MESSAGE) + \
sizeof(LPCP_CONNECTION_MESSAGE), 16)
//
// Maximum actual LPC Message Length
//
#define LPC_MAX_MESSAGE_LENGTH \
(LPCP_MAX_MESSAGE_SIZE - \
FIELD_OFFSET(LPCP_MESSAGE, Request))
//
// Maximum actual size of LPC Message Data
//
#define LPC_MAX_DATA_LENGTH \
(LPC_MAX_MESSAGE_LENGTH - \
sizeof(PORT_MESSAGE) - \
sizeof(LPCP_CONNECTION_MESSAGE))
#endif // _LPCTYPES_H