從復合文件中提取Flash遊戲

2021-08-22 12:48:13 字數 1334 閱讀 6261

校友juhong發過來乙個很有意思的flash遊戲,美中不足的是這個flash是內嵌於乙個excel文件中的。於是便加以分析並將其提取出來,以下為簡要過程記錄。

首先,用visual studio自帶的工具docfile viewer將這個xls文件開啟,檢視其復合文件結構。

其中流ctls就是我們要找的swf檔案流,那麼檢視其二進位制資料。

在偏移量0x18處發現swf標誌,並根據網上查得的swf檔案頭定義以下結構:

typedef

struct_tagswfhdrswfhdr;

偏移量、流大小的資訊至此都已獲得,可以做最後的編碼工作了,如下。

istorage*pstgroot=null;

hresulthr=stgopenstorage(l"c:\\1.xls",null,

stgm_read|stgm_share_deny_write,0,0,&pstgroot);

istream*pswf=null;

hr=pstgroot->openstream(l"ctls",null,stgm_read|stgm_share_exclusive,

0,&pswf);

large_integerpos;

pos.highpart=0;

pos.lowpart=0x18;

pswf->seek(pos,stream_seek_set,null);

swfhdrhdr;

pswf->read(&hdr,sizeof(hdr),null);

lpbytebuf=newbyte[hdr.dwfilesize];

rtlcopymemory(buf,&hdr,sizeof(swfhdr));

pswf->read(buf+sizeof(swfhdr),hdr.dwfilesize-sizeof(swfhdr),null);

handlehfile=createfile(_t("c:\\1.swf"),generic_write,0,null,

create_always,file_attribute_normal,null);

dworddwwritten;

writefile(hfile,buf,hdr.dwfilesize,&dwwritten,null);

closehandle(hfile);

deletebuf;

----------傳說中的分隔線----------

以下給出本篇blog中的1.xls和1.swf供大家實驗或娛樂,有效期一周。

ps:本來想就此編寫乙個通用的提取工具,但貌似網上已經有了,所以作罷。

從檔案中提取數字

程式的功能是從指定的檔案中提取所有的整數,並把它們依次存入到乙個字串中 void iostest char a 50 char b 50 istrstream sin a ostrstream sout b,sizeof b ifstream file1 w1.dat ios in ios nocr...

從文字中提取特定資訊

嘗試了兩種方法,正規表示式提取效果更佳 usr bin env python coding utf 8 方法1 採用位置引數來提取,效果不佳 file data with open 待處理文字.txt encoding utf 8 as f data f.read split file while ...

從文字中提取所有的單詞

比如 hello world hello everyone,my name is caozhy 輸出 caozhy everyone hello ismy name world class dictgen public node public ienumerable string get publi...