private async Task Watch() { await Task.Delay(500); var offsets = App.Services.Get <OffsetsService>(); var type = typeof(MemoryBase); var flags = BindingFlags.Instance | BindingFlags.NonPublic; var finfo = type.GetField("address", flags); while (this.IsAlive) { await Task.Delay(32); // Housing is on and item is selected if (this.housingOnMem.Value) { var baseAddr = new BaseOffset(offsets.Get("ActiveItem")); var position = baseAddr.GetMemory(new Offset <Vector>(offsets.Get("ActiveItemPosition"))); var address = ((UIntPtr)finfo.GetValue(position)).ToUInt64(); if (address != 0 && address != this.lastItemAddress) { SelectionChanged?.Invoke(position); } this.lastItemAddress = address; } } }
public UIntPtr GetAbsoluteAddress(uint n64Address, int size) { n64Address &= ~0x80000000U; UIntPtr absoluteAddress = (UIntPtr)(BaseOffset.ToUInt64() + n64Address); return(EndiannessUtilities.SwapAddressEndianness(absoluteAddress, size)); }
public MappedBaseOffset(IProcess process, BaseOffset offset) { if (offset.Offsets == null || offset.Offsets.Length <= 0) { throw new Exception("Invalid base offset"); } this.Offsets = new[] { process.GetBaseAddress() + offset.Offsets[0] }; }
public MappedBaseOffset(Process process, BaseOffset offset) { if (offset.Offsets == null || offset.Offsets.Length <= 0) { throw new Exception("Invalid base offset"); } this.Offsets = new[] { ((ulong)process.MainModule.BaseAddress.ToInt64()) + offset.Offsets[0] }; }
public bool WriteAbsolute(UIntPtr address, byte[] buffer, EndiannessType endianness) { int numOfBytes = 0; // Safety bounds check if (address.ToUInt64() < BaseOffset.ToUInt64() || address.ToUInt64() + (uint)buffer.Length >= BaseOffset.ToUInt64() + _ramSize) { return(false); } if (Endianness == endianness) { return(WriteFunc(address, buffer)); } else { bool success = true; IEnumerable <byte> bytes = buffer; int numberToWrite = Math.Min(EndiannessUtilities.NumberOfBytesToAlignment(address), buffer.Length); if (numberToWrite > 0) { byte[] toWrite = bytes.Take(numberToWrite).Reverse().ToArray(); success &= WriteFunc(EndiannessUtilities.AlignedAddressFloor(address), toWrite); bytes = bytes.Skip(toWrite.Length); address += toWrite.Length; } numberToWrite = bytes.Count(); if (bytes.Count() >= 4) { byte[] toWrite = EndiannessUtilities.SwapByteEndianness(bytes.Take(bytes.Count() & ~0x03).ToArray()); success &= WriteFunc(address, toWrite); bytes = bytes.Skip(toWrite.Length); address += toWrite.Length; } numberToWrite = bytes.Count(); if (numberToWrite > 0) { byte[] toWrite = bytes.Reverse().ToArray(); address = EndiannessUtilities.SwapAddressEndianness(address, toWrite.Length); success &= WriteFunc(address, toWrite); } return(success); } }
private void checkEncryption(FileStream fs, bool useIncomingKeys = false, Dictionary <string, byte> incomingLcgEncryptionKeys = null) { if (ParseFile.CompareSegment(MagicBytes, 0, SIGNATURE_BYTES) || useIncomingKeys && incomingLcgEncryptionKeys == null ) { IsEncrypted = false; UtfReader = new CriUtfReader(); } else { IsEncrypted = true; if (useIncomingKeys) // use incoming keys if available { if (incomingLcgEncryptionKeys != null) { LcgEncryptionKeys = incomingLcgEncryptionKeys; } } else if (LcgEncryptionKeys == null) // use keys found earlier, assume same keys for entire file { LcgEncryptionKeys = GetKeysForEncryptedUtfTable(MagicBytes); } if (LcgEncryptionKeys.Count != 2) { throw new FormatException(string.Format("Unable to decrypt UTF table at offset: 0x{0}", BaseOffset.ToString("X8"))); } else { UtfReader = new CriUtfReader(LcgEncryptionKeys[LCG_SEED_KEY], LcgEncryptionKeys[LCG_INCREMENT_KEY], IsEncrypted); } MagicBytes = UtfReader.GetBytes(fs, BaseOffset, 4, 0); } }
public bool WriteAbsolute(UIntPtr address, byte[] buffer, EndiannessType endianness) { // Safety bounds check if (address.ToUInt64() < BaseOffset.ToUInt64() || address.ToUInt64() + (uint)buffer.Length >= BaseOffset.ToUInt64() + Config.RamSize) { return(false); } if (Endianness == endianness) { return(WriteFunc(address, buffer)); } else { bool success = true; byte[] toWrite = EndiannessUtilities.SwapByteEndianness(buffer); // Between alignment writes if (buffer.Length < 4) { address = EndiannessUtilities.SwapAddressEndianness(address, toWrite.Length); success &= WriteFunc(address, toWrite); } else if (buffer.Length % 4 == 0) // Full alignment writes { success &= WriteFunc(address, toWrite); } else { throw new Exception("Misaligned data"); } return(success); } }
public uint GetRelativeAddress(UIntPtr absoluteAddress, int size) { uint n64address = 0x80000000 | (uint)(absoluteAddress.ToUInt64() - BaseOffset.ToUInt64()); return(EndiannessUtilities.SwapAddressEndianness(n64address, size)); }
public void OffsetsHierarchyOnSelectedItemChanged(BaseOffset newSelectedItem) { SelectedOffset = newSelectedItem; RaisePropertyChanged(nameof(SelectedOffset)); }