Author: tkreuzer
Date: Sat Aug 13 20:10:40 2011
New Revision: 53211
URL:
http://svn.reactos.org/svn/reactos?rev=53211&view=rev
Log:
[NTOSKRNL/WIN32K/NDK]
- OkToClose procedure (OB_OKAYTOCLOSE_METHOD) returns BOOLEAN, not NTSTATUS
- Check ppi for NULL before dereferencing it in IntWinstaOkToClose (it is NULL, if we do
our job of cleaning up the win32 process properly)
- Set the win32 process info to NULL on process cleanup
- Free THREADINFO and PROCESSINFO instead of leaking them
- Set NULL cursor, when the last thread is cleaned up in win32k, so we don't call
UserSetCursor() in the process cleanup, when we don't have a THREADINFO anymore. This
should hopefully fix a crash of MSVC builds.
- Remove unused UserGetNextHandle function
- Fix some warnings
Modified:
trunk/reactos/include/ndk/obtypes.h
trunk/reactos/ntoskrnl/ex/win32k.c
trunk/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c
trunk/reactos/subsystems/win32/win32k/main/dllmain.c
trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
trunk/reactos/subsystems/win32/win32k/ntuser/object.c
trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
Modified: trunk/reactos/include/ndk/obtypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/obtypes.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/obtypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/obtypes.h [iso-8859-1] Sat Aug 13 20:10:40 2011
@@ -236,7 +236,7 @@
IN KPROCESSOR_MODE AccessMode
);
-typedef NTSTATUS
+typedef BOOLEAN
(NTAPI *OB_OKAYTOCLOSE_METHOD)(
IN PEPROCESS Process OPTIONAL,
IN PVOID Object,
Modified: trunk/reactos/ntoskrnl/ex/win32k.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/win32k.c?rev=5…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/win32k.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/win32k.c [iso-8859-1] Sat Aug 13 20:10:40 2011
@@ -43,7 +43,7 @@
/* FUNCTIONS ****************************************************************/
-NTSTATUS
+BOOLEAN
NTAPI
ExpDesktopOkToClose( IN PEPROCESS Process OPTIONAL,
IN PVOID Object,
@@ -57,10 +57,10 @@
Parameters.Handle = Handle;
Parameters.PreviousMode = AccessMode;
- return ExpDesktopObjectOkToClose(&Parameters);
+ return NT_SUCCESS(ExpDesktopObjectOkToClose(&Parameters));
}
-NTSTATUS
+BOOLEAN
NTAPI
ExpWindowStationOkToClose( IN PEPROCESS Process OPTIONAL,
IN PVOID Object,
@@ -74,7 +74,7 @@
Parameters.Handle = Handle;
Parameters.PreviousMode = AccessMode;
- return ExpWindowStationObjectOkToClose(&Parameters);
+ return NT_SUCCESS(ExpWindowStationObjectOkToClose(&Parameters));
}
VOID
Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_symbols.…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c [iso-8859-1] Sat Aug 13 20:10:40 2011
@@ -35,8 +35,8 @@
static BOOLEAN LoadSymbols;
static LIST_ENTRY SymbolFileListHead;
static KSPIN_LOCK SymbolFileListLock;
-static PROSSYM_INFO KdbpRosSymInfo;
-static ULONG_PTR KdbpImageBase;
+//static PROSSYM_INFO KdbpRosSymInfo;
+//static ULONG_PTR KdbpImageBase;
BOOLEAN KdbpSymbolsInitialized = FALSE;
/* FUNCTIONS ****************************************************************/
@@ -178,7 +178,9 @@
PMEMORY_AREA MemoryArea = NULL;
PROS_SECTION_OBJECT SectionObject;
PLDR_DATA_TABLE_ENTRY LdrEntry;
+#if 0
PROSSYM_KM_OWN_CONTEXT FileContext;
+#endif
ULONG_PTR RelativeAddress;
NTSTATUS Status;
ROSSYM_LINEINFO LineInfo = {0};
@@ -599,7 +601,7 @@
UNICODE_STRING ModuleNameCopy;
RtlInitUnicodeString(&SystemRoot,
L"\\SystemRoot\\system32\\Drivers\\");
ModuleNameCopy.Length = 0;
- ModuleNameCopy.MaximumLength =
+ ModuleNameCopy.MaximumLength =
LdrEntry->BaseDllName.MaximumLength + SystemRoot.MaximumLength;
ModuleNameCopy.Buffer = ExAllocatePool(NonPagedPool, SystemRoot.MaximumLength +
LdrEntry->BaseDllName.MaximumLength);
RtlCopyUnicodeString(&ModuleNameCopy, &SystemRoot);
Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ma…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] Sat Aug 13 20:10:40
2011
@@ -203,6 +203,10 @@
GdiPoolDestroy(Win32Process->pPoolDcAttr);
GdiPoolDestroy(Win32Process->pPoolBrushAttr);
GdiPoolDestroy(Win32Process->pPoolRgnAttr);
+
+ /* Ftee the PROCESSINFO */
+ PsSetProcessWin32Process(Process, NULL);
+ ExFreePoolWithTag(Win32Process, USERTAG_PROCESSINFO);
}
RETURN( STATUS_SUCCESS);
@@ -418,10 +422,18 @@
IntSetThreadDesktop(NULL, TRUE);
- /* Decrement thread count */
+ /* Decrement thread count and check if its 0 */
ppiCurrent->cThreads--;
-
+ if (ppiCurrent->cThreads == 0)
+ {
+ /* UGLY: Prevent this function from being called later
+ when we don't have a THREADINFO anymore. */
+ UserSetCursor(NULL, TRUE);
+ }
+
+ /* Free the THREADINFO */
PsSetThreadWin32Thread(Thread, NULL);
+ ExFreePoolWithTag(ptiCurrent, USERTAG_THREADINFO);
}
Status = STATUS_SUCCESS;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Sat Aug 13
20:10:40 2011
@@ -182,10 +182,10 @@
if( Parameters->Handle == pti->ppi->hdeskStartup ||
Parameters->Handle == pti->hdesk)
{
- return FALSE;
- }
-
- return TRUE;
+ return STATUS_ACCESS_DENIED;
+ }
+
+ return STATUS_SUCCESS;
}
/* PRIVATE FUNCTIONS **********************************************************/
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/object.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/object.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/object.c [iso-8859-1] Sat Aug 13 20:10:40
2011
@@ -261,31 +261,7 @@
return entry->ptr;
}
-/* return the next user handle after 'handle' that is of a given type */
-PVOID UserGetNextHandle(PUSER_HANDLE_TABLE ht, HANDLE* handle, USER_OBJECT_TYPE type )
-{
- PUSER_HANDLE_ENTRY entry;
-
- if (!*handle)
- entry = ht->handles;
- else
- {
- int index = (((unsigned int)*handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
- if (index < 0 || index >= ht->nb_handles)
- return NULL;
- entry = ht->handles + index + 1; /* start from the next one */
- }
- while (entry < ht->handles + ht->nb_handles)
- {
- if (!type || entry->type == type)
- {
- *handle = entry_to_handle(ht, entry );
- return entry->ptr;
- }
- entry++;
- }
- return NULL;
-}
+
BOOL FASTCALL UserCreateHandleTable(VOID)
{
@@ -383,7 +359,7 @@
case otMenu:
case otCallProc:
((PPROCDESKHEAD)Object)->rpdesk = rpdesk;
- ((PPROCDESKHEAD)Object)->pSelf = Object;
+ ((PPROCDESKHEAD)Object)->pSelf = Object;
break;
case otCursorIcon:
@@ -469,7 +445,7 @@
UserDeleteObject(HANDLE h, USER_OBJECT_TYPE type )
{
PVOID body = UserGetObject(gHandleTable, h, type);
-
+
if (!body) return FALSE;
ASSERT( ((PHEAD)body)->cLockObj >= 1);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] Sat Aug 13 20:10:40
2011
@@ -187,19 +187,20 @@
return STATUS_OBJECT_TYPE_MISMATCH;
}
-NTSTATUS NTAPI
+NTSTATUS
+NTAPI
IntWinstaOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters)
{
PPROCESSINFO ppi;
ppi = PsGetCurrentProcessWin32Process();
- if(Parameters->Handle == ppi->hwinsta)
+ if(ppi && (Parameters->Handle == ppi->hwinsta))
{
- return FALSE;
+ return STATUS_ACCESS_DENIED;
}
- return TRUE;
+ return STATUS_SUCCESS;
}
/* PRIVATE FUNCTIONS **********************************************************/
@@ -974,7 +975,7 @@
/*
* FIXME - don't allow changing the window station if there are threads that are
attached to desktops and own gui objects
*/
-
+
PsSetProcessWindowStation(ppi->peProcess, hWindowStation);
ppi->prpwinsta = NewWinSta;