mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 12:13:29 +08:00
- Fix some referencing/bugs in Ob functions that I wrote which were known fixmes.
- Remove every instance of ObDereferenceObject after an ObInsertObject that I could find. This temporarily will make the object leaks even worse, but it's better to increase leaks and then fix the ref bug, then to decrease references while missing spots that forgot to reference them (you'd end up with hard to debug randomly dying objects). svn path=/trunk/; revision=22345
This commit is contained in:
parent
f45c3a82e8
commit
afee678695
@ -573,7 +573,7 @@ Cleanup:
|
||||
}
|
||||
if (ObjectName.Buffer) ObpReleaseCapturedName(&ObjectName);
|
||||
if (FreeRemainingPath) RtlFreeUnicodeString(&RemainingPath);
|
||||
if (Object != NULL) ObDereferenceObject(Object);
|
||||
//if (Object != NULL) ObDereferenceObject(Object);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -151,7 +151,6 @@ NtCreateEvent(OUT PHANDLE EventHandle,
|
||||
0,
|
||||
NULL,
|
||||
&hEvent);
|
||||
ObDereferenceObject(Event);
|
||||
|
||||
/* Check for success */
|
||||
if(NT_SUCCESS(Status))
|
||||
|
@ -110,7 +110,6 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
|
||||
0,
|
||||
NULL,
|
||||
&hEventPair);
|
||||
ObDereferenceObject(EventPair);
|
||||
|
||||
/* Check for success and return handle */
|
||||
if(NT_SUCCESS(Status))
|
||||
|
@ -133,7 +133,6 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
|
||||
0,
|
||||
NULL,
|
||||
&hMutant);
|
||||
ObDereferenceObject(Mutant);
|
||||
|
||||
/* Check for success */
|
||||
if(NT_SUCCESS(Status))
|
||||
|
@ -129,7 +129,6 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
|
||||
0,
|
||||
NULL,
|
||||
&hSemaphore);
|
||||
ObDereferenceObject(Semaphore);
|
||||
|
||||
/* Check for success */
|
||||
if(NT_SUCCESS(Status))
|
||||
|
@ -583,7 +583,6 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||
CreatedDeviceObject->DriverObject = DriverObject;
|
||||
CreatedDeviceObject->NextDevice = DriverObject->DeviceObject;
|
||||
DriverObject->DeviceObject = CreatedDeviceObject;
|
||||
|
||||
NtClose(TempHandle);
|
||||
|
||||
/* Return to caller */
|
||||
|
@ -273,7 +273,6 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle,
|
||||
0,
|
||||
NULL,
|
||||
&hIoCompletionHandle);
|
||||
ObDereferenceObject(Queue);
|
||||
|
||||
if (NT_SUCCESS(Status)) {
|
||||
|
||||
|
@ -878,7 +878,7 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||
ExFreePool(ConnectionRequest);
|
||||
ExFreePool(CReply);
|
||||
|
||||
ObDereferenceObject(OurPort);
|
||||
//ObDereferenceObject(OurPort);
|
||||
ObDereferenceObject(NamedPort);
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
|
@ -132,8 +132,6 @@ NtCreatePort (PHANDLE PortHandle,
|
||||
Port->MaxDataLength = LPC_MAX_MESSAGE_LENGTH;
|
||||
Port->MaxPoolUsage = MaxPoolUsage;
|
||||
|
||||
ObDereferenceObject (Port);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
@ -3408,7 +3408,6 @@ NtCreateSection (OUT PHANDLE SectionHandle,
|
||||
0,
|
||||
NULL,
|
||||
SectionHandle);
|
||||
ObDereferenceObject(SectionObject);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
@ -553,9 +553,6 @@ NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle,
|
||||
}
|
||||
_SEH_END;
|
||||
}
|
||||
|
||||
/* ReactOS HACK: ObInsertObject double-references */
|
||||
ObDereferenceObject(Directory);
|
||||
}
|
||||
|
||||
/* Return status to caller */
|
||||
|
@ -345,19 +345,7 @@ ObpIncrementHandleCount(IN PVOID Object,
|
||||
}
|
||||
|
||||
/* Increase the handle count */
|
||||
if(InterlockedIncrement(&ObjectHeader->HandleCount) == 1)
|
||||
{
|
||||
/*
|
||||
* FIXME: Is really needed? Perhaps we should instead take
|
||||
* advantage of the AddtionalReferences parameter to add the
|
||||
* bias when required. This might be the source of the mysterious
|
||||
* ReactOS bug where ObInsertObject *requires* an immediate dereference
|
||||
* even in a success case.
|
||||
* Will have to think more about this when doing the Increment/Create
|
||||
* split later.
|
||||
*/
|
||||
ObReferenceObject(Object);
|
||||
}
|
||||
InterlockedIncrement(&ObjectHeader->HandleCount);
|
||||
|
||||
/* FIXME: Use the Handle Database */
|
||||
ProcessHandleCount = 0;
|
||||
@ -457,19 +445,7 @@ ObpIncrementUnnamedHandleCount(IN PVOID Object,
|
||||
}
|
||||
|
||||
/* Increase the handle count */
|
||||
if(InterlockedIncrement(&ObjectHeader->HandleCount) == 1)
|
||||
{
|
||||
/*
|
||||
* FIXME: Is really needed? Perhaps we should instead take
|
||||
* advantage of the AddtionalReferences parameter to add the
|
||||
* bias when required. This might be the source of the mysterious
|
||||
* ReactOS bug where ObInsertObject *requires* an immediate dereference
|
||||
* even in a success case.
|
||||
* Will have to think more about this when doing the Increment/Create
|
||||
* split later.
|
||||
*/
|
||||
ObReferenceObject(Object);
|
||||
}
|
||||
InterlockedIncrement(&ObjectHeader->HandleCount);
|
||||
|
||||
/* FIXME: Use the Handle Database */
|
||||
ProcessHandleCount = 0;
|
||||
@ -1531,11 +1507,9 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
AccessMode,
|
||||
NULL,
|
||||
Handle);
|
||||
if (!NT_SUCCESS(Status)) ObDereferenceObject(Object);
|
||||
|
||||
Cleanup:
|
||||
/* Dereference the object */
|
||||
if (Object) ObDereferenceObject(Object);
|
||||
|
||||
/* Delete the access state */
|
||||
if (PassedAccessState == &AccessState)
|
||||
{
|
||||
@ -1635,6 +1609,7 @@ ObOpenObjectByPointer(IN PVOID Object,
|
||||
AccessMode,
|
||||
NULL,
|
||||
Handle);
|
||||
if (!NT_SUCCESS(Status)) ObDereferenceObject(Object);
|
||||
|
||||
/* Delete the access state */
|
||||
if (PassedAccessState == &AccessState)
|
||||
@ -1642,9 +1617,6 @@ ObOpenObjectByPointer(IN PVOID Object,
|
||||
SeDeleteAccessState(PassedAccessState);
|
||||
}
|
||||
|
||||
/* ROS Hack: Dereference the object and return */
|
||||
ObDereferenceObject(Object);
|
||||
|
||||
/* Return */
|
||||
OBTRACE(OB_HANDLE_DEBUG,
|
||||
"%s - returning Object with PC S: %lx %lx\n",
|
||||
|
@ -45,6 +45,7 @@ ObpDeleteNameCheck(IN PVOID Object)
|
||||
OBP_LOOKUP_CONTEXT Context;
|
||||
POBJECT_HEADER_NAME_INFO ObjectNameInfo;
|
||||
POBJECT_TYPE ObjectType;
|
||||
PVOID Directory = NULL;
|
||||
|
||||
/* Get object structures */
|
||||
ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object);
|
||||
@ -68,7 +69,7 @@ ObpDeleteNameCheck(IN PVOID Object)
|
||||
0,
|
||||
FALSE,
|
||||
&Context);
|
||||
if (Object)
|
||||
if ((Object) && !(ObjectHeader->HandleCount))
|
||||
{
|
||||
/* First delete it from the directory */
|
||||
ObpDeleteEntryDirectory(&Context);
|
||||
@ -94,10 +95,16 @@ ObpDeleteNameCheck(IN PVOID Object)
|
||||
RtlInitEmptyUnicodeString(&ObjectNameInfo->Name, NULL, 0);
|
||||
|
||||
/* Clear the current directory and de-reference it */
|
||||
ObDereferenceObject(ObjectNameInfo->Directory);
|
||||
ObDereferenceObject(Object);
|
||||
Directory = ObjectNameInfo->Directory;
|
||||
ObjectNameInfo->Directory = NULL;
|
||||
}
|
||||
|
||||
/* Check if we were inserted in a directory */
|
||||
if (Directory)
|
||||
{
|
||||
ObDereferenceObject(Directory);
|
||||
ObDereferenceObject(Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,7 @@ ObfDereferenceObject(IN PVOID Object)
|
||||
Header->NextToFree);
|
||||
|
||||
/* Queue the work item */
|
||||
KeBugCheck(0);
|
||||
ExQueueWorkItem(&ObpReaperWorkItem, DelayedWorkQueue);
|
||||
}
|
||||
}
|
||||
@ -193,6 +194,7 @@ ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||
}
|
||||
|
||||
/* Find the object */
|
||||
*ObjectPtr = NULL;
|
||||
Status = ObFindObject(NULL,
|
||||
&ObjectName,
|
||||
Attributes,
|
||||
@ -204,19 +206,12 @@ ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||
NULL,
|
||||
ParseContext,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status)) goto Quickie;
|
||||
|
||||
/* ROS Hack */
|
||||
if (Object == NULL)
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
*ObjectPtr = NULL;
|
||||
Status = STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
goto Quickie;
|
||||
/* Return the object */
|
||||
*ObjectPtr = Object;
|
||||
}
|
||||
|
||||
/* Return the object */
|
||||
*ObjectPtr = Object;
|
||||
|
||||
/* Free the access state */
|
||||
if (PassedAccessState == &AccessState)
|
||||
{
|
||||
|
@ -359,9 +359,6 @@ NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle,
|
||||
}
|
||||
_SEH_END;
|
||||
}
|
||||
|
||||
/* ReactOS Hack: Our ObInsertObject references an object twice */
|
||||
ObDereferenceObject(SymbolicLink);
|
||||
}
|
||||
|
||||
/* Return status to caller */
|
||||
|
@ -313,7 +313,6 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
||||
DPRINT("About to dispatch the thread: %x!\n", &Thread->Tcb);
|
||||
OldIrql = KeAcquireDispatcherDatabaseLock ();
|
||||
KiUnblockThread(&Thread->Tcb, NULL, 0);
|
||||
ObDereferenceObject(Thread);
|
||||
KeReleaseDispatcherDatabaseLock(OldIrql);
|
||||
|
||||
/* Return */
|
||||
|
@ -1507,8 +1507,6 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle,
|
||||
NULL,
|
||||
&hToken);
|
||||
|
||||
ObDereferenceObject(NewToken);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
_SEH_TRY
|
||||
@ -2263,8 +2261,6 @@ NtCreateToken(OUT PHANDLE TokenHandle,
|
||||
DPRINT1("ObInsertObject() failed (Status %lx)\n", Status);
|
||||
}
|
||||
|
||||
ObDereferenceObject(AccessToken);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
_SEH_TRY
|
||||
@ -2513,7 +2509,6 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle,
|
||||
Status = ObInsertObject(NewToken, NULL, DesiredAccess, 0, NULL,
|
||||
&hToken);
|
||||
|
||||
ObfDereferenceObject(NewToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user