// received at start of video session //struct vsheader //{ // int sizeof // int frame_width // int frame_height // short unk1 // short bpp // int unk2 // int frame_size // int unk3 // int unk4 // int unk5 // int block_size //} /// <summary> /// Begins a new video stream. /// </summary> public void Begin() { try { End(); Xbox.SendCommand("VSSnap first={0} last={1} flags=0x2000000 marker=0", (int)Size | (int)Interval | (int)Quality, timeBetweenFrames); byte[] header = Xbox.ReceiveBinaryData(40); uint size = BitConverter.ToUInt32(header, 0); Width = BitConverter.ToUInt32(header, 4); Height = BitConverter.ToUInt32(header, 8); int Format = BitConverter.ToUInt16(header, 12); // 1 = X8R8G8B8 ??? BitsPerPixel = BitConverter.ToUInt16(header, 14); uint unk2 = BitConverter.ToUInt32(header, 16); FrameSize = BitConverter.ToUInt32(header, 20); uint unk3 = BitConverter.ToUInt32(header, 24); uint unk4 = BitConverter.ToUInt32(header, 28); uint unk5 = BitConverter.ToUInt32(header, 32); uint blockSize = BitConverter.ToUInt32(header, 36); System.Threading.Thread.Sleep(100); // wait for it to fully activate isActive = true; } catch (Exception /*ex*/) { End(); } }
public void Read(uint address, int length, byte[] buffer, int offset, ref int read) { // only check base address - would add too much overhead to check range // plus, it's much more likely that the entire range will be valid if the base address is if (safeMode & !Xbox.IsValidAddress(address)) { throw new Exception("Safe Mode detected invalid base address"); } int iterations = (int)length / bufferSize; int remainder = (int)length % bufferSize; read = 0; StatusResponse response; for (int i = 0; i < iterations; i++) { response = Xbox.SendCommand("getmem2 addr=0x{0} length={1}", Convert.ToString(address + read, 16).PadLeft(8, '0'), bufferSize); Xbox.Wait(bufferSize); Xbox.Connection.Client.Receive(buffer, (int)(offset + read), bufferSize, SocketFlags.None); read += bufferSize; } if (remainder > 0) { response = Xbox.SendCommand("getmem2 addr=0x{0} length={1}", Convert.ToString(address + read, 16).PadLeft(8, '0'), remainder); Xbox.Wait(remainder); Xbox.Connection.Client.Receive(buffer, (int)(offset + read), remainder, SocketFlags.None); read += remainder; } }
bool IsPresent() { Xbox.SendCommand("getmem addr=0x{0} length=4", Convert.ToString(kBaseAddress, 16)); string yelo = Xbox.ReceiveSocketLine().Replace("\r\n", ""); Xbox.ReceiveSocketLine(); return(yelo == "59656C6F"); }
public void Read(string name, int offset, byte[] buffer, int length, ref int read) { int iterations = length / bufferSize; int remainder = length % bufferSize; int index = 0; StatusResponse Response; for (int i = 0; i < iterations; i++) { Response = Xbox.SendCommand("getfile name=\"{0}\" offset={1} size={2}", name, position + offset + index, bufferSize); if (Response.Type == ResponseType.BinaryResponse) { Xbox.Wait(4); byte[] temp = new byte[4]; Xbox.Connection.Client.Receive(temp, 4, SocketFlags.None); int bytesRead = BitConverter.ToInt32(temp, 0); if (bytesRead > 0) { Xbox.Wait((int)bytesRead); Xbox.Connection.Client.Receive(buffer, index, bufferSize, SocketFlags.None); read += bytesRead; index += bufferSize; position += (uint)read; } else { throw new IOException("File Read Failed"); } } else { throw new IOException("File Read Failed"); } } if (remainder > 0) { Response = Xbox.SendCommand("getfile name=\"{0}\" offset={1} size={2}", name, position + offset + index, remainder); if (Response.Type == ResponseType.BinaryResponse) { Xbox.Wait(4); byte[] temp = new byte[4]; Xbox.Connection.Client.Receive(temp, 4, SocketFlags.None); int bytesRead = BitConverter.ToInt32(temp, 0); if (bytesRead > 0) { Xbox.Wait((int)bytesRead); Xbox.Connection.Client.Receive(buffer, index, remainder, SocketFlags.None); read += bytesRead; position += (uint)read; } else { throw new IOException("File Read Failed"); } } else { throw new IOException("File Read Failed"); } } }