Пример #1
0
        private void ProcessTags(ByteBuffer tagBuffer)
        {
            while (true)
            {
                if (tagBuffer.Data.Length < 0x08)
                {
                    // Not enough data...
                    return;
                }

                string           tagMagic  = Encoding.ASCII.GetString(tagBuffer.Data, 0x00, 0x04);
                IJHITagProcessor processor = tagDispatch[tagMagic];

                int tagSize = JHI.SwapBytes(BitConverter.ToInt32(tagBuffer.Data, 0x04));
                if (tagBuffer.Data.Length < 0x08 + tagSize)
                {
                    // Not enough data...
                    return;
                }

                // Tag is done!
                JHITag tag = new JHITag();
                tag.Magic = tagMagic;
                tag.Data  = tagBuffer.Data.AsSpan(0x08, tagSize).ToArray();
                tagBuffer.DoneReading(0x08 + tagSize);

                processor.ProcessTag(tag);
            }
        }
Пример #2
0
 public void WriteToDolphin(JHITag tag)
 {
     byte[] data       = new byte[0x08 + tag.Data.Length];
     byte[] magicBytes = Encoding.ASCII.GetBytes(tag.Magic);
     Array.Copy(magicBytes, 0x00, data, 0x00, 0x04);
     byte[] lengthBytes = BitConverter.GetBytes(JHI.SwapBytes(tag.Data.Length));
     Array.Copy(lengthBytes, 0x00, data, 0x04, 0x04);
     Array.Copy(tag.Data, 0x00, data, 0x08, tag.Data.Length);
     WriteToDolphin(data);
 }
Пример #3
0
        public void ProcessTag(JHITag tag)
        {
            var            stream      = new MemoryInputStream(tag.Data);
            JORMessageType messageType = (JORMessageType)stream.ReadS32();

            // Debug.WriteLine("<- ORef {1}  {0}", tag.Dump(), messageType);

            if (messageType == JORMessageType.Reset)
            {
                this.Root.Reset();
                SendGetRootObjectRef();
            }
            else if (messageType == JORMessageType.InvalidNode)
            {
                Assert(stream.ReadU32() == 0x07u);
                JORNode node = ReadNodeID(stream);
                // Debug.WriteLine("<- InvalidNode {0}", node);
                if (node != null)
                {
                    node.Invalidate();
                }
                Assert(stream.ReadU32() == 0x03u);
            }
            else if (messageType == JORMessageType.GetRootObjectRef)
            {
                // Reply from GetRootObjectRef request
                JORNode node = ReadGenNodeSub(stream, false, this.Root.TreeRoot);
                SendGenObjectInfo(node);
            }
            else if (messageType == JORMessageType.GenObjectInfo)
            {
                // Reply from GenObjectInfo request
                ProcessObjectInfo(stream);
            }
            else if (messageType == JORMessageType.StartNode)
            {
                uint mode = stream.ReadU32();
                // startNode = 0, genNode = 3
                Assert(mode == 0u || mode == 3u || mode == 11u);

                if (mode == 0u || mode == 3u)
                {
                    uint    unk1       = stream.ReadU32();
                    JORNode parentNode = ReadNodeID(stream);
                    JORNode node       = ReadGenNodeSub(stream, true);
                    // Debug.WriteLine("<- StartNode {0} Parent = 0x{1:X8}", node?.Name, parentNode);
                }
                else if (mode == 11u)
                {
                    JORNode node = ReadNodeID(stream);
                }
            }
            else if (messageType == JORMessageType.StartUpdateNode)
            {
                JORNode node = ReadNodeID(stream);
                if (node == null)
                {
                    return;
                }

                ProcessUpdateNode(stream, node);
            }
            else if (messageType == JORMessageType.OpenMessageBox)
            {
                uint   retPtr = stream.ReadU32();
                uint   style  = stream.ReadU32();
                string msg    = stream.ReadSJIS();
                string title  = stream.ReadSJIS();
                MessageBox.Show(msg, title);
                SendResultU32(retPtr);
            }
            else if (messageType == JORMessageType.ShellExecute)
            {
                uint   retPtr = stream.ReadU32();
                string str0   = stream.ReadSJIS();
                string str1   = stream.ReadSJIS();
                string str2   = stream.ReadSJIS();
                string str3   = stream.ReadSJIS();
                int    unk4   = stream.ReadS32();
                // not actually gonna ShellExecute lol
                Debug.WriteLine("<- ShellExecute {0} {1} {2} {3} {4}", str0, str1, str2, str3, unk4);
                SendResultU32(retPtr);
            }
            else
            {
                Debug.WriteLine("<- JOR UNKNOWN!!!");
            }
        }