[PATCH 0/6] MR10932: Add ALPC stubs.
For React Native. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10932
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 b6a9aa5f045..0c9e8809e9e 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -355,6 +355,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
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_arm64ec.c | 1 + dlls/ntdll/unix/alpc.c | 13 ++ dlls/wow64/struct32.h | 55 ++++++++ dlls/wow64/syscall.c | 83 ++++++++++++ dlls/wow64/wow64_private.h | 255 ++++++++++++++++++++++++++++++++++++ 6 files changed, 408 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index c317954d125..9c486240b81 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 NtAlpcConnectPort(ptr ptr ptr ptr long ptr ptr ptr ptr ptr ptr) @ stdcall -syscall NtAlpcCreatePort(ptr ptr ptr) @ stub -syscall=0x004c NtApphelpCacheControl @ stdcall -syscall NtAreMappedFilesTheSame(ptr ptr) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index 0c9e8809e9e..17814e8db3a 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -355,6 +355,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(NtAlpcConnectPort, (HANDLE *port_handle, UNICODE_STRING *port_name, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, ULONG flags, SID *required_server_sid, PORT_MESSAGE *connect_msg, SIZE_T *connect_msg_size, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) 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)) diff --git a/dlls/ntdll/unix/alpc.c b/dlls/ntdll/unix/alpc.c index 6aea4daf634..3a55e6cc8fd 100644 --- a/dlls/ntdll/unix/alpc.c +++ b/dlls/ntdll/unix/alpc.c @@ -28,6 +28,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(alpc); +NTSTATUS WINAPI NtAlpcConnectPort( HANDLE *port_handle, UNICODE_STRING *port_name, + OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, + DWORD flags, PSID required_server_sid, + ALPC_PORT_MESSAGE *connect_msg, SIZE_T *connect_msg_size, + ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, + ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout ) +{ + FIXME( "%p, %s, %p, %p, %#x, %p, %p, %p, %p, %p, %p stub!\n", port_handle, + debugstr_us( port_name ), obj_attr, port_attr, (unsigned int)flags, required_server_sid, + connect_msg, connect_msg_size, send_msg_attr, recv_msg_attr, timeout ); + return STATUS_NOT_IMPLEMENTED; +} + 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 ); diff --git a/dlls/wow64/struct32.h b/dlls/wow64/struct32.h index 8a490778ae2..ba2bc02523f 100644 --- a/dlls/wow64/struct32.h +++ b/dlls/wow64/struct32.h @@ -803,4 +803,59 @@ typedef struct } DUMMYUNIONNAME4; } ALPC_PORT_MESSAGE32, *PALPC_PORT_MESSAGE32, ALPC_PORT_MESSAGE_HEADER32, *PALPC_PORT_MESSAGE_HEADER32; +typedef struct +{ + ULONG AllocatedAttributes; + ULONG ValidAttributes; +} ALPC_MESSAGE_ATTRIBUTES32, *PALPC_MESSAGE_ATTRIBUTES32; + +typedef struct +{ + ULONG Flags; + ULONG QoSPointer; + ULONG ContextHandle; +} ALPC_SECURITY_ATTR32, *PALPC_SECURITY_ATTR32; + +typedef struct +{ + ULONG Flags; + ULONG SectionHandle; + ULONG ViewBase; + ULONG ViewSize; +} ALPC_VIEW_ATTR32, *PALPC_VIEW_ATTR32; + +typedef struct +{ + ULONG PortContext; + ULONG MessageContext; + ULONG Sequence; + ULONG MessageId; + ULONG CallbackId; +} ALPC_CONTEXT_ATTR32, *PALPC_CONTEXT_ATTR32; + +typedef struct +{ + ULONG Flags; + ULONG Handle; + ULONG ObjectType; + ULONG DesiredAccess; +} ALPC_HANDLE_ATTR32, *PALPC_HANDLE_ATTR32; + +typedef struct +{ + ULONGLONG TokenId; + ULONGLONG AuthenticationId; + ULONGLONG ModifiedId; +} ALPC_TOKEN_ATTR32, *PALPC_TOKEN_ATTR32; + +typedef struct +{ + ULONG Event; +} ALPC_DIRECT_ATTR32, *PALPC_DIRECT_ATTR32; + +typedef struct +{ + ULONGLONG Ticket; +} ALPC_WORK_ON_BEHALF_ATTR32, *PALPC_WORK_ON_BEHALF_ATTR32; + #endif /* __WOW64_STRUCT32_H */ diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 7be7579a088..29250959836 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -463,6 +463,89 @@ NTSTATUS WINAPI wow64_NtAllocateUuids( UINT *args ) return NtAllocateUuids( time, delta, sequence, seed ); } +/********************************************************************** + * wow64_NtAlpcConnectPort + */ +NTSTATUS WINAPI wow64_NtAlpcConnectPort( UINT *args ) +{ + ULONG *handle_ptr = get_ptr( &args ); + UNICODE_STRING32 *str32 = get_ptr( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + ALPC_PORT_ATTRIBUTES32 *port_attr32 = get_ptr( &args ); + ULONG flags = get_ulong( &args ); + SID *sid = get_ptr( &args ); + ALPC_PORT_MESSAGE32 *msg32 = get_ptr( &args ); + ULONG *size32 = get_ptr( &args ); + ALPC_MESSAGE_ATTRIBUTES32 *send_msg_attr32 = get_ptr( &args ); + ALPC_MESSAGE_ATTRIBUTES32 *recv_msg_attr32 = get_ptr( &args ); + LARGE_INTEGER *timeout = get_ptr( &args ); + NTSTATUS status; + + HANDLE handle = 0; + UNICODE_STRING str; + struct object_attr64 attr; + ALPC_PORT_ATTRIBUTES port_attr; + ALPC_PORT_MESSAGE *msg = NULL; + SIZE_T size = size32 ? (*size32 + sizeof(ALPC_PORT_MESSAGE) - sizeof(ALPC_PORT_MESSAGE32)) : 65535; + ALPC_MESSAGE_ATTRIBUTES *send_msg_attr = NULL; + ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr = NULL; + SECURITY_QUALITY_OF_SERVICE send_qos; + SECURITY_QUALITY_OF_SERVICE recv_qos; + + if (!handle_ptr) return STATUS_OBJECT_NAME_NOT_FOUND; + + if (port_attr32 && (!port_attr32->MaxMessageLength + || port_attr32->MaxMessageLength > (65535 - (sizeof(ALPC_PORT_MESSAGE) - sizeof(ALPC_PORT_MESSAGE32))))) + return STATUS_INVALID_PARAMETER; + + if (msg32) + { + msg = RtlAllocateHeap( GetProcessHeap(), 0, size ); + if (!msg) return STATUS_NO_MEMORY; + } + + if (send_msg_attr32) + { + send_msg_attr = RtlAllocateHeap( GetProcessHeap(), 0, AlpcGetHeaderSize( send_msg_attr32->AllocatedAttributes ) ); + if (!send_msg_attr) + { + RtlFreeHeap( GetProcessHeap(), 0, msg ); + return STATUS_NO_MEMORY; + } + } + + if (recv_msg_attr32) + { + recv_msg_attr = RtlAllocateHeap( GetProcessHeap(), 0, AlpcGetHeaderSize( recv_msg_attr32->AllocatedAttributes ) ); + if (!recv_msg_attr) + { + RtlFreeHeap( GetProcessHeap(), 0, send_msg_attr ); + RtlFreeHeap( GetProcessHeap(), 0, msg ); + return STATUS_NO_MEMORY; + } + } + + status = NtAlpcConnectPort( &handle, unicode_str_32to64( &str, str32 ), objattr_32to64( &attr, attr32 ), + alpc_port_attributes_32to64( &port_attr, port_attr32 ), flags, sid, + alpc_port_message_32to64( msg, msg32 ), &size, + alpc_port_message_attributes_32to64( send_msg_attr, &send_qos, send_msg_attr32, TRUE ), + alpc_port_message_attributes_32to64( recv_msg_attr, &recv_qos, recv_msg_attr32, FALSE ), timeout); + if (status == STATUS_SUCCESS) + { + put_handle( handle_ptr, handle ); + alpc_port_message_64to32( msg32, msg ); + alpc_port_message_attributes_64to32( recv_msg_attr32, recv_msg_attr ); + } + else if (status == STATUS_BUFFER_TOO_SMALL) + { + put_size( size32, size - (sizeof(ALPC_PORT_MESSAGE) - sizeof(ALPC_PORT_MESSAGE32))); + } + RtlFreeHeap( GetProcessHeap(), 0, msg ); + RtlFreeHeap( GetProcessHeap(), 0, send_msg_attr ); + RtlFreeHeap( GetProcessHeap(), 0, recv_msg_attr ); + return status; +} + /********************************************************************** * wow64_NtAlpcCreatePort */ diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h index f2d55799341..d8ab4c84eb8 100644 --- a/dlls/wow64/wow64_private.h +++ b/dlls/wow64/wow64_private.h @@ -215,6 +215,261 @@ static inline ALPC_PORT_ATTRIBUTES *alpc_port_attributes_32to64( ALPC_PORT_ATTRI return out; } +static inline ALPC_PORT_MESSAGE *alpc_port_message_32to64( ALPC_PORT_MESSAGE *out, + const ALPC_PORT_MESSAGE32 *in ) +{ + if (!in) return NULL; + + out->DataLength = in->DataLength; + out->TotalLength = sizeof(*out) + out->DataLength; + out->Type = in->Type; + out->DataInfoOffset = in->DataInfoOffset; + client_id_32to64( &out->ClientId, &in->ClientId ); + out->MessageId = in->MessageId; + out->ClientViewSize = in->ClientViewSize; + memcpy( (unsigned char *)out + sizeof(*out), (const unsigned char *)in + sizeof(*in), in->DataLength ); + return out; +} + +static inline ALPC_MESSAGE_ATTRIBUTES *alpc_port_message_attributes_32to64( ALPC_MESSAGE_ATTRIBUTES *out, + SECURITY_QUALITY_OF_SERVICE *qos, + const ALPC_MESSAGE_ATTRIBUTES32 *in, + BOOL copy_attributes ) +{ + const unsigned char *current_from_attr; + + if (!in) return NULL; + + out->AllocatedAttributes = in->AllocatedAttributes; + + if (!copy_attributes) + { + out->ValidAttributes = 0; + return out; + } + + out->ValidAttributes = in->ValidAttributes; + current_from_attr = (const unsigned char *)in + sizeof(*in); + + if (in->ValidAttributes & ALPC_MESSAGE_SECURITY_ATTRIBUTE) + { + const ALPC_SECURITY_ATTR32 *from_attr = (const ALPC_SECURITY_ATTR32 *)current_from_attr; + ALPC_SECURITY_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_SECURITY_ATTRIBUTE ); + SECURITY_QUALITY_OF_SERVICE32 *qos32; + + to_attr->Flags = from_attr->Flags; + to_attr->ContextHandle = UlongToHandle( from_attr->ContextHandle ); + if (from_attr->QoSPointer) + { + qos32 = (SECURITY_QUALITY_OF_SERVICE32 *)ULongToPtr( from_attr->QoSPointer ); + to_attr->QoS = qos; + qos->Length = qos32->Length; + qos->ImpersonationLevel = qos32->ImpersonationLevel; + qos->ContextTrackingMode = qos32->ContextTrackingMode; + qos->EffectiveOnly = qos32->EffectiveOnly; + } + else + { + to_attr->QoS = NULL; + } + } + if (in->AllocatedAttributes & ALPC_MESSAGE_SECURITY_ATTRIBUTE) + current_from_attr += sizeof(ALPC_SECURITY_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_VIEW_ATTRIBUTE) + { + const ALPC_VIEW_ATTR32 *from_attr = (const ALPC_VIEW_ATTR32 *)current_from_attr; + ALPC_VIEW_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_VIEW_ATTRIBUTE ); + + to_attr->Flags = from_attr->Flags; + to_attr->SectionHandle = UlongToHandle( from_attr->SectionHandle ); + to_attr->ViewBase = UlongToPtr( from_attr->ViewBase ); + to_attr->ViewSize = from_attr->ViewSize; + } + if (in->AllocatedAttributes & ALPC_MESSAGE_VIEW_ATTRIBUTE) + current_from_attr += sizeof(ALPC_VIEW_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_CONTEXT_ATTRIBUTE) + { + const ALPC_CONTEXT_ATTR32 *from_attr = (const ALPC_CONTEXT_ATTR32 *)current_from_attr; + ALPC_CONTEXT_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_CONTEXT_ATTRIBUTE ); + + to_attr->PortContext = UlongToPtr( from_attr->PortContext ); + to_attr->MessageContext = UlongToPtr( from_attr->MessageContext ); + to_attr->Sequence = from_attr->Sequence; + to_attr->MessageId = from_attr->MessageId; + to_attr->CallbackId = from_attr->CallbackId; + } + if (in->AllocatedAttributes & ALPC_MESSAGE_CONTEXT_ATTRIBUTE) + current_from_attr += sizeof(ALPC_CONTEXT_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_HANDLE_ATTRIBUTE) + { + const ALPC_HANDLE_ATTR32 *from_attr = (const ALPC_HANDLE_ATTR32 *)current_from_attr; + ALPC_HANDLE_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_HANDLE_ATTRIBUTE ); + + to_attr->Flags = from_attr->Flags; + to_attr->Handle = UlongToHandle( from_attr->Handle ); + to_attr->ObjectType = from_attr->ObjectType; + to_attr->DesiredAccess = from_attr->DesiredAccess; + } + if (in->AllocatedAttributes & ALPC_MESSAGE_HANDLE_ATTRIBUTE) + current_from_attr += sizeof(ALPC_HANDLE_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_TOKEN_ATTRIBUTE) + { + const ALPC_TOKEN_ATTR32 *from_attr = (const ALPC_TOKEN_ATTR32 *)current_from_attr; + ALPC_TOKEN_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_TOKEN_ATTRIBUTE ); + + to_attr->TokenId = from_attr->TokenId; + to_attr->AuthenticationId = from_attr->AuthenticationId; + to_attr->ModifiedId = from_attr->ModifiedId; + } + if (in->AllocatedAttributes & ALPC_MESSAGE_TOKEN_ATTRIBUTE) + current_from_attr += sizeof(ALPC_TOKEN_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_DIRECT_ATTRIBUTE) + { + const ALPC_DIRECT_ATTR32 *from_attr = (const ALPC_DIRECT_ATTR32 *)current_from_attr; + ALPC_DIRECT_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_DIRECT_ATTRIBUTE ); + + to_attr->Event = UlongToHandle( from_attr->Event ); + } + if (in->AllocatedAttributes & ALPC_MESSAGE_DIRECT_ATTRIBUTE) + current_from_attr += sizeof(ALPC_DIRECT_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_WORK_ON_BEHALF_ATTRIBUTE) + { + const ALPC_WORK_ON_BEHALF_ATTR32 *from_attr = (const ALPC_WORK_ON_BEHALF_ATTR32 *)current_from_attr; + ALPC_WORK_ON_BEHALF_ATTR *to_attr = AlpcGetMessageAttribute( out, ALPC_MESSAGE_WORK_ON_BEHALF_ATTRIBUTE ); + + to_attr->Ticket = from_attr->Ticket; + } + + return out; +} + +static inline ALPC_PORT_MESSAGE32 *alpc_port_message_64to32( ALPC_PORT_MESSAGE32 *out, + const ALPC_PORT_MESSAGE *in ) +{ + if (!in) return NULL; + + out->DataLength = in->DataLength; + out->TotalLength = sizeof(*out) + in->DataLength; + out->Type = in->Type; + out->DataInfoOffset = in->DataInfoOffset; + out->ClientId.UniqueProcess = HandleToUlong( in->ClientId.UniqueProcess ); + out->ClientId.UniqueThread = HandleToUlong( in->ClientId.UniqueThread ); + out->MessageId = in->MessageId; + out->ClientViewSize = in->ClientViewSize; + memcpy( (unsigned char *)out + sizeof(*out), (const unsigned char *)in + sizeof(*in), in->DataLength ); + return out; +} + +static inline ALPC_MESSAGE_ATTRIBUTES32 *alpc_port_message_attributes_64to32( ALPC_MESSAGE_ATTRIBUTES32 *out, + ALPC_MESSAGE_ATTRIBUTES *in ) +{ + unsigned char *current_to_attr; + + if (!in) return NULL; + + out->AllocatedAttributes = in->AllocatedAttributes; + out->ValidAttributes = in->ValidAttributes; + + current_to_attr = (unsigned char *)out + sizeof(*out); + + if (in->ValidAttributes & ALPC_MESSAGE_SECURITY_ATTRIBUTE) + { + const ALPC_SECURITY_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_SECURITY_ATTRIBUTE ); + ALPC_SECURITY_ATTR32 *to_attr = (ALPC_SECURITY_ATTR32 *)current_to_attr; + + to_attr->Flags = from_attr->Flags; + to_attr->ContextHandle = HandleToUlong( from_attr->ContextHandle ); + if (to_attr->QoSPointer && from_attr->QoS) + { + SECURITY_QUALITY_OF_SERVICE32 *qos32 = ULongToPtr( to_attr->QoSPointer ); + qos32->ImpersonationLevel = from_attr->QoS->ImpersonationLevel; + qos32->ContextTrackingMode = from_attr->QoS->ContextTrackingMode; + qos32->EffectiveOnly = from_attr->QoS->EffectiveOnly; + } + } + if (out->AllocatedAttributes & ALPC_MESSAGE_SECURITY_ATTRIBUTE) + current_to_attr += sizeof(ALPC_SECURITY_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_VIEW_ATTRIBUTE) + { + const ALPC_VIEW_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_VIEW_ATTRIBUTE ); + ALPC_VIEW_ATTR32 *to_attr = (ALPC_VIEW_ATTR32 *)current_to_attr; + + to_attr->Flags = from_attr->Flags; + to_attr->SectionHandle = HandleToUlong( from_attr->SectionHandle ); + to_attr->ViewBase = PtrToUlong( from_attr->ViewBase ); + to_attr->ViewSize = from_attr->ViewSize; + } + if (out->AllocatedAttributes & ALPC_MESSAGE_VIEW_ATTRIBUTE) + current_to_attr += sizeof(ALPC_VIEW_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_CONTEXT_ATTRIBUTE) + { + const ALPC_CONTEXT_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_CONTEXT_ATTRIBUTE ); + ALPC_CONTEXT_ATTR32 *to_attr = (ALPC_CONTEXT_ATTR32 *)current_to_attr; + + to_attr->PortContext = PtrToUlong( from_attr->PortContext ); + to_attr->MessageContext = PtrToUlong( from_attr->MessageContext ); + to_attr->Sequence = from_attr->Sequence; + /* Should be from_attr->MessageId. But tests show that it's always 0 on 32-bit */ + to_attr->MessageId = 0; + to_attr->CallbackId = from_attr->CallbackId; + } + if (out->AllocatedAttributes & ALPC_MESSAGE_CONTEXT_ATTRIBUTE) + current_to_attr += sizeof(ALPC_CONTEXT_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_HANDLE_ATTRIBUTE) + { + const ALPC_HANDLE_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_HANDLE_ATTRIBUTE ); + ALPC_HANDLE_ATTR32 *to_attr = (ALPC_HANDLE_ATTR32 *)current_to_attr; + + to_attr->Flags = from_attr->Flags; + to_attr->Handle = HandleToUlong( from_attr->Handle ); + to_attr->ObjectType = from_attr->ObjectType; + to_attr->DesiredAccess = from_attr->DesiredAccess; + } + if (out->AllocatedAttributes & ALPC_MESSAGE_HANDLE_ATTRIBUTE) + current_to_attr += sizeof(ALPC_HANDLE_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_TOKEN_ATTRIBUTE) + { + const ALPC_TOKEN_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_TOKEN_ATTRIBUTE ); + ALPC_TOKEN_ATTR32 *to_attr = (ALPC_TOKEN_ATTR32 *)current_to_attr; + + to_attr->TokenId = from_attr->TokenId; + to_attr->AuthenticationId = from_attr->AuthenticationId; + to_attr->ModifiedId = from_attr->ModifiedId; + } + if (out->AllocatedAttributes & ALPC_MESSAGE_TOKEN_ATTRIBUTE) + current_to_attr += sizeof(ALPC_TOKEN_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_DIRECT_ATTRIBUTE) + { + const ALPC_DIRECT_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_DIRECT_ATTRIBUTE ); + ALPC_DIRECT_ATTR32 *to_attr = (ALPC_DIRECT_ATTR32 *)current_to_attr; + + to_attr->Event = HandleToUlong( from_attr->Event ); + } + if (out->AllocatedAttributes & ALPC_MESSAGE_DIRECT_ATTRIBUTE) + current_to_attr += sizeof(ALPC_DIRECT_ATTR32); + + if (in->ValidAttributes & ALPC_MESSAGE_WORK_ON_BEHALF_ATTRIBUTE) + { + const ALPC_WORK_ON_BEHALF_ATTR *from_attr = AlpcGetMessageAttribute( in, ALPC_MESSAGE_WORK_ON_BEHALF_ATTRIBUTE ); + ALPC_WORK_ON_BEHALF_ATTR32 *to_attr = (ALPC_WORK_ON_BEHALF_ATTR32 *)current_to_attr; + + to_attr->Ticket = from_attr->Ticket; + } + + 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
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_arm64ec.c | 1 + dlls/ntdll/unix/alpc.c | 11 ++++++++ dlls/wow64/syscall.c | 52 +++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 9c486240b81..05160b37a14 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 NtAlpcAcceptConnectPort(ptr ptr long ptr ptr ptr ptr ptr long) @ stdcall -syscall NtAlpcConnectPort(ptr ptr ptr ptr long ptr ptr ptr ptr ptr ptr) @ stdcall -syscall NtAlpcCreatePort(ptr ptr ptr) @ stub -syscall=0x004c NtApphelpCacheControl diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index 17814e8db3a..6674a837789 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -355,6 +355,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(NtAlpcAcceptConnectPort, (HANDLE *communication_port, HANDLE connection_port, DWORD flags, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, void *port_context, ALPC_PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, BOOLEAN accept)) DEFINE_SYSCALL(NtAlpcConnectPort, (HANDLE *port_handle, UNICODE_STRING *port_name, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, ULONG flags, SID *required_server_sid, PORT_MESSAGE *connect_msg, SIZE_T *connect_msg_size, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) DEFINE_SYSCALL(NtAlpcCreatePort, (HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr)) DEFINE_SYSCALL(NtApphelpCacheControl, (ULONG class, void *context)) diff --git a/dlls/ntdll/unix/alpc.c b/dlls/ntdll/unix/alpc.c index 3a55e6cc8fd..2e2d6e4c137 100644 --- a/dlls/ntdll/unix/alpc.c +++ b/dlls/ntdll/unix/alpc.c @@ -28,6 +28,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(alpc); +NTSTATUS WINAPI NtAlpcAcceptConnectPort( HANDLE *communication_port, HANDLE connection_port, + DWORD flags, OBJECT_ATTRIBUTES *obj_attr, + ALPC_PORT_ATTRIBUTES *port_attr, void *port_context, + ALPC_PORT_MESSAGE *send_msg, + ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, BOOLEAN accept ) +{ + FIXME( "%p, %p, %#x, %p, %p, %p, %p, %p, %d stub!\n", communication_port, connection_port, + (unsigned int)flags, obj_attr, port_attr, port_context, send_msg, send_msg_attr, accept ); + return STATUS_NOT_IMPLEMENTED; +} + NTSTATUS WINAPI NtAlpcConnectPort( HANDLE *port_handle, UNICODE_STRING *port_name, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, DWORD flags, PSID required_server_sid, diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 29250959836..5620d41b28e 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -463,6 +463,58 @@ NTSTATUS WINAPI wow64_NtAllocateUuids( UINT *args ) return NtAllocateUuids( time, delta, sequence, seed ); } +/********************************************************************** + * wow64_NtAlpcAcceptConnectPort + */ +NTSTATUS WINAPI wow64_NtAlpcAcceptConnectPort( UINT *args ) +{ + ULONG *communication_port_ptr = get_ptr( &args ); + HANDLE connection_port = get_handle( &args ); + ULONG flags = get_ulong( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + ALPC_PORT_ATTRIBUTES32 *port_attr32 = get_ptr( &args ); + void *context = get_ptr( &args ); + ALPC_PORT_MESSAGE32 *msg32 = get_ptr( &args ); + ALPC_MESSAGE_ATTRIBUTES32 *msg_attr32 = get_ptr( &args ); + BOOLEAN accept = get_ulong( &args ); + NTSTATUS status; + + HANDLE communication_port = 0; + struct object_attr64 attr; + ALPC_PORT_ATTRIBUTES port_attr; + ALPC_PORT_MESSAGE *msg = NULL; + ALPC_MESSAGE_ATTRIBUTES *msg_attr = NULL; + SECURITY_QUALITY_OF_SERVICE qos; + + if (msg32) + { + msg = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*msg) + msg32->DataLength ); + if (!msg) return STATUS_NO_MEMORY; + } + + if (msg_attr32) + { + msg_attr = RtlAllocateHeap( GetProcessHeap(), 0, AlpcGetHeaderSize( msg_attr32->AllocatedAttributes ) ); + if (!msg_attr) + { + RtlFreeHeap( GetProcessHeap(), 0, msg ); + return STATUS_NO_MEMORY; + } + } + + status = NtAlpcAcceptConnectPort( communication_port_ptr ? &communication_port : NULL, + connection_port, flags, objattr_32to64( &attr, attr32 ), + alpc_port_attributes_32to64( &port_attr, port_attr32 ), context, + alpc_port_message_32to64( msg, msg32 ), + alpc_port_message_attributes_32to64( msg_attr, &qos, msg_attr32, TRUE ), + accept); + if (status == STATUS_SUCCESS && accept && communication_port_ptr) + put_handle( communication_port_ptr, communication_port ); + RtlFreeHeap( GetProcessHeap(), 0, msg ); + RtlFreeHeap( GetProcessHeap(), 0, msg_attr ); + return status; +} + /********************************************************************** * wow64_NtAlpcConnectPort */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10932
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_arm64ec.c | 1 + dlls/ntdll/unix/alpc.c | 12 ++++++ dlls/wow64/syscall.c | 82 +++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 05160b37a14..84b35d44cc7 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -158,6 +158,7 @@ @ stdcall -syscall NtAlpcAcceptConnectPort(ptr ptr long ptr ptr ptr ptr ptr long) @ stdcall -syscall NtAlpcConnectPort(ptr ptr ptr ptr long ptr ptr ptr ptr ptr ptr) @ stdcall -syscall NtAlpcCreatePort(ptr ptr ptr) +@ stdcall -syscall NtAlpcSendWaitReceivePort(ptr long ptr ptr ptr 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 6674a837789..119c606b07c 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -358,6 +358,7 @@ DEFINE_WRAPPED_SYSCALL(NtAllocateVirtualMemoryEx, (HANDLE process, PVOID *ret, S DEFINE_SYSCALL(NtAlpcAcceptConnectPort, (HANDLE *communication_port, HANDLE connection_port, DWORD flags, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, void *port_context, ALPC_PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, BOOLEAN accept)) DEFINE_SYSCALL(NtAlpcConnectPort, (HANDLE *port_handle, UNICODE_STRING *port_name, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, ULONG flags, SID *required_server_sid, PORT_MESSAGE *connect_msg, SIZE_T *connect_msg_size, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) DEFINE_SYSCALL(NtAlpcCreatePort, (HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr)) +DEFINE_SYSCALL(NtAlpcSendWaitReceivePort, (HANDLE port_handle, ULONG flags, PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, PORT_MESSAGE *recv_msg, SIZE_T *recv_buffer_size, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) 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 index 2e2d6e4c137..f4b691c5033 100644 --- a/dlls/ntdll/unix/alpc.c +++ b/dlls/ntdll/unix/alpc.c @@ -57,3 +57,15 @@ NTSTATUS WINAPI NtAlpcCreatePort( HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_at FIXME( "%p, %p, %p stub!\n", port_handle, obj_attr, port_attr ); return STATUS_NOT_IMPLEMENTED; } + +NTSTATUS WINAPI NtAlpcSendWaitReceivePort( HANDLE port_handle, ULONG flags, + ALPC_PORT_MESSAGE *send_msg, + ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, + ALPC_PORT_MESSAGE *recv_msg, SIZE_T *recv_buffer_size, + ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, + LARGE_INTEGER *timeout ) +{ + FIXME( "%p, %#x, %p, %p, %p, %p, %p, %p stub!\n", port_handle, (unsigned int)flags, send_msg, + send_msg_attr, recv_msg, recv_buffer_size, recv_msg_attr, timeout ); + return STATUS_NOT_IMPLEMENTED; +} diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 5620d41b28e..0e052d2548d 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -620,6 +620,88 @@ NTSTATUS WINAPI wow64_NtAlpcCreatePort( UINT *args ) return status; } +/********************************************************************** + * wow64_NtAlpcSendWaitReceivePort + */ +NTSTATUS WINAPI wow64_NtAlpcSendWaitReceivePort( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ULONG flags = get_ulong( &args ); + ALPC_PORT_MESSAGE32 *send_msg32 = get_ptr( &args ); + ALPC_MESSAGE_ATTRIBUTES32 *send_msg_attr32 = get_ptr( &args ); + ALPC_PORT_MESSAGE32 *recv_msg32 = get_ptr( &args ); + ULONG *size32 = get_ptr( &args ); + ALPC_MESSAGE_ATTRIBUTES32 *recv_msg_attr32 = get_ptr( &args ); + LARGE_INTEGER *timeout = get_ptr( &args ); + NTSTATUS status; + + ALPC_PORT_MESSAGE *send_msg = NULL; + ALPC_MESSAGE_ATTRIBUTES *send_msg_attr = NULL; + ALPC_PORT_MESSAGE *recv_msg = NULL; + ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr = NULL; + SIZE_T size = size32 ? (*size32 + sizeof(ALPC_PORT_MESSAGE) - sizeof(ALPC_PORT_MESSAGE32)) : 65535; + SECURITY_QUALITY_OF_SERVICE send_qos; + SECURITY_QUALITY_OF_SERVICE recv_qos; + + if (send_msg32) + { + send_msg = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*send_msg) + send_msg32->DataLength ); + if (!send_msg) return STATUS_NO_MEMORY; + } + + if (send_msg_attr32) + { + send_msg_attr = RtlAllocateHeap( GetProcessHeap(), 0, AlpcGetHeaderSize( send_msg_attr32->AllocatedAttributes ) ); + if (!send_msg_attr) + { + RtlFreeHeap( GetProcessHeap(), 0, send_msg ); + return STATUS_NO_MEMORY; + } + } + + if (recv_msg32) + { + recv_msg = RtlAllocateHeap( GetProcessHeap(), 0, size ); + if (!recv_msg) + { + RtlFreeHeap( GetProcessHeap(), 0, send_msg_attr ); + RtlFreeHeap( GetProcessHeap(), 0, send_msg ); + return STATUS_NO_MEMORY; + } + } + + if (recv_msg_attr32) + { + recv_msg_attr = RtlAllocateHeap( GetProcessHeap(), 0, AlpcGetHeaderSize( recv_msg_attr32->AllocatedAttributes ) ); + if (!recv_msg_attr) + { + RtlFreeHeap( GetProcessHeap(), 0, recv_msg ); + RtlFreeHeap( GetProcessHeap(), 0, send_msg_attr ); + RtlFreeHeap( GetProcessHeap(), 0, send_msg ); + return STATUS_NO_MEMORY; + } + } + + status = NtAlpcSendWaitReceivePort( handle, flags, alpc_port_message_32to64( send_msg, send_msg32 ), + alpc_port_message_attributes_32to64( send_msg_attr, &send_qos, send_msg_attr32, TRUE ), + recv_msg, &size, + alpc_port_message_attributes_32to64( recv_msg_attr, &recv_qos, recv_msg_attr32, FALSE ), timeout ); + if (status == STATUS_SUCCESS) + { + alpc_port_message_64to32( recv_msg32, recv_msg ); + alpc_port_message_attributes_64to32( recv_msg_attr32, recv_msg_attr ); + } + else if (status == STATUS_BUFFER_TOO_SMALL && size32) + { + put_size( size32, size - (sizeof(ALPC_PORT_MESSAGE) - sizeof(ALPC_PORT_MESSAGE32)) ); + } + RtlFreeHeap( GetProcessHeap(), 0, recv_msg_attr ); + RtlFreeHeap( GetProcessHeap(), 0, recv_msg ); + RtlFreeHeap( GetProcessHeap(), 0, send_msg_attr ); + RtlFreeHeap( GetProcessHeap(), 0, send_msg ); + return status; +} + /*********************************************************************** * wow64_NtCallbackReturn */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10932
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_arm64ec.c | 1 + dlls/ntdll/unix/alpc.c | 6 ++++++ dlls/wow64/syscall.c | 11 +++++++++++ 4 files changed, 19 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 84b35d44cc7..d64a680534b 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -158,6 +158,7 @@ @ stdcall -syscall NtAlpcAcceptConnectPort(ptr ptr long ptr ptr ptr ptr ptr long) @ stdcall -syscall NtAlpcConnectPort(ptr ptr ptr ptr long ptr ptr ptr ptr ptr ptr) @ stdcall -syscall NtAlpcCreatePort(ptr ptr ptr) +@ stdcall -syscall NtAlpcDisconnectPort(ptr long) @ stdcall -syscall NtAlpcSendWaitReceivePort(ptr long ptr ptr ptr ptr ptr ptr) @ stub -syscall=0x004c NtApphelpCacheControl @ stdcall -syscall NtAreMappedFilesTheSame(ptr ptr) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index 119c606b07c..e6ede210221 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -358,6 +358,7 @@ DEFINE_WRAPPED_SYSCALL(NtAllocateVirtualMemoryEx, (HANDLE process, PVOID *ret, S DEFINE_SYSCALL(NtAlpcAcceptConnectPort, (HANDLE *communication_port, HANDLE connection_port, DWORD flags, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, void *port_context, ALPC_PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, BOOLEAN accept)) DEFINE_SYSCALL(NtAlpcConnectPort, (HANDLE *port_handle, UNICODE_STRING *port_name, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, ULONG flags, SID *required_server_sid, PORT_MESSAGE *connect_msg, SIZE_T *connect_msg_size, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) DEFINE_SYSCALL(NtAlpcCreatePort, (HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr)) +DEFINE_SYSCALL(NtAlpcDisconnectPort, (HANDLE port_handle, ULONG flags)) DEFINE_SYSCALL(NtAlpcSendWaitReceivePort, (HANDLE port_handle, ULONG flags, PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, PORT_MESSAGE *recv_msg, SIZE_T *recv_buffer_size, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) DEFINE_SYSCALL(NtApphelpCacheControl, (ULONG class, void *context)) DEFINE_SYSCALL(NtAreMappedFilesTheSame, (PVOID addr1, PVOID addr2)) diff --git a/dlls/ntdll/unix/alpc.c b/dlls/ntdll/unix/alpc.c index f4b691c5033..d6ad52974b1 100644 --- a/dlls/ntdll/unix/alpc.c +++ b/dlls/ntdll/unix/alpc.c @@ -58,6 +58,12 @@ NTSTATUS WINAPI NtAlpcCreatePort( HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_at return STATUS_NOT_IMPLEMENTED; } +NTSTATUS WINAPI NtAlpcDisconnectPort( HANDLE port_handle, ULONG flags ) +{ + FIXME( "%p, %#x stub!\n", port_handle, (unsigned int)flags ); + return STATUS_NOT_IMPLEMENTED; +} + NTSTATUS WINAPI NtAlpcSendWaitReceivePort( HANDLE port_handle, ULONG flags, ALPC_PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 0e052d2548d..030c56b3a50 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -620,6 +620,17 @@ NTSTATUS WINAPI wow64_NtAlpcCreatePort( UINT *args ) return status; } +/********************************************************************** + * wow64_NtAlpcDisconnectPort + */ +NTSTATUS WINAPI wow64_NtAlpcDisconnectPort( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ULONG flags = get_ulong( &args ); + + return NtAlpcDisconnectPort( handle, flags ); +} + /********************************************************************** * wow64_NtAlpcSendWaitReceivePort */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10932
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/signal_arm64ec.c | 1 + dlls/ntdll/unix/alpc.c | 6 ++++++ dlls/wow64/syscall.c | 23 +++++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index d64a680534b..21b3cb6e6de 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -159,6 +159,7 @@ @ stdcall -syscall NtAlpcConnectPort(ptr ptr ptr ptr long ptr ptr ptr ptr ptr ptr) @ stdcall -syscall NtAlpcCreatePort(ptr ptr ptr) @ stdcall -syscall NtAlpcDisconnectPort(ptr long) +@ stdcall -syscall NtAlpcImpersonateClientOfPort(ptr ptr ptr) @ stdcall -syscall NtAlpcSendWaitReceivePort(ptr long ptr ptr ptr ptr ptr ptr) @ stub -syscall=0x004c NtApphelpCacheControl @ stdcall -syscall NtAreMappedFilesTheSame(ptr ptr) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index e6ede210221..120440c454a 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -359,6 +359,7 @@ DEFINE_SYSCALL(NtAlpcAcceptConnectPort, (HANDLE *communication_port, HANDLE conn DEFINE_SYSCALL(NtAlpcConnectPort, (HANDLE *port_handle, UNICODE_STRING *port_name, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr, ULONG flags, SID *required_server_sid, PORT_MESSAGE *connect_msg, SIZE_T *connect_msg_size, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) DEFINE_SYSCALL(NtAlpcCreatePort, (HANDLE *port_handle, OBJECT_ATTRIBUTES *obj_attr, ALPC_PORT_ATTRIBUTES *port_attr)) DEFINE_SYSCALL(NtAlpcDisconnectPort, (HANDLE port_handle, ULONG flags)) +DEFINE_SYSCALL(NtAlpcImpersonateClientOfPort, (HANDLE port_handle, ALPC_PORT_MESSAGE *send_msg, void *reserved )) DEFINE_SYSCALL(NtAlpcSendWaitReceivePort, (HANDLE port_handle, ULONG flags, PORT_MESSAGE *send_msg, ALPC_MESSAGE_ATTRIBUTES *send_msg_attr, PORT_MESSAGE *recv_msg, SIZE_T *recv_buffer_size, ALPC_MESSAGE_ATTRIBUTES *recv_msg_attr, LARGE_INTEGER *timeout)) DEFINE_SYSCALL(NtApphelpCacheControl, (ULONG class, void *context)) DEFINE_SYSCALL(NtAreMappedFilesTheSame, (PVOID addr1, PVOID addr2)) diff --git a/dlls/ntdll/unix/alpc.c b/dlls/ntdll/unix/alpc.c index d6ad52974b1..c708b588011 100644 --- a/dlls/ntdll/unix/alpc.c +++ b/dlls/ntdll/unix/alpc.c @@ -75,3 +75,9 @@ NTSTATUS WINAPI NtAlpcSendWaitReceivePort( HANDLE port_handle, ULONG flags, send_msg_attr, recv_msg, recv_buffer_size, recv_msg_attr, timeout ); return STATUS_NOT_IMPLEMENTED; } + +NTSTATUS WINAPI NtAlpcImpersonateClientOfPort( HANDLE port_handle, ALPC_PORT_MESSAGE *msg, void *reserved ) +{ + FIXME( "%p, %p, %p stub!\n", port_handle, msg, reserved ); + return STATUS_NOT_IMPLEMENTED; +} diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 030c56b3a50..75544db76fe 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -631,6 +631,29 @@ NTSTATUS WINAPI wow64_NtAlpcDisconnectPort( UINT *args ) return NtAlpcDisconnectPort( handle, flags ); } +/********************************************************************** + * wow64_NtAlpcImpersonateClientOfPort + */ +NTSTATUS WINAPI wow64_NtAlpcImpersonateClientOfPort( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ALPC_PORT_MESSAGE32 *msg32 = get_ptr( &args ); + void *reserved = get_ptr( &args ); + NTSTATUS status; + + ALPC_PORT_MESSAGE *msg = NULL; + + if (msg32) + { + msg = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*msg) + msg32->DataLength ); + if (!msg) return STATUS_NO_MEMORY; + } + + status = NtAlpcImpersonateClientOfPort( handle, alpc_port_message_32to64( msg, msg32 ), reserved ); + RtlFreeHeap( GetProcessHeap(), 0, msg ); + return status; +} + /********************************************************************** * wow64_NtAlpcSendWaitReceivePort */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10932
participants (2)
-
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)