qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

extract-vsssdk-headers (937B)


      1 #! /bin/bash
      2 
      3 # extract-vsssdk-headers
      4 # Author: Paolo Bonzini <pbonzini@redhat.com>
      5 
      6 set -e
      7 if test $# != 1 || ! test -f "$1"; then
      8   echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >&2
      9   exit 1
     10 fi
     11 
     12 if ! command -v msiextract > /dev/null; then
     13   echo 'msiextract not found. Please install msitools.' >&2
     14   exit 1
     15 fi
     16 
     17 if test -e inc; then
     18   echo '"inc" already exists.' >&2
     19   exit 1
     20 fi
     21 
     22 # Extract .MSI file in the .exe, looking for the OLE compound
     23 # document signature.  Extra data at the end does not matter.
     24 export LC_ALL=C
     25 MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'
     26 offset=$(grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P')
     27 tmpdir=$(mktemp -d)
     28 trap 'rm -fr -- "$tmpdir" vsssdk.msi' EXIT HUP INT QUIT ALRM TERM
     29 tail -c +$(($offset+1)) -- "$1" > vsssdk.msi
     30 
     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.'
     35 exit 0