結構圖:
寫入extcontent資訊示例(讀取類似):
//no extcontent block we need add it
nnewheaderobjects++;
int extcontentpos = 16 + 8 + 4 + 2; // 設定extcontent開始的位置
byte blastdata = new byte[fs.length - extcontentpos];
fs.seek(extcontentpos, seekorigin.begin);
fs.read(blastdata, 0, blastdata.length);
//write new header object count
fs.seek(24, seekorigin.begin);
byte bheaderobjects = bitconverter.getbytes(nnewheaderobjects);
fs.write(bheaderobjects, 0, bheaderobjects.length);
bheaderobjects = null;
int naddlength = 0;
//we need add 'wm/albumtitle/0' tag
int16 newcontents = 1;
byte bcontents = bitconverter.getbytes(newcontents);
naddlength += 2;
string tagstring = "wm/albumtitle/0";
byte btagstring = encoding.unicode.getbytes(tagstring);
int16 ntaglen = (int16)btagstring.length;
naddlength += 2;
naddlength += (int16)btagstring.length;
int16 nflag = 0;
byte bflag = bitconverter.getbytes(nflag);
naddlength += 2;
byte bvaluestring = encoding.unicode.getbytes(minfo.albumename + "/0");
int16 nvaluelen = (int16)bvaluestring.length;
naddlength += 2;
naddlength += bvaluestring.length;
int64 blocklen = naddlength + 24;
newmaxsize += blocklen;
//fs.seek(newmaxsize, seekorigin.begin);
fs.seek(extcontentpos, seekorigin.begin);
writeguid(fs, guidextcontentst);
//write new extcontents block size
byte bnewlen = bitconverter.getbytes(blocklen);
fs.write(bnewlen, 0, bnewlen.length);
bnewlen = null;
//write content num
fs.write(bcontents, 0, bcontents.length);
bcontents = null;
//write name len & name string
bnewlen = bitconverter.getbytes(ntaglen);
fs.write(bnewlen, 0, bnewlen.length);
bnewlen = null;
fs.write(btagstring, 0, btagstring.length);
btagstring = null;
//write 2 byts flag
fs.write(bflag, 0, bflag.length);
bflag = null;
//write value len & value strint
bnewlen = bitconverter.getbytes(nvaluelen);
fs.write(bnewlen, 0, bnewlen.length);
bnewlen = null;
fs.write(bvaluestring, 0, bvaluestring.length);
bvaluestring = null;
//write last data
fs.write(blastdata, 0, blastdata.length);
blastdata = null;
PE檔案頭結構
typedef struct image file header image file header,pimage file header 1.machine 每個cpu都有唯一的machine碼,用來指定檔案的執行平台 define image file machine unknown 0 def...
pcap檔案解析 pcap檔案頭與包檔案頭(一)
前段時間接到乙個公司關於解析pacp檔案的培訓 我是被培訓的 在完成了一部分的功能後決定把一些關於pcap檔案的了解記錄到部落格中。在開始讀取pcap檔案之前,先讓我們來看看pcap檔案的大概結構。如上圖所示在乙個pcap檔案中存在1個pcap檔案頭和多個資料報,其中每個資料報都有自己的頭和包內容。...
pe檔案of映像檔案頭
typedef struct image file header image file header,pimage file header 結構體的第乙個成員說明cpu的型別。需要了解的話看win32 sdk的巨集定義。結構體的第三個成員使用的是格林尼治時間 gmt 計算的秒數。結構體最後乙個成員說...