Beispiel #1
0
VOID
NTAPI
NpCancelListeningQueueIrp(IN PDEVICE_OBJECT DeviceObject,
                          IN PIRP Irp)
{
    IoReleaseCancelSpinLock(Irp->CancelIrql);

    FsRtlEnterFileSystem();
    NpAcquireExclusiveVcb();

    RemoveEntryList(&Irp->Tail.Overlay.ListEntry);

    FsRtlExitFileSystem();
    NpReleaseVcb();

    Irp->IoStatus.Status = STATUS_CANCELLED;
    IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
}
Beispiel #2
0
NTSTATUS
NTAPI
NpFsdQuerySecurityInfo(IN PDEVICE_OBJECT DeviceObject,
                       IN PIRP Irp)
{
    NTSTATUS Status;
    PAGED_CODE();

    FsRtlEnterFileSystem();
    NpAcquireExclusiveVcb();

    Status = NpCommonQuerySecurityInfo(DeviceObject, Irp);

    NpReleaseVcb();
    FsRtlExitFileSystem();

    if (Status != STATUS_PENDING)
    {
        Irp->IoStatus.Status = Status;
        IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
    }

    return Status;
}
Beispiel #3
0
NTSTATUS
NpFsdSetInformation (
    IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
    IN PIRP Irp
    )

/*++

Routine Description:

    This routine implements the FSD part of the NtSetInformationFile API
    calls.

Arguments:

    NpfsDeviceObject - Supplies the device object to use.

    Irp - Supplies the Irp being processed

Return Value:

    NTSTATUS - The Fsd status for the Irp

--*/

{
    NTSTATUS Status;

    PAGED_CODE();

    DebugTrace(+1, Dbg, "NpFsdSetInformation\n", 0);

    //
    //  Call the common Set Information routine.
    //

    FsRtlEnterFileSystem();

    NpAcquireExclusiveVcb();

    try {

        Status = NpCommonSetInformation( NpfsDeviceObject, Irp );

    } except(NpExceptionFilter( GetExceptionCode() )) {

        //
        //  We had some trouble trying to perform the requested
        //  operation, so we'll abort the I/O request with
        //  the error status that we get back from the
        //  execption code
        //

        Status = NpProcessException( NpfsDeviceObject, Irp, GetExceptionCode() );
    }

    NpReleaseVcb();

    FsRtlExitFileSystem();

    //
    //  And return to our caller
    //

    DebugTrace(-1, Dbg, "NpFsdSetInformation -> %08lx\n", Status );

    return Status;
}
Beispiel #4
0
NTSTATUS
NpCommonClose (
    IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
    IN PIRP Irp
    )

/*++

Routine Description:

    This is the common routine for creating/opening a file.

Arguments:

    Irp - Supplies the Irp to process

Return Value:

    NTSTATUS - the return status for the operation

--*/

{
    NTSTATUS Status;

    PIO_STACK_LOCATION IrpSp;

    NODE_TYPE_CODE NodeTypeCode;
    PFCB Fcb;
    PCCB Ccb;

    PAGED_CODE();

    //
    //  Get the current stack location
    //

    IrpSp = IoGetCurrentIrpStackLocation( Irp );

    DebugTrace(+1, Dbg, "NpCommonClose...\n", 0);
    DebugTrace( 0, Dbg, " Irp                    = %08lx\n", Irp);

    //
    //  Now acquire exclusive access to the vcb
    //

    NpAcquireExclusiveVcb();

    try {

        //
        //  Decode the file object to figure out who we are.  If the result
        //  is null then the pipe has been disconnected.
        //

        if ((NodeTypeCode = NpDecodeFileObject( IrpSp->FileObject,
                                                &Fcb,
                                                &Ccb,
                                                NULL )) == NTC_UNDEFINED) {

            DebugTrace(0, Dbg, "Pipe is disconnected from us\n", 0);

            NpCompleteRequest( Irp, STATUS_PIPE_DISCONNECTED );
            try_return( Status = STATUS_PIPE_DISCONNECTED );
        }

        //
        //  Now case on the type of file object we're closing
        //

        switch (NodeTypeCode) {

        case NPFS_NTC_VCB:

            //
            //  Decrement the Open count and clear our fields in the file object
            //

            NpVcb->OpenCount -= 1;
            NpSetFileObject( IrpSp->FileObject, NULL, NULL, FILE_PIPE_SERVER_END );

            break;

        case NPFS_NTC_ROOT_DCB:

            //
            //  Decrement the Open count and clear our fields in the file object
            //

            Fcb->OpenCount -= 1;
            NpSetFileObject( IrpSp->FileObject, NULL, NULL, FILE_PIPE_SERVER_END );

            //
            //  Remove the root dcb ccb.
            //

            NpDeleteCcb( Ccb );

            break;

        case NPFS_NTC_CCB:

            break;
        }

        //
        //  Complete the close irp
        //

        NpCompleteRequest( Irp, STATUS_SUCCESS );

        Status = STATUS_SUCCESS;

    try_exit: NOTHING;
    } finally {

        NpReleaseVcb( );
    }

    DebugTrace(-1, Dbg, "NpCommonClose -> %08lx\n", Status);
    return Status;
}
Beispiel #5
0
VOID
NTAPI
NpCancelDataQueueIrp(IN PDEVICE_OBJECT DeviceObject,
                     IN PIRP Irp)
{
    PNP_DATA_QUEUE DataQueue;
    PNP_DATA_QUEUE_ENTRY DataEntry;
    LIST_ENTRY DeferredList;
    PSECURITY_CLIENT_CONTEXT ClientSecurityContext;
    BOOLEAN CompleteWrites, FirstEntry;

    if (DeviceObject) IoReleaseCancelSpinLock(Irp->CancelIrql);

    InitializeListHead(&DeferredList);

    DataQueue = Irp->Tail.Overlay.DriverContext[2];
    ClientSecurityContext = NULL;

    if (DeviceObject)
    {
        FsRtlEnterFileSystem();
        NpAcquireExclusiveVcb();
    }

    DataEntry = Irp->Tail.Overlay.DriverContext[3];
    if (DataEntry)
    {
        if (DataEntry->QueueEntry.Blink == &DataQueue->Queue)
        {
            DataQueue->ByteOffset = 0;
            FirstEntry = TRUE;
        }
        else
        {
            FirstEntry = FALSE;
        }

        RemoveEntryList(&DataEntry->QueueEntry);

        ClientSecurityContext = DataEntry->ClientSecurityContext;

        CompleteWrites = TRUE;
        if (DataQueue->QueueState != WriteEntries ||
            DataQueue->QuotaUsed < DataQueue->Quota ||
            !DataEntry->QuotaInEntry)
        {
            CompleteWrites = FALSE;
        }

        DataQueue->BytesInQueue -= DataEntry->DataSize;
        DataQueue->QuotaUsed -= DataEntry->QuotaInEntry;
        --DataQueue->EntriesInQueue;

        if (IsListEmpty(&DataQueue->Queue))
        {
            DataQueue->QueueState = Empty;
            ASSERT(DataQueue->BytesInQueue == 0);
            ASSERT(DataQueue->EntriesInQueue == 0);
            ASSERT(DataQueue->QuotaUsed == 0);
        }
        else
        {
            if (FirstEntry)
            {
                NpGetNextRealDataQueueEntry(DataQueue, &DeferredList);
            }
            if (CompleteWrites)
            {
                NpCompleteStalledWrites(DataQueue, &DeferredList);
            }
        }
    }

    if (DeviceObject)
    {
        NpReleaseVcb();
        FsRtlExitFileSystem();
    }

    if (DataEntry) ExFreePool(DataEntry);

    NpFreeClientSecurityContext(ClientSecurityContext);
    Irp->IoStatus.Status = STATUS_CANCELLED;
    IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);

    NpCompleteDeferredIrps(&DeferredList);
}
Beispiel #6
0
NTSTATUS
NpFsdDirectoryControl (
    IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
    IN PIRP Irp
    )

/*++

Routine Description:

    This routine is the FSD routine that handles directory control
    functions (i.e., query and notify).

Arguments:

    NpfsDeviceObject - Supplies the device object for the directory function.

    Irp - Supplies the IRP to process

Return Value:

    NTSTATUS - The appropriate result status

--*/

{
    NTSTATUS Status;

    PAGED_CODE();

    DebugTrace(+1, Dbg, "NpFsdDirectoryControl\n", 0);

    //
    //  Call the common Direcotry Control routine.
    //

    FsRtlEnterFileSystem();
    NpAcquireExclusiveVcb( );

    try {

        Status = NpCommonDirectoryControl( NpfsDeviceObject, Irp );

    } except(NpExceptionFilter( GetExceptionCode() )) {

        //
        //  We had some trouble trying to perform the requested
        //  operation, so we'll abort the I/O request with
        //  the error status that we get back from the
        //  execption code
        //

        Status = NpProcessException( NpfsDeviceObject, Irp, GetExceptionCode() );
    }

    NpReleaseVcb();
    FsRtlExitFileSystem();

    //
    //  And return to our caller
    //

    DebugTrace(-1, Dbg, "NpFsdDirectoryControl -> %08lx\n", Status );

    return Status;
}