a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync# Program to reverse the device identifier IDs in the PCIR and PnP
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync# structures in a ROM for old non-compliant BIOSes
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync# GPL, Ken Yap 2001
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync substr($$dataref, $loc1, 1) = substr($$dataref, $loc2, 1);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return (sprintf "%02x %02x %02x", unpack('C3', substr($$dataref, $loc, 3)));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$#ARGV >= 0 or die "Usage: $0 romimage\n";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync# Handle up to 64kB ROM images
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncsubstr($data, 0, 2) eq "\x55\xAA" or die "$file: Not a boot ROM image\n";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync($pci, $pnp) = unpack('v2', substr($data, 0x18, 4));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync($pci < $len and $pnp < $len) or die "$file: Not a PCI PnP ROM image\n";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync(substr($data, $pci, 4) eq 'PCIR' and substr($data, $pnp, 4) eq '$PnP')
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync or die "$file: No PCI and PNP structures, not a PCI PNP ROM image\n";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncseek(F, 0, SEEK_SET) or die "$file: Cannot seek to beginning\n";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncprint "PCI devids now: ", &printdevids(\$data, $pci+13), "\n";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncprint "PnP devids now: ", &printdevids(\$data, $pnp+18), "\n";