- Remove the heart (but not the brain) of the IopCreateFile hack. A much 'nicer' hack now detects if a filename can't be found, and instead of inserting it into the object directory (wrong!), calling IopCreateFile (wrong!), then having it fail, only to then remove the newly inserted object entry (wrong wrong wrong!), IopCreateFile is now *only* called for real files, otherwise Ob detects the invalid name and fails nicely and quickly.

svn path=/trunk/; revision=22288
This commit is contained in:
Alex Ionescu 2006-06-08 21:36:44 +00:00
parent d7c17c883d
commit 63e1686915

View file

@ -310,7 +310,6 @@ Next:
PVOID FoundObject = NULL;
POBJECT_HEADER Header = OBJECT_TO_OBJECT_HEADER(Insert);
POBJECT_HEADER FoundHeader = NULL;
BOOLEAN ObjectAttached = FALSE;
FoundObject = *ReturnedObject;
if (FoundObject)
{
@ -324,6 +323,29 @@ Next:
return STATUS_OBJECT_NAME_COLLISION;
}
/*
* MiniHack
* If we still have a remaining path on a directory object, but we are
* a file object, then fail, because this means the file doesn't exist
*/
if ((RemainingPath->Buffer) &&
(FoundHeader && FoundHeader->Type == ObDirectoryType) &&
(Header->Type == IoFileObjectType))
{
/* Hack */
RtlFreeUnicodeString(RemainingPath);
*ReturnedObject = NULL;
return STATUS_OBJECT_PATH_NOT_FOUND;
}
else if (Header->Type == IoFileObjectType)
{
/* Otherwise, call the hacked parse routine which will go away soon */
Status = IopCreateFile(&Header->Body,
FoundObject,
RemainingPath->Buffer,
NULL);
}
if (FoundHeader && FoundHeader->Type == ObDirectoryType &&
RemainingPath->Buffer)
{
@ -347,34 +369,8 @@ Next:
ObjectNameInfo->Name.Length = RemainingPath->Length - Delta;
ObjectNameInfo->Name.MaximumLength = RemainingPath->MaximumLength - Delta;
ObpInsertEntryDirectory(FoundObject, Context, Header);
ObjectAttached = TRUE;
}
if (Header->Type == IoFileObjectType)
{
/* TEMPORARY HACK. DO NOT TOUCH -- Alex */
DPRINT("Calling IopCreateFile: %p %p %wZ\n", &Header->Body, FoundObject, RemainingPath);
Status = IopCreateFile(&Header->Body,
FoundObject,
RemainingPath->Buffer,
NULL);
DPRINT("Called IopCreateFile: %x\n", Status);
}
if (!NT_SUCCESS(Status))
{
DPRINT("Create Failed\n");
if (ObjectAttached == TRUE)
{
ObpDeleteEntryDirectory(Context);
}
if (FoundObject)
{
ObDereferenceObject(FoundObject);
}
RtlFreeUnicodeString(RemainingPath);
return Status;
}
RtlFreeUnicodeString(RemainingPath);
*ReturnedObject = Insert;
}