* fhandler.cc (fhandler_base::open): Drop local wpath and upath
variables. Call pc.get_object_attr to create object attributes. * fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto. * syscalls.cc (unlink_nt): Ditto. * path.cc (path_conv::set_normalized_path): Set wide_path to NULL. (path_conv::get_nt_native_path): Drop parameter. Create path in wide_path/uni_path members. (path_conv::get_object_attr): New method to create object attributes. (path_conv::get_wide_win32_path): New method to create Win32 wide path. (path_conv::check): Initialize wide_path to NULL. (path_conv::~path_conv): cfree wide_path. * path.h (class path_conv): New members wide_path and uni_path. Add declarations of get_object_attr and get_wide_win32_path. (path_conv::path_conv): Initialize wide_path to NULL. (path_conv::get_nt_native_path): Drop parameter.
This commit is contained in:
@@ -79,6 +79,7 @@ details. */
|
||||
#include "environ.h"
|
||||
#include <assert.h>
|
||||
#include <ntdll.h>
|
||||
#include <wchar.h>
|
||||
|
||||
bool dos_file_warning = true;
|
||||
static int normalize_win32_path (const char *, char *, char *&);
|
||||
@@ -539,6 +540,7 @@ path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
|
||||
}
|
||||
|
||||
memcpy (normalized_path, path_copy, n);
|
||||
wide_path = NULL;
|
||||
}
|
||||
|
||||
PUNICODE_STRING
|
||||
@@ -566,9 +568,40 @@ get_nt_native_path (const char *path, UNICODE_STRING &upath)
|
||||
}
|
||||
|
||||
PUNICODE_STRING
|
||||
path_conv::get_nt_native_path (UNICODE_STRING &upath)
|
||||
path_conv::get_nt_native_path ()
|
||||
{
|
||||
return ::get_nt_native_path (path, upath);
|
||||
if (!wide_path)
|
||||
{
|
||||
uni_path.Length = 0;
|
||||
uni_path.MaximumLength = (strlen (path) + 10) * sizeof (WCHAR);
|
||||
wide_path = (PWCHAR) cmalloc (HEAP_STR, uni_path.MaximumLength);
|
||||
uni_path.Buffer = wide_path;
|
||||
::get_nt_native_path (path, uni_path);
|
||||
}
|
||||
return &uni_path;
|
||||
}
|
||||
|
||||
POBJECT_ATTRIBUTES
|
||||
path_conv::get_object_attr (OBJECT_ATTRIBUTES &attr, SECURITY_ATTRIBUTES &sa)
|
||||
{
|
||||
if (!get_nt_native_path ())
|
||||
return NULL;
|
||||
InitializeObjectAttributes (&attr, &uni_path,
|
||||
OBJ_CASE_INSENSITIVE
|
||||
| (sa.bInheritHandle ? OBJ_INHERIT : 0),
|
||||
NULL, sa.lpSecurityDescriptor);
|
||||
return &attr;
|
||||
}
|
||||
|
||||
PWCHAR
|
||||
path_conv::get_wide_win32_path (PWCHAR wc)
|
||||
{
|
||||
get_nt_native_path ();
|
||||
if (!wide_path || wide_path[1] != L'?') /* Native NT device path */
|
||||
return NULL;
|
||||
wcscpy (wc, wide_path);
|
||||
wc[1] = L'\\';
|
||||
return wc;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -640,6 +673,7 @@ path_conv::check (const char *src, unsigned opt,
|
||||
path_flags = 0;
|
||||
known_suffix = NULL;
|
||||
fileattr = INVALID_FILE_ATTRIBUTES;
|
||||
wide_path = NULL;
|
||||
case_clash = false;
|
||||
memset (&dev, 0, sizeof (dev));
|
||||
fs.clear ();
|
||||
@@ -1147,6 +1181,11 @@ path_conv::~path_conv ()
|
||||
cfree (normalized_path);
|
||||
normalized_path = NULL;
|
||||
}
|
||||
if (wide_path)
|
||||
{
|
||||
cfree (wide_path);
|
||||
wide_path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return true if src_path is a valid, internally supported device name.
|
||||
|
Reference in New Issue
Block a user