sync CredReadDomainCredentialsA/W with wine 1.14

svn path=/trunk/; revision=39482
This commit is contained in:
Christoph von Wittich 2009-02-08 10:34:09 +00:00
parent 37a3abe6fe
commit 3ae5eef453

View file

@ -1700,26 +1700,168 @@ BOOL WINAPI CredGetSessionTypes(DWORD persistCount, LPDWORD persists)
return TRUE;
}
BOOL
WINAPI
CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
DWORD Flags,
DWORD *Count,
PCREDENTIALW **Credential)
/******************************************************************************
* CredReadDomainCredentialsW [ADVAPI32.@]
*/
BOOL WINAPI CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInformation, DWORD Flags,
DWORD *Size, PCREDENTIALW **Credentials)
{
WARN("Not implemented\n");
FIXME("(%p, 0x%x, %p, %p) stub\n", TargetInformation, Flags, Size, Credentials);
/* follow Windows behavior - do not test for NULL, initialize early */
*Size = 0;
*Credentials = NULL;
if (!TargetInformation)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
SetLastError(ERROR_NOT_FOUND);
return FALSE;
}
BOOL
WINAPI
CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,
DWORD Flags,
DWORD *Count,
PCREDENTIALA **Credential)
/******************************************************************************
* CredReadDomainCredentialsA [ADVAPI32.@]
*/
BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInformation,
DWORD Flags, DWORD *Size, PCREDENTIALA **Credentials)
{
WARN("Not implemented\n");
return FALSE;
PCREDENTIAL_TARGET_INFORMATIONW TargetInformationW;
DWORD len, i;
WCHAR *buffer, *end;
BOOL ret;
PCREDENTIALW* CredentialsW;
TRACE("(%p, 0x%x, %p, %p)\n", TargetInformation, Flags, Size, Credentials);
/* follow Windows behavior - do not test for NULL, initialize early */
*Size = 0;
*Credentials = NULL;
if (!TargetInformation)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
len = sizeof(*TargetInformationW);
if (TargetInformation->TargetName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->TargetName, -1, NULL, 0) * sizeof(WCHAR);
if (TargetInformation->NetbiosServerName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->NetbiosServerName, -1, NULL, 0) * sizeof(WCHAR);
if (TargetInformation->DnsServerName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->DnsServerName, -1, NULL, 0) * sizeof(WCHAR);
if (TargetInformation->NetbiosDomainName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->NetbiosDomainName, -1, NULL, 0) * sizeof(WCHAR);
if (TargetInformation->DnsDomainName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->DnsDomainName, -1, NULL, 0) * sizeof(WCHAR);
if (TargetInformation->DnsTreeName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->DnsTreeName, -1, NULL, 0) * sizeof(WCHAR);
if (TargetInformation->PackageName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->PackageName, -1, NULL, 0) * sizeof(WCHAR);
TargetInformationW = HeapAlloc(GetProcessHeap(), 0, len);
if (!TargetInformationW)
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
buffer = (WCHAR*)(TargetInformationW + 1);
end = (WCHAR *)((char *)TargetInformationW + len);
if (TargetInformation->TargetName)
{
TargetInformationW->TargetName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->TargetName, -1,
TargetInformationW->TargetName, end - buffer);
} else
TargetInformationW->TargetName = NULL;
if (TargetInformation->NetbiosServerName)
{
TargetInformationW->NetbiosServerName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->NetbiosServerName, -1,
TargetInformationW->NetbiosServerName, end - buffer);
} else
TargetInformationW->NetbiosServerName = NULL;
if (TargetInformation->DnsServerName)
{
TargetInformationW->DnsServerName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->DnsServerName, -1,
TargetInformationW->DnsServerName, end - buffer);
} else
TargetInformationW->DnsServerName = NULL;
if (TargetInformation->NetbiosDomainName)
{
TargetInformationW->NetbiosDomainName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->NetbiosDomainName, -1,
TargetInformationW->NetbiosDomainName, end - buffer);
} else
TargetInformationW->NetbiosDomainName = NULL;
if (TargetInformation->DnsDomainName)
{
TargetInformationW->DnsDomainName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->DnsDomainName, -1,
TargetInformationW->DnsDomainName, end - buffer);
} else
TargetInformationW->DnsDomainName = NULL;
if (TargetInformation->DnsTreeName)
{
TargetInformationW->DnsTreeName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->DnsTreeName, -1,
TargetInformationW->DnsTreeName, end - buffer);
} else
TargetInformationW->DnsTreeName = NULL;
if (TargetInformation->PackageName)
{
TargetInformationW->PackageName = buffer;
buffer += MultiByteToWideChar(CP_ACP, 0, TargetInformation->PackageName, -1,
TargetInformationW->PackageName, end - buffer);
} else
TargetInformationW->PackageName = NULL;
TargetInformationW->Flags = TargetInformation->Flags;
TargetInformationW->CredTypeCount = TargetInformation->CredTypeCount;
TargetInformationW->CredTypes = TargetInformation->CredTypes;
ret = CredReadDomainCredentialsW(TargetInformationW, Flags, Size, &CredentialsW);
HeapFree(GetProcessHeap(), 0, TargetInformationW);
if (ret)
{
char *buf;
len = *Size * sizeof(PCREDENTIALA);
for (i = 0; i < *Size; i++)
convert_PCREDENTIALW_to_PCREDENTIALA(CredentialsW[i], NULL, &len);
*Credentials = HeapAlloc(GetProcessHeap(), 0, len);
if (!*Credentials)
{
CredFree(CredentialsW);
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
buf = (char *)&(*Credentials)[*Size];
for (i = 0; i < *Size; i++)
{
len = 0;
(*Credentials)[i] = (PCREDENTIALA)buf;
convert_PCREDENTIALW_to_PCREDENTIALA(CredentialsW[i], (*Credentials)[i], &len);
buf += len;
}
CredFree(CredentialsW);
}
return ret;
}
BOOL