Ejemplo n.º 1
0
NTSTATUS
BcInitialize (
    VOID
    )
{
    NTSTATUS Status;

    Status = BlHtCreate(50, BcpHashFunction, BcpCompareKey, &BcpHashTableId);
    if (!NT_SUCCESS(Status))
    {
        goto Quickie;
    }

    BcpBlockAllocatorHandle = BlpMmCreateBlockAllocator();
    if (BcpBlockAllocatorHandle == -1)
    {
        Status = STATUS_UNSUCCESSFUL;
        goto Quickie;
    }

    Status = BlpIoRegisterDestroyRoutine(BcpDestroy);
    if (Status >= 0)
    {
        return Status;
    }

Quickie:
    EfiPrintf(L"Failure path not yet implemented\n");
#if 0
    if (BcpHashTableId != -1)
    {
        BlHtDestroy(BcpHashTableId);
    }
    if (BcpBlockAllocatorHandle != -1)
    {
        BlpMmDeleteBlockAllocator(BcpBlockAllocatorHandle);
    }
#endif
    return Status;
}
Ejemplo n.º 2
0
NTSTATUS
MmBapFreeBlockAllocatorTableEntry (
    _In_ PVOID Entry,
    _In_ ULONG Index
    )
{
    PBL_BLOCK_DESCRIPTOR BlockInfo = (PBL_BLOCK_DESCRIPTOR)Entry;
    NTSTATUS Status, LocalStatus;

    /* Assume success */
    Status = STATUS_SUCCESS;

    /* Check if there was at least one reference */
    if (BlockInfo->ReferenceCount > 1)
    {
        /* Try to delete the allocator */
        LocalStatus = BlpMmDeleteBlockAllocator(BlockInfo->BlockId);
        if (!NT_SUCCESS(LocalStatus))
        {
            /* Remember status on failure only */
            Status = LocalStatus;
        }
    }

    /* Now destroy the allocator's descriptor */
    LocalStatus = BlMmFreeHeap(BlockInfo);
    if (!NT_SUCCESS(LocalStatus))
    {
        /* Remember status on failure only */
        Status = LocalStatus;
    }

    /* Free the entry, and return failure, if any */
    MmBlockAllocatorTable[Index] = NULL;
    return Status;
}