コード例 #1
0
ファイル: RobloxSharp.cs プロジェクト: rajeshwarn/RoSharp
        private IntPtr GetScriptContext()
        {
#if DEBUG_ROBLOX
            Logger.Log(Logger.LogType.WORK, "Attempting to scan for ScriptContext...");
#endif

            NativeObjects.MemoryBasicInformation mbi;

            IntPtr baseAdr = this.Native.MainModule.BaseAddress;

            SigScan sigScan = new SigScan()
            {
                Process = this.Native
            };

            for (IntPtr offset = baseAdr; offset.ToInt32() < 0x7FFFFFFF; offset += baseAdr.ToInt32())
            {
                NativeObjects.NativeMethods.VirtualQueryEx(this.Handle, offset, out mbi, Marshal.SizeOf <NativeObjects.MemoryBasicInformation>());

                if (mbi.Protect == NativeObjects.MemoryProtectionFlags.ReadWrite)
                {
                    sigScan.Address = offset;
                    sigScan.Size    = mbi.RegionSize;
                    IntPtr result = sigScan.FindPattern(BitConverter.ToString(BitConverter.GetBytes(FixAddress(Offsets.GlobalAddressTable["ScriptContext"].AddressValue.ToInt32()))).Replace("-", " "));
                    sigScan.ResetRegion();
                    if (result != IntPtr.Zero)
                    {
#if DEBUG_ROBLOX
                        Logger.Log(Logger.LogType.SUCCESS, "Successfully scanned for ScriptContext! SC: 0x{0:X}", result.ToInt32());
#endif

                        return(result);
                    }
                }

                baseAdr = (IntPtr)mbi.RegionSize;
            }

#if DEBUG_ROBLOX
            Logger.Log(Logger.LogType.ERROR, "Failed to scan for ScriptContext");
#endif
            return(IntPtr.Zero);
        }
コード例 #2
0
ファイル: SF4Memory.cs プロジェクト: The-Skas/Frame-Trapped
        public void runScan()
        {
            byte[] pattern = new byte[] {
                0x84, 0x05, 0xE0, 0xA2, 0xA8, 0x00, 0x75, 0x24, 0x09,
                0x05, 0x00, 0x00, 0x00, 0x00, 0xB9, 0x00, 0x00, 0x00,
                0x00, 0xC7, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE8,
                0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00,
                0xE8, 0x00, 0x00, 0x00, 0x00, 0x83, 0xC4, 0x04, 0xB8,
                0x00, 0x00, 0x00, 0x00, 0x8B, 0x4D, 0xF4, 0x64, 0x89,
                0x0D, 0x00, 0x00, 0x00, 0x00, 0x59, 0x8B, 0xE5, 0x5D
            };                                                            //This is the pattern we use to find the base of what we want in memory. Add 0x5c to it to get to the players.

            string mask = "xxx?xxxxxx????x????xx?????x????x????x????xxxx????xxxxxx????xxxx";

            this.SigScan.Address = new IntPtr(0x400000);
            this.SigScan.Size    = 0x900000; //This should be more than enough.
            IntPtr address = IntPtr.Zero;

            try
            {
                SigScan.Process = Process.GetProcessesByName("SSFIV")[0];
                address         = SigScan.FindPattern(pattern, mask, 0x2d);
            }
            catch
            {
                //Error message here. (Couldn't find the process)
            }
            SigScan.ResetRegion();

            if (address != IntPtr.Zero)
            {
                openSF4Process();
                playerBase       = readIntFromGameMemory(address.ToInt32()) + 0x5c;
                frameCounterBase = playerBase + 0x24;
                comboCounterBase = playerBase + 0x4;
            }
            else
            {
                //Error message here. (Probably wrong pattern/mask)
            }
        }