If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
a tip about how to extract .SWFfile from PowerPoint file
Hi, I saw an artical about how to extract .swf from PPT files and think it's quite useful, hope it helps.
--------------------------------------------- We had a Power Point Presentation file given us a few days ago with an embedded flash file which we needed to extract to use on the website. We couldn't find any way to do this. We could drag and drop the swf onto another presentation, we could even drag the object onto the desktop. This created a scrap file which was rather annoying. However, this led me to the discovery of the NeverShowExt registry key. I managed to rename the scrap to a have a .swf extension, but still no cookie. So I started digging around the scrap to see if I could find the swf object inside and after reading an introduction to SWF I found what I was looking for. Now I just wanted to extract this binary data from the scrap file, and I wanted to do it the hard way! So I wrote a small amount of code to look through a file and extract the goodies. The main part of the code was to take a byte array and copy that into my SWF struct - using the System.Runtime.InteropServices.Marshal class. After a bit of messing around the code runs like a dream. The final executable takes 2 parameters the first is the file containing the SWF and the second is the file to write the SWF. using System; using System.IO; using System.Runtime.InteropServices; namespace FlashExtractor { /// summary /// Summary description for Class1. /// /summary class Class1 { /// summary /// The main entry point for the application. /// /summary [STAThread] static void Main(string[] args) { //assume param 1 is the location of the shockwave file byte[] file = new byte[Marshal.SizeOf(typeof(swf))]; FileStream fs = File.Open(args[0], FileMode.Open, FileAccess.Read,FileShare.Read); int i=0; //go through the file byte by byte //could I have seeked this? while (ifs.Length-8) { //set the position in the file fs.Position = i; //read off 8 bytes worth of data to put into the swf struct fs.Read(file,0, 8); IntPtr ptr = Marshal.AllocHGlobal(file.Length); Marshal.Copy(file, 0x0, ptr, file.Length); swf s = (swf) Marshal.PtrToStructure(ptr, typeof(swf)); // if the struct header is FWS then we may have a flash file if (s.header1==0x46 && s.header2==0x57 && s.header3==0x53) { //we have the identity of a flash file Console.WriteLine("Found the header of a flash file"); Console.WriteLine("Version: {0}", s.version); Console.WriteLine("Size: {0}", s.size); //if the size of the fws is length of the file if (s.size + i=fs.Length) { Console.WriteLine("Attempting to write the file to {0}", args[1]); FileStream fw = File.OpenWrite(args[1]); Console.WriteLine("Allocation byte array of {0} length", s.size); byte[] b=new byte[s.size]; Console.WriteLine("Reseting the file back to position: {0}", i); fs.Position = i; Console.WriteLine("Reading from {0} to {1}", i, s.size); fs.Read(b,0,(int)s.size); Console.WriteLine("Writing byte array back to disk"); fw.Write(b, 0, b.Length); fw.Close(); break; } else { Console.WriteLine("The file is not of the correct size file: {0}, {1}", s.size, fs.Length); } } i++; } fs.Close(); } } [StructLayout (LayoutKind.Sequential, Pack = 0x1)] struct swf { public byte header1; public byte header2; public byte header3; public byte version; public UInt32 size; } } In theory this could be used to extract many forms of embedded binary data. --------------------------------------- http://www.sameshow.com A practical yet easy-to-use software to convert PowerPoint to Flash for publishing on Web or emailing to others |
#2
|
|||
|
|||
a tip about how to extract .SWFfile from PowerPoint file
This is a very nice tip. Here's the link to the article you saw.
http://www.hairy-spider.com/CommentV...5ee7b1121.aspx It's generally good form to add links to information that you didn't actually write. -- Echo [MS PPT MVP] http://www.echosvoice.com "SusanZheng" wrote in message . .. Hi, I saw an artical about how to extract .swf from PPT files and think it's quite useful, hope it helps. --------------------------------------------- We had a Power Point Presentation file given us a few days ago with an embedded flash file which we needed to extract to use on the website. We couldn't find any way to do this. We could drag and drop the swf onto another presentation, we could even drag the object onto the desktop. This created a scrap file which was rather annoying. However, this led me to the discovery of the NeverShowExt registry key. I managed to rename the scrap to a have a .swf extension, but still no cookie. So I started digging around the scrap to see if I could find the swf object inside and after reading an introduction to SWF I found what I was looking for. Now I just wanted to extract this binary data from the scrap file, and I wanted to do it the hard way! So I wrote a small amount of code to look through a file and extract the goodies. The main part of the code was to take a byte array and copy that into my SWF struct - using the System.Runtime.InteropServices.Marshal class. After a bit of messing around the code runs like a dream. The final executable takes 2 parameters the first is the file containing the SWF and the second is the file to write the SWF. using System; using System.IO; using System.Runtime.InteropServices; namespace FlashExtractor { /// summary /// Summary description for Class1. /// /summary class Class1 { /// summary /// The main entry point for the application. /// /summary [STAThread] static void Main(string[] args) { //assume param 1 is the location of the shockwave file byte[] file = new byte[Marshal.SizeOf(typeof(swf))]; FileStream fs = File.Open(args[0], FileMode.Open, FileAccess.Read,FileShare.Read); int i=0; //go through the file byte by byte //could I have seeked this? while (ifs.Length-8) { //set the position in the file fs.Position = i; //read off 8 bytes worth of data to put into the swf struct fs.Read(file,0, 8); IntPtr ptr = Marshal.AllocHGlobal(file.Length); Marshal.Copy(file, 0x0, ptr, file.Length); swf s = (swf) Marshal.PtrToStructure(ptr, typeof(swf)); // if the struct header is FWS then we may have a flash file if (s.header1==0x46 && s.header2==0x57 && s.header3==0x53) { //we have the identity of a flash file Console.WriteLine("Found the header of a flash file"); Console.WriteLine("Version: {0}", s.version); Console.WriteLine("Size: {0}", s.size); //if the size of the fws is length of the file if (s.size + i=fs.Length) { Console.WriteLine("Attempting to write the file to {0}", args[1]); FileStream fw = File.OpenWrite(args[1]); Console.WriteLine("Allocation byte array of {0} length", s.size); byte[] b=new byte[s.size]; Console.WriteLine("Reseting the file back to position: {0}", i); fs.Position = i; Console.WriteLine("Reading from {0} to {1}", i, s.size); fs.Read(b,0,(int)s.size); Console.WriteLine("Writing byte array back to disk"); fw.Write(b, 0, b.Length); fw.Close(); break; } else { Console.WriteLine("The file is not of the correct size file: {0}, {1}", s.size, fs.Length); } } i++; } fs.Close(); } } [StructLayout (LayoutKind.Sequential, Pack = 0x1)] struct swf { public byte header1; public byte header2; public byte header3; public byte version; public UInt32 size; } } In theory this could be used to extract many forms of embedded binary data. --------------------------------------- http://www.sameshow.com A practical yet easy-to-use software to convert PowerPoint to Flash for publishing on Web or emailing to others -- SusanZheng |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to embed .mid file into a .PPS file | Deneese | Powerpoint | 11 | October 13th, 2005 08:07 PM |
why dosnt microsoft have a installer for powerpoint...????? | Matt | Powerpoint | 2 | June 30th, 2005 02:35 AM |
Is Powerpoint still a single instance app? | Howard Kaikow | Powerpoint | 99 | June 16th, 2005 04:09 PM |
shortcuts ctrl x and ctrl c cuases powerpoint to shut down | Jenny Tollet | Powerpoint | 16 | June 25th, 2004 06:06 AM |
Unsafe Attachments | Ron | Installation & Setup | 2 | June 9th, 2004 01:55 AM |