예제 #1
0
        public void SetCreateFlags(CreateFlags createFlags)
        {
            if (this.MajorFunction != MajorFunction.IRP_MJ_CREATE)
                throw new ExceptionIoFlow("SetCreateFlags: IRP is not of type IRP_MJ_CREATE.");
            if (this.IsPostOp)
                throw new ExceptionIoFlow("SetCreateFlags: invalid on PostOp callback.");

            bool wasRead = ((Flags & (uint)HeaderFlags.HeaderFlagCrShareRead) != 0 ? true : false);
            bool wasWrite = ((Flags & (uint)HeaderFlags.HeaderFlagCrShareWrite) != 0 ? true : false);
            if (wasRead != createFlags.FILE_SHARE_READ || wasWrite != createFlags.FILE_SHARE_WRITE)
            {
                if (wasRead && !createFlags.FILE_SHARE_READ)
                    Flags &= ~(uint)HeaderFlags.HeaderFlagCrShareRead;
                if (!wasRead && createFlags.FILE_SHARE_READ)
                    Flags |= (uint)HeaderFlags.HeaderFlagCrShareRead;
                if (wasWrite && !createFlags.FILE_SHARE_WRITE)
                    Flags &= ~(uint)HeaderFlags.HeaderFlagCrShareWrite;
                if (!wasWrite && createFlags.FILE_SHARE_WRITE)
                    Flags |= (uint)HeaderFlags.HeaderFlagCrShareWrite;
                Flags |= (uint)HeaderFlags.HeaderFlagIsIrpModified;
            }
        }