From 0601cb87f221950f93feac8fc23cc6bd3946606a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Mon, 15 Jul 2024 21:08:44 +0200 Subject: [PATCH] Fix issue in log for NtQueryObject when name is not present. --- src/usvfs_dll/hooks/ntdll.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/usvfs_dll/hooks/ntdll.cpp b/src/usvfs_dll/hooks/ntdll.cpp index 288905a..4286a7b 100644 --- a/src/usvfs_dll/hooks/ntdll.cpp +++ b/src/usvfs_dll/hooks/ntdll.cpp @@ -1124,22 +1124,28 @@ DLLEXPORT NTSTATUS WINAPI usvfs::hook_NtQueryObject( // update the actual unicode string info->Name.Buffer = unicodeBuffer; - info->Name.Length = buffer.size() * 2; - info->Name.MaximumLength = unicodeBufferLength; + info->Name.Length = static_cast(buffer.size() * 2); + info->Name.MaximumLength = static_cast(unicodeBufferLength); res = STATUS_SUCCESS; } } - LOG_CALL() - .PARAMWRAP(res) - .PARAM(ObjectInformationLength) - .addParam("return_length", ReturnLength ? *ReturnLength : -1) - .addParam("tracker_path", trackerInfo) - .PARAM(ObjectInformationClass) - .PARAM(redir.redirected) - .PARAM(redir.path) - .addParam("name_info", info->Name); + auto logger = LOG_CALL() + .PARAMWRAP(res) + .PARAM(ObjectInformationLength) + .addParam("return_length", ReturnLength ? *ReturnLength : -1) + .addParam("tracker_path", trackerInfo) + .PARAM(ObjectInformationClass) + .PARAM(redir.redirected) + .PARAM(redir.path); + + if (res == STATUS_SUCCESS) { + logger.addParam("name_info", info->Name); + } + else { + logger.addParam("name_info", ""); + } } HOOK_END