WINDOWS_NATIVE_BUILD="yes"
VISIBILITY_CFLAGS=""
WINDOWS_CFLAGS="-municode"
- WINDOWS_CPPFLAGS="-D_POSIX"
+ WINDOWS_CPPFLAGS="-D_POSIX -DUNICODE -D_UNICODE"
WINDOWS_LDFLAGS="-no-undefined"
WINDOWS_LDADD="-lshlwapi"
;;
}
static bool
-win32_modify_privilege(const char *privilege, bool enable)
+win32_modify_privilege(const wchar_t *privilege, bool enable)
{
HANDLE hToken;
LUID luid;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken))
- {
goto out;
- }
- if (!LookupPrivilegeValue(NULL, privilege, &luid)) {
+ if (!LookupPrivilegeValueW(NULL, privilege, &luid))
goto out;
- }
newState.PrivilegeCount = 1;
newState.Privileges[0].Luid = luid;
lte.resource_entry.size = buf_size;
lte.resource_entry.offset = 0;
lte.resource_location = RESOURCE_IN_ATTACHED_BUFFER;
- lte.attached_buffer = buf;
+ lte.attached_buffer = (void*)buf;
zero_out_hash(lte.hash);
ret = write_wim_resource(<e, out_fp, out_ctype, out_res_entry, 0);
}
if (w->hdr.part_number != 1) {
ERROR("WIM `%"TS"' is not the first part of the split WIM.",
- T(w->filename));
+ w->filename);
return WIMLIB_ERR_SPLIT_INVALID;
}
for (unsigned i = 0; i < num_additional_swms; i++) {
win32_extract_chunk, hStream);
}
+static bool
+path_is_root_of_drive(const wchar_t *path)
+{
+ if (!*path)
+ return false;
+
+ if (*path != L'/' && *path != L'\\') {
+ if (*(path + 1) == L':')
+ path += 2;
+ else
+ return false;
+ }
+ while (*path == L'/' || *path == L'\\')
+ path++;
+ return (*path == L'\0');
+}
+
static int
win32_extract_stream(const struct wim_inode *inode,
const wchar_t *path,
if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) {
if (!CreateDirectoryW(stream_path, secattr)) {
err = GetLastError();
- if (err != ERROR_ALREADY_EXISTS) {
+ switch (err) {
+ case ERROR_ALREADY_EXISTS:
+ break;
+ case ERROR_ACCESS_DENIED:
+ if (path_is_root_of_drive(path))
+ break;
+ /* Fall through */
+ default:
ERROR("Failed to create directory \"%ls\"",
stream_path);
win32_error(err);