public override int Read(byte[] buffer, int offset, int count) { if (!_xbdm.Connect()) { return(0); } bool alreadyStopped = true; if (count > 20) { _xbdm._xboxDebugTarget.Stop(out alreadyStopped); } uint bytesRead; if (offset == 0) { _xbdm._xboxDebugTarget.GetMemory((uint)Position, (uint)count, buffer, out bytesRead); } else { // Offset isn't 0, so read into a temp buffer and then copy it into the output var tempBuffer = new byte[count]; _xbdm._xboxDebugTarget.GetMemory((uint)Position, (uint)count, tempBuffer, out bytesRead); Buffer.BlockCopy(tempBuffer, 0, buffer, offset, count); } Position += bytesRead; if (!alreadyStopped) { _xbdm._xboxDebugTarget.Go(out alreadyStopped); } return((int)bytesRead); }
/// <summary> /// Obtains a stream which can be used to read and write a cache file's meta in realtime. /// The stream will be set up such that offsets in the stream correspond to meta pointers in the cache file. /// </summary> /// <param name="cacheFile">The cache file to get a stream for.</param> /// <returns>The stream if it was opened successfully, or null otherwise.</returns> public IStream GetMetaStream(ICacheFile cacheFile) { // Okay, so technically we should be checking to see if the cache file is actually loaded into memory first // But that's kinda hard to do... return(_xbdm.Connect() ? new EndianStream(_xbdm.MemoryStream, Endian.BigEndian) : null); }