Convert FCB pathname from simple buffer to unicode string.
Please carefully review if I missed something
svn path=/trunk/; revision=62779
UNICODE_STRING ShortNameU;
UNICODE_STRING ShortNameU;
- WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
- WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
+ WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
+ UNICODE_STRING PathName; /* path+filename 260 max */
+ WCHAR PathNameBuffer[MAX_PATH]; /* Buffer for PathName */
WCHAR ShortNameBuffer[13];
LIST_ENTRY FcbListEntry;
WCHAR ShortNameBuffer[13];
LIST_ENTRY FcbListEntry;
- LARGE_INTEGER IndexNumber; /* HighPart: Parent directory start sector */
- /* LowPart: Directory record offset in the parent directory file */
+ LARGE_INTEGER IndexNumber; /* HighPart: Parent directory start sector */
+ /* LowPart: Directory record offset in the parent directory file */
LONG RefCount;
ULONG Flags;
LONG RefCount;
ULONG Flags;
}
/* construct absolute path name */
}
/* construct absolute path name */
- Length = (wcslen(Fcb->PathName) * sizeof(WCHAR)) +
+ Length = Fcb->PathName.Length +
sizeof(WCHAR) +
RelativeFileName->Length +
sizeof(WCHAR);
sizeof(WCHAR) +
RelativeFileName->Length +
sizeof(WCHAR);
return STATUS_INSUFFICIENT_RESOURCES;
}
return STATUS_INSUFFICIENT_RESOURCES;
}
- Status = RtlAppendUnicodeToString(AbsoluteFileName,
- Fcb->PathName);
+ Status = RtlAppendUnicodeStringToString(AbsoluteFileName,
+ &Fcb->PathName);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString(AbsoluteFileName);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString(AbsoluteFileName);
/* it's root : complete essentials fields then return ok */
RtlZeroMemory(Fcb, sizeof(FCB));
/* it's root : complete essentials fields then return ok */
RtlZeroMemory(Fcb, sizeof(FCB));
- Fcb->PathName[0] = '\\';
- Fcb->ObjectName = &Fcb->PathName[1];
+ Fcb->PathNameBuffer[0] = '\\';
+ Fcb->ObjectName = &Fcb->PathNameBuffer[1];
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
Fcb->Entry.FileFlags = 0x02; //FILE_ATTRIBUTE_DIRECTORY;
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
Fcb->Entry.FileFlags = 0x02; //FILE_ATTRIBUTE_DIRECTORY;
+ Fcb->PathName.Length = sizeof(WCHAR);
+ Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
+ Fcb->PathName.Buffer = Fcb->PathNameBuffer;
if (pDirIndex)
*pDirIndex = 0;
if (pOffset)
*pOffset = 0;
if (pDirIndex)
*pDirIndex = 0;
if (pOffset)
*pOffset = 0;
- DPRINT("CdfsFindFile: new Pathname %S, new Objectname %S)\n",Fcb->PathName, Fcb->ObjectName);
+ DPRINT("CdfsFindFile: new Pathname %wZ, new Objectname %S)\n",&Fcb->PathName, Fcb->ObjectName);
return STATUS_SUCCESS;
}
}
return STATUS_SUCCESS;
}
}
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
{
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
{
- if (Parent->PathName[0])
+ if (Parent->PathName.Buffer[0])
- len = wcslen(Parent->PathName);
- memcpy(Fcb->PathName, Parent->PathName, len*sizeof(WCHAR));
- Fcb->ObjectName=&Fcb->PathName[len];
- if (len != 1 || Fcb->PathName[0] != '\\')
+ len = Parent->PathName.Length / sizeof(WCHAR);
+ memcpy(Fcb->PathName.Buffer, Parent->PathName.Buffer, Parent->PathName.Length);
+ Fcb->PathName.Length = Parent->PathName.Length;
+ Fcb->ObjectName=&Fcb->PathName.Buffer[len];
+ if (len != 1 || Fcb->PathName.Buffer[0] != '\\')
{
Fcb->ObjectName[0] = '\\';
Fcb->ObjectName = &Fcb->ObjectName[1];
{
Fcb->ObjectName[0] = '\\';
Fcb->ObjectName = &Fcb->ObjectName[1];
- Fcb->ObjectName=Fcb->PathName;
+ Fcb->ObjectName=Fcb->PathName.Buffer;
Fcb->ObjectName[0]='\\';
Fcb->ObjectName=&Fcb->ObjectName[1];
}
Fcb->ObjectName[0]='\\';
Fcb->ObjectName=&Fcb->ObjectName[1];
}
- DPRINT("PathName '%S' ObjectName '%S'\n", Fcb->PathName, Fcb->ObjectName);
+ DPRINT("PathName '%wZ' ObjectName '%S'\n", &Fcb->PathName, Fcb->ObjectName);
memcpy(&Fcb->Entry, Record, sizeof(DIR_RECORD));
wcsncpy(Fcb->ObjectName, name, min(wcslen(name) + 1,
memcpy(&Fcb->Entry, Record, sizeof(DIR_RECORD));
wcsncpy(Fcb->ObjectName, name, min(wcslen(name) + 1,
- MAX_PATH - wcslen(Fcb->PathName) + wcslen(Fcb->ObjectName)));
+ MAX_PATH - (Fcb->PathName.Length / sizeof(WCHAR)) + wcslen(Fcb->ObjectName)));
/* Copy short name */
Fcb->ShortNameU.Length = ShortName.Length;
/* Copy short name */
Fcb->ShortNameU.Length = ShortName.Length;
if (pOffset)
*pOffset = Offset;
if (pOffset)
*pOffset = Offset;
- DPRINT("FindFile: new Pathname %S, new Objectname %S, DirIndex %u\n",
- Fcb->PathName, Fcb->ObjectName, DirIndex);
+ DPRINT("FindFile: new Pathname %wZ, new Objectname %S, DirIndex %u\n",
+ &Fcb->PathName, Fcb->ObjectName, DirIndex);
RtlFreeUnicodeString(&FileToFindUpcase);
CcUnpinData(Context);
RtlFreeUnicodeString(&FileToFindUpcase);
CcUnpinData(Context);
DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
+ TempFcb.PathName.Buffer = TempFcb.PathNameBuffer;
+ TempFcb.PathName.MaximumLength = sizeof(TempFcb.PathNameBuffer);
Ccb = (PCCB)FileObject->FsContext2;
Fcb = (PFCB)FileObject->FsContext;
Ccb = (PCCB)FileObject->FsContext2;
Fcb = (PFCB)FileObject->FsContext;
}
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern);
}
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern);
- TempFcb.ObjectName = TempFcb.PathName;
+ TempFcb.ObjectName = TempFcb.PathName.Buffer;
while (Status == STATUS_SUCCESS && BufferLength > 0)
{
Status = CdfsFindFile(DeviceExtension,
while (Status == STATUS_SUCCESS && BufferLength > 0)
{
Status = CdfsFindFile(DeviceExtension,
NTSTATUS NTAPI
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
NTSTATUS NTAPI
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
if(!Fcb) return NULL;
RtlZeroMemory(Fcb, sizeof(FCB));
if(!Fcb) return NULL;
RtlZeroMemory(Fcb, sizeof(FCB));
+ Fcb->PathName.Buffer = Fcb->PathNameBuffer;
+ Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
- CdfsWSubString(Fcb->PathName, FileName, sizeof(Fcb->PathName) / sizeof(Fcb->PathName[0]) - 1);
- if (wcsrchr(Fcb->PathName, '\\') != 0)
+ RtlAppendUnicodeToString(&Fcb->PathName, FileName);
+ if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
- Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
+ Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
- Fcb->ObjectName = Fcb->PathName;
+ Fcb->ObjectName = Fcb->PathName.Buffer;
BOOLEAN
CdfsFCBIsRoot(PFCB Fcb)
{
BOOLEAN
CdfsFCBIsRoot(PFCB Fcb)
{
- return(wcscmp(Fcb->PathName, L"\\") == 0);
+ return (Fcb->PathName.Length = sizeof(WCHAR) && Fcb->PathName.Buffer[0] == L'\\');
- DPRINT("releasing FCB at %p: %S, refCount:%d\n",
+ DPRINT("releasing FCB at %p: %wZ, refCount:%d\n",
Fcb->RefCount);
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
Fcb->RefCount);
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
{
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
{
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
- DPRINT("Comparing '%wZ' and '%S'\n", FileName, Fcb->PathName);
- if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
+ DPRINT("Comparing '%wZ' and '%wZ'\n", FileName, &Fcb->PathName);
+ if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
{
Fcb->RefCount++;
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
{
Fcb->RefCount++;
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
/* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
if ((LongName[0] != 0) &&
/* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
if ((LongName[0] != 0) &&
- (wcslen(DirectoryFCB->PathName) + 1 + wcslen(LongName) + 1 > MAX_PATH))
+ ((DirectoryFCB->PathName.Length / sizeof(WCHAR)) + 1 + wcslen(LongName) + 1 > MAX_PATH))
{
return(STATUS_OBJECT_NAME_INVALID);
}
{
return(STATUS_OBJECT_NAME_INVALID);
}
- wcscpy(pathName, DirectoryFCB->PathName);
+ wcscpy(pathName, DirectoryFCB->PathName.Buffer);
if (!CdfsFCBIsRoot(DirectoryFCB))
{
wcscat(pathName, L"\\");
if (!CdfsFCBIsRoot(DirectoryFCB))
{
wcscat(pathName, L"\\");
DeviceExt,
DirectoryFcb,
FileToFind);
DeviceExt,
DirectoryFcb,
FileToFind);
- DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
+ DPRINT("Dir Path:%wZ\n", &DirectoryFcb->PathName);
/* default to '.' if no filename specified */
if (FileToFind->Length == 0)
/* default to '.' if no filename specified */
if (FileToFind->Length == 0)
return STATUS_BUFFER_OVERFLOW;
/* Calculate file name length in bytes */
return STATUS_BUFFER_OVERFLOW;
/* Calculate file name length in bytes */
- NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
+ NameLength = Fcb->PathName.Length;
NameInfo->FileNameLength = NameLength;
/* Calculate amount of bytes to copy not to overflow the buffer */
NameInfo->FileNameLength = NameLength;
/* Calculate amount of bytes to copy not to overflow the buffer */
*BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]));
/* Fill in the bytes */
*BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]));
/* Fill in the bytes */
- RtlCopyMemory(NameInfo->FileName, Fcb->PathName, BytesToCopy);
+ RtlCopyMemory(NameInfo->FileName, Fcb->PathName.Buffer, BytesToCopy);
/* Check if we could write more but are not able to */
if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]))
/* Check if we could write more but are not able to */
if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]))
ASSERT(Info);
ASSERT(Fcb);
ASSERT(Info);
ASSERT(Fcb);
- NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
+ NameLength = Fcb->PathName.Length;
if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
return(STATUS_BUFFER_OVERFLOW);
if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
return(STATUS_BUFFER_OVERFLOW);
/* Name Information */
Info->NameInformation.FileNameLength = NameLength;
RtlCopyMemory(Info->NameInformation.FileName,
/* Name Information */
Info->NameInformation.FileNameLength = NameLength;
RtlCopyMemory(Info->NameInformation.FileName,
NameLength + sizeof(WCHAR));
*BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
NameLength + sizeof(WCHAR));
*BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
while (Entry != &DeviceExt->FcbListHead)
{
Fcb = (PFCB)CONTAINING_RECORD(Entry, FCB, FcbListEntry);
while (Entry != &DeviceExt->FcbListHead)
{
Fcb = (PFCB)CONTAINING_RECORD(Entry, FCB, FcbListEntry);
- DPRINT1("OpenFile %S RefCount %ld\n", Fcb->PathName, Fcb->RefCount);
+ DPRINT1("OpenFile %wZ RefCount %ld\n", &Fcb->PathName, Fcb->RefCount);