Esempio n. 1
0
        public void SetProcess(ProcessModel processModel, string gameLanguage = "English", string patchVersion = "latest", bool ignoreJSONCache = false, bool scanAllMemoryRegions = false)
        {
            ProcessModel    = processModel;
            GameLanguage    = gameLanguage;
            IgnoreJSONCache = ignoreJSONCache;
            try
            {
                ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)ProcessModel.ProcessID);
            }
            catch (Exception)
            {
                ProcessHandle = processModel.Process.Handle;
            }
            Constants.ProcessHandle = ProcessHandle;

            _systemModules = GetProcessModules();

            SetStructures(processModel, patchVersion);

            Scanner.Instance.Locations.Clear();
            Scanner.Instance.LoadOffsets(Signatures.Resolve(processModel, patchVersion), scanAllMemoryRegions);

            ActionHelper.Resolve();
            StatusEffectHelper.Resolve();
            ZoneHelper.Resolve();
        }
Esempio n. 2
0
        public void SetProcess(ProcessModel processModel, string gameLanguage = "English", string patchVersion = "latest", bool useLocalCache = true, bool scanAllMemoryRegions = false)
        {
            ProcessModel  = processModel;
            GameLanguage  = gameLanguage;
            UseLocalCache = useLocalCache;

            UnsetProcess();

            try
            {
                ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)ProcessModel.ProcessID);
            }
            catch (Exception)
            {
                ProcessHandle = processModel.Process.Handle;
            }
            finally
            {
                Constants.ProcessHandle = ProcessHandle;
                IsAttached = true;
            }

            if (IsNewInstance)
            {
                IsNewInstance = false;

                ActionHelper.Resolve();
                StatusEffectHelper.Resolve();
                ZoneHelper.Resolve();

                ResolveMemoryStructures(processModel, patchVersion);
            }

            AttachmentWorker = new AttachmentWorker();
            AttachmentWorker.StartScanning(processModel);

            SystemModules.Clear();
            GetProcessModules();

            Scanner.Instance.Locations.Clear();
            Scanner.Instance.LoadOffsets(Signatures.Resolve(processModel, patchVersion), scanAllMemoryRegions);
        }
Esempio n. 3
0
        public MemoryHandler(SharlayanConfiguration configuration)
        {
            this.Configuration = configuration;
            try {
                this.ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)this.Configuration.ProcessModel.ProcessID);
            }
            catch (Exception) {
                this.ProcessHandle = this.Configuration.ProcessModel.Process.Handle;
            }
            finally {
                this.IsAttached = true;
            }

            this.Configuration.ProcessModel.Process.EnableRaisingEvents = true;
            this.Configuration.ProcessModel.Process.Exited += this.Process_OnExited;

            this.GetProcessModules();

            this.Scanner = new Scanner(this);
            this.Reader  = new Reader(this);

            if (this._isNewInstance)
            {
                this._isNewInstance = false;

                Task.Run(
                    async() => {
                    await this.ResolveMemoryStructures();

                    await ActionLookup.Resolve(this.Configuration);
                    await StatusEffectLookup.Resolve(this.Configuration);
                    await ZoneLookup.Resolve(this.Configuration);
                });
            }

            Task.Run(
                async() => {
                Signature[] signatures = await Signatures.Resolve(this.Configuration);
                this.Scanner.LoadOffsets(signatures, this.Configuration.ScanAllRegions);
            });
        }
Esempio n. 4
0
        public async Task SetProcess(ProcessModel processModel, string gameLanguage = "English", string patchVersion = "latest", bool useLocalCache = true, bool scanAllMemoryRegions = false)
        {
            this.ProcessModel  = processModel;
            this.GameLanguage  = gameLanguage;
            this.UseLocalCache = useLocalCache;

            this.UnsetProcess();

            try {
                this.ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)this.ProcessModel.ProcessID);
            }
            catch (Exception) {
                this.ProcessHandle = processModel.Process.Handle;
            }
            finally {
                Constants.ProcessHandle = this.ProcessHandle;
                this.IsAttached         = true;
            }

            if (this.IsNewInstance)
            {
                this.IsNewInstance = false;

                //Parallel.Invoke(async () => await ActionLookup.Resolve(), async () => await StatusEffectLookup.Resolve(), async () => await ZoneLookup.Resolve());
                Task[] taskArray = new Task[3];

                taskArray[0] = Task.Factory.StartNew(async() => await ActionLookup.Resolve());
                taskArray[1] = Task.Factory.StartNew(async() => await StatusEffectLookup.Resolve());
                taskArray[2] = Task.Factory.StartNew(async() => await ZoneLookup.Resolve());

                Task.WaitAll(taskArray);
                //await ActionLookup.Resolve();
                //await StatusEffectLookup.Resolve();
                //await ZoneLookup.Resolve();


                await this.ResolveMemoryStructures(processModel, patchVersion);
            }

            this.AttachmentWorker = new AttachmentWorker();
            this.AttachmentWorker.StartScanning(processModel);

            this.SystemModules.Clear();
            this.GetProcessModules();

            Scanner.Instance.Locations.Clear();
            var signatures = await Signatures.Resolve(processModel, patchVersion);

            List <Signature> sigs = signatures as List <Signature>;

            sigs.Add(new Signature
            {
                Key         = "INVENTORYBAGS",
                PointerPath = new List <long>
                {
                    0x15786f0
                }
            });

            sigs.Add(new Signature
            {
                Key         = "INVENTORYSTART",
                PointerPath = new List <long>
                {
                    0x1c1de30
                }
            });
            Scanner.Instance.LoadOffsets(sigs, scanAllMemoryRegions);
        }