阅读:1070回复:2
一个关于文件结构的问题!!请大家帮助!!!
我使用了系统的结构_FILE_BOTH_DIR_INFORMATION
其中有两个变量是WCHAR FileName[1]; ULONG FileNameLength; 按照解释应该FileName是文件全名。 FileNameLength是文件名长度。 我使用下面的代码: PUNICODE_STRING uniFileName; PWSTR pTemp = (PWSTR)ExAllocatePool( NonPagedPool, 256); FileLength= ((PFILE_BOTH_DIR_INFORMATION)FileInformationBuffer)->FileNameLength; uniFileName = (PUNICODE_STRING)ExAllocatePool( NonPagedPool, sizeof( UNICODE_STRING)); uniFileName->Buffer = pTemp; RtlCopyMemory( uniFileName->Buffer, pFileInfo->FileName, FileLength); uniFileName->Length = (USHORT)FileLength; uniFileName->MaximumLength = (USHORT)FileLength; RtlUnicodeStringToAnsiString( &ansiDirName, uniFileName, TRUE); DbgPrint(\"uniFileName->Buffer = %S %d\\\\n\", uniFileName->Buffer,uniFileName->Length); DbgPrint(\"pFileInfo->FileName = %S %d\\\\n\", pFileInfo->FileName,FileLength); DbgPrint(\"ansiDirName.Buffer = %s %d\\\\n\", ansiDirName.Buffer,ansiDirName.Length); 向显示得到的结果,可是发现都是内容有差别!! 00000068 0.03064691 uniFileName->Buffer = Common Fy\\\\User\\\\S-1-5-21-436374069-1078145449-1957994488-1000_Classes\\\\CLSID\\\\{53BD6B4E-3780-4693-AFC3-7161C2F3EE9C}\\\\InProcServer32 16 00000069 0.03076089 pFileInfo->FileName = Common Files 16 00000070 0.03083157 ansiDirName.Buffer = Common F 8 显示的内容中,很明显00000069 0.03076089 pFileInfo->FileName = Common Files 16 是正确的,但是为什么FileNameLength不能准确的表示文件名的长度呢??? |
|
沙发#
发布于:2005-04-29 11:50
是不是说明_FILE_BOTH_DIR_INFORMATION结构中的FileNameLength不能很准确的表示出文件名称的长度呢???
|
|
板凳#
发布于:2005-04-29 14:16
问题搞定了!!! :D
|
|