Version: v0.6.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 5 Imported by: 119


Rendered for windows/amd64



View Source
const (
	//revive:disable-next-line:var-naming ALL_CAPS

	// Access Mask for opening a VHD.
	VirtualDiskAccessNone     VirtualDiskAccessMask = 0x00000000
	VirtualDiskAccessAttachRO VirtualDiskAccessMask = 0x00010000
	VirtualDiskAccessAttachRW VirtualDiskAccessMask = 0x00020000
	VirtualDiskAccessDetach   VirtualDiskAccessMask = 0x00040000
	VirtualDiskAccessGetInfo  VirtualDiskAccessMask = 0x00080000
	VirtualDiskAccessCreate   VirtualDiskAccessMask = 0x00100000
	VirtualDiskAccessMetaOps  VirtualDiskAccessMask = 0x00200000
	VirtualDiskAccessRead     VirtualDiskAccessMask = 0x000d0000
	VirtualDiskAccessAll      VirtualDiskAccessMask = 0x003f0000
	VirtualDiskAccessWritable VirtualDiskAccessMask = 0x00320000

	// Flags for creating a VHD.
	CreateVirtualDiskFlagNone                              CreateVirtualDiskFlag = 0x0
	CreateVirtualDiskFlagFullPhysicalAllocation            CreateVirtualDiskFlag = 0x1
	CreateVirtualDiskFlagPreventWritesToSourceDisk         CreateVirtualDiskFlag = 0x2
	CreateVirtualDiskFlagDoNotCopyMetadataFromParent       CreateVirtualDiskFlag = 0x4
	CreateVirtualDiskFlagCreateBackingStorage              CreateVirtualDiskFlag = 0x8
	CreateVirtualDiskFlagUseChangeTrackingSourceLimit      CreateVirtualDiskFlag = 0x10
	CreateVirtualDiskFlagPreserveParentChangeTrackingState CreateVirtualDiskFlag = 0x20
	CreateVirtualDiskFlagVhdSetUseOriginalBackingStorage   CreateVirtualDiskFlag = 0x40 //revive:disable-line:var-naming VHD, not Vhd
	CreateVirtualDiskFlagSparseFile                        CreateVirtualDiskFlag = 0x80
	CreateVirtualDiskFlagPmemCompatible                    CreateVirtualDiskFlag = 0x100 //revive:disable-line:var-naming PMEM, not Pmem
	CreateVirtualDiskFlagSupportCompressedVolumes          CreateVirtualDiskFlag = 0x200

	// Flags for opening a VHD.
	OpenVirtualDiskFlagNone                        VirtualDiskFlag = 0x00000000
	OpenVirtualDiskFlagNoParents                   VirtualDiskFlag = 0x00000001
	OpenVirtualDiskFlagBlankFile                   VirtualDiskFlag = 0x00000002
	OpenVirtualDiskFlagBootDrive                   VirtualDiskFlag = 0x00000004
	OpenVirtualDiskFlagCachedIO                    VirtualDiskFlag = 0x00000008
	OpenVirtualDiskFlagCustomDiffChain             VirtualDiskFlag = 0x00000010
	OpenVirtualDiskFlagParentCachedIO              VirtualDiskFlag = 0x00000020
	OpenVirtualDiskFlagVhdsetFileOnly              VirtualDiskFlag = 0x00000040
	OpenVirtualDiskFlagIgnoreRelativeParentLocator VirtualDiskFlag = 0x00000080
	OpenVirtualDiskFlagNoWriteHardening            VirtualDiskFlag = 0x00000100
	OpenVirtualDiskFlagSupportCompressedVolumes    VirtualDiskFlag = 0x00000200

	// Flags for attaching a VHD.
	AttachVirtualDiskFlagNone                          AttachVirtualDiskFlag = 0x00000000
	AttachVirtualDiskFlagReadOnly                      AttachVirtualDiskFlag = 0x00000001
	AttachVirtualDiskFlagNoDriveLetter                 AttachVirtualDiskFlag = 0x00000002
	AttachVirtualDiskFlagPermanentLifetime             AttachVirtualDiskFlag = 0x00000004
	AttachVirtualDiskFlagNoLocalHost                   AttachVirtualDiskFlag = 0x00000008
	AttachVirtualDiskFlagNoSecurityDescriptor          AttachVirtualDiskFlag = 0x00000010
	AttachVirtualDiskFlagBypassDefaultEncryptionPolicy AttachVirtualDiskFlag = 0x00000020
	AttachVirtualDiskFlagNonPnp                        AttachVirtualDiskFlag = 0x00000040
	AttachVirtualDiskFlagRestrictedRange               AttachVirtualDiskFlag = 0x00000080
	AttachVirtualDiskFlagSinglePartition               AttachVirtualDiskFlag = 0x00000100
	AttachVirtualDiskFlagRegisterVolume                AttachVirtualDiskFlag = 0x00000200

	// Flags for detaching a VHD.
	DetachVirtualDiskFlagNone DetachVirtualDiskFlag = 0x0


This section is empty.


func AttachVhd added in v0.4.16

func AttachVhd(path string) (err error)

AttachVhd attaches a virtual hard disk at `path` for use. Attaches using version 2 of the ATTACH_VIRTUAL_DISK_PARAMETERS.

func AttachVirtualDisk added in v0.4.16

func AttachVirtualDisk(
	handle syscall.Handle,
	attachVirtualDiskFlag AttachVirtualDiskFlag,
	parameters *AttachVirtualDiskParameters,
) (err error)

AttachVirtualDisk attaches a virtual hard disk for use.

func CreateDiffVhd added in v0.4.16

func CreateDiffVhd(diffVhdPath, baseVhdPath string, blockSizeInMB uint32) error

CreateDiffVhd is a helper function to create a differencing virtual disk.

func CreateVhdx

func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error

CreateVhdx is a helper function to create a simple vhdx file at the given path using default values.

func CreateVirtualDisk added in v0.4.16

func CreateVirtualDisk(
	path string,
	virtualDiskAccessMask VirtualDiskAccessMask,
	createVirtualDiskFlags CreateVirtualDiskFlag,
	parameters *CreateVirtualDiskParameters,
) (syscall.Handle, error)

CreateVirtualDisk creates a virtual harddisk and returns a handle to the disk.

func DetachVhd added in v0.4.11

func DetachVhd(path string) error

DetachVhd detaches a vhd found at `path`.

func DetachVirtualDisk added in v0.4.16

func DetachVirtualDisk(handle syscall.Handle) (err error)

DetachVirtualDisk detaches a virtual hard disk by handle.

func GetVirtualDiskPhysicalPath added in v0.4.16

func GetVirtualDiskPhysicalPath(handle syscall.Handle) (_ string, err error)

GetVirtualDiskPhysicalPath takes a handle to a virtual hard disk and returns the physical path of the disk on the machine. This path is in the form \\.\PhysicalDriveX where X is an integer that represents the particular enumeration of the physical disk on the caller's system.

func OpenVirtualDisk added in v0.4.13

func OpenVirtualDisk(
	vhdPath string,
	virtualDiskAccessMask VirtualDiskAccessMask,
	openVirtualDiskFlags VirtualDiskFlag,
) (syscall.Handle, error)

OpenVirtualDisk obtains a handle to a VHD opened with supplied access mask and flags.

func OpenVirtualDiskWithParameters added in v0.4.16

func OpenVirtualDiskWithParameters(
	vhdPath string,
	virtualDiskAccessMask VirtualDiskAccessMask,
	openVirtualDiskFlags VirtualDiskFlag,
	parameters *OpenVirtualDiskParameters,
) (syscall.Handle, error)

OpenVirtualDiskWithParameters obtains a handle to a VHD opened with supplied access mask, flags and parameters.


type AttachVersion2 added in v0.4.16

type AttachVersion2 struct {
	RestrictedOffset uint64
	RestrictedLength uint64

type AttachVirtualDiskFlag added in v0.4.16

type AttachVirtualDiskFlag uint32

type AttachVirtualDiskParameters added in v0.4.16

type AttachVirtualDiskParameters struct {
	Version  uint32
	Version2 AttachVersion2

type CreateVersion2 added in v0.4.16

type CreateVersion2 struct {
	UniqueID                 guid.GUID
	MaximumSize              uint64
	BlockSizeInBytes         uint32
	SectorSizeInBytes        uint32
	PhysicalSectorSizeInByte uint32
	ParentPath               *uint16 // string
	SourcePath               *uint16 // string
	OpenFlags                uint32
	ParentVirtualStorageType VirtualStorageType
	SourceVirtualStorageType VirtualStorageType
	ResiliencyGUID           guid.GUID

type CreateVirtualDiskFlag added in v0.4.16

type CreateVirtualDiskFlag uint32

type CreateVirtualDiskParameters added in v0.4.16

type CreateVirtualDiskParameters struct {
	Version  uint32 // Must always be set to 2
	Version2 CreateVersion2

type DetachVirtualDiskFlag added in v0.4.16

type DetachVirtualDiskFlag uint32

type OpenVersion2 added in v0.4.16

type OpenVersion2 struct {
	GetInfoOnly    bool
	ReadOnly       bool
	ResiliencyGUID guid.GUID

type OpenVirtualDiskParameters added in v0.4.16

type OpenVirtualDiskParameters struct {
	Version  uint32 // Must always be set to 2
	Version2 OpenVersion2

type VirtualDiskAccessMask added in v0.4.13

type VirtualDiskAccessMask uint32

type VirtualDiskFlag added in v0.4.13

type VirtualDiskFlag uint32

type VirtualStorageType added in v0.4.16

type VirtualStorageType struct {
	DeviceID uint32
	VendorID guid.GUID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL