#!/bin/sh
if [[ $# -ne 0 ]]; then
echo "USAGE: $0"
exit 1
fi
grep '^[^ ].*$' /proc/iomem | grep 'System RAM' | while read -r LINE; do
X0="0x`echo $LINE | sed 's|^\([^-]*\)-.*|\1|'`"
X1="0x`echo $LINE | sed 's|^[^-]*-\([^ ]*\) .*|\1|'`"
R0=$(( ($(printf %d $X0) / 4096)))
R1=$(( ($(printf %d $X1) / 4096)))
if [ $(( $(printf %d $X1) % 4096 )) -ne 0 ]; then
R1=$(( $R1 + 1 ))
fi
echo "CHUNK: $X0-$X1"
dd if=/dev/mem bs=4096 skip=$R0 count=$(( $R1 - $R0 ))
done
答案 0 :(得分:1)
您的脚本会将内存转储到其输出中,如果您希望将其格式化(例如,十六进制),则应将其传递给xxd
或od