It looks to me as though "filename_to_utf16" is not returning utf16 data (which is what it sounds like it should do):
No, sorry. I didn't notice the L prefix:
(gdb) p rootname_w $2 = L"c:\\\0[...]"
... which is correct.
Perhaps some problem with type-punning LARGE_INTEGER/ULARGE_INTEGER under -fstrict-aliasing. I can't say I understand that stuff very well, and I admit it doesn't seem very likely, but I'll see if I can get it to work without the casting.