Ejemplo n.º 1
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);
        }