From eabc9163f8cc53842554e84ea33c4c6d8816f6f4 Mon Sep 17 00:00:00 2001 From: esophagoose <> Date: Sun, 20 Nov 2022 01:01:21 -0800 Subject: [PATCH] Working --- altium_sch_document.js | 5 +++-- ole.js | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/altium_sch_document.js b/altium_sch_document.js index 7a3d8a0..242602c 100644 --- a/altium_sch_document.js +++ b/altium_sch_document.js @@ -681,10 +681,11 @@ class AltiumDocument { constructor(stream) { + const min_record_size = 4 this.stream = stream; this.records = []; let index = -1; // header comes first, so give it an index of -1 - while (this.stream.u8stream_position < this.stream.length) + while (this.stream.u8stream_position + min_record_size < this.stream.length) { this.records.push(new AltiumRecord(this.stream, index)); index++; @@ -782,4 +783,4 @@ class AltiumDocument } return results; } -} \ No newline at end of file +} diff --git a/ole.js b/ole.js index 1b13e30..06a1251 100644 --- a/ole.js +++ b/ole.js @@ -109,9 +109,17 @@ class OLE this.header.difat = new Uint32Array(this.stream.read(436, true)); this.fat_sectors = []; + let number_of_entries = 0 for (let i = 0; i < 109; i++) { this.fat_sectors[i] = new FATSector(this, this.header.difat[i]); + number_of_entries += this.fat_sectors[i].entries.length + } + let index = 0; + this.fat = new Uint32Array(number_of_entries); + for (let i=0; i= 0xFFFFFFFC) + break + this.ole.stream.seek_to((sector + 1) * sector_size); + data.push(this.ole.stream.read(sector_size)) + total_size += sector_size + sector = this.ole.fat[sector] + } + var all_data = new Uint8Array(total_size); + let index = 0 + for (let i=0; i