diff --git a/Makefile b/Makefile index 99297c0..8845a4a 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,8 @@ install.radare.projects: # just the Xx30 series, these generic rules will need to be reworked # keep intermediate files +.PRECIOUS: %.orig +.PRECIOUS: %.img .PRECIOUS: %.img.orig # Generate a working file with any known patches applied @@ -81,3 +83,9 @@ x220.8DHT34WW.img.enc.slice: x220.8DHT34WW.s01CB000.FL2.orig x230.G2HT35WW.img.enc.slice: x230.G2HT35WW.s01D3000.FL2.orig t430.G1HT35WW.img.enc.slice: g1uj38us.iso.orig t430s.G7HT39WW.img.enc.slice: g7uj18us.iso.orig + +x230.G2HT35WW.s01D3000.FL2: x230.G2HT35WW.img.enc.slice x230.G2HT35WW.img.enc + +# Hacky, non generic rule +x230.G2HT35WW.s01D3000.FL2: x230.G2HT35WW.img.enc + ./slice.insert $<.slice $< $@ diff --git a/slice.extract b/slice.extract index 74506dd..de60319 100755 --- a/slice.extract +++ b/slice.extract @@ -24,5 +24,5 @@ read SOURCE OFFSET LENGTH <"$INFOFILE" set -x -dd iflag=count_bytes,skip_bytes if=$SOURCE skip=$[$OFFSET] count=$[$LENGTH] of="$OUT" +dd status=none iflag=count_bytes,skip_bytes if=$SOURCE skip=$[$OFFSET] count=$[$LENGTH] of="$OUT" diff --git a/slice.insert b/slice.insert new file mode 100755 index 0000000..bcb398c --- /dev/null +++ b/slice.insert @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Quick and dirty script to insert a slice into a binary file +# Copyright (C) 2016 Hamish Coleman +# +# TODO: +# - a tool that is portable to Windows +# - should output dependancy information + +INFOFILE="$1" +if [ ! -r "$INFOFILE" ]; then + echo Need file with source and offset info + exit 1 +fi +shift + +INPUT="$1" +if [ -z "$INPUT" ]; then + echo Need input filename + exit 1 +fi +shift + +OUT="$1" +if [ -z "$OUT" ]; then + echo Need output filename + exit 1 +fi + +read SOURCE OFFSET LENGTH <"$INFOFILE" + +set -x + +cp --reflink=auto $SOURCE $OUT +dd status=none if=$INPUT bs=$[$LENGTH] count=1 | dd status=none conv=notrunc bs=$[$OFFSET] seek=1 of="$OUT" +