/// <summary> /// Verify the FSCTL_READ_FILE_USN_DATA Reply /// </summary> /// <param name="reply">the FSCTL_READ_FILE_USN_DATA reply message</param> public void VerifyMessageSyntaxFsctlReadFileUsnDataReply(FSCTL_READ_FILE_USN_DATA_Reply reply) { Site.DefaultProtocolDocShortName = "MS-FSCC"; string ServerOS = Site.Properties["ServerOSPlatform"]; if (ServerOS == "Win2k" || ServerOS == "WinXP" || ServerOS == "Win2k3" || ServerOS == "WinVista" || ServerOS == "Win2k8") { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1885"); // // Verify MS-FSCC requirement: MS-FSCC_R1885 // Site.CaptureRequirementIfAreEqual<ushort>( 2, reply.MajorVersion, 1885, @"<25> Section 2.3.44: The major version number[In USN_RECORD] is 2 for file systems created on Windows?2000, Windows?XP, Windows Server?2003, Windows?Vista, and Windows Server?2008."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1886"); // // Verify MS-FSCC requirement: MS-FSCC_R1886 // Site.CaptureRequirementIfAreEqual<ushort>( 0, reply.MinorVersion, 1886, @"<26> Section 2.3.44: The minor version number[In USN_RECORD] is 0 for file systems created on Windows?2000, Windows?XP, Windows Server?2003, Windows?Vista, and Windows Server?2008."); } Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }
/// <summary> /// Verify the message syntax in FSCTL_READ_FILE_USN_DATA_Reply /// </summary> /// <param name="fsctlReadFileUsnDataReply">The status code returned directly by the function that processes /// this FSCTL.</param> /// <param name="statusCode">A trailing Unicode NULL character.</param> /// <param name="numberOfFileOrDirectory">the number (assigned by the file system when the file is created) of /// the file or directory for which this record notes changes</param> /// <param name="totalLengthOfUSN"> the total length of the update sequence number (USN) record in bytes</param> /// <param name="indexOfUniqueSecurityId">Index of a unique security identifier assigned to the file or directory /// associated with this record.</param> /// <param name="fsctlCommand">FSCTL command which server doesnot understand</param> /// <param name="trailingUnicodeNullChar">The usn of the record.</param> /// <param name="isUsnChangeJournalRecordLogged">A variable to indicate that USN change journal records have been /// logged for the directory of the file associated with this record.</param> /// <param name="usnOfRecord">The USN of the record</param> /// <param name="fileAttributes">attributes for the file or directory associated with this record.</param> /// <param name="diretoryOrdinalNum">The ordinal number of the directory on which the file or directory that is /// associated with this record is located.</param> public void VerifyMessageSyntaxFsctlReadFileUsnDataReplyForOld( FSCTL_READ_FILE_USN_DATA_Reply fsctlReadFileUsnDataReply, bool isUsnChangeJournalRecordLogged) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // Status list of FsctlReadFileUsnDataReply List<Enum> statusCodeList = new List<Enum>(); statusCodeList.Add(FsctlReadFileUsnDataReplyStatus.STATUS_BUFFER_TOO_SMALL); statusCodeList.Add(FsctlReadFileUsnDataReplyStatus.STATUS_INVALID_DEVICE_REQUEST); statusCodeList.Add(FsctlReadFileUsnDataReplyStatus.STATUS_INVALID_PARAMETER); statusCodeList.Add(FsctlReadFileUsnDataReplyStatus.STATUS_INVALID_USER_BUFFER); statusCodeList.Add(FsctlReadFileUsnDataReplyStatus.STATUS_SUCCESS); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R766,the value of FileAttributes is {0}", fsctlReadFileUsnDataReply.FileAttributes); // // Verify MS-FSCC requirement: MS-FSCC_R766 // bool isVerifyR766 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.FileAttributes) == 4) && (fsctlReadFileUsnDataReply.FileAttributes.GetType() == typeof(uint)); Site.CaptureRequirementIfIsTrue( isVerifyR766, 766, @"[In USN_RECORD]FileAttributes (4 bytes): A 32-bit unsigned integer that contains attributes for the file or directory associated with this record."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R773,the length of the FileName is {0}", fsctlReadFileUsnDataReply.FileName.Length); // // Verify MS-FSCC requirement: MS-FSCC_R773 // // Each unicode character occupy 2 bits, so the length must be an even number bool isVerifyR773 = (fsctlReadFileUsnDataReply.FileName.Length % 2 == 0); Site.CaptureRequirementIfIsTrue( isVerifyR773, 773, @"[In USN_RECORD]FileName (variable): A variable-length field of UNICODE characters containing the name of the file or directory associated with this record in Unicode format."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R769,the value of FileNameLength is {0}", fsctlReadFileUsnDataReply.FileNameLength); // // Verify MS-FSCC requirement: MS-FSCC_R769 // bool isVerifyR769 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.FileNameLength) == 2) && (fsctlReadFileUsnDataReply.FileNameLength == (ushort)fsctlReadFileUsnDataReply.FileName.Length); Site.CaptureRequirementIfIsTrue( isVerifyR769, 769, @"[In USN_RECORD]FileNameLength (2 bytes): A 16-bit unsigned integer that contains the length of the file or directory name associated with this record in bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R771,the value of FileNameLength is {0}", fsctlReadFileUsnDataReply.FileNameLength); // // Verify MS-FSCC requirement: MS-FSCC_R771 // // If R769 was verified ,then means FileNameLength determine file name length Site.CaptureRequirementIfIsTrue( isVerifyR769, 771, @"[In USN_RECORD]FileNameLength (2 bytes):Use this member to determine file name length rather than depending on a trailing NULL to delimit the file name in FileName."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R772,the value of FileNameOffset is {0}", fsctlReadFileUsnDataReply.FileNameOffset); // // Verify MS-FSCC requirement: MS-FSCC_R772 // // 16 bits equal 2 bytes // From the beginning of the structure to the FileName member // there are 60 bytes,so the FileNameOffset should be 60 bool isVerifyR772 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.FileNameOffset) == 2) && (fsctlReadFileUsnDataReply.FileNameOffset == 60); Site.CaptureRequirementIfIsTrue( isVerifyR772, 772, @"[In USN_RECORD]FileNameOffset (2 bytes): A 16-bit unsigned integer that contains the offset in bytes of the FileName member from the beginning of the structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R720,the value of FileReferenceNumber is {0}", fsctlReadFileUsnDataReply.FileReferenceNumber); // // Verify MS-FSCC requirement: MS-FSCC_R720 // // 64 bits equal 8 bytes bool isVerifyR720 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.FileReferenceNumber) == 8) && (fsctlReadFileUsnDataReply.FileReferenceNumber.GetType() == typeof(ulong)); Site.CaptureRequirementIfIsTrue( isVerifyR720, 720, @"[In USN_RECORD]FileReferenceNumber (8 bytes): A 64-bit unsigned integer, opaque to the client, containing the number (assigned by the file system when the file is created) of the file or directory for which this record notes changes. T"); if (isWindows) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R718,the value of MajorVersion is {0}", fsctlReadFileUsnDataReply.MajorVersion); // // Verify MS-FSCC requirement: MS-FSCC_R718 // // 16 bits equal 2 bytes // From TD <25>,The major version number is 2 for file systems // created on Windows 2000, Windows XP, Windows Server 2003, // Windows Vista, and Windows Server 2008. bool isVerifyR718 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.MajorVersion) == 2) && (fsctlReadFileUsnDataReply.MajorVersion == 2); Site.CaptureRequirementIfIsTrue( isVerifyR718, 718, @"[In USN_RECORD]MajorVersion (2 bytes): A 16-bit unsigned integer that contains the major version of the change journal software for this record.<25>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R719,the vlaue of MinorVersion is {0}", fsctlReadFileUsnDataReply.MinorVersion); // // Verify MS-FSCC requirement: MS-FSCC_R719 // // 16 bits equal 2 bytes // From TD <26>,The minor version number is 0 for file systems // created on Windows 2000, Windows XP, Windows Server 2003, // Windows Vista, and Windows Server 2008. bool isVerifyR719 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.MinorVersion) == 2) && (fsctlReadFileUsnDataReply.MinorVersion == 0); Site.CaptureRequirementIfIsTrue( isVerifyR719, 719, @"[In USN_RECORD]MinorVersion (2 bytes): A 16-bit unsigned integer that contains the minor version of the change journal software for this record.<26>"); } // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R723,the value of ParentFileReferenceNumber is {0}", fsctlReadFileUsnDataReply.ParentFileReferenceNumber); // // Verify MS-FSCC requirement: MS-FSCC_R723 // bool isVerifyR723 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.ParentFileReferenceNumber) == 8) && (fsctlReadFileUsnDataReply.ParentFileReferenceNumber.GetType() == typeof(ulong)); Site.CaptureRequirementIfIsTrue( isVerifyR723, 723, @"[In USN_RECORD]ParentFileReferenceNumber (8 bytes): A 64-bit unsigned integer, opaque to the client, containing the ordinal number of the directory on which the file or directory that is associated with this record is located."); List<Enum> reasonCodeList = new List<Enum>(); reasonCodeList.Add(Reason_Values.USN_REASON_BASIC_INFO_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_CLOSE); reasonCodeList.Add(Reason_Values.USN_REASON_COMPRESSION_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_DATA_EXTEND); reasonCodeList.Add(Reason_Values.USN_REASON_DATA_OVERWRITE); reasonCodeList.Add(Reason_Values.USN_REASON_DATA_TRUNCATION); reasonCodeList.Add(Reason_Values.USN_REASON_EA_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_ENCRYPTION_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_FILE_CREATE); reasonCodeList.Add(Reason_Values.USN_REASON_FILE_DELETE); reasonCodeList.Add(Reason_Values.USN_REASON_HARD_LINK_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_INDEXABLE_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_NAMED_DATA_EXTEND); reasonCodeList.Add(Reason_Values.USN_REASON_NAMED_DATA_OVERWRITE); reasonCodeList.Add(Reason_Values.USN_REASON_NAMED_DATA_TRUNCATION); reasonCodeList.Add(Reason_Values.USN_REASON_OBJECT_ID_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_RENAME_NEW_NAME); reasonCodeList.Add(Reason_Values.USN_REASON_RENAME_OLD_NAME); reasonCodeList.Add(Reason_Values.USN_REASON_REPARSE_POINT_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_SECURITY_CHANGE); reasonCodeList.Add(Reason_Values.USN_REASON_STREAM_CHANGE); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R717,the value of RecordLength is {0}", fsctlReadFileUsnDataReply.RecordLength); // // Verify MS-FSCC requirement: MS-FSCC_R717 // bool isVerifyR717 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.RecordLength) == 4) && (fsctlReadFileUsnDataReply.RecordLength.GetType() == typeof(uint)); Site.CaptureRequirementIfIsTrue( isVerifyR717, 717, @"[In USN_RECORD]RecordLength (4 bytes): A 32-bit unsigned integer that contains the total length of the update sequence number (USN) record in bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R763,the value of SecurityId is {0}", fsctlReadFileUsnDataReply.SecurityId); // // Verify MS-FSCC requirement: MS-FSCC_R763 // // 32 bits equal 4 bytes. bool isVerifyR763 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.SecurityId) == 4) && (fsctlReadFileUsnDataReply.SecurityId.GetType() == typeof(uint)); Site.CaptureRequirementIfIsTrue( isVerifyR763, 763, @"[In USN_RECORD]SecurityId (4 bytes): A 32-bit unsigned integer that contains an index of a unique security identifier assigned to the file or directory associated with this record."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R775,the value of Reason is {0},the value of TimeStamp is {1},the value of SourceInfo is {2},the value of SecurityId is {3}", fsctlReadFileUsnDataReply.Reason, fsctlReadFileUsnDataReply.TimeStamp, fsctlReadFileUsnDataReply.SourceInfo, fsctlReadFileUsnDataReply.SecurityId); // // Verify MS-FSCC requirement: MS-FSCC_R775 // bool isVerifyR775 = (fsctlReadFileUsnDataReply.Reason == 0) && (fsctlReadFileUsnDataReply.TimeStamp.dwHighDateTime == 0) && (fsctlReadFileUsnDataReply.TimeStamp.dwLowDateTime == 0) && (fsctlReadFileUsnDataReply.SourceInfo == 0) && (fsctlReadFileUsnDataReply.SecurityId == 0); Site.CaptureRequirementIfIsTrue( isVerifyR775, 775, @"[In USN_RECORD]The fields Reason, TimeStamp, SourceInfo, and SecurityId for a USN RECORD element returned by this FSCTL MUST all be set 0.<28>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R729"); // // Verify MS-FSCC requirement: MS-FSCC_R729 // Site.CaptureRequirementIfAreEqual<Type>( typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME), fsctlReadFileUsnDataReply.TimeStamp.GetType(), 729, @"[In USN_RECORD]TimeStamp (8 bytes): A structure containing the absolute system time this change journal event was logged, expressed as the number of 100-nanosecond intervals since January 1, 1601 (UTC), in the format of a FILETIME (section 2.1.1) structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R725,the value of Usn is {0}", fsctlReadFileUsnDataReply.Usn); // // Verify MS-FSCC requirement: MS-FSCC_R725 // // 64 bits equal 8 bytes. bool isVerifyR725 = (Marshal.SizeOf(fsctlReadFileUsnDataReply.Usn) == 8) && (fsctlReadFileUsnDataReply.Usn.GetType() == typeof(long)); Site.CaptureRequirementIfIsTrue( isVerifyR725, 725, @"[In USN_RECORD]Usn (8 bytes): A 64-bit signed integer, opaque to the client, containing the USN of the record."); // Check if no USN change journal records have been logged for the // directory of the file associated with this record if (!isUsnChangeJournalRecordLogged) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R728"); // // Verify MS-FSCC requirement: MS-FSCC_R728 // Site.CaptureRequirementIfAreEqual<long>( 0, fsctlReadFileUsnDataReply.Usn, 728, @"[In USN_RECORD]Usn (8 bytes): This value MUST be 0 if no USN change journal records have been logged for the directory of the file associated with this record. "); } // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R727,the value of Usn is {0}", fsctlReadFileUsnDataReply.Usn); // // Verify MS-FSCC requirement: MS-FSCC_R727 // Site.CaptureRequirementIfIsTrue( fsctlReadFileUsnDataReply.Usn >= 0, 727, @"[In USN_RECORD]Usn (8 bytes): This value MUST be greater than or equal to 0."); Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }
/// <summary> /// Verify the message of FSCTL_READ_FILE_USN_DATA Reply /// </summary> /// <param name="reply">the Reply of FSCTL_READ_FILE_USN_DATA</param> /// <param name="returnedStatusCode">the status code returned in response, as specified in [MS-ERREF] /// section 2.3</param> /// <param name="expectedUSNLength">the expected total length of the update sequence number (USN) record /// in bytes</param> /// <param name="isReturnedByFSCTL">check if the a USN RECORD element returned by this FSCTL</param> /// <param name="isUsnChangeLogged">check if USN change journal records have been logged for the directory of /// the file associated with this record</param> /// <param name="expectedNumOfChanges">the expected number (assigned by the file system when the file is created) /// of the file or directory for which this record notes changes</param> public void VerifyMessageSyntaxFsctlReadFileUsnDataReply(FSCTL_READ_FILE_USN_DATA_Reply reply, FsctlReadFileUsnDataReplyStatus returnedStatusCode, bool isReturnedByFSCTL, bool isUsnChangeLogged) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R776. returnedStatusCode: {0}", returnedStatusCode); // // Verify MS-FSCC requirement: MS-FSCC_R776 // // the returned status code must be in the valid range,as specified in [MS-ERREF] section 2.3 bool isVerifyR776 = ((uint)returnedStatusCode >= 0x00000000 && (uint)returnedStatusCode <= 0xC03A0019); Site.CaptureRequirementIfIsTrue( isVerifyR776, 776, @"This message[FSCTL_READ_FILE_USN_DATA Reply] returns a status code, as specified in [MS-ERREF] section 2.3."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R777. The Returned Status Code : {0}", returnedStatusCode); // // Verify MS-FSCC requirement: MS-FSCC_R777 // // STATUS_SUCCESS 0x00000000 // STATUS_INVALID_PARAMETER 0xC000000D, // STATUS_INVALID_USER_BUFFER 0xC00000E8, // STATUS_BUFFER_TOO_SMALL 0xC0000023, // STATUS_INVALID_DEVICE_REQUEST 0xC0000010 bool isVerifyR777 = (returnedStatusCode == FsctlReadFileUsnDataReplyStatus.STATUS_SUCCESS || returnedStatusCode == FsctlReadFileUsnDataReplyStatus.STATUS_BUFFER_TOO_SMALL || returnedStatusCode == FsctlReadFileUsnDataReplyStatus.STATUS_INVALID_DEVICE_REQUEST || returnedStatusCode == FsctlReadFileUsnDataReplyStatus.STATUS_INVALID_PARAMETER || returnedStatusCode == FsctlReadFileUsnDataReplyStatus.STATUS_INVALID_USER_BUFFER); Site.CaptureRequirementIfIsTrue( isVerifyR777, 777, @"[In FSCTL_READ_FILE_USN_DATA Reply]The status code returned directly by the function that processes this FSCTL MUST be STATUS_SUCCESS or one of the following:[STATUS_INVALID_PARAMETER 0xC000000D, STATUS_INVALID_USER_BUFFER 0xC00000E8, STATUS_BUFFER_TOO_SMALL 0xC0000023, STATUS_INVALID_DEVICE_REQUEST 0xC0000010]."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R766. FileAttributes: {0}", reply.FileAttributes); // // Verify MS-FSCC requirement: MS-FSCC_R766 // // the combination of FileAttributes, as specified in section 2.6 uint bitsCombination = (0x00000020 | 0x00000800 | 0x00000010 | 0x00004000 | 0x00000002 | 0x00000080 | 0x00002000 | 0x00001000 | 0x00000001 | 0x00000400 | 0x00000200 | 0x00000004 | 0x00000100); // 0x00000000 also is value in FileAttributes field bool isVerifyR766 = (reply.FileAttributes == 0x00000000 || (reply.FileAttributes & ~bitsCombination) == 0); Site.CaptureRequirementIfIsTrue( isVerifyR766, 766, @"[In USN_RECORD]FileAttributes (4 bytes): A 32-bit unsigned integer that contains attributes for the file or directory associated with this record."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R773"); // // Verify MS-FSCC requirement: MS-FSCC_R773 // // verify the type of this field Site.CaptureRequirementIfAreEqual<Type>( typeof(byte[]), reply.FileName.GetType(), 773, @"[In USN_RECORD]FileName (variable): A variable-length field of UNICODE characters containing the name of the file or directory associated with this record in Unicode format."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R769"); // // Verify MS-FSCC requirement: MS-FSCC_R769 // Site.CaptureRequirementIfAreEqual<ushort>( (ushort)reply.FileName.Length, reply.FileNameLength, 769, @"[In USN_RECORD]FileNameLength (2 bytes): A 16-bit unsigned integer that contains the length of the file or directory name associated with this record in bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R772. FileNameOffset: {0}", reply.FileNameOffset); // // Verify MS-FSCC requirement: MS-FSCC_R772 // // FileName is parse by FileNameOffset and FileNameLength, which is got in correct size, // indicate FileNameOffset is from the beginning of the structure bool isVerifyR772 = (reply.FileNameOffset.GetType() == typeof(UInt16) && (ushort)reply.FileName.Length == reply.FileNameLength); Site.CaptureRequirementIfIsTrue( isVerifyR772, 772, @"[In USN_RECORD]FileNameOffset (2 bytes): A 16-bit unsigned integer that contains the offset in bytes of the FileName member from the beginning of the structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R720. FileReferenceNumber: {0}", reply.FileReferenceNumber); // // Verify MS-FSCC requirement: MS-FSCC_R720 // bool isVerifyR720 = (reply.FileReferenceNumber.GetType() == typeof(UInt64) && Marshal.SizeOf(reply.FileReferenceNumber) == 8); Site.CaptureRequirementIfIsTrue( isVerifyR720, 720, @"[In USN_RECORD]FileReferenceNumber (8 bytes): A 64-bit unsigned integer, opaque to the client, containing the number (assigned by the file system when the file is created) of the file or directory for which this record notes changes. T"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R721"); // // Verify MS-FSCC requirement: MS-FSCC_R721 // //be unique cannot be verified, // so here just to verify its type Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt64), reply.FileReferenceNumber.GetType(), 721, @"[In USN_RECORD]FileReferenceNumber (8 bytes): The FileReferenceNumber is an arbitrarily assigned value (unique within the volume on which the file is stored) that associates a journal record with a file."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R718"); // // Verify MS-FSCC requirement: MS-FSCC_R718 // Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt16), reply.MajorVersion.GetType(), 718, @"[In USN_RECORD]MajorVersion (2 bytes): A 16-bit unsigned integer that contains the major version of the change journal software for this record.<25>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R719"); // // Verify MS-FSCC requirement: MS-FSCC_R719 // Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt16), reply.MinorVersion.GetType(), 719, @"[In USN_RECORD]MinorVersion (2 bytes): A 16-bit unsigned integer that contains the minor version of the change journal software for this record.<26>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R723"); // // Verify MS-FSCC requirement: MS-FSCC_R723 // // ordinal number of the directory cannot be got on wire, // so just to verify its type Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt64), reply.ParentFileReferenceNumber.GetType(), 723, @"[In USN_RECORD]ParentFileReferenceNumber (8 bytes): A 64-bit unsigned integer, opaque to the client, containing the ordinal number of the directory on which the file or directory that is associated with this record is located."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R724. ParentFileReferenceNumber: {0}", reply.ParentFileReferenceNumber); // // Verify MS-FSCC requirement: MS-FSCC_R724 // //arbitrarily assigned value cannot be verified, so here verify value is in valid ranged bool isVerifyR724 = (reply.ParentFileReferenceNumber >= 0 && reply.ParentFileReferenceNumber <= UInt64.MaxValue); Site.CaptureRequirementIfIsTrue( isVerifyR724, 724, @"[In USN_RECORD]ParentFileReferenceNumber (8 bytes): This is an arbitrarily assigned value (unique within the volume on which the file is stored) that associates a journal record with a parent directory."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R730"); // // Verify MS-FSCC requirement: MS-FSCC_R730 // Site.CaptureRequirementIfAreEqual<Type>( typeof(Reason_Values), reply.Reason.GetType(), 730, @"[In USN_RECORD]Reason (4 bytes): A 32-bit unsigned integer that contains flags that indicate reasons for changes that have accumulated in this file or directory journal record since the file or directory was opened."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R734. Reason: {0}", reply.Reason); // // Verify MS-FSCC requirement: MS-FSCC_R734 // // used bits combination uint bitsUsed = ((uint)Reason_Values.USN_REASON_BASIC_INFO_CHANGE | (uint)Reason_Values.USN_REASON_CLOSE | (uint)Reason_Values.USN_REASON_COMPRESSION_CHANGE | (uint)Reason_Values.USN_REASON_DATA_EXTEND | (uint)Reason_Values.USN_REASON_DATA_OVERWRITE | (uint)Reason_Values.USN_REASON_DATA_TRUNCATION | (uint)Reason_Values.USN_REASON_EA_CHANGE | (uint)Reason_Values.USN_REASON_ENCRYPTION_CHANGE | (uint)Reason_Values.USN_REASON_FILE_CREATE | (uint)Reason_Values.USN_REASON_FILE_DELETE | (uint)Reason_Values.USN_REASON_HARD_LINK_CHANGE | (uint)Reason_Values.USN_REASON_INDEXABLE_CHANGE | (uint)Reason_Values.USN_REASON_NAMED_DATA_EXTEND | (uint)Reason_Values.USN_REASON_NAMED_DATA_OVERWRITE | (uint)Reason_Values.USN_REASON_NAMED_DATA_TRUNCATION | (uint)Reason_Values.USN_REASON_OBJECT_ID_CHANGE | (uint)Reason_Values.USN_REASON_RENAME_NEW_NAME | (uint)Reason_Values.USN_REASON_RENAME_OLD_NAME | (uint)Reason_Values.USN_REASON_REPARSE_POINT_CHANGE | (uint)Reason_Values.USN_REASON_SECURITY_CHANGE | (uint)Reason_Values.USN_REASON_STREAM_CHANGE); // Reason must use above bits bool isVerifyR734 = (((uint)reply.Reason & ~bitsUsed) == 0); Site.CaptureRequirementIfIsTrue( isVerifyR734, 734, @"[In USN_RECORD]Reason (4 bytes): Possible values for the reason code are as follows (all unused bits are reserved for future use and MUST NOT be used):[USN_REASON_BASIC_INFO_CHANGE 0x00008000, USN_REASON_CLOSE 0x80000000, USN_REASON_COMPRESSION_CHANGE 0x00020000, USN_REASON_DATA_EXTEND 0x00000002, USN_REASON_DATA_OVERWRITE 0x00000001, USN_REASON_DATA_TRUNCATION 0x00000004, USN_REASON_EA_CHANGE 0x00000400, USN_REASON_ENCRYPTION_CHANGE 0x00040000, USN_REASON_FILE_CREATE 0x00000100, USN_REASON_FILE_DELETE 0x00000200, USN_REASON_HARD_LINK_CHANGE 0x00010000, USN_REASON_INDEXABLE_CHANGE 0x00004000, USN_REASON_NAMED_DATA_EXTEND 0x00000020, USN_REASON_NAMED_DATA_OVERWRITE 0x00000010, USN_REASON_NAMED_DATA_TRUNCATION 0x00000040, USN_REASON_OBJECT_ID_CHANGE 0x00080000, USN_REASON_RENAME_NEW_NAME 0x00002000, USN_REASON_RENAME_OLD_NAME 0x00001000, USN_REASON_REPARSE_POINT_CHANGE 0x00100000, USN_REASON_SECURITY_CHANGE 0x00000800, USN_REASON_STREAM_CHANGE 0x00200000]."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R717"); // // Verify MS-FSCC requirement: MS-FSCC_R717 // // // The total length of the update sequence number bool isVerifyR717 = (reply.RecordLength.GetType() == typeof(uint)) && (Marshal.SizeOf(reply.RecordLength) == 4); Site.CaptureRequirementIfIsTrue( isVerifyR717, 717, @"[In USN_RECORD]RecordLength (4 bytes): A 32-bit unsigned integer that contains the total length of the update sequence number (USN) record in bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R725"); // // Verify MS-FSCC requirement: MS-FSCC_R725 // Site.CaptureRequirementIfAreEqual<Type>( typeof(Int64), reply.Usn.GetType(), 725, @"[In USN_RECORD]Usn (8 bytes): A 64-bit signed integer, opaque to the client, containing the USN of the record."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R726"); // // Verify MS-FSCC requirement: MS-FSCC_R726 // // be unique cannot be verified, so here just to verify the type Site.CaptureRequirementIfAreEqual<Type>( typeof(Int64), reply.Usn.GetType(), 726, @"[In USN_RECORD]Usn (8 bytes): This value is unique within the volume on which the file is stored."); // if no USN change journal records have been logged for the directory of the file associated with this record. if (!isUsnChangeLogged) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R728"); // // Verify MS-FSCC requirement: MS-FSCC_R728 // Site.CaptureRequirementIfAreEqual<long>( 0, reply.Usn, 728, @"[In USN_RECORD]Usn (8 bytes): This value MUST be 0 if no USN change journal records have been logged for the directory of the file associated with this record. "); } // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R727. Usn: {0}", reply.Usn); // // Verify MS-FSCC requirement: MS-FSCC_R727 // bool isVerifyR727 = (reply.Usn >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR727, 727, @"[In USN_RECORD]Usn (8 bytes): This value MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R729. TimeStamp: {0}{1}", reply.TimeStamp.dwHighDateTime, reply.TimeStamp.dwLowDateTime); // // Verify MS-FSCC requirement: MS-FSCC_R729 // bool isVerifyR729 = (reply.TimeStamp.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && reply.TimeStamp.dwHighDateTime >= 0 && reply.TimeStamp.dwLowDateTime >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR729, 729, @"[In USN_RECORD]TimeStamp (8 bytes): A structure containing the absolute system time this change journal event was logged, expressed as the number of 100-nanosecond intervals since January 1, 1601 (UTC), in the format of a FILETIME (section 2.1.1) structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R763"); // // Verify MS-FSCC requirement: MS-FSCC_R763 // Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt32), reply.SecurityId.GetType(), 763, @"[In USN_RECORD]SecurityId (4 bytes): A 32-bit unsigned integer that contains an index of a unique security identifier assigned to the file or directory associated with this record."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R756"); // // Verify MS-FSCC requirement: MS-FSCC_R756 // // SourceInfo has been parse into an enum by stack, // so here just to verify the type is the one defined in stack Site.CaptureRequirementIfAreEqual<Type>( typeof(SourceInfo_Values), reply.SourceInfo.GetType(), 756, @"[In USN_RECORD]SourceInfo (4 bytes): A 32-bit unsigned integer that provides additional information about the source of the change."); //a USN RECORD element returned by this FSCTL if (isReturnedByFSCTL) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R775. Reason: {0}, TimeStamp: {1}{2}, SourceInfo: {3}, SecurityId: {4}", reply.Reason, reply.TimeStamp.dwHighDateTime, reply.TimeStamp.dwLowDateTime, reply.SourceInfo, reply.SecurityId); // // Verify MS-FSCC requirement: MS-FSCC_R775 // bool isVerifyR775 = (reply.Reason == 0 && reply.TimeStamp.dwHighDateTime == 0 && reply.TimeStamp.dwLowDateTime == 0 && reply.SourceInfo == 0 && reply.SecurityId == 0); Site.CaptureRequirementIfIsTrue( isVerifyR775, 775, @"[In USN_RECORD]The fields Reason, TimeStamp, SourceInfo, and SecurityId for a USN RECORD element returned by this FSCTL MUST all be set 0.<28>"); } Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }