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