コード例 #1
0
        public StringConst GetNextStringConst()
        {
            if (this.lastStringConstPosition < this.StringConsts.Count)
            {
                StringConst stringConst = this.StringConsts[this.lastStringConstPosition];
                this.lastStringConstPosition++;

                return(stringConst);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        static public StringConst FindStringConst(int index, string text)
        {
            if (index < text.Length)
            {
                Regex regexToFindStringConsts = new Regex(@"(?<="")[\w,\W]*?(?="")");
                Match stringConstsMatch       = regexToFindStringConsts.Match(text, index);
                if (stringConstsMatch.Success)
                {
                    string value = stringConstsMatch.Value;

                    StringConst newStringConst = new StringConst(stringConstsMatch.Value, stringConstsMatch.Index);

                    return(newStringConst);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: Programm.cs プロジェクト: kirsen/Obfuscator
        public static StringConst FindStringConst(int index, string text)
        {
            if (index < text.Length)
            {
                Regex regexToFindStringConsts = new Regex(@"(?<="")[\w,\W]*?(?="")");
                Match stringConstsMatch = regexToFindStringConsts.Match(text, index);
                if (stringConstsMatch.Success)
                {
                    string value = stringConstsMatch.Value;

                    StringConst newStringConst = new StringConst(stringConstsMatch.Value, stringConstsMatch.Index);

                    return newStringConst;

                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
コード例 #4
0
        private string WorkWithConsts(string text)
        {
            Func     func;
            IntConst intConst = null;

            int lastIntConstIndex = 0;
            int lastFuncIndex     = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                lastIntConstIndex = 0;
                string callFuncToRead = "";
                while ((func = Programm.FindFunc(lastFuncIndex, text)) != null && (intConst = Programm.FindIntConst(lastIntConstIndex + callFuncToRead.Length, func.GetBody())) != null)
                {
                    int index       = this._table.AddVar(intConst.GetItemForVar());
                    int posIntoText = intConst.GetIndexIntoText() + func.GetIndexBody() + func.GetIndexFuncIntoText();

                    text           = text.Remove(posIntoText, intConst.GetLength());
                    callFuncToRead = this.GetFuncCallToRead(index, "int");
                    text           = text.Insert(posIntoText, callFuncToRead);

                    lastIntConstIndex = intConst.GetIndexIntoText();
                }
                lastFuncIndex = func.GetIndexFuncIntoText() + func.GetFuncText().Length;
            }

            StringConst stringConst = null;

            int lastStringConstIndex = 0;

            lastFuncIndex = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                lastStringConstIndex = 0;
                string callFuncToRead = "";
                while ((func = Programm.FindFunc(lastFuncIndex, text)) != null && (stringConst = Programm.FindStringConst(lastStringConstIndex + callFuncToRead.Length, func.GetBody())) != null)
                {
                    int index       = this._table.AddVar(stringConst.GetItemForVar());
                    int posIntoText = stringConst.GetIndexIntoText() + func.GetIndexBody() + func.GetIndexFuncIntoText();
                    // 2 кавычки
                    text = text.Remove(posIntoText, stringConst.GetLength() + 2);

                    callFuncToRead = this.GetFuncCallToRead(index, "string");

                    /*callFuncToRead = "(" + this.GetFuncCallToRead(index, "char");
                     *
                     * for (int i = 1; i < stringConst.GetLength(); i++)
                     * {
                     *  int indexOfChar = index + i;
                     *  callFuncToRead += "+"+this.GetFuncCallToRead(indexOfChar, "char");
                     * }
                     *
                     * callFuncToRead += ").ToString()";*/
                    text = text.Insert(posIntoText, callFuncToRead);

                    lastStringConstIndex = stringConst.GetIndexIntoText();
                }
                lastFuncIndex = func.GetIndexFuncIntoText() + func.GetFuncText().Length;
            }

            return(text);
        }