Author: ion
Date: Tue Jun 27 07:06:26 2006
New Revision: 22652
URL: http://svn.reactos.org/svn/reactos?rev=22652&view=rev
Log:
- Catch illegal call to Ob functions when ObjectAttributes == NULL and return distinguished status code for this situation (STATUS_INVALID_PARAMETER), instead of failing due to access violation.
- Create the BNO Global and Local symbolic links in kernel32.
- We pass all the Ob+Native tests in ntdll_winetest om now (we fail some named pipe ones, but I have no idea why WINE calls them "Object Manager" related...)
Modified:
trunk/reactos/dll/win32/kernel32/misc/dllmain.c
trunk/reactos/ntoskrnl/ob/obhandle.c
Modified: trunk/reactos/dll/win32/kernel32/misc/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/dl…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/dllmain.c (original)
+++ trunk/reactos/dll/win32/kernel32/misc/dllmain.c Tue Jun 27 07:06:26 2006
@@ -66,7 +66,10 @@
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\BaseNamedObjects");
+ UNICODE_STRING SymName = RTL_CONSTANT_STRING(L"Local");
+ UNICODE_STRING SymName2 = RTL_CONSTANT_STRING(L"Global");
NTSTATUS Status;
+ HANDLE SymHandle;
InitializeObjectAttributes(&ObjectAttributes,
&Name,
@@ -87,6 +90,36 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateDirectoryObject() failed\n");
+ }
+
+ /* Create the "local" Symbolic Link. FIXME: CSR should do this */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SymName,
+ OBJ_CASE_INSENSITIVE,
+ *DirHandle,
+ NULL);
+ Status = NtCreateSymbolicLinkObject(&SymHandle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes,
+ &Name);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateSymbolicLinkObject() failed\n");
+ }
+
+ /* Create the "global" Symbolic Link. FIXME: CSR should do this */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SymName2,
+ OBJ_CASE_INSENSITIVE,
+ *DirHandle,
+ NULL);
+ Status = NtCreateSymbolicLinkObject(&SymHandle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes,
+ &Name);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateSymbolicLinkObject() failed\n");
}
}
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Tue Jun 27 07:06:26 2006
@@ -1455,6 +1455,14 @@
OB_OPEN_REASON OpenReason;
PAGED_CODE();
+ /* Check if we didn't get any Object Attributes */
+ if (!ObjectAttributes)
+ {
+ /* Fail with special status code */
+ *Handle = NULL;
+ return STATUS_INVALID_PARAMETER;
+ }
+
/* Capture all the info */
Status = ObpCaptureObjectAttributes(ObjectAttributes,
AccessMode,
Author: ion
Date: Tue Jun 27 05:52:16 2006
New Revision: 22651
URL: http://svn.reactos.org/svn/reactos?rev=22651&view=rev
Log:
- Fix another critical bug in ObInsertObject: don't overwrite the lookup status with the handle creation status. If the lookup returned something like OBJECT_NAME_EXISTS (which is a success + warning), we don't want to overwrite it with ObpCreateHandle's STATUS_SUCCESS. This should fix a large number of regressions (and also fixes many WINE ntdll "om" tests).
- We also now correctly dereference the object in ObInsertObject, which should reduce one source of leaks (But there is still one). OTOH, this makes the Cm code crash at shutdown (I'll fix this ASAP, this fix is worth having atm.)
Modified:
trunk/reactos/ntoskrnl/ob/obhandle.c
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Tue Jun 27 05:52:16 2006
@@ -1705,7 +1705,7 @@
POBJECT_TYPE ObjectType;
PVOID FoundObject = NULL;
POBJECT_HEADER FoundHeader = NULL;
- NTSTATUS Status = STATUS_SUCCESS;
+ NTSTATUS Status = STATUS_SUCCESS, RealStatus;
PSECURITY_DESCRIPTOR DirectorySd = NULL;
BOOLEAN SdAllocated;
OBP_LOOKUP_CONTEXT Context;
@@ -1749,9 +1749,14 @@
Header->ObjectCreateInfo = NULL;
/* Remove the extra keep-alive reference */
- //ObDereferenceObject(Object); // FIXME: Needs sync changes
+ if (Handle) ObDereferenceObject(Object); // FIXME: Needs sync changes
/* Return */
+ OBTRACE(OB_HANDLE_DEBUG,
+ "%s - returning Object with PC S: %lx %lx\n",
+ __FUNCTION__,
+ OBJECT_TO_OBJECT_HEADER(Object)->PointerCount,
+ Status);
return Status;
}
@@ -1893,12 +1898,15 @@
}
}
+ /* Save the actual status until here */
+ RealStatus = Status;
+
/* HACKHACK: Because of ROS's incorrect startup, this can be called
- * without a valid Process until I finalize the startup patch,
- * so don't create a handle if this is the case. We also don't create
- * a handle if Handle is NULL when the Registry Code calls it, because
- * the registry code totally bastardizes the Ob and needs to be fixed
- */
+ * without a valid Process until I finalize the startup patch,
+ * so don't create a handle if this is the case. We also don't create
+ * a handle if Handle is NULL when the Registry Code calls it, because
+ * the registry code totally bastardizes the Ob and needs to be fixed
+ */
if (Handle)
{
/* Create the handle */
@@ -1925,7 +1933,15 @@
}
/* Remove the extra keep-alive reference */
- //ObDereferenceObject(Object);
+ if (Handle) ObDereferenceObject(Object);
+
+ /* Check our final status */
+ if (!NT_SUCCESS(Status))
+ {
+ /* Return the status of the failure */
+ *Handle = NULL;
+ RealStatus = Status;
+ }
/* Check if we created our own access state */
if (PassedAccessState == &AccessState)
@@ -1934,8 +1950,13 @@
SeDeleteAccessState(PassedAccessState);
}
- /* Return failure code */
- return Status;
+ /* Return status code */
+ OBTRACE(OB_HANDLE_DEBUG,
+ "%s - returning Object with PC S/RS: %lx %lx %lx\n",
+ __FUNCTION__,
+ OBJECT_TO_OBJECT_HEADER(Object)->PointerCount,
+ RealStatus, Status);
+ return RealStatus;
}
/*++
Author: ion
Date: Tue Jun 27 05:16:17 2006
New Revision: 22650
URL: http://svn.reactos.org/svn/reactos?rev=22650&view=rev
Log:
- ObpCreateUnnamedHandle/ObpCreateHandle => Reference the object before calling ExCreateHandle.
- Fix two critical bugs in ObInsertObject: We were creating a handle for the wrong object (in ObInsertObject) and we were not passing the ReferencedObject parameter to ObpCreateHandle, so that object was never being returned properly to the caller.
- ObfDereferenceObject shouldn't check for the OB_FLAG_PERMANENT flag, or else it would never be possible to kill permanent objects while in kernel mode (permanent objects only apply to user-mode handles).
Modified:
trunk/reactos/ntoskrnl/ob/obhandle.c
trunk/reactos/ntoskrnl/ob/obinit.c
trunk/reactos/ntoskrnl/ob/obref.c
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Tue Jun 27 05:16:17 2006
@@ -520,6 +520,7 @@
BOOLEAN AttachedToProcess = FALSE;
PVOID HandleTable;
NTSTATUS Status;
+ ULONG i;
PAGED_CODE();
/* Get the object header and type */
@@ -579,6 +580,18 @@
/* Save the access mask */
NewEntry.GrantedAccess = DesiredAccess;
+
+ /* Handle extra references */
+ if (AdditionalReferences)
+ {
+ /* Make a copy in case we fail later below */
+ i = AdditionalReferences;
+ while (i--)
+ {
+ /* Increment the count */
+ InterlockedIncrement(&ObjectHeader->PointerCount);
+ }
+ }
/*
* Create the actual handle. We'll need to do this *after* calling
@@ -597,13 +610,6 @@
/* Make sure we got a handle */
if (Handle)
{
- /* Handle extra references */
- while (AdditionalReferences--)
- {
- /* Increment the count */
- InterlockedIncrement(&ObjectHeader->PointerCount);
- }
-
/* Check if this was a kernel handle */
if (HandleAttributes & OBJ_KERNEL_HANDLE)
{
@@ -615,12 +621,19 @@
*ReturnedHandle = Handle;
if (ReturnedObject) *ReturnedObject = Object;
OBTRACE(OB_HANDLE_DEBUG,
- "%s %s - Returning Handle: %lx HC LC %lx %lx\n",
+ "%s - Returning Handle: %lx HC LC %lx %lx\n",
__FUNCTION__,
Handle,
ObjectHeader->HandleCount,
ObjectHeader->PointerCount);
return STATUS_SUCCESS;
+ }
+
+ /* Handle extra references */
+ while (AdditionalReferences--)
+ {
+ /* Decrement the count */
+ InterlockedDecrement(&ObjectHeader->PointerCount);
}
/* Decrement the handle count and detach */
@@ -692,6 +705,7 @@
POBJECT_TYPE ObjectType;
PVOID HandleTable;
NTSTATUS Status;
+ ULONG i;
PAGED_CODE();
/* Get the object header and type */
@@ -764,6 +778,18 @@
NewEntry.GrantedAccess = AccessState->RemainingDesiredAccess |
AccessState->PreviouslyGrantedAccess;
+ /* Handle extra references */
+ if (AdditionalReferences)
+ {
+ /* Make a copy in case we fail later below */
+ i = AdditionalReferences;
+ while (i--)
+ {
+ /* Increment the count */
+ InterlockedIncrement(&ObjectHeader->PointerCount);
+ }
+ }
+
/*
* Create the actual handle. We'll need to do this *after* calling
* ObpIncrementHandleCount to make sure that Object Security is valid
@@ -781,13 +807,6 @@
/* Make sure we got a handle */
if (Handle)
{
- /* Handle extra references */
- while (AdditionalReferences--)
- {
- /* Increment the count */
- InterlockedIncrement(&ObjectHeader->PointerCount);
- }
-
/* Check if this was a kernel handle */
if (HandleAttributes & OBJ_KERNEL_HANDLE)
{
@@ -805,6 +824,13 @@
ObjectHeader->HandleCount,
ObjectHeader->PointerCount);
return STATUS_SUCCESS;
+ }
+
+ /* Handle extra references */
+ while (AdditionalReferences--)
+ {
+ /* Increment the count */
+ InterlockedDecrement(&ObjectHeader->PointerCount);
}
/* Decrement the handle count and detach */
@@ -1052,7 +1078,7 @@
/* Make sure that the handle is inheritable */
Ret = (HandleTableEntry->ObAttributes & EX_HANDLE_ENTRY_INHERITABLE) != 0;
- if(Ret)
+ if (Ret)
{
/* Get the object header */
ObjectHeader = EX_HTE_TO_HDR(HandleTableEntry);
@@ -1519,9 +1545,10 @@
ObpReleaseCapturedAttributes(&ObjectCreateInfo);
if (ObjectName.Buffer) ObpReleaseCapturedName(&ObjectName);
OBTRACE(OB_HANDLE_DEBUG,
- "%s returning Object with PC S: %lx %lx\n",
+ "%s - returning Object %p with PC S: %lx %lx\n",
__FUNCTION__,
- OBJECT_TO_OBJECT_HEADER(Object)->PointerCount,
+ Object,
+ Object ? OBJECT_TO_OBJECT_HEADER(Object)->PointerCount : -1,
Status);
return Status;
}
@@ -1722,7 +1749,7 @@
Header->ObjectCreateInfo = NULL;
/* Remove the extra keep-alive reference */
- //ObDereferenceObject(Object); FIXME: Will require massive changes
+ //ObDereferenceObject(Object); // FIXME: Needs sync changes
/* Return */
return Status;
@@ -1853,6 +1880,7 @@
if (!NT_SUCCESS(Status))
{
/* We failed, dereference the object and delete the access state */
+ KEBUGCHECK(0);
ObDereferenceObject(Object);
if (PassedAccessState == &AccessState)
{
@@ -1875,13 +1903,13 @@
{
/* Create the handle */
Status = ObpCreateHandle(OpenReason,
- &Header->Body,
+ FoundObject,
NULL,
PassedAccessState,
AdditionalReferences + 1,
ObjectCreateInfo->Attributes,
ExGetPreviousMode(),
- NULL,
+ ReferencedObject,
Handle);
}
@@ -1897,7 +1925,7 @@
}
/* Remove the extra keep-alive reference */
- //ObDereferenceObject(Object); FIXME: Will require massive changes
+ //ObDereferenceObject(Object);
/* Check if we created our own access state */
if (PassedAccessState == &AccessState)
Modified: trunk/reactos/ntoskrnl/ob/obinit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obinit.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obinit.c (original)
+++ trunk/reactos/ntoskrnl/ob/obinit.c Tue Jun 27 05:16:17 2006
@@ -38,7 +38,7 @@
};
PDEVICE_MAP ObSystemDeviceMap = NULL;
-ULONG ObpTraceLevel = OB_NAMESPACE_DEBUG;
+ULONG ObpTraceLevel = OB_HANDLE_DEBUG | OB_REFERENCE_DEBUG;
/* PRIVATE FUNCTIONS *********************************************************/
Modified: trunk/reactos/ntoskrnl/ob/obref.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obref.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obref.c (original)
+++ trunk/reactos/ntoskrnl/ob/obref.c Tue Jun 27 05:16:17 2006
@@ -89,8 +89,7 @@
Header = OBJECT_TO_OBJECT_HEADER(Object);
/* Check whether the object can now be deleted. */
- if (!(InterlockedDecrement(&Header->PointerCount)) &&
- !(Header->Flags & OB_FLAG_PERMANENT))
+ if (!(InterlockedDecrement(&Header->PointerCount)))
{
/* Sanity check */
ASSERT(!Header->HandleCount);
Author: ion
Date: Tue Jun 27 03:50:03 2006
New Revision: 22649
URL: http://svn.reactos.org/svn/reactos?rev=22649&view=rev
Log:
- Lesson One: Don't revert commits because your eyes are inventing the word "copyright". I tried really hard, I really did, but I could not find even the word "copy", much less "copyright".
- Lesson Two: What do you know! En and De.rc actually *are* our files, not James Brown's (his is sol.rc, which hasn't been altered with a ROS Header).
- Lesson Three: It is official (voted) ROS Policy that all ROS files have a header. Reverting this header violated it.
Modified:
trunk/reactos/base/applications/games/solitaire/de.rc
trunk/reactos/base/applications/games/solitaire/en.rc
Modified: trunk/reactos/base/applications/games/solitaire/de.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/games/so…
==============================================================================
--- trunk/reactos/base/applications/games/solitaire/de.rc (original)
+++ trunk/reactos/base/applications/games/solitaire/de.rc Tue Jun 27 03:50:03 2006
@@ -1,3 +1,10 @@
+/*
+ * PROJECT: Solitaire
+ * LICENSE: Freeware, permission to use under Public Domain
+ * FILE: base/applications/games/solitaire/de.rc
+ * PURPOSE: German Language File for Solitaire
+ * PROGRAMMERS: Daniel "EmuandCo" Reimer (reimer.daniel(a)freenet.de)
+ */
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
Modified: trunk/reactos/base/applications/games/solitaire/en.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/games/so…
==============================================================================
--- trunk/reactos/base/applications/games/solitaire/en.rc (original)
+++ trunk/reactos/base/applications/games/solitaire/en.rc Tue Jun 27 03:50:03 2006
@@ -1,3 +1,10 @@
+/*
+ * PROJECT: Solitaire
+ * LICENSE: Freeware, permission to use under Public Domain
+ * FILE: base/applications/games/solitaire/en.rc
+ * PURPOSE: English Language File for Solitaire
+ * PROGRAMMERS: Daniel "EmuandCo" Reimer (reimer.daniel(a)freenet.de)
+ */
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
Author: ion
Date: Tue Jun 27 02:50:02 2006
New Revision: 22647
URL: http://svn.reactos.org/svn/reactos?rev=22647&view=rev
Log:
- Same fixes for LocalAlloc/LocalReAlloc
- We now pass all 278+49 WINE Regression Tests related to Heap/Memory.
Modified:
trunk/reactos/dll/win32/kernel32/mem/local.c
Modified: trunk/reactos/dll/win32/kernel32/mem/local.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/loc…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/mem/local.c (original)
+++ trunk/reactos/dll/win32/kernel32/mem/local.c Tue Jun 27 02:50:02 2006
@@ -113,7 +113,7 @@
if (!Ptr)
{
/* We don't have a valid pointer, but so reuse this handle */
- HandleEntry->Flags = BASE_HEAP_ENTRY_FLAG_REUSE;
+ HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSE;
}
/* Check if the handle is discardable */
@@ -319,7 +319,7 @@
if (Ptr)
{
/* Make sure the handle isn't locked */
- if ((uFlags & LMEM_MOVEABLE) & !(HandleEntry->LockCount))
+ if ((uFlags & LMEM_MOVEABLE) && !(HandleEntry->LockCount))
{
/* Free the current heap */
RtlFreeHeap(hProcessHeap, Flags, Ptr);
Author: ion
Date: Tue Jun 27 02:48:12 2006
New Revision: 22646
URL: http://svn.reactos.org/svn/reactos?rev=22646&view=rev
Log:
- Fix a typo in a comparison (& vs &&) which was breaking GlobalReAlloc in some cases.
- Fix a missing | (OR) in GlobalAlloc which created an invalid handle if the first allocation was of size 0.
Modified:
trunk/reactos/dll/win32/kernel32/include/baseheap.h
trunk/reactos/dll/win32/kernel32/mem/global.c
Modified: trunk/reactos/dll/win32/kernel32/include/baseheap.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/baseheap.h (original)
+++ trunk/reactos/dll/win32/kernel32/include/baseheap.h Tue Jun 27 02:48:12 2006
@@ -65,6 +65,7 @@
#define BASE_TRACE_FAILURE() \
BH_PRINT("[BASE_HEAP] %s : Failing %d\n", \
__FUNCTION__, __LINE__)
+
//
// The handle structure for global heap handles.
// Notice that it nicely overlays with RTL_HANDLE_ENTRY.
Modified: trunk/reactos/dll/win32/kernel32/mem/global.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/glo…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/mem/global.c (original)
+++ trunk/reactos/dll/win32/kernel32/mem/global.c Tue Jun 27 02:48:12 2006
@@ -117,7 +117,7 @@
if (!Ptr)
{
/* We don't have a valid pointer, but so reuse this handle */
- HandleEntry->Flags = BASE_HEAP_ENTRY_FLAG_REUSE;
+ HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSE;
}
/* Check if the handle is discardable */
@@ -486,7 +486,7 @@
if (Ptr)
{
/* Make sure the handle isn't locked */
- if ((uFlags & GMEM_MOVEABLE) & !(HandleEntry->LockCount))
+ if ((uFlags & GMEM_MOVEABLE) && !(HandleEntry->LockCount))
{
/* Free the current heap */
RtlFreeHeap(hProcessHeap, Flags, Ptr);