diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c index c44a3434b94..739fadb37ce 100644 --- a/dlls/kernel/process.c +++ b/dlls/kernel/process.c @@ -2468,16 +2468,28 @@ void WINAPI ExitProcess16( WORD status ) */ HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id ) { - HANDLE ret = 0; - SERVER_START_REQ( open_process ) + NTSTATUS status; + HANDLE handle; + OBJECT_ATTRIBUTES attr; + CLIENT_ID cid; + + cid.UniqueProcess = (HANDLE)id; + cid.UniqueThread = 0; /* FIXME ? */ + + attr.Length = sizeof(OBJECT_ATTRIBUTES); + attr.RootDirectory = NULL; + attr.Attributes = inherit ? OBJ_INHERIT : 0; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + attr.ObjectName = NULL; + + status = NtOpenProcess(&handle, access, &attr, &cid); + if (status != STATUS_SUCCESS) { - req->pid = id; - req->access = access; - req->inherit = inherit; - if (!wine_server_call_err( req )) ret = reply->handle; + SetLastError( RtlNtStatusToDosError(status) ); + return NULL; } - SERVER_END_REQ; - return ret; + return handle; } diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 0595042977b..c1e7f56de13 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -149,7 +149,7 @@ @ stdcall NtOpenKey(ptr long ptr) @ stdcall NtOpenMutant(ptr long ptr) @ stub NtOpenObjectAuditAlarm -@ stub NtOpenProcess +@ stdcall NtOpenProcess(ptr long ptr ptr) @ stdcall NtOpenProcessToken(long long long) @ stdcall NtOpenSection(ptr long ptr) @ stdcall NtOpenSemaphore(long long ptr) @@ -769,7 +769,7 @@ @ stdcall ZwOpenKey(ptr long ptr) NtOpenKey @ stdcall ZwOpenMutant(ptr long ptr) NtOpenMutant @ stub ZwOpenObjectAuditAlarm -@ stub ZwOpenProcess +@ stdcall ZwOpenProcess(ptr long ptr ptr) NtOpenProcess @ stdcall ZwOpenProcessToken(long long long) NtOpenProcessToken @ stdcall ZwOpenSection(ptr long ptr) NtOpenSection @ stdcall ZwOpenSemaphore(long long ptr) NtOpenSemaphore diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index 4a4f6d84c26..fe05cf9b3f5 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -281,3 +281,24 @@ NTSTATUS WINAPI NtFlushInstructionCache( #endif return STATUS_SUCCESS; } + +/****************************************************************** + * NtOpenProcess [NTDLL.@] + * ZwOpenProcess [NTDLL.@] + */ +NTSTATUS WINAPI NtOpenProcess(PHANDLE handle, ACCESS_MASK access, + const OBJECT_ATTRIBUTES* attr, const CLIENT_ID* cid) +{ + NTSTATUS status; + + SERVER_START_REQ( open_process ) + { + req->pid = (DWORD)cid->UniqueProcess; + req->access = access; + req->inherit = attr && (attr->Attributes & OBJ_INHERIT); + status = wine_server_call( req ); + if (!status) *handle = reply->handle; + } + SERVER_END_REQ; + return status; +} diff --git a/include/winternl.h b/include/winternl.h index 36abdd6f28d..7d4e75d59c8 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1695,6 +1695,7 @@ NTSTATUS WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BL NTSTATUS WINAPI NtOpenIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSTATUS WINAPI NtOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *); NTSTATUS WINAPI NtOpenMutant(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*); +NTSTATUS WINAPI NtOpenProcess(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*); NTSTATUS WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *); NTSTATUS WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSTATUS WINAPI NtOpenSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);