[PATCH 0/2] MR11146: dsrole: Add a new dll.
Some modules in wine-mono use that, instead of netapi32. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11146
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- configure | 2 + configure.ac | 1 + dlls/dsrole/Makefile.in | 5 ++ dlls/dsrole/dsrole.c | 110 ++++++++++++++++++++++++++++++++++++++++ dlls/dsrole/dsrole.spec | 2 + 5 files changed, 120 insertions(+) create mode 100644 dlls/dsrole/Makefile.in create mode 100644 dlls/dsrole/dsrole.c create mode 100644 dlls/dsrole/dsrole.spec diff --git a/configure b/configure index 4fad7b2636d..54779aa907c 100755 --- a/configure +++ b/configure @@ -1151,6 +1151,7 @@ enable_dpwsockx enable_drmclien enable_dsdmo enable_dsound +enable_dsrole enable_dsquery enable_dssenh enable_dsuiext @@ -22972,6 +22973,7 @@ wine_fn_config_makefile dlls/dsdmo/tests enable_tests wine_fn_config_makefile dlls/dsound enable_dsound wine_fn_config_makefile dlls/dsound/tests enable_tests wine_fn_config_makefile dlls/dsquery enable_dsquery +wine_fn_config_makefile dlls/dsrole enable_dsrole wine_fn_config_makefile dlls/dssenh enable_dssenh wine_fn_config_makefile dlls/dssenh/tests enable_tests wine_fn_config_makefile dlls/dsuiext enable_dsuiext diff --git a/configure.ac b/configure.ac index d597bad3750..c1fb4e77c61 100644 --- a/configure.ac +++ b/configure.ac @@ -2707,6 +2707,7 @@ WINE_CONFIG_MAKEFILE(dlls/dsdmo/tests) WINE_CONFIG_MAKEFILE(dlls/dsound) WINE_CONFIG_MAKEFILE(dlls/dsound/tests) WINE_CONFIG_MAKEFILE(dlls/dsquery) +WINE_CONFIG_MAKEFILE(dlls/dsrole) WINE_CONFIG_MAKEFILE(dlls/dssenh) WINE_CONFIG_MAKEFILE(dlls/dssenh/tests) WINE_CONFIG_MAKEFILE(dlls/dsuiext) diff --git a/dlls/dsrole/Makefile.in b/dlls/dsrole/Makefile.in new file mode 100644 index 00000000000..b0bc5f3033c --- /dev/null +++ b/dlls/dsrole/Makefile.in @@ -0,0 +1,5 @@ +MODULE = dsrole.dll +IMPORTS = advapi32 + +SOURCES = \ + dsrole.c diff --git a/dlls/dsrole/dsrole.c b/dlls/dsrole/dsrole.c new file mode 100644 index 00000000000..f3aef1d7b0e --- /dev/null +++ b/dlls/dsrole/dsrole.c @@ -0,0 +1,110 @@ +/* + * Copyright 2001 Mike McCormack + * Copyright 2002 Andriy Palamarchuk + * Copyright 2003 Juan Lang + * Copyright 2005,2006 Paul Vriens + * Copyright 2006 Robert Reif + * Copyright 2013 Hans Leidekker for CodeWeavers + * Copyright 2020 Dmitry Timoshkov + * + * 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 "ntstatus.h" +#include "windef.h" +#include "winbase.h" +#include "ntsecapi.h" + +#include "dsrole.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dsrole); + +/************************************************************ + * DsRoleFreeMemory (dsrole.@) + */ +void WINAPI DsRoleFreeMemory(void *buffer) +{ + TRACE("(%p)\n", buffer); + HeapFree(GetProcessHeap(), 0, buffer); +} + +/************************************************************ + * DsRoleGetPrimaryDomainInformation (dsrole.@) + */ +DWORD WINAPI DsRoleGetPrimaryDomainInformation( + LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, + PBYTE* Buffer) +{ + DWORD ret; + + FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer); + + /* Check some input parameters */ + + if (!Buffer) return ERROR_INVALID_PARAMETER; + if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER; + + *Buffer = NULL; + switch (InfoLevel) + { + case DsRolePrimaryDomainInfoBasic: + { + LSA_OBJECT_ATTRIBUTES ObjectAttributes; + LSA_HANDLE PolicyHandle; + PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo; + NTSTATUS NtStatus; + int logon_domain_sz; + DWORD size; + PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic; + + ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); + NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes, + POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle); + if (NtStatus != STATUS_SUCCESS) + { + TRACE("LsaOpenPolicyFailed with NT status %lx\n", + LsaNtStatusToWinError(NtStatus)); + return ERROR_OUTOFMEMORY; + } + LsaQueryInformationPolicy(PolicyHandle, + PolicyAccountDomainInformation, (PVOID*)&DomainInfo); + logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1; + LsaClose(PolicyHandle); + + size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) + + logon_domain_sz * sizeof(WCHAR); + basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + if (basic) + { + basic->MachineRole = DsRole_RoleStandaloneWorkstation; + basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic + + sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC)); + lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer); + ret = ERROR_SUCCESS; + } + else + ret = ERROR_OUTOFMEMORY; + *Buffer = (PBYTE)basic; + LsaFreeMemory(DomainInfo); + } + break; + default: + ret = ERROR_CALL_NOT_IMPLEMENTED; + } + return ret; +} diff --git a/dlls/dsrole/dsrole.spec b/dlls/dsrole/dsrole.spec new file mode 100644 index 00000000000..fae35b0b411 --- /dev/null +++ b/dlls/dsrole/dsrole.spec @@ -0,0 +1,2 @@ +@ stdcall DsRoleFreeMemory(ptr) +@ stdcall DsRoleGetPrimaryDomainInformation(wstr long ptr) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11146
From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/netapi32/netapi32.c | 91 ------------------------------------- dlls/netapi32/netapi32.spec | 4 +- 2 files changed, 2 insertions(+), 93 deletions(-) diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c index 9737f2ae370..f58647b34c3 100644 --- a/dlls/netapi32/netapi32.c +++ b/dlls/netapi32/netapi32.c @@ -2182,97 +2182,6 @@ DWORD WINAPI DsGetSiteNameA(LPCSTR ComputerName, LPSTR *SiteName) return ERROR_CALL_NOT_IMPLEMENTED; } -/************************************************************ - * DsRoleFreeMemory (NETAPI32.@) - * - * PARAMS - * Buffer [I] Pointer to the to-be-freed buffer. - * - * RETURNS - * Nothing - */ -VOID WINAPI DsRoleFreeMemory(PVOID Buffer) -{ - TRACE("(%p)\n", Buffer); - HeapFree(GetProcessHeap(), 0, Buffer); -} - -/************************************************************ - * DsRoleGetPrimaryDomainInformation (NETAPI32.@) - * - * PARAMS - * lpServer [I] Pointer to UNICODE string with ComputerName - * InfoLevel [I] Type of data to retrieve - * Buffer [O] Pointer to to the requested data - * - * RETURNS - * - * NOTES - * When lpServer is NULL, use the local computer - */ -DWORD WINAPI DsRoleGetPrimaryDomainInformation( - LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, - PBYTE* Buffer) -{ - DWORD ret; - - FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer); - - /* Check some input parameters */ - - if (!Buffer) return ERROR_INVALID_PARAMETER; - if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER; - - *Buffer = NULL; - switch (InfoLevel) - { - case DsRolePrimaryDomainInfoBasic: - { - LSA_OBJECT_ATTRIBUTES ObjectAttributes; - LSA_HANDLE PolicyHandle; - PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo; - NTSTATUS NtStatus; - int logon_domain_sz; - DWORD size; - PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic; - - ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); - NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes, - POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle); - if (NtStatus != STATUS_SUCCESS) - { - TRACE("LsaOpenPolicyFailed with NT status %lx\n", - LsaNtStatusToWinError(NtStatus)); - return ERROR_OUTOFMEMORY; - } - LsaQueryInformationPolicy(PolicyHandle, - PolicyAccountDomainInformation, (PVOID*)&DomainInfo); - logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1; - LsaClose(PolicyHandle); - - size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) + - logon_domain_sz * sizeof(WCHAR); - basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); - if (basic) - { - basic->MachineRole = DsRole_RoleStandaloneWorkstation; - basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic + - sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC)); - lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer); - ret = ERROR_SUCCESS; - } - else - ret = ERROR_OUTOFMEMORY; - *Buffer = (PBYTE)basic; - LsaFreeMemory(DomainInfo); - } - break; - default: - ret = ERROR_CALL_NOT_IMPLEMENTED; - } - return ret; -} - DWORD WINAPI DsGetDcOpenA(LPCSTR domain, ULONG flags, LPCSTR site, GUID *domain_guid, LPCSTR forest, ULONG dc_flags, PHANDLE context) { diff --git a/dlls/netapi32/netapi32.spec b/dlls/netapi32/netapi32.spec index 4906bfade6d..14cf6a3a5f8 100644 --- a/dlls/netapi32/netapi32.spec +++ b/dlls/netapi32/netapi32.spec @@ -16,8 +16,8 @@ @ stdcall DsGetSiteNameA(str ptr) @ stdcall DsGetSiteNameW(wstr ptr) @ stub DsMergeForestTrustInformationW -@ stdcall DsRoleFreeMemory(ptr) -@ stdcall DsRoleGetPrimaryDomainInformation(wstr long ptr) +@ stdcall DsRoleFreeMemory(ptr) dsrole.DsRoleFreeMemory +@ stdcall DsRoleGetPrimaryDomainInformation(wstr long ptr) dsrole.DsRoleGetPrimaryDomainInformation @ stub DsValidateSubnetName @ stub I_BrowserDebugCall @ stub I_BrowserDebugTrace -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11146
participants (2)
-
Nikolay Sivov -
Nikolay Sivov (@nsivov)