Esempio n. 1
0
 internal static extern uint CallNtPowerInformation(
     InformationLevel informationLevel,
     IntPtr lpInputBuffer,
     int nInputBufferSize,
     IntPtr lpOutputBuffer,
     int nOutputBufferSize
     );
        private T GetPowerInformation <T>(InformationLevel level)
        {
            var type          = typeof(T);
            T   returnedValue = default(T);
            var status        = Marshal.AllocCoTaskMem(Marshal.SizeOf(type));

            try
            {
                var retval = GetPowerInformation(level, (IntPtr)null, 0, status, (UInt32)Marshal.SizeOf(type));
                if (retval != 0)
                {
                    Marshal.FreeCoTaskMem(status);
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (type == typeof(ulong))
                {
                    returnedValue = (T)Convert.ChangeType(Marshal.ReadInt64(status), type);
                }

                else if (type.IsStruct())
                {
                    returnedValue = (T)Marshal.PtrToStructure(status, type);
                }
            }
            finally
            {
                Marshal.FreeCoTaskMem(status);
            }

            return(returnedValue);
        }
Esempio n. 3
0
 private static extern UInt32 CallNtPowerInformation(
     InformationLevel InformationLevel,
     IntPtr lpInputBuffer,
     UInt32 nInputBufferSize,
     IntPtr lpOutputBuffer,
     UInt32 nOutputBufferSize
     );
 private static extern UInt32 GetPowerInformation(
     InformationLevel informationLevel,
     IntPtr lpInputBuffer,
     UInt32 nInputBufferSize,
     [Out] IntPtr lpOutputBuffer,
     UInt32 nOutputBufferSize
     );
Esempio n. 5
0
        private static NtStatus CallNtPowerInformationInternal <TOut>(InformationLevel informationLevel, out TOut outputValue) where TOut : struct
        {
            var outputPtr = IntPtr.Zero;

            try
            {
                outputPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(TOut)));

                var ntStatus = CallNtPowerInformation(
                    (int)informationLevel,
                    IntPtr.Zero,
                    0,
                    outputPtr,
                    Marshal.SizeOf(typeof(TOut)));

                outputValue = (TOut)Marshal.PtrToStructure(outputPtr, typeof(TOut));
                return((NtStatus)ntStatus);
            }
            finally
            {
                if (outputPtr != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(outputPtr);
                }
            }
        }
 public Task <SmallTalks.Core.Models.Analysis> AnalyzeAsync(string input, InformationLevel informationLevel = default)
 {
     return(_smallTalksDetector.DetectAsync(input, new SmallTalksPreProcessingConfiguration
     {
         ToLower = true,
         UnicodeNormalization = true,
         InformationLevel = informationLevel
     }));
 }
 public void SetFaction(object faction)
 {
     this.architectureSurvey.ViewingFaction = faction as Faction;
     if (this.architectureSurvey.ViewingFaction != null)
     {
         InformationLevel knownAreaData = this.architectureSurvey.ViewingFaction.GetKnownAreaData(this.architectureSurvey.CurrentPosition);
         this.enableUpdate             = this.enableUpdate || (this.architectureSurvey.Level != knownAreaData);
         this.architectureSurvey.Level = knownAreaData;
     }
 }
Esempio n. 8
0
 public void SetFaction(object faction)
 {
     this.troopSurvey.ViewingFaction = faction as Faction;
     if (this.troopSurvey.ViewingFaction != null)
     {
         InformationLevel knownAreaData = this.troopSurvey.ViewingFaction.GetKnownAreaData(this.troopSurvey.TroopToSurvey.Position);
         this.enableUpdate      = this.enableUpdate || (this.troopSurvey.Level != knownAreaData);
         this.troopSurvey.Level = knownAreaData;
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Save the General.FileFormats.Excel settings to the settings file
        /// </summary>
        /// <param name="excelNode">XML-node for the General.FileFormats.Excel settings</param>
        public void Save(XmlNode excelNode)
        {
            string xpath;

            xpath = "./informationLevel";
            SettingsHelper.SetSettingValue(xpath, excelNode, InformationLevel.ToString());

            xpath = "./doubleColumn";
            SettingsHelper.SetSettingValue(xpath, excelNode, DoubleColumn.ToString());

            xpath = "./showDataNotes";
            SettingsHelper.SetSettingValue(xpath, excelNode, ShowDataNotes.ToString());
        }
Esempio n. 10
0
        public void RemoveInformationLevel(InformationLevel level)
        {
            switch (level)
            {
                case InformationLevel.低:
                    this.lowCount--;
                    break;

                case InformationLevel.中:
                    this.middleCount--;
                    break;

                case InformationLevel.高:
                    this.highCount--;
                    break;

                case InformationLevel.全:
                    this.fullCount--;
                    break;
            }
        }
Esempio n. 11
0
        public void RemoveInformationLevel(InformationLevel level)
        {
            switch (level)
            {
            case InformationLevel.低:
                this.lowCount--;
                break;

            case InformationLevel.中:
                this.middleCount--;
                break;

            case InformationLevel.高:
                this.highCount--;
                break;

            case InformationLevel.全:
                this.fullCount--;
                break;
            }
        }
        public void Trans2FindFirst2RequestInvalidFileToken(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            bool isReparse,
            InformationLevel informationLevel,
            int gmtTokenIndex,
            bool isFlagsKnowsLongNameSet,
            bool isGmtPatten)
        {
            #region Create Packet

            SmbTrans2FindFirst2RequestPacket smbPacket = new SmbTrans2FindFirst2RequestPacket();

            ushort uid = (ushort)this.uId[(uint)sessionId];
            ushort tid = (ushort)this.tId[(uint)treeId];
            NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE;
            string fileName = Site.Properties["SmbTestCaseBadGmt"].ToString();

            ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]);
            NamespaceCifs.Trans2FindFlags findFlags
                = (NamespaceCifs.Trans2FindFlags)(ushort.Parse(Site.Properties["SmbTransportFindFlags"]));

            NamespaceCifs.SmbFileAttributes searchAttributes = NamespaceCifs.SmbFileAttributes.SMB_FILE_ATTRIBUTE_NORMAL;

            NamespaceCifs.Trans2FindFirst2SearchStorageType searchStorageType =
                NamespaceCifs.Trans2FindFirst2SearchStorageType.FILE_NON_DIRECTORY_FILE;

            isReparse = true;
            isFlagsKnowsLongNameSet = true;

            smbPacket = this.smbClientStack.CreateTrans2FindFirst2Request(
                tid,
                fileName,
                transactOptions,
                searchCount,
                findFlags,
                searchAttributes,
                searchStorageType,
                isReparse,
                isFlagsKnowsLongNameSet,
                FindInformationLevel.SMB_INFO_STANDARD);

            if (isSigned)
            {
                NamespaceCifs.CifsClientPerConnection connection =
                    this.smbClientStack.Context.GetConnection(ConnectionId);

                NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid);

                smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey);
            }

            #endregion

            #region Send and Receive ExpectPacket

            this.smbClientStack.SendPacket(smbPacket);
            StackPacket response = this.smbClientStack.ExpectPacket(this.timeout);

            NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response;
            this.QueryUidTable(smbPacketResponse);
            this.QueryTidTable(smbPacketResponse);

            VerifyTransport(smbPacketResponse);
            VerifyCommonMessageSyntax(smbPacketResponse);

            if (response.GetType() == typeof(SmbErrorResponsePacket))
            {
                SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket;
                NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader;

                if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass)
                {
                    smbErrorHeader.Status = (uint)MessageStatus.NotSupported;
                }
                this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
            }
            else
            {
                NamespaceCifs.TRANS2_FIND_FIRST2_Request_Trans2_Parameters trans2FindFirst2RequestHeader
                    = smbPacket.Trans2Parameters;

                SmbTrans2FindFirst2ResponsePacket smbTrans2FindFirst2Packet
                    = response as SmbTrans2FindFirst2ResponsePacket;
                NamespaceCifs.SmbHeader smbTrans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.SmbHeader;
                NamespaceCifs.TRANS2_FIND_FIRST2_Response_Trans2_Parameters trans2FindFirst2ResponseHeader
                    = smbTrans2FindFirst2Packet.Trans2Parameters;

                bool isFileIDEqualZero = false;
                bool isReturnEnumPreviousVersion = false;
                ushort inforLevel = (ushort)trans2FindFirst2RequestHeader.InformationLevel;
                if (inforLevel ==
                    this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdFullDirectoryInfo])
                {
                    if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                    {
                        NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket fsccFullDirectoryPacket
                            = new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket();

                        fsccFullDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data);

                        NamespaceFscc.FileFullDirectoryInformation fullDirectoryInformation
                            = new NamespaceFscc.FileFullDirectoryInformation();

                        fullDirectoryInformation = fsccFullDirectoryPacket.Payload;
                        if (fullDirectoryInformation.FileNameLength == uint.MinValue)
                        {
                            isFileIDEqualZero = true;
                        }

                        VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(fullDirectoryInformation);

                        this.isfindIdFullDirectoryInfo = true;
                    }
                }
                else if (inforLevel ==
                    this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdBothDirectoryInfo])
                {
                    if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue)
                    {
                        NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket fsccBothDirectoryPacket
                            = new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket();

                        fsccBothDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data);

                        NamespaceFscc.FileBothDirectoryInformation bothDirectoryInformation
                            = new NamespaceFscc.FileBothDirectoryInformation();

                        bothDirectoryInformation = fsccBothDirectoryPacket.Payload;
                        if (bothDirectoryInformation.FileNameLength == uint.MinValue)
                        {
                            isFileIDEqualZero = true;
                        }

                        if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true)
                        {
                            VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation);
                        }
                        this.isfinIdBothDirectoryInfo = true;
                    }
                }
                else
                {
                    if (SmbAdapter.fileSystemType == FileSystemType.Fat)
                    {
                        isFileIDEqualZero = true;
                    }
                    else
                    {
                        isFileIDEqualZero = false;
                    }

                    if (this.sutOsVersion == Platform.Win2K3)
                    {
                        isReturnEnumPreviousVersion = false;
                    }
                    else
                    {
                        isReturnEnumPreviousVersion = true;
                    }
                }

                if (!this.sId.ContainsValue(trans2FindFirst2ResponseHeader.SID))
                {
                    this.sId.Add((uint)(gmtTokenIndex), (uint)trans2FindFirst2ResponseHeader.SID);
                }

                VerifyMessageSyntaxTrans2FindFirst2Request(
                    informationLevel,
                    smbTrans2FindFirst2Packet,
                    this.isfindIdFullDirectoryInfo,
                    this.isfinIdBothDirectoryInfo);

                this.isfindIdFullDirectoryInfo = false;
                this.isfinIdBothDirectoryInfo = false;

                this.Trans2FindFirst2Response(
                    smbTrans2FindFirst2ResponseHeader.Mid + this.addMidMark,
                    this.QueryUidTable(smbPacketResponse),
                    this.QueryTidTable(smbPacketResponse),
                    smbPacketResponse.IsSignRequired,
                    isFileIDEqualZero,
                    gmtTokenIndex,
                    isReturnEnumPreviousVersion,
                    (MessageStatus)smbTrans2FindFirst2ResponseHeader.Status,
                    true,
                    true);
            }

            #endregion
        }
Esempio n. 13
0
 public static string InformationString(InformationLevel level)
 {
     return level.ToString();
 }
 public static void OnInformation(this IEventSource source, string message, InformationLevel level)
 {
     source.OnEvent(new InformationEvent(message, level));
 }
Esempio n. 15
0
 public void RemovePositionInformation(Point position, InformationLevel level)
 {
     if (!base.Scenario.PositionOutOfRange(position))
     {
         this.knownAreaData[position.X, position.Y].RemoveInformationLevel(level);
     }
 }
Esempio n. 16
0
 public static void OnInformation(this IEventSource source, string message, InformationLevel level)
 {
     source.OnEvent(new InformationEvent(message, level));
 }
 /// <summary>
 /// TRANS2_SET_FS_INFORMATION Request.
 /// </summary>
 /// <param name="messageId">This is used to associate a response with a request.</param>
 /// <param name="sessionId">
 /// Set this value to 0 to request a new session setup, or set this value to a previously established session
 /// identifier to request the re-authentication of an existing session.
 /// </param>
 /// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
 /// <param name="isUsePassthrough">isUsePassthrough.</param>
 /// <param name="isSigned">It indicates whether the SUT has message signing enabled or required.</param>
 /// <param name="informationLevel">This can be used to query information from the SUT.</param>
 /// <param name="requireDisconnectTreeFlags">It indicates whether flags set to Disconnect_TID.</param>
 /// <param name="requireNoResponseFlags">It indicates whether flags set to NO_RESPONSE.</param>
 public Trans2SetFSInfoRequest(
     int messageId,
     int sessionId,
     int treeId,
     bool isUsePassthrough,
     bool requireDisconnectTreeFlags,
     bool requireNoResponseFlags,
     bool isSigned,
     InformationLevel informationLevel)
     : base(messageId, Command.Trans2SetFsInformaiton)
 {
     this.sessionId = sessionId;
     this.treeId = treeId;
     this.isUsePassthrough = isUsePassthrough;
     this.requireDisconnectTreeFlags = requireDisconnectTreeFlags;
     this.requireNoResponseFlags = requireNoResponseFlags;
     this.isSigned = isSigned;
     this.informationLevel = informationLevel;
 }
 public static void Trans2FindFirst2RequestInvalidFileToken(
     int messageId,
     int sessionId,
     int treeId,
     bool isSigned,
     bool isReparse,
     InformationLevel informationLevel,
     int gmtTokenIndex,
     bool isFlagsKnowsLongNameSet,
     bool isGmtPatten)
 {
     Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);
     smbRequest = new Trans2FindFirst2Request(
         messageId,
         sessionId,
         treeId,
         gmtTokenIndex,
         isReparse,
         informationLevel,
         isFlagsKnowsLongNameSet,
         isGmtPatten);
     // -1 here means the invalid token.
     const int invalidToken = -1;
     Condition.IsTrue(gmtTokenIndex == invalidToken);
     Update.UpdateRequest(smbConnection, smbRequest);
     Requirement.AssumeCaptured("Test case for invalid file token");
 }
 public static void OnInformation(this IContext context, string message, InformationLevel level)
 {
     context.OnEvent(new InformationEvent(message, level));
 }
 /// <summary>
 /// TRANS2_QUERY_FS_INFORMATION Request.
 /// </summary>
 /// <param name="messageId">This is used to associate a response with a request.</param>
 /// <param name="sessionId">
 /// Set this value to 0 to request a new session setup, or set this value to a previously established session
 /// identifier to request the re-authentication of an existing session.
 /// </param>
 /// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
 /// <param name="isSigned">It indicates whether the SUT has message signing enabled or required.</param>
 /// <param name="isUsePassthrough">
 /// It indicates whether adding SMB_INFO_PASSTHROUGH in InformationLevel field of the request.
 /// </param>
 /// <param name="informationLevel">This can be used to query information from the SUT.</param>
 public Trans2QueryFSInfoRequest(
     int messageId,
     int sessionId,
     int treeId,
     bool isSigned,
     bool isUsePassthrough,
     InformationLevel informationLevel)
     : base(messageId, Command.Trans2QueryFsInformation)
 {
     this.sessionId = sessionId;
     this.treeId = treeId;
     this.isSigned = isSigned;
     this.isUsePassthrough = isUsePassthrough;
     this.informationLevel = informationLevel;
 }
Esempio n. 21
0
        public string DominationInInformationLevel(InformationLevel level)
        {
            switch (level)
            {
                case InformationLevel.未知:
                    return "----";

                case InformationLevel.无:
                    return "----";

                case InformationLevel.低:
                    return StaticMethods.GetNumberStringByGranularity(this.Domination, 20);

                case InformationLevel.中:
                    return StaticMethods.GetNumberStringByGranularity(this.Domination, 10);

                case InformationLevel.高:
                    return StaticMethods.GetNumberStringByGranularity(this.Domination, 5);

                case InformationLevel.全:
                    return this.Domination.ToString();
            }
            return "----";
        }
Esempio n. 22
0
        public string PopulationInInformationLevel(InformationLevel level)
        {
            switch (level)
            {
                case InformationLevel.未知:
                    return "----";

                case InformationLevel.无:
                    return "----";

                case InformationLevel.低:
                    return StaticMethods.GetNumberStringByGranularity(this.Population, 0x186a0);

                case InformationLevel.中:
                    return StaticMethods.GetNumberStringByGranularity(this.Population, 0xc350);

                case InformationLevel.高:
                    return StaticMethods.GetNumberStringByGranularity(this.Population, 0x2710);

                case InformationLevel.全:
                    return this.Population.ToString();
            }
            return "----";
        }
Esempio n. 23
0
 private void DetectAmbush(Troop troop, InformationLevel level)
 {
     int chance = 40 - troop.Leader.Calmness;
     if (level <= InformationLevel.中)
     {
         if (troop.OnlyBeDetectedByHighLevelInformation)
         {
             return;
         }
     }
     else
     {
         chance *= 3;
     }
     if (GameObject.Chance(chance))
     {
         troop.AmbushDetected(troop);
     }
 }
Esempio n. 24
0
 public static string InformationString(InformationLevel level)
 {
     return(level.ToString());
 }
 /// <summary>
 /// TRANS2_SET_FS_INFORMATION Request.
 /// </summary>
 /// <param name="messageId">This is used to associate a response with a request.</param>
 /// <param name="sessionId">Set this value to 0 to request a new session setup, or set this value to a previously established session identifier to request the re-authentication of an existing session.</param>
 /// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
 /// <param name="fId"></param>
 /// <param name="isUsePassthrough">isUsePassthrough.</param>
 /// <param name="isSigned">It indicates whether the SUT has message signing enabled or required.</param>
 /// <param name="informationLevel">This can be used to query information from the SUT.</param>
 /// <param name="requestPara">TRANS2_SET_FS_INFORMATION request parameter.</param>
 public Trans2SetFSInfoRequestAdditional(
     int messageId,
     int sessionId,
     int treeId,
     int fId,
     bool isSigned,
     InformationLevel informationLevel,
     Trans2SetFsInfoResponseParameter requestPara)
     : base(messageId, Command.Trans2SetFsInforamtionAdditional)
 {
     this.sessionId = sessionId;
     this.treeId = treeId;
     this.fId = fId;
     this.isSigned = isSigned;
     this.requestPara = requestPara;
     this.informationLevel = informationLevel;
 }
        /// <summary>
        /// TRANS2_SET_FS_INFORMATION Request.
        /// </summary>
        /// <param name="messageId">This is used to associate a response with a request.</param>
        /// <param name="sessionId">
        /// Set this value to 0 to request a new session setup, or set this value to a previously established session 
        /// identifier to request reauthenticate to an existing session.
        /// </param>
        /// <param name="treeId">
        /// This field identifies the subdirectory (or tree) (also referred as a share in this document) on the 
        /// server that the client is accessing.
        /// </param>
        /// <param name="isSigned">
        /// Indicate whether the SUT has message signing enabled or required.
        /// </param>
        /// <param name="isUsePassthrough">
        /// Indicate whether adding SMB_INFO_PASSTHROUGH in InformationLevel field of the request.
        /// </param>
        /// <param name="isRequireDisconnectTreeFlags">Indicate whether flags set to Disconnect_TID.</param>
        /// <param name="isRequireNoResponseFlags">Indicate whether flags set to NO_RESPONSE.</param>
        /// <param name="informationLevel">This can be used to query information from the server.</param>
        /// <param name="fid">The file identifier.</param>
        /// <param name="otherBits">If it contains other bits.</param>
        /// <param name="reserved">The reserved int value.</param>
        public void Trans2SetFsInfoRequest(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            bool isUsePassthrough,
            bool isRequireDisconnectTreeFlags,
            bool isRequireNoResponseFlags,
            InformationLevel informationLevel,
            int fid,
            bool otherBits,
            int reserved)
        {
            #region Create Packet

            SmbTrans2SetFsInformationRequestPacket smbPacket = new SmbTrans2SetFsInformationRequestPacket();
            ushort uid = (ushort)this.uId[(uint)sessionId];
            ushort fileId = (ushort)this.fId[(uint)fid];

            NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE;

            if (isRequireDisconnectTreeFlags && isRequireNoResponseFlags)
            {
                transactOptions = NamespaceCifs.Trans2SmbParametersFlags.DISCONNECT_TID
                    | NamespaceCifs.Trans2SmbParametersFlags.NO_RESPONSE;
            }

            if (isRequireDisconnectTreeFlags && !isRequireNoResponseFlags)
            {
                transactOptions = NamespaceCifs.Trans2SmbParametersFlags.DISCONNECT_TID;
            }

            if (!isRequireDisconnectTreeFlags && isRequireNoResponseFlags)
            {
                transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NO_RESPONSE;
            }

            if (!isRequireDisconnectTreeFlags && !isRequireNoResponseFlags)
            {
                transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE;
            }

            ushort level = this.informationLevelBytes[(ushort)informationLevel];
            if (isUsePassthrough)
            {
                level += InformationLevelPathThrouth;
            }
            // FILE_FS_CONTROL_INFORMATION data
            NamespaceFscc.FileFsControlInformation fileFsControlInformation =
                new NamespaceFscc.FileFsControlInformation();

            fileFsControlInformation.DefaultQuotaLimit = uint.MinValue;
            fileFsControlInformation.DefaultQuotaThreshold = uint.MinValue;

            fileFsControlInformation.FileSystemControlFlags =
                NamespaceFscc.FileSystemControlFlags_Values.FILE_VC_LOG_QUOTA_LIMIT;

            fileFsControlInformation.FreeSpaceStartFiltering = uint.MinValue;
            fileFsControlInformation.FreeSpaceStopFiltering = uint.MinValue;
            fileFsControlInformation.FreeSpaceThreshold = uint.MinValue;

            NamespaceFscc.FsccFileFsControlInformationRequestPacket fsControlPacket
                = new NamespaceFscc.FsccFileFsControlInformationRequestPacket();

            fsControlPacket.Payload = fileFsControlInformation;

            byte[] data = new byte[DataCount];
            data = fsControlPacket.ToBytes();

            smbPacket = this.smbClientStack.CreateTrans2SetFileSystemInformationRequest(
                fileId,
                transactOptions,
                (NamespaceCifs.QueryFSInformationLevel)level,
                data);

            NamespaceCifs.SMB_COM_TRANSACTION2_Request_SMB_Parameters smbParameters = smbPacket.SmbParameters;
            smbParameters.DataCount = DataCount;
            smbPacket.SmbParameters = smbParameters;

            if (isSigned)
            {
                NamespaceCifs.CifsClientPerConnection connection =
                    this.smbClientStack.Context.GetConnection(ConnectionId);

                NamespaceCifs.CifsClientPerSession session =
                    this.smbClientStack.Context.GetSession(ConnectionId, uid);

                smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey);
            }

            #endregion

            #region Send and Receive ExpectPacket

            this.smbClientStack.SendPacket(smbPacket);
            StackPacket response = this.smbClientStack.ExpectPacket(this.timeout);

            NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response;

            this.QueryUidTable(smbPacketResponse);
            this.QueryTidTable(smbPacketResponse);

            VerifyTransport(smbPacketResponse);
            VerifyCommonMessageSyntax(smbPacketResponse);

            if (response.GetType() == typeof(SmbErrorResponsePacket))
            {
                SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket;
                NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader;

                if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass)
                {
                    smbErrorHeader.Status = (uint)MessageStatus.NotSupported;
                }

                //Workaround temp code (SetFsInfo Unknown Error TDQ)
                if (informationLevel == InformationLevel.FileFsControlInformaiton &&
                    !bool.Parse(Site.Properties["IsTDQ33016Fixed"]))
                {
                    this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, MessageStatus.AccessDenied);
                }
                else
                {
                    this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
                }
            }
            else
            {
                SmbTrans2SetFsInformationResponsePacket smbTrans2SetFsInformationPacket
                    = response as SmbTrans2SetFsInformationResponsePacket;

                NamespaceCifs.SmbHeader trans2SetFsInformationResponseHeader =
                    smbTrans2SetFsInformationPacket.SmbHeader;

                if (this.Trans2SetFsInfoResponse != null)
                {
                    this.Trans2SetFsInfoResponse(
                        trans2SetFsInformationResponseHeader.Mid + this.addMidMark,
                        this.QueryUidTable(smbPacketResponse),
                        this.QueryTidTable(smbPacketResponse),
                        (smbPacketResponse).IsSignRequired,
                        (MessageStatus)trans2SetFsInformationResponseHeader.Status);
                }
                else
                {
                    this.Trans2SetFsInfoResponseAdditional(
                        trans2SetFsInformationResponseHeader.Mid + this.addMidMark,
                        this.QueryUidTable(smbPacketResponse),
                        this.QueryTidTable(smbPacketResponse),
                        (smbPacketResponse).IsSignRequired,
                        (MessageStatus)trans2SetFsInformationResponseHeader.Status);
                }
            }

            #endregion
        }
 /// <summary>
 /// TRANS2_FIND_NEXT2 Request.
 /// </summary>
 /// <param name="messageId">This is used to associate a response with a request.</param>
 /// <param name="sessionId">
 /// Set this value to 0 to request a new session setup, or set this value to a previously established session
 /// identifier to request the re-authentication of an existing session.
 /// </param>
 /// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
 /// <param name="gmtTokenIndex">The index of the GMT token configured by CheckPreviousVersion action</param>
 /// <param name="isReparse">
 /// It indicates whether the SMB_FLAGS2_REPARSE_PATH is set in the Flag2 field of the SMB header.
 /// </param>
 /// <param name="informationLevel">This can be used to query information from the SUT.</param>
 /// <param name="searchHandlerId">Search Handler.</param>
 /// <param name="isFlagsKnowsLongNameSet">
 /// It indicates the adapter to set SMB_FLAGS2_KNOWS_LONG_NAMES flag in SMB header or not.
 /// </param>
 public Trans2FindNext2Request(
     int messageId,
     int sessionId,
     int treeId,
     int searchHandlerId,
     int gmtTokenIndex,
     bool isReparse,
     InformationLevel informationLevel,
     bool isFlagsKnowsLongNameSet)
     : base(messageId, Command.TransFindNext2)
 {
     this.sessionId = sessionId;
     this.treeId = treeId;
     this.searchHandlerId = searchHandlerId;
     this.gmtTokenIndex = gmtTokenIndex;
     this.isReparse = isReparse;
     this.informationLevel = informationLevel;
     this.isFlagsKnowsLongNameSet = isFlagsKnowsLongNameSet;
 }
 /// <summary>
 /// TRANS2_SET_PATH_INFORMATION Request.
 /// </summary>
 /// <param name="messageId">This is used to associate a response with a request.</param>
 /// <param name="sessionId">
 /// Set this value to 0 to request a new session setup, or set this value to a previously established session
 /// identifier to request the re-authentication of an existing session.
 /// </param>
 /// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
 /// <param name="isSigned">It indicates whether the SUT has message signing enabled or required.</param>
 /// <param name="isUsePassthrough">
 /// It indicates whether adding SMB_INFO_PASSTHROUGH in InformationLevel field of the request.
 /// </param>
 /// <param name="isReparse">
 /// It indicates whether the SMB_FLAGS2_REPARSE_PATH is set in the Flag2 field of the SMB header.
 /// </param>
 /// <param name="gmtTokenIndex">The index of the GMT token configured by CheckPreviousVersion action</param>
 /// <param name="informationLevel">This can be used to query information from the SUT.</param>
 public Trans2SetPathInfoRequest(
     int messageId,
     int sessionId,
     int treeId,
     bool isSigned,
     bool isUsePassthrough,
     bool isReparse,
     int gmtTokenIndex,
     InformationLevel informationLevel)
     : base(messageId, Command.Trans2SetPathInforamtion)
 {
     this.sessionId = sessionId;
     this.treeId = treeId;
     this.isSigned = isSigned;
     this.isUsePassthrough = isUsePassthrough;
     this.isReparse = isReparse;
     this.gmtTokenIndex = gmtTokenIndex;
     this.informationLevel = informationLevel;
 }
 /// <summary>
 /// TRANS2_SET_FILE_INFORMATION Request.
 /// </summary>
 /// <param name="messageId">This is used to associate a response with a request.</param>
 /// <param name="sessionId">
 /// Set this value to 0 to request a new session setup, or set this value to a previously established session
 /// identifier to request the re-authentication of an existing session.
 /// </param>
 /// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
 /// <param name="isSigned">It indicates whether the SUT has message signing enabled or required.</param>
 /// <param name="replaceEnable">
 /// It indicates whether the new name or link will replace the original one that exists already.
 /// </param>
 /// <param name="fId">The SMB file identifier of the target directory.</param>
 /// <param name="isUsePassthrough">
 /// It indicates whether adding SMB_INFO_PASSTHROUGH in InformationLevel field of the request.
 /// </param>
 /// <param name="fileName">The This is used to represent the name of the resource.</param>
 /// <param name="informationLevel">This can be used to query information from the SUT.</param>
 /// <param name="isRootDirectory">Whether RootDirectory is null</param>
 public Trans2SetFileInfoRequest(
     int messageId,
     int sessionId,
     int treeId,
     bool isSigned,
     bool replaceEnable,
     bool isUsePassthrough,
     int fId,
     string fileName,
     InformationLevel informationLevel,
     bool isRootDirectory)
     : base(messageId, Command.Trans2SetFileInformation)
 {
     this.sessionId = sessionId;
     this.treeId = treeId;
     this.isSigned = isSigned;
     this.replaceEnable = replaceEnable;
     this.isUsePassthrough = isUsePassthrough;
     this.fId = fId;
     this.fileName = fileName;
     this.informationLevel = informationLevel;
     this.isRootDirectory = isRootDirectory;
 }
        /// <summary>
        /// Verify TRAN2_FIND_FIRST2 Client Request.
        /// </summary>
        /// <param name="informationLevel">The InformationLevel in the Trans2Parameters of the 
        /// TRAN2_FIND_FIRST2 Client Request.</param>
        /// <param name="response">The TRAN2_FIND_FIRST2 Server Response.</param>
        /// <param name="isFindFullDirectoryInfoNull">To verify whether the struct of 
        /// SMB_FIND_FILE_FULL_DIRECTORY_INFO_OF_TRANS2_FIND_FIRST2 is null or not.</param>
        /// <param name="isFindBothDirectoryInfoNull">To verify whether the struct of 
        /// SMB_FIND_FILE_BOTH_DIRECTORY_INFO_OF_TRANS2_FIND_FIRST2 is null or not.</param>
        private void VerifyMessageSyntaxTrans2FindFirst2Request(
            InformationLevel informationLevel,
            SmbTrans2FindFirst2ResponsePacket response,
            bool isFindFullDirectoryInfoNull,
            bool isFindBothDirectoryInfoNull)
        {
            // SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO and SMB_FIND_FILE_ID_FULL_DIRECTORY_INFO are the new
            // informationLevel specified in section 2.2.2.3.1.
            if ((informationLevel == InformationLevel.SmbFindFileIdBothDirectoryInfo)
               || (informationLevel == InformationLevel.SmbFindFileIdFullDirectoryInfo))
            {
                // The following statement code will be run only when debugging.
                //
                Site.Log.Add(LogEntryKind.Debug,
                    @"Verify MS-SMB_R2404 ,isfindIdFullDirectoryInfoNull is : {0},
                    isfinIdBothDirectoryInfoNull is {1}",
                    isFindFullDirectoryInfoNull,
                    isFindBothDirectoryInfoNull);

                //
                // Verify MS-SMB requirement: MS-SMB_R2404.
                //
                // If one of the new Information Levels structure isn't null, it means the structure has been used for
                // the return of subsequent entries in the enumeration continuation.
                bool isVerifyR2404 = (isFindFullDirectoryInfoNull
                    || isFindBothDirectoryInfoNull);

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR2404,
                    2404,
                    @"[In Receiving a TRANS2_FIND_NEXT2 Request New Information Levels] If the query is started using
                    one of the new Information Levels, then as specified in section 2.2.2.3.1, the same Information
                    Level structure MUST be used for the return of subsequent entries in the enumeration
                    continuation.");

                if (isWindows)
                {
                    // 0x0105 is the number of SMB_FIND_FILE_ID_FULL_DIRECTORY_INFO,
                    // 0x0106 is the number of SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO,
                    // These two numbers are the new Infromation Level.

                    //
                    // The following statement code will be run only when debugging.
                    //
                    Site.Log.Add(LogEntryKind.Debug,
                        @"Verify MS-SMB_R30038");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R30038.
                    //
                    // 0xC00000BB is the errorcode STATUS_NOT_SUPPORTED's number.
                    // According to TD, if the SUT doesn't support the new Information Levels, it will
                    // return STATUS_NOT_SUPPORTED. Otherwise it wouldn't return STATUS_NOT_SUPPORTED.
                    Site.CaptureRequirementIfAreNotEqual<uint>(
                        0xC00000BB,
                        response.SmbHeader.Status,
                        30038,
                        @"[InReceiving a TRANS2_FIND_FIRST2 Request New Information Levels] <123> Section
                        3.3.5.9.2:Windows servers support these new Information Levels for directory queries.");
                }
                if (informationLevel == InformationLevel.SmbFindFileIdBothDirectoryInfo)
                {
                    SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO[] payload =
                    (SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO[])response.Trans2Data.Data;
                    //
                    // Verify MS-SMB requirement: MS-SMB_R9487.
                    //
                    Site.CaptureRequirementIfAreEqual<CIFS.SmbFileAttributes32>(
                        CIFS.SmbFileAttributes32.FILE_ATTRIBUTE_DIRECTORY,
                        (CIFS.SmbFileAttributes32)payload[0].FileAttributes,
                        9487,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO Extensions]ExtFileAttributes (4 bytes):  Extended attributes
                for this file that MUST be marked as a DIRECTORY.");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R9488.
                    //
                    Site.CaptureRequirementIfAreEqual<uint>(
                        0,
                        payload[0].EaSize,
                        9488,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO Extensions]EaSize (4 bytes):  This field MUST be set to zero
                when sending a response .");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R9491.
                    //
                    Site.CaptureRequirementIfAreEqual<uint>(
                        0x00,
                        payload[0].Reserved,
                        9491,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO] Reserved (1 byte):  This member MUST be 0x00.");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R9493.
                    //
                    Site.CaptureRequirementIfAreEqual<uint>(
                        0x0000,
                        payload[0].Reserved2,
                        9493,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO]Reserved2 (2 bytes):This member MUST be 0x0000.");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R3478.
                    //
                    Site.CaptureRequirementIfAreEqual<uint>(
                        0x0000,
                        payload[0].Reserved2,
                        3478,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO]Reserved2 (2 bytes):This member MUST be 0x0000.");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R9483.
                    //
                    Site.CaptureRequirementIfAreEqual<ulong>(
                        0x00000000,
                        payload[0].FileIndex,
                        9483,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO]FileIndex (4 bytes):  This field MUST be set to zero when sending a response.");

                    //
                    // Verify MS-SMB requirement: MS-SMB_R9485.
                    //
                    Site.CaptureRequirementIfAreEqual<ulong>(
                        0x00000000,
                        payload[0].AllocationSize,
                        9485,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO]AllocationSize (8 bytes):  This LARGE_INTEGER field MUST be set to zero when sending a response.");

                    //
                    // The following statement code will be run only when debugging.
                    //
                    Site.Log.Add(LogEntryKind.Debug,
                        @"Verify MS-SMB_R9495");

                    // If Field isn't unique, it will throw exception and the case will stop and won't come here.
                    // So this requirement has been verified by the protocol SDK.
                    Site.CaptureRequirement(
                        9495,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO]FileId (8 bytes):This number MUST be unique
                        for each file on a given volume.");

                    //
                    // The following statement code will be run only when debugging.
                    //
                    Site.Log.Add(LogEntryKind.Debug,
                        @"Verify MS-SMB_R3480");

                    // If Field isn't unique, it will throw exception and the case will stop and won't come here.
                    // So this requirement has been verified by the protocol SDK.
                    Site.CaptureRequirement(
                        3480,
                        @"[In SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO]FileId (8 bytes):This number MUST be unique
                        for each file on a given volume.");
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// 情報パネルへメッセージ及びレベルに応じたCSSを適用します。
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="icon"></param>
        /// <param name="label"></param>
        /// <param name="message"></param>
        /// <param name="level"></param>
        public static void SetInformationPanel(ref Panel panel, ref Label icon, ref Label label, string message, InformationLevel level)
        {
            logger.Debug(LOG_START);
            string IconCssClass  = "ui-icon floatLeft ";
            string PanelCssClass = "ui-corner-all ";

            switch (level)
            {
            case InformationLevel.None:
                // 表示させない
                panel.Visible = false;
                break;

            case InformationLevel.Highlight:
                // 情報パネル
                label.Text     = message;
                icon.CssClass  = IconCssClass + "ui-icon-info";
                panel.CssClass = PanelCssClass + "ui-state-highlight";
                panel.Visible  = true;
                break;

            case InformationLevel.Error:
                // エラーパネル
                label.Text     = message;
                icon.CssClass  = IconCssClass + "ui-icon-alert";
                panel.CssClass = PanelCssClass + "ui-state-error";
                panel.Visible  = true;
                break;

            default:
                // デフォルトは非表示
                panel.Visible = false;
                break;
            }
        }
Esempio n. 32
0
        public string ArmyQuantityInInformationLevel(InformationLevel level)
        {
            switch (level)
            {
                case InformationLevel.未知:
                    return "----";

                case InformationLevel.无:
                    return "----";

                case InformationLevel.低:
                    return StaticMethods.GetNumberStringByGranularity(this.ArmyQuantity, 0x2710);

                case InformationLevel.中:
                    return StaticMethods.GetNumberStringByGranularity(this.ArmyQuantity, 0x1388);

                case InformationLevel.高:
                    return StaticMethods.GetNumberStringByGranularity(this.ArmyQuantity, 0x3e8);

                case InformationLevel.全:
                    return this.ArmyQuantity.ToString();
            }
            return "----";
        }
 public InformationEvent(string message, InformationLevel level)
 {
     Message = message;
     Level   = level;
 }
Esempio n. 34
0
        public string EnduranceInInformationLevel(InformationLevel level)
        {
            switch (level)
            {
                case InformationLevel.未知:
                    return "----";

                case InformationLevel.无:
                    return "----";

                case InformationLevel.低:
                    return StaticMethods.GetNumberStringByGranularity(this.Endurance, 500);

                case InformationLevel.中:
                    return StaticMethods.GetNumberStringByGranularity(this.Endurance, 200);

                case InformationLevel.高:
                    return StaticMethods.GetNumberStringByGranularity(this.Endurance, 100);

                case InformationLevel.全:
                    return this.Endurance.ToString();
            }
            return "----";
        }
Esempio n. 35
0
 public SmallTalksPreProcessingConfiguration()
 {
     UnicodeNormalization = false;
     ToLower          = true;
     InformationLevel = InformationLevel.MINIMUM;
 }
Esempio n. 36
0
 public InformationEvent(string message, InformationLevel level)
 {
     Message = message;
     Level = level;
 }
 public static void OnInformation(this IHasContext obj, string message, InformationLevel level)
 {
     obj.OnEvent(new InformationEvent(message, level));
 }