Esempio n. 1
0
        private static void OutputControlData(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                string prefix = Encoding.Default.GetString(reader.ReadBytes(4));

                if (prefix == "\x10\a\0\0")
                {
                    //TODO: figure out CRViewer.ControlData
                    return;
                }
                else if (prefix == "\u201C\xB2\0\0")
                {
                    //TODO: figure out DirDialog.ControlData
                    return;
                }
                else if (prefix == "!C4\x12")
                {
                    //TODO: figure out CommonDialog.ControlData
                    return;
                }
                else if (prefix == "\xFF\xFE<\0")
                {
                    //TODO: figure out ChartSpace2.ControlData
                    return;
                }
                else if (prefix == "\x17\0\x02\0")
                {
                    //TODO: figure out SigPlus.ControlData
                    return;
                }
                else if (prefix != "TPF0")
                {
                    throw new DelphiException("Invalid component prefix: " + prefix);
                }

                OutputComponent(reader, indentation);
                Debug.Assert(stream.Position == stream.Length);
            }
        }
Esempio n. 2
0
        private static void OutputLicense(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int size = reader.ReadInteger();

                if (size > 0)
                {
                    //TODO: figure out what this number means
                    Debug.Assert(reader.ReadByte() == 6);
                    Debug.Assert(reader.ReadByte() == size);
                    //TODO: figure out what this data means
                    byte[] licenseData = reader.ReadBytes(size);
                    WriteLine("{0}{1}", indentation, Encoding.Unicode.GetString(licenseData));
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
Esempio n. 3
0
        private static void OutputPictureData(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                string type = reader.ReadString();

                if (type == "TBitmap")
                {
                    byte[] imageData = reader.ReadBinary();

                    if (imageData.Length > 0)
                    {
                        using (Stream imageStream = new MemoryStream(imageData))
                        {
                            Image image = Image.FromStream(imageStream);
                            WriteLine("{0}{1}", indentation, image.Size);
                        }
                    }
                }
                else if (type == "TIcon")
                {
                    byte[] imageData = reader.ReadBytes(data.Length - 6);

                    using (Stream imageStream = new MemoryStream(imageData))
                    {
                        Icon image = new Icon(imageStream);
                        WriteLine("{0}{1}", indentation, image.Size);
                    }
                }
                else if (type == "TMetafile")
                {
                    int len = reader.ReadInt32();
                    byte[] imageData = reader.ReadBytes(len - 4);

                    using (Stream imageStream = new MemoryStream(imageData))
                    {
                        Image image = Image.FromStream(imageStream);
                        WriteLine("{0}{1}", indentation, image.Size);
                    }
                }
                else
                {
                    Debug.Assert(false);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
        private DelphiComponent ParseControlData(byte[] data)
        {
            using (DelphiBinaryReader binaryReader = new DelphiBinaryReader(data))
            {
                string prefix = Encoding.GetEncoding("iso-8859-1").GetString(binaryReader.ReadBytes(4));

                if (prefix != "TPF0")
                {
                    throw new DelphiException("Invalid component prefix: " + prefix);
                }

                DelphiComponent controlData = ParseComponent(binaryReader);
                Debug.Assert(binaryReader.BaseStream.Position == binaryReader.BaseStream.Length);
                return controlData;
            }
        }