Workaround for missing readBigUInt64LE() in older NodeJS.

Ylian Saint-Hilaire committed Jun 9, 2022 at 10:50 UTC 97a9b2ee006d78c7a54d8f23fda92d897061cf15
1 file changed +10 -10
authenticode.js
+10 -10
@@ -172,7 +172,7 @@ function createAuthenticodeHandler(path) {
172 obj.header.peWindows = {}
173 if (obj.header.pe32plus == 0) {
174 // 32bit header
175 - obj.header.peWindows.imageBase = optinalHeader.readUInt32LE(28);
175 + //obj.header.peWindows.imageBase = optinalHeader.readUInt32LE(28);
176 obj.header.peWindows.sectionAlignment = optinalHeader.readUInt32LE(32);
177 obj.header.peWindows.fileAlignment = optinalHeader.readUInt32LE(36);
178 obj.header.peWindows.majorOperatingSystemVersion = optinalHeader.readUInt16LE(40);
@@ -187,15 +187,15 @@ function createAuthenticodeHandler(path) {
187 obj.header.peWindows.checkSum = optinalHeader.readUInt32LE(64);
188 obj.header.peWindows.subsystem = optinalHeader.readUInt16LE(68);
189 obj.header.peWindows.dllCharacteristics = optinalHeader.readUInt16LE(70);
190 - obj.header.peWindows.sizeOfStackReserve = optinalHeader.readUInt32LE(72);
191 - obj.header.peWindows.sizeOfStackCommit = optinalHeader.readUInt32LE(76);
192 - obj.header.peWindows.sizeOfHeapReserve = optinalHeader.readUInt32LE(80);
193 - obj.header.peWindows.sizeOfHeapCommit = optinalHeader.readUInt32LE(84);
190 + //obj.header.peWindows.sizeOfStackReserve = optinalHeader.readUInt32LE(72);
191 + //obj.header.peWindows.sizeOfStackCommit = optinalHeader.readUInt32LE(76);
192 + //obj.header.peWindows.sizeOfHeapReserve = optinalHeader.readUInt32LE(80);
193 + //obj.header.peWindows.sizeOfHeapCommit = optinalHeader.readUInt32LE(84);
194 obj.header.peWindows.loaderFlags = optinalHeader.readUInt32LE(88);
195 obj.header.peWindows.numberOfRvaAndSizes = optinalHeader.readUInt32LE(92);
196 } else {
197 // 64bit header
198 - obj.header.peWindows.imageBase = optinalHeader.readBigUInt64LE(24);
198 + //obj.header.peWindows.imageBase = optinalHeader.readBigUInt64LE(24); // TODO: readBigUInt64LE is not supported in older NodeJS versions
199 obj.header.peWindows.sectionAlignment = optinalHeader.readUInt32LE(32);
200 obj.header.peWindows.fileAlignment = optinalHeader.readUInt32LE(36);
201 obj.header.peWindows.majorOperatingSystemVersion = optinalHeader.readUInt16LE(40);
@@ -210,10 +210,10 @@ function createAuthenticodeHandler(path) {
210 obj.header.peWindows.checkSum = optinalHeader.readUInt32LE(64);
211 obj.header.peWindows.subsystem = optinalHeader.readUInt16LE(68);
212 obj.header.peWindows.dllCharacteristics = optinalHeader.readUInt16LE(70);
213 - obj.header.peWindows.sizeOfStackReserve = optinalHeader.readBigUInt64LE(72);
214 - obj.header.peWindows.sizeOfStackCommit = optinalHeader.readBigUInt64LE(80);
215 - obj.header.peWindows.sizeOfHeapReserve = optinalHeader.readBigUInt64LE(88);
216 - obj.header.peWindows.sizeOfHeapCommit = optinalHeader.readBigUInt64LE(96);
213 + //obj.header.peWindows.sizeOfStackReserve = optinalHeader.readBigUInt64LE(72);
214 + //obj.header.peWindows.sizeOfStackCommit = optinalHeader.readBigUInt64LE(80);
215 + //obj.header.peWindows.sizeOfHeapReserve = optinalHeader.readBigUInt64LE(88);
216 + //obj.header.peWindows.sizeOfHeapCommit = optinalHeader.readBigUInt64LE(96);
217 obj.header.peWindows.loaderFlags = optinalHeader.readUInt32LE(104);
218 obj.header.peWindows.numberOfRvaAndSizes = optinalHeader.readUInt32LE(108);
219 }