阅读:886回复:2
一个奇怪的现象.
我使用函数ZwQueryDirectoryFile得到文件名称以后,想将这个文件名添加到路径的后面,可是使用下面的代码是,总是提示我的"存储太小",真是不知道为什么了?请高手帮助!!
RtlInitUnicodeString(&uniFileName,pFileInfo->FileName); RtlUnicodeStringToAnsiString(&ansiFileName,&uniFileName,TRUE); RtlUnicodeStringToAnsiString(&ansiDirName,&uniFileName,TRUE); RtlUpperString(&ansiFileName,&ansiDirName); TempFileName = (UNICODE_STRING *)ExAllocatePool(PagedPool,1024 ); RtlZeroMemory(TempFileName,1024 ); TempFileName->MaximumLength = 1024 ; RtlAnsiStringToUnicodeString(TempFileName,&ansiFileName,TRUE); DbgPrint("得到的 :%ws Len=%d\n",TempFileName->Buffer,TempFileName->MaximumLength); pFullPath = (UNICODE_STRING *)ExAllocatePool(PagedPool,1024 ); RtlZeroMemory(pFullPath,1024 ); pFullPath->MaximumLength = 1024 ; rc = ObQueryNameString(pFileObject,pFullPath,1024,&ActualLength); if(rc != STATUS_SUCCESS) { ExFreePool(&pFullPath); ObDereferenceObject(pFileObject); return rc; } //向查询文件添加文件名称 rc=RtlAppendUnicodeStringToString(pFullPath,TempFileName); if(rc != STATUS_SUCCESS) { DbgPrint("添加失败"); if(rc==STATUS_BUFFER_TOO_SMALL) { DbgPrint("存储太小"); } } |
|
沙发#
发布于:2004-05-31 15:42
在
//向查询文件添加文件名称 rc=RtlAppendUnicodeStringToString(pFullPath,TempFileName); 之前,你先把这句添上试一下: pFullPath->MaximumLength = (USHORT)(pFullPath->Length + TempFileName->Length + sizefo(UNICODE_NULL)); |
|
|
板凳#
发布于:2004-06-02 16:44
对的
sfilter里有例子的 |
|
|