+static const char wincfg[] =
+"[ExclusionList]\n"
+"/$ntfs.log\n"
+"/hiberfil.sys\n"
+"/pagefile.sys\n"
+"/System Volume Information\n"
+"/RECYCLER\n"
+"/Windows/CSC\n";
+
+static const tchar *wimboot_cfgfile =
+ T("/Windows/System32/WimBootCompress.ini");
+
+static int
+get_capture_config(const tchar *config_file, struct capture_config *config,
+ int add_flags, const tchar *fs_source_path)
+{
+ int ret;
+ tchar *tmp_config_file = NULL;
+
+ memset(config, 0, sizeof(*config));
+
+ /* For WIMBoot capture, check for default capture configuration file
+ * unless one was explicitly specified. */
+ if (!config_file && (add_flags & WIMLIB_ADD_FLAG_WIMBOOT)) {
+
+ /* XXX: Handle loading file correctly when in NTFS volume. */
+
+ size_t len = tstrlen(fs_source_path) +
+ tstrlen(wimboot_cfgfile);
+ tmp_config_file = MALLOC((len + 1) * sizeof(tchar));
+ struct stat st;
+
+ tsprintf(tmp_config_file, T("%"TS"%"TS),
+ fs_source_path, wimboot_cfgfile);
+ if (!tstat(tmp_config_file, &st)) {
+ config_file = tmp_config_file;
+ add_flags &= ~WIMLIB_ADD_FLAG_WINCONFIG;
+ } else {
+ WARNING("\"%"TS"\" does not exist.\n"
+ " Using default capture configuration!",
+ tmp_config_file);
+ }
+ }
+
+ if (add_flags & WIMLIB_ADD_FLAG_WINCONFIG) {
+ /* Use Windows default. */
+ if (config_file)
+ return WIMLIB_ERR_INVALID_PARAM;
+ ret = do_read_capture_config_file(T("wincfg"), wincfg,
+ sizeof(wincfg) - 1, config);
+ } else if (config_file) {
+ /* Use the specified configuration file. */
+ ret = do_read_capture_config_file(config_file, NULL, 0, config);
+ } else {
+ /* ... Or don't use any configuration file at all. No files
+ * will be excluded from capture, all files will be compressed,
+ * etc. */
+ ret = 0;
+ }
+ FREE(tmp_config_file);
+ return ret;
+}
+
+static int
+replace_wimboot_cfg(WIMStruct *wim, const tchar *config_file)
+{
+ struct wimlib_update_command cmds[] = {
+ {
+ .op = WIMLIB_UPDATE_OP_DELETE,
+ .delete_ = {
+ .wim_path = (tchar *)wimboot_cfgfile,
+ .delete_flags = WIMLIB_DELETE_FLAG_FORCE |
+ WIMLIB_DELETE_FLAG_RECURSIVE,
+ },
+ },
+ {
+ .op = WIMLIB_UPDATE_OP_ADD,
+ .add = {
+ .fs_source_path = (tchar *)config_file,
+ .wim_target_path = (tchar *)wimboot_cfgfile,
+ .add_flags = 0,
+ .config_file = NULL,
+ },
+ },
+ };
+ return wimlib_update_image(wim, wim->current_image,
+ cmds, ARRAY_LEN(cmds), 0, NULL);
+}
+