Modifying Windows Image
Injecting Drivers into Vhdx Windows Image
Injecting drivers and registry entries into your VHDX image is straight forward using DISM. You will need the driver binaries and inf file to install the driver.
-
Mount the VHDX by double clicking on it and noting the drive letter that is mounted
-
Inject your driver using DISM
dism /Image:e:\ /Add-Driver /Driver:d:\drivers\testdrv -
This will execute the installation steps in the INF including copying your driver into the mounted image and updating the registry. Make sure the operation completes successfully. If you have multiple drivers you can use the /Recurse option to install all inf files.
-
Make sure to cleanly unmount your VHDX drive.
-
Copy the ValidationOS.vhdx to postbuild/os/prebuilt.
-
Run
make -C postbuild/os qcow2to regenerate the qcow file for QEMU. -
Run
make run_osto boot your new windows image.
Injecting Executables and Autorun
To inject executable content you can simply click on the VHDX file to mount it and make a folder and copy content to the device. If you are trying to overwrite existing system content you may need to make yourself the owener and allow overwrite permissions. Sfpcopy can also be used to accomplish secure copy.
takeown /f <filename>
icacls <filename> /grant everyone:f
copy <localfile> <destfile>
To automatically run an executable in WinVOS you can edit the registry in the VHDX.
- Mount the VHDX image by double clicking on it and noting the drive letter.
- Run regedit as administrator.
- Select the root of HKLM.
- File -> Load Hive and browse to your mounted drive under e:\windows\system32\config\SOFTWARE
- Name the mount location "Offline"
- Browse to the following key
Computer\HKEY_LOCAL_MACHINE\offline\Microsoft\Windows NT\CurrentVersion\Winlogon - Modify the "Shell" REG_SZ entry which just runs
cmd.exeby default. - After you've modified the key be sure to select the root of the offline folder and select File -> Unload Hive
- Unmount your VDHX file to make sure it is saved
- Convert windows image to qcow2 and load in QEMU
