Exemplo n.º 1
0
        public void OnProcessChanged(Process process)
        {
            if (process != null && process.HasExited)
            {
                process = null;
            }
            bool changed_existance = (process_ == null) != (process == null);
            bool changed_pid       = process_ != null && process != null && process_.Id != process.Id;

            if (changed_existance || changed_pid)
            {
                player_ptr_addr_     = IntPtr.Zero;
                job_data_outer_addr_ = IntPtr.Zero;
                process_             = process != null ? new LimitedProcess(process) : null;

                if (process_ != null)
                {
                    ReadSignatures();
                }
            }

            if (process_ == null && !showed_dx9_error_)
            {
                int found_32bit = (from x in Process.GetProcessesByName("ffxiv")
                                   where !x.HasExited && x.MainModule != null && x.MainModule.ModuleName == "ffxiv.exe"
                                   select x).Count();
                if (found_32bit > 0)
                {
                    logger_.LogError(Strings.FoundDX9FFXIVErrorMessage);
                    showed_dx9_error_ = true;
                }
            }
        }
Exemplo n.º 2
0
        public bool FindProcess()
        {
            if (HasProcess())
            {
                return(true);
            }

            // Only support the DirectX 11 binary. The DirectX 9 one has different addresses.
            Process found_process = (from x in Process.GetProcessesByName("ffxiv_dx11")
                                     where !x.HasExited && x.MainModule != null && x.MainModule.ModuleName == "ffxiv_dx11.exe"
                                     select x).FirstOrDefault <Process>();

            if (found_process != null && found_process.HasExited)
            {
                found_process = null;
            }
            bool changed_existance = (process_ == null) != (found_process == null);
            bool changed_pid       = process_ != null && found_process != null && process_.Id != found_process.Id;

            if (changed_existance || changed_pid)
            {
                player_ptr_addr_     = IntPtr.Zero;
                target_ptr_addr_     = IntPtr.Zero;
                focus_ptr_addr_      = IntPtr.Zero;
                job_data_outer_addr_ = IntPtr.Zero;
                process_             = found_process != null ? new LimitedProcess(found_process) : null;

                if (process_ != null)
                {
                    ReadSignatures();
                }
            }

            if (process_ == null && !showed_dx9_error_)
            {
                int found_32bit = (from x in Process.GetProcessesByName("ffxiv")
                                   where !x.HasExited && x.MainModule != null && x.MainModule.ModuleName == "ffxiv.exe"
                                   select x).Count();
                if (found_32bit > 0)
                {
                    logger_.LogError("Found DirectX9 FFXIV process. Requires DirectX11.");
                    showed_dx9_error_ = true;
                }
            }

            return(process_ != null);
        }
Exemplo n.º 3
0
        public bool FindProcess()
        {
            if (HasProcess())
            {
                return(true);
            }

            // Only support the DirectX 11 binary. The DirectX 9 one has different addresses.
            Process found_process = (from x in Process.GetProcessesByName("ffxiv_dx11")
                                     where !x.HasExited && x.MainModule != null && x.MainModule.ModuleName == "ffxiv_dx11.exe"
                                     select x).FirstOrDefault <Process>();

            if (found_process != null && found_process.HasExited)
            {
                found_process = null;
            }
            bool changed_existance = (process_ == null) != (found_process == null);
            bool changed_pid       = process_ != null && found_process != null && process_.Id != found_process.Id;

            if (changed_existance || changed_pid)
            {
                player_ptr_addr_     = IntPtr.Zero;
                target_ptr_addr_     = IntPtr.Zero;
                focus_ptr_addr_      = IntPtr.Zero;
                job_data_outer_addr_ = IntPtr.Zero;
                process_             = new LimitedProcess(found_process);

                if (process_ != null)
                {
                    List <IntPtr> p = SigScan(kCharmapSignature, kCharmapSignatureOffset, kCharmapSignatureRIP);
                    if (p.Count != 1)
                    {
                        logger_.LogError("Charmap signature found " + p.Count + " matches");
                    }
                    else
                    {
                        player_ptr_addr_ = IntPtr.Add(p[0], kCharmapStructOffsetPlayer);
                    }

                    p = SigScan(kTargetSignature, kTargetSignatureOffset, kTargetSignatureRIP);
                    if (p.Count != 1)
                    {
                        logger_.LogError("Target signature found " + p.Count + " matches");
                    }
                    else
                    {
                        target_ptr_addr_ = IntPtr.Add(p[0], kTargetStructOffsetTarget);
                        focus_ptr_addr_  = IntPtr.Add(p[0], kTargetStructOffsetFocus);
                    }

                    p = SigScan(kJobDataSignature, kJobDataSignatureOffset, kJobDataSignatureRIP);
                    if (p.Count != 1)
                    {
                        logger_.LogError("Job signature found " + p.Count + " matches");
                    }
                    else
                    {
                        job_data_outer_addr_ = IntPtr.Add(p[0], kJobDataOuterStructOffset);
                    }

                    p = SigScan(kInCombatSignature, kInCombatBaseOffset, kInCombatBaseRIP);
                    if (p.Count != 1)
                    {
                        logger_.LogError("In combat signature found " + p.Count + " matches");
                    }
                    else
                    {
                        var baseAddress = p[0];
                        p = SigScan(kInCombatSignature, kInCombatOffsetOffset, kInCombatOffsetRIP);
                        if (p.Count != 1)
                        {
                            logger_.LogError("In combat offset signature found " + p.Count + " matches");
                        }
                        else
                        {
                            // Abuse sigscan here to return 64-bit "pointer" which we will mask into the 32-bit immediate integer we need.
                            // TODO: maybe sigscan should be able to return different types?
                            int offset = (int)(((UInt64)p[0]) & 0xFFFFFFFF);
                            in_combat_addr_ = IntPtr.Add(baseAddress, offset);
                        }
                    }

                    p = SigScan(kBaitSignature, kBaitBaseOffset, kBaitBaseRIP);
                    if (p.Count != 1)
                    {
                        logger_.LogError("Bait signature found " + p.Count + " matches");
                    }
                    else
                    {
                        bait_addr_ = p[0];
                    }
                }
            }

            if (process_ == null && !showed_dx9_error_)
            {
                int found_32bit = (from x in Process.GetProcessesByName("ffxiv")
                                   where !x.HasExited && x.MainModule != null && x.MainModule.ModuleName == "ffxiv.exe"
                                   select x).Count();
                if (found_32bit > 0)
                {
                    logger_.LogError("Found DirectX9 FFXIV process. Requires DirectX11.");
                    showed_dx9_error_ = true;
                }
            }

            return(process_ != null);
        }