#Converting WIDE string data returned by Windows API

13 messages · Page 1 of 1 (latest)

dire gazelle
#

The last three characters seem completely random, or at least not text data. I'm guessing something happened to the bytes between being d:/русский_тест and being printed by rust. Pretty sure it should be UTF16.

#

yay memory unsafety

#

If you were getting random characters before, it's also possible that the corruption happening is random. I'm guessing it's either getting printed before the string is written, or after the string is overwritten, and if it happens to get timed right, you won't see it.

#

If you're getting it from a windows API, then either it has some unsafety that isn't being properly handled, or there's a bug in windows.

gloomy kelp
#

&mut x.as_ptr() looks weird

#

what's the full code?

#

it's not equivalent

#

this is pointer to pointer

#

this is just a pointer

#

because you're casting it to void*

#

it's basically

#

(void*)&x.as_ptr()

#

the second is just (void*)x.as_ptr()