/*++

Copyright (c) 1998-1999 Microsoft Corporation

Module Name:

    poolext.h

Abstract:

    Header file for access to pool extension driver.

    This header file can be included by user-mode or kernel-mode components.

Author:

    Ted Miller (tedm) 12-Dec-1997

Revision History:

--*/


//
// Name of device in both DOS (\DosDevices) and NT (\Device) namespaces
//
#define POOLEXT_DEVICE_NAME     L"POOLEXT"

//
// Ioctl codes.
//
#define IOCTL_POOLEXT_GET_VERSION_INFO          CTL_CODE(FILE_DEVICE_UNKNOWN, 1,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_SET_TRACKING              CTL_CODE(FILE_DEVICE_UNKNOWN, 2,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_REMOVE_TRACKING           CTL_CODE(FILE_DEVICE_UNKNOWN, 3,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_SET_TAILCHECK_FAILURE_OP  CTL_CODE(FILE_DEVICE_UNKNOWN, 4,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_RESET_STATISTICS          CTL_CODE(FILE_DEVICE_UNKNOWN, 5,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_QUERY_STATISTICS          CTL_CODE(FILE_DEVICE_UNKNOWN, 6,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_QUERY_CONFIG              CTL_CODE(FILE_DEVICE_UNKNOWN, 7,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_GET_MODULE_LIST           CTL_CODE(FILE_DEVICE_UNKNOWN, 8,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_SET_LOGGING               CTL_CODE(FILE_DEVICE_UNKNOWN, 9,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_SET_FILL                  CTL_CODE(FILE_DEVICE_UNKNOWN,10,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_POOLEXT_QUERY_CONFIG_EX           CTL_CODE(FILE_DEVICE_UNKNOWN,11,METHOD_BUFFERED,FILE_ANY_ACCESS)

//
// Enumerated types.
//
typedef enum {
    PoolTrackNoSetting,
    PoolTrackDisable,
    PoolTrackEnable,
    PoolTrackMax
} PoolTrackType;

typedef enum {
    PoolLogDisable,
    PoolLogEnable,
    PoolLogMax
} PoolLogType;

typedef enum {
    PoolFillDisable,
    PoolFillEnable,
    PoolFillMax
} PoolFillType;

#define TAIL_CHECK_FAIL_NO_ACTION    0x00
#define TAIL_CHECK_FAIL_BUGCHECK     0x01

//
// Pool types. These values index the statistics arrays.
//
#define POOLTYPE_NONPAGED                        0
#define POOLTYPE_PAGED                           1

#define POOLTYPE_COUNT                           2

//
// Data structures.
//
typedef struct _POOLEXT_MODULE {
    WCHAR ModuleName[9];
    WCHAR UnusedPadding;
    PVOID ModuleBaseAddress;
    SIZE_T ModuleSize;
} POOLEXT_MODULE, *PPOOLEXT_MODULE;


typedef struct _POOLEXT_MODULE_NAME {
    WCHAR ModuleName[9];
} POOLEXT_MODULE_NAME, *PPOOLEXT_MODULE_NAME;


typedef struct _POOLEXT_VERSION_DATA {
    USHORT MajorVersion;
    USHORT MinorVersion;
} POOLEXT_VERSION_DATA, *PPOOLEXT_VERSION_DATA;


typedef struct _POOLEXT_BLOCK_TRACKING_CONTROL {
    WCHAR ModuleName[9];
    WCHAR UnusedPadding;
    ULONG32 Tag;
    PoolTrackType TrackingType;
} POOLEXT_BLOCK_TRACKING_CONTROL, *PPOOLEXT_BLOCK_TRACKING_CONTROL;


typedef struct _POOLEXT_TAILCHECK_CONTROL {
    ULONG32 Operation;
} POOLEXT_TAILCHECK_CONTROL, *PPOOLEXT_TAILCHECK_CONTROL;


typedef struct _POOLEXT_LOGGING_CONTROL {
    WCHAR ModuleName[9];
    USHORT UnusedPadding;
    PoolLogType LogType;
    SIZE_T Spares[5];
} POOLEXT_LOGGING_CONTROL, *PPOOLEXT_LOGGING_CONTROL;


typedef struct _POOLEXT_FILL_CONTROL {
    WCHAR ModuleName[9];
    USHORT UnusedPadding;
    PoolFillType FillType;
    ULONG32 Pattern;
    SIZE_T MaxFillLength;
    SIZE_T Spares[5];
} POOLEXT_FILL_CONTROL, *PPOOLEXT_FILL_CONTROL;


typedef struct _POOLEXT_STATISTICS {
    WCHAR ModuleName[9];
    USHORT UnusedPadding;
    SSIZE_T CurrentlyAllocated[POOLTYPE_COUNT];
    SSIZE_T Overhead;
    ULONG32 AllocCount[POOLTYPE_COUNT];
    ULONG32 FreeCount[POOLTYPE_COUNT];
} POOLEXT_STATISTICS, *PPOOLEXT_STATISTICS;


typedef struct _POOLEXT_CONFIGURATION {
    SIZE_T OffsetToNext;
    WCHAR ModuleName[9];
    USHORT UnusedPadding;
    ULONG32 TailCheckFailureOperation;
    PoolTrackType TrackingType;
    ULONG32 TagCount;
    struct {
        ULONG32 Tag;
        PoolTrackType TrackingType;
    } PerTag[ANYSIZE_ARRAY];
} POOLEXT_CONFIGURATION, *PPOOLEXT_CONFIGURATION;


typedef struct _POOLEXT_CONFIGURATION_EX {
    SIZE_T OffsetToNext;
    WCHAR ModuleName[9];
    USHORT UnusedPadding;
    ULONG32 TailCheckFailureOperation;
    PoolTrackType TrackingType;
    PoolLogType LogType;
    PoolFillType FillType;
    ULONG32 FillPattern;
    SIZE_T MaxFillLength;
    SIZE_T Spares[10];
    ULONG32 TagCount;
    struct {
        ULONG32 Tag;
        PoolTrackType TrackingType;
        SIZE_T Spares[5];
    } PerTag[ANYSIZE_ARRAY];
} POOLEXT_CONFIGURATION_EX, *PPOOLEXT_CONFIGURATION_EX;
