Created
October 15, 2012 19:32
-
-
Save johanneswuerbach/3894710 to your computer and use it in GitHub Desktop.
Fix OS X DVD Playback
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
#!/usr/bin/env ruby | |
# | |
# Forked from http://pastebin.com/WpRpaLAn | |
require 'fileutils' | |
# Settings | |
dvdLibPath = "/System/Library/Frameworks/DVDPlayback.framework/Versions/A/DVDPlayback" | |
search = "Internal" | |
replace = "External" | |
# writable? | |
raise "Can't patch the dvd library, please run via sudo." unless File.writable? dvdLibPath | |
# Create backup | |
FileUtils.cp dvdLibPath, "#{dvdLibPath} - #{Time.new}.bak" | |
# Patch | |
offset = 0 | |
dvdlib = File.open dvdLibPath, "rb+" | |
dvdlib.seek(0, IO::SEEK_END) | |
length = dvdlib.pos | |
dvdlib.rewind | |
while (dvdlib.pos < (length - search.length)) | |
dvdlib.pos = offset | |
bytes = dvdlib.read(search.length) | |
if bytes == search | |
dvdlib.pos = offset | |
dvdlib.write(replace) | |
printf "patched at offset: %#010x\n", offset | |
else | |
offset = offset + 1 | |
end | |
end | |
dvdlib.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment