📄 wksta.c
字号:
memcpy(&allTransports, ALL_TRANSPORTS, sizeof(ULONG));
NetBIOSEnumAdapters(allTransports, WkstaEnumAdaptersCallback,
&enumData);
*read_entries = enumData.n_read;
*total_entries = enumData.n_adapt;
if (hresume) *hresume= 0;
ret = enumData.ret;
break;
}
default:
TRACE("Invalid level %d is specified\n", level);
ret = ERROR_INVALID_LEVEL;
}
}
return ret;
}
/************************************************************
* NetWkstaUserGetInfo (NETAPI32.@)
*/
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
PBYTE* bufptr)
{
TRACE("(%s, %d, %p)\n", debugstr_w(reserved), level, bufptr);
switch (level)
{
case 0:
{
PWKSTA_USER_INFO_0 ui;
DWORD dwSize = UNLEN + 1;
/* set up buffer */
NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR),
(LPVOID *) bufptr);
ui = (PWKSTA_USER_INFO_0) *bufptr;
ui->wkui0_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0));
/* get data */
if (!GetUserNameW(ui->wkui0_username, &dwSize))
{
NetApiBufferFree(ui);
return ERROR_NOT_ENOUGH_MEMORY;
}
else
NetApiBufferReallocate(
*bufptr, sizeof(WKSTA_USER_INFO_0) +
(lstrlenW(ui->wkui0_username) + 1) * sizeof(WCHAR),
(LPVOID *) bufptr);
break;
}
case 1:
{
PWKSTA_USER_INFO_1 ui;
PWKSTA_USER_INFO_0 ui0;
DWORD dwSize;
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle;
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
NTSTATUS NtStatus;
/* sizes of the field buffers in WCHARS */
int username_sz, logon_domain_sz, oth_domains_sz, logon_server_sz;
FIXME("Level 1 processing is partially implemented\n");
oth_domains_sz = 1;
logon_server_sz = 1;
/* get some information first to estimate size of the buffer */
ui0 = NULL;
NetWkstaUserGetInfo(NULL, 0, (PBYTE *) &ui0);
username_sz = lstrlenW(ui0->wkui0_username) + 1;
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
POLICY_VIEW_LOCAL_INFORMATION,
&PolicyHandle);
if (NtStatus != STATUS_SUCCESS)
{
TRACE("LsaOpenPolicyFailed with NT status %x\n",
LsaNtStatusToWinError(NtStatus));
NetApiBufferFree(ui0);
return ERROR_NOT_ENOUGH_MEMORY;
}
LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation,
(PVOID*) &DomainInfo);
logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
LsaClose(PolicyHandle);
/* set up buffer */
NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) +
(username_sz + logon_domain_sz +
oth_domains_sz + logon_server_sz) * sizeof(WCHAR),
(LPVOID *) bufptr);
ui = (WKSTA_USER_INFO_1 *) *bufptr;
ui->wkui1_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1));
ui->wkui1_logon_domain = (LPWSTR) (
((PBYTE) ui->wkui1_username) + username_sz * sizeof(WCHAR));
ui->wkui1_oth_domains = (LPWSTR) (
((PBYTE) ui->wkui1_logon_domain) +
logon_domain_sz * sizeof(WCHAR));
ui->wkui1_logon_server = (LPWSTR) (
((PBYTE) ui->wkui1_oth_domains) +
oth_domains_sz * sizeof(WCHAR));
/* get data */
dwSize = username_sz;
lstrcpyW(ui->wkui1_username, ui0->wkui0_username);
NetApiBufferFree(ui0);
lstrcpynW(ui->wkui1_logon_domain, DomainInfo->DomainName.Buffer,
logon_domain_sz);
LsaFreeMemory(DomainInfo);
/* FIXME. Not implemented. Populated with empty strings */
ui->wkui1_oth_domains[0] = 0;
ui->wkui1_logon_server[0] = 0;
break;
}
case 1101:
{
PWKSTA_USER_INFO_1101 ui;
DWORD dwSize = 1;
FIXME("Stub. Level 1101 processing is not implemented\n");
/* FIXME see also wkui1_oth_domains for level 1 */
/* set up buffer */
NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR),
(LPVOID *) bufptr);
ui = (PWKSTA_USER_INFO_1101) *bufptr;
ui->wkui1101_oth_domains = (LPWSTR)(ui + 1);
/* get data */
ui->wkui1101_oth_domains[0] = 0;
break;
}
default:
TRACE("Invalid level %d is specified\n", level);
return ERROR_INVALID_LEVEL;
}
return NERR_Success;
}
/************************************************************
* NetpGetComputerName (NETAPI32.@)
*/
NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer)
{
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
TRACE("(%p)\n", Buffer);
NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) Buffer);
if (GetComputerNameW(*Buffer, &dwSize))
{
NetApiBufferReallocate(
*Buffer, (dwSize + 1) * sizeof(WCHAR),
(LPVOID *) Buffer);
return NERR_Success;
}
else
{
NetApiBufferFree(*Buffer);
return ERROR_NOT_ENOUGH_MEMORY;
}
}
NET_API_STATUS WINAPI I_NetNameCompare(LPVOID p1, LPWSTR wkgrp, LPWSTR comp,
LPVOID p4, LPVOID p5)
{
FIXME("(%p %s %s %p %p): stub\n", p1, debugstr_w(wkgrp), debugstr_w(comp),
p4, p5);
return ERROR_INVALID_PARAMETER;
}
NET_API_STATUS WINAPI I_NetNameValidate(LPVOID p1, LPWSTR wkgrp, LPVOID p3,
LPVOID p4)
{
FIXME("(%p %s %p %p): stub\n", p1, debugstr_w(wkgrp), p3, p4);
return ERROR_INVALID_PARAMETER;
}
NET_API_STATUS WINAPI NetWkstaGetInfo( LPWSTR 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_ACCOUNT_DOMAIN_INFO DomainInfo;
LsaQueryInformationPolicy(PolicyHandle,
PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
domainNameLen = lstrlenW(DomainInfo->DomainName.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 = (LPWSTR)(*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->DomainName.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;
}
/************************************************************
* NetGetJoinInformation (NETAPI32.@)
*/
NET_API_STATUS NET_API_FUNCTION NetGetJoinInformation(
LPCWSTR Server,
LPWSTR *Name,
PNETSETUP_JOIN_STATUS type)
{
FIXME("Stub %s %p %p\n", wine_dbgstr_w(Server), Name, type);
*Name = NULL;
*type = NetSetupUnknownStatus;
return NERR_Success;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -