3 # extract-vsssdk-headers
4 # Author: Paolo Bonzini <pbonzini@redhat.com>
7 if test $# != 1 ||
! test -f "$1"; then
8 echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >&2
12 if ! command -v msiextract
> /dev
/null
; then
13 echo 'msiextract not found. Please install msitools.' >&2
18 echo '"inc" already exists.' >&2
22 # Extract .MSI file in the .exe, looking for the OLE compound
23 # document signature. Extra data at the end does not matter.
25 MAGIC
=$
'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'
26 offset
=$
(grep -abom1 "$MAGIC" "$1" |
sed -n 's/:/\n/; P')
28 trap 'rm -fr -- "$tmpdir" vsssdk.msi' EXIT HUP INT QUIT ALRM TERM
29 tail -c +$
(($offset+1)) -- "$1" > vsssdk.msi
31 # Now extract the files.
32 msiextract
-C $tmpdir vsssdk.msi
33 mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc
34 echo 'Extracted SDK headers into "inc" directory.'