37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
/* [MS-CFB] 2.2 Compound File Header -- read up to major version */
|
|
function check_get_mver(blob/*:CFBlob*/)/*:[number, number]*/ {
|
|
if(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];
|
|
// header signature 8
|
|
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
|
|
|
|
// clsid 16
|
|
//blob.chk(HEADER_CLSID, 'CLSID: ');
|
|
blob.l += 16;
|
|
|
|
// minor version 2
|
|
var mver/*:number*/ = blob.read_shift(2, 'u');
|
|
|
|
return [blob.read_shift(2,'u'), mver];
|
|
}
|
|
function check_shifts(blob/*:CFBlob*/, mver/*:number*/)/*:void*/ {
|
|
var shift = 0x09;
|
|
|
|
// Byte Order
|
|
//blob.chk('feff', 'Byte Order: '); // note: some writers put 0xffff
|
|
blob.l += 2;
|
|
|
|
// Sector Shift
|
|
switch((shift = blob.read_shift(2))) {
|
|
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);
|
|
}
|
|
|
|
// Mini Sector Shift
|
|
blob.chk('0600', 'Mini Sector Shift: ');
|
|
|
|
// Reserved
|
|
blob.chk('000000000000', 'Reserved: ');
|
|
}
|
|
|