[ros-diffs] [cwittich] 39482: sync CredReadDomainCredentialsA/W with wine 1.14

cwittich at svn.reactos.org cwittich at svn.reactos.org
Sun Feb 8 11:34:09 CET 2009


Author: cwittich
Date: Sun Feb  8 04:34:09 2009
New Revision: 39482

URL: http://svn.reactos.org/svn/reactos?rev=39482&view=rev
Log:
sync CredReadDomainCredentialsA/W with wine 1.14

Modified:
    trunk/reactos/dll/win32/advapi32/sec/cred.c

Modified: trunk/reactos/dll/win32/advapi32/sec/cred.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/sec/cred.c?rev=39482&r1=39481&r2=39482&view=diff
==============================================================================
--- trunk/reactos/dll/win32/advapi32/sec/cred.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/sec/cred.c [iso-8859-1] Sun Feb  8 04:34:09 2009
@@ -1700,26 +1700,168 @@
     return TRUE;
 }
 
-BOOL
-WINAPI
-CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
-                           DWORD Flags,
-                           DWORD *Count,
-                           PCREDENTIALW **Credential)
-{
-    WARN("Not implemented\n");
+/******************************************************************************
+ * CredReadDomainCredentialsW [ADVAPI32.@]
+ */
+BOOL WINAPI CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInformation, DWORD Flags,
+                                       DWORD *Size, PCREDENTIALW **Credentials)
+{
+    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)
-{
-    WARN("Not implemented\n");
-    return FALSE;
+/******************************************************************************
+ * CredReadDomainCredentialsA [ADVAPI32.@]
+ */
+BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInformation,
+                                       DWORD Flags, DWORD *Size, PCREDENTIALA **Credentials)
+{
+    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



More information about the Ros-diffs mailing list