Expand description
§wimlib
These are wimlib Rust bindings. wimlib is a C library for creating, modifying, extracting and mounting files in the Windows Imaging Format (WIM files). It provides a free and corss-platform alternative to Microsoft’s WIMGAPI, ImageX and DISM.
C library link: https://wimlib.net
§Basic WIM handling concepts
Wimlib bindings wrap up a WIM file in a opaque Wim
type. There are two
ways to create its instance
WimLib::open_wim
opens an on-disk WIM file and creates aWim
for itWimLib::create_new_wim
creates a newWim
that initially contains no images and does not yet have a backing on-disk file
Wim
contains zero or more independent directory trees called images.
Images may be extracted, added, deleted, exported, and updated using various
API functions. You can select these images using Wim::select_image
and
Wim::select_all_images
as most of methods using them are under structure
Image
.
Changes made to a WIM represented by a Wim
have no persistent effect
until the WIM is actually written to an on-disk file. This can be done using
Image::write
, but if the WIM was originally opened using
WimLib::open_wim
, then Wim::overwrite
can be used instead.
wimlib’s API is designed to let you combine functions to accomplish tasks in a flexible way. Here are some example sequences of function calls:
Apply an image from a WIM file, similar to the command-line program wimapply
Capture an image into a new WIM file, similar to wimcapture:
Append an image to an existing WIM file, similar to wimappend:
Delete an image from an existing WIM file, similar to wimdelete:
Export an image from one WIM file to another, similar to wimexport:
WimLib::open_wim
(on source)WimLib::open_wim
(on destination)Image::export
Wim::overwrite
(on destination)
The API also lets you do things the command-line tools don’t directly allow.
For example, you could make multiple changes to a WIM before efficiently
committing the changes with just one call to Wim::overwrite
. Perhaps you
want to both delete an image and add a new one; or perhaps you want to
customize an image with Wim::overwrite
after adding it. All these use
cases are supported by the API.
You can also visit documentation of modules in wim module for detailed documentation of certain scopes.
§Additional information and features
§Mounting WIM images
See Mounting WIM images.
§Progress Messages
§Non-standalone WIMs
See Creating and handling non-standalone WIMSs.
§Pipable WIMs
wimlib supports a special »pipable« WIM format which unfortunately is not
compatible with Microsoft’s software. To create a pipable WIM, call
Image::write
, Image::write_to_file
, or Wim::overwrite
with
WriteFlags::PIPABLE
specified. Pipable WIMs are pipable in both
directions, so Image::write_to_file
can be used to write a pipable WIM
to a pipe, and WimLib::extract_image_from_pipe
can be used to apply an
image from a pipable WIM. wimlib can also transparently open and operate on
pipable WIM s using a seekable file descriptor using the regular function
calls (e.g. WimLib::open_wim
, Image::extract
).
See the documentation for the –pipable
flag of wimcapture
for more
information about pipable WIMs.
§Custom allocation functions
WimLib allows settings custom allocator functions. I would really like to
make wimlib
bindings support this feature, especially by
automatically hooking that to users global allocator, but…
-
It uses C-style allocation APIs, which are very basic compared to Rusts and inherently incompatible. Rust’s allocation APIs require knowing
Layout
. which includes alignment.malloc
requires only size. For dallocation memory, C’s API is even more basic. Just provide a pointer. No size, no alignment. This can be bypassed by having some fixed alignment and allocating a bit more to store the size information and return shifted pointer. Tried this and it lead me to… -
wimlib
callslibc
’srealpath
. That one allocates usinglibc
’s allocation facilities (malloc
) butwimlib
then deallocates the memory by user provided deallocation function. And as my deallocation trick shifted pointer back to the header and tried to read it, it made Address-san sad (of course it did). I could possibly try to do evil things like catchSIGSEGV
and then try again withlibc::free
. Or somehow hook the library and overridelibc
’s allocation facilities. But I am (at least for now) not willing to risk such fragile solution.
Re-exports§
pub use wimlib_sys as sys;
Modules§
- progress
- Track the progress of long WIM operations
- string
- WimLib is made to support both UTF-8 and UTF-16, depending on platform
- wim
- Most of the interfaces live in here. Manipulating WIMs
Macros§
- tstr
- Create a new
crate::string::TStr
from literal
Structs§
- AddFlags
- Flags related to operations of adding items to the WIM
- Delete
Flags - Flags related to operations of deleting items from the WIM
- DirEntry
- Structure passed to the
Image::iterate_dir_tree
’s callback function - Export
Flags - Flags related to exporting image to another WIM
- Extract
Flags - Flags to configure extraction methods for
Image
- File
Attributes - File attributes are metadata values stored by the file system on disk and are used by the system and are available to developers via various file I/O APIs. For a list of related APIs and topics, see the See also section.
- Image
- Selected WIM image
- Init
Flags - Flags for initialising the library using
WimLib::try_init
- Iterate
DirTree Flags - Flags for
Image::iterate_dir_tree
- Iterate
Lookup Table Flags - Flags for [
Wim::interate_lookup_table
]; empty, reserved for future use - Lazy
Stream Entry - Unresolved stream entry
- Object
Id - An object ID, which is an extra piece of metadata that may be associated with a file on NTFS filesystems
- Open
Flags - Flags related to
WimLib::open_wim
- Reference
Flags - Resource reference flags
- Reference
Template Image Flags - Reference template file flags – currently unused
- Rename
Flags - Item rename flags – currently unused
- Resource
Entry - Information about a “blob”, which is a fixed length sequence of binary data
- Resource
WimRef - Wim resource reference
- SetInfo
- Builder for
Wim::set_info
- Source
Target Pair - Pair of source and target for
Wim::add_image_multisource
- Stream
Entry - Information about a stream of a particular file in the WIM
- Update
Command - Specification of an update to perform on a WIM image
- Update
Flags - Flags related to updating items in file
- Wim
- Structure that contains opaque structure reference representing WIM and an optional progress callback pointer.
- WimInfo
- General information about a WIM file
- WimLib
- A zero-sized type which guards the resources by counting global refernece counter
- Write
Flags - Flags for writing image
Enums§
- Compression
Type - Specifies a compression type
- Error
- Possible values of the error code returned by many functions in wimlib
- Reparse
Tag - A unique identifier for a file system filter driver stored within a file’s optional reparse point data that indicates the file system filter driver that performs additional filter-defined processing on a file during I/O operations.
- TryInit
Error - Error returned when tried to initialise WimLib
Constants§
- ALL_
IMAGES - All images index
Functions§
- version
- Return the version of wimlib
Type Aliases§
- Image
Index - Index for an image in a WIM