Author: ion
Date: Sat Jul 23 11:43:57 2011
New Revision: 52802
URL: http://svn.reactos.org/svn/reactos?rev=52802&view=rev
Log:
[KERNEL32]: Bug #42: GetThreadPriority was only returning -2, -1, 0, 1, 2 or 15 and -15. For realtime threads, priorities of 3, 4, 5, 6, 7, and their negatives, are also valid. Also, GetThreadPriority was returning -15/15 for any priorty outside the -2/2 range, instead of just the special saturation values (I should count this as a separate bug, really...)
Modified:
trunk/reactos/dll/win32/kernel32/client/thread.c
Modified: trunk/reactos/dll/win32/kernel32/client/thread.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] Sat Jul 23 11:43:57 2011
@@ -621,13 +621,15 @@
return THREAD_PRIORITY_ERROR_RETURN;
}
- /* Do some conversions for out of boundary values */
- if (ThreadBasic.BasePriority > THREAD_BASE_PRIORITY_MAX)
- {
+ /* Do some conversions for saturation values */
+ if (ThreadBasic.BasePriority == ((HIGH_PRIORITY + 1) / 2))
+ {
+ /* Win32 calls this "time critical" */
ThreadBasic.BasePriority = THREAD_PRIORITY_TIME_CRITICAL;
}
- else if (ThreadBasic.BasePriority < THREAD_BASE_PRIORITY_MIN)
- {
+ else if (ThreadBasic.BasePriority == -((HIGH_PRIORITY + 1) / 2))
+ {
+ /* Win32 calls this "idle" */
ThreadBasic.BasePriority = THREAD_PRIORITY_IDLE;
}
Author: ion
Date: Sat Jul 23 11:38:58 2011
New Revision: 52801
URL: http://svn.reactos.org/svn/reactos?rev=52801&view=rev
Log:
[KERNEL32]:
Bug #39: BaseThreadStartup needs to call CsrNewThread (which registers the termination port with CSRSS) for Win32 threads.
Bug #40: If a crash happens during thread execution, ExitProcess should be called instead of ExitThread (unless this is a CSR thread).
Bug #41: The ExitThread/Process APIs should be called still from within the context of the SEH frame, not outside of it.
Use BaseRunningInServerProcess global instead of local IsServer local when connecting to CSRSS. This is needed for things such as the above.
Modified:
trunk/reactos/dll/win32/kernel32/client/dllmain.c
trunk/reactos/dll/win32/kernel32/client/thread.c
trunk/reactos/dll/win32/kernel32/include/kernel32.h
Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Sat Jul 23 11:38:58 2011
@@ -21,6 +21,8 @@
extern UNICODE_STRING SystemDirectory;
extern UNICODE_STRING WindowsDirectory;
+
+BOOLEAN BaseRunningInServerProcess;
WCHAR BaseDefaultPathBuffer[6140];
@@ -258,7 +260,6 @@
LPVOID lpReserved)
{
NTSTATUS Status;
- BOOLEAN IsServer;
ULONG Dummy;
ULONG DummySize = sizeof(Dummy);
WCHAR SessionDir[256];
@@ -304,7 +305,7 @@
InWindows ? 1 : 0,
&Dummy,
&DummySize,
- &IsServer);
+ &BaseRunningInServerProcess);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to connect to CSR (Status %lx)\n", Status);
@@ -313,7 +314,7 @@
}
/* Check if we are running a CSR Server */
- if (!IsServer)
+ if (!BaseRunningInServerProcess)
{
/* Set the termination port for the thread */
DPRINT("Creating new thread for CSR\n");
Modified: trunk/reactos/dll/win32/kernel32/client/thread.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] Sat Jul 23 11:38:58 2011
@@ -52,22 +52,34 @@
BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter)
{
- volatile UINT uExitCode = 0;
-
/* Attempt to call the Thread Start Address */
_SEH2_TRY
{
+ /* Legacy check which is still used today for Win32 threads */
+ if (NtCurrentTeb()->NtTib.Version == (30 << 8)) // OS/2 V3.0 ("Cruiser")
+ {
+ /* This registers the termination port with CSRSS */
+ if (!BaseRunningInServerProcess) CsrNewThread();
+ }
+
/* Get the exit code from the Thread Start */
- uExitCode = (lpStartAddress)((PVOID)lpParameter);
+ ExitThread((lpStartAddress)((PVOID)lpParameter));
}
_SEH2_EXCEPT(BaseThreadExceptionFilter(_SEH2_GetExceptionInformation()))
{
/* Get the Exit code from the SEH Handler */
- uExitCode = _SEH2_GetExceptionCode();
- } _SEH2_END;
-
- /* Exit the Thread */
- ExitThread(uExitCode);
+ if (!BaseRunningInServerProcess)
+ {
+ /* Kill the whole process, usually */
+ ExitProcess(_SEH2_GetExceptionCode());
+ }
+ else
+ {
+ /* If running inside CSRSS, kill just this thread */
+ ExitThread(_SEH2_GetExceptionCode());
+ }
+ }
+ _SEH2_END;
}
/*
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Sat Jul 23 11:38:58 2011
@@ -106,6 +106,8 @@
extern SYSTEM_BASIC_INFORMATION BaseCachedSysInfo;
+extern BOOLEAN BaseRunningInServerProcess;
+
/* FUNCTION PROTOTYPES *******************************************************/
BOOL WINAPI VerifyConsoleIoHandle(HANDLE Handle);