Пример #1
0
        private static FunctionKind ReadType(MemoryScanner scanner)
        {
            FunctionKind type;

            var typeByte = scanner.NextByte();

            switch (typeByte)
            {
            case 0xC0:
                type = FunctionKind.StackArgument;
                break;

            case 0xC1:
                type = FunctionKind.LocalArgument;
                break;

            default:
                if (typeByte >= 0xC0 && typeByte <= 0xDF)
                {
                    throw new InvalidOperationException($"Unknown function type: {typeByte}");
                }

                throw new InvalidOperationException($"Non-function: {typeByte}");
            }

            return(type);
        }
Пример #2
0
        private static Operand ReadOperand(MemoryScanner scanner, byte type)
        {
            switch (type)
            {
            case 0x0: return(new Operand(OperandType.Constant, 0));

            case 0x1: return(new Operand(OperandType.Constant, (uint)(sbyte)scanner.NextByte()));

            case 0x2: return(new Operand(OperandType.Constant, (uint)(short)scanner.NextWord()));

            case 0x3: return(new Operand(OperandType.Constant, scanner.NextDWord()));

            case 0x5: return(new Operand(OperandType.Address, scanner.NextByte()));

            case 0x6: return(new Operand(OperandType.Address, scanner.NextWord()));

            case 0x7: return(new Operand(OperandType.Address, scanner.NextDWord()));

            case 0x8: return(new Operand(OperandType.Stack, 0));

            case 0x9: return(new Operand(OperandType.LocalAddress, scanner.NextByte()));

            case 0xa: return(new Operand(OperandType.LocalAddress, scanner.NextWord()));

            case 0xb: return(new Operand(OperandType.LocalAddress, scanner.NextDWord()));

            case 0xd: return(new Operand(OperandType.RamAddress, scanner.NextByte()));

            case 0xe: return(new Operand(OperandType.RamAddress, scanner.NextWord()));

            case 0xf: return(new Operand(OperandType.RamAddress, scanner.NextDWord()));

            default: throw new InvalidOperationException($"Invalid operand type byte: {type}");
            }
        }
Пример #3
0
        private static bool Init()
        {
            if (IsProcessNullCheck())
            {
                Dispose();
            }

            var processes = Process.GetProcessesByName("A Dance of Fire and Ice");

            if (!(processes.Length > 0))
            {
                return(false);
            }

            try
            {
                TargetProcess = processes[0];
                MS            = new MemoryScanner(p => p.ProcessName == TargetProcess.ProcessName);

                //FrameAddress = new MemoryAddress(new IntPtr(0x1E52CFC38B0), null);
                FrameAddress = new MemoryAddress(GetModuleBaseAddress("UnityPlayer.dll") + 0x017EEDD0, new int[] { 0x3D8, 0x0, 0x578, 0xE30 });
                //FrameAddress = new MemoryAddress(GetModuleBaseAddress("UnityPlayer.dll") + 0x0173E000, new int[] { 0x0, 0x20, 0x118 });

                IsPauseAddress = new MemoryAddress(GetModuleBaseAddress("UnityPlayer.dll") + 0x0179C458, new int[] { 0x170, 0x18, 0x18, 0x94 });
                InputOffset    = new MemoryAddress(GetModuleBaseAddress("UnityPlayer.dll") + 0x01731010, new int[] { 0x270, 0x10, 0xA50, 0x70, 0x7C0 });
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #4
0
        private static ImmutableDictionary <int, AstLocal> ReadLocals(MemoryScanner scanner, AstBodyBuilder bodyBuilder)
        {
            var map     = ImmutableDictionary.CreateBuilder <int, AstLocal>();
            var address = 0;

            while (true)
            {
                var sizeByte  = scanner.NextByte();
                var countByte = scanner.NextByte();

                if (sizeByte == 0 && countByte == 0)
                {
                    break;
                }

                var size = SizeByteToValueSize(sizeByte);

                // The Glulx spec states that locals will have padding to bring values
                // to their natural alignment. We should account for that here. Note that
                // the spec guarantees that the locals will start at a 4-byte boundary.
                if (size != ValueSize.Byte && address % sizeByte != 0)
                {
                    address += sizeByte;
                }

                for (int i = 0; i < countByte; i++)
                {
                    var local = bodyBuilder.DeclareLocal(size);
                    map.Add(address, local);
                    address += sizeByte;
                }
            }

            return(map.ToImmutable());
        }
Пример #5
0
        protected override void Run()
        {
            base.Run();

            Scanner = new MemoryScanner(Process.GetProcess());
            Scanner.Scan(1);
        }
Пример #6
0
        private void GetAdressButton_Click(object sender, EventArgs e)
        {
            var memScanner       = new MemoryScanner(cancerGame);
            var healthLocations  = memScanner.SearchFor <byte[]>(new byte[] { 0x29, 0x51, 0x34 });
            var energyLocations  = memScanner.SearchFor <byte[]>(new byte[] { 0x29, 0x50, 0x40 });
            var bowAmmoLocations = memScanner.SearchFor <byte[]>(new byte[] { 0x29, 0x42, 0x0C });

            IntPtr GetLocation(IntPtr[] locations)
            {
                foreach (var p in locations)
                {
                    MEMORY_BASIC_INFORMATION m;
                    VirtualQueryEx(cancerGame.Handle, p, out m, (uint)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION)));

                    if (m.Protect == 0x00000040) //0x00000040 equals PAGE_EXECUTE_READWRITE
                    {
                        return(p);
                    }
                }

                return(IntPtr.Zero);
            }

            if (_healthAsmLocation == IntPtr.Zero)                 //checking wether this is set already
            {
                _healthAsmLocation = GetLocation(healthLocations); //getting the right asm line's location
            }
            if (_energyAsmLocation == IntPtr.Zero)
            {
                _energyAsmLocation = GetLocation(energyLocations);
            }
            if (_bowAmmoAsmLocation == IntPtr.Zero)
            {
                _bowAmmoAsmLocation = GetLocation(bowAmmoLocations);
            }



            void SetInitialized(IntPtr adress, Label l)
            {
                if (adress == IntPtr.Zero)
                {
                    return;
                }
                l.ForeColor = Color.Green;
                l.Text      = "Initialized";
            }

            SetInitialized(_healthAsmLocation, HealthInitzialied);
            SetInitialized(_energyAsmLocation, EnergyInitialized);
            SetInitialized(_bowAmmoAsmLocation, ArrowsInitizialied);
        }
Пример #7
0
        public static GameClock GetClock(MemoryScanInfoPanel infoPanel = null)
        {
            var foundAddresses = MemoryScanner.FindSignatureInMemory(GameClock.signature, false, null, infoPanel);

            if (foundAddresses.Any())
            {
                return(new GameClock(foundAddresses));
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
        public static BoostMeter GetBoostMeter()
        {
            var foundAddresses = MemoryScanner.FindByteArrayInMemory(BoostMeter.locatorBytes);

            if (foundAddresses.Any())
            {
                return(new BoostMeter(foundAddresses));
            }
            else
            {
                return(null);
            }
        }
Пример #9
0
        private Program()
        {
            OnClose(Console_OnClose);

            //Take care, PauseWhileScanning is unstable yet
            _settings = new ScanSettings(writable: ScanType.ONLY);
            //This is our default setup

            _scanner         = new MemoryScanner();
            _processesPaused = new List <Process>();

            _scanner.SearchResult += Search_Result;
        }
Пример #10
0
        public static Ball GetBall(List <int> ignoredAddresses = null, MemoryScanInfoPanel infoPanel = null)
        {
            var locations = MemoryScanner.FindSignatureInMemory(Ball.signature, false, ignoredAddresses, infoPanel);

            if (!locations.Any())
            {
                return(null);
            }
            var ball = new Ball(locations);

            //ball.UseNextAddress();
            return(ball);
        }
        public GameClock FindClock()
        {
            var foundAddresses = MemoryScanner.FindSignatureInMemory(GameClock.signature, false, null, ClockInfoPanel);

            if (foundAddresses.Any())
            {
                Console.WriteLine("Game Clock found at " + foundAddresses);
                return(new GameClock(foundAddresses));
            }
            else
            {
                return(null);
            }
        }
Пример #12
0
        private static uint ReadOpcodeNumber(MemoryScanner scanner)
        {
            var firstByte = scanner.PeekByte();

            if ((firstByte & 0xC0) == 0xC0)
            {
                return(scanner.NextDWord() & 0x0fffffffu);
            }

            if ((firstByte & 0x80) == 0x80)
            {
                return(scanner.NextWord() & 0x3fffu);
            }

            return(scanner.NextByte() & 0x7fu);
        }
Пример #13
0
        // Need to make sure Spidey is frozen via Cheat Engine so levels don't change
        // Dump number + level title + enemy count
        // Also, send number rather than level title and just read from static list
        public static void Main(string[] args)
        {
            IEnumerable <IntPtr> handles = null;

            while (handles == null || handles.Count() == 0 || handles.All(h => h == IntPtr.Zero))
            {
                handles = WindowManager.FindSpideyWindows();
                Thread.Sleep(100);
            }

            var spideyWindow = WindowManager.GetSpideyWindow(handles.First());

            while (!MemoryScanner.GetMemoryAddresses(out string error, spideyWindow.Handle, true))
            {
                Thread.Sleep(100);
            }

            try
            {
                MemoryScanner.WriteSpideyXAndYPosition(0x77, 0x77);

                using (var output = new StreamWriter("Levels.txt", false))
                {
                    for (byte levelNumber = 0x00; levelNumber <= 0x3F; ++levelNumber)
                    {
                        MemoryScanner.WriteSpideyLevelCheatData(levelNumber);
                        var stopwatch = new Stopwatch();
                        stopwatch.Start();
                        while (stopwatch.ElapsedMilliseconds < 500)
                        {
                            MemoryScanner.WriteSpideyXAndYPosition(0x77, 0x77);
                        }
                        var name       = AsciiEncoding.GetString(MemoryScanner.ReadLevelNameData());
                        var enemyCount = MemoryScanner.ReadEnemyCountData();
                        output.WriteLine(levelNumber.ToString("X2") + "|" + name + "|" + enemyCount.ToString("X2"));
                    }
                }
            }
            finally
            {
                MemoryScanner.CloseDosBoxHandle();
            }
        }
Пример #14
0
        private static void ReadBody(MemoryScanner scanner, InstructionBinder binder)
        {
            while (true)
            {
                // Note: We read instructions until we find an opcode number that we don't know about.

                var address      = scanner.Address;
                var opcodeNumber = ReadOpcodeNumber(scanner);

                if (!Opcodes.TryGetOpcode(opcodeNumber, out var opcode))
                {
                    break;
                }

                var(loadOps, storeOps) = ReadOperands(scanner, opcode);

                var length = scanner.Address - address;

                binder.BindInstruction(opcode, loadOps, storeOps, address, length);
            }
        }
Пример #15
0
        public static Car GetCar(List <int> ignoredAddresses = null, MemoryScanInfoPanel infoPanel = null)
        {
            var results = MemoryScanner.FindSignatureInMemory(Car.signature, false, ignoredAddresses, infoPanel);

            //foreach (var result in results)
            //{
            //    var bytes = MemoryEdits.ReadMemory(result, (6*4));
            //    var a1 = Math.Abs(MemoryEdits.ReadFloat(result));
            //    var b1 = Math.Abs(MemoryEdits.ReadFloat(result + 4));
            //    var a2 = Math.Abs(MemoryEdits.ReadFloat(result + 20));
            //    var b2 = Math.Abs(MemoryEdits.ReadFloat(result + 16));
            //    if (Math.Abs(a1 - a2) > .001f && Math.Abs(b1 - b2) > .1f)
            //    {
            //        results = results.Where(x => x != result).ToList();
            //    }
            //}
            if (results.Any() != true)
            {
                return(null);
            }
            return(new Car(results));
        }
Пример #16
0
 public PeekMessageA(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #17
0
 public RedSquare(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #18
0
 public RedSquare(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #19
0
 public MaxCreatures(MemoryReader _memRead, MemoryScanner _memScan,AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #20
0
 public GuiPointer(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #21
0
 public WalkFunction(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #22
0
 public SpeakFunction(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #23
0
 public CreatePacket(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #24
0
 public AttackCount(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #25
0
 public FullLight(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
 public OutGoingPacketLen(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #27
0
 public Vector3D GetViewOffset()
 {
     byte[] vecData = new byte[12];
     Buffer.BlockCopy(readData, ExternalCounterstrike.NetVars["m_vecViewOffset"], vecData, 0, 12);
     return(MemoryScanner.GetStructure <Vector3D>(vecData));
 }
Пример #28
0
        async Task Scan()
        {
            addressListView.Items.Clear();
            var count = 0;

            var stopwatch = Stopwatch.StartNew();

            Invoke((MethodInvoker)(() =>
            {
                readyToolStripStatusLabel.Text = ScanState.Scanning.ToString(count);
                Text = Title + " (検索中...)";
            }));

            var items = new Dictionary <ulong, ListViewItem>();

            var query = GetQuery();

            if (query == null)
            {
                return;
            }

            Watches = await MemoryScanner.FindMatches(query, exclusions : Exclusions, handler : (address, found) =>
            {
                BeginInvoke((MethodInvoker)(() =>
                {
                    var c = Interlocked.Increment(ref count);
                    Text = $"{Title} (検索中: {c})";
                    readyToolStripStatusLabel.Text = ScanState.Scanning.ToString(c);
                    items[address] = addressListView.Items.Add(new ListViewItem(new[] {
                        address.ToString("X8"), "", found.ToString()
                    }));
                }));
            });

            stopwatch.Stop();

            Invoke((MethodInvoker)(() =>
            {
                Text = $"{Title} ({Watches.Count})";
                readyToolStripStatusLabel.Text = ScanState.Complete.ToString(Watches.Count) + " (" + stopwatch.ElapsedMilliseconds + " ms)";
            }));

            Cancellation?.Cancel();
            Cancellation = new CancellationTokenSource();
            await MemoryScanner.Watch(Watches, 500, Cancellation.Token, t : query, handler : (k, v) =>
            {
                Invoke((MethodInvoker)(() =>
                {
                    if (items.ContainsKey(k))
                    {
                        items[k].SubItems[1].Text = v.ToString();
                    }
                    else
                    {
                        items[k] = addressListView.Items.Add(new ListViewItem(new[] {
                            k.ToString("X8"), v.ToString(), v.ToString()
                        }));
                    }
                }));
            });
        }
Пример #29
0
 public NopFps(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #30
0
 public SendPointer(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #31
0
 public BlistStep(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #32
0
        //protected static int GetObjectAddress(float[] objectSignature)
        //{
        //    var occurence = 3;
        //    var address = -1;
        //    var objectFound = false;

        //    while (!objectFound)
        //    {
        //        address = MemoryEdits.FindFloatSequenceInMemory(objectSignature, .001f);
        //        var x = MemoryEdits.ReadFloat(address + XPositionMemoryOffset);
        //        var y = MemoryEdits.ReadFloat(address + YPositionMemoryOffset);

        //        if (x > -6000f &&
        //            x < 6000f &&
        //            y > -10000f &&
        //            y < 10000f &&
        //            Math.Abs(x) > 1f &&
        //            Math.Abs(y) > 1f
        //            )
        //        {
        //            objectFound = true;
        //        }
        //        else
        //        {
        //            occurence++;
        //        }
        //    }


        //    return address;
        //}

        protected static List <int> LocateObject(MemorySignature signature, bool findAll = false, List <int> ignoredAddress = null)
        {
            return(MemoryScanner.FindSignatureInMemory(signature, findAll, ignoredAddress));
        }
Пример #33
0
 public StatusBarTime(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #34
0
 public AddPacketByte(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #35
0
 public OutgoingBuffer(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #36
0
 public lastSeenID(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #37
0
 public BlistStart(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #38
0
 public ReciveStream(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #39
0
 public CreatePacket(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #40
0
 static void Main(string[] args)
 {
     var memory = new MemoryScanner(p => p.ProcessName == "Zombidle");
     var a      = memory.ReadMemory <double>(new IntPtr(0x14B18878 - 0x8));
 }
Пример #41
0
 public FullLight(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #42
0
 public PlayerX(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
Пример #43
0
 public StatusBarTime(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #44
0
 public ReciveStream(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
Пример #45
0
 public Experience(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }