#!/bin/bash # Horrific hack to bypass X version test # Copyright 2007, Kees Cook # License: GPLv2 set -e SO="$1" if [ -z "$SO" ]; then SO="/usr/lib/xorg/modules/drivers/fglrx_drv.so" fi if [ ! -e "$SO" ]; then echo "No such file '$SO'" >&2 exit 1 fi if [ ! -w "$SO" ]; then echo "Cannot write to '$SO' (try using sudo?)" >&2 exit 1 fi if [ ! -x /usr/bin/objdump ]; then apt-get install -y binutils fi function oppatch() { so="$1" target="$2" op="$3" size="$4" bak="$so".pre-patch-"$target"-"$op"-"$size" if [ -e "$bak" ]; then echo "'$bak' already exists! If you're really sure, delete it and try again" >&2 exit 1 fi echo " creating backup file '$bak' ..." cp "$so" "$bak" perl < "$DIS" # 2D Engine (skip conditional jump) echo "Attempting to patch 2D version test..." for addr in $(grep atiddxMiscCheckXF86Version "$DIS" | grep call | awk '{print $1}') do target=$(grep -A2 '^ *'"$addr" "$DIS" | tail -1 | grep "jg" | awk '{print $1}') if [ -n "$target" ]; then target=$(echo "$target" | cut -d: -f1) oppatch "$SO" "$target" 0x90 2 fi done # 3D Engine (force conditional jump) echo "Attempting to patch 3D version test..." for addr in $(grep atiddxDriCloseScreen "$DIS" | grep call | awk '{print $1}') do target=$(grep -B4 '^ *'"$addr" "$DIS" | grep "jle" | grep "atiddxDriScreenInit" | head -1 | awk '{print $1}') if [ -n "$target" ]; then target=$(echo "$target" | cut -d: -f1) oppatch "$SO" "$target" 0xeb 1 fi done