Beispiel #1
0
        /// <summary>
        ///     Find the offsets for the <see cref="Process" /> opened by <see cref="BotManager.Memory" />
        /// </summary>
        /// <param name="proc">A process to find offsets</param>
        /// <returns>
        ///     true if we find all offsets successfully; otherwise false. <see cref="Offsets.Addresses" /> will still
        ///     contain the offsets that were found despite error.
        /// </returns>
        internal static bool FindOffsets(Process proc)
        {
            try
            {
                if (proc == null || proc.HasExited)
                {
                    Logger.Warn("Process is null or has already exited");
                    return(false);
                }
                var addresses = new Dictionary <string, IntPtr>();
                var fp        = new FindPattern(new MemoryStream(Encoding.UTF8.GetBytes(Resources.Patterns)), proc);
                var baseAddr  = (int)proc.MainModule.BaseAddress;

                foreach (var pattern in fp.Patterns)
                {
                    switch (pattern.Key)
                    {
                    case "FrameScript_ExecuteBuffer":
                    case "CGWorldFrame__Render":
                    case "FrameScript_GetText":
                        addresses.Add(pattern.Key, fp.Get(pattern.Key));
                        break;

                    default:
                        addresses.Add(pattern.Key, fp.Get(pattern.Key) - baseAddr);
                        break;
                    }
                }

                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Base: 0x" + baseAddr.ToString("X"));
                    foreach (var address in addresses)
                    {
                        Logger.Debug(address.Key + ": 0x" + (address.Value - baseAddr).ToString("X"));
                    }
                }

                Addresses = new ReadOnlyDictionary <string, IntPtr>(addresses);
                return(fp.NotFoundCount == 0);
            }
            catch (FileNotFoundException ex)
            {
                if (ex.FileName.Contains("fasmdll_managed"))
                {
                    Logger.Fatal(
                        "You have not downloaded a required prerequisite for CoolFish. Please visit the following download page for the Visual C++ Redistributable: http://www.microsoft.com/en-us/download/details.aspx?id=40784 (Download the vcredist_x86.exe when asked)");
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Exception thrown while finding offsets. ", ex);
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        ///     Find the offsets for the <see cref="Process" /> opened by <see cref="BotManager.Memory" />
        /// </summary>
        /// <param name="proc">A process to find offsets</param>
        /// <returns>
        ///     true if we find all offsets successfully; otherwise false. <see cref="Offsets.Addresses" /> will still
        ///     contain the offsets that were found despite error.
        /// </returns>
        internal static bool FindOffsets(Process proc)
        {
            try
            {
                if (proc == null || proc.HasExited)
                {
                    Logger.Warn("Process is null or has already exited");
                    return(false);
                }
                var addresses = new Dictionary <string, IntPtr>();
                var fp        = new FindPattern(new MemoryStream(Encoding.UTF8.GetBytes(Resources.Patterns)), proc);
                var baseAddr  = (int)proc.MainModule.BaseAddress;

                foreach (var pattern in fp.Patterns)
                {
                    switch (pattern.Key)
                    {
                    case "FrameScript_ExecuteBuffer":
                    case "CGWorldFrame__Render":
                    case "FrameScript_GetText":
                        addresses.Add(pattern.Key, fp.Get(pattern.Key));
                        break;

                    default:
                        addresses.Add(pattern.Key, fp.Get(pattern.Key) - baseAddr);
                        break;
                    }
                }

                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Base: 0x" + baseAddr.ToString("X"));
                    foreach (var address in addresses)
                    {
                        Logger.Debug(address.Key + ": 0x" + (address.Value - baseAddr).ToString("X"));
                    }
                }

                Addresses = new ReadOnlyDictionary <string, IntPtr>(addresses);
                return(fp.NotFoundCount == 0);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception thrown while finding offsets. ", ex);
            }
            return(false);
        }
Beispiel #3
0
        internal static bool FindOffsets(Process woWProc)
        {
            Addresses.Clear();
            var fp       = new FindPattern(new MemoryStream(Encoding.UTF8.GetBytes(Resources.Patterns)), woWProc);
            var baseAddr = (int)woWProc.MainModule.BaseAddress;

            try
            {
                foreach (var pattern in fp._patterns)
                {
                    switch (pattern.Key)
                    {
                    case "FrameScript_ExecuteBuffer":
                    case "FrameScript_GetLocalizedText":
                    case "ClntObjMgrGetActivePlayerObj":
                        Addresses.Add(pattern.Key, fp.Get(pattern.Key));
                        break;

                    default:
                        Addresses.Add(pattern.Key, fp.Get(pattern.Key) - baseAddr);
                        break;
                    }
                }

                Logging.Log("Base: 0x" + baseAddr.ToString("X"));
                foreach (var address in Addresses)
                {
                    Logging.Log(address.Key + ": 0x" + (address.Value - baseAddr).ToString("X"));
                }
            }
            catch (Exception ex)
            {
                Logging.Log(ex);
                return(false);
            }


            return(fp.NotFoundCount == 0);
        }