
/**
 * @file: object_initializer_vista.h
 *
 * Tento soubor je soucasti frameworku na prochazeni internich datovych struktur spravce
 * objektu jadra Windos. Obsahuje prototypy funkci a definici struktury OBJECT_TYPE_INITIALIZER
 * pro Windows Vista.
 */

#ifndef __OBJECT_INITIALIZER_VISTA_H_
#define __OBJECT_INITIALIZER_VISTA_H_

#include <ntddk.h>
#include "object_initializer.h"

// Definice (virtualnich) method
typedef VOID (*DUMP_METHOD_VISTA)(PVOID Object, PDUMP_CONTROL Control);
typedef NTSTATUS (*OPEN_METHOD_VISTA)(OPEN_REASON OpenReason, KPROCESSOR_MODE AccessMode, PEPROCESS Process, PVOID Object, ACCESS_MASK *GrantedAccess, ULONG32 HandleCount);
typedef BOOLEAN (*OKAYTOCLOSE_METHOD_VISTA)(PEPROCESS Process, PVOID Object, HANDLE Handle, KPROCESSOR_MODE PreviousMode);
typedef VOID (*CLOSE_METHOD_VISTA)(PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG_PTR ProcessHandleCount, ULONG_PTR SystemHandleCount);
typedef VOID (*DELETE_METHOD_VISTA)(PVOID Object);
typedef NTSTATUS (*PARSE_METHOD_VISTA)(PVOID ParseObject, PVOID ObjectType, PACCESS_STATE AccessState, KPROCESSOR_MODE AccessMode, ULONG32 Attributes, PUNICODE_STRING CompleteName, PUNICODE_STRING RemainingName, PVOID Context, PSECURITY_QUALITY_OF_SERVICE SecurityQos, PVOID *Object);
typedef NTSTATUS (*SECURITY_METHOD_VISTA)(PVOID Object, SECURITY_OPERATION_CODE OperationCode, PSECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG32 CapturedLength, PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, POOL_TYPE PoolType, PGENERIC_MAPPING GenericMapping, KPROCESSOR_MODE AccessMode);
typedef NTSTATUS (*QUERYNAME_METHOD_VISTA)(PVOID Object, BOOLEAN HasObjectName, POBJECT_NAME_INFORMATION ObjectNameInfo, ULONG32 Length, PULONG32 ReturnLength, KPROCESSOR_MODE AccessMode);

// Definice struktury OBJECT_TYPE_INITIALIZER. Vyznam jednotlivych clenu najdete
// u implementace funkci v souboru object_initializer.c a v souboru object_initializer.h
typedef struct 
{
  USHORT  Length;    
  union 
  { 
    UCHAR ObjectTypeFlags;
    struct {
      UINT8 CaseInsensitive : 1;                  
      UINT8 UnnamedObjectsOnly : 1; 
      UINT8 UseDefaultObject : 1;
      UINT8 SecurityRequired : 1;               
      UINT8 MaintainHandleCount : 1;                  
      UINT8 MaintainTypeList : 1;               
      UINT8 SupportsObjectCallbacks : 1;                 
    } ObjectFlags;
  }; 
                                                                         
  ULONG32 ObjectTypeCode;
  ULONG32 InvalidAttributes;
  ULONG32 GenericMapping [4];                          
  ULONG32 ValidAccessMask;
  ULONG32 RetainAccess;
  POOL_TYPE PoolType;
  ULONG32 DefaultPagedPoolCharge;
  ULONG32 DefaultNonPagedPoolCharge;
  DUMP_METHOD_VISTA DumpProcedure;
  OPEN_METHOD_VISTA OpenProcedure;
  CLOSE_METHOD_VISTA CloseProcedure;
  DELETE_METHOD_VISTA DeleteProcedure;                            
  PARSE_METHOD_VISTA ParseProcedure;
  SECURITY_METHOD_VISTA SecurityProcedure;
  QUERYNAME_METHOD_VISTA QueryNameProcedure;                                    OKAYTOCLOSE_METHOD_VISTA OkayToCloseProcedure;
} OBJECT_TYPE_INITIALIZER_VISTA, *POBJECT_TYPE_INITIALIZER_VISTA;

// Makra slouzici k "vytahnuti" dulezitych clenu struktury OBJECTy_TYPE_INITIALIZER

#define OTIVistaCaseInsensitive(a)             ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.CaseInsensitive
#define OTIVistaUnnamedObjectsOnly(a)          ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.UnnamedObjectsOnly
#define OTIVistaUseDefaultObject(a)            ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.UseDefaultObject
#define OTIVistaSecurityRequired(a)            ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.SecurityRequired
#define OTIVistaMaintainHandleCount(a)         ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.MaintainHandleCount
#define OTIVistaMaintainTypeList(a)            ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.MaintainTypeList
#define OTIVistaSupportsObjectCallbacks(a)     ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectFlags.SupportsObjectCallbacks

#define OTIVistaObjectTypeCode(a)              ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ObjectTypeCode
#define OTIVistaInvalidAttributes(a)           ((POBJECT_TYPE_INITIALIZER_VISTA)a)->InvalidAttributes
#define OTIVistaValidAccessMask(a)             ((POBJECT_TYPE_INITIALIZER_VISTA)a)->ValidAccessMask
#define OTIVistaRetainAccess(a)                ((POBJECT_TYPE_INITIALIZER_VISTA)a)->RetainAccess
#define OTIVistaPoolType(a)                    ((POBJECT_TYPE_INITIALIZER_VISTA)a)->PoolType
#define OTIVistaDefaultPagedPoolCharge(a)      ((POBJECT_TYPE_INITIALIZER_VISTA)a)->DefaultPagedPoolCharge
#define OTIVistaDefaultNonPagedPoolCharge(a)   ((POBJECT_TYPE_INITIALIZER_VISTA)a)->DefaultNonPagedPoolCharge
#define OTIVistaDumpProcedure(a)               (DUMP_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->DumpProcedure
#define OTIVistaOpenProcedure(a)               (OPEN_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->OpenProcedure
#define OTIVistaCloseProcedure(a)              (CLOSE_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->CloseProcedure
#define OTIVistaOkayToCloseProcedure(a)        (OKAYTOCLOSE_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->OkayToCloseProcedure
#define OTIVistaDeleteProcedure(a)             (DELETE_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->DeleteProcedure
#define OTIVistaParseProcedure(a)              (PARSE_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->ParseProcedure
#define OTIVistaSecurityProcedure(a)           (SECURITY_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->SecurityProcedure
#define OTIVistaQueryNameProcedure(a)          (QUERYNAME_METHOD_VISTA)((POBJECT_TYPE_INITIALIZER_VISTA)a)->QueryNameProcedure

#endif
