From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/Makefile.in | 1 + dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_arm64ec.c | 1 + dlls/ntdll/unix/alpc.c | 35 ++++++++++++++++++++++++ dlls/wow64/struct32.h | 54 +++++++++++++++++++++++++++++++++++++ dlls/wow64/syscall.c | 21 +++++++++++++++ dlls/wow64/wow64_private.h | 21 +++++++++++++++ 7 files changed, 134 insertions(+) create mode 100644 dlls/ntdll/unix/alpc.c diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index 022583aa20e..460aada5c5e 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -49,6 +49,7 @@ SOURCES = \ thread.c \ threadpool.c \ time.c \ + unix/alpc.c \ unix/cdrom.c \ unix/debug.c \ unix/env.c \ diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index f396c334e2d..c317954d125 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -155,6 +155,7 @@ @ stdcall -syscall NtAllocateUuids(ptr ptr ptr ptr) @ stdcall -syscall=0x0018 NtAllocateVirtualMemory(long ptr long ptr long long) @ stdcall -syscall NtAllocateVirtualMemoryEx(long ptr ptr long long ptr long) +@ stdcall -syscall NtAlpcCreatePort(ptr ptr ptr) @ stub -syscall=0x004c NtApphelpCacheControl @ stdcall -syscall NtAreMappedFilesTheSame(ptr ptr) @ stdcall -syscall NtAssignProcessToJobObject(long long) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index c0bfab1157e..92549aa9845 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -364,6 +364,7 @@ DEFINE_SYSCALL(NtAllocateReserveObject, (HANDLE *handle, const OBJECT_ATTRIBUTES DEFINE_SYSCALL(NtAllocateUuids, (ULARGE_INTEGER *time, ULONG *delta, ULONG *sequence, UCHAR *seed)) DEFINE_WRAPPED_SYSCALL(NtAllocateVirtualMemory, (HANDLE process, PVOID *ret, ULONG_PTR zero_bits, SIZE_T *size_ptr, ULONG type, ULONG protect)) DEFINE_WRAPPED_SYSCALL(NtAllocateVirtualMemoryEx, (HANDLE process, PVOID *ret, SIZE_T *size_ptr, ULONG type, ULONG protect, MEM_EXTENDED_PARAMETER *parameters, ULONG count)) +DEFINE_SYSCALL(NtAlpcCreatePort, (HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr)) DEFINE_SYSCALL(NtApphelpCacheControl, (ULONG class, void *context)) DEFINE_SYSCALL(NtAreMappedFilesTheSame, (PVOID addr1, PVOID addr2)) DEFINE_SYSCALL(NtAssignProcessToJobObject, (HANDLE job, HANDLE process)) diff --git a/dlls/ntdll/unix/alpc.c b/dlls/ntdll/unix/alpc.c new file mode 100644 index 00000000000..6aea4daf634 --- /dev/null +++ b/dlls/ntdll/unix/alpc.c @@ -0,0 +1,35 @@ +/* + * Advanced Local Procedure Call + * + * Copyright 2026 Zhiyi Zhang for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "ntstatus.h" +#include "wine/debug.h" +#include "unix_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(alpc); + +NTSTATUS WINAPI NtAlpcCreatePort( HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr ) +{ + FIXME( "%p, %p, %p stub!\n", port_handle, obj_attr, port_attr ); + return STATUS_NOT_IMPLEMENTED; +} diff --git a/dlls/wow64/struct32.h b/dlls/wow64/struct32.h index de378c13cc2..8a490778ae2 100644 --- a/dlls/wow64/struct32.h +++ b/dlls/wow64/struct32.h @@ -749,4 +749,58 @@ typedef struct LARGE_INTEGER TimeLimit; } QUOTA_LIMITS32; +typedef struct +{ + DWORD Length; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; + BOOLEAN EffectiveOnly; +} SECURITY_QUALITY_OF_SERVICE32; + +typedef struct +{ + ULONG Flags; + SECURITY_QUALITY_OF_SERVICE32 SecurityQos; + ULONG MaxMessageLength; + ULONG MemoryBandwidth; + ULONG MaxPoolUsage; + ULONG MaxSectionSize; + ULONG MaxViewSize; + ULONG MaxTotalSectionSize; + ULONG DupObjectTypes; +} ALPC_PORT_ATTRIBUTES32; + +typedef struct +{ + union + { + struct + { + USHORT DataLength; + USHORT TotalLength; + } DUMMYSTRUCTNAME1; + ULONG Length; + } DUMMYUNIONNAME1; + union + { + struct + { + USHORT Type; + USHORT DataInfoOffset; + } DUMMYSTRUCTNAME2; + ULONG ZeroInit; + } DUMMYUNIONNAME2; + union + { + CLIENT_ID32 ClientId; + double DoNotUseThisField; + } DUMMYUNIONNAME3; + ULONG MessageId; + union + { + ULONG ClientViewSize; + ULONG CallbackId; + } DUMMYUNIONNAME4; +} ALPC_PORT_MESSAGE32, *PALPC_PORT_MESSAGE32, ALPC_PORT_MESSAGE_HEADER32, *PALPC_PORT_MESSAGE_HEADER32; + #endif /* __WOW64_STRUCT32_H */ diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 9fdef4a6d9e..7be7579a088 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -463,6 +463,27 @@ NTSTATUS WINAPI wow64_NtAllocateUuids( UINT *args ) return NtAllocateUuids( time, delta, sequence, seed ); } +/********************************************************************** + * wow64_NtAlpcCreatePort + */ +NTSTATUS WINAPI wow64_NtAlpcCreatePort( UINT *args ) +{ + ULONG *handle_ptr = get_ptr( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + ALPC_PORT_ATTRIBUTES32 *port_attr32 = get_ptr( &args ); + NTSTATUS status; + + struct object_attr64 attr; + ALPC_PORT_ATTRIBUTES port_attr; + HANDLE handle = 0; + + if (!handle_ptr) return STATUS_ACCESS_VIOLATION; + + status = NtAlpcCreatePort( &handle, objattr_32to64( &attr, attr32 ), + alpc_port_attributes_32to64( &port_attr, port_attr32 ) ); + if (!status) put_handle( handle_ptr, handle ); + return status; +} /*********************************************************************** * wow64_NtCallbackReturn diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h index deca72d445c..f2d55799341 100644 --- a/dlls/wow64/wow64_private.h +++ b/dlls/wow64/wow64_private.h @@ -194,6 +194,27 @@ static inline OBJECT_ATTRIBUTES *objattr_32to64_redirect( struct object_attr64 * return attr; } +static inline ALPC_PORT_ATTRIBUTES *alpc_port_attributes_32to64( ALPC_PORT_ATTRIBUTES *out, + const ALPC_PORT_ATTRIBUTES32 *in ) +{ + if (!in) return NULL; + + out->Flags = in->Flags; + out->SecurityQos.Length = in->SecurityQos.Length; + out->SecurityQos.ImpersonationLevel = in->SecurityQos.ImpersonationLevel; + out->SecurityQos.ContextTrackingMode = in->SecurityQos.ContextTrackingMode; + out->SecurityQos.EffectiveOnly = in->SecurityQos.EffectiveOnly; + out->MaxMessageLength = in->MaxMessageLength + (sizeof(ALPC_PORT_MESSAGE) - sizeof(ALPC_PORT_MESSAGE32)); + out->MemoryBandwidth = in->MemoryBandwidth; + out->MaxPoolUsage = in->MaxPoolUsage; + out->MaxSectionSize = in->MaxSectionSize; + out->MaxViewSize = in->MaxViewSize; + out->MaxTotalSectionSize = in->MaxTotalSectionSize; + out->DupObjectTypes = in->DupObjectTypes; + out->Reserved = 0; + return out; +} + static inline TOKEN_USER *token_user_32to64( TOKEN_USER *out, const TOKEN_USER32 *in ) { out->User.Sid = ULongToPtr( in->User.Sid ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10932