#!/bin/sh # ARG 1: LIB PATH # copy libs find $1/bin $1/lib -type d | sed -r 's/'$1'\/(bin|lib)\///;Tn;s/^/mkdir lindows_c\/Windows\/System32\//;by;:n;d;:y;e' > /dev/null; find $1/bin -type f | sed -r 's/'$1'\/bin\/(.*)/cp '$1'\/bin\/\1 lindows_c\/Windows\/System32\/\1.exe/;e' > /dev/null find $1/lib -type f | sed -r 's/'$1'\/lib\/(.*)/cp '$1'\/lib\/\1 lindows_c\/Windows\/System32\/\1/;e' > /dev/null # ntfs-3g cant seem to figure out ntfs symlinks, its 1500 lines of code for reparse points dont even work # with symlinks, so we have to build the reparse point and do it ourselves for lib in $(cd $1/lib && find -type l); do WPATH="$(echo -n $(readlink "$1/lib/$lib"))" LPATH="$(echo -n '/Windows/System32/'"$WPATH" | sed -E 's/(.)/\1\\x00/g;s/\//\\\\/g')" # sed -E 's/(.)/\\0\1/g'); LPATHL=$(( 36 + ${#WPATH} * 2 )); LPATHL1=$(printf "%o" $((($LPATHL >> 8 ) & 255 )) ); LPATHL0=$(printf "%o" $((($LPATHL ) & 255 )) ); LBUF="\\x00\\x00\\$LPATHL0\\$LPATHL1\\x00\\x00\\$LPATHL0\\$LPATHL1\\x00\\x00\\x00\\x00$LPATH" LBUFL=$(( 12 + $LPATHL )) LBUFL1=$(printf "%o" $((($LBUFL >> 8) & 255 )) ); LBUFL0=$(printf "%o" $((($LBUFL ) & 255 )) ); touch "lindows_c/Windows/System32/$lib"; setfattr -h -n system.ntfs_reparse_data \ -v "0S$(printf "\x0C\\x00\\x00\xA0\\$LBUFL0\\$LBUFL1\\x00\\x00$LBUF" | base64 -w0)"\ "lindows_c/Windows/System32/$lib"; #ln -sr "lindows_c/Windows/System32/$(readlink $1/lib/$lib)" "lindows_c/Windows/System32/$lib" done