Пример #1
0
        public void PoolSignaturePointer()
        {
            InitTest();

            var p = new MemoryPool("MyPool", MemoryAddress.StaticAbsolute, "A0XXXXXXXX8B0D????????F6D81BC0", new[] { 0 }, 0x6000);

            var provider = new MemoryProvider(reader);

            provider.Add(p);
            provider.Scanner.Enable();
            provider.Refresh();
            provider.Scanner.Disable();

            Assert.AreEqual("MyPool", p.Name);
            Assert.AreEqual(MemoryAddress.StaticAbsolute, p.AddressType);
            Assert.AreEqual(0x71528C, p.Address);
            Assert.AreEqual(0x6000, p.Size);
            Assert.AreEqual(0, p.Offset);
            Assert.AreEqual(1, p.Pointers.Count());
            Assert.AreEqual(0, p.Pointers.FirstOrDefault().Offset);
            Assert.False(p.IsDynamic);
            Assert.False(p.IsConstant);
            Assert.True(p.IsSignature);
            Assert.True(p.IsStatic);
            Assert.False(p.IsTemplate);
            Assert.AreEqual(2, p.AddressTree.Length);
            Assert.AreEqual(0x71528C, p.AddressTree[0]);
            Assert.AreEqual(0x7154C0, p.AddressTree[1]);


            Assert.Greater(actionLogbook.Count, 2);
            var preRefreshCount = actionLogbook.Count;

            Assert.AreEqual(0x71528C, actionLogbook[actionLogbook.Count - 2].Address);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 1].Address);

            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 2].Size);
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 1].Size);

            // re-read
            // it will only read what was initially found by the signature.
            provider.Refresh();

            var postRefreshCount = actionLogbook.Count;

            Assert.AreEqual(2, postRefreshCount - preRefreshCount);

            Assert.AreEqual(0x71528C, actionLogbook[actionLogbook.Count - 4].Address);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 3].Address);
            Assert.AreEqual(0x71528C, actionLogbook[actionLogbook.Count - 2].Address);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 1].Address);

            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 4].Size);
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 3].Size);
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 2].Size);
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 1].Size);
        }
Пример #2
0
        public void PoolStaticPointer()
        {
            InitTest();

            var p = new MemoryPool("MyPool", MemoryAddress.Static, 0x315298, new[] { 0 }, 0x6000);

            var provider = new MemoryProvider(reader);

            provider.Add(p);
            provider.Refresh();

            Assert.AreEqual("MyPool", p.Name);
            Assert.AreEqual(MemoryAddress.Static, p.AddressType);
            Assert.AreEqual(0x315298, p.Address);
            Assert.AreEqual(0x6000, p.Size);
            Assert.AreEqual(0, p.Offset);
            Assert.AreEqual(1, p.Pointers.Count());
            Assert.AreEqual(0, p.Pointers.FirstOrDefault().Offset);
            Assert.False(p.IsDynamic);
            Assert.False(p.IsConstant);
            Assert.True(p.IsStatic);
            Assert.False(p.IsSignature);
            Assert.False(p.IsTemplate);
            Assert.AreEqual(2, p.AddressTree.Length);
            Assert.AreEqual(0x715298, p.AddressTree[0]);
            Assert.AreEqual(0x7154C0, p.AddressTree[1]);

            Assert.AreEqual(2, actionLogbook.Count);

            Assert.AreEqual(0x715298, actionLogbook[0].Address);
            Assert.AreEqual(0x7154C0, actionLogbook[1].Address);

            Assert.AreEqual(0x4, actionLogbook[0].Size);
            Assert.AreEqual(0x6000, actionLogbook[1].Size);

            // re-read
            // it will follow the pointer every refresh cycle.
            provider.Refresh();

            Assert.AreEqual(4, actionLogbook.Count);

            Assert.AreEqual(0x715298, actionLogbook[0].Address);
            Assert.AreEqual(0x7154C0, actionLogbook[1].Address);
            Assert.AreEqual(0x715298, actionLogbook[2].Address);
            Assert.AreEqual(0x7154C0, actionLogbook[3].Address);

            Assert.AreEqual(0x4, actionLogbook[0].Size);
            Assert.AreEqual(0x6000, actionLogbook[1].Size);
            Assert.AreEqual(0x4, actionLogbook[2].Size);
            Assert.AreEqual(0x6000, actionLogbook[3].Size);
        }
Пример #3
0
        public void PoolContainerNonZeroSize()
        {
            InitTest();

            var p = new MemoryPool("MyPool", MemoryAddress.StaticAbsolute, 0, 0, 4);

            var provider = new MemoryProvider(reader);

            provider.Add(p);
            provider.Refresh();

            Assert.AreEqual("MyPool", p.Name);
            Assert.AreEqual(MemoryAddress.StaticAbsolute, p.AddressType);
            Assert.AreEqual(0, p.Address);
            Assert.AreEqual(4, p.Size);
            Assert.AreEqual(0, p.Offset);
            Assert.False(p.IsDynamic);
            Assert.False(p.IsConstant);
            Assert.True(p.IsStatic);
            Assert.False(p.IsSignature);
            Assert.False(p.IsTemplate);

            Assert.AreEqual(1, actionLogbook.Count);

            Assert.AreEqual(0, actionLogbook[0].Address);
            Assert.AreEqual(4, actionLogbook[0].Size);
        }
Пример #4
0
        public void Basic()
        {
            InitTest();

            var testField = new MemoryFieldConstant <bool>("Test", false);

            drvPool.Add(testField);

            memory.Refresh();

            Assert.AreEqual("Test", testField.Name);
            Assert.AreEqual(0, testField.Address);
            Assert.AreEqual(0, testField.Size);
            Assert.AreEqual(0, testField.Offset);

            Assert.True(testField.IsConstant);
            Assert.False(testField.IsDynamic);
            Assert.False(testField.IsStatic);

            Assert.True(testField.HasChanged());
            Assert.False(testField.HasChanged());
        }
Пример #5
0
        public void PoolTemplate()
        {
            InitTest();

            var driversPool = new MemoryPool("Drivers", MemoryAddress.Static, 0x315298, 0x200);

            driversPool.SetTemplate(true);

            var provider = new MemoryProvider(reader);

            provider.Add(driversPool);
            provider.Refresh();

            Assert.AreEqual("Drivers", driversPool.Name);
            Assert.AreEqual(MemoryAddress.Static, driversPool.AddressType);
            Assert.AreEqual(0x315298, driversPool.Address);
            Assert.AreEqual(0x200, driversPool.Size);
            Assert.AreEqual(0, driversPool.Offset);
            Assert.False(driversPool.IsDynamic);
            Assert.False(driversPool.IsConstant);
            Assert.True(driversPool.IsStatic);
            Assert.False(driversPool.IsSignature);
            Assert.True(driversPool.IsTemplate);

            Assert.AreEqual(0, actionLogbook.Count);

            for (int i = 0; i < 100; i++)
            {
                provider.Refresh();
            }
            Assert.AreEqual(0, actionLogbook.Count);

            driversPool.SetTemplate(false);

            provider.Refresh();

            Assert.AreEqual(0x715298, actionLogbook[0].Address);
            Assert.AreEqual(0x200, actionLogbook[0].Size);
        }
Пример #6
0
        public void PoolStaticAbsolute()
        {
            InitTest();

            var p = new MemoryPool("MyPool", MemoryAddress.StaticAbsolute, 0x7154c0, 0x6000);

            var provider = new MemoryProvider(reader);

            provider.Add(p);
            provider.Refresh();

            Assert.AreEqual("MyPool", p.Name);
            Assert.AreEqual(MemoryAddress.StaticAbsolute, p.AddressType);
            Assert.AreEqual(0x7154c0, p.Address);
            Assert.AreEqual(0x6000, p.Size);
            Assert.AreEqual(0, p.Offset);
            Assert.False(p.IsDynamic);
            Assert.False(p.IsConstant);
            Assert.True(p.IsStatic);
            Assert.False(p.IsSignature);
            Assert.False(p.IsTemplate);
            Assert.AreEqual(1, p.AddressTree.Length);
            Assert.AreEqual(0x7154C0, p.AddressTree[0]);

            Assert.AreEqual(1, actionLogbook.Count);

            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);

            provider.Refresh();

            Assert.AreEqual(2, actionLogbook.Count);

            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[1].Address);
            Assert.AreEqual(0x6000, actionLogbook[1].Size);
        }
Пример #7
0
        public void CounterField()
        {
            InitTest();

            int iCounter = 0;

            var fieldCounter = new MemoryFieldFunc <int>("Counter", (pool) =>
            {
                iCounter++;
                return(iCounter);
            });

            drvPool.Add(fieldCounter);
            memory.Refresh();

            Assert.AreEqual(1, drvPool.ReadAs <int>("Counter"));
            Assert.AreEqual(2, drvPool.ReadAs <int>("Counter"));
            Assert.AreEqual(3, drvPool.ReadAs <int>("Counter"));
            Assert.AreEqual(4, drvPool.ReadAs <int>("Counter"));
            Assert.AreEqual(5, drvPool.ReadAs <int>("Counter"));
            Assert.AreEqual(6, drvPool.ReadAs <int>("Counter"));
            Assert.AreEqual(7, drvPool.ReadAs <int>("Counter"));
        }
Пример #8
0
        private void sdktel_Data(Ets2Telemetry data, bool newTimestamp)
        {
            if (sdkBusy)
            {
                return;
            }
            sdkBusy = true;
            try
            {
                if (miner != null)
                {
                    miner.Refresh();
                    for (int k = 0; k < 64; k++)
                    {
                        var carPool = miner.Get("Car " + k);
                        if (carPool == null)
                        {
                            continue;
                        }
                        var car = Cars.FirstOrDefault(x => x.ID == k);
                        if (car == null)
                        {
                            continue;
                        }

                        car.Speed = carPool.ReadAs <float>("Speed");
                        car.X     = carPool.ReadAs <float>("CoordinateX");
                        car.Y     = carPool.ReadAs <float>("CoordinateY");
                        car.Z     = carPool.ReadAs <float>("CoordinateZ");
                    }
                }

                var ep = new IPEndPoint(IPAddress.Parse("192.168.1.158"), 12345);
                var r  = (data.Drivetrain.EngineRpm - 300) / (2500 - 300);
                if (data.Drivetrain.EngineRpm < 300)
                {
                    r = -1;
                }
                var s = ((int)(r * 10000)).ToString() + "," +
                        ((int)(data.Controls.GameThrottle * 1000)).ToString() + "," + ((data.Paused) ? 1 : 0);
                var sb    = ASCIIEncoding.ASCII.GetBytes(s);
                var dgram = ASCIIEncoding.ASCII.GetBytes(s);

                server.SendTo(dgram, ep);
            }
            catch
            {
            }
            sdkBusy = false;
        }
        public void Initialize(MemoryProvider provider)
        {
            MemoryPool simulator = new MemoryPool("Simulator", MemoryAddress.Static, 0, 0);

            simulator.Add(new MemoryFieldLazy <int>("CarPlayer", MemoryAddress.Static, 0x31528c, 4));
            simulator.Add(new MemoryFieldLazy <int[]>("Drivers", MemoryAddress.Static, 0x315298, 0x19C));

            simulator.Add(new MemoryFieldLazy <string>("LocationGame", MemoryAddress.Static, 0x6EB320, 0, 256));

            MemoryPool session = new MemoryPool("Session", MemoryAddress.Static, 0, 0);

            session.Add(new MemoryFieldLazy <int>("Cars", MemoryAddress.Static, 0x315290, 4));
            session.Add(new MemoryFieldLazy <float>("Time", MemoryAddress.Static, 0x60022C, 4));
            session.Add(new MemoryFieldLazy <float>("Clock", MemoryAddress.Static, 0x6E2CD8, 4));

            session.Add(new MemoryFieldLazy <string>("LocationTrack", MemoryAddress.Static, 0x309D28, 0, 256));

            session.Add(new MemoryFieldLazy <bool>("IsOffline", MemoryAddress.Static, 0x315444, 1, (x) => !x));
            session.Add(new MemoryFieldLazy <bool>("IsActive", MemoryAddress.Static, 0x30FEE4, 1));
            session.Add(new MemoryFieldLazy <bool>("IsReplay", MemoryAddress.Static, 0x315444, 1));
            session.Add(new MemoryFieldFunc <bool>("IsLoading", (pool) => !pool.ReadAs <bool>("IsActive") && pool.ReadAs <int>("Cars") > 0 && pool.ReadAs <string>("LocationTrack").Length != 0));

            MemoryPool templateDriver = new MemoryPool("DriverTemplate", MemoryAddress.StaticAbsolute, 0, 0x5F48); // base, 0x5F48 size

            templateDriver.Add(new MemoryFieldConstant <bool>("IsActive", true));

            templateDriver.Add(new MemoryFieldLazy <int>("Index", MemoryAddress.Dynamic, 0, 0x8, 32));

            templateDriver.Add(new MemoryFieldLazy <string>("Name", MemoryAddress.Dynamic, 0, 0x5B08, 32));
            templateDriver.Add(new MemoryFieldLazy <string>("CarTeam", MemoryAddress.Dynamic, 0, 0x5C22, 64));
            templateDriver.Add(new MemoryFieldLazy <string>("CarModel", MemoryAddress.Dynamic, 0, 0x5C62, 64));
            templateDriver.Add(new MemoryFieldLazy <string>("CarClasses", MemoryAddress.Dynamic, 0, 0x39BC, 64));

            templateDriver.Add(new MemoryFieldLazy <float>("Meter", MemoryAddress.Dynamic, 0, 0x3D04, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("Speed", MemoryAddress.Dynamic, 0, 0x57C0, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("RPM", MemoryAddress.Dynamic, 0, 0x317C, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("RPMMax", MemoryAddress.Dynamic, 0, 0x3180, 4));
            templateDriver.Add(new MemoryFieldLazy <int>("Gear", MemoryAddress.Dynamic, 0, 0x321C, 1));

            templateDriver.Add(new MemoryFieldLazy <float>("Mass", MemoryAddress.Dynamic, 0, 0x28DC, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("Fuel", MemoryAddress.Dynamic, 0, 0x315C, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("FuelCapacity", MemoryAddress.Dynamic, 0, 0x3160, 4));

            templateDriver.Add(new MemoryFieldLazy <float>("TyreWearLF", MemoryAddress.Dynamic, 0, 0x2A34, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("TyreWearRF", MemoryAddress.Dynamic, 0, 0x2C1C, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("TyreWearLR", MemoryAddress.Dynamic, 0, 0x2E04, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("TyreWearRR", MemoryAddress.Dynamic, 0, 0x2FEC, 4));

            templateDriver.Add(new MemoryFieldLazy <float>("InputThrottle", MemoryAddress.Dynamic, 0, 0x2938, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("InputBrake", MemoryAddress.Dynamic, 0, 0x2940, 4));

            templateDriver.Add(new MemoryFieldLazy <float>("CoordinateX", MemoryAddress.Dynamic, 0, 0x289C, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("CoordinateY", MemoryAddress.Dynamic, 0, 0x28A4, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("CoordinateZ", MemoryAddress.Dynamic, 0, 0x28A0, 4));

            templateDriver.Add(new MemoryFieldLazy <float>("CoordinateX-Replay", MemoryAddress.Dynamic, 0, 0x10, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("CoordinateY-Replay", MemoryAddress.Dynamic, 0, 0x18, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("CoordinateZ-Replay", MemoryAddress.Dynamic, 0, 0x14, 4));

            templateDriver.Add(new MemoryFieldLazy <float>("RotationX", MemoryAddress.Dynamic, 0, 0x40, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("RotationY", MemoryAddress.Dynamic, 0, 0x48, 4));
            templateDriver.Add(new MemoryFieldLazy <float>("RotationZ", MemoryAddress.Dynamic, 0, 0x44, 4));
            templateDriver.Add(new MemoryFieldFunc <float>("Yaw", (pool) => (float)Math.Atan2(pool.ReadAs <float>("RotationX"), pool.ReadAs <float>("RotationY")), true));
            templateDriver.Add(new MemoryFieldLazy <float>("AccelerationX", MemoryAddress.Dynamic, 0, 0x57C8, 4));

            templateDriver.Add(new MemoryFieldLazy <int>("Pitstops", MemoryAddress.Dynamic, 0, 0x3D2C, 4));
            templateDriver.Add(new MemoryFieldLazy <int>("Position", MemoryAddress.Dynamic, 0, 0x3D20, 4));
            templateDriver.Add(new MemoryFieldLazy <int>("Laps", MemoryAddress.Dynamic, 0, 0x3CF8, 1));

            templateDriver.Add(new MemoryFieldLazy <bool>("IsAI", MemoryAddress.Dynamic, 0, 0x59C8, 1));
            templateDriver.Add(new MemoryFieldLazy <bool>("IsRetired", MemoryAddress.Dynamic, 0, 0x4160, 1));
            templateDriver.Add(new MemoryFieldLazy <bool>("IsLimiter", MemoryAddress.Dynamic, 0, 0x17B1, 1));
            templateDriver.Add(new MemoryFieldLazy <bool>("IsPits", MemoryAddress.Dynamic, 0, 0x27A8, 1));
            templateDriver.Add(new MemoryFieldLazy <bool>("IsDriving", MemoryAddress.Dynamic, 0, 0x3CBF, 1));
            templateDriver.Add(new MemoryFieldLazy <byte>("IsDisqualified", MemoryAddress.Dynamic, 0x3D24, 1,
                                                          (v) => (byte)((v == 3) ? 1 : 0)));

            templateDriver.Add(new MemoryFieldLazy <bool>("FlagYellow", MemoryAddress.Dynamic, 0, 0x104, 1, (x) => !x));
            templateDriver.Add(new MemoryFieldLazy <bool>("FlagBlue", MemoryAddress.Dynamic, 0, 0x3E39, 1));
            templateDriver.Add(new MemoryFieldLazy <bool>("FlagBlack", MemoryAddress.Dynamic, 0, 0x3D24, 1));
            templateDriver.Add(new MemoryFieldLazy <bool>("Ignition", MemoryAddress.Dynamic, 0, 0xAA, 1));

            var laps = new MemoryPool("Laps", MemoryAddress.Dynamic, templateDriver, 0x3D90, 6 * 4 * 200);

            // 200 laps, 6 floats each.
            templateDriver.Add(laps);


            provider.Add(simulator);
            provider.Add(session);
            provider.Add(templateDriver);

            provider.Refresh();
            templateDriver.SetTemplate(true);

            DriverPositionOffset = templateDriver.Fields["Position"].Offset;
            NamePositionOffset   = templateDriver.Fields["Name"].Offset;
        }
Пример #10
0
        public void FieldDynamic()
        {
            InitTest();

            var FieldFuel  = new MemoryField <float>("FuelCapacity", MemoryAddress.Dynamic, 0, 0x3160, 4);
            var FieldIndex = new MemoryField <int>("Index", MemoryAddress.Dynamic, 0, 0x8, 4); // +0x8 = driver index

            drvPool.Add(FieldIndex);
            drvPool.Add(FieldFuel);

            memory.Refresh();

            Assert.True(FieldIndex.HasChanged());
            Assert.True(FieldFuel.HasChanged());

            // only 1 read from pool:
            Assert.AreEqual(1, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);

            // And read some values in different types:
            Assert.AreEqual(0, drvPool.ReadAs <int>("Index"));
            Assert.AreEqual(0, drvPool.ReadAs <uint>("Index"));
            Assert.AreEqual(0.0f, drvPool.ReadAs <float>("Index"));

            Assert.AreEqual(100.0f, drvPool.ReadAs <float>("FuelCapacity"));
            Assert.AreEqual(100, drvPool.ReadAs <int>("FuelCapacity"));
            Assert.AreEqual(100.0, drvPool.ReadAs <double>("FuelCapacity"));

            memory.Refresh();

            Assert.False(FieldIndex.HasChanged());
            Assert.False(FieldFuel.HasChanged());

            Assert.AreEqual(2, actionLogbook.Count);
            Assert.AreEqual(0x7154C0, actionLogbook[0].Address);
            Assert.AreEqual(0x6000, actionLogbook[0].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[1].Address);
            Assert.AreEqual(0x6000, actionLogbook[1].Size);
        }
Пример #11
0
        public void FieldStaticAbsoluteSignature()
        {
            InitTest();

            var plrMemoryPtr = new MemoryFieldSignature <int>("Player", MemoryAddress.StaticAbsolute,
                                                              "A0XXXXXXXX8B0D????????F6D81BC0", new[] { 0 }, 0x6000);

            drvPool.Add(plrMemoryPtr);

            memory.Scanner.Enable();
            memory.Refresh();
            memory.Scanner.Disable();

            Assert.True(plrMemoryPtr.HasChanged());

            int preRescanCount = actionLogbook.Count;

            Assert.Greater(actionLogbook.Count, 1);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 3].Address); // pool itself
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 3].Size);
            Assert.AreEqual(0x71528C, actionLogbook[actionLogbook.Count - 2].Address); // our sig ptr scan
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 2].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 1].Address); // our sig
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 1].Size);

            Assert.AreEqual(0x7154C0, drvPool.ReadAs <int>("Player"));
            Assert.AreEqual(0x7154C0, plrMemoryPtr.Address);

            Assert.AreEqual(actionLogbook.Count, preRescanCount);

            // It will only refresh the contents of the pointer
            memory.Refresh();

            Assert.False(plrMemoryPtr.HasChanged());

            int postRescanCount = actionLogbook.Count;

            Assert.AreEqual(2, postRescanCount - preRescanCount);

            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 5].Address); // pool itself
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 5].Size);
            Assert.AreEqual(0x71528C, actionLogbook[actionLogbook.Count - 4].Address); // our sig ptr scan
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 4].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 3].Address); // our sig
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 3].Size);

            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 2].Address); // pool itself
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 2].Size);
            Assert.AreEqual(0x7154C0, actionLogbook[actionLogbook.Count - 1].Address); // our result from sig
            Assert.AreEqual(0x6000, actionLogbook[actionLogbook.Count - 1].Size);
        }
Пример #12
0
        public void PoolDynamic()
        {
            InitTest();

            var driversPool = new MemoryPool("Drivers", MemoryAddress.Static, 0x315298, 0x200);

            var provider = new MemoryProvider(reader);

            provider.Add(driversPool);
            provider.Refresh();

            Assert.AreEqual("Drivers", driversPool.Name);
            Assert.AreEqual(MemoryAddress.Static, driversPool.AddressType);
            Assert.AreEqual(0x315298, driversPool.Address);
            Assert.AreEqual(0x200, driversPool.Size);
            Assert.AreEqual(0, driversPool.Offset);
            Assert.False(driversPool.IsDynamic);
            Assert.False(driversPool.IsConstant);
            Assert.True(driversPool.IsStatic);
            Assert.False(driversPool.IsSignature);
            Assert.False(driversPool.IsTemplate);

            Assert.AreEqual(1, actionLogbook.Count);

            Assert.AreEqual(0x715298, actionLogbook[0].Address);
            Assert.AreEqual(0x200, actionLogbook[0].Size);

            var driver1 = new MemoryPool("Driver1", MemoryAddress.Dynamic, driversPool, 0x0, 0x6000);
            var driver2 = new MemoryPool("Driver2", MemoryAddress.Dynamic, driversPool, 0x4, 0x6000);

            provider.Add(driver1);
            provider.Add(driver2);
            provider.Refresh();

            Assert.AreEqual("Driver1", driver1.Name);
            Assert.AreEqual(MemoryAddress.Dynamic, driver1.AddressType);
            Assert.AreEqual(0, driver1.Address);
            Assert.AreEqual(0x6000, driver1.Size);
            Assert.AreEqual(0, driver1.Offset);
            Assert.AreEqual(driversPool, driver1.Pool);
            Assert.True(driver1.IsDynamic);
            Assert.False(driver1.IsConstant);
            Assert.False(driver1.IsStatic);
            Assert.False(driver1.IsSignature);
            Assert.False(driver1.IsTemplate);

            Assert.AreEqual("Driver2", driver2.Name);
            Assert.AreEqual(MemoryAddress.Dynamic, driver2.AddressType);
            Assert.AreEqual(0, driver2.Address);
            Assert.AreEqual(0x6000, driver2.Size);
            Assert.AreEqual(4, driver2.Offset);
            Assert.AreEqual(driversPool, driver2.Pool);
            Assert.True(driver2.IsDynamic);
            Assert.False(driver2.IsConstant);
            Assert.False(driver2.IsStatic);
            Assert.False(driver2.IsSignature);
            Assert.False(driver2.IsTemplate);

            Assert.AreEqual(4, actionLogbook.Count);

            Assert.AreEqual(0x715298, actionLogbook[0].Address);
            Assert.AreEqual(0x200, actionLogbook[0].Size);
            Assert.AreEqual(0x715298, actionLogbook[1].Address);
            Assert.AreEqual(0x200, actionLogbook[1].Size);
            Assert.AreEqual(0x7154c0, actionLogbook[2].Address);
            Assert.AreEqual(0x6000, actionLogbook[2].Size);
            Assert.AreEqual(0x71b408, actionLogbook[3].Address);
            Assert.AreEqual(0x6000, actionLogbook[3].Size);
        }
Пример #13
0
        public void PoolStaticAbsolutePointerSignature()
        {
            InitTest();

            var p = new MemoryPool("MyPool", MemoryAddress.StaticAbsolute, 0x715298,
                                   new[]
            {
                new MemoryFieldSignaturePointer(0, false),
                new MemoryFieldSignaturePointer("7CD5D9XX????????518BCFD91C24E8", true),
            }, 0x4);

            var provider = new MemoryProvider(reader);

            provider.Add(p);
            provider.Scanner.Enable();
            provider.Refresh();
            provider.Scanner.Disable();

            Assert.AreEqual("MyPool", p.Name);
            Assert.AreEqual(MemoryAddress.StaticAbsolute, p.AddressType);
            Assert.AreEqual(0x715298, p.Address);
            Assert.AreEqual(0x4, p.Size);
            Assert.AreEqual(0, p.Offset);
            Assert.AreEqual(2, p.Pointers.Count());
            Assert.AreEqual(0, p.Pointers.FirstOrDefault().Offset);
            Assert.AreEqual(0x317C, p.Pointers.ToList()[1].Offset);
            Assert.False(p.IsDynamic);
            Assert.False(p.IsConstant);
            Assert.True(p.IsStatic);
            Assert.False(p.IsSignature);
            Assert.False(p.IsTemplate);
            Assert.AreEqual(3, p.AddressTree.Length);
            Assert.AreEqual(0x715298, p.AddressTree[0]);
            Assert.AreEqual(0x7154C0, p.AddressTree[1]);
            Assert.AreEqual(0x71863C, p.AddressTree[2]);

            Assert.Greater(actionLogbook.Count, 2);
            int preLogBookSize = actionLogbook.Count;

            Assert.AreEqual(0x715298, actionLogbook[actionLogbook.Count - 2].Address);
            Assert.AreEqual(0x71863C, actionLogbook[actionLogbook.Count - 1].Address);

            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 2].Size);
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 1].Size);

            // re-read
            // it will follow the pointer every refresh cycle.
            provider.Refresh();
            int postLogBookSize = actionLogbook.Count;

            Assert.AreEqual(postLogBookSize - preLogBookSize, 2);

            Assert.AreEqual(0x715298, actionLogbook[actionLogbook.Count - 4].Address);
            Assert.AreEqual(0x71863C, actionLogbook[actionLogbook.Count - 3].Address);
            Assert.AreEqual(0x715298, actionLogbook[actionLogbook.Count - 2].Address);
            Assert.AreEqual(0x71863C, actionLogbook[actionLogbook.Count - 1].Address);

            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 4].Size);
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 3].Size);
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 2].Size);
            Assert.AreEqual(0x4, actionLogbook[actionLogbook.Count - 1].Size);
        }