yalishandar / tasklist-rs

Get the process name or process id on windows
19 stars 3 forks source link

Null not handled on process names #5

Open FrostyCoolSlug opened 10 months ago

FrostyCoolSlug commented 10 months ago

Hi,

This is likely related to 714e5f1 and #3, in the current master, NULL characters aren't being correctly handled when creating the pname, so the following code:

let tasks = tasklist::Tasklist::new();
tasks.for_each(|task| println!("{}", task.get_pname()));

Will output tasks like: svchost.exe

So the process name, and enough null characters up to 260 characters, so looks like get_proc_name isn't handling the null termination correctly.

yalishandar commented 4 months ago

Sorry I replied late, because I have been busy at work recently. That is a very weird phenomenon, and I think you're right. In the past, I used std::ffi::OsString::from_wide(& name) in get_proc_name function,now I have changed it to String::from_utf16_lossy(&name)