private void FsCtl_Get_IntegrityInformation_IsIntegritySupported(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: FSCTL Request with FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL Request with FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify returned NTStatus code."); if (!IsCurrentTransportSupportIntegrity(status)) { return; } if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "Integrity is supported, status set to STATUS_SUCCESS."); } }
private void AlternateDataStream_FsCtl_Get_IntegrityInformation(FileType fileType) { //Prerequisites: Create streams on a newly created file //Step 1: FSCTL Request with FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "{0}. FSCTL Request with FSCTL_GET_INTEGRITY_INFORMATION.", ++testStep); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 2: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "{0}. Verify returned NTStatus code.", ++testStep); if (this.fsaAdapter.Transport == Transport.SMB) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.NOT_SUPPORTED, status, "This operation is not supported for SMB transport."); } else { if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "Integrity is supported, status set to STATUS_SUCCESS."); } } }
public static extern Boolean DeviceIoControl( SafeFileHandle hDevice, Int32 dwIoControlCode, IntPtr lpInBuffer, Int32 nInBufferSize, ref FSCTL_GET_INTEGRITY_INFORMATION_BUFFER lpOutBuffer, Int32 nOutBufferSize, out Int32 lpBytesReturned, IntPtr lpOverlapped );
private void FsCtl_Get_IntegrityInformation_OutputValue_Common(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: FSCTL Request with FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL Request with FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify test result."); // Check if Integrity is supported if (!IsCurrentTransportSupportIntegrity(status)) { return; } if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } // Check output result integrityInfo = TypeMarshal.ToStruct <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); BaseTestSite.Log.Add(LogEntryKind.Debug, "3.1. Verify OutputBuffer.CheckSumAlgorithm."); bool isCheckSumAlgorithmCorrect = FsaUtility.IsOneOfExpectedChecksumAlgorithm(integrityInfo.ChecksumAlgorithm); this.fsaAdapter.AssertAreEqual(this.Manager, true, isCheckSumAlgorithmCorrect, "The object store MUST set OutputBuffer.CheckSumAlgorithm to one of the values for ChecksumAlgorithm."); BaseTestSite.Log.Add(LogEntryKind.Debug, "3.2. Verify OutputBuffer.ClusterSizeInBytes."); BaseTestSite.Log.Add(LogEntryKind.Debug, "Expected ClusterSizeInBytes: " + (this.fsaAdapter.ClusterSizeInKB * 1024)); BaseTestSite.Log.Add(LogEntryKind.Debug, "Actual ClusterSizeInBytes: " + integrityInfo.ClusterSizeInBytes); string comment = string.Format("The default clusterSize for {0} is {1} KB.", this.fsaAdapter.FileSystem.ToString(), this.fsaAdapter.ClusterSizeInKB.ToString()); this.fsaAdapter.AssertAreEqual(this.Manager, this.fsaAdapter.ClusterSizeInKB * 1024, integrityInfo.ClusterSizeInBytes, comment); BaseTestSite.Log.Add(LogEntryKind.Debug, "3.3. Verify CHECKSUM_ENFORCEMENT_OFF flag."); bool isChecksumEnforcementSet = ((integrityInfo.Flags & FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF) != FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumEnforcementSet, "If Open.Stream.StreamType is not data stream, the object store should not set OutputBuffer.Flags to CHECKSUM_ENFORCEMENT_OFF."); }
private void FsCtl_Get_IntegrityInformation_OutputValue_ChecksumEnforcement(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType, true); //Step 2: FsCtlSetIntegrityInfo with CHECKSUM_ENFORCEMENT_OFF flag FSCTL_SET_INTEGRITY_INFORMATION_BUFFER setIntegrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); setIntegrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; setIntegrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; uint inputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(setIntegrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FsCtlSetIntegrityInfo with CHECKSUM_ENFORCEMENT_OFF flag."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(setIntegrityInfo, inputBufferSize); if (!IsCurrentTransportSupportIntegrity(status)) { return; } if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } //Step 3: FSCTL request with FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request with FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 4: Verify test result integrityInfo = TypeMarshal.ToStruct <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify CHECKSUM_ENFORCEMENT_OFF flag."); bool isChecksumEnforcementSet = ((integrityInfo.Flags & FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF) == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF); string streamType = (fileType == FileType.DataFile ? "DataStream" : "DirectoryStream"); string comment = string.Format("If Open.Stream.StreamType is {0} and Open.Stream.ChecksumEnforcementOff is TRUE, then the object store MUST set OutputBuffer.Flags to CHECKSUM_ENFORCEMENT_OFF.", streamType); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumEnforcementSet, comment); }
private void FsCtl_Get_IntegrityInformation_SystemFile(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); BaseTestSite.Log.Add(LogEntryKind.Debug, "Parameter: Set FileAttribute to SYSTEM."); status = this.fsaAdapter.CreateFile( FileAttribute.SYSTEM, fileType == FileType.DataFile ? CreateOptions.NON_DIRECTORY_FILE : CreateOptions.DIRECTORY_FILE, StreamTypeNameToOPen.NULL, FileAccess.GENERIC_READ | FileAccess.GENERIC_WRITE, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.OPEN_IF, StreamFoundType.StreamIsFound, SymbolicLinkType.IsNotSymbolicLink, fileType, FileNameStatus.PathNameValid); //Step 2: FSCTL request with FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request with FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify returned NTStatus code."); if (!IsCurrentTransportSupportIntegrity(status)) { return; } if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "Integrity is supported, status set to STATUS_SUCCESS."); } }
public void FsCtl_Set_IntegrityInformation_InvalidParameter_NonEmptyFile() { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create DataFile"); status = this.fsaAdapter.CreateFile(FileType.DataFile); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; integrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; uint inputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); // Check if Integrity is supported if (!IsCurrentTransportSupportIntegrity(status)) { return; } if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } //Step 3: FSCTL request FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER getIntegrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(getIntegrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 4: Verify ChecksumAlgorithm is correctly set getIntegrityInfo = TypeMarshal.ToStruct <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); bool isChecksumTypeNone = (getIntegrityInfo.ChecksumAlgorithm == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify ChecksumAlgorithm is correctly set."); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumTypeNone, "ChecksumAlgorithm is CHECKSUM_TYPE_NONE."); //Step 5: Write some data so that the file is not empty long bytesWritten = 0; BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. Write some data so that the file is not empty."); status = this.fsaAdapter.WriteFile(0, 10240, out bytesWritten); //Step 6: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_NONE; integrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.NONE; BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 7: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "7. Verify returned NTStatus code."); this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "FSCTL_SET_INTEGRITY_INFORMATION request should succeed when change the checksum state of a non-empty file."); }
private void FsCtl_Set_IntegrityInformation_ChecksumTypeCrc64AndUnchanged(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; uint inputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION with CHECKSUM_TYPE_CRC64."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); // Check if Integrity is supported if (!IsCurrentTransportSupportIntegrity(status)) { return; } if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } //Step 3: FSCTL request FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER getIntegrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(getIntegrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 4: Verify ChecksumAlgorithm getIntegrityInfo = TypeMarshal.ToStruct <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); bool isChecksumTypeNone = (getIntegrityInfo.ChecksumAlgorithm == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify ChecksumAlgorithm."); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumTypeNone, "ChecksumAlgorithm is CHECKSUM_TYPE_CRC64."); //Step 5: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_UNCHANGED; inputBufferSize = (uint)TypeMarshal.ToBytes <FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION with CHECKSUM_TYPE_UNCHANGED."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 6: FSCTL request FSCTL_GET_INTEGRITY_INFORMATION BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. FSCTL request FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 7: Verify ChecksumAlgorithm getIntegrityInfo = TypeMarshal.ToStruct <FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); isChecksumTypeNone = (getIntegrityInfo.ChecksumAlgorithm == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64); BaseTestSite.Log.Add(LogEntryKind.TestStep, "7. Verify ChecksumAlgorithm."); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumTypeNone, "ChecksumAlgorithm is CHECKSUM_TYPE_CRC64."); }