]> wimlib.net Git - wimlib/commitdiff
Win32 fixes
authorEric Biggers <ebiggers3@gmail.com>
Sun, 24 Mar 2013 01:21:41 +0000 (20:21 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 24 Mar 2013 01:21:41 +0000 (20:21 -0500)
configure.ac
programs/imagex-win32.c
src/metadata_resource.c
src/verify.c
src/win32.c

index 80ea8df2228e901d33b772637e396d3098628d04..13da4dd003cd2abf1338541f69d695be671a5fc5 100644 (file)
@@ -192,7 +192,7 @@ case "$host" in
                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"
                ;;
index 18581ed0d2603bd94442c18d2814372d7008b4cb..19aa92cf0bb2fcb64fb7c3773b507789170cd03a 100644 (file)
@@ -119,7 +119,7 @@ globfree(glob_t *pglob)
 }
 
 static bool
-win32_modify_privilege(const char *privilege, bool enable)
+win32_modify_privilege(const wchar_t *privilege, bool enable)
 {
        HANDLE hToken;
        LUID luid;
@@ -129,13 +129,10 @@ win32_modify_privilege(const char *privilege, bool enable)
        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;
index d54641de27a04dc31aea59a36992c5b07ac20651..a2ae93c6111eaaba7e03369dd16e81058b63ce9f 100644 (file)
@@ -213,7 +213,7 @@ write_wim_resource_from_buffer(const u8 *buf, u64 buf_size,
        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(&lte, out_fp, out_ctype, out_res_entry, 0);
index efaca0da1cff0b80abed84a2e81a0e442fbdc4e8..decd90c0387bab77de5c1518d40d39b13d97c0cb 100644 (file)
@@ -265,7 +265,7 @@ verify_swm_set(WIMStruct *w, WIMStruct **additional_swms,
        }
        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++) {
index dfa92ffd01169c6b86a18ddd919f4be696be810e..21225e2fce6b7c48b19e9550ed76d27c0e1df07c 100644 (file)
@@ -949,6 +949,23 @@ do_win32_extract_stream(HANDLE hStream, struct wim_lookup_table_entry *lte)
                                    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,
@@ -1013,7 +1030,14 @@ win32_extract_stream(const struct wim_inode *inode,
                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);