I have to open a file using ZwOpenFile API. This is my requirement. When I set the path in object name parameter. I could see fields Length and maximumlength in the object name.
Length is just length of the path and I usually keep maximumlength as the value of Length.
It worked mostly, however some times it doesnot work. In some cases I solved it via maximumlength = length *2. Even this computation doesn’t work for few other cases.
I am very much puzzled with the Maximumlength value computation.
Can some one help.
Look at UNICODE_STRING structure definition: link
Length is wcslen(str.Buffer) * sizeof(WCHAR) == * 2
MaximumLength field may be Length + sizeof(WCHAR) == Length + 2
ZwOpenFile will not write to this string, so we shouldn’t care about capacity of string.