Implemented dll detach on thread termination

svn path=/trunk/; revision=1333
This commit is contained in:
Eric Kohl 2000-09-05 13:53:27 +00:00
parent 19e205fb97
commit fbac67d372
5 changed files with 110 additions and 17 deletions

View file

@ -1,4 +1,4 @@
/* $Id: dllmain.c,v 1.14 2000/09/05 10:59:27 ekohl Exp $ /* $Id: dllmain.c,v 1.15 2000/09/05 13:52:04 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -11,6 +11,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntdll/csr.h> #include <ntdll/csr.h>
#include <ntdll/ldr.h>
#include <napi/shared_data.h> #include <napi/shared_data.h>
#include <windows.h> #include <windows.h>
#include <wchar.h> #include <wchar.h>
@ -51,6 +52,9 @@ WINBOOL STDCALL DllMain(HANDLE hInst,
(PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE; (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
DPRINT("DLL_PROCESS_ATTACH\n"); DPRINT("DLL_PROCESS_ATTACH\n");
LdrDisableThreadCalloutsForDll ((PVOID)hInst);
/* /*
* Connect to the csrss server * Connect to the csrss server
*/ */

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.21 2000/09/01 17:09:19 ekohl Exp $ /* $Id: stubs.c,v 1.22 2000/09/05 13:52:04 ekohl Exp $
* *
* KERNEL32.DLL stubs (unimplemented functions) * KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them. * Remove from this file, if you implement them.
@ -748,16 +748,6 @@ ExtendVirtualBuffer (
} }
VOID
STDCALL
FatalExit (
int ExitCode
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
}
ATOM ATOM
STDCALL STDCALL
FindAtomW ( FindAtomW (

View file

@ -1,4 +1,4 @@
/* $Id: proc.c,v 1.34 2000/09/05 11:00:07 ekohl Exp $ /* $Id: proc.c,v 1.35 2000/09/05 13:52:30 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -509,6 +509,16 @@ FatalAppExitW (
} }
VOID
STDCALL
FatalExit (
int ExitCode
)
{
ExitProcess(ExitCode);
}
DWORD DWORD
STDCALL STDCALL
GetPriorityClass ( GetPriorityClass (

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.18 2000/09/01 17:09:50 ekohl Exp $ /* $Id: thread.c,v 1.19 2000/09/05 13:52:44 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -170,6 +170,26 @@ DWORD STDCALL GetCurrentThreadId()
VOID STDCALL ExitThread(UINT uExitCode) VOID STDCALL ExitThread(UINT uExitCode)
{ {
NTSTATUS errCode; NTSTATUS errCode;
BOOLEAN LastThread;
NTSTATUS Status;
/*
* Terminate process if this is the last thread
* of the current process
*/
Status = NtQueryInformationThread(NtCurrentThread(),
ThreadAmILastThread,
&LastThread,
sizeof(BOOLEAN),
NULL);
if (NT_SUCCESS(Status) && LastThread == TRUE)
{
ExitProcess (uExitCode);
}
/* FIXME: notify csrss of thread termination */
LdrShutdownThread();
errCode = NtTerminateThread(NtCurrentThread(), errCode = NtTerminateThread(NtCurrentThread(),
uExitCode); uExitCode);
@ -282,7 +302,7 @@ TerminateThread (
) )
{ {
NTSTATUS errCode; NTSTATUS errCode;
errCode = NtTerminateThread(hThread, errCode = NtTerminateThread(hThread,
dwExitCode); dwExitCode);
if (!NT_SUCCESS(errCode)) if (!NT_SUCCESS(errCode))

View file

@ -92,7 +92,7 @@ NTSTATUS STDCALL NtSetInformationThread(HANDLE ThreadHandle,
break; break;
case ThreadAmILastThread: case ThreadAmILastThread:
break; break;
case ThreadPriorityBoost: case ThreadPriorityBoost:
break; break;
@ -114,7 +114,76 @@ NtQueryInformationThread (
IN ULONG ThreadInformationLength, IN ULONG ThreadInformationLength,
OUT PULONG ReturnLength) OUT PULONG ReturnLength)
{ {
UNIMPLEMENTED PETHREAD Thread;
NTSTATUS Status;
Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_QUERY_INFORMATION,
PsThreadType,
UserMode,
(PVOID*)&Thread,
NULL);
if (!NT_SUCCESS(Status))
{
return Status;
}
switch (ThreadInformationClass)
{
case ThreadBasicInformation:
break;
case ThreadTimes:
break;
case ThreadPriority:
break;
case ThreadBasePriority:
break;
case ThreadAffinityMask:
break;
case ThreadImpersonationToken:
break;
case ThreadDescriptorTableEntry:
UNIMPLEMENTED;
break;
case ThreadEventPair:
UNIMPLEMENTED;
break;
case ThreadQuerySetWin32StartAddress:
break;
case ThreadZeroTlsCell:
break;
case ThreadPerformanceCount:
break;
case ThreadAmILastThread:
{
BOOLEAN *LastThread;
PLIST_ENTRY Entry;
LastThread = (PBOOLEAN) ThreadInformation;
Entry = &(Thread->ThreadsProcess->ThreadListHead);
*LastThread = (Entry->Flink->Flink == Entry)?TRUE:FALSE;
}
break;
case ThreadPriorityBoost:
break;
default:
Status = STATUS_UNSUCCESSFUL;
}
ObDereferenceObject(Thread);
return Status;
} }
VOID KeSetPreviousMode(ULONG Mode) VOID KeSetPreviousMode(ULONG Mode)