hi
I want to printout UNICODE_STRING in the user-mode.
This is my code
typedef struct _FILE_INFO {
UNICODE_STRING ParentDir;
UNICODE_STRING Extension;
UNICODE_STRING Volume;
UNICODE_STRING Name;
} FILE_INFO, *PFILE_INFO;
…
PFILE_INFO openedFile;
…
printf(“%s\n”,&openedFile->Name.Buffer);
printf(“%s\n”,&openedFile->Extension.Buffer);
printf(“%s\n”,&openedFile->ParentDir.Buffer);
printf(“%s\n”,&openedFile->Volume.Buffer);
and the output is
ì╜¿
╚ì╜¿.
Nì╜¿
ì╜¿«
how can i transform it? or wher am i doing it wrong?
thanks
mm1
March 28, 2011, 3:19pm
2
You’re trying to print it as ANSI. You need to use “%S” (capital ‘S’).
The buffer is not necessarily null terminated. You need to do something like
Printf(“%.*S\n”, openedFiled->Name.Length, openedFile->Name.Buffer);
Good luck,
mm
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com ] On Behalf Of Michal Pandošcák
Sent: Monday, March 28, 2011 3:10 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] UNICODE_STRING
hi
I want to printout UNICODE_STRING in the user-mode.
This is my code
typedef struct _FILE_INFO {
UNICODE_STRING ParentDir;
UNICODE_STRING Extension;
UNICODE_STRING Volume;
UNICODE_STRING Name;
} FILE_INFO, *PFILE_INFO;
…
PFILE_INFO openedFile;
…
printf(“%s\n”,&openedFile->Name.Buffer);
printf(“%s\n”,&openedFile->Extension.Buffer);
printf(“%s\n”,&openedFile->ParentDir.Buffer);
printf(“%s\n”,&openedFile->Volume.Buffer);
and the output is
ì╜¿
╚ì╜¿.
Nì╜¿
ì╜¿«
how can i transform it? or wher am i doing it wrong?
thanks
— NTFSD is sponsored by OSR For our schedule of debugging and file system seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
UNICODE_STRING as name suggests are in unicode format.
You will have to use printf like this - printf(“%*S*\n”, buffer); (notice
the capital S)
UNICODE_STRING’s buffer are not null terminated, so your code might
crash.
UNICODE_STRING are counted strings, copy the string to local buffer and
null terminate it.
-Deepak
On Tue, Mar 29, 2011 at 12:40 AM, Michal Pandoščák <
xxxxx@gmail.com > wrote:
hi
I want to printout UNICODE_STRING in the user-mode.
This is my code
typedef struct _FILE_INFO {
UNICODE_STRING ParentDir;
UNICODE_STRING Extension;
UNICODE_STRING Volume;
UNICODE_STRING Name;
} FILE_INFO, *PFILE_INFO;
…
PFILE_INFO openedFile;
…
printf(“%s\n”,&openedFile->Name.Buffer);
printf(“%s\n”,&openedFile->Extension.Buffer);
printf(“%s\n”,&openedFile->ParentDir.Buffer);
printf(“%s\n”,&openedFile->Volume.Buffer);
and the output is
ì╜¿
╚ì╜¿.
Nì╜¿
ì╜¿«
how can i transform it? or wher am i doing it wrong?
thanks
— NTFSD is sponsored by OSR For our schedule of debugging and file system
seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List
Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
%wZ and pass PUNICODE_STRING as the parameter (ie &openedFile->Name), not Buffer
d