
/**
 * @file: object_initializer_w2k3.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 Server 2003.
 */

#ifndef __OBJECT_INITIALIZER_W2K3_H_
#define __OBJECT_INITIALIZER_W2K3_H_

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

// Definice (virtualnich) metod
typedef VOID (*DUMP_METHOD_W2K3)(PVOID Object, PDUMP_CONTROL Control);
typedef NTSTATUS (*OPEN_METHOD_W2K3)(OPEN_REASON OpenReason, PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG32 HandleCount);
typedef BOOLEAN (*OKAYTOCLOSE_METHOD_W2K3)(PEPROCESS Process, PVOID Object, HANDLE Handle, KPROCESSOR_MODE PreviousMode);
typedef VOID (*CLOSE_METHOD_W2K3)(PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG_PTR ProcessHandleCount, ULONG_PTR SystemHandleCount);
typedef VOID (*DELETE_METHOD_W2K3)(PVOID Object);
typedef NTSTATUS (*PARSE_METHOD_W2K3)(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_W2K3)(PVOID Object, SECURITY_OPERATION_CODE OperationCode, PSECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG32 CapturedLength, PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, POOL_TYPE PoolType, PGENERIC_MAPPING GenericMapping);
typedef NTSTATUS (*QUERYNAME_METHOD_W2K3)(PVOID Object, BOOLEAN HasObjectName, POBJECT_NAME_INFORMATION ObjectNameInfo, ULONG32 Length, PULONG32 ReturnLength, KPROCESSOR_MODE Mode);


// 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;                                                                                                                                                                                
  ULONG32 GenericMapping[4]; 
  ULONG32 ValidAccessMask;                                                                                                                                                                                  
  UCHAR SecurityRequired;                                                                                                                                                                                 
  UCHAR MaintainHandleCount;                                                                                                                                                                              
  UCHAR MaintainTypeList;                                                                                                                                                                                 
  UCHAR Padding;                                                                                                                                                                                
  POOL_TYPE PoolType;                                                                                                                                                                                      
  ULONG32 DefaultPagedPoolCharge;                                                                                                                                                                           
  ULONG32 DefaultNonPagedPoolCharge;                                                                                                                                                                        
  DUMP_METHOD_W2K3 DumpProcedure;                                                                                                                                                                  
  OPEN_METHOD_W2K3 OpenProcedure;                                                                                                                                                                  
  CLOSE_METHOD_W2K3 CloseProcedure;                                                                                                                                                                
  DELETE_METHOD_W2K3 DeleteProcedure;                                     
  PARSE_METHOD_W2K3 ParseProcedure;                                                                                                                                                                
  SECURITY_METHOD_W2K3 SecurityProcedure;                                                                                                                                                          
  QUERYNAME_METHOD_W2K3 QueryNameProcedure;                                                                                                                                                        
  OKAYTOCLOSE_METHOD_W2K3 OkayToCloseProcedure;  
} OBJECT_TYPE_INITIALIZER_W2K3, *POBJECT_TYPE_INITIALIZER_W2K3;

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

#define OTIW2K3CaseInsensitive(a)              ((POBJECT_TYPE_INITIALIZER_W2K3)a)->CaseInsensitive
#define OTIW2K3UseDefaultObject(a)             ((POBJECT_TYPE_INITIALIZER_W2K3)a)->UseDefaultObject
#define OTIW2K3SecurityRequired(a)             ((POBJECT_TYPE_INITIALIZER_W2K3)a)->SecurityRequired
#define OTIW2K3MaintainHandleCount(a)          ((POBJECT_TYPE_INITIALIZER_W2K3)a)->MaintainHandleCount
#define OTIW2K3MaintainTypeList(a)             ((POBJECT_TYPE_INITIALIZER_W2K3)a)->MaintainTypeList

#define OTIW2K3InvalidAttributes(a)            ((POBJECT_TYPE_INITIALIZER_W2K3)a)->InvalidAttributes
#define OTIW2K3ValidAccessMask(a)              ((POBJECT_TYPE_INITIALIZER_W2K3)a)->ValidAccessMask
#define OTIW2K3PoolType(a)                     ((POBJECT_TYPE_INITIALIZER_W2K3)a)->PoolType
#define OTIW2K3DefaultPagedPoolCharge(a)       ((POBJECT_TYPE_INITIALIZER_W2K3)a)->DefaultPagedPoolCharge
#define OTIW2K3DefaultNonPagedPoolCharge(a)    ((POBJECT_TYPE_INITIALIZER_W2K3)a)->DefaultNonPagedPoolCharge
#define OTIW2K3DumpProcedure(a)                (DUMP_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->DumpProcedure
#define OTIW2K3OpenProcedure(a)                (OPEN_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->OpenProcedure
#define OTIW2K3CloseProcedure(a)               (CLOSE_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->CloseProcedure
#define OTIW2K3OkayToCloseProcedure(a)         (OKAYTOCLOSE_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->OkayToCloseProcedure
#define OTIW2K3DeleteProcedure(a)              (DELETE_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->DeleteProcedure
#define OTIW2K3ParseProcedure(a)               (PARSE_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->ParseProcedure
#define OTIW2K3SecurityProcedure(a)            (SECURITY_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->SecurityProcedure
#define OTIW2K3QueryNameProcedure(a)           (QUERYNAME_METHOD_W2K3)((POBJECT_TYPE_INITIALIZER_W2K3)a)->QueryNameProcedure

#endif
