Skip to content

Instantly share code, notes, and snippets.

@johanneswuerbach
Created October 15, 2012 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johanneswuerbach/3894710 to your computer and use it in GitHub Desktop.
Save johanneswuerbach/3894710 to your computer and use it in GitHub Desktop.
Fix OS X DVD Playback
#!/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