示例#1
0
        private async void Timer1_Tick(object sender, EventArgs e)
        {
            if (_lock)
            {
                return;
            }

            _lock = true;

            try
            {
                if (ZodiacMemory == null)
                {
                    if (await AttachProcAsync())
                    {
                        timer1.Interval = Config.RefreshInterval;
                        if (Config.PatchAutoPause)
                        {
                            AutoPause.Apply();
                        }
                    }
                    else
                    {
                        //timer1.Interval = ProcessCheckTimer;
                    }
                }
                else
                {
                    try
                    {
                        (uint[] mt, int mti) = ZodiacMemory.GetMtAndMti(MemoryData.MtAddress);

                        _movement = _rng.Sync(mti, in mt);

                        // On load or rng injection, reload and reset.
                        if (_movement == -1)
                        {
                            _rng.LoadState(mti, in mt);
                            ResetGridHighlighting();
                        }

                        Generate();
                    }
                    // Couldn't read from process, so we dispose.
                    catch (ReadMemoryException)
                    {
                        ZodiacMemory.Dispose();
                        ZodiacMemory = null;
                        //timer1.Interval = ProcessCheckTimer;
                    }
                }
            }
            finally
            {
                _lock = false;
            }
        }
示例#2
0
        private bool AttachProcByName()
        {
            const string procName = "FFXII_TZA";

            Process[] procs = Process.GetProcessesByName(procName);
            if (procs.Length == 0)
            {
                return(false);
            }

            Process proc = procs.Single();

            if (proc.HasExited)
            {
                return(false);
            }

            ZodiacMemory = new ZodiacMemory(proc);
            return(true);
        }
示例#3
0
        private void ForceUpdate()
        {
            if (ZodiacMemory == null)
            {
                return;
            }

            try
            {
                _movement            = -1;
                (uint[] mt, int mti) = ZodiacMemory.GetMtAndMti(MemoryData.MtAddress);
                _rng.LoadState(mti, in mt);
                Generate();
            }
            // Couldn't read from process, so we dispose.
            catch (ReadMemoryException)
            {
                ZodiacMemory.Dispose();
                ZodiacMemory = null;
            }
        }
示例#4
0
        // implemented but unused for now
        // i dont like this implementation and its not needed for now, since all game versions(steam, gamepass, etc) seem to have the same process name
        // so no need to scan all open processes for patterns
        private bool AttachProcBySignature()
        {
            IEnumerable <Process> procs = ProcessHelpers.GetProcesses((mem) =>
            {
                // maybe add recheck timeout
                DateTime now   = DateTime.UtcNow;
                var processKey = ProcessKey.ForProcess(mem.NativeProcess);
                if (_checkedProcs.ContainsKey(processKey))
                {
                    return(false);
                }

                long foundSig = mem.FindSignature(MemoryData.MtiSig);
                if (foundSig == -1)
                {
                    _checkedProcs[processKey] = now;
                    return(false);
                }

                return(true);
            });

            Process?proc = null;

            foreach (Process item in procs)
            {
                proc = item;
                break;
            }

            if (proc is null || proc.HasExited)
            {
                return(false);
            }

            ZodiacMemory = new ZodiacMemory(proc);
            return(true);
        }