[kernel] Remove unnecessary string copy

This commit is contained in:
Joel Linn
2022-02-24 22:38:55 +01:00
committed by Rick Gibbed
parent b625ef0a38
commit 38d589d1e0
5 changed files with 14 additions and 15 deletions

View File

@@ -614,8 +614,7 @@ dword_result_t NtOpenSymbolicLinkObject_entry(
auto object_name =
kernel_memory()->TranslateVirtual<X_ANSI_STRING*>(object_attrs->name_ptr);
std::string target_path =
util::TranslateAnsiString(kernel_memory(), object_name);
auto target_path = util::TranslateAnsiString(kernel_memory(), object_name);
// Enforce that the path is ASCII.
if (!IsValidPath(target_path, false)) {

View File

@@ -144,10 +144,10 @@ DECLARE_XBOXKRNL_EXPORT1(ObDereferenceObject, kNone, kImplemented);
dword_result_t ObCreateSymbolicLink_entry(pointer_t<X_ANSI_STRING> path_ptr,
pointer_t<X_ANSI_STRING> target_ptr) {
auto path = util::TranslateAnsiString(kernel_memory(), path_ptr);
auto target = util::TranslateAnsiString(kernel_memory(), target_ptr);
path = xe::utf8::canonicalize_guest_path(path);
target = xe::utf8::canonicalize_guest_path(target);
auto path = xe::utf8::canonicalize_guest_path(
util::TranslateAnsiString(kernel_memory(), path_ptr));
auto target = xe::utf8::canonicalize_guest_path(
util::TranslateAnsiString(kernel_memory(), target_ptr));
if (xe::utf8::starts_with(path, u8"\\??\\")) {
path = path.substr(4); // Strip the full qualifier