BolterV2.SigScan.FindPattern C# (CSharp) Method

FindPattern() public method

FindPattern Attempts to locate the given pattern inside the dumped memory region compared against the given mask. If the pattern is found, the offset is added to the located address and returned to the user.
public FindPattern ( byte btPattern, string strMask, int nOffset ) : IntPtr
btPattern byte Byte pattern to look for in the dumped region.
strMask string The mask string to compare against.
nOffset int The offset added to the result address.
return System.IntPtr
        public IntPtr FindPattern(byte[] btPattern, string strMask, int nOffset)
        {
            try
            {
                // Dump the memory region if we have not dumped it yet.
                if (m_vDumpedRegion == null || m_vDumpedRegion.Length == 0)
                {
                    if (!DumpMemory())
                        return IntPtr.Zero;
                }

                // Ensure the mask and pattern lengths match.
                if (strMask.Length != btPattern.Length)
                    return IntPtr.Zero;

                // Loop the region and look for the pattern.
                for (var x = 0; x < m_vDumpedRegion.Length; x++)
                {
                    if (MaskCheck(x, btPattern, strMask))
                    {
                        // The pattern was found, return it.
                        return new IntPtr((int)m_vAddress + (x + nOffset));
                    }
                }

                // Pattern was not found.
                return IntPtr.Zero;
            }
            catch
            {
                return IntPtr.Zero;
            }
        }

Usage Example

Example #1
0
        private void Refresh(object sender, RoutedEventArgs e)
        {
            var ThePs = Process.GetProcessesByName("ffxiv");

            foreach (var process in ThePs)
            {
                var    hProc           = process.Handle;
                var    sigScam         = new SigScan(process, process.MainModule.BaseAddress + 0xFB9000, 0x14B000);
                byte[] playerStructSig = { 0x46, 0x69, 0x72, 0x65, 0x20, 0x53, 0x68, 0x61, 0x72, 0x64, 0x02, 0x13, 0x02, 0xEC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 };
                var    NamePtr         = sigScam.FindPattern(playerStructSig, "xxxxxxxxxxxxxxxxxxxx", -(int)process.MainModule.BaseAddress) - 0xC26;
                playerName =
                    Encoding.ASCII.GetString(_mapper.ReadMemory(
                                                 hProc, process.MainModule.BaseAddress + (int)NamePtr, 21).TakeWhile(p => p != 0).ToArray());

                var newimg = (ImageSource)CreateBitmapSourceFromBitmap(Properties.Resources.ffxiv);
                ProcessListBox.Items.Add(new ListImg(string.Format("{0}\nPID - {1}", playerName, process.Id), newimg));
            }

            foreach (var file in Directory.EnumerateFiles(Directory.GetCurrentDirectory()).Where(file => file.EndsWith(".dll")))
            {
                PluginsBox.Items.Add(new string(file.Skip(Directory.GetCurrentDirectory().Length + 1).ToArray()).Replace(".dll", ""));
            }
            PluginsBox.SelectedIndex     = 0;
            ProcessListBox.SelectedIndex = 0;
        }
All Usage Examples Of BolterV2.SigScan::FindPattern