dism

package
v0.0.0-...-d707387 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

README

Glazier: DISM Package

The Glazier DISM package is a wrapper for Microsoft's Deployment Image Servicing and Management (DISM) API.

Example Usage

// Connect to DISM
s, err := dism.OpenSession(dism.DISM_ONLINE_IMAGE, "", "", dism.DismLogErrorsWarningsInfo, "", "")
if err != nil {
  return err
}
defer s.Close()

// Disable Features
for _, f := range []string{
  "SMB1Protocol",
}{
  if err := s.DisableFeature(f, "", nil, nil); err != nil && !errors.Is(err, windows.ERROR_SUCCESS_REBOOT_REQUIRED) {
    return err
  }
}

Documentation

Rendered for windows/amd64

Overview

Package dism provides an interface to the Deployment Image Servicing and Management (DISM).

Reference: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/deployment-image-servicing-and-management--dism--api

Index

Constants

View Source
const (
	DISM_ONLINE_IMAGE = "DISM_{53BFAE52-B167-4E2F-A258-0A37B57FF845}"

	DISM_MOUNT_READWRITE       = 0x00000000
	DISM_MOUNT_READONLY        = 0x00000001
	DISM_MOUNT_OPTIMIZE        = 0x00000002
	DISM_MOUNT_CHECK_INTEGRITY = 0x00000004

	DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED syscall.Errno = 0x00000001
)

API Constants Ref https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dism-api-constants

Variables

This section is empty.

Functions

func DismAddCapability

func DismAddCapability(Session uint32, Name *uint16, LimitAccess bool, SourcePaths **uint16, SourcePathCount uint32, CancelEvent *windows.Handle, Progress unsafe.Pointer, UserData unsafe.Pointer) (e error)

func DismAddDriver

func DismAddDriver(Session uint32, DriverPath *uint16, ForceUnsigned bool) (e error)

func DismAddPackage

func DismAddPackage(Session uint32, PackagePath *uint16, IgnoreCheck bool, PreventPending bool, CancelEvent *windows.Handle, Progress unsafe.Pointer, UserData unsafe.Pointer) (e error)

func DismApplyUnattend

func DismApplyUnattend(Session uint32, UnattendFile *uint16, SingleSession bool) (e error)

func DismCloseSession

func DismCloseSession(Session uint32) (e error)

func DismDisableFeature

func DismDisableFeature(Session uint32, FeatureName *uint16, PackageName *uint16, RemovePayload bool, CancelEvent *windows.Handle, Progress unsafe.Pointer, UserData unsafe.Pointer) (e error)

func DismEnableFeature

func DismEnableFeature(Session uint32, FeatureName *uint16, Identifier *uint16, PackageIdentifier *DismPackageIdentifier, LimitAccess bool, SourcePaths *string, SourcePathCount uint32, EnableAll bool, CancelEvent *windows.Handle, Progress unsafe.Pointer, UserData unsafe.Pointer) (e error)

func DismInitialize

func DismInitialize(LogLevel DismLogLevel, LogFilePath *uint16, ScratchDirectory *uint16) (e error)

func DismOpenSession

func DismOpenSession(ImagePath *uint16, WindowsDirectory *uint16, SystemDrive *uint16, Session *uint32) (e error)

func DismRemoveCapability

func DismRemoveCapability(Session uint32, Name *uint16, CancelEvent *windows.Handle, Progress unsafe.Pointer, UserData unsafe.Pointer) (e error)

func DismRemoveDriver

func DismRemoveDriver(Session uint32, DriverPath *uint16) (e error)

func DismRemovePackage

func DismRemovePackage(Session uint32, Identifier *uint16, PackageIdentifier *DismPackageIdentifier, CancelEvent *windows.Handle, Progress unsafe.Pointer, UserData unsafe.Pointer) (e error)

func DismShutdown

func DismShutdown() (e error)

Types

type DismLogLevel

type DismLogLevel uint32

DismLogLevel specifies the kind of information that is reported in the log file. Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismloglevel-enumeration

const (
	// DismLogErrors logs only errors.
	DismLogErrors DismLogLevel = 0
	// DismLogErrorsWarnings logs errors and warnings.
	DismLogErrorsWarnings DismLogLevel = 1
	// DismLogErrorsWarningsInfo logs errors, warnings, and additional information.
	DismLogErrorsWarningsInfo DismLogLevel = 2
)

type DismPackageIdentifier

type DismPackageIdentifier uint32

DismPackageIdentifier specifies whether a package is identified by name or by file path.

const (
	// DismPackageNone indicates that no package is specified.
	DismPackageNone DismPackageIdentifier = iota
	// DismPackageName indicates that the package is identified by its name.
	DismPackageName
	// DismPackagePath indicates that the package is specified by its path.
	DismPackagePath
)

type Session

type Session struct {
	Handle *uint32
	// contains filtered or unexported fields
}

Session holds a dism session. You must call Close() to free up the session upon completion.

func OpenSession

func OpenSession(imagePath, optWindowsDir, optSystemDrive string, logLevel DismLogLevel, optLogFilePath, optScratchDir string) (Session, error)

OpenSession opens a DISM session. The session can be used for subsequent DISM calls.

Don't forget to call Close() on the returned Session object.

Example, modifying the online image:

dism.OpenSession(dism.DISM_ONLINE_IMAGE, "", "", dism.DismLogErrorsWarningsInfo, "", "")

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/disminitialize-function Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismopensession-function

func (Session) AddCapability

func (s Session) AddCapability(
	name string,
	limitAccess bool,
	sourcePaths string,
	sourcePathsCount uint32,
	cancelEvent *windows.Handle,
	progressCallback unsafe.Pointer,
) error

AddCapability adds a Windows capability from an image.

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismaddcapability

func (Session) AddPackage

func (s Session) AddPackage(
	packagePath string,
	ignoreCheck bool,
	preventPending bool,
	cancelEvent *windows.Handle,
	progressCallback unsafe.Pointer,
) error

AddPackage adds Windows packages(s) to an image.

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismaddpackage-function

func (Session) Close

func (s Session) Close() error

Close closes the session and shuts down dism. This must be called prior to exiting.

func (Session) DisableFeature

func (s Session) DisableFeature(
	feature string,
	optPackageName string,
	cancelEvent *windows.Handle,
	progressCallback unsafe.Pointer,
) error

DisableFeature disables Windows Feature(s).

To disable multiple features, separate each feature name with a semicolon.

May return the error windows.ERROR_SUCCESS_REBOOT_REQUIRED if a reboot is required to complete the operation.

Example, disabling a feature:

s.DisableFeature("SMB1Protocol", "", nil, nil)

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismdisablefeature-function

func (Session) EnableFeature

func (s Session) EnableFeature(
	feature string,
	optIdentifier string,
	optPackageIdentifier *DismPackageIdentifier,
	enableAll bool,
	cancelEvent *windows.Handle,
	progressCallback unsafe.Pointer,
) error

EnableFeature enables Windows Feature(s).

To enable multiple features, separate each feature name with a semicolon.

May return the error windows.ERROR_SUCCESS_REBOOT_REQUIRED if a reboot is required to complete the operation.

Example, enabling a feature, including all dependencies:

s.EnableFeature("SMB1Protocol", "", nil, true, nil, nil)

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismenablefeature-function

func (Session) RemoveCapability

func (s Session) RemoveCapability(
	name string,
	cancelEvent *windows.Handle,
	progressCallback unsafe.Pointer,
) error

RemoveCapability removes a Windows capability from an image.

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismremovecapability

func (Session) RemovePackage

func (s Session) RemovePackage(
	identifier string,
	packageIdentifier *DismPackageIdentifier,
	cancelEvent *windows.Handle,
	progressCallback unsafe.Pointer,
) error

RemovePackage removes Windows packages(s) from an image.

Ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismremovepackage-function

Jump to

Keyboard shortcuts

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