public static Structs.PatternList FindPatternList(Structs.PatternList patternList)
        {
            Structs.PatternList newPatternList = new Structs.PatternList();
            newPatternList.processName = patternList.processName;
            uint baseModule = 0;

            BlackMagic memread = new BlackMagic();
            if (memread.OpenProcessAndThread(SProcess.GetProcessFromProcessName(patternList.processName)))
            {
                try
                {
                    // Dump module
                    ProcessModuleCollection modules = Process.GetProcessById(memread.ProcessId).Modules;
                    foreach (ProcessModule o in modules)
                    {
                        Structs.ModuleList m = new Structs.ModuleList();
                        m.Name = o.ModuleName;
                        m.baseAddressDec = (int)o.BaseAddress;
                        m.baseAddressHex = (o.BaseAddress).ToString("X");
                        patternList.Modules.Add(m);

                        // Check module base if exist.
                        if (patternList.baseModuleName != "")
                            if (patternList.baseModuleName.ToLower() == o.ModuleName.ToLower())
                                baseModule = (uint)o.BaseAddress;
                    }
                }
                catch { }

                foreach (Structs.Pattern p in patternList.Patterns)
                {
                    try
                    {
                        uint dwCodeLoc = memread.FindPattern(p.pattern, p.mask);
                        uint offset = memread.ReadUInt((uint)((int)dwCodeLoc + p.offsetLocation));
                        if (offset > 0)
                        {
                            offset = offset - baseModule;
                            dwCodeLoc = dwCodeLoc - baseModule;
                        }

                        if (offset > 0)
                        {
                            // Dump offset
                            p.offset = offset.ToString("X");
                            p.offsetDec = offset;
                            p.offsetUsedAtDec = (uint)((int)dwCodeLoc + p.offsetLocation);
                            p.offsetUsedAt = ((int)dwCodeLoc + p.offsetLocation).ToString("X");
                            try
                            {
                                switch (p.type)
                                {
                                    case "int64":
                                        p.value = Convert.ToString(memread.ReadUInt64(p.offsetDec));
                                        break;
                                    case "int":
                                        p.value = Convert.ToString(memread.ReadInt(p.offsetDec));
                                        break;
                                    case "float":
                                        p.value = Convert.ToString(memread.ReadFloat(p.offsetDec));
                                        break;
                                    case "string":
                                        p.value = Convert.ToString(memread.ReadASCIIString(p.offsetDec, 30));
                                        break;
                                }
                            }
                            catch { p.value = "No Found"; }
                        }
                        else
                            p.offset = "No Found";

                    }
                    catch
                    { p.offset = "No Found"; }
                    newPatternList.Patterns.Add(p);
                }
                memread.Close();
            }
            else
            {
                MessageBox.Show("Process no found.");
            }
            return patternList;
        }
Exemple #2
0
        public void Refresh(BlackMagic w, GameObject go) {
            try {
                this.WowClass = (WoWClass)w.ReadByte((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.Class8);
                this.Shapeshift = (ShapeshiftForm)w.ReadByte((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.ShapeShift);
                this.Role = Role.Unknown;

                this.Level = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.Level);
                this.Health = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.Health);
                this.MaxHealth = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.MaxHealth);
                this.Power = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.Power);
                this.MaxPower = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.MaxPower);
                this.SecondaryPower = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.SecondaryPower);
                this.MovingInfo = new MovementFlags(w.ReadByte((uint)go.MovementArrayAddress + (uint)ConstOffsets.Movements.IsMoving8));
                this.HolyPower = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.HolyPower);
                this.Faction = w.ReadUInt((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.Faction);
                this.TargetGUID = w.ReadUInt64((uint)go.DescriptorArrayAddress + (uint)ConstOffsets.Descriptors.TargetGUID);
                //byte temp = w.ReadByte((uint)go.BuffSmallArrayAddress + (uint)ConstOffsets.Descriptors.IsinCombat);
                this.IsInCombat = (w.ReadByte((w.ReadUInt((uint)go.BaseAddress + (uint)ConstOffsets.Movements.IsinCombatOffset1)) + (uint)ConstOffsets.Movements.IsinCombatOffset2+2)& 0x8)!=0;
                this.position.X = w.ReadFloat((uint)go.BaseAddress + (uint)ConstOffsets.Positions.X);
                this.position.Y = w.ReadFloat((uint)go.BaseAddress + (uint)ConstOffsets.Positions.Y);
                this.position.Z = w.ReadFloat((uint)go.BaseAddress + (uint)ConstOffsets.Positions.Z);

                this.CastingSpellID = w.ReadUInt((uint)go.BaseAddress + (uint)ConstOffsets.CastingInfo.IsCasting);
                this.ChannelingSpellID = w.ReadUInt((uint)go.BaseAddress + (uint)ConstOffsets.CastingInfo.ChanneledCasting);
                this.BalancePower = w.ReadInt((uint)go.BaseAddress + (uint)ConstOffsets.CastingInfo.BalancePower);
                //this.BalanceStance = (BalanceFlag)(w.ReadByte((uint)go.BaseAddress + (uint)ConstOffsets.CastingInfo.BalanceState) & 0x01);
                float temprot = w.ReadFloat((uint)go.BaseAddress + (uint)ConstOffsets.Positions.Rotation);

                if (temprot > Math.PI) {
                    this.Rotation = -(2 * Math.PI - temprot);
                }
                else {
                    this.Rotation = temprot;
                }
                this.RefreshBuffs(w, go);
            }
            catch {

            }

            //this.Position = new Vector3(x,y,z);
        }