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
* PROJECT: ReactOS system libraries
@ -11,6 +11,7 @@
#include <ddk/ntddk.h>
#include <ntdll/csr.h>
#include <ntdll/ldr.h>
#include <napi/shared_data.h>
#include <windows.h>
#include <wchar.h>
@ -51,6 +52,9 @@ WINBOOL STDCALL DllMain(HANDLE hInst,
(PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
DPRINT("DLL_PROCESS_ATTACH\n");
LdrDisableThreadCalloutsForDll ((PVOID)hInst);
/*
* 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)
* Remove from this file, if you implement them.
@ -748,16 +748,6 @@ ExtendVirtualBuffer (
}
VOID
STDCALL
FatalExit (
int ExitCode
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
}
ATOM
STDCALL
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
* PROJECT: ReactOS system libraries
@ -509,6 +509,16 @@ FatalAppExitW (
}
VOID
STDCALL
FatalExit (
int ExitCode
)
{
ExitProcess(ExitCode);
}
DWORD
STDCALL
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
* PROJECT: ReactOS system libraries
@ -170,6 +170,26 @@ DWORD STDCALL GetCurrentThreadId()
VOID STDCALL ExitThread(UINT uExitCode)
{
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(),
uExitCode);

View file

@ -114,7 +114,76 @@ NtQueryInformationThread (
IN ULONG ThreadInformationLength,
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)