+const tchar wincfg[] =
+T(
+"[ExclusionList]\n"
+"/$ntfs.log\n"
+"/hiberfil.sys\n"
+"/pagefile.sys\n"
+"/System Volume Information\n"
+"/RECYCLER\n"
+"/Windows/CSC\n"
+);
+
+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. */
+
+ const tchar *wimboot_cfgfile =
+ T("/Windows/System32/WimBootCompress.ini");
+ 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. */
+
+ tchar *wincfg_copy;
+ const size_t wincfg_len = ARRAY_LEN(wincfg) - 1;
+
+ if (config_file)
+ return WIMLIB_ERR_INVALID_PARAM;
+
+ wincfg_copy = memdup(wincfg, wincfg_len * sizeof(wincfg[0]));
+ if (!wincfg_copy)
+ return WIMLIB_ERR_NOMEM;
+
+ ret = do_read_capture_config_file(T("wincfg"), wincfg_copy,
+ wincfg_len, config);
+ if (ret)
+ FREE(wincfg_copy);
+ } 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;
+}
+