Пример #1
0
        public void when_ScanResult_constructed_with_nmaprun_and_no_extraports_then_ExtraPorts_should_be_empty()
        {
            var nr = new nmaprun
                {
                    runstats = new runstats
                        {
                            hosts = new hosts
                                {
                                    total = "0",
                                    down = "0",
                                    up = "0"
                                }
                        },
                    Items = new object[]
                        {
                            new host
                                {
                                    address = new address
                                        {
                                            addr = "127.0.0.1"
                                        },
                                    Items = new object[] {}
                                }
                        }
                };
            var sr = new ScanResult(nr);

            Assert.IsFalse(sr.Hosts.First().ExtraPorts.Any());
        }
Пример #2
0
        // �X�L�������ʂ𓾂�Ɣ��΂��郁�\�b�h
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            // result.Device     : ��������BluetoothDevice
            // result.Rssi       : RSSI�l
            // result.ScanRecord : �X�L�������R�[�h(byte[]�Ŏ擾����Ȃ�Aresult.ScanRecord.GetBytes()��)
            ScanResultEvent(result.Device, result.Rssi, result.ScanRecord);
        }
Пример #3
0
 static void ClientState(ISmartMemory memUtils)
 {
     scan = memUtils["engine.dll"].Find(new byte[] { 0xC2, 0x00, 0x00, 0xCC, 0xCC, 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x33, 0xC0, 0x83, 0xB9 }, "x??xxxx????xxxx");
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 7));
         Offsets.EngineClientState = (IntPtr)tmp - engineDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.EngineClientState) + "\n" + Offsets.EngineClientState.ToString("X8"));
     }
 }
		public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
		{
			String name = (result.Device.Name == null ? "null" : result.Device.Name);

			Console.WriteLine("Lollipop: Device Discovered: " + name);

			if (this.deviceFoundEvent != null)
			{
				this.deviceFoundEvent(result.Device, result.Rssi, null);
			}
		}
Пример #5
0
 static void EntityHealth(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(
         new byte[] { 0x8B, 0x41, 0x00, 0x89, 0x41, 0x00, 0x8B, 0x41, 0x00, 0x89, 0x41, 0x00, 0x8B, 0x41, 0x00, 0x89, 0x41, 0x00, 0x8B, 0x4F, 0x00, 0x83, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x2E },
         "xx?xx?xx?xx?xx?xx?xx?xx????xxx");
     if (scan.Success)
     {
         //int tmp = memUtils.Read<int>((IntPtr)(lastScan.Address.ToInt32() + 23));
         Offsets.Health = (IntPtr)memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 23));
         Logger.Info(ObjectEx.GetName(() => Offsets.Health) + "\n" + Offsets.Health.ToString("X8"));
     }
 }
Пример #6
0
 static void EntityID(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(
         new byte[] { 0x74, 0x72, 0x80, 0x79, 0x00, 0x00, 0x8B, 0x56, 0x00, 0x89, 0x55, 0x00, 0x74, 0x17 },
         "xxxx??xx?xx?xx");
     if (scan.Success)
     {
         //byte tmp = memUtils.Read<byte>((IntPtr)(lastScan.Address.ToInt32() + 8));
         Offsets.EntityId = (IntPtr)memUtils.Read<byte>((IntPtr)(scan.Address.ToInt32() + 8));
         Logger.Info(ObjectEx.GetName(() => Offsets.EntityId) + "\n" + Offsets.EntityId.ToString("X8"));
     }
 }
Пример #7
0
        public void when_ScanResult_constructed_with_empty_nmaprun_then_Hosts_should_be_empty()
        {
            var nr = new nmaprun
                {
                    runstats = new runstats
                        {
                            hosts = new hosts
                                {
                                    total = "0",
                                    down = "0",
                                    up = "0"
                                }
                        }
                };
            var sr = new ScanResult(nr);

            Assert.IsFalse(sr.Hosts.Any());
        }
Пример #8
0
        public void Can_scan_100_collection_over_cursor()
        {
            var allKeys = new HashSet<string>();
            Redis.FlushAll();
            var keys = 100.Times(x => "KEY" + x);
            Redis.SetAll(keys.ToSafeDictionary(x => x));

            var i = 0;
            var ret = new ScanResult();
            while (true)
            {
                ret = Redis.Scan(ret.Cursor, 10);
                i++;
                ret.AsStrings().ForEach(x => allKeys.Add(x));
                if (ret.Cursor == 0) break;
            }

            Assert.That(i, Is.GreaterThanOrEqualTo(2));
            Assert.That(allKeys.Count, Is.EqualTo(keys.Count));
            Assert.That(allKeys, Is.EquivalentTo(keys));
        }
Пример #9
0
        public void TestDirectoryScan()
        {
            var address1 = World.AddressFactory.UniqueWith("test-actor1");
            var address2 = World.AddressFactory.UniqueWith("test-actor2");
            var address3 = World.AddressFactory.UniqueWith("test-actor3");
            var address4 = World.AddressFactory.UniqueWith("test-actor4");
            var address5 = World.AddressFactory.UniqueWith("test-actor5");

            var address6 = World.AddressFactory.UniqueWith("test-actor6");
            var address7 = World.AddressFactory.UniqueWith("test-actor7");

            World.Stage.Directory.Register(address1, new TestInterfaceActor());
            World.Stage.Directory.Register(address2, new TestInterfaceActor());
            World.Stage.Directory.Register(address3, new TestInterfaceActor());
            World.Stage.Directory.Register(address4, new TestInterfaceActor());
            World.Stage.Directory.Register(address5, new TestInterfaceActor());

            var scanResults = new ScanResult();

            scanResults.AfterCompleting(7);

            Action <INoProtocol> afterConsumer = actor =>
            {
                Assert.NotNull(actor);
                scanResults.ScanFound.WriteUsing("foundCount", 1);
            };

            World.Stage.ActorOf <INoProtocol>(address5).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address4).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address3).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address2).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address1).AndThenConsume(afterConsumer);

            World.Stage.ActorOf <INoProtocol>(address6)
            .AndThen(null, actor =>
            {
                Assert.Null(actor);
                scanResults.ScanFound.WriteUsing("foundCount", 1);
                return(actor);
            })
            .Otherwise(noSuchActor =>
            {
                Assert.Null(noSuchActor);
                scanResults.ScanFound.WriteUsing("notFoundCount", 1);
                return(null);
            });
            World.Stage.ActorOf <INoProtocol>(address7)
            .AndThen(null, actor =>
            {
                Assert.Null(actor);
                scanResults.ScanFound.WriteUsing("foundCount", 1);
                return(actor);
            })
            .Otherwise(noSuchActor =>
            {
                Assert.Null(noSuchActor);
                scanResults.ScanFound.WriteUsing("notFoundCount", 1);
                return(null);
            });

            Assert.Equal(5, scanResults.ScanFound.ReadFrom <int>("foundCount"));
            Assert.Equal(2, scanResults.ScanFound.ReadFrom <int>("notFoundCount"));
        }
Пример #10
0
        public void TestCompare(ScanCompareType compareType, float value1, float value2, byte[] data, bool expectedResult, ScanResult expectedScanResult)
        {
            var sut = new FloatMemoryComparer(compareType, ScanRoundMode.Normal, 1, value1, value2, BitConverter);

            Check.That(sut.Compare(data, 0, out var scanResult)).IsEqualTo(expectedResult);
            Check.That(scanResult).IsEqualTo(expectedScanResult);
            if (scanResult != null)
            {
                Check.That(scanResult).IsInstanceOf <FloatScanResult>();
            }
        }
Пример #11
0
        public async Task <InfoModel> ScanFile(ScanJob scanJob)
        {
            //Create the EICAR test virus. See http://www.eicar.org/86-0-Intended-use.html
            //byte[] eicar = Encoding.ASCII.GetBytes(@"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");

            //If the file has been scanned before, the results are embedded inside the report.
            //if (hasFileBeenScannedBefore)
            //{
            //    PrintScan(fileReport);
            //}
            //else
            //{
            FileReport fileReport = null;

            if (scanJob.GetSize() < 33553369 && scanJob.GetSize() > 0)
            {
                try
                {
                    byte[]     file       = File.ReadAllBytes(scanJob.mFilePath);
                    ScanResult fileResult = await mVirusTotal.ScanFileAsync(file, scanJob.mFilePath);

                    int NR_ATTEMPTS = 3;
                    while (NR_ATTEMPTS != 0)
                    {
                        fileReport = await mVirusTotal.GetFileReportAsync(fileResult.SHA256);

                        if (fileReport.ResponseCode == FileReportResponseCode.Present)
                        {
                            break;
                        }
                        Thread.Sleep(1000);
                        NR_ATTEMPTS--;
                    }
                }
                catch (Exception ex)
                {
                }
            }

            //    PrintScan(fileResult);
            //}

            //Console.WriteLine();

            //string scanUrl = "http://www.google.com/";

            //UrlReport urlReport = await mVirusTotal.GetUrlReportAsync(scanUrl);

            //bool hasUrlBeenScannedBefore = urlReport.ResponseCode == UrlReportResponseCode.Present;
            //Console.WriteLine("URL has been scanned before: " + (hasUrlBeenScannedBefore ? "Yes" : "No"));

            ////If the url has been scanned before, the results are embedded inside the report.
            //if (hasUrlBeenScannedBefore)
            //{
            //    PrintScan(urlReport);
            //}
            //else
            //{
            //    UrlScanResult urlResult = await mVirusTotal.ScanUrlAsync(scanUrl);
            //    PrintScan(urlResult);
            //}
            InfoModel infoModel;

            if (fileReport != null && fileReport.ResponseCode == FileReportResponseCode.Present)
            {
                infoModel = new InfoModel
                {
                    ScandId   = fileReport.ScanId,
                    Date      = fileReport.ScanDate,
                    SHA1      = fileReport.SHA1,
                    SHA256    = fileReport.SHA256,
                    FilePath  = scanJob.mFilePath,
                    Positives = fileReport.Positives,
                    Total     = fileReport.Total
                };
                List <Scan> Scans = new List <Scan>();
                try
                {
                    foreach (KeyValuePair <string, ScanEngine> scan in fileReport.Scans)
                    {
                        var scanModel = new Scan
                        {
                            EngineName = scan.Key,
                            Detected   = scan.Value.Detected,
                            Version    = scan.Value.Version,
                            Result     = scan.Value.Result
                        };
                        Scans.Add(scanModel);
                    }
                }
                catch (Exception ex)
                {
                }
                infoModel.Scans = Scans;
            }
            else
            {
                infoModel = new InfoModel();
                infoModel.Messages.Add("The file is too large for Virus Total, has 0 bytes or license limit.");
            }
            return(infoModel);
        }
Пример #12
0
		private bool HandleKeyScan(ScanResult result)
		{
			//	When you return false you tell the InputManager that it should keep scaning for other keys
			if(!IsKeyValid(result.key))
				return false;
			
			//	The key is KeyCode.None when the timeout has been reached or the scan has been canceled
			if(result.key != KeyCode.None)
			{
				//	If the key is KeyCode.Backspace clear the current binding
				result.key = (result.key == KeyCode.Backspace) ? KeyCode.None : result.key;
				if(m_changePositiveKey)
				{
					if(m_changeAltKey)
						m_axisConfig.altPositive = result.key;
					else
						m_axisConfig.positive = result.key;
				}
				else
				{
					if(m_changeAltKey)
						m_axisConfig.altNegative = result.key;
					else
						m_axisConfig.negative = result.key;
				}
				m_keyDescription.text = (result.key == KeyCode.None) ? "" : result.key.ToString();
			}
			else
			{
				KeyCode currentKey = GetCurrentKeyCode();
				m_keyDescription.text = (currentKey == KeyCode.None) ? "" : currentKey.ToString();
			}

			m_image.overrideSprite = m_normalState;
			return true;
		}
Пример #13
0
 static void vMatrix(ISmartMemory memUtils)
 {
     var pattern = new byte[] {
         0xE8, 0x00, 0x00, 0x00, 0x00, 0x8D, 0x95, 0xE0 };
     scan = memUtils["client.dll"].Find(pattern);
     if (scan.Success)
     {
         int address = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() - 0x1a));
         address -= clientDllBase;
         address += 0x90;
         Offsets.ViewMatrix = new IntPtr(address);
     }
 }
Пример #14
0
		private static bool CompareInternal(byte[] data, int index, Func<short, bool> matcher, out ScanResult result)
		{
			result = null;

			var value = BitConverter.ToInt16(data, index);

			if (!matcher(value))
			{
				return false;
			}

			result = new ShortScanResult(value);

			return true;
		}
Пример #15
0
        protected ProductionScan AddScan(string value, ScanResult result, PrdnJobStatus? status = null, string msg = null)
        {
            DateTime nowTime = DateTime.Now;

            ProductionScan newScan = new ProductionScan(nowTime, GetCurrentUserID(), value, result, status, msg);

            if ((result != ScanResult.CstItemCreatedAndPrinted) &&  (result != ScanResult.CstItemCreatedNotPrinted)
                && (result != ScanResult.CompletedAndPrinted) && (result != ScanResult.CompletedNotPrinted))
            {
                LastScanModel lastScan = Session[LastScanKey] as LastScanModel;
                if ((lastScan != null) && (lastScan.Value == value) && (lastScan.Result == result))
                {
                    TimeSpan ts = lastScan.ScanDt.Subtract(nowTime);
                    if (ts.Minutes < 2)
                    {
                        lastScan.ScanDt = nowTime;
                        Session[LastScanKey] = lastScan;
                        return newScan;
                    }
                }
            }

            PrdnDBContext.ProductionScans.AddObject(newScan);
            PrdnDBContext.SaveChanges();

            Session[LastScanKey] = new LastScanModel { Value = newScan.Value, Result = newScan.Result, ScanDt = newScan.ScanDt };

            return newScan;
        }
Пример #16
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            var device = result.Device;

            if (!string.IsNullOrEmpty(device.Name))
            {
                //_textView.Text += result.Device.Address + result.Device.Name;
                Console.WriteLine(result.Device.Address + result.Device.Name);
            }
            //base.OnScanResult(callbackType, result);
        }
Пример #17
0
        private bool HandleJoystickButtonScan(ScanResult result)
        {
            if (result.scanFlags == ScanFlags.Key || result.scanFlags == ScanFlags.JoystickButton)
            {
                //	When you return false you tell the InputManager that it should keep scaning for other keys
                if (!IsJoytickButtonValid(result.key))
                {
                    return(false);
                }

                //	The key is KeyCode.None when the timeout has been reached or the scan has been canceled
                if (result.key != KeyCode.None)
                {
                    //	If the key is KeyCode.Backspace clear the current binding
                    result.key        = (result.key == KeyCode.Backspace) ? KeyCode.None : result.key;
                    m_axisConfig.type = InputType.Button;
                    if (m_changePositiveKey)
                    {
                        if (m_changeAltKey)
                        {
                            m_axisConfig.altPositive = result.key;
                        }
                        else
                        {
                            m_axisConfig.positive = result.key;
                        }
                    }
                    else
                    {
                        if (m_changeAltKey)
                        {
                            m_axisConfig.altNegative = result.key;
                        }
                        else
                        {
                            m_axisConfig.negative = result.key;
                        }
                    }
                    m_keyDescription.text = (result.key == KeyCode.None) ? "" : result.key.ToString();
                }
                else
                {
                    if (m_axisConfig.type == InputType.Button)
                    {
                        KeyCode currentKey = GetCurrentKeyCode();
                        m_keyDescription.text = (currentKey == KeyCode.None) ? "" : currentKey.ToString();
                    }
                    else
                    {
                        m_keyDescription.text = m_axisNames[m_axisConfig.axis];
                    }
                }
                m_image.overrideSprite = m_normalState;
            }
            else
            {
                //	The axis is negative when the timeout has been reached or the scan has been canceled
                if (result.joystickAxis >= 0)
                {
                    m_axisConfig.type = InputType.AnalogButton;
                    m_axisConfig.SetAnalogButton(m_joystick, result.joystickAxis);
                    m_keyDescription.text = m_axisNames[m_axisConfig.axis];
                }
                else
                {
                    if (m_axisConfig.type == InputType.AnalogButton)
                    {
                        m_keyDescription.text = m_axisNames[m_axisConfig.axis];
                    }
                    else
                    {
                        KeyCode currentKey = GetCurrentKeyCode();
                        m_keyDescription.text = (currentKey == KeyCode.None) ? "" : currentKey.ToString();
                    }
                }
                m_image.overrideSprite = m_normalState;
            }

            return(true);
        }
Пример #18
0
        /// <summary>
        /// Runaway from target.
        /// </summary>
        public (Vector, bool, double) RunAway(List <Navigator> others, Entity target, List <Wall> walls)
        {
            // ====  Scan  ====
            var rads = SampleRads(target);

            double oppoRad   = (ego.pos - target.pos).rad;
            int    oppoIndex = (int)((oppoRad - (ego.rad - fov / 2)) / (fov / (nsample - 1)));

            var(res, resCol) = Scan(others, target, walls, rads);
            res.calcPoints(); resCol.calcPoints();


            // ====  Choose Waypoint  ====
            // find waypoint by res, which is the scan result of objects NOT in collision
            waypointIndex = 0;
            Vector waypoint = Vector.zero;

            {
                double maxDist = 0;
                for (int i = 0; i < rads.Length; ++i)
                {
                    // distance of waypoint to target
                    var point        = res.points[i] * p_runaway_range / range + ego.pos;
                    var dist         = (target.pos + target.v * 0.5).distTo(point);
                    var dist_penalty = dist;

                    // Soft penalty : away from target (predicted)
                    dist_penalty -= (-PI + AbsRad(rads[i] - (ego.pos - target.pos - target.v * 0.2).rad)) * p_runaway_penalty_away_k;

                    // Soft penalty : keep self's direction
                    dist_penalty -= (-PI + AbsRad(rads[i] - ego.rad)) * p_runaway_penalty_keeprad_k;

                    // Hard penalty
                    var    drad       = AbsRad((rads[i] - (ego.pos - target.pos - target.v * 0.0).rad));
                    double danger_fov = PI / 4 - 0.15;// + 5/(Max(ego.pos.distTo(target.pos)-20, 20)) ;   // greater than pi/4 make ego not able to leave corner
                    if (drad - PI + danger_fov > 0)
                    {
                        dist_penalty = 0;
                    }

                    // Search Furthest waypoint away from target, with SAFE direction
                    if (maxDist < dist_penalty && resCol.safety[i] > p_waypoint_safety_threshold)
                    {
                        maxDist       = dist_penalty;
                        waypointIndex = i;
                    }
                }

                if (maxDist > 0)
                {
                    waypoint = res.points[waypointIndex];
                }
                else
                {
                    // Debug.Log("Stuck");
                }
            }


            // ====  Speed Limit  ====
            double speedLimit  = double.MaxValue;
            var    waypointRad = rads[waypointIndex];

            // slow down when colliders are close around.
            {
                double minRadius = 1e10;
                for (int i = 0; i < rads.Length; ++i)
                {
                    var rad = rads[i];
                    if (Rad(rad - ego.rad) > 0.1 && Rad(waypointRad - rad) > 0.1 ||
                        Rad(ego.rad - rad) > 0.1 && Rad(rad - waypointRad) > 0.1)
                    {
                        // minimal maximal turning radius
                        minRadius = Min(minRadius, (res.dists[i] + 20) / (2 * Sin(Abs(rad - ego.rad))));
                    }
                }
                speedLimit = Max(8, minRadius * Max(1, Abs(ego.w)));
            }
            // stop when ego.rad is pointing insides colliders.
            if (resCol.isCollision)
            {
                for (int i = 0; i < rads.Length; ++i)
                {
                    var rad = rads[i];
                    if (AbsRad(rad - ego.rad) < PI * 2 / nsample &&
                        resCol.safety[i] <= 0
                        )
                    {
                        speedLimit = 100 * Max(0, resCol.safety[i] * 2 + 1);
                        break;
                    }
                }
            }


            // ==== make result ====
            res.rads        = rads;
            res.isCollision = resCol.isCollision;
            if (resCol.isCollision && useSafety)
            {
                Array.Copy(resCol.safety, res.safety, res.safety.Length);
            }
            scanResult = res;
            return(waypoint, resCol.isCollision, speedLimit);
        }
Пример #19
0
        /// <summary>
        /// Scan One other entity
        /// </summary>
        private ScanResult _ScanEntity(Navigator other, double[] rads)
        {
            ScanResult res       = ScanResult.init(rads, range + 1);
            var        o         = other.entity;
            var        marginSum = margin + other.avoid.margin;
            var        vmag      = Max(ego.spd, 20);

            // Scan for safe distance to other
            for (int i = 0; i < rads.Length; ++i)
            {
                var rad = rads[i];
                // var v = Vector.fromRadMag(rad, Max(ego.spd, 10));
                var vx = vmag * Cos(rad); var vy = vmag * Sin(rad);

                // var vUnit = Vector.fromRadMag(rad, 1);

                // var dv = v - o.v;
                var dvx = vx - o.v.x; var dvy = vy - o.v.y;

                // var dPos = ego.pos - o.pos;
                var dPosx    = ego.x - o.x;
                var dPosy    = ego.y - o.y;
                var dPosmag2 = dPosx * dPosx + dPosy * dPosy;

                // var a = dv * dv;
                var a = dvx * dvx + dvy * dvy;

                // var b = 2 * dv * dPos;
                var b = 2 * (dvx * dPosx + dvy * dPosy);

                // var c = dPos * dPos - marginSum * marginSum;
                var c = dPosmag2 - marginSum * marginSum;

                var delta = b * b - 4 * a * c;

                double dist;
                if (delta < 0 || Abs(a) < 1)    // No collision
                {
                    dist = range + 1;
                }
                else
                {
                    var t1 = (-b - Sqrt(delta)) / 2 / a;
                    var t2 = (-b + Sqrt(delta)) / 2 / a;

                    if (t2 <= 0)            // No collision in future
                    {
                        dist = range + 1;
                    }
                    else if (t1 > 0)        // Collsion in future
                    // dist = t1 * v.mag;
                    {
                        dist = t1 * vmag;
                    }
                    else                     // Collsion Now
                    // dist = Max(0.1, vUnit * dPos.unit * 100);    // another method
                    // dist = (v*dPos)/vmag/dPos.mag * 100;
                    {
                        dist            = (vx * dPosx + vy * dPosy) / vmag / Math.Sqrt(dPosmag2) * 100;
                        res.isCollision = true;
                    }
                }

                res.dists[i] = dist;
            }

            // When Collison, Find available rads.
            if (res.isCollision)
            {
                var dPos        = o.pos - ego.pos;
                var colSeverity = Max(0, margin + o.margin - dPos.mag) / margin;

                for (int i = 0; i < rads.Length; ++i)
                {
                    res.safety[i] = Cos(AbsRad(rads[i] - (-dPos).rad)) * (1 + colSeverity);
                }
            }

            return(res);
        }
Пример #20
0
        /// <summary>
        /// Run towards target.
        /// </summary>
        public (Vector, bool, double) RunTowards(List <Navigator> others, Entity target, List <Wall> walls)
        {
            // ====  Scan  ====
            var rads = SampleRads(target);

            var(res, resCol) = Scan(others, target, walls, rads);
            res.calcPoints(); resCol.calcPoints();


            // ====  Choose Waypoint  ====
            // find waypoint by res, which is the scan result of objects NOT in collision
            waypointIndex = 0;
            Vector waypoint = Vector.zero;

            // evaluate "distance" for each rad
            List <double> dists = new List <double>();

            for (int i = 0; i < rads.Length; ++i)
            {
                // nearest point at certain rad
                // var targetDist = ego.pos.distTo(target.pos);
                var targetDist = Math.Sqrt((ego.x - target.x) * (ego.x - target.x) + (ego.y - target.y) * (ego.y - target.y));
                var nearestMag = Max(Cos((target.pos - ego.pos).rad - rads[i]) * targetDist, 1);
                var mv         = res.points[i].clip(nearestMag);
                res.points[i] = mv;

                // distance of waypoint to target
                var dist = (ego.pos + mv).distTo(target.pos);

                // penalty of turning
                // NOTE may cause not turning when target right behind ego
                dist += Max(AbsRad(ego.rad - rads[i]), 0.5) * 0.1;
                dist += Max((AbsRad(ego.rad - rads[i]) - PI / 2), 0) * 2;

                dists.Add(dist);
            }

            // choose best waypoint
            if (useSafety)  // combine with safety
            {
                double minDist = double.MaxValue;
                for (int i = 0; i < rads.Length; ++i)
                {
                    var dist = dists[i];

                    // Search Nearest waypoint away from target, with SAFE direction
                    if (dist < minDist && resCol.safety[i] > p_waypoint_safety_threshold)
                    {
                        minDist = dist; waypointIndex = i;
                    }
                }

                if (minDist < double.MaxValue)
                {
                    waypoint = res.points[waypointIndex];
                }
                else
                {
                    // Debug.Log("Stuck");
                }
            }
            else                         // with force from collided entity
            {
                if (!resCol.isCollision) // Yet no collision.
                {
                    double minDist = double.MaxValue;
                    for (int i = 0; i < rads.Length; ++i)
                    {
                        var dist = dists[i];

                        // Search Nearest waypoint away from target
                        if (dist < minDist)
                        {
                            minDist = dist; waypointIndex = i;
                        }
                    }
                    waypoint = res.points[waypointIndex];
                }
                else                    // Now collision
                {
                    var maxDist = resCol.dists[0];
                    for (int i = 0; i < rads.Length; ++i)
                    {
                        var d = resCol.dists[i];
                        if (d > maxDist)
                        {
                            maxDist = d; waypointIndex = i;
                        }
                    }
                    waypoint = resCol.points[waypointIndex];
                }
            }



            // ====  Speed Limit  ====
            double speedLimit  = double.MaxValue;
            var    waypointRad = rads[waypointIndex];

            // slow down when colliders are close around.
            {
                double minRadius = 1e10;
                for (int i = 0; i < rads.Length; ++i)
                {
                    var rad = rads[i];
                    if (res.dists[i] < 50 &&
                        (Rad(rad - ego.rad) > 0.1 && Rad(waypointRad - rad) > 0.1 ||
                         Rad(ego.rad - rad) > 0.1 && Rad(rad - waypointRad) > 0.1))
                    {
                        // minimal maximal turning radius
                        minRadius = Min(minRadius, (res.dists[i] + 20) / (2 * Sin(Abs(rad - ego.rad))));
                    }
                }
                speedLimit = Max(8, minRadius * Max(1, Abs(ego.w)));
            }
            // stop when ego.rad is pointing insides colliders.
            if (resCol.isCollision)
            {
                for (int i = 0; i < rads.Length; ++i)
                {
                    var rad = rads[i];
                    if (AbsRad(rad - ego.rad) < PI * 2 / nsample &&
                        resCol.safety[i] <= 0
                        )
                    {
                        speedLimit = 100 * Max(0, resCol.safety[i] * 2 + 1);
                        break;
                    }
                }
            }


            // ==== make result ====
            res.rads        = rads;
            res.isCollision = resCol.isCollision;
            if (resCol.isCollision && useSafety)
            {
                Array.Copy(resCol.safety, res.safety, res.safety.Length);
            }
            scanResult = res;
            return(waypoint, resCol.isCollision, speedLimit);
        }
Пример #21
0
		private bool HandleJoystickAxisScan(ScanResult result)
		{
			//	The axis is negative when the timeout has been reached or the scan has been canceled
			if(result.joystickAxis >= 0)
				m_axisConfig.SetAnalogAxis(m_joystick, result.joystickAxis);

			m_image.overrideSprite = m_normalState;
			m_keyDescription.text = m_axisNames[m_axisConfig.axis];
			return true;
		}
Пример #22
0
		private bool HandleJoystickButtonScan(ScanResult result)
		{
			if(result.scanFlags == ScanFlags.Key || result.scanFlags == ScanFlags.JoystickButton)
			{
				//	When you return false you tell the InputManager that it should keep scaning for other keys
				if(!IsJoytickButtonValid(result.key))
					return false;
				
				//	The key is KeyCode.None when the timeout has been reached or the scan has been canceled
				if(result.key != KeyCode.None)
				{
					//	If the key is KeyCode.Backspace clear the current binding
					result.key = (result.key == KeyCode.Backspace) ? KeyCode.None : result.key;
					m_axisConfig.type = InputType.Button;
					if(m_changePositiveKey)
					{
						if(m_changeAltKey)
							m_axisConfig.altPositive = result.key;
						else
							m_axisConfig.positive = result.key;
					}
					else
					{
						if(m_changeAltKey)
							m_axisConfig.altNegative = result.key;
						else
							m_axisConfig.negative = result.key;
					}
					m_keyDescription.text = (result.key == KeyCode.None) ? "" : result.key.ToString();
				}
				else
				{
					if(m_axisConfig.type == InputType.Button)
					{
						KeyCode currentKey = GetCurrentKeyCode();
						m_keyDescription.text = (currentKey == KeyCode.None) ? "" : currentKey.ToString();
					}
					else
					{
						m_keyDescription.text = m_axisNames[m_axisConfig.axis];
					}
				}
				m_image.overrideSprite = m_normalState;
			}
			else
			{
				//	The axis is negative when the timeout has been reached or the scan has been canceled
				if(result.joystickAxis >= 0)
				{
					m_axisConfig.type = InputType.AnalogButton;
					m_axisConfig.SetAnalogButton(m_joystick, result.joystickAxis);
					m_keyDescription.text = m_axisNames[m_axisConfig.axis];
				}
				else
				{
					if(m_axisConfig.type == InputType.AnalogButton)
					{
						m_keyDescription.text = m_axisNames[m_axisConfig.axis];
					}
					else
					{
						KeyCode currentKey = GetCurrentKeyCode();
						m_keyDescription.text = (currentKey == KeyCode.None) ? "" : currentKey.ToString();
					}
				}
				m_image.overrideSprite = m_normalState;
			}
			
			return true;
		}
Пример #23
0
        private static bool CompareInternal(byte[] data, int index, Func <int, bool> matcher, out ScanResult result)
        {
            result = null;

            var value = BitConverter.ToInt32(data, index);

            if (!matcher(value))
            {
                return(false);
            }

            result = new IntegerScanResult(value);

            return(true);
        }
Пример #24
0
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                base.OnScanResult(callbackType, result);

                /* Might want to transition to parsing the API21+ ScanResult, but sort of a pain for now
                 * List<AdvertisementRecord> records = new List<AdvertisementRecord>();
                 * records.Add(new AdvertisementRecord(AdvertisementRecordType.Flags, BitConverter.GetBytes(result.ScanRecord.AdvertiseFlags)));
                 * if (!string.IsNullOrEmpty(result.ScanRecord.DeviceName))
                 * {
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.CompleteLocalName, Encoding.UTF8.GetBytes(result.ScanRecord.DeviceName)));
                 * }
                 * for (int i = 0; i < result.ScanRecord.ManufacturerSpecificData.Size(); i++)
                 * {
                 *  int key = result.ScanRecord.ManufacturerSpecificData.KeyAt(i);
                 *  var arr = result.ScanRecord.GetManufacturerSpecificData(key);
                 *  byte[] data = new byte[arr.Length + 2];
                 *  BitConverter.GetBytes((ushort)key).CopyTo(data,0);
                 *  arr.CopyTo(data, 2);
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.ManufacturerSpecificData, data));
                 * }
                 *
                 * foreach(var uuid in result.ScanRecord.ServiceUuids)
                 * {
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.UuidsIncomplete128Bit, uuid.Uuid.));
                 * }
                 *
                 * foreach(var key in result.ScanRecord.ServiceData.Keys)
                 * {
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.ServiceData, result.ScanRecord.ServiceData));
                 * }*/

                var device = new Device(result.Device, null, null, result.Rssi, result.ScanRecord.GetBytes());

                //Device device;
                //if (result.ScanRecord.ManufacturerSpecificData.Size() > 0)
                //{
                //    int key = result.ScanRecord.ManufacturerSpecificData.KeyAt(0);
                //    byte[] mdata = result.ScanRecord.GetManufacturerSpecificData(key);
                //    byte[] mdataWithKey = new byte[mdata.Length + 2];
                //    BitConverter.GetBytes((ushort)key).CopyTo(mdataWithKey, 0);
                //    mdata.CopyTo(mdataWithKey, 2);
                //    device = new Device(result.Device, null, null, result.Rssi, mdataWithKey);
                //}
                //else
                //{
                //    device = new Device(result.Device, null, null, result.Rssi, new byte[0]);
                //}

                _adapter.DeviceAdvertised(this, new DeviceDiscoveredEventArgs {
                    Device = device
                });

                if (_adapter._discoveredDevices.Contains(device))
                {
                    return;
                }

                _adapter._discoveredDevices.Add(device);

                _adapter.DeviceDiscovered(this, new DeviceDiscoveredEventArgs {
                    Device = device
                });
            }
Пример #25
0
 public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
 {
     OnScanFinished?.Invoke(this, new EventArgs());
 }
Пример #26
0
 static void PlayerWeaponHandle(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(
         new byte[] { 0x0F, 0x45, 0xF7, 0x5F, 0x8B, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x5E, 0x83, 0xF9, 0xFF },
         "xxxxxx????xxxx");
     if (scan.Success)
     {
         //int tmp = memUtils.Read<int>((IntPtr)(lastScan.Address.ToInt32() + 6));
         Offsets.WeaponHandle = (IntPtr)memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 6));
         Logger.Info(ObjectEx.GetName(() => Offsets.WeaponHandle) + "\n" + Offsets.WeaponHandle.ToString("X8"));
     }
 }
Пример #27
0
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                _adapter.OnLeScan(result.Device, result.Rssi, result.ScanRecord.GetBytes());

                base.OnScanResult(callbackType, result);
            }
Пример #28
0
 //static void ClientState2(MemUtils memUtils)
 //{
 //    scan = memUtils.PerformSignatureScan(new byte[] { 0x68, 0, 0, 0, 0, 0xFF, 0x15, 0x98, 0x75, 0x1C, 0x0D, 0xA1, 0, 0, 0, 0, 0x83, 0xc4, 0x1c }, "x????xx????x????xxx", engineDll);
 //    if (scan.Success)
 //    {
 //        int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 12));
 //        Options.Engine = tmp - engineDllBase;
 //    }
 //}
 static void SetViewAngles(ISmartMemory memUtils)
 {
     scan = memUtils["engine.dll"].Find(new byte[] { 0x8B, 0x15, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x4D, 0x08, 0x8B, 0x82, 0x00, 0x00, 0x00, 0x00, 0x89, 0x01, 0x8B, 0x82, 0x00, 0x00, 0x00, 0x00, 0x89, 0x41, 0x04 }, "xx????xxxxx????xxxx????xxx");
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 11));
         Offsets.SetViewAngles = (IntPtr)tmp;
         Logger.Info(ObjectEx.GetName(() => Offsets.SetViewAngles) + "\n" + Offsets.SetViewAngles.ToString("X8"));
     }
 }
Пример #29
0
        private static void SaveDgml(ScanResult result, GroupType group, ShowType show, string templatePath, string outputPath)
        {
            XElement dg;
            XElement nodes;
            XElement links;

            if (String.IsNullOrEmpty(templatePath))
            {
                nodes = new XElement(XDgmlNamespace + "Nodes");
                links = new XElement(XDgmlNamespace + "Links");
                dg    = new XElement(XDgmlNamespace + "DirectedGraph", nodes, links);
            }
            else // load from the provided template path.
            {
                dg    = XElement.Load(templatePath);
                nodes = dg.Element(XDgmlNamespace + "Nodes");
                if (nodes == null)
                {
                    nodes = new XElement(XDgmlNamespace + "Nodes");
                    dg.Add(nodes);
                }

                links = dg.Element(XDgmlNamespace + "Links");
                if (links == null)
                {
                    links = new XElement(XDgmlNamespace + "Links");
                    dg.Add(links);
                }
            }

            // Draw the projects.
            if (ShowType.Projects == (show & ShowType.Projects))
            {
                Console.WriteLine("Graphing projects...");
                foreach (ScannedProject project in result.ProjectFiles.Values)
                {
                    XElement node = new XElement(XDgmlNamespace + "Node",
                                                 new XAttribute("Id", project.Key),
                                                 new XAttribute("Category", "ProjectFile"),
                                                 new XAttribute("Reference", project.Path),
                                                 new XElement(XDgmlNamespace + "Category",
                                                              new XAttribute("Ref", String.Concat(project.Type, "Project"))
                                                              )
                                                 );

                    if (GroupType.Projects == (group & GroupType.Projects))
                    {
                        node.Add(new XAttribute("Group", "collapsed"));
                    }

                    nodes.Add(node);

                    foreach (ScannedProject projectRef in project.TargetProjects)
                    {
                        links.Add(new XElement(XDgmlNamespace + "Link",
                                               new XAttribute("Category", "ProjectReference"),
                                               new XAttribute("Source", project.Key),
                                               new XAttribute("Target", projectRef.Key)
                                               )
                                  );
                    }

                    if (ShowType.Files == (show & ShowType.Files))
                    {
                        foreach (ScannedSourceFile file in project.SourceFiles)
                        {
                            links.Add(new XElement(XDgmlNamespace + "Link",
                                                   new XAttribute("Category", "CompilesFile"),
                                                   new XAttribute("Source", project.Key),
                                                   new XAttribute("Target", file.Key),
                                                   new XElement(XDgmlNamespace + "Category",
                                                                new XAttribute("Ref", "Contains")
                                                                )
                                                   )
                                      );
                        }
                    }
                }
            }

            // Draw the files.
            if (ShowType.Files == (show & ShowType.Files))
            {
                Console.WriteLine("Graphing files...");
                foreach (ScannedSourceFile file in result.SourceFiles.Values)
                {
                    XElement node = new XElement(XDgmlNamespace + "Node",
                                                 new XAttribute("Id", file.Key),
                                                 new XAttribute("Category", "SourceFile"),
                                                 new XAttribute("Reference", file.Path)
                                                 );

                    if (GroupType.Files == (group & GroupType.Files))
                    {
                        node.Add(new XAttribute("Group", "collapsed"));
                    }

                    nodes.Add(node);
                }
            }

            // Draw the symbols.
            if (ShowType.Symbols == (show & ShowType.Symbols))
            {
                Console.WriteLine("Graphing symbols...");
                foreach (ScannedSymbol symbol in result.Symbols.Values)
                {
                    nodes.Add(new XElement(XDgmlNamespace + "Node",
                                           new XAttribute("Id", symbol.Key),
                                           new XAttribute("Category", symbol.Type),
                                           new XAttribute("Reference", symbol.SourceFiles[0].Path)
                                           )
                              );

                    if (ShowType.Files == (show & ShowType.Files))
                    {
                        foreach (ScannedSourceFile fileRef in symbol.SourceFiles)
                        {
                            links.Add(new XElement(XDgmlNamespace + "Link",
                                                   new XAttribute("Category", "DefinesSymbol"),
                                                   new XAttribute("Source", fileRef.Key),
                                                   new XAttribute("Target", symbol.Key),
                                                   new XElement(XDgmlNamespace + "Category",
                                                                new XAttribute("Ref", "Contains")
                                                                )
                                                   )
                                      );
                        }
                    }

                    if (ShowType.References == (show & ShowType.References))
                    {
                        foreach (ScannedSymbol symbolRef in symbol.TargetSymbols)
                        {
                            links.Add(new XElement(XDgmlNamespace + "Link",
                                                   new XAttribute("Category", "SymbolReference"),
                                                   new XAttribute("Source", symbol.Key),
                                                   new XAttribute("Target", symbolRef.Key)
                                                   )
                                      );
                        }
                    }
                }
            }

            dg.Save(outputPath, SaveOptions.None);
        }
Пример #30
0
        public void SearchSamples()
        {
            RemoveTables();
            CreateLSITable();
            TableUtils.WaitUntilTableActive("SampleTable", TestClient);

            {
                // Create items to put into first table
                Dictionary <string, AttributeValue> item1 = new Dictionary <string, AttributeValue>();
                item1["Author"] = new AttributeValue {
                    S = "Mark Twain"
                };
                item1["Title"] = new AttributeValue {
                    S = "A Connecticut Yankee in King Arthur's Court"
                };
                item1["Pages"] = new AttributeValue {
                    N = "575"
                };
                Dictionary <string, AttributeValue> item2 = new Dictionary <string, AttributeValue>();
                item2["Author"] = new AttributeValue {
                    S = "Booker Taliaferro Washington"
                };
                item2["Title"] = new AttributeValue {
                    S = "My Larger Education"
                };
                item2["Pages"] = new AttributeValue {
                    N = "313"
                };
                item2["Year"] = new AttributeValue {
                    N = "1911"
                };

                // Construct write-request for first table
                List <WriteRequest> sampleTableItems = new List <WriteRequest>();
                sampleTableItems.Add(new WriteRequest
                {
                    PutRequest = new PutRequest {
                        Item = item1
                    }
                });
                sampleTableItems.Add(new WriteRequest
                {
                    PutRequest = new PutRequest {
                        Item = item2
                    }
                });
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();
                client.BatchWriteItem(new BatchWriteItemRequest
                {
                    RequestItems = new Dictionary <string, List <WriteRequest> >
                    {
                        { "SampleTable", sampleTableItems }
                    }
                });

                PutSample();
            }


            {
                #region Query Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item hash-key to be string value "Mark Twain"
                AttributeValue hashKey = new AttributeValue {
                    S = "Mark Twain"
                };

                // Define query condition to search for range-keys that begin with the string "The Adventures"
                Condition condition = new Condition
                {
                    ComparisonOperator = "BEGINS_WITH",
                    AttributeValueList = new List <AttributeValue>
                    {
                        new AttributeValue {
                            S = "The Adventures"
                        }
                    }
                };

                // Create the key conditions from hashKey and condition
                Dictionary <string, Condition> keyConditions = new Dictionary <string, Condition>
                {
                    // Hash key condition. ComparisonOperator must be "EQ".
                    {
                        "Author",
                        new Condition
                        {
                            ComparisonOperator = "EQ",
                            AttributeValueList = new List <AttributeValue> {
                                hashKey
                            }
                        }
                    },
                    // Range key condition
                    {
                        "Title",
                        condition
                    }
                };

                // Define marker variable
                Dictionary <string, AttributeValue> startKey = null;

                do
                {
                    // Create Query request
                    QueryRequest request = new QueryRequest
                    {
                        TableName         = "SampleTable",
                        ExclusiveStartKey = startKey,
                        KeyConditions     = keyConditions
                    };

                    // Issue request
                    var result = client.Query(request);

                    // View all returned items
                    List <Dictionary <string, AttributeValue> > items = result.Items;
                    foreach (Dictionary <string, AttributeValue> item in items)
                    {
                        Console.WriteLine("Item:");
                        foreach (var keyValuePair in item)
                        {
                            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                              keyValuePair.Key,
                                              keyValuePair.Value.S,
                                              keyValuePair.Value.N,
                                              string.Join(", ", keyValuePair.Value.SS ?? new List <string>()),
                                              string.Join(", ", keyValuePair.Value.NS ?? new List <string>()));
                        }
                    }

                    // Set marker variable
                    startKey = result.LastEvaluatedKey;
                } while (startKey != null && startKey.Count > 0);

                #endregion
            }

            {
                #region Query Local Secondary Index Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item hash-key to be string value "Mark Twain"
                AttributeValue hashKey = new AttributeValue {
                    S = "Mark Twain"
                };

                // Define query condition to search for range-keys ("Year", in "YearsIndex") that are less than 1900
                Condition condition = new Condition
                {
                    ComparisonOperator = "LT",
                    AttributeValueList = new List <AttributeValue>
                    {
                        new AttributeValue {
                            N = "1900"
                        }
                    }
                };

                // Create the key conditions from hashKey and condition
                Dictionary <string, Condition> keyConditions = new Dictionary <string, Condition>
                {
                    // Hash key condition. ComparisonOperator must be "EQ".
                    {
                        "Author",
                        new Condition
                        {
                            ComparisonOperator = "EQ",
                            AttributeValueList = new List <AttributeValue> {
                                hashKey
                            }
                        }
                    },
                    // Range key condition
                    {
                        "Year", // Reference the correct range key when using indexes
                        condition
                    }
                };

                // Define marker variable
                Dictionary <string, AttributeValue> startKey = null;

                do
                {
                    // Create Query request
                    QueryRequest request = new QueryRequest
                    {
                        TableName         = "SampleTable",
                        ExclusiveStartKey = startKey,
                        KeyConditions     = keyConditions,
                        IndexName         = "YearsIndex" // Specify the index to query against
                    };

                    // Issue request
                    var result = client.Query(request);

                    // View all returned items
                    List <Dictionary <string, AttributeValue> > items = result.Items;
                    foreach (Dictionary <string, AttributeValue> item in items)
                    {
                        Console.WriteLine("Item:");
                        foreach (var keyValuePair in item)
                        {
                            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                              keyValuePair.Key,
                                              keyValuePair.Value.S,
                                              keyValuePair.Value.N,
                                              string.Join(", ", keyValuePair.Value.SS ?? new List <string>()),
                                              string.Join(", ", keyValuePair.Value.NS ?? new List <string>()));
                        }
                    }

                    // Set marker variable
                    startKey = result.LastEvaluatedKey;
                } while (startKey != null && startKey.Count > 0);

                #endregion
            }

            {
                #region Scan Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define scan conditions
                Dictionary <string, Condition> conditions = new Dictionary <string, Condition>();

                // Title attribute should contain the string "Adventures"
                Condition titleCondition = new Condition();
                titleCondition.ComparisonOperator = ComparisonOperator.CONTAINS;
                titleCondition.AttributeValueList.Add(new AttributeValue {
                    S = "Adventures"
                });
                conditions["Title"] = titleCondition;

                // Pages attributes must be greater-than the numeric value "200"
                Condition pagesCondition = new Condition();
                pagesCondition.ComparisonOperator = ComparisonOperator.GT;;
                pagesCondition.AttributeValueList.Add(new AttributeValue {
                    N = "200"
                });
                conditions["Pages"] = pagesCondition;


                // Define marker variable
                Dictionary <string, AttributeValue> startKey = null;

                do
                {
                    // Create Scan request
                    ScanRequest request = new ScanRequest
                    {
                        TableName         = "SampleTable",
                        ExclusiveStartKey = startKey,
                        ScanFilter        = conditions
                    };

                    // Issue request
                    ScanResult result = client.Scan(request);

                    // View all returned items
                    List <Dictionary <string, AttributeValue> > items = result.Items;
                    foreach (Dictionary <string, AttributeValue> item in items)
                    {
                        Console.WriteLine("Item:");
                        foreach (var keyValuePair in item)
                        {
                            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                              keyValuePair.Key,
                                              keyValuePair.Value.S,
                                              keyValuePair.Value.N,
                                              string.Join(", ", keyValuePair.Value.SS ?? new List <string>()),
                                              string.Join(", ", keyValuePair.Value.NS ?? new List <string>()));
                        }
                    }

                    // Set marker variable
                    startKey = result.LastEvaluatedKey;
                } while (startKey != null && startKey.Count > 0);

                #endregion
            }

            {
                // Create lots of items to put into first table
                var table      = Amazon.DynamoDBv2.DocumentModel.Table.LoadTable(TestClient, "SampleTable");
                var batchWrite = table.CreateBatchWrite();
                for (int i = 0; i < 100; i++)
                {
                    var document = new Amazon.DynamoDBv2.DocumentModel.Document();
                    document["Author"] = "FakeAuthor" + i;
                    document["Title"]  = "Book" + i;
                    document["Pages"]  = (180 + i);
                    document["Year"]   = 1900 + i;
                    batchWrite.AddDocumentToPut(document);
                }
                batchWrite.Execute();
            }


            {
                #region Parallel Scan Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define scan conditions
                Dictionary <string, Condition> conditions = new Dictionary <string, Condition>();

                // Pages attributes must be greater-than the numeric value "200"
                Condition pagesCondition = new Condition();
                pagesCondition.ComparisonOperator = ComparisonOperator.GT;
                pagesCondition.AttributeValueList.Add(new AttributeValue {
                    N = "200"
                });
                conditions["Pages"] = pagesCondition;

                // Setup 10 simultaneous threads, each thread calling Scan operation
                // with its own segment value.
                int totalSegments = 10;
                Parallel.For(0, totalSegments, segment =>
                {
                    // Define marker variable
                    Dictionary <string, AttributeValue> startKey = null;

                    do
                    {
                        // Create Scan request
                        ScanRequest request = new ScanRequest
                        {
                            TableName         = "SampleTable",
                            ExclusiveStartKey = startKey,
                            ScanFilter        = conditions,
                            // Total segments to split the table into
                            TotalSegments = totalSegments,
                            // Current segment to scan
                            Segment = segment
                        };

                        // Issue request
                        var result = client.Scan(request);

                        // Write returned items to file
                        string path = string.Format("ParallelScan-{0}-of-{1}.txt", totalSegments, segment);
                        List <Dictionary <string, AttributeValue> > items = result.Items;
                        using (Stream stream = File.OpenWrite(path))
                            using (StreamWriter writer = new StreamWriter(stream))
                            {
                                foreach (Dictionary <string, AttributeValue> item in items)
                                {
                                    writer.WriteLine("Item:");
                                    foreach (var keyValuePair in item)
                                    {
                                        writer.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                                         keyValuePair.Key,
                                                         keyValuePair.Value.S,
                                                         keyValuePair.Value.N,
                                                         string.Join(", ", keyValuePair.Value.SS ?? new List <string>()),
                                                         string.Join(", ", keyValuePair.Value.NS ?? new List <string>()));
                                    }
                                }
                            }

                        // Set marker variable
                        startKey = result.LastEvaluatedKey;
                    } while (startKey != null && startKey.Count > 0);
                });

                #endregion
            }
        }
Пример #31
0
 static void PlayerTeamNum(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(
         new byte[] { 0xCC, 0xCC, 0xCC, 0x8B, 0x89, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x8B, 0x81, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xCC, 0xCC },
         "xxxxx????x????xxxxxxx????xxx");
     if (scan.Success)
     {
         //int tmp = memUtils.Read<int>((IntPtr)(lastScan.Address.ToInt32() + 5));
         Offsets.Team = (IntPtr)memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 5));
         Logger.Info(ObjectEx.GetName(() => Offsets.Team) + "\n" + Offsets.Team.ToString("X8"));
     }
 }
Пример #32
0
 public abstract void Run(Result result, ScanResult scanResult);
Пример #33
0
 static void Server(ISmartMemory memUtils)
 {
     byte[] pattern = new byte[]{
         0x81, 0xC6, 0x00, 0x00, 0x00, 0x00,
         0x81, 0xFE, 0x00, 0x00, 0x00, 0x00,
         0x7C, 0xEB,
         0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00, //<<<<
         0x5F,
         0x5E,
         0x85, 0xC9,
         0x74, 0x0F,
         0x8B, 0x01,
         0xFF, 0x50, 0x04,
         0xC7, 0x05
         };
     scan = memUtils["client.dll"].Find(pattern);
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 16));
         Offsets.Server = (IntPtr)tmp - clientDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.Server) + "\n" + Offsets.Server.ToString("X8"));
     }
 }
Пример #34
0
        public void TestDirectoryScan()
        {
            var address1 = World.AddressFactory.UniqueWith("test-actor1");
            var address2 = World.AddressFactory.UniqueWith("test-actor2");
            var address3 = World.AddressFactory.UniqueWith("test-actor3");
            var address4 = World.AddressFactory.UniqueWith("test-actor4");
            var address5 = World.AddressFactory.UniqueWith("test-actor5");

            var address6 = World.AddressFactory.UniqueWith("test-actor6");
            var address7 = World.AddressFactory.UniqueWith("test-actor7");

            World.Stage.Directory.Register(address1, new TestInterfaceActor());
            World.Stage.Directory.Register(address2, new TestInterfaceActor());
            World.Stage.Directory.Register(address3, new TestInterfaceActor());
            World.Stage.Directory.Register(address4, new TestInterfaceActor());
            World.Stage.Directory.Register(address5, new TestInterfaceActor());

            var scanResults = new ScanResult(7);

            Action <INoProtocol> afterConsumer = actor =>
            {
                Assert.NotNull(actor);
                scanResults.Found();
            };

            World.Stage.ActorOf <INoProtocol>(address5).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address4).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address3).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address2).AndThenConsume(afterConsumer);
            World.Stage.ActorOf <INoProtocol>(address1).AndThenConsume(afterConsumer);

            World.Stage
            .MaybeActorOf <INoProtocol>(address6)
            .AndThenConsume(maybe =>
            {
                if (maybe.IsPresent)
                {
                    scanResults.Found();
                }
                else
                {
                    scanResults.NotFound();
                }
            });
            World.Stage
            .MaybeActorOf <INoProtocol>(address7)
            .AndThenConsume(maybe =>
            {
                if (maybe.IsPresent)
                {
                    scanResults.Found();
                }
                else
                {
                    scanResults.NotFound();
                }
            });

            Assert.Equal(5, scanResults.FoundCount);
            Assert.Equal(2, scanResults.NotFoundCount);
        }
Пример #35
0
 static void SignOnState(ISmartMemory memUtils)
 {
     scan = memUtils["engine.dll"].Find(
         new byte[] { 0x51, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x51, 0x00, 0x83, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x40, 0x3B, 0xD1 },
         "xx????xx?xx?????xxxx");
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 11));
         Offsets.SignOnState = (IntPtr)tmp;
         Logger.Info(ObjectEx.GetName(() => Offsets.SignOnState) + "\n" + Offsets.SignOnState.ToString("X8"));
     }
 }
Пример #36
0
        public bool GetInfo()
        {
            if (!this.PLC.IsPingSuccess)
            {
                this.IsAlive = false;
                LogHelper.WriteError("无法连接到 " + this.PLC.IP);
                return(false);
            }

            string msg    = string.Empty;
            string output = string.Empty;
            string input  = string.Empty;

            try
            {
                #region 获取是否可扫码信号

                output = string.Empty;
                if (!this.PLC.GetInfo(false, Current.Option.GetIsReadyScanCommand, out output, out msg))
                {
                    Error.Alert(msg);
                    this.IsAlive = false;
                    return(false);
                }

                if (output.Substring(3, 1) != "$")
                {
                    LogHelper.WriteError(string.Format("与PLC通信格式错误,input:{0},output:{1}", Current.Option.GetIsReadyScanCommand, output));
                    return(false);
                }

                //%01$RC120
                this.CanScan = output.Trim().Substring(6, 1) == "1";

                #endregion


                #region 控制开门

                if (this.ScanResult == ScanResult.OK || this.ScanResult == ScanResult.NG)
                {
                    var command = this.ScanResult == ScanResult.OK ? Current.Option.SetScanOKCommand : Current.Option.SetScanNGCommand;
                    output = string.Empty;
                    if (!this.PLC.GetInfo(false, command, out output, out msg))
                    {
                        Error.Alert(msg);
                        this.IsAlive = false;
                        return(false);
                    }

                    if (output.Substring(3, 1) != "$")
                    {
                        LogHelper.WriteError(string.Format("与PLC通信格式错误,input:{0},output:{1}", command, output));
                        return(false);
                    }
                    LogHelper.WriteInfo(string.Format("成功发送指令到{0}:{1}", this.Name, command));
                    this.ScanResult = ScanResult.Unknown;
                }
                #endregion

                this.RealtimeStatus = IsReadyScan ? "可扫码" : "等待可扫码信号";
            }
            catch (Exception ex)
            {
                Error.Alert(ex);
                this.IsAlive = false;
                return(false);
            }

            this.IsAlive = true;
            return(true);
        }
Пример #37
0
 static void WeaponTable(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(new byte[] { 0xA1, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xB7, 0xC9, 0x03, 0xC9, 0x8B, 0x44, 0x00, 0x0C, 0xC3 }, "x????xxxxxxx?xx");
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 1));
         Offsets.MiscWeaponInfo = (IntPtr)tmp - clientDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.MiscWeaponInfo) + "\n" + Offsets.MiscWeaponInfo.ToString("X8"));
     }
 }
Пример #38
0
        // default gateway
        private bool CheckLatencyToRouter(IReadOnlyDictionary <string, ScanHistory> HostScanHistoryOrigin, ScanResult result, long threshold)
        {
            double delta = result.Avg - HostScanHistoryOrigin[NetworkTools.DefaultGatewayAddress].Avg;

            if (delta > threshold)
            {
                return(false);
            }

            return(true);
        }
Пример #39
0
        public void TestCompare(ScanCompareType compareType, short value1, short value2, byte[] data, bool expectedResult, ScanResult expectedScanResult)
        {
            var sut = new ShortMemoryComparer(compareType, value1, value2);

            Check.That(sut.Compare(data, 0, out var scanResult)).IsEqualTo(expectedResult);
            Check.That(scanResult).IsEqualTo(expectedScanResult);
            if (scanResult != null)
            {
                Check.That(scanResult).IsInstanceOf <ShortScanResult>();
            }
        }
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     base.OnScanResult(callbackType, result);
     _manager.OnDeviceDiscovered(result.Device, result.ScanRecord, result.Rssi);
 }
Пример #41
0
 static void EntityOff(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(new byte[] { 0x05, 0x00, 0x00, 0x00, 0x00, 0xC1, 0xe9, 0x00, 0x39, 0x48, 0x04 }, "x????xx?xxx");
     if (scan.Success)
     {
         var tmp = memUtils.Read<int>((IntPtr)(scan.Address + 1));
         byte tmp2 = memUtils.Read<byte>((IntPtr)(scan.Address + 7));
         Offsets.EntityList = (IntPtr) tmp + tmp2 - (int)scan.OriginalAddress;
         Logger.Info(
             ObjectEx.GetName(()=> Offsets.EntityList)+"\n"+
             Offsets.EntityList.ToString("X8")
             );
     }
 }
Пример #42
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            var device = new BLEDevice(result.Device);

            if (_discoveredDevices.All(x => x.Guid != device.Guid))
            {
                _discoveredDevices.Add(device);
            }
        }
Пример #43
0
        public void Process(IHackContext context, PatternFinding finding, Stack <Pointer> operands, ScanResult result)
        {
            Pointer operand = Pointer.Zero;

            switch (Type)
            {
            case OperandType.i8:
                operand = (int)finding.Data[Offset];
                break;

            case OperandType.i16:
                operand = new Pointer(BitConverter.ToInt16(finding.Data, Offset));
                break;

            case OperandType.i32:
                operand = new Pointer(BitConverter.ToInt32(finding.Data, Offset));
                break;

            case OperandType.i64:
                operand = new Pointer(BitConverter.ToInt64(finding.Data, Offset));
                break;

            case OperandType.u16:
                operand = new Pointer(BitConverter.ToUInt16(finding.Data, Offset));
                break;

            case OperandType.u32:
                operand = new Pointer(BitConverter.ToUInt32(finding.Data, Offset));
                break;

            case OperandType.u64:
                operand = new Pointer(BitConverter.ToUInt64(finding.Data, Offset));
                break;
            }
            operands.Push(operand);
        }
Пример #44
0
        public bool Compare(byte[] data, int index, FloatScanResult previous, out ScanResult result)
        {
            result = null;

            var value = BitConverter.ToSingle(data, index);

            bool IsMatch()
            {
                switch (CompareType)
                {
                case ScanCompareType.Equal:
                    return(CheckRoundedEquality(value));

                case ScanCompareType.NotEqual:
                    return(!CheckRoundedEquality(value));

                case ScanCompareType.Changed:
                    return(value != previous.Value);

                case ScanCompareType.NotChanged:
                    return(value == previous.Value);

                case ScanCompareType.GreaterThan:
                    return(value > Value1);

                case ScanCompareType.GreaterThanOrEqual:
                    return(value >= Value1);

                case ScanCompareType.Increased:
                    return(value > previous.Value);

                case ScanCompareType.IncreasedOrEqual:
                    return(value >= previous.Value);

                case ScanCompareType.LessThan:
                    return(value < Value1);

                case ScanCompareType.LessThanOrEqual:
                    return(value <= Value1);

                case ScanCompareType.Decreased:
                    return(value < previous.Value);

                case ScanCompareType.DecreasedOrEqual:
                    return(value <= previous.Value);

                case ScanCompareType.Between:
                    return(Value1 < value && value < Value2);

                case ScanCompareType.BetweenOrEqual:
                    return(Value1 <= value && value <= Value2);

                default:
                    throw new InvalidCompareTypeException(CompareType);
                }
            }

            if (!IsMatch())
            {
                return(false);
            }

            result = new FloatScanResult(value);

            return(true);
        }
Пример #45
0
 private static void PrintScan(ScanResult scanResult)
 {
     Console.WriteLine("Scan ID: " + scanResult.ScanId);
     Console.WriteLine("Message: " + scanResult.VerboseMsg);
     Console.WriteLine();
 }
Пример #46
0
 static void EntityVecOrigin(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(
         new byte[] { 0x8A, 0x0E, 0x80, 0xE1, 0xFC, 0x0A, 0xC8, 0x88, 0x0E, 0xF3, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x9F },
         "xxxxxxxxxx??x??????x????x");
     if (scan.Success)
     {
         //int tmp = memUtils.Read<int>((IntPtr)(lastScan.Address.ToInt32() + 13));
         Offsets.VecOrigin = (IntPtr)memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 13));
         Logger.Info(ObjectEx.GetName(() => Offsets.VecOrigin) + "\n" + Offsets.VecOrigin.ToString("X8"));
     }
 }
Пример #47
0
            public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
            {
                base.OnScanResult(callbackType, result);
                BluetoothDevice device = result.Device;

                Console.WriteLine(result);
            }
Пример #48
0
 private static void FindAttack(ISmartMemory memUtils)
 {
     byte[] bytes = BitConverter.GetBytes(4294967293U);
     byte[] pattern = new byte[27]
     {
     137,21,0,0,0,0,139,21,0,0,0,0,246,194,3,
     116,3,131,206,4,168,4,191,bytes[0],bytes[1],bytes[2],bytes[3]
     };
     scan = memUtils["client.dll"].Find(pattern);
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 2));
         Offsets.Attack = new IntPtr(tmp - clientDllBase);
         Logger.Info(ObjectEx.GetName(() => Offsets.Attack) + "\n" +Offsets.Attack.ToString("X8")
         );
     }
 }
        private static ScanResult ScanLocation(GeoCoordinates location)
        {
            var formatter = new NumberFormatInfo {
                NumberDecimalSeparator = "."
            };

            var offset = 0.003;

            // 0.003 = half a mile; maximum 0.06 is 10 miles
            if (offset < 0.001)
            {
                offset = 0.003;
            }
            if (offset > 0.06)
            {
                offset = 0.06;
            }

            var boundLowerLeftLat  = location.Latitude - offset;
            var boundLowerLeftLng  = location.Longitude - offset;
            var boundUpperRightLat = location.Latitude + offset;
            var boundUpperRightLng = location.Longitude + offset;

            var uri =
                $"http://skiplagged.com/api/pokemon.php?bounds={boundLowerLeftLat.ToString(formatter)},{boundLowerLeftLng.ToString(formatter)},{boundUpperRightLat.ToString(formatter)},{boundUpperRightLng.ToString(formatter)}";

            ScanResult scanResult;

            try
            {
                var request = WebRequest.CreateHttp(uri);
                request.UserAgent        = UserAgentHelper.GetRandomUseragent();
                request.Accept           = "application/json";
                request.Method           = "GET";
                request.Timeout          = 15000;
                request.ReadWriteTimeout = 32000;

                using (var resp = request.GetResponse())
                {
                    using (var reader = new StreamReader(resp.GetResponseStream()))
                    {
                        var fullresp =
                            reader.ReadToEnd()
                            .Replace(" M", "Male")
                            .Replace(" F", "Female")
                            .Replace("Farfetch'd", "Farfetchd")
                            .Replace("Mr.Maleime", "MrMime");
                        scanResult = JsonConvert.DeserializeObject <ScanResult>(fullresp);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Debug("Error querying skiplagged", ex);
                scanResult = new ScanResult
                {
                    Status   = "fail",
                    pokemons = new List <PokemonLocation>()
                };
            }
            return(scanResult);
        }
Пример #50
0
 private static void FindAttack2(ISmartMemory memUtils)
 {
     byte[] int1 = BitConverter.GetBytes(0xFFFFFFFD);
     byte[] int2 = BitConverter.GetBytes(0x00002000);
     byte[] pattern = new byte[]{
         0x89, 0x15, 0x00, 0x00, 0x00, 0x00, //mov [client.dll+xxxx],edx
         0x8B, 0x15, 0x00, 0x00, 0x00, 0x00, //mov edx, [client.dll+????]
         0xF6, 0xC2, 0x03,                   //test dl, 03
         0x74, 0x06,                         //je client.dll+????
         0x81, 0xCE, int2[0], int2[1], int2[2], int2[3], //or esi,00002000
         0xA9,  int2[0], int2[1], int2[2], int2[3],      //test al,00002000
         0xBF, int1[0], int1[1], int1[2], int1[3]        //mov edi,FFFFFFFD
         };
     scan = memUtils["client.dll"].Find(pattern);
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 2));
         Offsets.Attack2 = (IntPtr)tmp - clientDllBase;
         Logger.Info(
         ObjectEx.GetName(() => Offsets.Attack2) + "\n" +
         Offsets.Attack2.ToString("X8")
         );
     }
 }
Пример #51
0
 public override void Run(Result result, ScanResult scanResult)
 {
     _xmlHelper.ProjectsXmlNodePresenceRun("StyleCopEnabled", result, scanResult);
 }
Пример #52
0
 static void GlowManager(ISmartMemory memUtils)
 {
     var bytu = new byte[] { 0xE8, 0x0, 0x0, 0x0, 0x0, 0x83, 0xC4, 0x04, 0xB8, 0x0, 0x0, 0x0, 0x0, 0xC3, 0xcc };
     scan = memUtils["client.dll"].Find(bytu, "x????xxxx????xx");
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 9));
         Offsets.GlowObjectBase = (IntPtr)tmp - clientDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.GlowObjectBase) + "\n" + Offsets.GlowObjectBase.ToString("X8"));
     }
 }
Пример #53
0
 public void Process(IHackContext context, PatternFinding finding, Stack <Pointer> operands, ScanResult result)
 {
     result.Values[Name] = operands.Pop();
 }
Пример #54
0
 static void Jump(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(new byte[] { 0x89, 0x15, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x15, 0x00, 0x00, 0x00, 0x00, 0xF6, 0xC2, 0x03, 0x74, 0x03, 0x83, 0xCE, 0x08, 0xA8, 0x08, 0xBF }, "xx????xx????xxxxxxxxxxx");
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 2));
         Offsets.Jump = (IntPtr)tmp - clientDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.Jump) + "\n" + Offsets.Jump.ToString("X8"));
     }
 }
Пример #55
0
 private void OnScanCompleted(ScanResult result)
 {
     scanResult = result;
     waitScanResetEvent.Set();
 }
Пример #56
0
 static void LocalPlayer(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(new byte[] { 0x8D, 0x34, 0x85, 0x00, 0x00, 0x00, 0x00, 0x89, 0x15, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x41, 0x08, 0x8B, 0x48 }, "xxx????xx????xxxxx");
     if (scan.Success)
     {
         var tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 3));
         byte tmp2 = memUtils.Read<byte>((IntPtr)(scan.Address.ToInt32() + 18));
         Offsets.LocalPlayer = (IntPtr) tmp + tmp2 - clientDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.LocalPlayer) + "\n" + Offsets.LocalPlayer.ToString("X8"));
     }
 }
Пример #57
0
 /// <summary>
 ///     Performs a pattern scan.
 /// </summary>
 /// <param name="myPattern">The patterns bytes.</param>
 /// <param name="mask">The mask of the pattern. ? Is for wild card, x otherwise.</param>
 /// <param name="offsetToAdd">The offset to add to the offset result found from the pattern.</param>
 /// <param name="isOffsetMode">If the address is found from the base address + offset or not.</param>
 /// <param name="reBase">If the address should be rebased to this <see cref="RemoteModule" /> Instance's base address.</param>
 /// <returns>A new <see cref="ScanResult" /></returns>
 public ScanResult Find(byte[] myPattern, string mask)
 {
     var patternData = ModuleData;
     var patternBytes = myPattern;
     var patternMask = mask;
     var result = new ScanResult();
     for (var offset = 0; offset < patternData.Length; offset++)
     {
         if (patternMask.Where((m, b) => m == 'x' && patternBytes[b] != patternData[b + offset]).Any()) continue;
         // If this area is reached, the pattern has been found.
         result.Success = true;
         result.OriginalAddress = ImageBase;
         result.Address = IntPtr.Add(ImageBase, offset);
         result.Offset = offset;
         return result;
     }
     // If this is reached, the pattern was not found.
     result.Success = false;
     return result;
 }
Пример #58
0
 static void MapName(ISmartMemory memUtils)
 {
     byte[] pattern = new byte[]{
        0x72, 0xEF,
        0xC6, 0x00, 0x00,
        0xB8, 0x00, 0x00, 0x00, 0x00,
        0x80, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x74, 0x15,
        0x8A, 0x08,
        0x80, 0xF9
         };
     scan = memUtils["engine.dll"].Find(pattern);
     if (scan.Success)
     {
         int tmp = memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 6));
         Offsets.ServerMap = (IntPtr)tmp - engineDllBase;
         Logger.Info(ObjectEx.GetName(() => Offsets.ServerMap) + "\n" + Offsets.ServerMap.ToString("X8"));
     }
 }
Пример #59
0
 private Scanner()
 {
     result = new ScanResult();
 }
Пример #60
0
 static void PlayerBoneMatrix(ISmartMemory memUtils)
 {
     scan = memUtils["client.dll"].Find(
         new byte[] { 0x83, 0x3C, 0xB0, 0xFF, 0x75, 0x15, 0x8B, 0x87, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xCF, 0x8B, 0x17, 0x03, 0x44, 0x24, 0x0C, 0x50 },
         "xxxxxxxx????xxxxxxxxx");
     if (scan.Success)
     {
         //int tmp = memUtils.Read<int>((IntPtr)(lastScan.Address.ToInt32() + 8));
         Offsets.BoneMatrix = (IntPtr)memUtils.Read<int>((IntPtr)(scan.Address.ToInt32() + 8));
         Logger.Info(ObjectEx.GetName(() => Offsets.BoneMatrix) + "\n" + Offsets.BoneMatrix.ToString("X8"));
     }
 }