- Merge from trunk
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Fri, 3 Dec 2010 13:32:50 +0000 (13:32 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Fri, 3 Dec 2010 13:32:50 +0000 (13:32 +0000)
- Hackfixed to build

svn path=/branches/audio-bringup/; revision=49923

dll/win32/advapi32/sec/cred.c
dll/win32/advapi32/sec/lsa.c

index e8e0283..cd74a6a 100644 (file)
@@ -103,16 +103,22 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW credential,
         credential->TargetName = (LPWSTR)buffer;
         ret = RegQueryValueExW(hkey, NULL, 0, &type, (LPVOID)credential->TargetName,
                                &count);
-        if (ret != ERROR_SUCCESS || type != REG_SZ) return ret;
+        if (ret != ERROR_SUCCESS)
+            return ret;
+        else if (type != REG_SZ)
+            return ERROR_REGISTRY_CORRUPT;
         buffer += count;
     }
 
     ret = RegQueryValueExW(hkey, wszCommentValue, 0, &type, NULL, &count);
-    if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
-        return ret;
-    else if (type != REG_SZ)
-        return ERROR_REGISTRY_CORRUPT;
-    *len += count;
+    if (ret != ERROR_FILE_NOT_FOUND)
+    {
+        if (ret != ERROR_SUCCESS)
+            return ret;
+        else if (type != REG_SZ)
+            return ERROR_REGISTRY_CORRUPT;
+        *len += count;
+    }
     if (credential)
     {
         credential->Comment = (LPWSTR)buffer;
@@ -129,11 +135,14 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW credential,
     }
 
     ret = RegQueryValueExW(hkey, wszTargetAliasValue, 0, &type, NULL, &count);
-    if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
-        return ret;
-    else if (type != REG_SZ)
-        return ERROR_REGISTRY_CORRUPT;
-    *len += count;
+    if (ret != ERROR_FILE_NOT_FOUND)
+    {
+        if (ret != ERROR_SUCCESS)
+            return ret;
+        else if (type != REG_SZ)
+            return ERROR_REGISTRY_CORRUPT;
+        *len += count;
+    }
     if (credential)
     {
         credential->TargetAlias = (LPWSTR)buffer;
@@ -150,11 +159,14 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW credential,
     }
 
     ret = RegQueryValueExW(hkey, wszUserNameValue, 0, &type, NULL, &count);
-    if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
-        return ret;
-    else if (type != REG_SZ)
-        return ERROR_REGISTRY_CORRUPT;
-    *len += count;
+    if (ret != ERROR_FILE_NOT_FOUND)
+    {
+        if (ret != ERROR_SUCCESS)
+            return ret;
+        else if (type != REG_SZ)
+            return ERROR_REGISTRY_CORRUPT;
+        *len += count;
+    }
     if (credential)
     {
         credential->UserName = (LPWSTR)buffer;
@@ -171,9 +183,12 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW credential,
     }
 
     ret = read_credential_blob(hkey, key_data, NULL, &count);
-    if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
-        return ret;
-    *len += count;
+    if (ret != ERROR_FILE_NOT_FOUND)
+    {
+        if (ret != ERROR_SUCCESS)
+            return ret;
+        *len += count;
+    }
     if (credential)
     {
         credential->CredentialBlob = (LPBYTE)buffer;
index 604dcb2..5462280 100644 (file)
@@ -143,18 +143,37 @@ LsaDelete(IN LSA_HANDLE ObjectHandle)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 WINAPI
-LsaAddAccountRights(
-    LSA_HANDLE PolicyHandle,
-    PSID AccountSid,
-    PLSA_UNICODE_STRING UserRights,
-    ULONG CountOfRights)
+LsaAddAccountRights(IN LSA_HANDLE PolicyHandle,
+                    IN PSID AccountSid,
+                    IN PLSA_UNICODE_STRING UserRights,
+                    IN ULONG CountOfRights)
 {
-    FIXME("(%p,%p,%p,0x%08x) stub\n", PolicyHandle, AccountSid, UserRights, CountOfRights);
-    return STATUS_OBJECT_NAME_NOT_FOUND;
+    LSAPR_USER_RIGHT_SET UserRightSet;
+    NTSTATUS Status;
+
+    TRACE("(%p,%p,%p,0x%08x) stub\n", PolicyHandle, AccountSid, UserRights, CountOfRights);
+
+    UserRightSet.Entries = CountOfRights;
+    UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
+
+    RpcTryExcept
+    {
+        Status = LsarAddAccountRights((LSAPR_HANDLE)PolicyHandle,
+                                      (PRPC_SID)AccountSid,
+                                      &UserRightSet);
+
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return Status;
 }
 
 
@@ -265,6 +284,7 @@ LsaCreateTrustedDomainEx(
     return STATUS_SUCCESS;
 }
 
+
 /*
  * @implemented
  */
@@ -291,16 +311,16 @@ LsaDeleteTrustedDomain(IN LSA_HANDLE PolicyHandle,
     return Status;
 }
 
+
 /*
  * @implemented
  */
 NTSTATUS
 WINAPI
-LsaEnumerateAccountRights(
-    LSA_HANDLE PolicyHandle,
-    PSID AccountSid,
-    PLSA_UNICODE_STRING *UserRights,
-    PULONG CountOfRights)
+LsaEnumerateAccountRights(IN LSA_HANDLE PolicyHandle,
+                          IN PSID AccountSid,
+                          OUT PLSA_UNICODE_STRING *UserRights,
+                          OUT PULONG CountOfRights)
 {
     LSAPR_USER_RIGHT_SET UserRightsSet;
     NTSTATUS Status;
@@ -333,6 +353,7 @@ LsaEnumerateAccountRights(
     return Status;
 }
 
+
 /*
  * @unimplemented
  */
@@ -385,17 +406,19 @@ LsaEnumerateTrustedDomainsEx(
     return STATUS_SUCCESS;
 }
 
+
 /*
  * @implemented
  */
 NTSTATUS
 WINAPI
-LsaFreeMemory(PVOID Buffer)
+LsaFreeMemory(IN PVOID Buffer)
 {
     TRACE("(%p)\n", Buffer);
     return RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
 }
 
+
 /*
  * @implemented
  */
@@ -446,6 +469,7 @@ LsaLookupNames(IN LSA_HANDLE PolicyHandle,
     return Status;
 }
 
+
 /*
  * @unimplemented
  */
@@ -470,8 +494,9 @@ LsaLookupNames2(
     return STATUS_NONE_MAPPED;
 }
 
+
 /*
- * @unmplemented
+ * @implemented
  */
 NTSTATUS
 WINAPI
@@ -504,6 +529,7 @@ LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
     return Status;
 }
 
+
 /*
  * @implemented
  */
@@ -535,6 +561,7 @@ LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
     return Status;
 }
 
+
 /*
  * @implemented
  */
@@ -591,6 +618,7 @@ LsaLookupSids(IN LSA_HANDLE PolicyHandle,
     return Status;
 }
 
+
 /******************************************************************************
  * LsaNtStatusToWinError
  *
@@ -599,7 +627,8 @@ LsaLookupSids(IN LSA_HANDLE PolicyHandle,
  *
  * @implemented
  */
-ULONG WINAPI
+ULONG
+WINAPI
 LsaNtStatusToWinError(IN NTSTATUS Status)
 {
     TRACE("(%lx)\n", Status);
@@ -747,6 +776,7 @@ LsaQueryForestTrustInformation(
     return STATUS_NOT_IMPLEMENTED;
 }
 
+
 /*
  * @implemented
  */
@@ -782,52 +812,94 @@ LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
     return Status;
 }
 
+
 /*
  * @unimplemented
  */
 NTSTATUS
 WINAPI
-LsaQueryTrustedDomainInfoByName(
+LsaQueryTrustedDomainInfo(
     LSA_HANDLE PolicyHandle,
-    PLSA_UNICODE_STRING TrustedDomainName,
+    PSID TrustedDomainSid,
     TRUSTED_INFORMATION_CLASS InformationClass,
     PVOID *Buffer)
 {
-    FIXME("(%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainName, InformationClass, Buffer);
+    FIXME("(%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
     return STATUS_OBJECT_NAME_NOT_FOUND;
 }
 
+
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 WINAPI
-LsaQueryTrustedDomainInfo(
-    LSA_HANDLE PolicyHandle,
-    PSID TrustedDomainSid,
-    TRUSTED_INFORMATION_CLASS InformationClass,
-    PVOID *Buffer)
+LsaQueryTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
+                                IN PLSA_UNICODE_STRING TrustedDomainName,
+                                IN TRUSTED_INFORMATION_CLASS InformationClass,
+                                OUT PVOID *Buffer)
 {
-    FIXME("(%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
-    return STATUS_OBJECT_NAME_NOT_FOUND;
+    NTSTATUS Status;
+
+    TRACE("(%p,%p,%d,%p)\n", PolicyHandle, TrustedDomainName, InformationClass, Buffer);
+
+    if (InformationClass == 9 /*TrustedDomainAuthInformationInternal*/ ||
+        InformationClass == 10 /*TrustedDomainFullInformationInternal*/)
+        return STATUS_INVALID_INFO_CLASS;
+
+    RpcTryExcept
+    {
+        Status = LsarQueryTrustedDomainInfoByName((LSAPR_HANDLE)PolicyHandle,
+                                                  (PRPC_UNICODE_STRING)TrustedDomainName,
+                                                  InformationClass,
+                                                  (unsigned long *)Buffer); // Shuld be: (PLSAPR_POLICY_INFORMATION *)Buffer
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return Status;
 }
 
+
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 WINAPI
-LsaRemoveAccountRights(
-    LSA_HANDLE PolicyHandle,
-    PSID AccountSid,
-    BOOLEAN AllRights,
-    PLSA_UNICODE_STRING UserRights,
-    ULONG CountOfRights)
+LsaRemoveAccountRights(IN LSA_HANDLE PolicyHandle,
+                       IN PSID AccountSid,
+                       IN BOOLEAN AllRights,
+                       IN PLSA_UNICODE_STRING UserRights,
+                       IN ULONG CountOfRights)
 {
-    FIXME("(%p,%p,%d,%p,0x%08x) stub\n", PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
+    LSAPR_USER_RIGHT_SET UserRightSet;
+    NTSTATUS Status;
+
+    TRACE("(%p,%p,%d,%p,0x%08x) stub\n", PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
+
+    UserRightSet.Entries = CountOfRights;
+    UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
+
+    RpcTryExcept
+    {
+        Status = LsarRemoveAccountRights((LSAPR_HANDLE)PolicyHandle,
+                                         (PRPC_SID)AccountSid,
+                                         AllRights,
+                                         &UserRightSet);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
     return STATUS_SUCCESS;
 }
 
+
 /*
  * @unimplemented
  */