public void Update(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            throw new ArgumentNullException("accessor");

              Debug.WriteLine($"Updating modifiers (pid={accessor.ProcessId})...");
        }
Beispiel #2
0
 public Player(ClientProcess process)
 {
     this.process = process;
       accessor = new ProcessMemoryAccessor(process.ProcessId, ProcessAccess.Read);
       inventory = new Inventory(this);
       equipment = new EquipmentSet(this);
       skillbook = new Skillbook(this);
       spellbook = new Spellbook(this);
       stats = new PlayerStats(this);
       modifiers = new PlayerModifiers(this);
       location = new MapLocation(this);
       gameClient = new ClientState(this);
 }
Beispiel #3
0
 void UpdateTitle(ProcessMemoryAccessor accessor)
 {
     if (accessor == null)
     throw new ArgumentNullException("accessor");
 }
Beispiel #4
0
        void UpdateName(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            throw new ArgumentNullException("accessor");

              string name = null;

              if (version != null && version.ContainsVariable(CharacterNameKey))
              {
            Debug.WriteLine($"Updating character name (pid={accessor.ProcessId})...");

            Stream stream = null;
            try
            {
              stream = accessor.GetStream();
              using (var reader = new BinaryReader(stream, Encoding.ASCII))
              {
            stream = null;

            var nameVariable = version.GetVariable(CharacterNameKey);
            nameVariable.TryReadString(reader, out name);
              }
            }
            finally { stream?.Dispose(); }

            Debug.WriteLine($"CharacterName = {name}");
              }

              if (!string.IsNullOrWhiteSpace(name))
            Name = name;
        }
Beispiel #5
0
        public void Update(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            throw new ArgumentNullException("accessor");

              var version = Owner.Version;

              if (version == null)
              {
            ResetDefaults();
            return;
              }

              var mapNumberVariable = version.GetVariable(MapNumberKey);
              var mapXVariable = version.GetVariable(MapXKey);
              var mapYVariable = version.GetVariable(MapYKey);
              var mapNameVariable = version.GetVariable(MapNameKey);

              int mapNumber;
              int mapX, mapY;
              string mapName;

              Debug.WriteLine($"Updating map location (pid={accessor.ProcessId})...");

              Stream stream = null;
              try
              {
            stream = accessor.GetStream();
            using (var reader = new BinaryReader(stream, Encoding.ASCII))
            {
              stream = null;

              if (mapNumberVariable != null && mapNumberVariable.TryReadInt32(reader, out mapNumber))
            MapNumber = mapNumber;
              else
            MapNumber = 0;

              if (mapXVariable != null && mapXVariable.TryReadInt32(reader, out mapX))
            X = mapX;
              else
            X = 0;

              if (mapYVariable != null && mapYVariable.TryReadInt32(reader, out mapY))
            Y = mapY;
              else
            Y = 0;

              if (mapNameVariable != null && mapNameVariable.TryReadString(reader, out mapName))
            MapName = mapName;
              else
            MapName = null;
            }
              }
              finally { stream?.Dispose(); }
              Debug.WriteLine($"MapNumber = {MapNumber}");
              Debug.WriteLine($"MapName = {MapName}");
              Debug.WriteLine($"X = {X}");
              Debug.WriteLine($"Y = {Y}");
        }
        void PatchClient(ProcessInformation process, ClientVersion version, out ClientLoadResult result)
        {
            var patchMultipleInstances = UserSettingsManager.Instance.Settings.AllowMultipleInstances;
              var patchIntroVideo = UserSettingsManager.Instance.Settings.SkipIntroVideo;
              var patchNoWalls = UserSettingsManager.Instance.Settings.NoWalls;

              // Patch Process
              ProcessMemoryAccessor accessor = null;
              Stream patchStream = null;
              BinaryReader reader = null;
              BinaryWriter writer = null;
              try
              {
            accessor = new ProcessMemoryAccessor(process.ProcessId, ProcessAccess.ReadWrite);
            patchStream = accessor.GetStream();
            reader = new BinaryReader(patchStream);
            writer = new BinaryWriter(patchStream);

            if (patchMultipleInstances && version.MultipleInstanceAddress > 0)
            {
              patchStream.Position = version.MultipleInstanceAddress;
              writer.Write((byte)0x31);        // XOR
              writer.Write((byte)0xC0);        // EAX, EAX
              writer.Write((byte)0x90);        // NOP
              writer.Write((byte)0x90);        // NOP
              writer.Write((byte)0x90);        // NOP
              writer.Write((byte)0x90);        // NOP
            }

            if (patchIntroVideo && version.IntroVideoAddress > 0)
            {
              patchStream.Position = version.IntroVideoAddress;
              writer.Write((byte)0x83);        // CMP
              writer.Write((byte)0xFA);        // EDX
              writer.Write((byte)0x00);        // 0
              writer.Write((byte)0x90);        // NOP
              writer.Write((byte)0x90);        // NOP
              writer.Write((byte)0x90);        // NOP
            }

            if (patchNoWalls && version.NoWallAddress > 0)
            {
              patchStream.Position = version.NoWallAddress;
              writer.Write((byte)0xEB);        // JMP SHORT
              writer.Write((byte)0x17);        // +0x17
              writer.Write((byte)0x90);        // NOP
            }

            result = ClientLoadResult.Success;
              }
              catch
              {
            result = ClientLoadResult.PatchingFailed;
              }
              finally
              {
            reader?.Dispose();
            writer?.Dispose();
            accessor?.Dispose();
            patchStream?.Dispose();

            // Resume and close handles.
            NativeMethods.ResumeThread(process.ThreadHandle);
            NativeMethods.CloseHandle(process.ThreadHandle);
            NativeMethods.CloseHandle(process.ProcessHandle);
              }
        }
Beispiel #7
0
        public void Update(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            throw new ArgumentNullException("accessor");

              var version = Owner.Version;

              if (version == null)
              {
            ResetDefaults();
            return;
              }

              var activePanelVariable = version.GetVariable(ActivePanelKey);
              var inventoryExpandedVariable = version.GetVariable(InventoryExpandedKey);
              var minimizedModeVariable = version.GetVariable(MinimizedModeKey);
              var dialogOpenVariable = version.GetVariable(DialogOpenKey);
              var senseOpenVariable = version.GetVariable(SenseOpenKey);
              var userChattingVariable = version.GetVariable(UserChattingKey);

              byte activePanelByte;
              bool isInventoryExpanded;
              bool isMinimizedMode;
              bool isDialogOpen;
              bool isUserChatting;

              Debug.WriteLine($"Updating client state (pid={accessor.ProcessId})...");

              Stream stream = null;
              try
              {
            stream = accessor.GetStream();
            using (var reader = new BinaryReader(stream, Encoding.ASCII))
            {
              stream = null;

              if (activePanelVariable != null && activePanelVariable.TryReadByte(reader, out activePanelByte))
            ActivePanel = (InterfacePanel)activePanelByte;
              else
            ActivePanel = InterfacePanel.Unknown;

              if (inventoryExpandedVariable != null && inventoryExpandedVariable.TryReadBoolean(reader, out isInventoryExpanded))
            IsInventoryExpanded = isInventoryExpanded;
              else
            IsInventoryExpanded = false;

              if (minimizedModeVariable != null && minimizedModeVariable.TryReadBoolean(reader, out isMinimizedMode))
            IsMinimizedMode = isMinimizedMode;
              else
            IsMinimizedMode = false;

              if (dialogOpenVariable != null && dialogOpenVariable.TryReadBoolean(reader, out isDialogOpen))
            IsDialogOpen = isDialogOpen;
              else
            IsDialogOpen = false;

              if (senseOpenVariable != null && senseOpenVariable.TryReadBoolean(reader, out isSenseOpen))
            IsSenseOpen = isSenseOpen;
              else
            IsSenseOpen = false;

              if (userChattingVariable != null && userChattingVariable.TryReadBoolean(reader, out isUserChatting))
            IsUserChatting = isUserChatting;
              else
            IsUserChatting = false;
            }
              }
              finally { stream?.Dispose(); }

              Debug.WriteLine($"ActivePanel = {ActivePanel}");
              Debug.WriteLine($"IsInventoryExpanded = {IsInventoryExpanded}");
              Debug.WriteLine($"IsMinimizedMode = {IsMinimizedMode}");
              Debug.WriteLine($"IsDialogOpen = {IsDialogOpen}");
              Debug.WriteLine($"IsSenseOpen = {IsSenseOpen}");
              Debug.WriteLine($"IsUserChatting = {IsUserChatting}");
        }
Beispiel #8
0
        public void Update(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            throw new ArgumentNullException("accessor");

              var version = Owner.Version;

              if (version == null)
              {
            ResetDefaults();
            return;
              }

              var currentHealthVariable = version.GetVariable(CurrentHealthKey);
              var maximumHealthVariable = version.GetVariable(MaximumHealthKey);
              var currentManaVariable = version.GetVariable(CurrentManaKey);
              var maximumManaVariable = version.GetVariable(MaximumManaKey);
              var levelVariable = version.GetVariable(LevelKey);
              var abilityLevelVariable = version.GetVariable(AbilityLevelKey);

              long currentHealth, maximumHealth;
              long currentMana, maximumMana;
              long level, abilityLevel;

              Debug.WriteLine($"Updating stats (pid={accessor.ProcessId})...");

              Stream stream = null;
              try
              {
            stream = accessor.GetStream();
            using (var reader = new BinaryReader(stream, Encoding.ASCII))
            {
              stream = null;

              // Current Health
              if (currentHealthVariable != null && currentHealthVariable.TryReadIntegerString(reader, out currentHealth))
            CurrentHealth = (int)currentHealth;
              else
            CurrentHealth = 0;

              // Max Health
              if (maximumHealthVariable != null && maximumHealthVariable.TryReadIntegerString(reader, out maximumHealth))
            MaximumHealth = (int)maximumHealth;
              else
            MaximumHealth = 0;

              // Current Mana
              if (currentManaVariable != null && currentManaVariable.TryReadIntegerString(reader, out currentMana))
            CurrentMana = (int)currentMana;
              else
            CurrentMana = 0;

              // Max Mana
              if (maximumManaVariable != null && maximumManaVariable.TryReadIntegerString(reader, out maximumMana))
            MaximumMana = (int)maximumMana;
              else
            MaximumMana = 0;

              // Level
              if (levelVariable != null && levelVariable.TryReadIntegerString(reader, out level))
            Level = (int)level;
              else
            Level = 0;

              // Ability Level
              if (abilityLevelVariable != null && abilityLevelVariable.TryReadIntegerString(reader, out abilityLevel))
            AbilityLevel = (int)abilityLevel;
              else
            AbilityLevel = 0;
            }
              }
              finally { stream?.Dispose(); }

              Debug.WriteLine($"CurrentHealth = {CurrentHealth}");
              Debug.WriteLine($"MaximumHealth = {MaximumHealth}");
              Debug.WriteLine($"CurrentMana = {CurrentMana}");
              Debug.WriteLine($"MaximumMana = {MaximumMana}");
              Debug.WriteLine($"Level = { Level}");
              Debug.WriteLine($"AbilityLevel = {AbilityLevel}");
        }