Exemplo n.º 1
0
        private void ChatHandleCreateChannel(CreateChannel chatPayload, PayloadWriter writer)
        {
            UnknownData data = ReadUnknownData(chatPayload.Data);

            Program.LogDebug($" --- Chat Create Channel Data ---");
            data.Serialize(Logger);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        protected override Task DeserializeAsync(Stream stream)
        {
            lock (_lockObject)
            {
                _parsedController = null;
                UnknownData.Clear();
            }

            var regionStream = stream as RegionStream;

            using (var reader = new BinaryReader(stream, FileEncoding.Default, true))
            {
                // Read parent id.
                ParentId = reader.ReadUInt64();

                ulong alwaysZero = reader.ReadUInt64();
                Debug.Assert(alwaysZero == 0, "Expected 0.");

                // Cache position.
                _relativePosition = stream.Position;
                _absolutePosition = regionStream?.BaseStream.Position ?? _relativePosition;

                // Read the raw unparsed controller data (we defer deserializing until property access).
                _unparsedControllerData = reader.ReadBytes((int)(stream.Length - _relativePosition));
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
 private void ProcessData(byte data)
 {
     if (_state == DebuggerState.NotConnected)
     {
         DettectDebugRequest(data);
         if (_state != DebuggerState.NotConnected)
         {
             Trace.WriteLine(
                 $"Debugger Attached Version = {DebugVersion}, Signature = 0x{DeviceSignature:X8}, Caps = {Caps}");
             InDebug = true;
             Task.Run(() => { DebuggerAttached?.Invoke(); });
         }
     }
     else
     {
         if (_currentCommand != null)
         {
             _currentCommandBuffer[_currentCommandReceiveIdx++] = data;
             if (_currentCommandReceiveIdx != _currentCommand.Command.ResponseSize)
             {
                 return;
             }
             Trace.WriteLine("Debugger Server - DONE Command " + _currentCommand.Command);
             _currentCommand.TCS.SetResult(_currentCommandBuffer);
             _currentCommand = null;
         }
         else
         {
             //Trace.WriteLine($"Debugger Server - Unknown Data 0x{data:X2} - `{Convert.ToChar(data)}`");
             UnknownData?.Invoke(data);
         }
     }
 }
Exemplo n.º 4
0
        private UnknownData ReadUnknownData(byte[] data)
        {
            MemoryStream stream = new MemoryStream(data);
            BinaryReader reader = new BinaryReader(stream);

            Serializer dataReader = new PayloadReader(reader);

            UnknownData unknownData = new UnknownData();

            unknownData.Serialize(dataReader);

            reader.Close();
            stream.Close();

            return(unknownData);
        }
Exemplo n.º 5
0
        private void DettectDebugRequest(byte data)
        {
            if (_state != DebuggerState.NotConnected)
            {
                return;
            }

            _debugPreambleBuffer[_debugPreambleIdx] = data;

            if (_debugPreambleData[_debugPreambleIdx].Action == DebugDetectAction.Skip)
            {
                _debugPreambleIdx++;
                return;
            }
            if (_debugPreambleData[_debugPreambleIdx].Value != data)
            {
                // If we have data and we could not match the preamble
                //  Dump the data (basically notify anyone else interested in the data)
                for (var i = 0; i <= _debugPreambleIdx; ++i)
                {
                    UnknownData?.Invoke(_debugPreambleBuffer[i]);
                }
                _debugPreambleIdx = 0;
                return;
            }

            _debugPreambleIdx++;
            if (_debugPreambleIdx != _debugPreambleData.Count)
            {
                return;
            }

            _state          = DebuggerState.Connected;
            DebugVersion    = _debugPreambleBuffer[5];
            DeviceSignature = (uint)(
                (_debugPreambleBuffer[6] << 16) +
                (_debugPreambleBuffer[7] << 8) +
                _debugPreambleBuffer[8]
                );
            Caps = (DebuggerCapabilities)(
                (_debugPreambleBuffer[10] << 8) +
                _debugPreambleBuffer[9]
                );
            _debugPreambleIdx = 0;
        }
Exemplo n.º 6
0
        public void NewProject()
        {
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                RomProject.Instance.Reset();

                UnknownData data = new UnknownData(0, File.ReadAllBytes(openFileDialog.FileName));
                RomFile     file = new RomFile(Path.GetFileNameWithoutExtension(openFileDialog.FileName),
                                               RomProject.Instance.Files.Count + 1, data);
                RomProject.Instance.AddRomFile(file);

                statusBarFile.Text = "New Project";

                this.Enabled = false;

                MarioKart64Reader.ReadingFinished += ReadingFinished;

                MarioKart64Reader.ReadRom();

                UpdateSelectedModule();
            }
        }