Skip to content

Instantly share code, notes, and snippets.

@IntelOrca
Created November 30, 2020 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntelOrca/a8b263ab942c5466d4fc54751bc0e9d2 to your computer and use it in GitHub Desktop.
Save IntelOrca/a8b263ab942c5466d4fc54751bc0e9d2 to your computer and use it in GitHub Desktop.
// Copyright (C) 2020 Micro Focus or one of its affiliates.
import fs from 'fs';
// Open the given vsix file and patch the Linux debug adapter binary to be executable
if (process.argv.length < 3) {
console.log("usage: rezip <vsix>");
process.exit(1);
} else {
let vsixPath = process.argv[2];
console.log(`Fixing ${vsixPath}...`)
var buffer = fs.readFileSync(vsixPath);
for (let i = buffer.length - 4; i >= 0; i--) {
let signature = buffer.readInt32BE(i);
if (signature == 0x504B0102) {
let fileNameLen = buffer.readInt16LE(i + 0x1C);
let name = "";
for (let j = 0; j < fileNameLen; j++) {
let b = buffer.readUInt8(i + 0x2E + j);
name += String.fromCharCode(b);
}
let fileAttributes = buffer.readUInt32LE(i + 0x26);
if (name === 'extension/bin/debugadapter/linux-x64/MicroFocus.VsCodeDebugProtocol') {
fileAttributes = 0x81FF8000;
buffer.writeUInt32LE(fileAttributes, i + 0x26);
break;
}
}
}
fs.writeFileSync(vsixPath, buffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment