Annotation of truecrypt/driver/ntfiledv.c, revision 1.1

1.1     ! root        1: /* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
        !             2:    This product uses components written by Paul Le Roux <[email protected]> */
        !             3: 
        !             4: #include "TCdefs.h"
        !             5: #include "crypto.h"
        !             6: #include "fat.h"
        !             7: #include "volumes.h"
        !             8: 
        !             9: #include "apidrvr.h"
        !            10: #include "ntdriver.h"
        !            11: #include "ntvol.h"
        !            12: #include "ntfiledv.h"
        !            13: 
        !            14: #pragma warning( disable : 4127 )
        !            15: 
        !            16: TCSendIRP_FileDevice (PDEVICE_OBJECT DeviceObject,
        !            17:                       PEXTENSION Extension,
        !            18:                       PVOID pUserBuffer,
        !            19:                       ULONG uFlags,
        !            20:                       UCHAR uMajorFunction,
        !            21:                       PIRP Irp)
        !            22: {
        !            23:        PIO_STACK_LOCATION irpOldSp;
        !            24:        NTSTATUS ntStatus;
        !            25:        PIRP NewIrp;
        !            26: 
        !            27: //     Dump ("Sending IRP...\n");
        !            28: 
        !            29:        NewIrp = IoAllocateIrp ((CCHAR) (Extension->pFsdDevice->StackSize + 1), FALSE);
        !            30: 
        !            31:        irpOldSp = IoGetCurrentIrpStackLocation (Irp);
        !            32: 
        !            33:        if (NewIrp != NULL)
        !            34:        {
        !            35:                PIO_STACK_LOCATION irpSp, irpNextSp;
        !            36: 
        !            37:                NewIrp->UserEvent = NULL;
        !            38:                NewIrp->UserIosb = &Irp->IoStatus;
        !            39: 
        !            40:                /* Doc's say to copy the Tail.Overlay.Thread from the
        !            41:                   original Irp but if I do this the user is not prompted on
        !            42:                   media removed and other user conditions! */
        !            43:                NewIrp->Tail.Overlay.Thread = PsGetCurrentThread ();
        !            44:                NewIrp->Tail.Overlay.OriginalFileObject = Extension->pfoDeviceFile;
        !            45:                NewIrp->RequestorMode = KernelMode;
        !            46: 
        !            47:                NewIrp->Flags = uFlags;
        !            48: 
        !            49:                NewIrp->AssociatedIrp.SystemBuffer = NULL;
        !            50:                NewIrp->MdlAddress = NULL;
        !            51:                NewIrp->UserBuffer = pUserBuffer;
        !            52: 
        !            53:                IoSetNextIrpStackLocation (NewIrp);
        !            54: 
        !            55:                irpSp = IoGetCurrentIrpStackLocation (NewIrp);
        !            56:                irpNextSp = IoGetNextIrpStackLocation (NewIrp);
        !            57: 
        !            58:                irpSp->DeviceObject = DeviceObject;
        !            59:                irpSp->FileObject = Extension->pfoDeviceFile;
        !            60: 
        !            61:                irpNextSp->MajorFunction = irpSp->MajorFunction = uMajorFunction;
        !            62:                irpNextSp->MinorFunction = irpSp->MinorFunction = irpSp->MinorFunction;
        !            63:                irpNextSp->DeviceObject = Extension->pFsdDevice;
        !            64:                irpNextSp->FileObject = Extension->pfoDeviceFile;
        !            65:                /* Copy our flags down one level, this is to get the proper
        !            66:                   removable-media handling */
        !            67:                irpNextSp->Flags = irpSp->Flags = irpOldSp->Flags;
        !            68:                /* Copy over io parameters, this is a union, so it handles
        !            69:                   deviceiocontrol & read/write */
        !            70:                irpNextSp->Parameters.Read.Length = irpSp->Parameters.Read.Length = irpOldSp->Parameters.Read.Length;
        !            71:                irpNextSp->Parameters.Read.ByteOffset = irpSp->Parameters.Read.ByteOffset = irpOldSp->Parameters.Read.ByteOffset;
        !            72:                irpNextSp->Parameters.Read.Key = irpSp->Parameters.Read.Key = irpOldSp->Parameters.Read.Key;
        !            73:        }
        !            74:        else
        !            75:        {
        !            76:                TCfree (pUserBuffer);   /* Free the temp buffer we allocated
        !            77:                                           for the IRP */
        !            78: 
        !            79:                /* Complete the processing of the original Irp */
        !            80:                return COMPLETE_IRP (DeviceObject, Irp, STATUS_INSUFFICIENT_RESOURCES, 0);
        !            81:        }
        !            82: 
        !            83:        IoSetCompletionRoutine (NewIrp, TCCompletion, Irp, TRUE, TRUE, TRUE);
        !            84: 
        !            85:        ntStatus = IoCallDriver (Extension->pFsdDevice, NewIrp);
        !            86:        //if (ntStatus == STATUS_PENDING)
        !            87:        //{
        !            88:        //      Dump ("Pending returned!\n");
        !            89:        //}
        !            90: 
        !            91: //     Dump ("IRP Sent!\n");
        !            92:        return ntStatus;
        !            93: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.