win32_apply.c: Fallback to RtlDosPathNameToNtPathName_U()
authorEric Biggers <ebiggers3@gmail.com>
Thu, 22 May 2014 16:53:38 +0000 (11:53 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 22 May 2014 16:54:17 +0000 (11:54 -0500)
RtlDosPathNameToNtPathName_U_WithStatus() is not available on Windows XP.

include/wimlib/win32_common.h
src/win32_apply.c
src/win32_common.c

index d9a4ff3..2921caa 100644 (file)
@@ -128,6 +128,12 @@ typedef struct _RTL_RELATIVE_NAME_U {
        PRTLP_CURDIR_REF CurDirRef;
 } RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U;
 
+extern BOOLEAN (WINAPI *func_RtlDosPathNameToNtPathName_U)
+               (IN PCWSTR DosName,
+                OUT PUNICODE_STRING NtName,
+                OUT PCWSTR *PartName,
+                OUT PRTL_RELATIVE_NAME_U RelativeName);
+
 extern NTSTATUS (WINAPI *func_RtlDosPathNameToNtPathName_U_WithStatus)
                (IN PCWSTR DosName,
                 OUT PUNICODE_STRING NtName,
index ee45acb..fcb2c00 100644 (file)
@@ -517,9 +517,18 @@ prepare_target(struct list_head *dentry_list, struct win32_apply_ctx *ctx)
 
        /* Open handle to the target directory (possibly creating it).  */
 
-       status = (*func_RtlDosPathNameToNtPathName_U_WithStatus)(ctx->common.target,
-                                                                &ctx->target_ntpath,
-                                                                NULL, NULL);
+       if (func_RtlDosPathNameToNtPathName_U_WithStatus) {
+               status = (*func_RtlDosPathNameToNtPathName_U_WithStatus)(ctx->common.target,
+                                                                        &ctx->target_ntpath,
+                                                                        NULL, NULL);
+       } else {
+               if ((*func_RtlDosPathNameToNtPathName_U)(ctx->common.target,
+                                                        &ctx->target_ntpath,
+                                                        NULL, NULL))
+                       status = STATUS_SUCCESS;
+               else
+                       status = STATUS_NO_MEMORY;
+       }
        if (!NT_SUCCESS(status)) {
                if (status == STATUS_NO_MEMORY) {
                        return WIMLIB_ERR_NOMEM;
index 7f0521e..7016fe2 100644 (file)
@@ -469,6 +469,12 @@ NTSTATUS (WINAPI *func_NtClose) (HANDLE Handle);
 
 DWORD (WINAPI *func_RtlNtStatusToDosError)(NTSTATUS status);
 
+BOOLEAN (WINAPI *func_RtlDosPathNameToNtPathName_U)
+                 (IN PCWSTR DosName,
+                  OUT PUNICODE_STRING NtName,
+                  OUT PCWSTR *PartName,
+                  OUT PRTL_RELATIVE_NAME_U RelativeName);
+
 NTSTATUS (WINAPI *func_RtlDosPathNameToNtPathName_U_WithStatus)
                (IN PCWSTR DosName,
                 OUT PUNICODE_STRING NtName,
@@ -526,7 +532,8 @@ struct dll_spec ntdll_spec = {
                DLL_SYM(NtClose, true),
                DLL_SYM(RtlNtStatusToDosError, true),
                DLL_SYM(RtlCreateSystemVolumeInformationFolder, false),
-               DLL_SYM(RtlDosPathNameToNtPathName_U_WithStatus, true),
+               DLL_SYM(RtlDosPathNameToNtPathName_U, true),
+               DLL_SYM(RtlDosPathNameToNtPathName_U_WithStatus, false), /* Not present on XP  */
                {NULL, NULL},
        },
 };