private byte[] ReadProgModuleMemory() { byte[] progModuleMemory = new byte[GameProgModule.ModuleMemorySize]; CheckHr(DataSpaces.ReadVirtualUncached( (ulong)GameProgModule.BaseAddress, progModuleMemory, (uint)progModuleMemory.Length, out uint progModuleReadMemoryBytes) ); return(progModuleMemory); }
public override int Breakpoint(IDebugBreakpoint2 breakpoint) { if (breakpoint == _pickUpWeaponBreakpoint) { CheckHr(Registers.GetIndexByName("edx", out uint edxIndex)); CheckHr(Registers.GetValue(edxIndex, out DEBUG_VALUE edxValue)); Control.OutputWide( DEBUG_OUTPUT.NORMAL, "Picking up weapon " + (Weapon)edxValue.I32 + "\r\n" ); Weapon weapon = (Weapon)edxValue.I32; PickingUpWeapon?.Invoke(ref weapon); edxValue.I32 = (uint)weapon; CheckHr(Registers.SetValue(edxIndex, ref edxValue)); return((int)DEBUG_STATUS.GO); } else if (breakpoint == _pickUpPerkBreakpoint) { CheckHr(Registers.GetIndexByName("ecx", out uint ecxIndex)); CheckHr(Registers.GetValue(ecxIndex, out DEBUG_VALUE ecxValue)); Control.OutputWide( DEBUG_OUTPUT.NORMAL, "Picking up perk " + (Perk)ecxValue.I32 + "\r\n" ); Perk perk = (Perk)ecxValue.I32; PickingUpPerk?.Invoke(ref perk); ecxValue.I32 = (uint)perk; CheckHr(Registers.SetValue(ecxIndex, ref ecxValue)); return((int)DEBUG_STATUS.GO); } else if (breakpoint == _pickUpBonusBreakpoint) { CheckHr(Registers.GetIndexByName("edx", out uint edxIndex)); CheckHr(Registers.GetValue(edxIndex, out DEBUG_VALUE edxValue)); byte[] bonusIdBytes = new byte[4]; CheckHr(DataSpaces.ReadVirtualUncached(edxValue.I64, bonusIdBytes, (uint)bonusIdBytes.Length, out uint bytesRead)); Bonus bonus = (Bonus)BitConverter.ToInt32(bonusIdBytes, 0); Control.OutputWide( DEBUG_OUTPUT.NORMAL, "Picking up bonus " + (Bonus)bonus + "\r\n" ); if (bonus != Bonus.Weapon) { PickingUpBonus?.Invoke(ref bonus); bonusIdBytes[0] = (byte)bonus; DataSpaces.WriteVirtualUncached(edxValue.I64, bonusIdBytes, (uint)bonusIdBytes.Length, out uint bytesWritten); } return((int)DEBUG_STATUS.GO); } else if (breakpoint == _spawnCreatureBreakpoint) { CheckHr(Registers.GetIndexByName("ecx", out uint ecxIndex)); CheckHr(Registers.GetValue(ecxIndex, out DEBUG_VALUE ecxValue)); Control.OutputWide( DEBUG_OUTPUT.NORMAL, "Spawning creature " + (Creature)ecxValue.I32 + "\r\n" ); Creature creature = (Creature)ecxValue.I32; SpawningCreature?.Invoke(ref creature); ecxValue.I32 = (uint)creature; CheckHr(Registers.SetValue(ecxIndex, ref ecxValue)); return((int)DEBUG_STATUS.GO); } return(base.Breakpoint(breakpoint)); }