[RTL] Fixes for supportedOS close elements.
[reactos.git] / sdk / lib / rtl / actctx.c
index 545f5fe..e70363c 100644 (file)
@@ -2353,11 +2353,52 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly, struct
     return ret;
 }
 
+static BOOL parse_supportedos_elem(xmlbuf_t *xmlbuf, struct assembly *assembly, struct actctx_loader *acl)
+{
+    xmlstr_t attr_name, attr_value;
+    BOOL end = FALSE, error;
+
+    while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end))
+    {
+        if (xmlstr_cmp(&attr_name, IdW))
+        {
+            COMPATIBILITY_CONTEXT_ELEMENT *compat;
+            UNICODE_STRING str;
+            GUID compat_id;
+
+            str.Buffer = (PWSTR)attr_value.ptr;
+            str.Length = str.MaximumLength = (USHORT)attr_value.len * sizeof(WCHAR);
+            if (RtlGUIDFromString(&str, &compat_id) == STATUS_SUCCESS)
+            {
+                if (!(compat = add_compat_context(assembly))) return FALSE;
+                compat->Type = ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS;
+                compat->Id = compat_id;
+            }
+            else
+            {
+                UNICODE_STRING attr_valueU = xmlstr2unicode(&attr_value);
+                DPRINT1("Invalid guid %wZ\n", &attr_valueU);
+            }
+        }
+        else
+        {
+            UNICODE_STRING attr_nameU = xmlstr2unicode(&attr_name);
+            UNICODE_STRING attr_valueU = xmlstr2unicode(&attr_value);
+            DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU);
+        }
+    }
+
+    if (error) return FALSE;
+    if (end) return TRUE;
+
+    return parse_expect_end_elem(xmlbuf, supportedOSW, asmv1W);
+}
+
 static BOOL parse_compatibility_application_elem(xmlbuf_t* xmlbuf, struct assembly* assembly,
                                                  struct actctx_loader* acl)
 {
-    xmlstr_t attr_name, attr_value, elem;
-    BOOL end = FALSE, ret = TRUE, error;
+    BOOL ret = TRUE;
+    xmlstr_t elem;
 
     while (ret && (ret = next_xml_elem(xmlbuf, &elem)))
     {
@@ -2368,34 +2409,7 @@ static BOOL parse_compatibility_application_elem(xmlbuf_t* xmlbuf, struct assemb
         }
         else if (xmlstr_cmp(&elem, supportedOSW))
         {
-            while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end))
-            {
-                if (xmlstr_cmp(&attr_name, IdW))
-                {
-                    UNICODE_STRING str;
-                    COMPATIBILITY_CONTEXT_ELEMENT* compat;
-                    GUID compat_id;
-                    str.Buffer = (PWSTR)attr_value.ptr;
-                    str.Length = str.MaximumLength = (USHORT)attr_value.len * sizeof(WCHAR);
-                    if (RtlGUIDFromString(&str, &compat_id) == STATUS_SUCCESS)
-                    {
-                        if (!(compat = add_compat_context(assembly))) return FALSE;
-                        compat->Type = ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS;
-                        compat->Id = compat_id;
-                    }
-                    else
-                    {
-                        UNICODE_STRING attr_valueU = xmlstr2unicode(&attr_value);
-                        DPRINT1("Invalid guid %wZ\n", &attr_valueU);
-                    }
-                }
-                else
-                {
-                    UNICODE_STRING attr_nameU = xmlstr2unicode(&attr_name);
-                    UNICODE_STRING attr_valueU = xmlstr2unicode(&attr_value);
-                    DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU);
-                }
-            }
+            ret = parse_supportedos_elem(xmlbuf, assembly, acl);
         }
         else
         {
@@ -2485,7 +2499,7 @@ static BOOL parse_requested_execution_level_elem(xmlbuf_t* xmlbuf, struct assemb
 
     while (ret && (ret = next_xml_elem(xmlbuf, &elem)))
     {
-        if (xmlstr_cmp_end(&elem, requestedExecutionLevelW))
+        if (xml_elem_cmp_end(&elem, requestedExecutionLevelW, asmv2W))
         {
             ret = parse_end_element(xmlbuf);
             break;
@@ -2508,12 +2522,12 @@ static BOOL parse_requested_privileges_elem(xmlbuf_t* xmlbuf, struct assembly* a
 
     while (ret && (ret = next_xml_elem(xmlbuf, &elem)))
     {
-        if (xmlstr_cmp_end(&elem, requestedPrivilegesW))
+        if (xml_elem_cmp_end(&elem, requestedPrivilegesW, asmv2W))
         {
             ret = parse_end_element(xmlbuf);
             break;
         }
-        else if (xmlstr_cmp(&elem, requestedExecutionLevelW))
+        else if (xml_elem_cmp(&elem, requestedExecutionLevelW, asmv2W))
             ret = parse_requested_execution_level_elem(xmlbuf, assembly, acl);
         else
         {
@@ -2533,12 +2547,12 @@ static BOOL parse_security_elem(xmlbuf_t *xmlbuf, struct assembly *assembly, str
 
     while (ret && (ret = next_xml_elem(xmlbuf, &elem)))
     {
-        if (xmlstr_cmp_end(&elem, securityW))
+        if (xml_elem_cmp_end(&elem, securityW, asmv2W))
         {
             ret = parse_end_element(xmlbuf);
             break;
         }
-        else if (xmlstr_cmp(&elem, requestedPrivilegesW))
+        else if (xml_elem_cmp(&elem, requestedPrivilegesW, asmv2W))
             ret = parse_requested_privileges_elem(xmlbuf, assembly, acl);
         else
         {
@@ -2558,12 +2572,12 @@ static BOOL parse_trust_info_elem(xmlbuf_t *xmlbuf, struct assembly *assembly, s
 
     while (ret && (ret = next_xml_elem(xmlbuf, &elem)))
     {
-        if (xmlstr_cmp_end(&elem, trustInfoW))
+        if (xml_elem_cmp_end(&elem, trustInfoW, asmv2W))
         {
             ret = parse_end_element(xmlbuf);
             break;
         }
-        else if (xmlstr_cmp(&elem, securityW))
+        else if (xml_elem_cmp(&elem, securityW, asmv2W))
             ret = parse_security_elem(xmlbuf, assembly, acl);
         else
         {