From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/ntdll/Makefile.in | 1 + dlls/ntdll/alpc.c | 58 +++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/tests/alpc.c | 1 - 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 dlls/ntdll/alpc.c diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index ad5c3bdc60f..4a912adaa82 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -15,6 +15,7 @@ VER_PRODUCTVERSION = 6,1,7601,24059 SOURCES = \ actctx.c \ + alpc.c \ atom.c \ crypt.c \ debugbuffer.c \ diff --git a/dlls/ntdll/alpc.c b/dlls/ntdll/alpc.c new file mode 100644 index 00000000000..730d2942890 --- /dev/null +++ b/dlls/ntdll/alpc.c @@ -0,0 +1,58 @@ +/* + * 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 + */ + +#include <stdarg.h> +#include <windef.h> +#include <winternl.h> +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(alpc); + +SIZE_T WINAPI AlpcGetHeaderSize(ULONG attribute_flags) +{ + static const struct + { + ULONG attribute; + SIZE_T size; + } attribute_sizes[] = + { + /* Attribute with a higher bit is stored before that with a lower bit */ + {ALPC_MESSAGE_SECURITY_ATTRIBUTE, sizeof(ALPC_SECURITY_ATTR)}, + {ALPC_MESSAGE_VIEW_ATTRIBUTE, sizeof(ALPC_VIEW_ATTR)}, + {ALPC_MESSAGE_CONTEXT_ATTRIBUTE, sizeof(ALPC_CONTEXT_ATTR)}, + {ALPC_MESSAGE_HANDLE_ATTRIBUTE, sizeof(ALPC_HANDLE_ATTR)}, + {ALPC_MESSAGE_TOKEN_ATTRIBUTE, sizeof(ALPC_TOKEN_ATTR)}, + {ALPC_MESSAGE_DIRECT_ATTRIBUTE, sizeof(ALPC_DIRECT_ATTR)}, + {ALPC_MESSAGE_WORK_ON_BEHALF_ATTRIBUTE, sizeof(ALPC_WORK_ON_BEHALF_ATTR)}, + }; + unsigned int i; + SIZE_T size; + + TRACE("%#lx.\n", attribute_flags); + + size = sizeof(ALPC_MESSAGE_ATTRIBUTES); + for (i = 0; i < ARRAY_SIZE(attribute_sizes); i++) + { + if (attribute_flags & attribute_sizes[i].attribute) + size += attribute_sizes[i].size; + } + + return size; +} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index f289709f68d..55a05d084e8 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -6,6 +6,7 @@ @ stdcall A_SHAFinal(ptr ptr) @ stdcall A_SHAInit(ptr) @ stdcall A_SHAUpdate(ptr ptr long) +@ stdcall AlpcGetHeaderSize(long) @ stdcall ApiSetQueryApiSetPresence(ptr ptr) @ stdcall ApiSetQueryApiSetPresenceEx(ptr ptr ptr) @ stub CsrAllocateCaptureBuffer diff --git a/dlls/ntdll/tests/alpc.c b/dlls/ntdll/tests/alpc.c index 1bf0bdfea72..d7921e67b50 100644 --- a/dlls/ntdll/tests/alpc.c +++ b/dlls/ntdll/tests/alpc.c @@ -98,7 +98,6 @@ static void test_AlpcGetHeaderSize(void) if (!pAlpcGetHeaderSize) { - todo_wine win_skip("AlpcGetHeaderSize is unavailable.\n"); return; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10492