예제 #1
0
        public void 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;

                ActionLookup.Resolve();
                StatusEffectLookup.Resolve();
                ZoneLookup.Resolve();

                this.ResolveMemoryStructures(processModel, patchVersion);
            }

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

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

            Scanner.Instance.Locations.Clear();
            Scanner.Instance.LoadOffsets(Signatures.Resolve(processModel, patchVersion), scanAllMemoryRegions);
        }
예제 #2
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);
            });
        }
예제 #3
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);
        }