
/**
 * @file: object_initializer_w2k.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 2000.
 */

#ifndef __OBJECT_INITIALIZER_W2K_H_
#define __OBJECT_INITIALIZER_W2K_H_

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

// Definice (virtualnich) metod
typedef VOID (*DUMP_METHOD_W2K)(PVOID Object, PDUMP_CONTROL Control);
typedef NTSTATUS (*OPEN_METHOD_W2K)(OPEN_REASON OpenReason, PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG32 HandleCount);
typedef BOOLEAN (*OKAYTOCLOSE_METHOD_W2K)(PEPROCESS Process, PVOID Object, HANDLE Handle);
typedef VOID (*CLOSE_METHOD_W2K)(PEPROCESS Process, PVOID Object, ACCESS_MASK GrantedAccess, ULONG_PTR ProcessHandleCount, ULONG_PTR SystemHandleCount);
typedef VOID (*DELETE_METHOD_W2K)(PVOID Object);
typedef NTSTATUS (*PARSE_METHOD_W2K)(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_W2K)(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_W2K)(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 Reserved;
  ULONG32 InvalidAttributes;
  ULONG32 GenericMapping[4];
  ULONG32 ValidAccessMask;
  UCHAR SecurityRequired;
  UCHAR MaintainHandleCount;
  UCHAR MaintainTypeList;
  UCHAR _PADDING0_[0x1];
  POOL_TYPE PoolType;
  ULONG32 DefaultPagedPoolCharge;
  ULONG32 DefaultNonPagedPoolCharge;
  DUMP_METHOD_W2K DumpProcedure;
  OPEN_METHOD_W2K OpenProcedure;
  CLOSE_METHOD_W2K CloseProcedure;
  DELETE_METHOD_W2K DeleteProcedure;
  PARSE_METHOD_W2K ParseProcedure;
  SECURITY_METHOD_W2K SecurityProcedure;
  QUERYNAME_METHOD_W2K QueryNameProcedure;
  OKAYTOCLOSE_METHOD_W2K OkayToCloseProcedure;
} OBJECT_TYPE_INITIALIZER_W2K, *POBJECT_TYPE_INITIALIZER_W2K;

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

#define OTIW2KUseDefaultObject(a)              ((POBJECT_TYPE_INITIALIZER_W2K)a)->UseDefaultObject
#define OTIW2KSecurityRequired(a)              ((POBJECT_TYPE_INITIALIZER_W2K)a)->SecurityRequired
#define OTIW2KMaintainHandleCount(a)           ((POBJECT_TYPE_INITIALIZER_W2K)a)->MaintainHandleCount
#define OTIW2KMaintainTypeList(a) (            (POBJECT_TYPE_INITIALIZER_W2K)a)->MaintainTypeList

#define OTIW2KInvalidAttributes(a)             ((POBJECT_TYPE_INITIALIZER_W2K)a)->InvalidAttributes
#define OTIW2KValidAccessMask(a)               ((POBJECT_TYPE_INITIALIZER_W2K)a)->ValidAccessMask
#define OTIW2KRetainAccess(a)                  ((POBJECT_TYPE_INITIALIZER_W2K)a)->RetainAccess
#define OTIW2KPoolType(a)                      ((POBJECT_TYPE_INITIALIZER_W2K)a)->PoolType
#define OTIW2KDefaultPagedPoolCharge(a)        ((POBJECT_TYPE_INITIALIZER_W2K)a)->DefaultPagedPoolCharge
#define OTIW2KDefaultNonPagedPoolCharge(a)     ((POBJECT_TYPE_INITIALIZER_W2K)a)->DefaultNonPagedPoolCharge
#define OTIW2KDumpProcedure(a)                 (DUMP_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->DumpProcedure
#define OTIW2KOpenProcedure(a)                 (OPEN_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->OpenProcedure
#define OTIW2KCloseProcedure(a)                (CLOSE_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->CloseProcedure
#define OTIW2KOkayToCloseProcedure(a)          (OKAYTOCLOSE_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->OkayToCloseProcedure
#define OTIW2KDeleteProcedure(a)               (DELETE_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->DeleteProcedure
#define OTIW2KParseProcedure(a)                (PARSE_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->ParseProcedure
#define OTIW2KSecurityProcedure(a)             (SECURITY_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->SecurityProcedure
#define OTIW2KQueryNameProcedure(a)            (QUERYNAME_METHOD_W2K)((POBJECT_TYPE_INITIALIZER_W2K)a)->QueryNameProcedure


#endif
