Created
November 30, 2020 10:24
-
-
Save IntelOrca/a8b263ab942c5466d4fc54751bc0e9d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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