Author: fireball
Date: Tue Apr 22 10:45:58 2014
New Revision: 62865
URL:
http://svn.reactos.org/svn/reactos?rev=62865&view=rev
Log:
[ARWINSS]
- Properly set and reset Win32 process/thread info. Fixes a crash when first thread in the
system terminates (and that's CSRSS thread by design).
Modified:
branches/arwinss/arwinss/server/include/tags.h
branches/arwinss/arwinss/server/main/init.c
Modified: branches/arwinss/arwinss/server/include/tags.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/include/…
==============================================================================
--- branches/arwinss/arwinss/server/include/tags.h [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/include/tags.h [iso-8859-1] Tue Apr 22 10:45:58 2014
@@ -1,6 +1,6 @@
-#ifndef _WIN32K_TAGS_H
-#define _WIN32K_TAGS_H
+#pragma once
+/* GDI objects from the handle table */
#define TAG_BRUSHOBJ 'OHRB' /* brush object */
#define TAG_CLIP 'PILC' /* clipping */
#define TAG_CLIPOBJ 'OPLC' /* clip object */
@@ -19,6 +19,8 @@
#define TAG_PENSTYLES 'ytsG' /* pen styles */
#define TAG_BRUSH '@alG'
#define TAG_BITMAP 'PMTB' /* bitmap */
+
+/* Official tags */
#define GDITAG_RBRUSH 'rbdG'
-
-#endif /* _WIN32K_TAGS_H */
+#define USERTAG_PROCESSINFO 'ipsU'
+#define USERTAG_THREADINFO 'itsU'
Modified: branches/arwinss/arwinss/server/main/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/main/ini…
==============================================================================
--- branches/arwinss/arwinss/server/main/init.c [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/main/init.c [iso-8859-1] Tue Apr 22 10:45:58 2014
@@ -17,7 +17,7 @@
#include <handle.h>
#include <user.h>
-#define NDEBUG
+//#define NDEBUG
#include <debug.h>
void init_directories(void);
@@ -56,7 +56,7 @@
/* FIXME - lock the process */
Win32Thread = ExAllocatePoolWithTag(NonPagedPool,
sizeof(THREADINFO),
- 't23W');
+ USERTAG_THREADINFO);
if (!Win32Thread)
return STATUS_NO_MEMORY;
@@ -93,14 +93,14 @@
DPRINT("Destroying W32 thread TID:%d at IRQ level: %lu\n",
Thread->Tcb.Teb->ClientId.UniqueThread, KeGetCurrentIrql());
/* USER thread-level cleanup */
- UserEnterExclusive();
cleanup_clipboard_thread(Win32Thread);
destroy_thread_windows(Win32Thread);
free_msg_queue(Win32Thread);
close_thread_desktop(Win32Thread);
- UserLeave();
-
- PsSetThreadWin32Thread(Thread, NULL, NULL);
+
+ /* Free THREADINFO */
+ PsSetThreadWin32Thread(Thread, NULL, Win32Thread);
+ ExFreePoolWithTag(Win32Thread, USERTAG_THREADINFO);
return STATUS_SUCCESS;
}
@@ -125,7 +125,8 @@
/* Allocate one if needed */
/* FIXME - lock the process */
Win32Process = ExAllocatePoolWithTag(NonPagedPool,
- sizeof(PROCESSINFO), 'p23W');
+ sizeof(PROCESSINFO),
+ USERTAG_PROCESSINFO);
if (!Win32Process) return STATUS_NO_MEMORY;
@@ -181,6 +182,10 @@
ZwClose(Win32Process->idle_event_handle);
}
+ /* Free the PROCESSINFO */
+ PsSetProcessWin32Process(Process, NULL, Win32Process);
+ ExFreePoolWithTag(Win32Process, USERTAG_PROCESSINFO);
+
UserLeave();
}
@@ -195,7 +200,11 @@
{
NTSTATUS Status;
- DPRINT("Enter Win32kThreadCallback, current thread id %d, process id %d\n",
PsGetCurrentThread()->Tcb.Teb->ClientId.UniqueThread,
PsGetCurrentThread()->Tcb.Teb->ClientId.UniqueProcess);
+ UserEnterExclusive();
+
+ DPRINT("Enter Win32kThreadCallback, current thread id %d, process id %d, type
%d\n",
+ PsGetCurrentThread()->Tcb.Teb->ClientId.UniqueThread,
+ PsGetCurrentThread()->Tcb.Teb->ClientId.UniqueProcess, Type);
ASSERT(NtCurrentTeb());
@@ -209,6 +218,8 @@
}
DPRINT("Leave Win32kThreadCallback\n");
+
+ UserLeave();
return Status;
}