From 756c9d6dc2ba457820c7f479dee2612e6a6e4821 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Mon, 10 Oct 2011 12:14:12 +0000 Subject: [PATCH] [KERNEL32] - Properly copy image name in TH32CreateSnapshotSectionInitialize. Fixes truncated file names in kernel32:toolhelp test svn path=/trunk/; revision=54071 --- reactos/dll/win32/kernel32/client/toolhelp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/toolhelp.c b/reactos/dll/win32/kernel32/client/toolhelp.c index ca2f558bd27..0487726f3ce 100644 --- a/reactos/dll/win32/kernel32/client/toolhelp.c +++ b/reactos/dll/win32/kernel32/client/toolhelp.c @@ -409,9 +409,12 @@ TH32CreateSnapshotSectionInitialize(DWORD dwFlags, ProcessListEntry->dwFlags = 0; /* no longer used */ if(ProcessInfo->ImageName.Buffer != NULL) { - lstrcpynW(ProcessListEntry->szExeFile, - ProcessInfo->ImageName.Buffer, - min(ProcessInfo->ImageName.Length / sizeof(WCHAR), sizeof(ProcessListEntry->szExeFile) / sizeof(ProcessListEntry->szExeFile[0]))); + ULONG ExeFileLength = min(ProcessInfo->ImageName.Length, + sizeof(ProcessListEntry->szExeFile) - sizeof(WCHAR)); + RtlCopyMemory(ProcessListEntry->szExeFile, + ProcessInfo->ImageName.Buffer, + ExeFileLength); + ProcessListEntry->szExeFile[ExeFileLength / sizeof(WCHAR)] = UNICODE_NULL; } else { -- 2.17.1