Пример #1
0
VOID EtInitializeDiskInformation(
    VOID
    )
{
    LARGE_INTEGER performanceCounter;

    EtDiskItemType = PhCreateObjectType(L"DiskItem", 0, EtpDiskItemDeleteProcedure);
    EtDiskHashtable = PhCreateHashtable(
        sizeof(PET_DISK_ITEM),
        EtpDiskHashtableEqualFunction,
        EtpDiskHashtableHashFunction,
        128
        );
    InitializeListHead(&EtDiskAgeListHead);

    PhInitializeFreeList(&EtDiskPacketFreeList, sizeof(ETP_DISK_PACKET), 64);
    RtlInitializeSListHead(&EtDiskPacketListHead);
    EtFileNameHashtable = PhCreateSimpleHashtable(128);

    NtQueryPerformanceCounter(&performanceCounter, &EtpPerformanceFrequency);

    EtDiskEnabled = TRUE;

    // Collect all existing file names.
    EtStartEtwRundown();

    PhRegisterCallback(
        &PhProcessesUpdatedEvent,
        ProcessesUpdatedCallback,
        NULL,
        &ProcessesUpdatedCallbackRegistration
        );
}
Пример #2
0
VOID PhWorkQueueInitialization(
    VOID
    )
{
    PhInitializeFreeList(&PhWorkQueueItemFreeList, sizeof(PH_WORK_QUEUE_ITEM), 32);

#ifdef DEBUG
    PhDbgWorkQueueList = PhCreateList(4);
#endif
}
Пример #3
0
/**
 * Initializes the object manager module.
 */
NTSTATUS PhInitializeRef(
    VOID
    )
{
    NTSTATUS status = STATUS_SUCCESS;
    PH_OBJECT_TYPE dummyObjectType;

#ifdef DEBUG
    InitializeListHead(&PhDbgObjectListHead);
#endif

    PhInitializeFreeList(
        &PhObjectSmallFreeList,
        PhpAddObjectHeaderSize(PHOBJ_SMALL_OBJECT_SIZE),
        PHOBJ_SMALL_OBJECT_COUNT
        );

    // Create the fundamental object type.

    memset(&dummyObjectType, 0, sizeof(PH_OBJECT_TYPE));
    PhObjectTypeObject = &dummyObjectType; // PhCreateObject expects an object type.

    status = PhCreateObjectType(
        &PhObjectTypeObject,
        L"Type",
        0,
        NULL
        );

    if (!NT_SUCCESS(status))
        return status;

    // Now that the fundamental object type exists, fix it up.
    PhObjectToObjectHeader(PhObjectTypeObject)->Type = PhObjectTypeObject;
    PhObjectTypeObject->NumberOfObjects = 1;

    // Create the allocated memory object type.
    status = PhCreateObjectType(
        &PhAllocType,
        L"Alloc",
        0,
        NULL
        );

    if (!NT_SUCCESS(status))
        return status;

    // Reserve a slot for the auto pool.
    PhpAutoPoolTlsIndex = TlsAlloc();

    if (PhpAutoPoolTlsIndex == TLS_OUT_OF_INDEXES)
        return STATUS_INSUFFICIENT_RESOURCES;

    return status;
}
Пример #4
0
/**
 * Creates an object type.
 *
 * \param ObjectType A variable which receives a pointer to the newly
 * created object type.
 * \param Name The name of the type.
 * \param Flags A combination of flags affecting the behaviour of the
 * object type.
 * \param DeleteProcedure A callback function that is executed when
 * an object of this type is about to be freed (i.e. when its
 * reference count is 0).
 * \param Parameters A structure containing additional parameters
 * for the object type.
 *
 * \remarks Do not reference or dereference the object type once it
 * is created.
 */
NTSTATUS PhCreateObjectTypeEx(
    __out PPH_OBJECT_TYPE *ObjectType,
    __in PWSTR Name,
    __in ULONG Flags,
    __in_opt PPH_TYPE_DELETE_PROCEDURE DeleteProcedure,
    __in_opt PPH_OBJECT_TYPE_PARAMETERS Parameters
    )
{
    NTSTATUS status = STATUS_SUCCESS;
    PPH_OBJECT_TYPE objectType;

    /* Check the flags. */
    if ((Flags & PHOBJTYPE_VALID_FLAGS) != Flags) /* Valid flag mask */
        return STATUS_INVALID_PARAMETER_3;
    if ((Flags & PHOBJTYPE_USE_FREE_LIST) && !Parameters)
        return STATUS_INVALID_PARAMETER_MIX;

    /* Create the type object. */
    status = PhCreateObject(
        &objectType,
        sizeof(PH_OBJECT_TYPE),
        0,
        PhObjectTypeObject
        );

    if (!NT_SUCCESS(status))
        return status;

    /* Initialize the type object. */
    objectType->Flags = Flags;
    objectType->DeleteProcedure = DeleteProcedure;
    objectType->Name = Name;
    objectType->NumberOfObjects = 0;

    if (Parameters)
    {
        if (Flags & PHOBJTYPE_USE_FREE_LIST)
        {
            PhInitializeFreeList(
                &objectType->FreeList,
                PhpAddObjectHeaderSize(Parameters->FreeListSize),
                Parameters->FreeListCount
                );
        }
    }

    *ObjectType = objectType;

    return status;
}