Skip to content

Instantly share code, notes, and snippets.

@kirbysayshi
Last active Oct 28, 2020
Embed
What would you like to do?
use hdl_dump to inject local ISO/bin+cue files into a locally-connected Playstation 2 hard drive

Mac Instructions:

# clone the hdl-dump repo
USE_THREADED_IIN=no RELEASE=yes make # otherwise will semaphore deadlock

diskutil list # find the /dev/diskX identifier of the PS2 HDD

sudo -s # must be root to query drive and inject
IMG_ROOT=/path/to/ISOs HDD_IDENT=/dev/diskX CLI_PATH=./hdl_dump node ./mass_inject.js

Windows Instructions:

make RELEASE=yes
# configure
$env:HDD_IDENT="hdd1:"; $env:IMG_ROOT="E:\"; $env:CLI_PATH="hdl_dump.exe"; node .\mass_inject.js
const fs = require('fs');
const execSync = require('child_process').execSync;
const path = require('path');
const ROOT = process.env.IMG_ROOT || process.cwd(); // '/Users/drew/PS2/'
const CLI = process.env.CLI_PATH || 'hdl_dump'; // hdl_dump
const HDD_IDENT = process.env.HDD_IDENT;
if (!HDD_IDENT) throw new Error('Must specify HDD_IDENT (e.g. /dev/diskX) ENV var!');
const dir = fs.readdirSync(ROOT)
.filter(e => e.indexOf('.cue') > -1 || e.indexOf('.iso') > -1)
.sort();
const injects = [];
for (const name of dir) {
const pathname = path.join(ROOT, name);
try {
console.log(pathname)
const result = execSync(`${CLI} cdvd_info "${pathname}"`);
console.log(result.toString('utf8'));
const parsed = result.toString('utf8').split(/\s+/).map(p => p.replace(/"/g, ''));
console.log(parsed);
const [startup, opt_name, kbsize] = parsed;
const ext = path.extname(name);
let inject = `${CLI} ${ext === '.cue' ? 'inject_cd' : 'inject_dvd'}`;
inject += ` ${HDD_IDENT} "${path.basename(name, ext)}" "${pathname}" ${startup} *u4`;
injects.push(inject);
} catch(err) {
console.log(err)
process.exit(1);
}
}
for (const cmd of injects) {
try {
console.log(cmd);
const result = execSync(cmd, {stdio: 'inherit'});
// console.log(result.toString());
} catch(err) {
console.log(err)
// console.log(err.stdout.toString());
// console.log(err.stderr.toString());
process.exit(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment