Help us shape the future of Go! Take the 2026 Go Developer Survey

wimlib

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 3

README

go-wimlib

Go bindings for wimlib, the library behind wimlib-imagex. It covers what you need to work with Windows WIM images from Go: open and create archives, extract full images or single paths, add and delete files in an image, export images between archives (ESD to WIM included), and set image names and boot flags.

Two extras go beyond the usual imaging calls. Decompressor gives you raw LZX/LZMS block decompression, and the dcs package uses it to parse CBS delta-compressed stores, the format Windows packages hide their payloads in. ListChildren enumerates a directory inside an image without extracting anything.

The cgo bindings sit behind the wimlib build tag, so plain go build compiles a stub that returns errors instead, and packages that import this one still build on machines without libwim. Build with -tags wimlib (and libwim installed) to get the real thing. This library is part of the Windows tooling behind devcell; pin a version, there is no v1 yet.

go get github.com/devcell-sh/go-wimlib

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

func DecompressDCS

func DecompressDCS(data []byte) ([]byte, error)

DecompressDCS decompresses a DCS\x01 container (CBS delta-compressed store). The format wraps LZMS-compressed blocks:

Header (12 bytes): Signature(4) + NumberOfBlocks(4, LE) + UncompressedFileSize(4, LE)
Per block: BlockSize(4, LE) + DecompressedBlockSize(4, LE) + CompressedData[BlockSize-4]
Next block starts at current offset + BlockSize + 4.

func IsDCS

func IsDCS(data []byte) bool

IsDCS checks whether data starts with the DCS\x01 signature.

Types

type Compression

type Compression int

Compression type for WIM images.

const (
	None Compression = 0
	LZX  Compression = 1
	LZMS Compression = 2
)

type Decompressor

type Decompressor struct {
	// contains filtered or unexported fields
}

Decompressor wraps a wimlib decompressor handle for raw block decompression.

func NewDecompressor

func NewDecompressor(ctype Compression, maxBlockSize int) (*Decompressor, error)

func (*Decompressor) Close

func (d *Decompressor) Close()

func (*Decompressor) Decompress

func (d *Decompressor) Decompress(compressed []byte, uncompressedSize int) ([]byte, error)

type ProgressFunc

type ProgressFunc func(percentDone int)

ProgressFunc is called during long WIM operations with completion percentage.

type WIM

type WIM struct {
	// contains filtered or unexported fields
}

WIM represents an open WIM archive.

func CreateWIM

func CreateWIM(compression Compression) (*WIM, error)

func OpenWIM

func OpenWIM(path string) (*WIM, error)

func (*WIM) AddEmptyImage added in v0.2.0

func (w *WIM) AddEmptyImage(name string) (int, error)

AddEmptyImage adds a new, empty image to the WIM and returns its 1-based index. Files can then be added via UpdateImageAdd/UpdateImageAddTree.

func (*WIM) Close

func (w *WIM) Close()

func (*WIM) ExportImage

func (w *WIM) ExportImage(imageNum int, dest *WIM, compression Compression) error

func (*WIM) ExtractImage

func (w *WIM) ExtractImage(imageNum int, targetDir string, onProgress ProgressFunc) error

func (*WIM) ExtractPaths

func (w *WIM) ExtractPaths(imageNum int, targetDir string, wimPaths []string) error

ExtractPaths extracts specific paths from a WIM image into targetDir. Each wimPath is an absolute path within the WIM (e.g. `\Windows\System32\config\SYSTEM`). The extracted files land in targetDir preserving their directory structure.

func (*WIM) ImageCount

func (w *WIM) ImageCount() (int, error)

func (*WIM) ImageDescription

func (w *WIM) ImageDescription(imageNum int) (string, error)

func (*WIM) ListChildren

func (w *WIM) ListChildren(imageNum int, wimDirPath string) ([]string, error)

ListChildren returns the names of the immediate children of wimDirPath inside the given image, e.g. every component directory under `\Windows\WinSxS`. Names are basenames, not full paths.

func (*WIM) Overwrite

func (w *WIM) Overwrite() error

func (*WIM) ReferenceResourceFilePaths

func (w *WIM) ReferenceResourceFilePaths(paths []string) error

ReferenceResourceFilePaths adds individual file paths (not globs) as resource references. This bypasses glob expansion and opens each file directly.

func (*WIM) ReferenceResourceFiles

func (w *WIM) ReferenceResourceFiles(globs []string) error

func (*WIM) SetBootImage

func (w *WIM) SetBootImage(imageNum int) error

func (*WIM) SetImageName

func (w *WIM) SetImageName(imageNum int, name, description string) error

SetImageName sets the name and description of a WIM image via properties. Uses wimlib_set_image_property (wimlib_set_image_description was removed).

func (*WIM) SetImageProperty

func (w *WIM) SetImageProperty(imageNum int, propertyName, propertyValue string) error

SetImageProperty sets a property on a WIM image (e.g. FLAGS, DISPLAYNAME).

func (*WIM) UpdateImageAdd

func (w *WIM) UpdateImageAdd(imageNum int, fsSourcePath, wimTargetPath string) error

UpdateImageAdd adds a file or directory from the filesystem into a WIM image.

func (*WIM) UpdateImageAddTree

func (w *WIM) UpdateImageAddTree(imageNum int, fsRootDir, wimRootDir string) error

UpdateImageAddTree adds an entire directory tree from the filesystem into a WIM image. All files and subdirectories under fsRootDir are added under wimRootDir.

func (*WIM) UpdateImageDelete

func (w *WIM) UpdateImageDelete(imageNum int, wimPath string) error

UpdateImageDelete removes a path from a WIM image.

func (*WIM) Write

func (w *WIM) Write(path string) error

Jump to

Keyboard shortcuts

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