
/**
 * @file: object_initializer_wxp.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 XP.
 */

#ifndef __OBJECT_INITIALIZER_WXP_H_
#define __OBJECT_INITIALIZER_WXP_H_

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

// Definice jednotlivych (virtualnich) metod
typedef VOID (*DUMP_METHOD_WXP)(PVOID Object, DUMP_CONTROL Control);
typedef NTSTATUS (*OPEN_METHOD_WXP)(OPEN_REASON OpenReason, PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG32 HandleCount);
typedef BOOLEAN (*OKAYTOCLOSE_METHOD_WXP)(PEPROCESS Process, PVOID Object, HANDLE Handle, KPROCESSOR_MODE PreviousMode);
typedef VOID (*CLOSE_METHOD_WXP)(PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG_PTR ProcessHandleCount, ULONG_PTR SystemHandleCount);
typedef VOID (*DELETE_METHOD_WXP)(PVOID Object);
typedef NTSTATUS (*PARSE_METHOD_WXP)(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_WXP)(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_WXP)(PVOID Object, BOOLEAN HasObjectName, POBJECT_NAME_INFORMATION ObjectNameInfo, ULONG32 Length, PULONG32 ReturnLength);


// 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;                                                                                                                                                                                           
  UCHAR UseDefaultObject;                                                                                                                                                                                 
  UCHAR CaseInsensitive;                                                                                                                                                                                  
  ULONG32 InvalidAttributes;                                                                                                                                                                                
  ULONG GenericMapping [4];
  ULONG32 ValidAccessMask;                                                                                                                                                                                  
  UCHAR SecurityRequired;                                                                                                                                                                                 
  UCHAR MaintainHandleCount;                                                                                                                                                                              
  UCHAR MaintainTypeList;                                                                                                                                                                                 
  UCHAR Padding;                                                                                                                                                                                  
  POOL_TYPE PoolType;                                                                                                                                                                                      
  ULONG32 DefaultPagedPoolCharge;                                                                                                                                                                           
  ULONG32 DefaultNonPagedPoolCharge;                                                                                                                                                                        
  DUMP_METHOD_WXP DumpProcedure;                                                                                                                                                                  
  OPEN_METHOD_WXP OpenProcedure;                                                                                                                                                                  
  CLOSE_METHOD_WXP CloseProcedure;                                                                                                                                                                
  DELETE_METHOD_WXP DeleteProcedure;                                     
  PARSE_METHOD_WXP ParseProcedure;                                                                                                                                                                
  SECURITY_METHOD_WXP SecurityProcedure;                                                                                                                                                          
  QUERYNAME_METHOD_WXP QueryNameProcedure;                                                                                                                                                        
  OKAYTOCLOSE_METHOD_WXP OkayToCloseProcedure;
} OBJECT_TYPE_INITIALIZER_WXP, *POBJECT_TYPE_INITIALIZER_WXP;

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

#define OTIWXPCaseInsensitive(a)              ((POBJECT_TYPE_INITIALIZER_WXP)a)->CaseInsensitive
#define OTIWXPUseDefaultObject(a)             ((POBJECT_TYPE_INITIALIZER_WXP)a)->UseDefaultObject
#define OTIWXPSecurityRequired(a)             ((POBJECT_TYPE_INITIALIZER_WXP)a)->SecurityRequired
#define OTIWXPMaintainHandleCount(a)          ((POBJECT_TYPE_INITIALIZER_WXP)a)->MaintainHandleCount
#define OTIWXPMaintainTypeList(a)             ((POBJECT_TYPE_INITIALIZER_WXP)a)->MaintainTypeList

#define OTIWXPInvalidAttributes(a)            ((POBJECT_TYPE_INITIALIZER_WXP)a)->InvalidAttributes
#define OTIWXPValidAccessMask(a)              ((POBJECT_TYPE_INITIALIZER_WXP)a)->ValidAccessMask
#define OTIWXPPoolType(a)                     ((POBJECT_TYPE_INITIALIZER_WXP)a)->PoolType
#define OTIWXPDefaultPagedPoolCharge(a)       ((POBJECT_TYPE_INITIALIZER_WXP)a)->DefaultPagedPoolCharge
#define OTIWXPDefaultNonPagedPoolCharge(a)    ((POBJECT_TYPE_INITIALIZER_WXP)a)->DefaultNonPagedPoolCharge
#define OTIWXPDumpProcedure(a)                (DUMP_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->DumpProcedure
#define OTIWXPOpenProcedure(a)                (OPEN_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->OpenProcedure
#define OTIWXPCloseProcedure(a)               (CLOSE_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->CloseProcedure
#define OTIWXPOkayToCloseProcedure(a)         (OKAYTOCLOSE_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->OkayToCloseProcedure
#define OTIWXPDeleteProcedure(a)              (DELETE_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->DeleteProcedure
#define OTIWXPParseProcedure(a)               (PARSE_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->ParseProcedure
#define OTIWXPSecurityProcedure(a)            (SECURITY_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->SecurityProcedure
#define OTIWXPQueryNameProcedure(a)           (QUERYNAME_METHOD_WXP)((POBJECT_TYPE_INITIALIZER_WXP)a)->QueryNameProcedure

#endif
