mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[WKSSVC][NETAPI32] Implement NetrWkstaGetInfo and get rid of the old NetWkstaGetInfo implementation
This commit is contained in:
parent
0d1a804581
commit
87a4624e20
4 changed files with 152 additions and 90 deletions
|
@ -83,11 +83,145 @@ __stdcall
|
|||
NetrWkstaGetInfo(
|
||||
WKSSVC_IDENTIFY_HANDLE ServerName,
|
||||
unsigned long Level,
|
||||
LPWKSTA_INFO WkstaInfo)
|
||||
LPWKSTA_INFO *WkstaInfo)
|
||||
{
|
||||
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
DWORD dwComputerNameLength;
|
||||
LPCWSTR pszLanRoot = L"";
|
||||
PWKSTA_INFO pWkstaInfo = NULL;
|
||||
OSVERSIONINFOW VersionInfo;
|
||||
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
LSA_HANDLE PolicyHandle;
|
||||
PPOLICY_PRIMARY_DOMAIN_INFO DomainInfo = NULL;
|
||||
NTSTATUS NtStatus;
|
||||
DWORD dwResult = NERR_Success;
|
||||
|
||||
TRACE("NetrWkstaGetInfo level %lu\n", Level);
|
||||
|
||||
return 0;
|
||||
dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
GetComputerNameW(szComputerName, &dwComputerNameLength);
|
||||
dwComputerNameLength++; /* include NULL terminator */
|
||||
|
||||
VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
|
||||
GetVersionExW(&VersionInfo);
|
||||
|
||||
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
||||
NtStatus = LsaOpenPolicy(NULL,
|
||||
&ObjectAttributes,
|
||||
POLICY_VIEW_LOCAL_INFORMATION,
|
||||
&PolicyHandle);
|
||||
if (NtStatus != STATUS_SUCCESS)
|
||||
{
|
||||
WARN("LsaOpenPolicy() failed (Status 0x%08lx)\n", NtStatus);
|
||||
return LsaNtStatusToWinError(NtStatus);
|
||||
}
|
||||
|
||||
NtStatus = LsaQueryInformationPolicy(PolicyHandle,
|
||||
PolicyPrimaryDomainInformation,
|
||||
(PVOID*)&DomainInfo);
|
||||
|
||||
LsaClose(PolicyHandle);
|
||||
|
||||
if (NtStatus != STATUS_SUCCESS)
|
||||
{
|
||||
WARN("LsaQueryInformationPolicy() failed (Status 0x%08lx)\n", NtStatus);
|
||||
return LsaNtStatusToWinError(NtStatus);
|
||||
}
|
||||
|
||||
switch (Level)
|
||||
{
|
||||
case 100:
|
||||
pWkstaInfo = midl_user_allocate(sizeof(WKSTA_INFO_100));
|
||||
if (pWkstaInfo == NULL)
|
||||
{
|
||||
dwResult = ERROR_NOT_ENOUGH_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
pWkstaInfo->WkstaInfo100.wki100_platform_id = PLATFORM_ID_NT;
|
||||
|
||||
pWkstaInfo->WkstaInfo100.wki100_computername = midl_user_allocate(dwComputerNameLength * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo100.wki100_computername != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo100.wki100_computername, szComputerName);
|
||||
|
||||
pWkstaInfo->WkstaInfo100.wki100_langroup = midl_user_allocate((wcslen(DomainInfo->Name.Buffer) + 1) * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo100.wki100_langroup != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo100.wki100_langroup, DomainInfo->Name.Buffer);
|
||||
|
||||
pWkstaInfo->WkstaInfo100.wki100_ver_major = VersionInfo.dwMajorVersion;
|
||||
pWkstaInfo->WkstaInfo100.wki100_ver_minor = VersionInfo.dwMinorVersion;
|
||||
|
||||
*WkstaInfo = pWkstaInfo;
|
||||
break;
|
||||
|
||||
case 101:
|
||||
pWkstaInfo = midl_user_allocate(sizeof(WKSTA_INFO_101));
|
||||
if (pWkstaInfo == NULL)
|
||||
{
|
||||
dwResult = ERROR_NOT_ENOUGH_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
pWkstaInfo->WkstaInfo101.wki101_platform_id = PLATFORM_ID_NT;
|
||||
|
||||
pWkstaInfo->WkstaInfo101.wki101_computername = midl_user_allocate(dwComputerNameLength * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo101.wki101_computername != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo101.wki101_computername, szComputerName);
|
||||
|
||||
pWkstaInfo->WkstaInfo101.wki101_langroup = midl_user_allocate((wcslen(DomainInfo->Name.Buffer) + 1) * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo101.wki101_langroup != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo101.wki101_langroup, DomainInfo->Name.Buffer);
|
||||
|
||||
pWkstaInfo->WkstaInfo101.wki101_ver_major = VersionInfo.dwMajorVersion;
|
||||
pWkstaInfo->WkstaInfo101.wki101_ver_minor = VersionInfo.dwMinorVersion;
|
||||
|
||||
pWkstaInfo->WkstaInfo101.wki101_lanroot = midl_user_allocate((wcslen(pszLanRoot) + 1) * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo101.wki101_lanroot != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo101.wki101_lanroot, pszLanRoot);
|
||||
|
||||
*WkstaInfo = pWkstaInfo;
|
||||
break;
|
||||
|
||||
case 102:
|
||||
pWkstaInfo = midl_user_allocate(sizeof(WKSTA_INFO_102));
|
||||
if (pWkstaInfo == NULL)
|
||||
{
|
||||
dwResult = ERROR_NOT_ENOUGH_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
pWkstaInfo->WkstaInfo102.wki102_platform_id = PLATFORM_ID_NT;
|
||||
|
||||
pWkstaInfo->WkstaInfo102.wki102_computername = midl_user_allocate(dwComputerNameLength * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo102.wki102_computername != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo102.wki102_computername, szComputerName);
|
||||
|
||||
pWkstaInfo->WkstaInfo102.wki102_langroup = midl_user_allocate((wcslen(DomainInfo->Name.Buffer) + 1) * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo102.wki102_langroup != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo102.wki102_langroup, DomainInfo->Name.Buffer);
|
||||
|
||||
pWkstaInfo->WkstaInfo102.wki102_ver_major = VersionInfo.dwMajorVersion;
|
||||
pWkstaInfo->WkstaInfo102.wki102_ver_minor = VersionInfo.dwMinorVersion;
|
||||
|
||||
pWkstaInfo->WkstaInfo102.wki102_lanroot = midl_user_allocate((wcslen(pszLanRoot) + 1) * sizeof(WCHAR));
|
||||
if (pWkstaInfo->WkstaInfo102.wki102_lanroot != NULL)
|
||||
wcscpy(pWkstaInfo->WkstaInfo102.wki102_lanroot, pszLanRoot);
|
||||
|
||||
pWkstaInfo->WkstaInfo102.wki102_logged_on_users = 1; /* FIXME */
|
||||
|
||||
*WkstaInfo = pWkstaInfo;
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Level %d unimplemented\n", Level);
|
||||
dwResult = ERROR_INVALID_LEVEL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (DomainInfo != NULL)
|
||||
LsaFreeMemory(DomainInfo);
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -468,87 +468,3 @@ NET_API_STATUS WINAPI I_NetNameValidate(LPVOID p1, LPWSTR wkgrp, LPVOID p3,
|
|||
FIXME("(%p %s %p %p): stub\n", p1, debugstr_w(wkgrp), p3, p4);
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NET_API_STATUS WINAPI NetWkstaGetInfo( LMSTR servername, DWORD level,
|
||||
LPBYTE* bufptr)
|
||||
{
|
||||
NET_API_STATUS ret;
|
||||
|
||||
TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr );
|
||||
if (servername)
|
||||
{
|
||||
if (!NETAPI_IsLocalComputer(servername))
|
||||
{
|
||||
FIXME("remote computers not supported\n");
|
||||
return ERROR_INVALID_LEVEL;
|
||||
}
|
||||
}
|
||||
if (!bufptr) return ERROR_INVALID_PARAMETER;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
{
|
||||
static const WCHAR lanroot[] = {'c',':','\\','l','a','n','m','a','n',0}; /* FIXME */
|
||||
DWORD computerNameLen, domainNameLen, size;
|
||||
WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
LSA_HANDLE PolicyHandle;
|
||||
NTSTATUS NtStatus;
|
||||
|
||||
computerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
GetComputerNameW(computerName, &computerNameLen);
|
||||
computerNameLen++; /* include NULL terminator */
|
||||
|
||||
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
||||
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
|
||||
POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
|
||||
if (NtStatus != STATUS_SUCCESS)
|
||||
ret = LsaNtStatusToWinError(NtStatus);
|
||||
else
|
||||
{
|
||||
PPOLICY_PRIMARY_DOMAIN_INFO DomainInfo;
|
||||
|
||||
LsaQueryInformationPolicy(PolicyHandle,
|
||||
PolicyPrimaryDomainInformation, (PVOID*)&DomainInfo);
|
||||
domainNameLen = lstrlenW(DomainInfo->Name.Buffer) + 1;
|
||||
size = sizeof(WKSTA_INFO_102) + computerNameLen * sizeof(WCHAR)
|
||||
+ domainNameLen * sizeof(WCHAR) + sizeof(lanroot);
|
||||
ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
|
||||
if (ret == NERR_Success)
|
||||
{
|
||||
/* INFO_100 and INFO_101 structures are subsets of INFO_102 */
|
||||
PWKSTA_INFO_102 info = (PWKSTA_INFO_102)*bufptr;
|
||||
OSVERSIONINFOW verInfo;
|
||||
|
||||
info->wki102_platform_id = PLATFORM_ID_NT;
|
||||
info->wki102_computername = (LMSTR)(*bufptr +
|
||||
sizeof(WKSTA_INFO_102));
|
||||
memcpy(info->wki102_computername, computerName,
|
||||
computerNameLen * sizeof(WCHAR));
|
||||
info->wki102_langroup = info->wki102_computername + computerNameLen;
|
||||
memcpy(info->wki102_langroup, DomainInfo->Name.Buffer,
|
||||
domainNameLen * sizeof(WCHAR));
|
||||
info->wki102_lanroot = info->wki102_langroup + domainNameLen;
|
||||
memcpy(info->wki102_lanroot, lanroot, sizeof(lanroot));
|
||||
memset(&verInfo, 0, sizeof(verInfo));
|
||||
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
|
||||
GetVersionExW(&verInfo);
|
||||
info->wki102_ver_major = verInfo.dwMajorVersion;
|
||||
info->wki102_ver_minor = verInfo.dwMinorVersion;
|
||||
info->wki102_logged_on_users = 1;
|
||||
}
|
||||
LsaFreeMemory(DomainInfo);
|
||||
LsaClose(PolicyHandle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
FIXME("level %d unimplemented\n", level);
|
||||
ret = ERROR_INVALID_LEVEL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -856,7 +856,6 @@ NetValidateName(
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
NET_API_STATUS
|
||||
WINAPI
|
||||
NetWkstaGetInfo(
|
||||
|
@ -878,7 +877,7 @@ NetWkstaGetInfo(
|
|||
{
|
||||
status = NetrWkstaGetInfo(servername,
|
||||
level,
|
||||
(LPWKSTA_INFO)bufptr);
|
||||
(LPWKSTA_INFO*)bufptr);
|
||||
}
|
||||
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
@ -888,7 +887,6 @@ NetWkstaGetInfo(
|
|||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
NET_API_STATUS
|
||||
|
|
|
@ -198,6 +198,7 @@ typedef struct _WKSTA_TRANSPORT_INFO_0
|
|||
unsigned long wkti0_wan_ish;
|
||||
} WKSTA_TRANSPORT_INFO_0, *PWKSTA_TRANSPORT_INFO_0, *LPWKSTA_TRANSPORT_INFO_0;
|
||||
|
||||
/*
|
||||
typedef [switch_type(unsigned long)] union _WKSTA_INFO
|
||||
{
|
||||
[case(100)] LPWKSTA_INFO_100 WkstaInfo100;
|
||||
|
@ -209,6 +210,18 @@ typedef [switch_type(unsigned long)] union _WKSTA_INFO
|
|||
[case(1046)] LPWKSTA_INFO_1046 WkstaInfo1046;
|
||||
[default] ;
|
||||
} WKSTA_INFO, *PWKSTA_INFO, *LPWKSTA_INFO;
|
||||
*/
|
||||
typedef [switch_type(unsigned long)] union _WKSTA_INFO
|
||||
{
|
||||
[case(100)] WKSTA_INFO_100 WkstaInfo100;
|
||||
[case(101)] WKSTA_INFO_101 WkstaInfo101;
|
||||
[case(102)] WKSTA_INFO_102 WkstaInfo102;
|
||||
[case(502)] WKSTA_INFO_502 WkstaInfo502;
|
||||
[case(1013)] WKSTA_INFO_1013 WkstaInfo1013;
|
||||
[case(1018)] WKSTA_INFO_1018 WkstaInfo1018;
|
||||
[case(1046)] WKSTA_INFO_1046 WkstaInfo1046;
|
||||
[default] ;
|
||||
} WKSTA_INFO, *PWKSTA_INFO, *LPWKSTA_INFO;
|
||||
|
||||
typedef struct _USE_INFO_0
|
||||
{
|
||||
|
@ -366,7 +379,8 @@ interface wkssvc
|
|||
NetrWkstaGetInfo(
|
||||
[in, string, unique] WKSSVC_IDENTIFY_HANDLE ServerName,
|
||||
[in] unsigned long Level,
|
||||
[out, switch_is(Level)] LPWKSTA_INFO WkstaInfo);
|
||||
[out, switch_is(Level)] LPWKSTA_INFO *WkstaInfo);
|
||||
// [out, switch_is(Level)] LPWKSTA_INFO WkstaInfo);
|
||||
|
||||
/* Function 1 */
|
||||
unsigned long
|
||||
|
|
Loading…
Reference in a new issue