/*
* Copyright (C) 2013, 2014 Eric Biggers
*
- * This file is part of wimlib, a library for working with WIM files.
+ * This file is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option) any
+ * later version.
*
- * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * This file is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
- * You should have received a copy of the GNU General Public License
- * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this file; if not, see http://www.gnu.org/licenses/.
*/
#ifdef __WIN32__
#include "wimlib/reparse.h"
#include "wimlib/textfile.h"
#include "wimlib/xml.h"
+#include "wimlib/wildcard.h"
#include "wimlib/wimboot.h"
struct win32_apply_ctx {
return 0;
}
-/* Returns %true if the path to @dentry matches a pattern in [PrepopulateList]
- * of WimBootCompress.ini. Otherwise returns %false.
- *
- * @dentry must have had its full path calculated. */
+/* Returns %true if the specified absolute path to a file in the WIM image
+ * matches a pattern in [PrepopulateList] of WimBootCompress.ini. Otherwise
+ * returns %false. */
static bool
-in_prepopulate_list(struct wim_dentry *dentry,
+in_prepopulate_list(const wchar_t *path, size_t path_nchars,
const struct win32_apply_ctx *ctx)
{
const struct string_set *pats = ctx->wimboot.prepopulate_pats;
if (!pats || !pats->num_strings)
return false;
- return match_pattern_list(dentry->_full_path,
- wcslen(dentry->_full_path), pats);
+ return match_pattern_list(path, path_nchars, pats);
+}
+
+/* Returns %true if the specified absolute path to a file in the WIM image can
+ * be subject to external backing when extracted. Otherwise returns %false. */
+static bool
+can_externally_back_path(const wchar_t *path, size_t path_nchars,
+ const struct win32_apply_ctx *ctx)
+{
+ if (in_prepopulate_list(path, path_nchars, ctx))
+ return false;
+
+ /* Since we attempt to modify the SYSTEM registry after it's extracted
+ * (see end_wimboot_extraction()), it can't be extracted as externally
+ * backed. This extends to associated files such as SYSTEM.LOG that
+ * also must be writable in order to write to the registry. Normally,
+ * SYSTEM is in [PrepopulateList], and the SYSTEM.* files match patterns
+ * in [ExclusionList] and therefore are not captured in the WIM at all.
+ * However, a WIM that wasn't specifically captured in "WIMBoot mode"
+ * may contain SYSTEM.* files. So to make things "just work", hard-code
+ * the pattern. */
+ if (match_path(path, path_nchars, L"\\Windows\\System32\\config\\SYSTEM*",
+ OS_PREFERRED_PATH_SEPARATOR, false))
+ return false;
+
+ return true;
}
static const wchar_t *
if (ret)
return ret;
- if (in_prepopulate_list(dentry, ctx))
+ if (!can_externally_back_path(dentry->_full_path,
+ wcslen(dentry->_full_path), ctx))
return WIM_BACKING_EXCLUDED;
return 0;