/// <summary>
        /// Cache a Pointer and your response
        /// </summary>
        /// <param name="Input">Original Pointer</param>
        /// <param name="Output">Response Pointer</param>
        internal static void CachePtr(IntPtr Input, IntPtr Output)
        {
            if (PtrCacheIn.Contains(Input))
            {
                return;
            }

            if (CacheArrPtr > CacheLength)
            {
                CacheArrPtr = 0;
            }

            PtrCacheIn.Insert(CacheArrPtr, Input);
            PtrCacheOut.Insert(CacheArrPtr++, Output);

#if DEBUG
            if (Debugging)
            {
                Log("\"{0:D16}\" Added to the cache at {1}", false, Output, CacheArrPtr - 1);
            }
#endif
        }
Beispiel #2
0
        internal static IntPtr ProcessReal(IntPtr Target)
        {
            again :;
            int Tries = 0;

            try {
                DateTime?Begin = DelayTest ? DateTime.Now : (DateTime?)null;
                dynamic  Ptr   = ParsePtr(Target);

                if (StrRld == null)
                {
                    try {
                        Init();
                        Log("Initiallized", true);
                    } catch (Exception ex) {
                        PreserveStackTrace(ex);
                        throw ex;
                    }
                    Initialized = true;
                }

                if (Ptr == 0)
                {
                    return(IntPtr.Zero);
                }


#if DEBUG
                if (LogAll)
                {
                    Log("Target: {0} | Ptr: {1} | char.MaxValue {2} | Convert: {3}", true, Target.ToString(), Ptr, char.MaxValue, unchecked ((uint)Ptr));
                }
#endif

                if (!LiteMode)
                {
                    if (Ptr <= char.MaxValue)
                    {
                        return(ProcessChar(Target));
                    }

                    if (CachePointers)
                    {
                        if (PtrCacheIn.Contains(Target))
                        {
                            return(PtrCacheOut[PtrCacheIn.IndexOf(Target)]);
                        }
                    }
                }

                if (IsBadCodePtr(Target) && Ptr >= char.MaxValue)
                {
                    if (LogAll)
                    {
                        Log("BAD PTR: {0}", true, Ptr);
                    }
                    return(Target);
                }

                string Input = GetString(Target);

                if (string.IsNullOrWhiteSpace(Input))
                {
                    return(Target);
                }

                string Reloaded = StrMap(Input, Target, false);

                LastInput = Input;

                if (Input != Reloaded)
                {
                    Reloaded = PostReload(Reloaded);
                }

                //Prevent inject a string already injected
                if (Input == Reloaded)
                {
                    return(Target);
                }

                DialogFound = true;

                if (!LiteMode)
                {
                    if (StringModifier != null)
                    {
                        try {
                            Reloaded = StringModifier.Call("Modifier", "ResultHook", Reloaded);
                        } catch {
                            Log("Result Hook Error...", true);
                        }
                    }

                    Reloaded = PrefixWorker(Reloaded);

                    CacheReply(Reloaded);
                    TrimWorker(ref Reloaded, Input);

                    if (NoReload)
                    {
                        return(Target);
                    }

                    if (LogAll || LogOutput)
                    {
                        if (AllowDuplicates)
                        {
                            Log("Output: {0}\r\nDB Current Index: {1}", true, Reloaded);
                        }
                        else
                        {
                            Log("Output: {0}", true, Reloaded);
                        }
                    }
                }
                IntPtr Output = GenString(Reloaded);

                if (!LiteMode)
                {
                    AddPtr(Output);
                    AddPtr(Target);

                    if (CachePointers)
                    {
                        CachePtr(Target, Output);
                    }

                    if (DelayTest)
                    {
                        Log("Delay - {0}ms", false, (DateTime.Now - Begin)?.TotalMilliseconds);
                    }
                }

                return(Output);
            } catch (Exception ex) {
                Error("Ops, a Bug...\n{0}\n======================\n{1}\n============================\n{2}\n============================\n{3}", ex.Message, ex.StackTrace, ex.Data, ex.Source);

                if (Tries++ < 3)
                {
                    goto again;
                }
                Initialized = true;
            }
            return(Target);
        }