#!/usr/bin/python import os,sys,time,string # find the files that need to be patched files = string.split(os.popen("slocate /lib/modules/*/visor.o").read()) if len(files) == 0: print "Could not find visor.o in /lib/modules/. Where is it?" sys.exit() for file in files: print "Reading %s" % file data = open(file,"rb").read() count = 0 for i in range(0,len(data)-4,2): word1 = (ord(data[i+0]) << 8) + ord(data[i+1]) word2 = (ord(data[i+2]) << 8) + ord(data[i+3]) if word1 == 0x082d and word2 == 0x0300: print "File already supports treo 600, skipping" count = 0 break if word1 == 0x082d and word2 == 0x0200: #word2 = 0x0300 print "Changed word 0x%x from 0x0200 to 0x300" % (i) data = data[:i+2] + \ chr(word2 >> 8) + \ chr(word2 & 0xff) + \ data[i+4:] count = count + 1 if count > 0: f = file[:-2]+".treo600" open(f,"wb").write(data) print "Chaned %d occurrance of 0x082d0200 to 0x082d0300" % (count) print "Wrote %s" % f else: print "I coudn't find the bytes I needed... Is everything ok?" print "Rename visor.treo600 to visor.o and reboot!"