private dynamic GetValue(Process p, String type, DeepPointer pointer)
 {
     if (type == "int")
         return pointer.Deref<int>(p);
     else if (type == "uint")
         return pointer.Deref<uint>(p);
     else if (type == "float")
         return pointer.Deref<float>(p);
     else if (type == "double")
         return pointer.Deref<double>(p);
     else if (type == "byte")
         return pointer.Deref<byte>(p);
     else if (type == "sbyte")
         return pointer.Deref<sbyte>(p);
     else if (type == "short")
         return pointer.Deref<short>(p);
     else if (type == "ushort")
         return pointer.Deref<ushort>(p);
     else if (type == "bool")
         return pointer.Deref<bool>(p);
     else if (type.StartsWith("string"))
     {
         var length = Int32.Parse(type.Substring("string".Length));
         return pointer.DerefString(p, length);
     }
     else if (type.StartsWith("byte"))
     {
         var length = Int32.Parse(type.Substring("byte".Length));
         return pointer.DerefBytes(p, length);
     }
     throw new ArgumentException(string.Format("The provided type, '{0}', is not supported", type));
 }
Example #2
0
        public GameInfo(Process gameProcess)
        {
            this.gameProcess = gameProcess;
            if (gameProcess.MainModuleWow64Safe().ModuleMemorySize == 5029888)
            {
                gameVersion = GameVersion.v2014_12_03;
            }
            else if (gameProcess.MainModuleWow64Safe().ModuleMemorySize == 5033984)
            {
                gameVersion = GameVersion.v2016_01_12;
            }
            else
            {
                MessageBox.Show("Unsupported game version", "LiveSplit.Quake2", 
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                gameVersion = GameVersion.v2014_12_03;
            }

            switch (gameVersion)
            {
                case GameVersion.v2014_12_03:
                    gameStateAddress = new DeepPointer(0x31BDC0);
                    mapAddress = new DeepPointer(0x3086C4);
                    inIntermissionAddress = new DeepPointer(0x2C679C);
                    break;
                case GameVersion.v2016_01_12:
                    gameStateAddress = new DeepPointer(0x286400);
                    mapAddress = new DeepPointer(0x33FF44);
                    inIntermissionAddress = new DeepPointer(0x2FDF28);
                    break;
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var memory = new MemoryManager();

            memory.OpenProcess("MirrorsEdgeCatalyst");

            DeepPointer <float> ptr = new DeepPointer <float>(memory.ProcHandle, 0, 0x1423DA028, 0x20, 0x20, 0x40, 0x20, 0x04);
            long dyn = ptr.GetDynamicAddress();

            Stopwatch w = new Stopwatch();
            long      gtime, stime;

            byte[] b = new byte[4];
            var    z = IntPtr.Zero;

            w.Start();
            for (int i = 0; i < 500; i++)
            {
                WinAPI.ReadProcessMemory(memory.ProcHandle, dyn, b, 4, out z);
            }
            gtime = w.ElapsedTicks;
            w.Restart();
            for (int i = 0; i < 500; i++)
            {
                WinAPI.WriteProcessMemory(memory.ProcHandle, dyn, b, 4, out z);
            }
            stime = w.ElapsedTicks;

            Console.WriteLine("[AVERAGE OF 5000 GETS/SETS]");
            Console.WriteLine("get is faster by a factor of {0}", (double)stime / gtime);

            Console.Read();
        }
Example #4
0
        public static void DEV_FindObjects(string Name, List <Room> rooms = default)
        {
            int c = 0;

            ReadDPValue(PtrDB.DP_SublevelsCount, out int Sublevels);

            for (var j = 1; j < Sublevels; j++)
            {
                ReadDPValue(new DeepPointer(PtrDB.DP_ObjectsCount).Format(0x8 * (j - 1)), out int Objects);
                for (var i = 1; i < Objects; i++)
                {
                    DeepPointer DP = new DeepPointer(PtrDB.DP_VFTablePattern).Format(0x8 * (j - 1), 0x8 * (i - 1), 0x18);
                    ReadDPValue(DP, out int fname);

                    string objectname = GetNameFromFName(fname);
                    if (objectname.Contains(Name))
                    {
                        ReadLocation(DP, 0x1d0, out Vector3f location);
                        if (rooms == default(List <Room>) || rooms.Where(r => GameUtils.PlayerWithinRectangle(location, r.pointA, r.pointB)).Count() > 0)
                        {
                            c++;
                            Console.WriteLine($"{objectname}:\nPos: {location.X} {location.Y} {location.Z}");
                            Console.WriteLine($"Pointer:(0x04609420, 0x98, 0x{0x8 * (j - 1):X}, 0x128, 0xA8, 0x{0x8 * (i - 1):X}, 0x0)\n");
                        }
                    }
                }
            }
            Console.WriteLine("found: " + c);
        }
Example #5
0
 private dynamic GetValue(Process p, String type, DeepPointer pointer)
 {
     if (type == "int")
     {
         int x;
         pointer.Deref <int>(p, out x);
         return(x);
     }
     else if (type == "uint")
     {
         uint x;
         pointer.Deref <uint>(p, out x);
         return(x);
     }
     else if (type == "float")
     {
         float x;
         pointer.Deref <float>(p, out x);
         return(x);
     }
     else if (type == "byte")
     {
         byte x;
         pointer.Deref <byte>(p, out x);
         return(x);
     }
     else if (type == "bool")
     {
         bool x;
         pointer.Deref <bool>(p, out x);
         return(x);
     }
     else if (type == "short")
     {
         short x;
         pointer.Deref <short>(p, out x);
         return(x);
     }
     else if (type == "sbyte")
     {
         sbyte x;
         pointer.Deref <sbyte>(p, out x);
         return(x);
     }
     else if (type.StartsWith("string"))
     {
         String x;
         var    length = Int32.Parse(type.Substring("string".Length));
         pointer.Deref(p, out x, length);
         return(x);
     }
     else if (type.StartsWith("byte"))
     {
         byte[] x;
         var    length = Int32.Parse(type.Substring("byte".Length));
         pointer.Deref(p, out x, length);
         return(x);
     }
     throw new ArgumentException("The provided type is not supported");
 }
Example #6
0
        public bool IsSpeedmodEnabled()
        {
            var speedmodCode =
                new DeepPointer("server.dll", 0x43373A, new int[] { }).Deref <byte>(FzzyComponent.process);

            return(speedmodCode == 0x83);
        }
Example #7
0
 public Witcher3GameIntegration(ILogger logger)
 {
     this.logger = logger;
     // v1.32
     this.consoleTextPointer           = new DeepPointer(ModuleName, 0x02a5cb28, 0x48, 0x0);
     this.consoleKeyPressDoublePointer = new DeepPointer(ModuleName, 0x2BD98C8);
 }
Example #8
0
        public GameMemory(ElMatadorSettings componentSettings)
        {
            _settings = componentSettings;

            _isLoadingPtr = new DeepPointer("ElMatadorGraphWrapper.dll", 0x3030);  // == 1 if a loadscreen is happening
            _ignorePIDs   = new List <int>();
        }
Example #9
0
        private LocalizationManager.Language GetSettingsLang()
        {
            byte langID;

            SettingsLangDP = new DeepPointer(PtrDB.DP_Settings_Lang);
            SettingsLangDP.DerefOffsets(game, out SettingsLangPtr);
            game.ReadValue(SettingsLangPtr, out langID);
            switch (langID)
            {
            case 0:
                return(LocalizationManager.Language.EN);

            case 1:
                return(LocalizationManager.Language.PL);

            case 2:
                return(LocalizationManager.Language.FR);

            case 3:
                return(LocalizationManager.Language.DE);

            case 6:
                return(LocalizationManager.Language.ES);

            case 7:
                return(LocalizationManager.Language.RU);
            }

            return(LocalizationManager.Language.OTHER);
        }
Example #10
0
        private DeepPointer AppendBaseOffset(DeepPointer dp, int[] appendOffsets)
        {
            List <int> offsets = new List <int>(dp.GetOffsets());

            offsets.AddRange(appendOffsets); // add new offsets
            return(new DeepPointer(dp.GetBase(), new List <int>(offsets)));
        }
Example #11
0
        public JumpPad(int offset)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_JumpPad).ModifyOffset(2, offset);

            // Pointers
            Pointers.Add("Speed", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x248), IntPtr.Zero));
            Pointers.Add("Rotation", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x230, 0x1C0), IntPtr.Zero));
        }
Example #12
0
 public CVPlatform(DeepPointer PlatformDP) : base(new DeepPointer(PlatformDP, 0x248, 0x1d0))
 {
     endPointDP       = new DeepPointer(PlatformDP, 0x240, 0x1d0);
     startMoveDelayDP = new DeepPointer(PlatformDP, 0x280);
     timeLerpA_DP     = new DeepPointer(PlatformDP, 0x284);
     timeLerpB_DP     = new DeepPointer(PlatformDP, 0x278);
     Pos = EndPoint = LastPos = Vector3f.Empty;
 }
Example #13
0
        public SignSpawner(int offset)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_SignSpawner).ModifyOffset(4, offset);

            Pointers.Add("Speed", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x248), IntPtr.Zero));
            Pointers.Add("SpawnDelay", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x24C), IntPtr.Zero));
            Pointers.Add("DelayOnStart", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x250), IntPtr.Zero));
        }
Example #14
0
        /// <summary>
        /// Get the name of an entity using a pointer.
        /// </summary>
        /// <param name="ptr">The pointer.</param>
        /// <param name="isTargetName">Whether the supplied name is the entity's name or its class name.</param>
        /// <returns></returns>
        private static string GetNameFromPtr(IntPtr ptr, bool isTargetName = false)
        {
            DeepPointer nameptr = new DeepPointer(ptr, 0x10, (isTargetName) ? 0x18 : 0x20, 0x0);
            string      name    = "";

            nameptr.DerefString(game, 128, out name);
            return(name);
        }
Example #15
0
 public GameMemory(IntelDisplay intelDisplay)
 {
     _intelFishPtr      = new DeepPointer(0x198452C); // 0x197C460
     _intelFishPtrDebug = new DeepPointer(0x25AF8AC); // 0x25A77E0
     _intelDisplay      = intelDisplay;
     _netClient         = new NetClient();
     IntelFishCurrent   = new byte[1];
     IntelUnitCurrent   = new byte[1];
 }
Example #16
0
        public void ChangePatrolPoint(Process game, DeepPointer patrolDP, Vector3f pos)
        {
            IntPtr patrolPtr;

            patrolDP.DerefOffsets(game, out patrolPtr);
            game.WriteBytes(patrolPtr, BitConverter.GetBytes((float)pos.X));
            game.WriteBytes(patrolPtr + 4, BitConverter.GetBytes((float)pos.Y));
            game.WriteBytes(patrolPtr + 8, BitConverter.GetBytes((float)pos.Z));
        }
Example #17
0
        public UplinkSlowmo(int firstOffset, int secondOffset, int thirdOffet)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_UplinkSlowmo).ModifyOffset(1, firstOffset).ModifyOffset(4, secondOffset).ModifyOffset(6, thirdOffet);

            // add pointers
            Pointers.Add("TimeMultiplier", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x8), IntPtr.Zero));
            Pointers.Add("MidCurveTime", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x20), IntPtr.Zero));
            Pointers.Add("TotalTime", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x3C), IntPtr.Zero));
        }
Example #18
0
 public GameMemory(IntelDisplay intelDisplay, Action <int> fishCountDisplay)
 {
     _intelFishPtr      = new DeepPointer(0x198452C); // 0x197C460
     _intelFishPtrDebug = new DeepPointer(0x25AF8AC); // 0x25A77E0
     _intelDisplay      = intelDisplay;
     _fishCountDisplay  = fishCountDisplay;
     IntelFishCurrent   = new byte[1];
     IntelUnitCurrent   = new byte[1];
 }
Example #19
0
        public static void ModifyCP(DeepPointer dp, Vector3f pos, Process game)
        {
            IntPtr cpPtr;

            dp.DerefOffsets(game, out cpPtr);
            game.WriteBytes(cpPtr, BitConverter.GetBytes(pos.X));
            game.WriteBytes(cpPtr + 4, BitConverter.GetBytes(pos.Y));
            game.WriteBytes(cpPtr + 8, BitConverter.GetBytes(pos.Z));
        }
Example #20
0
        //base + 98 + <firstOffset> + 128 + A8 + <secondOffset> + XXX
        public ToggleableFan(int firstOffset, int secondOffset)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_ToggleableFan).ModifyOffset(1, firstOffset).ModifyOffset(4, secondOffset);

            // Add pointers
            Pointers.Add("FanSpeed", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2E0), IntPtr.Zero));
            Pointers.Add("HackedFanSpeed", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2E8), IntPtr.Zero));
            Pointers.Add("HackedDuration", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2EC), IntPtr.Zero));
        }
Example #21
0
        public TomLaser(int offset)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_Tom_Laser).ModifyOffset(5, offset);

            // pointers
            Pointers.Add("Pos", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x11C), IntPtr.Zero));
            Pointers.Add("VerticalAngle", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x128), IntPtr.Zero));
            Pointers.Add("Rotation", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x1A0), IntPtr.Zero));
        }
Example #22
0
        public override bool Attach()
        {
            if (!Attach((Process p) =>
            {
                if (!p.ProcessName.ToLowerInvariant().StartsWith("lamulana"))
                {
                    return(false);
                }
                try
                {
                    return(p.MainModule.FileVersionInfo.ProductName == "La-Mulana");
                }
                catch (Win32Exception) // sigh, see http://www.aboutmycode.com/net/access-denied-process-bugs/
                {
                    throw;
                }
                catch { return(false); }
            }))
            {
                offsets = null;
                return(false);
            }

            if (offsets != null)
            {
                return(true);
            }

            version = proc.MainModule.FileVersionInfo.FileVersion;

            if (!veroffsets.TryGetValue(version, out offsets))
            {
                return(false);
            }

            bytesptr = new DeepPointer(offsets.Value.bytes);
            for (int i = 0; i < 0x1000; i++)
            {
                vars.Add(new GameVar <byte>(String.Format("byte-{0:x3}", i), offsets.Value.bytes + i));
            }

            wordsptr = new DeepPointer(offsets.Value.wordsptr, 0);
            for (int i = 0; i < 255; i++)
            {
                vars.Add(new GameVar <ushort>(String.Format("word-{0:x3}", i), offsets.Value.wordsptr, i * 2));
            }

            vars.Add(new GameVar <uint>("flags-1", offsets.Value.flags));
            vars.Add(new GameVar <uint>("flags-2", offsets.Value.flags + 4));
            vars.Add(new GameVar <uint>("flags-3", offsets.Value.flags + 8));
            vars.Add(new GameVar <uint>("flags-4", offsets.Value.flags + 12));
            vars.Add(new GameVar <uint>("flags-5", offsets.Value.flags + 16));

            vars.Add(new GameVar <uint>("igt", offsets.Value.igt));
            return(true);
        }
Example #23
0
        //0x045A3C20, 0x98, <firstOffset>, 0x128, 0xA8, <secondOffset>
        public UplinkJump(int firstOffset, int secondOffset)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_UplinkJump).ModifyOffset(1, firstOffset).ModifyOffset(4, secondOffset);

            // add pointers
            Pointers.Add("TimeToActivate", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x234), IntPtr.Zero));
            Pointers.Add("JumpMultiplier", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x280), IntPtr.Zero));
            Pointers.Add("JumpForwardMultiplier", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x284), IntPtr.Zero));
            Pointers.Add("JumpGravity", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x288), IntPtr.Zero)); // 6 by default, 2x from basic value ingame
        }
Example #24
0
        // base, 0x98, firstOffset, 0x128, 0xA8, secondOffset
        public Billboard(int firstOffset, int secondOffset)
        {
            ObjectDP = new DeepPointer(PtrDB.DP_Billboard).ModifyOffset(1, firstOffset).ModifyOffset(4, secondOffset);

            // Pointers
            Pointers.Add("Time1", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2C8), IntPtr.Zero));
            Pointers.Add("Angle1", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2CC), IntPtr.Zero));
            Pointers.Add("Time2", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2C0), IntPtr.Zero));
            Pointers.Add("Angle2", new Tuple <DeepPointer, IntPtr>(AppendBaseOffset(0x2D4), IntPtr.Zero));
        }
Example #25
0
        public static void DisableCP(DeepPointer dp)
        {
            IntPtr cpPtr;
            var    offsets = dp.GetOffsets();

            offsets.RemoveRange(offsets.Count - 2, 2);
            offsets.Add(0x02A0);
            dp = new DeepPointer(dp.GetBase(), offsets);
            dp.DerefOffsets(GameHook.game, out cpPtr);
            GameHook.game.WriteBytes(cpPtr, new byte[] { 0 });
        }
Example #26
0
        public Trigger(int firstOffset, int secondOffset, Vector3f pos, Vector3f size, DeepPointer startSearch, int searchLength, string signature)
        {
            originDP  = new DeepPointer(PtrDB.DP_WorldTrigger).ModifyOffset(1, firstOffset).ModifyOffset(4, secondOffset);
            this.pos  = pos;
            this.size = size;

            // signature searching
            this.startSearch  = startSearch;
            this.signature    = signature;
            this.searchLength = searchLength;
        }
        private bool VerifyProcessRunning()
        {
            if (gameProc != null && !gameProc.HasExited)
            {
                return(true);
            }
            Process[] game = Process.GetProcessesByName("MomodoraRUtM");
            if (game.Length > 0)
            {
                switch (game[0].MainModule.ModuleMemorySize)
                {
                case 40222720:
                    //version 1.07

                    deathsPointer              = new DeepPointer(0x2371EA8, new int[] { 0x4, 0x530 });
                    roomsVisitedPointer        = new DeepPointer(0x2371EAC, new int[] { 0x4, 0x880 });
                    commonEnemiesKilledPointer = new DeepPointer(0x2371EA8, new int[] { 0x4, 0x60, 0x4, 0x4, 0x490 });
                    diccifultyPointer          = new DeepPointer(0x2379600, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x630 });
                    bugsDeliveredPointer       = new DeepPointer(0x2371EA8, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x7C0 });
                    shroomDeliveredPointer     = new DeepPointer(0x2371EA8, new int[] { 0x4, 0x60, 0x4, 0x4, 0x500 });
                    greenLeafPointer           = new DeepPointer(0x2371EA8, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x600 });
                    maxHealthPointer           = new DeepPointer(0x2371EA8, new int[] { 0x4, 0xA0 });
                    choirPointer       = new DeepPointer(0x2371EA8, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x6A0 });
                    bugCountPointer    = new DeepPointer(0x2371EA8, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x3C0 });
                    saveSlotPointer    = new DeepPointer(0x2371EA8, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0xFA0 });
                    shroomFoundPointer = new DeepPointer(0x2371EA8, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x480 });
                    break;

                case 39690240:
                    //version 1.05b

                    deathsPointer              = new DeepPointer(0x02304CE8, new int[] { 0x4, 0x540 });
                    roomsVisitedPointer        = new DeepPointer(0x02304CE8, new int[] { 0x4, 0x870 });
                    commonEnemiesKilledPointer = new DeepPointer(0x02304CE8, new int[] { 0x4, 0x60, 0x4, 0x4, 0x490 });
                    diccifultyPointer          = new DeepPointer(0x0230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x630 });
                    bugsDeliveredPointer       = new DeepPointer(0x230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x7C0 });
                    shroomDeliveredPointer     = new DeepPointer(0x02304CE8, new int[] { 0x4, 0x60, 0x4, 0x4, 0x500 });
                    greenLeafPointer           = new DeepPointer(0x230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x600 });
                    maxHealthPointer           = new DeepPointer(0x02304CE8, new int[] { 0x4, 0xA0 });
                    choirPointer       = new DeepPointer(0x230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x6A0 });
                    bugCountPointer    = new DeepPointer(0x230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x3C0 });
                    saveSlotPointer    = new DeepPointer(0x230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0xFA0 });
                    shroomFoundPointer = new DeepPointer(0x230C440, new int[] { 0x0, 0x4, 0x60, 0x4, 0x4, 0x480 });
                    break;
                }

                gameProc = game[0];



                return(true);
            }
            return(false);
        }
Example #28
0
        private void CheckNewGame()
        {
            DeepPointer bestTimeDP = new DeepPointer(PtrDB.DP_Awakening_BestTime);
            IntPtr      bestTimePtr;

            bestTimeDP.DerefOffsets(GameHook.game, out bestTimePtr);
            float time;

            GameHook.game.ReadValue <float>(bestTimePtr, out time);
            IsNewGame = time < 1;
        }
Example #29
0
        private static void WriteUI(DeepPointer TextDP, DeepPointer TextLengthDP, string text)
        {
            // pointers
            IntPtr titlePtr, titleLengthPtr;

            TextDP.DerefOffsets(game, out titlePtr);
            TextLengthDP.DerefOffsets(game, out titleLengthPtr);

            // set title and length + 1
            game.WriteBytes(titleLengthPtr, BitConverter.GetBytes((int)(text.Length + 1)));
            game.WriteBytes(titlePtr, StringToMemoryBytes(text));
        }
Example #30
0
        private void AddAltTabPause()
        {
            var deepClient = new DeepPointer("engine.dll", 0x1A1B04);

            deepClient.DerefOffsets(FzzyComponent.process, out var pointerClient);
            FzzyComponent.process.WriteBytes(pointerClient, new byte[] { 0x88, 0x81 });

            var deepServer = new DeepPointer("engine.dll", 0x1C8C02);

            deepServer.DerefOffsets(FzzyComponent.process, out var pointerServer);
            FzzyComponent.process.WriteBytes(pointerServer, new byte[] { 0x75 });
        }
Example #31
0
        private static dynamic GetValue(Process p, string type, DeepPointer pointer)
        {
            switch (type)
            {
            case "int":
                return(pointer.Deref <int>(p));

            case "uint":
                return(pointer.Deref <uint>(p));

            case "long":
                return(pointer.Deref <long>(p));

            case "ulong":
                return(pointer.Deref <ulong>(p));

            case "float":
                return(pointer.Deref <float>(p));

            case "double":
                return(pointer.Deref <double>(p));

            case "byte":
                return(pointer.Deref <byte>(p));

            case "sbyte":
                return(pointer.Deref <sbyte>(p));

            case "short":
                return(pointer.Deref <short>(p));

            case "ushort":
                return(pointer.Deref <ushort>(p));

            case "bool":
                return(pointer.Deref <bool>(p));

            default:
                if (type.StartsWith("string"))
                {
                    var length = int.Parse(type.Substring("string".Length));
                    return(pointer.DerefString(p, length));
                }
                else if (type.StartsWith("byte"))
                {
                    var length = int.Parse(type.Substring("byte".Length));
                    return(pointer.DerefBytes(p, length));
                }
                break;
            }

            throw new ArgumentException($"The provided type, '{type}', is not supported");
        }
        public GameState GetGameState()
        {
            try
            {
                if (GameProcess == null || GameProcess.HasExited)
                {
                    return(GameState.None);
                }
                CurrentMap.Deref(GameProcess, out int rawMapAddr);
                var cm = new DeepPointer(new IntPtr(rawMapAddr));
                cm.DerefString(GameProcess, 1024, out string rawMap);

                if (string.IsNullOrWhiteSpace(rawMap))
                {
                    return(GameState.None);
                }
                rawMap = rawMap.ToLower();

                string formattedMap = rawMap.Replace(".unr", "").Replace(".UNR", "");

                if (OldMap == "DEFAULT")
                {
                    OldMap = formattedMap;
                }

                if (formattedMap != OldMap)
                {
                    OldMap = formattedMap;

                    if (formattedMap == "book_frontend")
                    {
                        return(GameState.Reset);
                    }
                    if (formattedMap == "book_story_1")
                    {
                        return(GameState.NewGame);
                    }

                    if (Shrek2Variables.ExcludedSplitMaps.Any(p => p == formattedMap))
                    {
                        return(GameState.None);
                    }
                    return(GameState.Split);
                }

                return(GameState.None);
            }
            catch
            {
                return(GameState.None);
            }
        }
        private static dynamic GetValue(Process p, string type, DeepPointer pointer)
        {
            switch (type)
            {
                case "int":
                    return pointer.Deref<int>(p);
                case "uint":
                    return pointer.Deref<uint>(p);
                case "float":
                    return pointer.Deref<float>(p);
                case "double":
                    return pointer.Deref<double>(p);
                case "byte":
                    return pointer.Deref<byte>(p);
                case "sbyte":
                    return pointer.Deref<sbyte>(p);
                case "short":
                    return pointer.Deref<short>(p);
                case "ushort":
                    return pointer.Deref<ushort>(p);
                case "bool":
                    return pointer.Deref<bool>(p);
                default:
                    if (type.StartsWith("string"))
                    {
                        var length = int.Parse(type.Substring("string".Length));
                        return pointer.DerefString(p, length);
                    }
                    else if (type.StartsWith("byte"))
                    {
                        var length = int.Parse(type.Substring("byte".Length));
                        return pointer.DerefBytes(p, length);
                    }
                    break;
            }

            throw new ArgumentException($"The provided type, '{type}', is not supported");
        }
        public GameMemory(Doom3bfgSettings componentSettings)
        {
            _settings = componentSettings;
            splitStatesBaseGame = new bool[(int)SplitArea.hellhole + 1];
            splitStatesRoE = new bool[(int)SplitArea_RoE.hell_roe + 1];
            splitStatesLostMission = new bool[(int)SplitArea_LostMission.le_hell_post +1];
            splits_currentGame = 0;

            _isLoadingPtr = new DeepPointer(0x4B56D4);
            _levelNamePtr = new DeepPointer(0x47B38C);
            _savinggamePtr = new DeepPointer(0x4B4CA0);
            _isCutscenePtr = new DeepPointer(0xC8EB2C);

            _cyberdemonHPPtr = new DeepPointer(0x0090FF78, 0xD8);

            resetSplitStates();

            _ignorePIDs = new List<int>();
        }
 public GameMemory()
 {
     IsLoadingPtr = new DeepPointer(0x02660990, 0x378, 0x140, 0); // == 1 if loading
     _ignorePIDs = new List<int>();
 }
Example #36
0
        partial void GetVersion()
        {
            switch (gameProcess.ProcessName)
            {
                case "joequake-gl":
                    gameVersion = GameVersion.JoeQuake;
                    break;
                case "NeaQuakeGL":
                    gameVersion = GameVersion.NeaQuake;
                    break;
                default:
                    gameVersion = GameVersion.JoeQuake;
                    break;
            }

            switch (gameVersion)
            {
                case GameVersion.JoeQuake:
                    mapAddress = 0x6FD148;
                    mapTimeAddress = 0x6108F0;
                    gameStateAddress = 0x64F664;
                    qdqTotalTimeAddress = new DeepPointer(0x6FBFF8, 0x2948);
                    break;
                case GameVersion.NeaQuake:
                    mapAddress = 0x26E368;
                    mapTimeAddress = 0x2619EC;
                    gameStateAddress = 0xB6AA84;
                    qdqTotalTimeAddress = new DeepPointer(0x28085C, 0x2948);
                    break;
            }
        }
Example #37
0
        Process GetGameProcess()
        {
            Process game = Process.GetProcesses().FirstOrDefault(p => p.ProcessName == "GTA5" && !p.HasExited && !_ignorePIDs.Contains(p.Id));
            if (game == null)
                return null;

            if (game.MainModule.ModuleMemorySize == (int)ExpectedDllSizes.RGSC3722)
                _isLoadingPtr = new DeepPointer(0x2153C30);

            else if (game.MainModule.ModuleMemorySize == (int)ExpectedDllSizes.RGSC3934)
                _isLoadingPtr = new DeepPointer(0x21C94C0);

            else if (game.MainModule.ModuleMemorySize == (int)ExpectedDllSizes.Steam3934)
                _isLoadingPtr = new DeepPointer(0x21CC740);

            else
            {
                MessageBox.Show("Unexpected game version. Steam 393.4 or RGSC 393.4/372.2 is currently required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _ignorePIDs.Add(game.Id);
                return null;
            }

            return game;
        }
        partial void GetVersion()
        {
            ProcessModuleWow64Safe mainModule = gameProcess.MainModuleWow64Safe();
            if (!mainModule.ModuleName.EndsWith(".exe"))
            {
                // kind of a workaround for MainModuleWow64Safe maybe not returning
                // the correct module
                throw new ArgumentException("Process not initialised yet!");
            }

            if (mainModule.ModuleMemorySize == 6635520)
            {
                gameVersion = GameVersion.v11;
            }
            else if (mainModule.ModuleMemorySize == 7524352)
            {
                gameVersion = GameVersion.v12;
            }
            else
            {
                MessageBox.Show("Unsupported game version", "LiveSplit.StVoyEf",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                gameVersion = GameVersion.v11;
            }

            switch (gameVersion)
            {
                case GameVersion.v11:
                    gameStateAddress = 0xC52D8;
                    mapAddress = 0x1C14FD;
                    vorsothHealthAddress = new DeepPointer(0x424B4, 0x3114);
                    inMenuAddress = 0x269570;
                    break;
                case GameVersion.v12:
                    gameStateAddress = 0xB9E78;
                    mapAddress = 0x1B709D;
                    vorsothHealthAddress = new DeepPointer(0x641C28, 0x7A04);
                    inMenuAddress = 0x269570;
                    break;
            }
        }
        private void UpdatePointer(object sender, EventArgs e)
        {
            int baseAddress;
            int[] offsets;

            if (TryParseHex(txtBase.Text, out baseAddress))
            {
                if (!string.IsNullOrWhiteSpace(txtOffsets.Text))
                {
                    string[] offsetStrings = txtOffsets.Text.Split(',');
                    offsets = new int[offsetStrings.Length];
                    int j = 0;
                    foreach (string offset in offsetStrings)
                    {
                        TryParseHex(offset.Trim(), out offsets[j]);
                        j += 1;
                    }
                }
                else
                {
                    offsets = new int[0];
                }

                if (string.IsNullOrWhiteSpace(txtModule.Text))
                {
                    Pointer = new DeepPointer(baseAddress, offsets);
                }
                else
                {
                    Pointer = new DeepPointer(txtModule.Text, baseAddress, offsets);
                }
            }
            else
            {
                Pointer = null;
            }
        }
        public GameMemory(RedFactionSettings componentSettings)
        {
            _settings = componentSettings;
            splitStates = new bool[(int)SplitArea.Bomb + 1];

            _isLoadingPtr = new DeepPointer(0x13756AC); // == 1 if a loadscreen is happening
            _levelNamePtr = new DeepPointer(0x0246144, 0x0);
            _binkMoviePlaying = new DeepPointer("binkw32.dll", 0x41BD8);    //binkw32.dll+41BD8

            resetSplitStates();

            _ignorePIDs = new List<int>();
        }
 public GameMemory()
 {
     IsNotLoadingPtr = new DeepPointer("Engine.dll", 0x657AB0); // == 1 if not loading
     _ignorePIDs = new List<int>();
 }