Ejemplo n.º 1
0
        private static void OutputChildControls(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int count = reader.ReadInteger();

                for (int i = 0; i < count; i++)
                {
                    string name = (string) reader.ReadValue();
                    WriteLine("{0}{1}", indentation, name);
                    //TODO: figure out what this number means
                    Debug.Assert(reader.ReadByte() == 1);

                    while (reader.PeekChar() != 0)
                    {
                        OutputProperty(reader, indentation + "  ");
                    }

                    Debug.Assert(reader.ReadByte() == 0);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
Ejemplo n.º 2
0
        private static void OutputProperty(DelphiBinaryReader reader, string indentation)
        {
            string key = reader.ReadString();

            switch (key)
            {
                case "PopupMenu":
                case "PopupMenuX":
                case "ImageList":
                case "ImagesList":
                case "LargeImagesList":
                case "SmallImagesList":
                case "StateImagesList":
                case "_ImageList":
                    WriteLine("{0}{1}", indentation, key);
                    OutputComponent(reader.ReadComponent(false), indentation + "  ");
                    break;
                default:
                    object value = reader.ReadValue();
                    OutputProperty(key, value, indentation);
                    break;
            }
        }
Ejemplo n.º 3
0
        private static void OutputEvents(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int count = reader.ReadInteger();

                for (int i = 0; i < count; i++)
                {
                    int eventIndex = reader.ReadInteger();
                    Debug.Assert((eventIndex >= 1 && eventIndex <= 23) ||
                                 (eventIndex >= 201 && eventIndex <= 206) || eventIndex == 0x60000017 || eventIndex == 0x60000018);
                    string str = (string) reader.ReadValue();
                    WriteLine("{0}{1} ({2})", indentation, str, eventIndex);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
Ejemplo n.º 4
0
        private static void OutputDataBindings(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int count = reader.ReadInteger();

                for (int i = 0; i < count; i++)
                {
                    int propertyIndex = reader.ReadInteger();
                    Debug.Assert(
                        propertyIndex == -518 ||
                        propertyIndex == -517 ||
                        (propertyIndex >= 1 && propertyIndex <= 9) ||
                        propertyIndex == 11 ||
                        propertyIndex == 12 ||
                        propertyIndex == 14 ||
                        propertyIndex == 16 ||
                        propertyIndex == 17 ||
                        propertyIndex == 19 ||
                        propertyIndex == 21 ||
                        (propertyIndex >= 29 && propertyIndex <= 33) ||
                        propertyIndex == 36 ||
                        propertyIndex == 39 ||
                        propertyIndex == 43 ||
                        (propertyIndex >= 101 && propertyIndex <= 105) ||
                        propertyIndex == 222 ||
                        propertyIndex == 0x60020010 ||
                        propertyIndex == 0x60020012 ||
                        propertyIndex == 0x60020016 ||
                        propertyIndex == 0x60020018 ||
                        propertyIndex == 0x6002001A);
                    string str = (string) reader.ReadValue();
                    WriteLine("{0}{1} ({2})", indentation, str, propertyIndex);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
        private void ParseProperty(DelphiBinaryReader reader, IDictionary<string, object> properties)
        {
            string key = reader.ReadString();
            object value;

            switch (key)
            {
                case "PopupMenu":
                case "PopupMenuX":
                case "ImageList":
                case "ImagesList":
                case "LargeImagesList":
                case "SmallImagesList":
                case "StateImagesList":
                case "_ImageList":
                    DelphiComponent component = reader.ReadComponent(false);
                    _componentSimplifier.Simplify(component);
                    value = component;
                    break;
                default:
                    value = reader.ReadValue();
                    break;
            }

            properties.Add(key, value);
        }
        private ICollection<DelphiComponent> ParseChildControls(byte[] data)
        {
            using (DelphiBinaryReader binaryReader = new DelphiBinaryReader(new MemoryStream(data)))
            {
                int count = binaryReader.ReadInteger();
                ICollection<DelphiComponent> childControls = new List<DelphiComponent>();

                for (int i = 0; i < count; i++)
                {
                    DelphiComponent component = new DelphiComponent();
                    component.Name = (string) binaryReader.ReadValue();
                    //TODO: figure out what this number means
                    byte b = binaryReader.ReadByte();
                    Debug.Assert(b == 1);

                    while (binaryReader.PeekChar() != 0)
                    {
                        ParseProperty(binaryReader, component.Properties);
                    }

                    b = binaryReader.ReadByte();
                    Debug.Assert(b == 0);
                    childControls.Add(component);
                }

                Debug.Assert(binaryReader.BaseStream.Position == binaryReader.BaseStream.Length);
                return childControls;
            }
        }