From de6c4c8cb31977bd7f0296a1d83ba7aeb101bb96 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Tue, 2 Nov 2004 21:51:25 +0000 Subject: [PATCH] 1. get rid of InternalGetProcessId() 2. Implemented GetProcessIdOfThread() and GetThreadId() svn path=/trunk/; revision=11531 --- reactos/lib/kernel32/k32.h | 2 +- reactos/lib/kernel32/kernel32.def | 2 ++ reactos/lib/kernel32/misc/handle.c | 7 ++-- reactos/lib/kernel32/process/proc.c | 39 +++++----------------- reactos/lib/kernel32/thread/thread.c | 50 +++++++++++++++++++++++++++- 5 files changed, 64 insertions(+), 36 deletions(-) diff --git a/reactos/lib/kernel32/k32.h b/reactos/lib/kernel32/k32.h index 7eeb80f3b73..bd463828558 100755 --- a/reactos/lib/kernel32/k32.h +++ b/reactos/lib/kernel32/k32.h @@ -1,4 +1,4 @@ -#define _WIN32_WINNT 0x0501 +#define _WIN32_WINNT 0x0502 #define __USE_W32API #define NTOS_MODE_USER #define __NO_CTYPE_INLINES diff --git a/reactos/lib/kernel32/kernel32.def b/reactos/lib/kernel32/kernel32.def index 33b1145435e..f618755bef1 100644 --- a/reactos/lib/kernel32/kernel32.def +++ b/reactos/lib/kernel32/kernel32.def @@ -439,6 +439,7 @@ GetProcessHandleCount@8 GetProcessHeap@0 GetProcessHeaps@8 GetProcessId@4 +GetProcessIdOfThread@4 GetProcessIoCounters@8 GetProcessPriorityBoost@8 GetProcessShutdownParameters@8 @@ -485,6 +486,7 @@ GetTempFileNameW@16 GetTempPathA@8 GetTempPathW@8 GetThreadContext@8 +GetThreadId@4 GetThreadIOPendingFlag@8 GetThreadLocale@0 GetThreadPriority@4 diff --git a/reactos/lib/kernel32/misc/handle.c b/reactos/lib/kernel32/misc/handle.c index af5bcd6be49..264c953ecc6 100644 --- a/reactos/lib/kernel32/misc/handle.c +++ b/reactos/lib/kernel32/misc/handle.c @@ -1,4 +1,4 @@ -/* $Id: handle.c,v 1.18 2004/10/24 12:36:12 weiden Exp $ +/* $Id: handle.c,v 1.19 2004/11/02 21:51:25 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -213,8 +213,9 @@ BOOL STDCALL DuplicateHandle(HANDLE hSourceProcessHandle, if (IsConsoleHandle(hSourceHandle)) { - if (FALSE == InternalGetProcessId(hSourceProcessHandle, &SourceProcessId) || - FALSE == InternalGetProcessId(hTargetProcessHandle, &TargetProcessId) || + SourceProcessId = GetProcessId(hSourceProcessHandle); + TargetProcessId = GetProcessId(hTargetProcessHandle); + if (!SourceProcessId || !TargetProcessId || SourceProcessId != TargetProcessId || SourceProcessId != GetCurrentProcessId()) { diff --git a/reactos/lib/kernel32/process/proc.c b/reactos/lib/kernel32/process/proc.c index d8580124cbf..64389ce927f 100644 --- a/reactos/lib/kernel32/process/proc.c +++ b/reactos/lib/kernel32/process/proc.c @@ -1,4 +1,4 @@ -/* $Id: proc.c,v 1.70 2004/10/19 10:27:11 weiden Exp $ +/* $Id: proc.c,v 1.71 2004/11/02 21:51:25 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -26,10 +26,6 @@ LPSTARTUPINFOA lpLocalStartupInfo = NULL; VOID STDCALL RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle); -BOOL STDCALL -InternalGetProcessId (HANDLE hProcess, LPDWORD lpProcessId); - - /* FUNCTIONS ****************************************************************/ /* @@ -301,44 +297,25 @@ GetExitCodeProcess(HANDLE hProcess, /* * @implemented */ -BOOL STDCALL -InternalGetProcessId(HANDLE hProcess, - LPDWORD lpProcessId) +DWORD +STDCALL +GetProcessId(HANDLE Process) { PROCESS_BASIC_INFORMATION ProcessBasic; NTSTATUS Status; - Status = NtQueryInformationProcess(hProcess, + Status = NtQueryInformationProcess(Process, ProcessBasicInformation, &ProcessBasic, sizeof(PROCESS_BASIC_INFORMATION), NULL); if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return(FALSE); - } - - memcpy(lpProcessId, &ProcessBasic.UniqueProcessId, sizeof(DWORD)); - - return(TRUE); -} - - -/* - * @implemented - */ -DWORD -STDCALL -GetProcessId(HANDLE Process) -{ - DWORD ProcessId; - - if(!InternalGetProcessId(Process, &ProcessId)) { + SetLastErrorByStatus(Status); return 0; } - return ProcessId; + + return ProcessBasic.UniqueProcessId; } diff --git a/reactos/lib/kernel32/thread/thread.c b/reactos/lib/kernel32/thread/thread.c index b5322880b97..7f66d747221 100644 --- a/reactos/lib/kernel32/thread/thread.c +++ b/reactos/lib/kernel32/thread/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.55 2004/11/02 20:42:06 weiden Exp $ +/* $Id: thread.c,v 1.56 2004/11/02 21:51:25 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -714,6 +714,54 @@ SetThreadIdealProcessor(HANDLE hThread, return dwIdealProcessor; } + +/* + * @implemented + */ +DWORD STDCALL +GetProcessIdOfThread(HANDLE Thread) +{ + THREAD_BASIC_INFORMATION ThreadBasic; + NTSTATUS Status; + + Status = NtQueryInformationThread(Thread, + ThreadBasicInformation, + &ThreadBasic, + sizeof(THREAD_BASIC_INFORMATION), + NULL); + if(!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return 0; + } + + return (DWORD)ThreadBasic.ClientId.UniqueProcess; +} + + +/* + * @implemented + */ +DWORD STDCALL +GetThreadId(HANDLE Thread) +{ + THREAD_BASIC_INFORMATION ThreadBasic; + NTSTATUS Status; + + Status = NtQueryInformationThread(Thread, + ThreadBasicInformation, + &ThreadBasic, + sizeof(THREAD_BASIC_INFORMATION), + NULL); + if(!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return 0; + } + + return (DWORD)ThreadBasic.ClientId.UniqueThread; +} + /* * @unimplemented */