+pwrite_to_handle(HANDLE h, const void *data, size_t size, u64 offset)
+{
+ const void * const end = data + size;
+ const void *p;
+ IO_STATUS_BLOCK iosb;
+ NTSTATUS status;
+
+ for (p = data; p != end; p += iosb.Information,
+ offset += iosb.Information)
+ {
+ LARGE_INTEGER offs = { .QuadPart = offset };
+
+ status = NtWriteFile(h, NULL, NULL, NULL, &iosb,
+ (void *)p, min(INT32_MAX, end - p),
+ &offs, NULL);
+ if (!NT_SUCCESS(status)) {
+ winnt_error(status,
+ L"Error writing data to target volume");
+ return WIMLIB_ERR_WRITE;
+ }
+ }
+ return 0;
+}
+
+/* Called when the next chunk of a blob has been read for extraction */
+static int
+win32_extract_chunk(const struct blob_descriptor *blob, u64 offset,
+ const void *chunk, size_t size, void *_ctx)