func AppManifestFromXML(data []byte) (AppManifest, error) {
	x := appManifestXML{}
	err := xml.Unmarshal(data, &x)
	if err != nil {
		return AppManifest{}, err
	}
	var m AppManifest

	m.Identity.Name = x.Identity.Name
	v := strings.Split(x.Identity.Version, ".")
	if len(v) > 4 {
		v = v[:4]
	}
	for i := range v {
		n, _ := strconv.ParseUint(v[i], 10, 16)
		m.Identity.Version[i] = uint16(n)
	}
	m.Description = x.Description

	m.Compatibility = Win10AndAbove + 1
	for _, os := range x.Compatibility.Application.SupportedOS {
		c := osIDToEnum(os.Id)
		if c < m.Compatibility {
			m.Compatibility = c
		}
	}
	if m.Compatibility > Win10AndAbove {
		m.Compatibility = Win7AndAbove
	}

	settings := x.Application.WindowsSettings
	m.DPIAwareness = readDPIAwareness(settings.DPIAware, settings.DPIAwareness)
	m.AutoElevate = manifestBool(settings.AutoElevate)
	m.DisableTheming = manifestBool(settings.DisableTheming)
	m.DisableWindowFiltering = manifestBool(settings.DisableWindowFiltering)
	m.HighResolutionScrollingAware = manifestBool(settings.HighResolutionScrollingAware)
	m.PrinterDriverIsolation = manifestBool(settings.PrinterDriverIsolation)
	m.UltraHighResolutionScrollingAware = manifestBool(settings.UltraHighResolutionScrollingAware)
	m.LongPathAware = manifestBool(settings.LongPathAware)
	m.GDIScaling = manifestBool(settings.GDIScaling)
	m.SegmentHeap = manifestString(settings.HeapType) == "segmentheap"

	for _, dep := range x.Dependency.DependentAssembly {
		if manifestString(dep.Identity.Name) == "microsoft.windows.common-controls" &&
			strings.HasPrefix(manifestString(dep.Identity.Version), "6.") &&
			manifestString(dep.Identity.PublicKeyToken) == "6595b64144ccf1df" {
			m.UseCommonControlsV6 = true
		}
	}

	m.UIAccess = manifestBool(x.TrustInfo.Security.RequestedPrivileges.RequestedExecutionLevel.UIAccess)
	switch manifestString(x.TrustInfo.Security.RequestedPrivileges.RequestedExecutionLevel.Level) {
	case "requireadministrator":
		m.ExecutionLevel = RequireAdministrator
	case "highestavailable":
		m.ExecutionLevel = HighestAvailable
	}

	return m, nil
}
// AppManifestFromXML makes an AppManifest from an xml manifest,
// trying to retrieve as much valid information as possible.
//
// If the xml contains other data, they are ignored.
//
// This function can only return xml syntax errors, other errors are ignored.
AppManifestFromXML makes an AppManifest from an xml manifest,
trying to retrieve as much valid information as possible.

If the xml contains other data, they are ignored.

This function can only return xml syntax errors, other errors are ignored.
// AppManifestFromXML makes an AppManifest from an xml manifest // trying to retrieve as much valid information as possible . // // If the xml contains other data they are ignored . // // This function can only return xml syntax errors other errors are ignored .
func AppManifestFromXML(data []byte) (AppManifest, error) {
	x := appManifestXML{}
	err := xml.Unmarshal(data, &x)
	if err != nil {
		return AppManifest{}, err
	}
	var m AppManifest
	m.Identity.Name = x.Identity.Name
	v := strings.Split(x.Identity.Version, ".")
	if len(v) > 4 {
		v = v[:4]
	}
	for i := range v {
		n, _ := strconv.ParseUint(v[i], 10, 16)
		m.Identity.Version[i] = uint16(n)
	}
	m.Description = x.Description
	m.Compatibility = Win10AndAbove + 1
	for _, os := range x.Compatibility.Application.SupportedOS {
		c := osIDToEnum(os.Id)
		if c < m.Compatibility {
			m.Compatibility = c
		}
	}
	if m.Compatibility > Win10AndAbove {
		m.Compatibility = Win7AndAbove
	}
	settings := x.Application.WindowsSettings
	m.DPIAwareness = readDPIAwareness(settings.DPIAware, settings.DPIAwareness)
	m.AutoElevate = manifestBool(settings.AutoElevate)
	m.DisableTheming = manifestBool(settings.DisableTheming)
	m.DisableWindowFiltering = manifestBool(settings.DisableWindowFiltering)
	m.HighResolutionScrollingAware = manifestBool(settings.HighResolutionScrollingAware)
	m.PrinterDriverIsolation = manifestBool(settings.PrinterDriverIsolation)
	m.UltraHighResolutionScrollingAware = manifestBool(settings.UltraHighResolutionScrollingAware)
	m.LongPathAware = manifestBool(settings.LongPathAware)
	m.GDIScaling = manifestBool(settings.GDIScaling)
	m.SegmentHeap = manifestString(settings.HeapType) == "segmentheap"
	for _, dep := range x.Dependency.DependentAssembly {
		if manifestString(dep.Identity.Name) == "microsoft.windows.common-controls" &&
			strings.HasPrefix(manifestString(dep.Identity.Version), "6.") &&
			manifestString(dep.Identity.PublicKeyToken) == "6595b64144ccf1df" {
			m.UseCommonControlsV6 = true
		}
	}
	m.UIAccess = manifestBool(x.TrustInfo.Security.RequestedPrivileges.RequestedExecutionLevel.UIAccess)
	switch manifestString(x.TrustInfo.Security.RequestedPrivileges.RequestedExecutionLevel.Level) {
	case "requireadministrator":
		m.ExecutionLevel = RequireAdministrator
	case "highestavailable":
		m.ExecutionLevel = HighestAvailable
	}
	return m, nil
}
func AppManifestFromXML ( data [ ] byte ) ( AppManifest , error ) { x := appManifestXML { } err := xml . Unmarshal ( data , & x ) if err != nil { return AppManifest { } , err } var m AppManifest m . Identity . Name = x . Identity . Name v := strings . Split ( x . Identity . Version , " " ) if len ( v ) > 4 { v = v [ : 4 ] } for i := range v { n , _ := strconv . ParseUint ( v [ i ] , 10 , 16 ) m . Identity . Version [ i ] = uint16 ( n ) } m . Description = x . Description m . Compatibility = Win10AndAbove + 1 for _ , os := range x . Compatibility . Application . SupportedOS { c := osIDToEnum ( os . Id ) if c < m . Compatibility { m . Compatibility = c } } if m . Compatibility > Win10AndAbove { m . Compatibility = Win7AndAbove } settings := x . Application . WindowsSettings m . DPIAwareness = readDPIAwareness ( settings . DPIAware , settings . DPIAwareness ) m . AutoElevate = manifestBool ( settings . AutoElevate ) m . DisableTheming = manifestBool ( settings . DisableTheming ) m . DisableWindowFiltering = manifestBool ( settings . DisableWindowFiltering ) m . HighResolutionScrollingAware = manifestBool ( settings . HighResolutionScrollingAware ) m . PrinterDriverIsolation = manifestBool ( settings . PrinterDriverIsolation ) m . UltraHighResolutionScrollingAware = manifestBool ( settings . UltraHighResolutionScrollingAware ) m . LongPathAware = manifestBool ( settings . LongPathAware ) m . GDIScaling = manifestBool ( settings . GDIScaling ) m . SegmentHeap = manifestString ( settings . HeapType ) == " " for _ , dep := range x . Dependency . DependentAssembly { if manifestString ( dep . Identity . Name ) == " " && strings . HasPrefix ( manifestString ( dep . Identity . Version ) , " " ) && manifestString ( dep . Identity . PublicKeyToken ) == " " { m . UseCommonControlsV6 = true } } m . UIAccess = manifestBool ( x . TrustInfo . Security . RequestedPrivileges . RequestedExecutionLevel . UIAccess ) switch manifestString ( x . TrustInfo . Security . RequestedPrivileges . RequestedExecutionLevel . Level ) { case " " : m . ExecutionLevel = RequireAdministrator case " " : m . ExecutionLevel = HighestAvailable } return m , nil }
AppManifestFromXML makes an AppManifest from an xml manifest,
trying to retrieve as much valid information as possible.
AppManifestFromXML makes an AppManifest from an xml manifest trying to retrieve as much valid information as possible .