Ejemplo n.º 1
0
                outFile.WriteUInt64(leaf.TotalLength);
            }

            if (leaf.PayloadData != null)
            {
                outFile.WriteBytes(leaf.PayloadData);
            }
            else
            {
                if (leaf.OriginalPayloadFileOffset > 0)
                {
                    outFile.WriteFromInput(inFile, leaf.OriginalPayloadFileOffset, leaf.PayloadLength);
                }
                else
                {
                    outFile.WriteFromInput(inFile, leaf.PayloadFileOffset, leaf.PayloadLength);
                }
            }
        }
    }
}
Ejemplo n.º 2
0
            else
            {
                outFile.WriteUInt32(1);
                outFile.WriteChars(container.Type.ToCharArray());
                outFile.WriteUInt64(container.TotalLength);
            }

            foreach (var obj in container.Children)
            {
                if (obj is ContainerAtom)
                {
                    SaveContainer(inFile, outFile, (ContainerAtom)obj);
                }
                else
                {
                    SaveAtom(inFile, outFile, (LeafAtom)obj);
                }
            }
        }

        private void SaveAtom(InputFile inFile, OutputFile outFile, LeafAtom leaf)
        {
            if (leaf.HeaderLength == 8)
            {
                outFile.WriteUInt32((UInt32)leaf.TotalLength);
                outFile.WriteChars(leaf.Type.ToCharArray());
            }
            else
            {
                outFile.WriteUInt32(1);
Ejemplo n.º 3
0
                }
                else
                {
                    SaveAtom(inFile, outFile, (LeafAtom)obj);
                }
            }
        }

        private void SaveContainer(InputFile inFile, OutputFile outFile, ContainerAtom container)
        {
            if (container.HeaderLength == 8)
            {
                outFile.WriteUInt32((UInt32)container.TotalLength);
                outFile.WriteChars(container.Type.ToCharArray());
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Log("[i] Saving file...");

                OutputFile outFile = new OutputFile(dlg.FileName);
                AtomWriter writer = new AtomWriter();

                btnSave.Enabled = false;
                Thread writerThread = new Thread(() =>
                {
                    try
                    {
                        writer.SaveFile(InFile, outFile, Atoms);
                        Log("[i] Done");
                    }
                    catch (Exception ex)
                    {
                        Log("");
                        Log("[E] " + ex.ToString());
                    }

                    BeginInvoke(new Action(() =>
                    {
                        InFile.Close();
                        outFile.Close();

                        btnLoad.Enabled = true;
                        btnPatch.Enabled = false;
                        btnSave.Enabled = false;
                    }));
                });

                writerThread.Start();
            }
        }