Alexandre Julliard : ntdll: Avoid using RtlDosPathNameToNtPathName_U() in the Unix library.
Alexandre Julliard
julliard at winehq.org
Fri Jul 10 16:30:30 CDT 2020
Module: wine
Branch: master
Commit: bcc3410732c60e32eaf3abd808be7482218f57d7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bcc3410732c60e32eaf3abd808be7482218f57d7
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Jul 10 07:58:14 2020 +0200
ntdll: Avoid using RtlDosPathNameToNtPathName_U() in the Unix library.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/process.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index 8a4da2cd55..67450fdb3d 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -476,6 +476,10 @@ static ULONG get_env_size( const RTL_USER_PROCESS_PARAMETERS *params, char **win
*/
static int get_unix_curdir( const RTL_USER_PROCESS_PARAMETERS *params )
{
+ static const WCHAR ntprefixW[] = {'\\','?','?','\\',0};
+ static const WCHAR uncprefixW[] = {'U','N','C','\\',0};
+ const UNICODE_STRING *curdir = ¶ms->CurrentDirectory.DosPath;
+ const WCHAR *dir = curdir->Buffer;
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
@@ -483,13 +487,27 @@ static int get_unix_curdir( const RTL_USER_PROCESS_PARAMETERS *params )
HANDLE handle;
int fd = -1;
- if (!RtlDosPathNameToNtPathName_U( params->CurrentDirectory.DosPath.Buffer, &nt_name, NULL, NULL ))
- return -1;
+ if (!(nt_name.Buffer = malloc( curdir->Length + 8 * sizeof(WCHAR) ))) return -1;
+
+ /* simplified version of RtlDosPathNameToNtPathName_U */
+ wcscpy( nt_name.Buffer, ntprefixW );
+ if (dir[0] == '\\' && dir[1] == '\\')
+ {
+ if ((dir[2] == '.' || dir[2] == '?') && dir[3] == '\\') dir += 4;
+ else
+ {
+ wcscat( nt_name.Buffer, uncprefixW );
+ dir += 2;
+ }
+ }
+ wcscat( nt_name.Buffer, dir );
+ nt_name.Length = wcslen( nt_name.Buffer ) * sizeof(WCHAR);
+
InitializeObjectAttributes( &attr, &nt_name, OBJ_CASE_INSENSITIVE, 0, NULL );
status = NtOpenFile( &handle, FILE_TRAVERSE | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
- RtlFreeUnicodeString( &nt_name );
+ free( nt_name.Buffer );
if (status) return -1;
server_handle_to_fd( handle, FILE_TRAVERSE, &fd, NULL );
NtClose( handle );
More information about the wine-cvs
mailing list