pe-library
pe-library provides parsing and generating Portable Executable (known as Windows Executables) binaries.
Usage
import * as PE from 'pe-library';
import * as fs from 'fs';
let data = fs.readFileSync('MyApp.exe');
let exe = PE.NtExecutable.from(data);
let exportSection = exe.getSectionByEntry(PE.Format.ImageDirectoryEntry.Export);
let newBin = exe.generate();
fs.writeFileSync('MyApp_modified.exe', new Buffer(newBin));
from CommonJS (using require
)
Starting from v1.0.0, CommonJS support is changed; you must use pe-library/cjs
to use from CommonJS file.
const { load } = require('pe-library/cjs');
const fs = require('fs');
load().then((PE) => {
let data = fs.readFileSync('MyApp.exe');
let exe = PE.NtExecutable.from(data);
let exportSection = exe.getSectionByEntry(
PE.Format.ImageDirectoryEntry.Export
);
let newBin = exe.generate();
fs.writeFileSync('MyApp_modified.exe', new Buffer(newBin));
});
for CommonJS-based TypeScript module
import { type PE, load } from 'pe-library/cjs';
load().then((pe: typeof PE) => {
...
});
License
- All programs / source codes / binaries in this package, EXCEPT FOLLOWINGS, are licensed with MIT License.
- The followings are licensed with 0-BSD license: