示例#1
0
NTSTATUS
DebugInitialize(
    IN  PXENBUS_FDO                     Fdo,
    OUT PXENBUS_DEBUG_INTERFACE         Interface
    )
{
    PXENBUS_DEBUG_CONTEXT               Context;
    NTSTATUS                            status;

    UNREFERENCED_PARAMETER(Fdo);

    Trace("====>\n");

    Context = __DebugAllocate(sizeof (XENBUS_DEBUG_CONTEXT));

    status = STATUS_NO_MEMORY;
    if (Context == NULL)
        goto fail1;

    InitializeListHead(&Context->List);
    InitializeHighLock(&Context->Lock);

    KeInitializeCallbackRecord(&Context->BugCheckCallbackRecord);

    status = STATUS_UNSUCCESSFUL;
    if (!KeRegisterBugCheckCallback(&Context->BugCheckCallbackRecord,
                                    DebugBugCheckCallback,
                                    Context,
                                    sizeof (XENBUS_DEBUG_CONTEXT),
                                    (PUCHAR)__MODULE__))
        goto fail2;

    Interface->Context = Context;
    Interface->Operations = &Operations;

    Trace("<====\n");

    return STATUS_SUCCESS;

fail2:
    Error("fail2\n");

    RtlZeroMemory(&Context->Lock, sizeof (KSPIN_LOCK));
    RtlZeroMemory(&Context->List, sizeof (LIST_ENTRY));

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}
示例#2
0
NTSTATUS
UnplugInitialize(
    OUT PXENFILT_UNPLUG_INTERFACE   Interface
    )
{
    PXENFILT_UNPLUG_CONTEXT         Context;
    ULONG                           References;
    NTSTATUS                        status;

    Trace("====>\n");

    Context = &UnplugContext;

    References = InterlockedIncrement(&Context->References);
    if (References > 1)
        goto done;

    InitializeHighLock(&Context->Lock);

    __UnplugGetFlags(Context);

    status = __UnplugPreamble(Context, FALSE);
    if (!NT_SUCCESS(status))
        goto fail1;

    __UnplugDisks(Context);
    __UnplugNics(Context);

done:
    Interface->Context = Context;
    Interface->Operations = &Operations;

    Trace("<====\n");

    return STATUS_SUCCESS;

fail1:
    Error("fail1 (%08x)\n", status);

    RtlZeroMemory(&Context->Lock, sizeof (HIGH_LOCK));
    Context->BootEmulated = FALSE;

    (VOID) InterlockedDecrement(&Context->References);

    return status;
}