Skip to content

Instantly share code, notes, and snippets.

@AlexanderOMara
Last active December 21, 2019 20:21
Show Gist options
  • Save AlexanderOMara/1b53507b4da53fb5c9febb125096a756 to your computer and use it in GitHub Desktop.
Save AlexanderOMara/1b53507b4da53fb5c9febb125096a756 to your computer and use it in GitHub Desktop.
Node resedit fails on some version strings
# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
# Node files
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
report.*.json
*.tgz
yarn.lock

Node resedit fails on some version strings

Output

$ node main.js
.../node_modules/resedit/dist/resource/VersionInfo.js:53
        throw new Error('Invalid StringTable data format');
        ^

Error: Invalid StringTable data format
    at parseStringTable (.../node_modules/resedit/dist/resource/VersionInfo.js:53:15)
    at _loop_1 (.../node_modules/resedit/dist/resource/VersionInfo.js:97:25)
    at parseStringFileInfo (.../node_modules/resedit/dist/resource/VersionInfo.js:112:9)
    at parseVersionEntry (.../node_modules/resedit/dist/resource/VersionInfo.js:220:46)
    at new VersionInfo (.../node_modules/resedit/dist/resource/VersionInfo.js:376:25)
    at .../node_modules/resedit/dist/resource/VersionInfo.js:384:97
    at Array.map (<anonymous>)
    at Function.VersionInfo.fromEntries (.../node_modules/resedit/dist/resource/VersionInfo.js:384:71)
    at Object.<anonymous> (.../main.js:11:43)
    at Module._compile (internal/modules/cjs/loader.js:1128:30)
'use strict';
const fs = require('fs');
const resedit = require('resedit');
const data = fs.readFileSync('projec32.exe');
const exe = resedit.NtExecutable.from(data.buffer);
const res = resedit.NtExecutableResource.from(exe);
// Problem:
const vers = resedit.Resource.VersionInfo.fromEntries(res.entries);
console.log(vers);
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"resedit": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/resedit/-/resedit-0.3.0.tgz",
"integrity": "sha512-80sKE1yPUHcv7PAMFN6P7jdT1GQpRtfJP4SNg0B8gDHZwzm7vgcpGlBxAke9UhQbAEGGybghPuUZJBV1MoZEiQ=="
}
}
}
{
"private": true,
"dependencies": {
"resedit": "^0.3.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment