You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thinkpad-ec/scripts/slice.extract

28 lines
544 B
Bash

#!/bin/bash
#
# Quick and dirty extractor to slice out a section of a binary file
# Copyright (C) 2016 Hamish Coleman
#
# TODO:
# - a tool that is portable to Windows
# - should output dependency information
INFOFILE="$1"
if [ ! -r "$INFOFILE" ]; then
echo Need file with source and offset info
exit 1
fi
shift
OUT="$1"
if [ -z "$OUT" ]; then
echo Need output filename
exit 1
fi
read SOURCE OFFSET LENGTH <"$INFOFILE"
set -x
dd status=none iflag=count_bytes,skip_bytes if=$SOURCE skip=$[$OFFSET] count=$[$LENGTH] of="$OUT"