2014-06-24 04:00:39 +00:00
|
|
|
/* [MS-CFB] 2.2 Compound File Header -- read up to major version */
|
2017-07-28 17:53:08 +00:00
|
|
|
function check_get_mver(blob/*:CFBlob*/)/*:[number, number]*/ {
|
2018-09-04 07:14:20 +00:00
|
|
|
if(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];
|
2014-06-24 04:00:39 +00:00
|
|
|
// header signature 8
|
|
|
|
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
|
|
|
|
|
|
|
|
// clsid 16
|
2019-06-10 12:44:27 +00:00
|
|
|
//blob.chk(HEADER_CLSID, 'CLSID: ');
|
|
|
|
blob.l += 16;
|
2014-06-24 04:00:39 +00:00
|
|
|
|
|
|
|
// minor version 2
|
2017-07-28 17:53:08 +00:00
|
|
|
var mver/*:number*/ = blob.read_shift(2, 'u');
|
2014-06-24 04:00:39 +00:00
|
|
|
|
2014-11-03 04:02:42 +00:00
|
|
|
return [blob.read_shift(2,'u'), mver];
|
2014-06-24 04:00:39 +00:00
|
|
|
}
|
2017-07-28 17:53:08 +00:00
|
|
|
function check_shifts(blob/*:CFBlob*/, mver/*:number*/)/*:void*/ {
|
2014-06-24 04:00:39 +00:00
|
|
|
var shift = 0x09;
|
|
|
|
|
|
|
|
// Byte Order
|
2017-03-30 21:34:37 +00:00
|
|
|
//blob.chk('feff', 'Byte Order: '); // note: some writers put 0xffff
|
|
|
|
blob.l += 2;
|
2014-06-24 04:00:39 +00:00
|
|
|
|
|
|
|
// Sector Shift
|
|
|
|
switch((shift = blob.read_shift(2))) {
|
2017-03-30 21:34:37 +00:00
|
|
|
case 0x09: if(mver != 3) throw new Error('Sector Shift: Expected 9 saw ' + shift); break;
|
|
|
|
case 0x0c: if(mver != 4) throw new Error('Sector Shift: Expected 12 saw ' + shift); break;
|
|
|
|
default: throw new Error('Sector Shift: Expected 9 or 12 saw ' + shift);
|
2014-06-24 04:00:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mini Sector Shift
|
|
|
|
blob.chk('0600', 'Mini Sector Shift: ');
|
|
|
|
|
|
|
|
// Reserved
|
|
|
|
blob.chk('000000000000', 'Reserved: ');
|
|
|
|
}
|
|
|
|
|