Beispiel #1
0
        /// <inheritdoc/>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                await JSModule.Initialize(DotNetObjectRef, ElementRef, ElementId, new
                {
                    Controls,
                    AutomaticallyHideControls,
                    AutoPlay,
                    AutoPause,
                    Muted,
                    Source,
                    Poster,
                    StreamingLibrary = StreamingLibrary.ToStreamingLibrary(),
                    SeekTime,
                    CurrentTime,
                    Volume,
                    ClickToPlay,
                    DisableContextMenu,
                    ResetOnEnd,
                    Ratio,
                    InvertTime,
                    Protection = ProtectionType != VideoProtectionType.None ? new
                    {
                        Data               = ProtectionData,
                        Type               = ProtectionType.ToVideoProtectionType(),
                        ServerUrl          = ProtectionServerUrl,
                        HttpRequestHeaders = ProtectionHttpRequestHeaders
                    } : null
                });
            }

            await base.OnAfterRenderAsync(firstRender);
        }
Beispiel #2
0
 internal LinkDetailsV2(
     string path,
     LinkType type,
     LinkAccessibility accessibility,
     bool notify,
     bool linkToCurrent,
     DateTime creationDate,
     string createdBy,
     ProtectionType protection,
     List <string> recipients,
     string url,
     string id,
     string resourceId,
     int expiry_clicks,
     DateTime expiry_date)
     : base(
         path,
         type,
         accessibility,
         notify,
         linkToCurrent,
         creationDate,
         createdBy,
         protection,
         recipients,
         url,
         id)
 {
     ResourceId   = resourceId;
     ExpiryClicks = expiry_clicks;
     ExpiryDate   = expiry_date;
 }
 public void GetProtectionType()
 {
     //ExStart:GetProtectionType
     Document       doc            = new Document(MyDir + "Document.docx");
     ProtectionType protectionType = doc.ProtectionType;
     //ExEnd:GetProtectionType
 }
Beispiel #4
0
        public DefMember(XmlElement elem)
        {
            this._elem          = elem;
            this.ProtectionType = DefType.GetProtectionEnum(elem.GetAttribute("protection"));
            this.PassedByType   = (PassedByType)Enum.Parse(typeof(PassedByType), elem.GetAttribute("passedBy"), true);

            foreach (XmlElement child in elem.ChildNodes)
            {
                switch (child.Name)
                {
                case "name":
                    _name = child.InnerText;
                    break;

                case "type":
                    this.TypeName        = child.InnerText;
                    this._container      = child.GetAttribute("container");
                    this._containerKey   = child.GetAttribute("containerKey");
                    this._containerValue = child.GetAttribute("containerValue");
                    break;

                case "definition":
                    this.Definition = child.InnerText;
                    break;

                default:
                    InterpretChildElement(child);
                    break;
                }
            }
        }
Beispiel #5
0
            public static async Task TriggeredAntiProtection(IGuildUser[] users, PunishmentAction action, ProtectionType protection)
            {
                if (users.Length == 0)
                    return;

                LogSetting logSetting;
                if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out logSetting)
                    || !logSetting.IsLogging)
                    return;
                ITextChannel logChannel;
                if ((logChannel = TryGetLogChannel(users.First().Guild, logSetting)) == null)
                    return;

                var punishment = "";
                if (action == PunishmentAction.Mute)
                {
                    punishment = "🔇 MUTED";
                    //punishment = "MUTED";
                }
                else if (action == PunishmentAction.Kick)
                {
                    punishment = "☣ SOFT-BANNED (KICKED)";
                    //punishment = "KICKED";
                }
                else if (action == PunishmentAction.Ban)
                {
                    punishment = "⛔️ BANNED";
                    //punishment = "BANNED";
                }
                await logChannel.SendMessageAsync(String.Join("\n",users.Select(user=>$"‼️ {Format.Bold(user.ToString())} got **{punishment}** due to __**{protection}**__ protection on **{user.Guild.Name}** server.")))
                //await logChannel.SendMessageAsync(String.Join("\n",users.Select(user=>$"{Format.Bold(user.ToString())} was **{punishment}** due to `{protection}` protection on **{user.Guild.Name}** server.")))
                                .ConfigureAwait(false);
            }
Beispiel #6
0
        /// <summary>
        /// Sets the protection type that the user has for transformations on the given server.
        /// </summary>
        /// <param name="discordUser">The user to set the protection for.</param>
        /// <param name="discordServer">The server to set the protection on.</param>
        /// <param name="protectionType">The protection type to set.</param>
        /// <returns>An entity modification result which may or may not have succeeded.</returns>
        public async Task <ModifyEntityResult> SetServerProtectionTypeAsync
        (
            IUser discordUser,
            IGuild discordServer,
            ProtectionType protectionType
        )
        {
            var getServerProtectionResult = await GetOrCreateServerUserProtectionAsync(discordUser, discordServer);

            if (!getServerProtectionResult.IsSuccess)
            {
                return(ModifyEntityResult.FromError(getServerProtectionResult));
            }

            var protection = getServerProtectionResult.Entity;

            if (protection.Type == protectionType)
            {
                return(ModifyEntityResult.FromError($"{protectionType.Humanize()} is already your current setting."));
            }

            protection.Type = protectionType;
            await _database.SaveChangesAsync();

            return(ModifyEntityResult.FromSuccess());
        }
Beispiel #7
0
        public static string GetDisplayName(this ProtectionType protectionType)
        {
            switch (protectionType)
            {
            case ProtectionType.NONE:
                return("Missing");

            case ProtectionType.BOULDER:
                return("Bouldering");

            case ProtectionType.TOPROPE:
                return("Top Rope");

            case ProtectionType.SPORTFOLLOW:
                return("Follow (Sport)");

            case ProtectionType.TRADFOLLOW:
                return("Follow (Trad)");

            case ProtectionType.SPORTLEAD:
                return("Lead (Sport)");

            case ProtectionType.TRADLEAD:
                return("Lead (Trad)");

            case ProtectionType.ROPESOLO:
                return("Solo (Rope)");

            case ProtectionType.FREESOLO:
                return("Free Solo");

            default:
                return("Missing");
            }
        }
Beispiel #8
0
 internal void Protect(IntPtr baseAddress, int size, ProtectionType protectionType)
 {
     if (!Kernel32.VirtualProtectEx(_processHandle, baseAddress, size, protectionType, out _))
     {
         throw new Win32Exception($"Failed to call VirtualProtectEx with error code {Marshal.GetLastWin32Error()}");
     }
 }
        public IActionResult AddDefense([FromBody] AddDefenseInputDTO input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ProtectionType damageType = ProtectionType.Resistant;

            if (input.Protection == "immune")
            {
                damageType = ProtectionType.Immune;
            }

            Defense defense = new Defense(input.Type, damageType);

            var character = _repository.GetById(input.CharacterId);

            if (character == null)
            {
                return(BadRequest("Character does not exist."));
            }

            if (character.Defenses.Any(x => x.Protection == defense.Protection && x.Type == defense.Type))
            {
                return(BadRequest("Character already has this defense."));
            }

            character.AddDefense(defense);

            _context.SaveChanges();

            return(Ok(character));
        }
Beispiel #10
0
 internal LinkDetails(
     string path,
     LinkType type,
     LinkAccessibility accessibility,
     bool notify,
     bool linkToCurrent,
     DateTime creationDate,
     string createdBy,
     ProtectionType protection,
     List <string> recipients,
     string url,
     string id)
 {
     Path          = path;
     Type          = type;
     Accessibility = accessibility;
     Notify        = notify;
     LinkToCurrent = linkToCurrent;
     CreationDate  = creationDate;
     CreatedBy     = createdBy;
     Protection    = protection;
     Recipients    = recipients;
     Url           = url;
     Id            = id;
 }
Beispiel #11
0
 public Defense(
     string type,
     ProtectionType protection
     ) : this()
 {
     Type       = type;
     Protection = protection;
 }
 /// <summary>
 /// Encrypts data according to a specified protection type.
 /// </summary>
 /// <param name="type">One of the <see cref="ProtectionType"/> values.</param>
 /// <param name="data">The data to encrypt.</param>
 /// <param name="entropy">Additional entropy to use during the encyption process. This parameter can be set to null.</param>
 /// <exception cref="ArgumentNullException"><i>data</i> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
 /// <exception cref="CryptographicException">An error occurs during the encryption process. Under some circumstances, Microsoft cryptographic service providers may not allow encryption when used in France. This may occur on down-level platforms such as Windows 98 and Windows NT 4.0, depending on the system's configuration and the version of the CSPs.</exception>
 /// <returns>An array of encrypted bytes.</returns>
 /// <remarks>The number of the returned bytes will be larger than the number of input bytes.</remarks>
 public byte[] ProtectData(ProtectionType type, byte[] data, byte[] entropy)
 {
     if (data == null)
     {
         throw new ArgumentNullException();
     }
     return(ProtectData(type, data, 0, data.Length, entropy));
 }
Beispiel #13
0
        public Task TriggeredAntiProtection(PunishmentAction action, ProtectionType protection, params IGuildUser[] users)
        {
            var _ = Task.Run(async() =>
            {
                try
                {
                    if (users.Length == 0)
                    {
                        return;
                    }

                    if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out LogSetting logSetting) ||
                        (logSetting.LogOtherId == null))
                    {
                        return;
                    }
                    ITextChannel logChannel;
                    if ((logChannel = await TryGetLogChannel(users.First().Guild, logSetting, LogType.Other)) == null)
                    {
                        return;
                    }

                    var punishment = "";
                    switch (action)
                    {
                    case PunishmentAction.Mute:
                        punishment = "🔇 " + GetText(logChannel.Guild, "muted_pl").ToUpperInvariant();
                        break;

                    case PunishmentAction.Kick:
                        punishment = "👢 " + GetText(logChannel.Guild, "kicked_pl").ToUpperInvariant();
                        break;

                    case PunishmentAction.Softban:
                        punishment = "☣ " + GetText(logChannel.Guild, "soft_banned_pl").ToUpperInvariant();
                        break;

                    case PunishmentAction.Ban:
                        punishment = "⛔️ " + GetText(logChannel.Guild, "banned_pl").ToUpperInvariant();
                        break;
                    }

                    var embed = new EmbedBuilder().WithAuthor(eab => eab.WithName($"🛡 Anti-{protection}"))
                                .WithTitle(GetText(logChannel.Guild, "users") + " " + punishment)
                                .WithDescription(string.Join("\n", users.Select(u => u.ToString())))
                                .WithFooter(fb => fb.WithText(CurrentTime(logChannel.Guild)))
                                .WithOkColor();

                    await logChannel.EmbedAsync(embed).ConfigureAwait(false);
                }
                catch
                {
                    // ignored
                }
            });

            return(Task.CompletedTask);
        }
Beispiel #14
0
        internal ProtectionType ProtectBuffer(IntPtr address, int size, ProtectionType protectionType)
        {
            if (!Kernel32.VirtualProtectEx(_processHandle, address, size, protectionType, out var oldProtectionType))
            {
                throw new Win32Exception();
            }

            return(oldProtectionType);
        }
Beispiel #15
0
        /// <summary>
        /// Map section into a specific process
        /// </summary>
        /// <param name="process">The process to map into</param>
        /// <param name="type">The protection of the mapping</param>
        /// <returns>The mapped section</returns>
        public NtMappedSection Map(NtProcess process, ProtectionType type)
        {
            IntPtr base_address = IntPtr.Zero;
            IntPtr view_size    = new IntPtr(0);

            NtSystemCalls.NtMapViewOfSection(Handle, process.Handle, ref base_address, IntPtr.Zero,
                                             new IntPtr(0), null, ref view_size, SectionInherit.ViewUnmap, AllocationType.None, type).ToNtException();
            return(new NtMappedSection(base_address, view_size.ToInt64(), process, true));
        }
Beispiel #16
0
        //コピーコンストラクタ
        public ProtectionItem(ProtectionItem other)
            : base(other.itemID, other.itemName, other.itemExplanation,
                   other.itemPrice, other.itemRare, other.itemWeight, other.amountLimit)
        {
            this.protectionType = other.protectionType;

            effect = new EquipmentEffect(other.itemPower, other.itemDefense, other.reinforcementLimit,
                                         other.upPower, other.upDefense, other.randomMinP, other.randomMaxP, other.randomMinD, other.randomMaxD);
        }
        /// <summary>
        /// Shows how to get protection type
        /// </summary>
        /// <param name="inputFileName">input file name with complete path.</param>
        private static void GetProtectionType(string inputFileName)
        {
            // ExStart:GetProtectionType
            Document       doc            = new Document(inputFileName);
            ProtectionType protectionType = doc.ProtectionType;

            // ExEnd:GetProtectionType
            Console.WriteLine("\nDocument protection type is " + protectionType.ToString());
        }
            public void HasProtection_CorrectType_True(
                [ValueSource(typeof(ValuesEnumerator), "GetValues")] ProtectionType.ProtectionCategoryCodes category)
            {
                var pro = new ProtectionType {
                    ProtectionCategoryCode = category
                };
                var ret = pro.HasProtection(DateTime.Today, category);

                Assert.True(ret);
            }
            public void HasProtection_CorrectCategory_OK(
                [ValueSource(typeof(ValuesEnumerator), "GetValues")] ProtectionType.ProtectionCategoryCodes category)
            {
                var ret = ProtectionType.HasProtection(new ProtectionType[] { new ProtectionType()
                                                                              {
                                                                                  ProtectionCategoryCode = category
                                                                              } }, DateTime.Today, category);

                Assert.True(ret);
            }
Beispiel #20
0
        internal IntPtr Allocate(int size, ProtectionType protectionType)
        {
            var buffer = Kernel32.VirtualAllocEx(_processHandle, IntPtr.Zero, size, AllocationType.Commit | AllocationType.Reserve, protectionType);

            if (buffer == IntPtr.Zero)
            {
                throw new Win32Exception($"Failed to call VirtualAllocEx with error code {Marshal.GetLastWin32Error()}");
            }

            return(buffer);
        }
            public void HasProtection_CorrectTypeOutOfDateRange_False(
                [ValueSource(typeof(ValuesEnumerator), "GetValues")] ProtectionType.ProtectionCategoryCodes category)
            {
                DateTime today = DateTime.Today;
                var      pro   = new ProtectionType {
                    ProtectionCategoryCode = category, StartDate = today.AddDays(1), EndDate = today.AddDays(2)
                };
                var ret = pro.HasProtection(today, category);

                Assert.False(ret);
            }
Beispiel #22
0
        public async Task ReturnsUnsuccessfulResultIfSameTypeIsAlreadySet()
        {
            const ProtectionType currentType = ProtectionType.Blacklist;
            var result = await this.Transformations.SetDefaultProtectionTypeAsync
                         (
                _user,
                currentType
                         );

            Assert.False(result.IsSuccess);
        }
    internal static IntPtr AllocateBuffer(this Process process, int size, ProtectionType protectionType)
    {
        var address = Kernel32.VirtualAllocEx(process.SafeHandle, IntPtr.Zero, size, AllocationType.Commit | AllocationType.Reserve, protectionType);

        if (address == IntPtr.Zero)
        {
            throw new Win32Exception();
        }

        return(address);
    }
Beispiel #24
0
            private static async Task PunishUsers(PunishmentAction action, ProtectionType pt, params IGuildUser[] gus)
            {
                _log.Info($"[{pt}] - Punishing [{gus.Length}] users with [{action}] in {gus[0].Guild.Name} guild");
                foreach (var gu in gus)
                {
                    switch (action)
                    {
                    case PunishmentAction.Mute:
                        try
                        {
                            await MuteCommands.MuteUser(gu).ConfigureAwait(false);
                        }
                        catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); }
                        break;

                    case PunishmentAction.Kick:
                        try
                        {
                            await gu.KickAsync().ConfigureAwait(false);
                        }
                        catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); }
                        break;

                    case PunishmentAction.Softban:
                        try
                        {
                            await gu.Guild.AddBanAsync(gu, 7).ConfigureAwait(false);

                            try
                            {
                                await gu.Guild.RemoveBanAsync(gu).ConfigureAwait(false);
                            }
                            catch
                            {
                                await gu.Guild.RemoveBanAsync(gu).ConfigureAwait(false);

                                // try it twice, really don't want to ban user if
                                // only kick has been specified as the punishement
                            }
                        }
                        catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); }
                        break;

                    case PunishmentAction.Ban:
                        try
                        {
                            await gu.Guild.AddBanAsync(gu, 7).ConfigureAwait(false);
                        }
                        catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); }
                        break;
                    }
                }
                await LogCommands.TriggeredAntiProtection(gus, action, pt).ConfigureAwait(false);
            }
Beispiel #25
0
        //強化値指定
        public ProtectionItem(int itemID, string itemName, string itemExplanation,
                              int itemPrice, int itemRare, float itemWeight, ProtectionType protectionType,
                              int itemPower, int itemDefense, int reinforcement, int reinforcementLimit,
                              int upPower, int upDefense, int addPower, int addDefence)
            : base(itemID, itemName, itemExplanation, itemPrice, itemRare, itemWeight, 1)
        {
            this.protectionType = protectionType;

            effect = new EquipmentEffect(itemPower, itemDefense, reinforcementLimit,
                                         upPower, upDefense, addPower, addDefence, reinforcement);
        }
Beispiel #26
0
        internal static IntPtr AllocateMemory(this Process process, int size, ProtectionType protectionType)
        {
            var block = Kernel32.VirtualAllocEx(process.SafeHandle, IntPtr.Zero, size, AllocationType.Commit | AllocationType.Reserve, protectionType);

            if (block == IntPtr.Zero)
            {
                throw ExceptionBuilder.BuildWin32Exception("VirtualAllocEx");
            }

            return(block);
        }
            public void HasProtection_CorrectTypeWithDateRange_True(
                [ValueSource(typeof(ValuesEnumerator), "GetValues")] ProtectionType.ProtectionCategoryCodes category,
                [Values(0, 1, 2)] int offset)
            {
                DateTime today = DateTime.Today;
                var      pro   = new ProtectionType {
                    ProtectionCategoryCode = category, StartDate = today.AddDays(-offset), EndDate = today.AddDays(offset)
                };
                var ret = pro.HasProtection(today, category);

                Assert.True(ret);
            }
Beispiel #28
0
 public static extern NtStatus NtMapViewOfSection(
     SafeKernelObjectHandle SectionHandle,
     SafeKernelObjectHandle ProcessHandle,
     ref IntPtr BaseAddress,
     IntPtr ZeroBits,
     IntPtr CommitSize,
     [In, Out] LargeInteger SectionOffset,
     ref IntPtr ViewSize,
     SectionInherit InheritDisposition,
     AllocationType AllocationType,
     ProtectionType Win32Protect
     );
Beispiel #29
0
        public bool Allocate(ProtectionType protectionType = ProtectionType.PAGE_EXECUTE_READWRITE)
        {
            Address = Kernel32.VirtualAllocEx(
                ProcessHandle,
                0x0,
                Size,
                (uint)Memory.COMMIT,
                (uint)protectionType
                );

            return(Address != 0x0);
        }
Beispiel #30
0
        /// <summary>
        /// 保护当前工作表
        /// </summary>
        /// <param name="protectPassword"></param>
        /// <param name="protectionType"></param>
        public void ProtectWorksheet(string protectPassword, ProtectionType protectionType)
        {
            //如果工作表已经是保护的,假定原密码与新密码相同
            string oldPassword = string.Empty;

            if (this._worksheet.IsProtected)
            {
                oldPassword = protectPassword;
            }

            this._worksheet.Protect(protectionType, protectPassword, oldPassword);
        }
Beispiel #31
0
        public async Task CanSetType()
        {
            const ProtectionType expected = ProtectionType.Whitelist;
            var result = await this.Transformations.SetDefaultProtectionTypeAsync
                         (
                _user,
                expected
                         );

            Assert.True(result.IsSuccess);
            Assert.Equal(expected, this.Database.GlobalUserProtections.First().DefaultType);
        }
Beispiel #32
0
 public static string GetProtectionString(ProtectionType prot)
 {
     switch (prot)
     {
         case ProtectionType.Public:
             return "public";
         case ProtectionType.Protected:
             return "protected public";
         case ProtectionType.Private:
             return "private";
         default:
             throw new Exception("Unexpected");
     }
 }
        /***********Method  ProtectDocument Added by:Zeeshan*******/
        public bool ProtectDocument(string password, ProtectionType protectionType)
        {
            try
            {
                //check whether file is set or not
                if (FileName == "")
                    throw new Exception("No file name specified");

                //build URI
                string strURI = Product.BaseProductUri + "/words/" + FileName;
                strURI += "/protection";

                //sign URI
                string signedURI = Utils.Sign(strURI);

                //serialize the JSON request content
                ProtectionRequest protectionRequest = new ProtectionRequest();
                protectionRequest.Password = password;
                protectionRequest.ProtectionType = protectionType.ToString();

                string strJSON = JsonConvert.SerializeObject(protectionRequest);

                Stream responseStream = Utils.ProcessCommand(signedURI, "PUT", strJSON);
                StreamReader reader = new StreamReader(responseStream);
                
                //further process JSON response
                string strResponseJSON = reader.ReadToEnd();

                //Parse the json string to JObject
                JObject parsedJSON = JObject.Parse(strResponseJSON);

                //Deserializes the JSON to a object. 
                BaseResponse baseResponse = JsonConvert.DeserializeObject<BaseResponse>(parsedJSON.ToString());

                if (baseResponse.Code == "200" && baseResponse.Status == "OK")
                    return true;
                else
                    return false;
            
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public bool ProtectWorkbook(ProtectionType protectionType, string password)
        {
            try
            {
                //build URI to get page count
                string strURI = Product.BaseProductUri + "/cells/" + FileName + "/protection";
                string signedURI = Utils.Sign(strURI);

                //serialize the JSON request content
                Protection protection = new Protection();
                protection.ProtectionType = protectionType.ToString();
                protection.Password = password;

                string strJSON = JsonConvert.SerializeObject(protection);

                Stream responseStream = Utils.ProcessCommand(signedURI, "POST", strJSON);

                StreamReader reader = new StreamReader(responseStream);
                string strResponse = reader.ReadToEnd();

                //Parse the json string to JObject
                JObject pJSON = JObject.Parse(strResponse);

                BaseResponse baseResponse = JsonConvert.DeserializeObject<BaseResponse>(pJSON.ToString());

                if (baseResponse.Code == "200" && baseResponse.Status == "OK")
                    return true;
                else
                    return false;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 private async Task PunishUsers(PunishmentAction action, IRole muteRole, ProtectionType pt, params IGuildUser[] gus)
 {
     foreach (var gu in gus)
     {
         switch (action)
         {
             case PunishmentAction.Mute:
                 try
                 {
                     await gu.AddRolesAsync(muteRole);
                 }
                 catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); }
                 break;
             case PunishmentAction.Kick:
                 try
                 {
                     await gu.Guild.AddBanAsync(gu, 7);
                     try
                     {
                         await gu.Guild.RemoveBanAsync(gu);
                     }
                     catch
                     {
                         await gu.Guild.RemoveBanAsync(gu);
                         // try it twice, really don't want to ban user if 
                         // only kick has been specified as the punishement
                     }
                 }
                 catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); }
                 break;
             case PunishmentAction.Ban:
                 try
                 {
                     await gu.Guild.AddBanAsync(gu, 7);
                 }
                 catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); }
                 break;
             default:
                 break;
         }
     }
     await LogCommands.TriggeredAntiProtection(gus, action, pt).ConfigureAwait(false);
 }
		/// <summary>
		/// Encrypts data according to a specified protection type.
		/// </summary>
		/// <param name="type">One of the <see cref="ProtectionType"/> values.</param>
		/// <param name="data">The data to encrypt.</param>
		/// <param name="entropy">Additional entropy to use during the encyption process. This parameter can be set to null.</param>
		/// <exception cref="ArgumentNullException"><i>data</i> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
		/// <exception cref="CryptographicException">An error occurs during the encryption process. Under some circumstances, Microsoft cryptographic service providers may not allow encryption when used in France. This may occur on down-level platforms such as Windows 98 and Windows NT 4.0, depending on the system's configuration and the version of the CSPs.</exception>
		/// <returns>An array of encrypted bytes.</returns>
		/// <remarks>The number of the returned bytes will be larger than the number of input bytes.</remarks>
		public byte[] ProtectData(ProtectionType type, byte[] data, byte[] entropy) {
			if (data == null)
				throw new ArgumentNullException();
			return ProtectData(type, data, 0, data.Length, entropy);
		}
		/// <summary>
		/// Encrypts data according to a specified protection type.
		/// </summary>
		/// <param name="type">One of the <see cref="ProtectionType"/> values.</param>
		/// <param name="data">The data to encrypt.</param>
		/// <exception cref="ArgumentNullException"><i>data</i> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
		/// <exception cref="CryptographicException">An error occurs during the encryption process. Under some circumstances, Microsoft cryptographic service providers may not allow encryption when used in France. This may occur on down-level platforms such as Windows 98 and Windows NT 4.0, depending on the system's configuration and the version of the CSPs.</exception>
		/// <returns>An array of encrypted bytes.</returns>
		/// <remarks>
		/// The number of the returned bytes will be larger than the number of input bytes.
		/// The method will use the entropy from the <see cref="Entropy"/> property.
		/// </remarks>
		public byte[] ProtectData(ProtectionType type, byte[] data) {
			return ProtectData(type, data, this.Entropy);
		}
 public WordsProtectionRequest(string password, string newPassword, ProtectionType protectionType)
 {
     Password = password;
     NewPassword = newPassword;
     ProtectionType = protectionType.ToString();
 }
        public ForkProtection(ProtectionType protectionType)
        {
            this.ProtectionType = protectionType;
            this.CriticalProcessesCount = BaseCriticalProcessesCount;
            this.WarningProcessesCount = MinimumWarningProcessesCount;

            this.ProcessesCount = new Dictionary<string, int>();
            this.ProcessesExclusion = new List<string>();
            this.ProcessesExclusion.Add("svchost");

            this.BannedProcesses = new List<string>();

            this.DetectionTimer = new Timer();
            this.DetectionTimer.Interval = 100;
            this.DetectionTimer.Enabled = false;
            this.DetectionTimer.Elapsed += new ElapsedEventHandler(Handler_DetectionTimerTick);
        }
		/// <summary>
		/// Encrypts data according to a specified protection type.
		/// </summary>
		/// <param name="type">One of the <see cref="ProtectionType"/> values.</param>
		/// <param name="data">The data to encrypt.</param>
		/// <param name="offset">The zero-based position in the <i>data</i> parameter at which to begin encrypting.</param>
		/// <param name="size">The number of bytes to encrypt.</param>
		/// <param name="entropy">Additional entropy to use during the encryption process. This parameter can be set to null.</param>
		/// <exception cref="ArgumentNullException"><i>data</i> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
		/// <exception cref="ArgumentException">The specified <i>offset</i> or <i>size</i> exceeds the size of buffer.</exception>
		/// <exception cref="CryptographicException">An error occurs during the encryption process. Under some circumstances, Microsoft cryptographic service providers may not allow encryption when used in France. This may occur on down-level platforms such as Windows 98 and Windows NT 4.0, depending on the system's configuration and the version of the CSPs.</exception>
		/// <returns>An array of encrypted bytes.</returns>
		/// <remarks>The number of the returned bytes will be larger than the number of input bytes.</remarks>
		public byte[] ProtectData(ProtectionType type, byte[] data, int offset, int size, byte[] entropy) {
			if (m_Disposed)
				throw new ObjectDisposedException(this.GetType().FullName);
			if (data == null)
				throw new ArgumentNullException();
			if (offset < 0 || offset + size > data.Length || !Enum.IsDefined(typeof(ProtectionType), type))
				throw new ArgumentException();
			DataBlob input = new DataBlob();
			DataBlob entr = new DataBlob();
			DataBlob output = new DataBlob();
			try {
				// initialize input structure
				input.cbData = size;
				input.pbData = Marshal.AllocHGlobal(size);
				Marshal.Copy(data, offset, input.pbData, size);
				// initialize entropy structure
				if (entropy == null) {
					entr.cbData = 0;
					entr.pbData = IntPtr.Zero;
				} else {
					entr.cbData = entropy.Length;
					entr.pbData = Marshal.AllocHGlobal(entr.cbData);
					Marshal.Copy(entropy, 0, entr.pbData, entr.cbData);
				}
				// initialize output structure
				output.cbData = 0;
				output.pbData = IntPtr.Zero;
				// call the function and check for errors
				int flags = 0;
				if (type == ProtectionType.LocalMachine)
					flags = flags | SecurityConstants.CRYPTPROTECT_LOCAL_MACHINE;
				if (!Environment.UserInteractive)
					flags = flags | SecurityConstants.CRYPTPROTECT_UI_FORBIDDEN;
				if (SspiProvider.CryptProtectData(ref input, "", ref entr, IntPtr.Zero, IntPtr.Zero, flags, ref output) == 0 || output.pbData == IntPtr.Zero)
					throw new CryptographicException("The data could not be protected.");
				byte[] ret = new byte[output.cbData];
				Marshal.Copy(output.pbData, ret, 0, output.cbData);
				return ret;
			} finally {
				if (input.pbData != IntPtr.Zero)
					Marshal.FreeHGlobal(input.pbData);
				if (entr.pbData != IntPtr.Zero)
					Marshal.FreeHGlobal(entr.pbData);
				if (output.pbData != IntPtr.Zero)
					Marshal.FreeHGlobal(output.pbData);
			}
		}