diff --git a/AppInstallerReset.sln b/AppInstallerReset.sln
index 806d252..7aa137a 100644
--- a/AppInstallerReset.sln
+++ b/AppInstallerReset.sln
@@ -61,6 +61,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WAShell", "WAShell\WAShell.csproj", "{4EC16578-EFBF-41E6-8D7F-976E3646DD1D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Manager", "Manager\Manager.csproj", "{DC074727-72E4-43C5-BAAF-E0D548104797}"
+ ProjectSection(ProjectDependencies) = postProject
+ {3AE2A022-ED83-41F1-948A-12A7593CBD00} = {3AE2A022-ED83-41F1-948A-12A7593CBD00}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IEHelper", "IEHelper\IEHelper.vcxproj", "{E4CA78A9-9408-4F5F-ADD6-730FD501FF8E}"
EndProject
diff --git a/AppxPackage/AppxPackage.csproj b/AppxPackage/AppxPackage.csproj
index c008200..f1694e0 100644
--- a/AppxPackage/AppxPackage.csproj
+++ b/AppxPackage/AppxPackage.csproj
@@ -62,6 +62,7 @@
+
diff --git a/AppxPackage/ManifestReader.cs b/AppxPackage/ManifestReader.cs
new file mode 100644
index 0000000..59311c6
--- /dev/null
+++ b/AppxPackage/ManifestReader.cs
@@ -0,0 +1,1000 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using AppxPackage.Info;
+using NativeWrappers;
+using System.IO;
+namespace AppxPackage
+{
+ public static class DataUrlHelper
+ {
+ [DllImport ("urlmon.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ private static extern int FindMimeFromData (
+ IntPtr pBC,
+ string pwzUrl,
+ byte [] pBuffer,
+ int cbSize,
+ string pwzMimeProposed,
+ int dwMimeFlags,
+ out IntPtr ppwzMimeOut,
+ int dwReserved);
+ private const int FMFD_RETURNUPDATEDIMGMIMES = 0x00000001;
+ private const int FMFD_IGNOREMIMETEXTPLAIN = 0x00000010;
+ private const int FMFD_URLASFILENAME = 0x00000020;
+ private static string GetMimeTypeFromStream (Stream stream)
+ {
+ if (stream == null) return string.Empty;
+ long originalPos = 0;
+ try
+ {
+ if (stream.CanSeek)
+ {
+ originalPos = stream.Position;
+ stream.Seek (0, SeekOrigin.Begin);
+ }
+ byte [] buffer = new byte [256];
+ int bytesRead = stream.Read (buffer, 0, buffer.Length);
+ if (stream.CanSeek) stream.Seek (originalPos, SeekOrigin.Begin);
+ if (bytesRead == 0) return string.Empty;
+ IntPtr mimePtr;
+ int hr = FindMimeFromData (
+ IntPtr.Zero,
+ null,
+ buffer,
+ bytesRead,
+ null,
+ FMFD_RETURNUPDATEDIMGMIMES | FMFD_IGNOREMIMETEXTPLAIN | FMFD_URLASFILENAME,
+ out mimePtr,
+ 0);
+ string mime = string.Empty;
+ if (hr == 0 && mimePtr != IntPtr.Zero)
+ {
+ mime = Marshal.PtrToStringUni (mimePtr);
+ Marshal.FreeCoTaskMem (mimePtr);
+ }
+ if (string.IsNullOrEmpty (mime))
+ {
+ // fallback by magic bytes
+ if (bytesRead >= 8 && buffer [0] == 0x89 && buffer [1] == 0x50 && buffer [2] == 0x4E && buffer [3] == 0x47 &&
+ buffer [4] == 0x0D && buffer [5] == 0x0A && buffer [6] == 0x1A && buffer [7] == 0x0A)
+ mime = "image/png";
+ else if (bytesRead >= 3 && buffer [0] == 0xFF && buffer [1] == 0xD8)
+ mime = "image/jpeg";
+ else if (bytesRead >= 6 && Encoding.ASCII.GetString (buffer, 0, 6) == "GIF89a")
+ mime = "image/gif";
+ else if (bytesRead >= 2 && buffer [0] == 'B' && buffer [1] == 'M')
+ mime = "image/bmp";
+ else if (bytesRead >= 12 && Encoding.ASCII.GetString (buffer, 0, 4) == "RIFF" &&
+ Encoding.ASCII.GetString (buffer, 8, 4) == "WEBP")
+ mime = "image/webp";
+ else if (bytesRead >= 4 && buffer [0] == 0x00 && buffer [1] == 0x00 && buffer [2] == 0x01 && buffer [3] == 0x00)
+ mime = "image/x-icon";
+ else
+ mime = "application/octet-stream";
+ }
+ return mime;
+ }
+ catch
+ {
+ return string.Empty;
+ }
+ }
+ public static string FileToDataUrl (string filePath)
+ {
+ if (string.IsNullOrEmpty (filePath)) return string.Empty;
+ try
+ {
+ using (FileStream fs = new FileStream (filePath, FileMode.Open, FileAccess.Read))
+ {
+ if (fs.Length == 0) return string.Empty;
+ string mime = GetMimeTypeFromStream (fs);
+ if (string.IsNullOrEmpty (mime)) return string.Empty;
+ byte [] bytes = new byte [fs.Length];
+ fs.Seek (0, SeekOrigin.Begin);
+ int read = fs.Read (bytes, 0, bytes.Length);
+ if (read != bytes.Length) return string.Empty;
+ string base64 = Convert.ToBase64String (bytes);
+ return $"data:{mime};base64,{base64}";
+ }
+ }
+ catch
+ {
+ return string.Empty;
+ }
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class BaseInfoSectWithPRISingle: BaseInfoSection
+ {
+ protected Ref m_reader = null;
+ protected Ref m_pri = null;
+ protected Ref m_usePri = false;
+ protected Ref m_enablePri = false;
+ public BaseInfoSectWithPRISingle (ref IntPtr hReader, ManifestReader reader, ref PriReader pri, ref bool usePri, ref bool enablePri) : base (ref hReader)
+ {
+ m_reader.Set (reader);
+ m_pri.Set (pri);
+ m_usePri.Set (usePri);
+ m_enablePri.Set (enablePri);
+ }
+ public new void Dispose ()
+ {
+ try { m_reader.Set (null); } catch (Exception) { }
+ try { m_pri.Set (null); } catch (Exception) { }
+ m_usePri = null;
+ m_enablePri = null;
+ m_hReader = null;
+ }
+ ~BaseInfoSectWithPRISingle () { Dispose (); }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRIdentity: BaseInfoSection, Info.IIdentity
+ {
+ public MRIdentity (ref IntPtr hReader) : base (ref hReader) { }
+ protected string StringValue (uint name)
+ {
+ var ptr = PackageReadHelper.GetManifestIdentityStringValue (m_hReader, name);
+ return PackageReadHelper.GetStringAndFreeFromPkgRead (ptr) ?? "";
+ }
+ public string FamilyName { get { return StringValue (2); } }
+ public string FullName { get { return StringValue (3); } }
+ public string Name { get { return StringValue (0); } }
+ public List ProcessArchitecture
+ {
+ get
+ {
+ var list = new List ();
+ uint uarch = 0;
+ PackageReadHelper.GetManifestIdentityArchitecture (m_hReader, out uarch);
+ var t = PackageReadHelper.GetManifestType (m_hReader);
+ switch (t)
+ {
+ case 1:
+ switch (uarch)
+ {
+ case 0x1: list.Add (Architecture.x86); break;
+ case 0x2: list.Add (Architecture.x64); break;
+ case 0x4: list.Add (Architecture.ARM); break;
+ case 0x8: list.Add (Architecture.ARM64); break;
+ case 0xE: list.Add (Architecture.Neutral); break;
+ }
+ break;
+ case 2:
+ if ((uarch & 0x1) != 0) list.Add (Architecture.x86);
+ if ((uarch & 0x2) != 0) list.Add (Architecture.x64);
+ if ((uarch & 0x4) != 0) list.Add (Architecture.ARM);
+ if ((uarch & 0x8) != 0) list.Add (Architecture.ARM64);
+ break;
+ }
+ return list;
+ }
+ }
+ public string Publisher { get { return StringValue (1); } }
+ public string ResourceId { get { return StringValue (4); } }
+ public DataUtils.Version Version
+ {
+ get
+ {
+ PackageReadHelper.VERSION ver = new PackageReadHelper.VERSION ();
+ PackageReadHelper.GetManifestIdentityVersion (m_hReader, out ver);
+ return new DataUtils.Version (ver.major, ver.minor, ver.build, ver.revision);
+ }
+ }
+ public override object BuildJSON ()
+ {
+ return new
+ {
+ name = Name,
+ package_full_name = FullName,
+ package_family_name = FamilyName,
+ publisher = Publisher,
+ resource_id = ResourceId,
+ architecture = ProcessArchitecture.Select (e => (int)e).ToList (),
+ version = Version.BuildJSON ()
+ };
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRProperties: BaseInfoSectWithPRISingle, Info.IProperties
+ {
+ public MRProperties (ref IntPtr hReader, ManifestReader reader, ref PriReader priBundle, ref bool usePri, ref bool enablePri) : base (ref hReader, reader, ref priBundle, ref usePri, ref enablePri) { }
+ protected string StringValue (string attr)
+ {
+ var ptr = PackageReadHelper.GetManifestPropertiesStringValue (m_hReader, attr);
+ return PackageReadHelper.GetStringAndFreeFromPkgRead (ptr) ?? "";
+ }
+ protected bool BoolValue (string attr, bool defaultValue = false)
+ {
+ int ret = 0;
+ HRESULT hr = PackageReadHelper.GetManifestPropertiesBoolValue (m_hReader, attr, out ret);
+ if (hr.Succeeded) return ret != 0;
+ else return defaultValue;
+ }
+ protected string StringResValue (string attr)
+ {
+ var res = StringValue (attr);
+ try
+ {
+ if (m_usePri && m_enablePri)
+ {
+ if (PriFileHelper.IsMsResourcePrefix (res))
+ return m_pri.Value.String (res) ?? res;
+ }
+ }
+ catch (Exception) { }
+ return res;
+ }
+ protected string PathResValue (string attr)
+ {
+ var res = StringValue (attr);
+ try
+ {
+ if (m_usePri && m_enablePri)
+ {
+ var resvalue = m_pri.Value.String (res);
+ if (!string.IsNullOrEmpty (resvalue)) return resvalue;
+ else return res;
+ }
+ }
+ catch (Exception) { }
+ return res;
+ }
+ public string Description { get { return StringResValue ("Description"); } }
+ public string DisplayName { get { return StringResValue ("DisplayName"); } }
+ public bool Framework { get { return BoolValue ("Framework"); } }
+ public string Logo { get { return PathResValue ("Logo"); } }
+ public string LogoBase64
+ {
+ get
+ {
+ var root = m_reader.Value.FileRoot;
+ var logopath = Path.Combine (root, Logo);
+ var ret = DataUrlHelper.FileToDataUrl (logopath);
+ if (!string.IsNullOrWhiteSpace (ret)) return ret;
+ logopath = Path.Combine (root, StringValue ("Logo"));
+ ret = DataUrlHelper.FileToDataUrl (logopath);
+ if (!string.IsNullOrWhiteSpace (ret)) return ret;
+ return String.Empty;
+ }
+ }
+ public string Publisher { get { return StringResValue ("PublisherDisplayName"); } }
+ public bool ResourcePackage { get { return BoolValue ("ResourcePackage"); } }
+ public override object BuildJSON ()
+ {
+ return new
+ {
+ display_name = DisplayName,
+ description = Description,
+ publisher_display_name = Publisher,
+ Framework = Framework,
+ resource_package = ResourcePackage,
+ logo = Logo,
+ logo_base64 = LogoBase64
+ };
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRApplication: Dictionary
+ {
+ protected Ref m_hReader = IntPtr.Zero;
+ protected Ref m_pri = null;
+ protected Ref m_usePri = false;
+ protected Ref m_enablePri = false;
+ protected string m_root = String.Empty;
+ public MRApplication (ref IntPtr hReader, ref PriReader priBundle, ref bool usePri, ref bool enablePri, string rootDir) : base (StringComparer.OrdinalIgnoreCase)
+ {
+ m_hReader = hReader;
+ m_pri = priBundle;
+ m_usePri = usePri;
+ m_enablePri = enablePri;
+ m_root = rootDir;
+ }
+ public MRApplication (ref Ref m_hReader, ref Ref m_priBundle, ref Ref m_usePri, ref Ref m_enablePri, string rootDir)
+ {
+ this.m_hReader = m_hReader;
+ this.m_pri = m_priBundle;
+ this.m_usePri = m_usePri;
+ this.m_enablePri = m_enablePri;
+ this.m_root = rootDir;
+ }
+ public string UserModelID { get { return this ["AppUserModelID"]; } }
+ protected bool EnablePri ()
+ {
+ if (m_pri == null || m_pri.Value == null) return false;
+ if (!m_usePri.Value) return false;
+ return m_enablePri.Value;
+ }
+ protected string StringResValue (string attr)
+ {
+ try
+ {
+ var res = this [attr];
+ try
+ {
+ if (m_usePri && m_enablePri)
+ {
+ if (PriFileHelper.IsMsResourcePrefix (res))
+ return m_pri.Value.String (res) ?? res;
+ }
+ }
+ catch (Exception) { }
+ return res;
+ }
+ catch (Exception) { return String.Empty; }
+ }
+ protected string PriGetRes (string resName)
+ {
+ if (string.IsNullOrEmpty (resName)) return string.Empty;
+ if (m_pri == null || m_pri.Value == null) return string.Empty;
+ return m_pri.Value.Resource (resName);
+ }
+ protected bool IsFilePathKey (string key)
+ {
+ foreach (var i in ConstData.FilePathItems)
+ if ((i?.Trim ()?.ToLower () ?? "") == (key?.Trim ()?.ToLower () ?? ""))
+ return true;
+ return false;
+ }
+ public new string this [string key]
+ {
+ get
+ {
+ string value;
+ if (!TryGetValue (key, out value))
+ {
+ value = string.Empty;
+ base [key] = value;
+ }
+ if (!EnablePri ()) return value;
+ if (PriFileHelper.IsMsResourcePrefix (value))
+ {
+ string pri = PriGetRes (value);
+ return string.IsNullOrEmpty (pri) ? value : pri;
+ }
+ if (IsFilePathKey (key) && !string.IsNullOrEmpty (value))
+ {
+ string pri = PriGetRes (value);
+ return string.IsNullOrEmpty (pri) ? value : pri;
+ }
+ return value;
+ }
+ }
+ public string At (string key)
+ {
+ string value;
+ if (!TryGetValue (key, out value)) throw new KeyNotFoundException ($"PRBaseApplication.At: key \"{key}\" not found");
+ if (!EnablePri ()) return value;
+ if (PriFileHelper.IsMsResourcePrefix (value))
+ {
+ string pri = PriGetRes (value);
+ if (!string.IsNullOrEmpty (pri))
+ return pri;
+ }
+ return value;
+ }
+ public string NewAt (string key, bool toPriString)
+ {
+ string value;
+ if (!TryGetValue (key, out value))
+ {
+ value = string.Empty;
+ base [key] = value;
+ }
+ if (!EnablePri () && toPriString) return value;
+ if (PriFileHelper.IsMsResourcePrefix (value))
+ {
+ string pri = PriGetRes (value);
+ return string.IsNullOrEmpty (pri) ? value : pri;
+ }
+ if (IsFilePathKey (key) && !string.IsNullOrEmpty (value))
+ {
+ string pri = PriGetRes (value);
+ return string.IsNullOrEmpty (pri) ? value : pri;
+ }
+ return value;
+ }
+ public string NewAtBase64 (string key)
+ {
+ string value = NewAt (key, true);
+ if (!IsFilePathKey (key) || string.IsNullOrEmpty (value)) return "";
+ switch (PackageReadHelper.GetPackageType (m_hReader))
+ {
+ case 1: // PKGTYPE_APPX
+ {
+ var root = m_root;
+ var logopath = Path.Combine (root, NewAt (key, true));
+ var ret = DataUrlHelper.FileToDataUrl (logopath);
+ if (!string.IsNullOrWhiteSpace (ret)) return ret;
+ logopath = Path.Combine (root, NewAt (key, false));
+ ret = DataUrlHelper.FileToDataUrl (logopath);
+ if (!string.IsNullOrWhiteSpace (ret)) return ret;
+ return String.Empty;
+ } break;
+ }
+ return "";
+ }
+ public static bool operator == (MRApplication a, MRApplication b)
+ {
+ if (ReferenceEquals (a, b)) return true;
+ if ((object)a == null || (object)b == null) return false;
+ return string.Equals (a.UserModelID, b.UserModelID, StringComparison.OrdinalIgnoreCase);
+ }
+ public static bool operator != (MRApplication a, MRApplication b)
+ {
+ return !(a == b);
+ }
+ public override bool Equals (object obj)
+ {
+ var other = obj as MRApplication;
+ if (other == null) return false;
+ return this == other;
+ }
+ public override int GetHashCode ()
+ {
+ return (UserModelID ?? "").ToLowerInvariant ().GetHashCode ();
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRApplications: BaseInfoSectWithPRISingle, IEnumerable
+ {
+ private IntPtr _hList = IntPtr.Zero;
+ private List _apps;
+ public MRApplications (
+ ref IntPtr hReader,
+ ManifestReader reader,
+ ref PriReader priBundle,
+ ref bool usePri,
+ ref bool enablePri)
+ : base (ref hReader, reader, ref priBundle, ref usePri, ref enablePri)
+ {
+ if (IsValid)
+ {
+ _hList = PackageReadHelper.GetManifestApplications (m_hReader.Value);
+ }
+ }
+ #region Dispose
+ public new void Dispose ()
+ {
+ if (_hList != IntPtr.Zero)
+ {
+ PackageReadHelper.DestroyManifestApplications (_hList);
+ _hList = IntPtr.Zero;
+ }
+ base.Dispose ();
+ }
+ ~MRApplications ()
+ {
+ Dispose ();
+ }
+ #endregion
+ #region 属性:Applications
+ public List Applications
+ {
+ get
+ {
+ if (_apps == null)
+ _apps = ReadApplications ();
+ return _apps;
+ }
+ }
+ #endregion
+ #region 索引器
+ public MRApplication this [int index]
+ {
+ get { return Applications [index]; }
+ }
+ public MRApplication this [string key]
+ {
+ get
+ {
+ foreach (var app in Applications)
+ {
+ if (string.Equals (app.UserModelID, key, StringComparison.OrdinalIgnoreCase))
+ {
+ return app;
+ }
+ }
+ return null;
+ }
+ }
+ #endregion
+ #region IEnumerable
+ public IEnumerator GetEnumerator ()
+ {
+ return Applications.GetEnumerator ();
+ }
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+ #endregion
+ #region 内部解析逻辑(核心等价 C++ get)
+ private List ReadApplications ()
+ {
+ var list = new List ();
+ if (_hList == IntPtr.Zero) return list;
+ IntPtr hMapList = PackageReadHelper.ApplicationsToMap (_hList);
+ if (hMapList == IntPtr.Zero) return list;
+ try
+ {
+ uint count = (uint)Marshal.ReadInt32 (hMapList);
+ int baseOffset = Marshal.SizeOf (typeof (uint));
+ for (int i = 0; i < count; i++)
+ {
+ IntPtr hKeyValues = Marshal.ReadIntPtr (hMapList, baseOffset + i * IntPtr.Size);
+ if (hKeyValues == IntPtr.Zero) continue;
+ list.Add (ReadSingleApplication (hKeyValues));
+ }
+ }
+ finally
+ {
+ PackageReadHelper.DestroyApplicationsMap (hMapList);
+ }
+ return list;
+ }
+ private MRApplication ReadSingleApplication (IntPtr hKeyValues)
+ {
+ var app = new MRApplication (ref m_hReader, ref m_pri, ref m_usePri, ref m_enablePri, m_reader.Value.FileRoot);
+ uint pairCount = (uint)Marshal.ReadInt32 (hKeyValues);
+ int baseOffset = Marshal.SizeOf (typeof (uint));
+ int pairSize = Marshal.SizeOf (typeof (PackageReadHelper.PAIR_PVOID));
+ for (int j = 0; j < pairCount; j++)
+ {
+ IntPtr pPair = IntPtr.Add (hKeyValues, baseOffset + j * pairSize);
+ var pair = (PackageReadHelper.PAIR_PVOID)Marshal.PtrToStructure (pPair, typeof (PackageReadHelper.PAIR_PVOID));
+ if (pair.lpKey == IntPtr.Zero) continue;
+ string key = Marshal.PtrToStringUni (pair.lpKey);
+ if (string.IsNullOrEmpty (key)) continue;
+ string value = pair.lpValue != IntPtr.Zero
+ ? Marshal.PtrToStringUni (pair.lpValue)
+ : string.Empty;
+ app.Add (key, value);
+ }
+ return app;
+ }
+ #endregion
+ public override object BuildJSON ()
+ {
+ using (var apps = this)
+ {
+ return apps.Select (app => {
+ var dict = new Dictionary (StringComparer.OrdinalIgnoreCase);
+ foreach (var kv in app)
+ {
+ dict [kv.Key] = kv.Value;
+ if (ConstData.IsFilePathKey (kv.Key))
+ {
+ dict [(kv.Key?.Trim () ?? "") + "_Base64"] = app.NewAtBase64 (kv.Key);
+ }
+ }
+ dict ["AppUserModelID"] = app.UserModelID;
+ return dict;
+ }).ToList ();
+ }
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRCapabilities: BaseInfoSection, ICapabilities
+ {
+ public MRCapabilities (ref IntPtr hReader) : base (ref hReader) { }
+ public List Capabilities
+ {
+ get
+ {
+ var ret = new List ();
+ if (!IsValid) return ret;
+ IntPtr hList = PackageReadHelper.GetCapabilitiesList (m_hReader.Value);
+ if (hList == IntPtr.Zero) return ret;
+ try
+ {
+ uint count = (uint)Marshal.ReadInt32 (hList);
+ int baseOffset = Marshal.SizeOf (typeof (uint)); // dwSize 后
+ for (int i = 0; i < count; i++)
+ {
+ IntPtr pStr = Marshal.ReadIntPtr (hList, baseOffset + i * IntPtr.Size);
+ if (pStr == IntPtr.Zero) continue;
+ string s = Marshal.PtrToStringUni (pStr);
+ if (!string.IsNullOrEmpty (s)) ret.Add (s);
+ }
+ }
+ finally
+ {
+ PackageReadHelper.DestroyWStringList (hList);
+ }
+ return ret;
+ }
+ }
+ public List DeviceCapabilities
+ {
+ get
+ {
+ var ret = new List ();
+ if (!IsValid) return ret;
+ IntPtr hList = PackageReadHelper.GetDeviceCapabilitiesList (m_hReader.Value);
+ if (hList == IntPtr.Zero) return ret;
+ try
+ {
+ uint count = (uint)Marshal.ReadInt32 (hList);
+ int baseOffset = Marshal.SizeOf (typeof (uint)); // dwSize 后
+ for (int i = 0; i < count; i++)
+ {
+ IntPtr pStr = Marshal.ReadIntPtr (hList, baseOffset + i * IntPtr.Size);
+ if (pStr == IntPtr.Zero) continue;
+ string s = Marshal.PtrToStringUni (pStr);
+ if (!string.IsNullOrEmpty (s)) ret.Add (s);
+ }
+ }
+ finally
+ {
+ PackageReadHelper.DestroyWStringList (hList);
+ }
+ return ret;
+ }
+ }
+ public List CapabilityDisplayNames
+ {
+ get
+ {
+ var caps = Capabilities;
+ var dev = DeviceCapabilities;
+ var ret = new List ();
+ foreach (var c in caps)
+ {
+ var capname = CacheData.GetPackageCapabilityDisplayName (c);
+ if (String.IsNullOrWhiteSpace (capname)) ret.Add (c);
+ else ret.Add (capname);
+ }
+ foreach (var d in dev)
+ {
+ var dcapname = CacheData.GetPackageCapabilityDisplayName (d);
+ if (!String.IsNullOrWhiteSpace (dcapname)) ret.Add (dcapname);
+ }
+ return ret;
+ }
+ }
+ public override object BuildJSON ()
+ {
+ return new
+ {
+ capabilities_name = Capabilities,
+ device_capabilities = DeviceCapabilities,
+ scales = CapabilityDisplayNames
+ };
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRDependencies: BaseInfoSection, IEnumerable
+ {
+ public MRDependencies (ref IntPtr hReader) : base (ref hReader) { }
+ public List Dependencies
+ {
+ get
+ {
+ var output = new List ();
+ if (!IsValid) return output;
+ IntPtr hList = PackageReadHelper.GetDependencesInfoList (m_hReader);
+ if (hList == IntPtr.Zero) return output;
+ try
+ {
+ var deps = PackageReadHelper.ReadDependencyInfoList (hList);
+ foreach (var dep in deps)
+ {
+ // dep.lpName / dep.lpPublisher 是 IntPtr
+ string name = Marshal.PtrToStringUni (dep.lpName) ?? "";
+ string publisher = Marshal.PtrToStringUni (dep.lpPublisher) ?? "";
+ // VERSION 直接映射为 System.Version
+ var ver = new DataUtils.Version (dep.verMin.major, dep.verMin.minor, dep.verMin.build, dep.verMin.revision);
+ output.Add (new DependencyInfo (name, publisher, ver));
+ }
+ }
+ finally
+ {
+ PackageReadHelper.DestroyDependencesInfoList (hList);
+ }
+ return output;
+ }
+ }
+ public DependencyInfo this [int index] => Dependencies [index];
+ public IEnumerator GetEnumerator ()
+ {
+ return Dependencies.GetEnumerator ();
+ }
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+ public override object BuildJSON ()
+ {
+ return this.Select (d => new {
+ name = d.Name,
+ publisher = d.Publisher,
+ vermin = d.Version.BuildJSON ()
+ }).ToList ();
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class MRResources: BaseInfoSection, IResources
+ {
+ public MRResources (ref IntPtr hReader) : base (ref hReader) { }
+ public List DXFeatures
+ {
+ get
+ {
+ var ret = new List ();
+ try
+ {
+ var dw = PackageReadHelper.GetResourcesDxFeatureLevels (m_hReader);
+ if ((dw & 0x1) != 0) ret.Add (DXFeatureLevel.Level9);
+ if ((dw & 0x2) != 0) ret.Add (DXFeatureLevel.Level10);
+ if ((dw & 0x4) != 0) ret.Add (DXFeatureLevel.Level11);
+ if ((dw & 0x8) != 0) ret.Add (DXFeatureLevel.Level12);
+ }
+ catch (Exception) { }
+ return ret;
+ }
+ }
+ public List Languages
+ {
+ get
+ {
+ var ret = new List ();
+ if (!IsValid) return ret;
+ IntPtr hList = PackageReadHelper.GetResourcesLanguages (m_hReader.Value);
+ if (hList == IntPtr.Zero) return ret;
+ try
+ {
+ ret = PackageReadHelper.ReadWStringList (hList).ToList ();
+ }
+ finally
+ {
+ PackageReadHelper.DestroyWStringList (hList);
+ }
+ return ret;
+ }
+ }
+ public List Languages_LCID
+ {
+ get
+ {
+ var ret = new List ();
+ if (!IsValid) return ret;
+ IntPtr hList = PackageReadHelper.GetResourcesLanguagesToLcid (m_hReader.Value);
+ if (hList == IntPtr.Zero) return ret;
+ try
+ {
+ ret = PackageReadHelper.ReadLcidList (hList).ToList ();
+ }
+ finally
+ {
+ PackageReadHelper.DestroyResourcesLanguagesLcidList (hList);
+ }
+ return ret;
+ }
+ }
+ public List Scales
+ {
+ get
+ {
+ var ret = new List ();
+ if (!IsValid) return ret;
+ IntPtr hList = PackageReadHelper.GetResourcesLanguagesToLcid (m_hReader.Value);
+ if (hList == IntPtr.Zero) return ret;
+ try
+ {
+ ret = PackageReadHelper.ReadUInt32List (hList).Select (e => (int)e).ToList ();
+ }
+ finally
+ {
+ PackageReadHelper.DestroyUInt32List (hList);
+ }
+ return ret;
+ }
+ }
+ public override object BuildJSON ()
+ {
+ return new
+ {
+ dx_feature_levels = DXFeatures.Select (e => (int)e).ToList (),
+ languages = Languages,
+ scales = Scales
+ };
+ }
+ }
+ public class MRPrerequisites: BaseInfoSection, IPrerequisites
+ {
+ public MRPrerequisites (ref IntPtr hReader) : base (ref hReader) { }
+ protected DataUtils.Version GetVersion (string name)
+ {
+ PackageReadHelper.VERSION ver;
+ bool res = PackageReadHelper.GetManifestPrerequisite (m_hReader, name, out ver);
+ if (res) return new DataUtils.Version (ver.major, ver.minor, ver.build, ver.revision);
+ else return new DataUtils.Version ();
+ }
+ protected string GetVersionDescription (string name)
+ {
+ var ptr = PackageReadHelper.GetPackagePrerequistieSystemVersionName (m_hReader, name);
+ return PackageReadHelper.GetStringAndFreeFromPkgRead (ptr) ?? "";
+ }
+ public string OSMaxVersionDescription { get { return GetVersionDescription ("OSMaxVersionTested"); } }
+ public DataUtils.Version OSMaxVersionTested { get { return GetVersion ("OSMaxVersionTested"); } }
+ public DataUtils.Version OSMinVersion { get { return GetVersion ("OSMinVersion"); } }
+ public string OSMinVersionDescription { get { return GetVersionDescription ("OSMinVersion"); } }
+ public override object BuildJSON ()
+ {
+ return new
+ {
+ os_min_version = OSMinVersion.BuildJSON (),
+ os_min_version_description = OSMinVersionDescription,
+ os_max_version_tested = OSMaxVersionTested.BuildJSON (),
+ os_max_version_tested_description = OSMaxVersionDescription
+ };
+ }
+ }
+ [ComVisible (true)]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+ public class ManifestReader: IDisposable
+ {
+ private IntPtr m_hReader = PackageReadHelper.CreateManifestReader ();
+ private string m_filePath = string.Empty;
+ private bool m_usePRI = false;
+ private bool m_enablePRI = false;
+ private PriReader m_pri = new PriReader ();
+ public IntPtr Instance => m_hReader;
+ public string FileRoot{ get { return Path.GetPathRoot (m_filePath); } }
+ private void InitPri ()
+ {
+ m_pri.Dispose ();
+ if (!m_usePRI) return;
+ #region Get PRI IStream
+ switch (Type)
+ {
+ case PackageType.Appx:
+ {
+ var pripath = Path.Combine (FileRoot, "resources.pri");
+ m_pri.Create (pripath);
+ }
+ break;
+ }
+ #endregion
+ try
+ {
+ var resnames = new HashSet ();
+ using (var prop = Properties)
+ {
+ var temp = prop.Description;
+ if (PriFileHelper.IsMsResourcePrefix (temp)) resnames.Add (temp);
+ temp = prop.DisplayName;
+ if (PriFileHelper.IsMsResourcePrefix (temp)) resnames.Add (temp);
+ temp = prop.Publisher;
+ if (PriFileHelper.IsMsResourcePrefix (temp)) resnames.Add (temp);
+ resnames.Add (prop.Logo);
+ }
+ using (var apps = Applications)
+ {
+ foreach (var app in apps)
+ {
+ foreach (var pair in app)
+ {
+ foreach (var pathres in ConstData.FilePathItems)
+ {
+ if ((pathres?.Trim ()?.ToLower () ?? "") == (pair.Key?.Trim ()?.ToLower ()))
+ {
+ resnames.Add (pair.Value);
+ }
+ else if (PriFileHelper.IsMsResourcePrefix (pair.Value))
+ resnames.Add (pair.Value);
+ }
+ }
+ }
+ }
+ m_pri.AddSearch (resnames);
+ }
+ catch (Exception) { }
+ }
+ public PackageType Type
+ {
+ get
+ {
+ var value = PackageReadHelper.GetManifestType (m_hReader);
+ switch (value)
+ {
+ case 0: return PackageType.Unknown;
+ case 1: return PackageType.Appx;
+ case 2: return PackageType.Bundle;
+ }
+ return PackageType.Unknown;
+ }
+ }
+ public PackageRole Role
+ {
+ get
+ {
+ var value = PackageReadHelper.GetManifestRole (m_hReader);
+ switch (value)
+ {
+ case 0: return PackageRole.Unknown;
+ case 1: return PackageRole.Application;
+ case 2: return PackageRole.Framework;
+ case 3: return PackageRole.Resource;
+ }
+ return PackageRole.Unknown;
+ }
+ }
+ public bool IsApplicationManifest { get { return Role == PackageRole.Application; } }
+ public bool IsValid { get { return m_hReader != IntPtr.Zero && Type != PackageType.Unknown; } }
+ /// 使用 PRI,启用后会预先处理 PRI 文件。
+ public bool UsePri { get { return m_usePRI; } set { m_usePRI = value; InitPri (); } }
+ /// 允许 PRI,启用后会返回读取的 PRI 文件结果,需保证 UsePri 开启。
+ public bool EnablePri { get { return m_enablePRI; } set { m_enablePRI = value; } }
+ public MRIdentity Identity { get { return new MRIdentity (ref m_hReader); } }
+ public MRProperties Properties { get { return new MRProperties (ref m_hReader, this, ref m_pri, ref m_usePRI, ref m_enablePRI); } }
+ public MRPrerequisites Prerequisites { get { return new MRPrerequisites (ref m_hReader); } }
+ public MRResources Resources { get { return new MRResources (ref m_hReader); } }
+ public MRApplications Applications { get { return new MRApplications (ref m_hReader, this, ref m_pri, ref m_usePRI, ref m_enablePRI); } }
+ public MRCapabilities Capabilities { get { return new MRCapabilities (ref m_hReader); } }
+ public MRDependencies Dependencies { get { return new MRDependencies (ref m_hReader); } }
+ public void Dispose ()
+ {
+ if (m_hReader != IntPtr.Zero)
+ {
+ PackageReadHelper.DestroyManifestReader (m_hReader);
+ m_hReader = IntPtr.Zero;
+ }
+ var lastvalue = m_usePRI;
+ m_usePRI = false;
+ InitPri ();
+ m_usePRI = lastvalue;
+ }
+ ~ManifestReader () { Dispose (); }
+ public string FilePath
+ {
+ get
+ {
+ return m_filePath;
+ }
+ set
+ {
+ PackageReadHelper.LoadManifestFromFile (m_hReader, m_filePath = value);
+ }
+ }
+ public ManifestReader (string filePath) { FilePath = filePath; }
+ public ManifestReader () { }
+ public string JSONText { get { return BuildJsonText (); } }
+ public string BuildJsonText ()
+ {
+ var obj = BuildJsonObject ();
+ return Newtonsoft.Json.JsonConvert.SerializeObject (
+ obj,
+ Newtonsoft.Json.Formatting.Indented
+ );
+ }
+ private object BuildJsonObject ()
+ {
+ return new
+ {
+ valid = IsValid,
+ filepath = FilePath,
+ type = (int)Type,
+ role = (int)Role,
+ identity = Identity.BuildJSON (),
+ properties = Properties.BuildJSON (),
+ prerequisites = Prerequisites.BuildJSON (),
+ resources = Resources.BuildJSON (),
+ capabilities = Capabilities.BuildJSON (),
+ dependencies = Dependencies.BuildJSON (),
+ applications = Applications.BuildJSON ()
+ };
+ }
+ }
+}
diff --git a/AppxPackage/PackageManager.cs b/AppxPackage/PackageManager.cs
index 3e33dfc..307f077 100644
--- a/AppxPackage/PackageManager.cs
+++ b/AppxPackage/PackageManager.cs
@@ -77,7 +77,8 @@ namespace AppxPackage
private string familyName = "";
private string fullName = "";
private string resourceId = "";
- public PMIdentity (string _name, string _publisher, DataUtils.Version _ver, IEnumerable _archs, string _family, string _full, string _resid)
+ private string publisherId = "";
+ public PMIdentity (string _name, string _publisher, DataUtils.Version _ver, IEnumerable _archs, string _family, string _full, string _resid, string _publisherId)
{
name = _name;
publisher = _publisher;
@@ -86,6 +87,7 @@ namespace AppxPackage
familyName = _family;
fullName = _full;
resourceId = _resid;
+ publisherId = _publisherId;
}
public PMIdentity (PackageManageHelper.FIND_PACKAGE_ID pkgId) :
this (
@@ -95,7 +97,8 @@ namespace AppxPackage
new Architecture [] { (Architecture)pkgId.wProcessArchitecture },
Marshal.PtrToStringUni (pkgId.lpFamilyName),
Marshal.PtrToStringUni (pkgId.lpFullName),
- Marshal.PtrToStringUni (pkgId.lpResourceId)
+ Marshal.PtrToStringUni (pkgId.lpResourceId),
+ Marshal.PtrToStringUni (pkgId.lpPublisherId)
)
{ }
public string FamilyName => familyName;
@@ -103,8 +106,9 @@ namespace AppxPackage
public string Name => name;
public List ProcessArchitecture => archs.ToList ();
public string Publisher => publisher;
+ public string PublisherId => publisherId;
public string ResourceId => resourceId;
- DataUtils.Version IIdentity.Version => version;
+ public DataUtils.Version Version => version;
}
[ComVisible (true)]
[ClassInterface (ClassInterfaceType.AutoDual)]
diff --git a/AppxPackage/PackageReader.cs b/AppxPackage/PackageReader.cs
index e2bd163..a2ca103 100644
--- a/AppxPackage/PackageReader.cs
+++ b/AppxPackage/PackageReader.cs
@@ -104,10 +104,10 @@ namespace AppxPackage
[ClassInterface (ClassInterfaceType.AutoDual)]
public class BaseInfoSectWithPRI: BaseInfoSection
{
- protected Ref m_reader = null;
- protected Ref m_priBundle = null;
- protected Ref m_usePri = false;
- protected Ref m_enablePri = false;
+ protected Ref m_reader = new Ref (null);
+ protected Ref m_priBundle = new Ref (null);
+ protected Ref m_usePri = new Ref (false);
+ protected Ref m_enablePri = new Ref (false);
public BaseInfoSectWithPRI (ref IntPtr hReader, PackageReader reader, ref PriReaderBundle priBundle, ref bool usePri, ref bool enablePri) : base (ref hReader)
{
m_reader.Set (reader);
@@ -1168,7 +1168,7 @@ namespace AppxPackage
public PackageReader (string filePath) { FilePath = filePath; }
public PackageReader () { }
public string JSONText { get { return BuildJsonText (); } }
- private string BuildJsonText ()
+ public string BuildJsonText ()
{
var obj = BuildJsonObject ();
return Newtonsoft.Json.JsonConvert.SerializeObject (
diff --git a/AppxPackage/PkgReadNative.cs b/AppxPackage/PkgReadNative.cs
index a26f1d4..2dea4de 100644
--- a/AppxPackage/PkgReadNative.cs
+++ b/AppxPackage/PkgReadNative.cs
@@ -210,7 +210,8 @@ namespace NativeWrappers
string s = Marshal.PtrToStringUni (nativePtr);
try
{
- crt_free (nativePtr);
+ PackageReaderFreeString (nativePtr);
+ nativePtr = IntPtr.Zero;
}
catch
{
@@ -303,5 +304,103 @@ namespace NativeWrappers
{
}
}
+ // ================= Manifest Reader =================
+
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ public static extern IntPtr CreateManifestReader ();
+
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool LoadManifestFromFile (
+ IntPtr hReader,
+ string lpFilePath
+ );
+
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ public static extern void DestroyManifestReader (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern ushort GetManifestType (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool IsManifestValid (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern ushort GetManifestRole (IntPtr hReader);
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ public static extern IntPtr GetManifestIdentityStringValue (
+ IntPtr hReader,
+ uint dwName
+ );
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool GetManifestIdentityVersion (
+ IntPtr hReader,
+ out VERSION pVersion
+ );
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool GetManifestIdentityArchitecture (
+ IntPtr hReader,
+ out DWORD pdwArchi
+ );
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ public static extern IntPtr GetManifestPropertiesStringValue (
+ IntPtr hReader,
+ string lpName
+ );
+
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ public static extern HRESULT GetManifestPropertiesBoolValue (
+ IntPtr hReader,
+ string lpName,
+ out BOOL pRet
+ );
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool AddManifestApplicationItemGetName (string lpName);
+
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool RemoveManifestApplicationItemGetName (string lpName);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestApplications (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern void DestroyManifestApplications (IntPtr hEnumerator);
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestResourcesLanguages (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestResourcesLanguagesToLcid (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestResourcesScales (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern DWORD GetManifestResourcesDxFeatureLevels (IntPtr hReader);
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestDependencesInfoList (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestCapabilitiesList (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern IntPtr GetManifestDeviceCapabilitiesList (IntPtr hReader);
+
+ [DllImport (DllName, CallingConvention = CallConv, CharSet = CharSet.Unicode)]
+ [return: MarshalAs (UnmanagedType.Bool)]
+ public static extern bool GetManifestPrerequisite (
+ IntPtr hReader,
+ string lpName,
+ out VERSION pVerRet
+ );
+ [DllImport (DllName, CallingConvention = CallConv)]
+ public static extern void PackageReaderFreeString (IntPtr p);
+
}
}
\ No newline at end of file
diff --git a/AppxPackage/PriFileNative.cs b/AppxPackage/PriFileNative.cs
index c8886c1..008fb74 100644
--- a/AppxPackage/PriFileNative.cs
+++ b/AppxPackage/PriFileNative.cs
@@ -57,11 +57,13 @@ namespace AppxPackage
[DllImport (DLL, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.Bool)]
public static extern bool IsMsResourceUri ([MarshalAs (UnmanagedType.LPWStr)] string pResUri);
+ [DllImport (DLL, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void PriFormatFreeString (IntPtr ptr);
public static string PtrToString (IntPtr ptr)
{
if (ptr == IntPtr.Zero) return null;
string s = Marshal.PtrToStringUni (ptr);
- Marshal.FreeHGlobal (ptr); // 如果 DLL 返回的内存要求 free
+ PriFormatFreeString (ptr); // 如果 DLL 返回的内存要求 free
return s;
}
[DllImport (DLL, CallingConvention = CallingConvention.Cdecl)]
diff --git a/Bridge/SysInit.cs b/Bridge/SysInit.cs
index 0f57ca8..5789cec 100644
--- a/Bridge/SysInit.cs
+++ b/Bridge/SysInit.cs
@@ -496,6 +496,8 @@ namespace Bridge
{
public AppxPackage.PackageReader Reader (string packagePath) { return new AppxPackage.PackageReader (packagePath); }
public _I_PackageManager Manager => new _I_PackageManager ();
+ public AppxPackage.ManifestReader Manifest (string manifestPath) { return new AppxPackage.ManifestReader (manifestPath); }
+ public AppxPackage.ManifestReader FromInstallLocation (string installLocation) { return Manifest (Path.Combine (installLocation, "AppxManifest.xml")); }
}
[ComVisible (true)]
[ClassInterface (ClassInterfaceType.AutoDual)]
diff --git a/DataUtils/SysInit.cs b/DataUtils/SysInit.cs
index cf79e0b..5bddabf 100644
--- a/DataUtils/SysInit.cs
+++ b/DataUtils/SysInit.cs
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
namespace DataUtils
{
- internal static class VisualElementsStore
+ public static class VisualElementsStore
{
// Publicly accessible instances for internal use
public static readonly VisualElementManifest Vemanifest;
diff --git a/DataUtils/Theme.cs b/DataUtils/Theme.cs
index cca9ebe..b588ede 100644
--- a/DataUtils/Theme.cs
+++ b/DataUtils/Theme.cs
@@ -186,17 +186,6 @@ namespace DataUtils
if (string.IsNullOrWhiteSpace (colorStr)) return Color.Transparent;
string s = colorStr.Trim ();
- // Named color
- try
- {
- Color byName = Color.FromName (s);
- if (byName.IsKnownColor || byName.IsNamedColor)
- {
- return byName;
- }
- }
- catch { /* ignore */ }
-
// Hex: #RGB, #RRGGBB, #AARRGGBB
if (s.StartsWith ("#"))
{
@@ -321,6 +310,17 @@ namespace DataUtils
}
}
+ // Named color
+ try
+ {
+ Color byName = Color.FromName (s);
+ if (byName.IsKnownColor || byName.IsNamedColor)
+ {
+ return byName;
+ }
+ }
+ catch { /* ignore */ }
+
// fallback: try parse as known color again (case-insensitive)
try
{
diff --git a/Manager/Manager.csproj b/Manager/Manager.csproj
index aafaa79..32c9304 100644
--- a/Manager/Manager.csproj
+++ b/Manager/Manager.csproj
@@ -53,6 +53,7 @@
ManagerShell.cs
+
@@ -66,6 +67,7 @@
True
Resources.resx
+ True
diff --git a/Manager/ManagerShell.Designer.cs b/Manager/ManagerShell.Designer.cs
index 2f08544..fb6828d 100644
--- a/Manager/ManagerShell.Designer.cs
+++ b/Manager/ManagerShell.Designer.cs
@@ -40,6 +40,7 @@
this.PageScale = 125;
this.Text = "Form1";
this.Load += new System.EventHandler(this.ManagerShell_Load);
+ this.Resize += new System.EventHandler(this.ManagerShell_Resize);
this.ResumeLayout(false);
}
diff --git a/Manager/ManagerShell.cs b/Manager/ManagerShell.cs
index 4fb81bd..8b3d53e 100644
--- a/Manager/ManagerShell.cs
+++ b/Manager/ManagerShell.cs
@@ -14,12 +14,82 @@ namespace Manager
public ManagerShell ()
{
InitializeComponent ();
- SplashScreen.SplashBackgroundColor = Color.Honeydew;
+ try
+ {
+ var relativePath = DataUtils.VisualElementsStore.Vemanifest.SplashScreenImage (Program.g_appId);
+ var img = Image.FromFile (relativePath);
+ SplashScreen.SplashImage = img;
+ } catch (Exception e) {
+ var ex = e;
+ }
+ try
+ {
+ SplashScreen.SplashBackgroundColor = DataUtils.UITheme.StringToColor (DataUtils.VisualElementsStore.Vemanifest.SplashScreenBackgroundColor (Program.g_appId));
+ }
+ catch { }
+ InitSize ();
+ }
+ private void InitSize ()
+ {
+ uint ww = 0, wh = 0;
+ var ini = Bridge.InitFileStore.Config;
+ var setsect = ini ["Settings"];
+ var savepos = setsect.GetKey ("PackageManager:SavePosAndSizeBeforeCancel");
+ var lastw = setsect.GetKey ("PackageManager:LastWidth");
+ var lasth = setsect.GetKey ("PackageManager:LastHeight");
+ var defw = setsect.GetKey ("PackageManager:DefaultWidth");
+ var defh = setsect.GetKey ("PackageManager:DefaultHeight");
+ var minw = setsect.GetKey ("PackageManager:MinimumWidth");
+ var minh = setsect.GetKey ("PackageManager:MinimumHeight");
+ var lasts = setsect.GetKey ("PackageManager:LastWndState");
+ if (savepos.ReadBool ())
+ {
+ ww = lastw.ReadUInt (defw.ReadUInt (Properties.Resources.IDS_DEFAULTWIDTH.ParseTo ()));
+ wh = lasth.ReadUInt (defh.ReadUInt (Properties.Resources.IDS_DEFAULTHEIGHT.ParseTo ()));
+ }
+ else
+ {
+ ww = defw.ReadUInt (Properties.Resources.IDS_DEFAULTWIDTH.ParseTo ());
+ wh = defh.ReadUInt (Properties.Resources.IDS_DEFAULTHEIGHT.ParseTo ());
+ }
+ ClientSize = new Size ((int)(ww * DataUtils.UITheme.DPIDouble), (int)(wh * DataUtils.UITheme.DPIDouble));
+ int hborder = Size.Width - ClientSize.Width,
+ vborder = Size.Height - ClientSize.Height;
+ MinimumSize = new Size (
+ (int)(minw.ReadUInt (Properties.Resources.IDS_MINWIDTH.ParseTo ()) * DataUtils.UITheme.DPIDouble) + hborder,
+ (int)(minh.ReadUInt (Properties.Resources.IDS_MINHEIGHT.ParseTo ()) * DataUtils.UITheme.DPIDouble) + vborder
+ );
+ WindowState = (FormWindowState)lasts.ReadInt ((int)FormWindowState.Normal);
}
private void ManagerShell_Load (object sender, EventArgs e)
{
var root = Path.GetDirectoryName (DataUtils.Utilities.GetCurrentProgramPath ());
WebUI.Navigate (Path.Combine (root, "html\\manager.html"));
+ var pkg = new AppxPackage.PackageReader (@"F:\新建文件夹 (2)\9E2F88E3.Twitter_1.1.13.8_x86__wgeqdkkx372wm.appx");
+ pkg.EnablePri = true;
+ pkg.UsePri = true;
+ var displayName = pkg.Properties.LogoBase64;
+ }
+ private void ManagerShell_Resize (object sender, EventArgs e)
+ {
+ var ini = Bridge.InitFileStore.Config;
+ var setsect = ini ["Settings"];
+ var savepos = setsect.GetKey ("PackageManager:SavePosAndSizeBeforeCancel");
+ var lastw = setsect.GetKey ("PackageManager:LastWidth");
+ var lasth = setsect.GetKey ("PackageManager:LastHeight");
+ var lasts = setsect.GetKey ("PackageManager:LastWndState");
+ switch (WindowState)
+ {
+ case FormWindowState.Normal:
+ case FormWindowState.Maximized:
+ lasts.Write ((int)WindowState);
+ break;
+ }
+ if (WindowState == FormWindowState.Normal && savepos.ReadBool ())
+ {
+ lastw.Write ((int)(ClientSize.Width / DataUtils.UITheme.DPIDouble));
+ lasth.Write ((int)(ClientSize.Height / DataUtils.UITheme.DPIDouble));
+ }
}
}
}
diff --git a/Manager/Polyfill.cs b/Manager/Polyfill.cs
new file mode 100644
index 0000000..ce8beea
--- /dev/null
+++ b/Manager/Polyfill.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+
+namespace Manager
+{
+ public static class Polyfill
+ {
+ public static T ParseTo (this string src, T dflt = default (T))
+ {
+ if (string.IsNullOrWhiteSpace (src)) return dflt;
+ try
+ {
+ Type targetType = typeof (T);
+ Type underlying = Nullable.GetUnderlyingType (targetType);
+ if (underlying != null)
+ {
+ object v = Convert.ChangeType (src, underlying, CultureInfo.InvariantCulture);
+ return (T)v;
+ }
+ if (targetType.IsEnum)
+ {
+ object enumValue = Enum.Parse (targetType, src, true);
+ return (T)enumValue;
+ }
+ TypeConverter converter = TypeDescriptor.GetConverter (targetType);
+ if (converter != null && converter.CanConvertFrom (typeof (string)))
+ {
+ object v = converter.ConvertFrom (null, CultureInfo.InvariantCulture, src);
+ return (T)v;
+ }
+ }
+ catch { }
+ return dflt;
+ }
+ }
+}
diff --git a/Manager/Program.cs b/Manager/Program.cs
index 25ccbad..fdd20ad 100644
--- a/Manager/Program.cs
+++ b/Manager/Program.cs
@@ -7,6 +7,8 @@ namespace Manager
{
static class Program
{
+ static public readonly string g_appUserId = "WindowsModern.PracticalToolsProject!Manager";
+ static public readonly string g_appId = "Manager";
///
/// 应用程序的主入口点。
///
diff --git a/Manager/Properties/Resources.Designer.cs b/Manager/Properties/Resources.Designer.cs
index d0cd4f2..e47740d 100644
--- a/Manager/Properties/Resources.Designer.cs
+++ b/Manager/Properties/Resources.Designer.cs
@@ -1,71 +1,99 @@
//------------------------------------------------------------------------------
//
// 此代码由工具生成。
-// 运行时版本: 4.0.30319.42000
+// 运行时版本:4.0.30319.42000
//
-// 对此文件的更改可能导致不正确的行为,如果
-// 重新生成代码,则所做更改将丢失。
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
//
//------------------------------------------------------------------------------
-namespace Manager.Properties
-{
-
-
- ///
- /// 强类型资源类,用于查找本地化字符串等。
- ///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute ("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute ()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute ()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute ("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources ()
- {
- }
-
- ///
- /// 返回此类使用的缓存 ResourceManager 实例。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute (global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager ("Manager.Properties.Resources", typeof (Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// 覆盖当前线程的 CurrentUICulture 属性
- /// 使用此强类型的资源类的资源查找。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute (global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
+namespace Manager.Properties {
+ using System;
+
+
+ ///
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// 返回此类使用的缓存的 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Manager.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 使用此强类型资源类,为所有资源查找
+ /// 重写当前线程的 CurrentUICulture 属性。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// 查找类似 600 的本地化字符串。
+ ///
+ internal static string IDS_DEFAULTHEIGHT {
+ get {
+ return ResourceManager.GetString("IDS_DEFAULTHEIGHT", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 800 的本地化字符串。
+ ///
+ internal static string IDS_DEFAULTWIDTH {
+ get {
+ return ResourceManager.GetString("IDS_DEFAULTWIDTH", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 412 的本地化字符串。
+ ///
+ internal static string IDS_MINHEIGHT {
+ get {
+ return ResourceManager.GetString("IDS_MINHEIGHT", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 504 的本地化字符串。
+ ///
+ internal static string IDS_MINWIDTH {
+ get {
+ return ResourceManager.GetString("IDS_MINWIDTH", resourceCulture);
+ }
+ }
+ }
}
diff --git a/Manager/Properties/Resources.resx b/Manager/Properties/Resources.resx
index af7dbeb..60b27a0 100644
--- a/Manager/Properties/Resources.resx
+++ b/Manager/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,25 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 600
+ 默认窗口高度
+
+
+ 800
+ 默认窗口宽度
+
+
+ 412
+ 默认最小窗口高度
+
+
+ 504
+ 默认最小窗口宽度
+
\ No newline at end of file
diff --git a/Manager/app.manifest b/Manager/app.manifest
index 7db33c3..b0b2bcf 100644
--- a/Manager/app.manifest
+++ b/Manager/app.manifest
@@ -8,16 +8,16 @@
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
-
+ -->
-
+
-
+
diff --git a/PrivateInit/Win32.cs b/PrivateInit/Win32.cs
index d9159e5..dd7a15a 100644
--- a/PrivateInit/Win32.cs
+++ b/PrivateInit/Win32.cs
@@ -186,7 +186,7 @@ namespace Win32
public object Get (string section, string key, object dflt) => GetKey (section, key).Get (dflt);
public object Get (string section, string key) => GetKey (section, key).Get ();
public bool Set (string section, string key, object value) => GetKey (section, key).Set (value);
- public object this [string key] => GetSection (key);
+ public InitSection this [string key] => GetSection (key);
public string [] GetAllSections ()
{
var sections = new System.Collections.Generic.List ();
diff --git a/Release.7z b/Release.7z
new file mode 100644
index 0000000..abc7095
Binary files /dev/null and b/Release.7z differ
diff --git a/WAShell/Properties/Resources.Designer.cs b/WAShell/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..fafc8ee
--- /dev/null
+++ b/WAShell/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace WAShell.Properties {
+ using System;
+
+
+ ///
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// 返回此类使用的缓存的 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WAShell.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 使用此强类型资源类,为所有资源查找
+ /// 重写当前线程的 CurrentUICulture 属性。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/WAShell/Properties/Resources.resx b/WAShell/Properties/Resources.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/WAShell/Properties/Resources.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WAShell/SplashForm.Designer.cs b/WAShell/SplashForm.Designer.cs
index 771ec4e..93f1c50 100644
--- a/WAShell/SplashForm.Designer.cs
+++ b/WAShell/SplashForm.Designer.cs
@@ -38,6 +38,7 @@
//
this.picbox.Anchor = System.Windows.Forms.AnchorStyles.None;
this.picbox.BackColor = System.Drawing.Color.Transparent;
+ this.picbox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.picbox.Location = new System.Drawing.Point(6, 47);
this.picbox.Name = "picbox";
this.picbox.Size = new System.Drawing.Size(620, 300);
diff --git a/WAShell/SplashForm.cs b/WAShell/SplashForm.cs
index e3b911e..385ce19 100644
--- a/WAShell/SplashForm.cs
+++ b/WAShell/SplashForm.cs
@@ -87,9 +87,9 @@ namespace WAShell
set
{
splashImage = value;
- if (picbox != null && picbox.IsHandleCreated)
+ if (picbox != null)
{
- picbox.Image = splashImage;
+ try { picbox.Image = splashImage; } catch { }
}
}
}
diff --git a/WAShell/WAShell.csproj b/WAShell/WAShell.csproj
index 5c4b0a2..3665537 100644
--- a/WAShell/WAShell.csproj
+++ b/WAShell/WAShell.csproj
@@ -42,6 +42,11 @@
+
+ True
+ True
+ Resources.resx
+
Form
@@ -78,6 +83,10 @@
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
SplashForm.cs
diff --git a/pkgmgr/pkgmgr.cpp b/pkgmgr/pkgmgr.cpp
index 2de779a..dea8dd2 100644
--- a/pkgmgr/pkgmgr.cpp
+++ b/pkgmgr/pkgmgr.cpp
@@ -298,10 +298,10 @@ struct pkg_info
pi.users += sid;
}
{
- std::wstring sid;
- WAPParseSetStringValue (sid, it->UserSecurityId);
+ std::wstring sid2;
+ WAPParseSetStringValue (sid2, it->UserSecurityId);
if (i) pi.sids += L';';
- pi.sids += sid;
+ pi.sids += sid2;
}
i ++;
}
@@ -857,4 +857,149 @@ HRESULT FindAppxPackagesByFamilyName (LPCWSTR lpPkgFamilyName, PKGMGR_FINDENUMCA
void PackageManagerFreeString (LPWSTR lpString)
{
if (lpString) free (lpString);
-}
\ No newline at end of file
+}
+[STAThread]
+HRESULT CreateAppDataManager (LPCWSTR lpFamilyName, HWRTAPPDATA *ppApplicationData, LPWSTR *pErrorCode, LPWSTR *pDetailMsg)
+{
+ g_swExceptionCode = L"";
+ g_swExceptionDetail = L"";
+ try
+ {
+ auto adm = ApplicationDataManager::CreateForPackageFamily (ref new String (lpFamilyName ? lpFamilyName : L""));
+ auto insp = reinterpret_cast (adm);
+ insp->AddRef ();
+ if (ppApplicationData) *ppApplicationData = (HWRTAPPDATA)insp;
+ return S_OK;
+ }
+ catch (AccessDeniedException ^e)
+ {
+ g_swExceptionDetail = e->ToString ()->Data ();
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return (SUCCEEDED ((HRESULT)e->HResult) ? E_FAIL : (HRESULT)e->HResult);
+ }
+ catch (Exception ^e)
+ {
+ g_swExceptionDetail = e->ToString ()->Data ();
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return (SUCCEEDED ((HRESULT)e->HResult) ? E_FAIL : (HRESULT)e->HResult);
+ }
+ catch (const std::exception &e)
+ {
+ g_swExceptionDetail = StringToWString (e.what () ? e.what () : "Unknown exception.");
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_FAIL;
+ }
+ catch (...)
+ {
+ g_swExceptionDetail = L"Unknown exception";
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_FAIL;
+ }
+ return E_FAIL;
+}
+HRESULT RunAsyncActionOperation (Windows::Foundation::IAsyncAction ^asyncAction, LPWSTR *pErrorCode, LPWSTR *pDetailMsg)
+{
+ g_swExceptionCode.clear ();
+ g_swExceptionDetail.clear ();
+ if (pErrorCode) *pErrorCode = nullptr;
+ if (pDetailMsg) *pDetailMsg = nullptr;
+ if (!asyncAction) return E_POINTER;
+ HANDLE hCompEvt = CreateEventExW (
+ nullptr,
+ nullptr,
+ CREATE_EVENT_MANUAL_RESET,
+ EVENT_ALL_ACCESS
+ );
+ if (!hCompEvt) return HRESULT_FROM_WIN32 (GetLastError ());
+ auto closeEvt = destruct ([&] () {
+ CloseHandle (hCompEvt);
+ });
+ try
+ {
+ asyncAction->Completed =
+ ref new Windows::Foundation::AsyncActionCompletedHandler (
+ [&hCompEvt] (
+ Windows::Foundation::IAsyncAction^,
+ Windows::Foundation::AsyncStatus)
+ {
+ SetEvent (hCompEvt);
+ });
+ WaitForSingleObject (hCompEvt, INFINITE);
+ switch (asyncAction->Status)
+ {
+ case Windows::Foundation::AsyncStatus::Completed: return S_OK;
+ case Windows::Foundation::AsyncStatus::Canceled:
+ g_swExceptionDetail = L"Async action was canceled.";
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_ABORT;
+ case Windows::Foundation::AsyncStatus::Error:
+ {
+ auto err = asyncAction->ErrorCode;
+ HRESULT hr = (HRESULT)err.Value;
+ auto errStr = Platform::Exception::CreateException (err.Value)->ToString ();
+ if (errStr && errStr->Data ()) g_swExceptionCode = errStr->Data ();
+ if (pErrorCode) *pErrorCode = _wcsdup (g_swExceptionCode.c_str ());
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return hr;
+ }
+ default: return E_FAIL;
+ }
+ }
+ catch (Platform::Exception^ e)
+ {
+ g_swExceptionDetail = e->ToString ()->Data ();
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return e->HResult;
+ }
+ catch (const std::exception& e)
+ {
+ g_swExceptionDetail = StringToWString (e.what () ? e.what () : "Unknown exception.");
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_FAIL;
+ }
+ catch (...)
+ {
+ g_swExceptionDetail = L"Unknown exception.";
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_FAIL;
+ }
+}
+#define HWRTAppDataToAppData(pInspectable) \
+ safe_cast (reinterpret_cast (pInspectable))
+[MTAThread]
+HRESULT WRTAppDataClearAll (HWRTAPPDATA hAppData, LPWSTR *pErrorCode, LPWSTR *pDetailMsg)
+{
+ g_swExceptionCode = L"";
+ g_swExceptionDetail = L"";
+ try
+ {
+ ApplicationData ^appData = HWRTAppDataToAppData (hAppData, appData, pErrorCode, pDetailMsg);
+ if (appData == nullptr) return E_FAIL;
+ return RunAsyncActionOperation (appData->ClearAsync (), pErrorCode, pDetailMsg);
+ }
+ catch (AccessDeniedException ^e)
+ {
+ g_swExceptionDetail = e->ToString ()->Data ();
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return (SUCCEEDED ((HRESULT)e->HResult) ? E_FAIL : (HRESULT)e->HResult);
+ }
+ catch (Exception ^e)
+ {
+ g_swExceptionDetail = e->ToString ()->Data ();
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return (SUCCEEDED ((HRESULT)e->HResult) ? E_FAIL : (HRESULT)e->HResult);
+ }
+ catch (const std::exception &e)
+ {
+ g_swExceptionDetail = StringToWString (e.what () ? e.what () : "Unknown exception.");
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_FAIL;
+ }
+ catch (...)
+ {
+ g_swExceptionDetail = L"Unknown exception";
+ if (pDetailMsg) *pDetailMsg = _wcsdup (g_swExceptionDetail.c_str ());
+ return E_FAIL;
+ }
+ return E_FAIL;
+}
diff --git a/pkgmgr/pkgmgr.h b/pkgmgr/pkgmgr.h
index ca53289..3dec0ae 100644
--- a/pkgmgr/pkgmgr.h
+++ b/pkgmgr/pkgmgr.h
@@ -194,6 +194,15 @@ extern "C"
PKGMGR_API HRESULT FindAppxPackagesByFamilyName (LPCWSTR lpPkgFamilyName, PKGMGR_FINDENUMCALLBACK pfCallback, void *pCustom _DEFAULT_INIT_VALUE_FORFUNC_ (NULL), LPWSTR *pErrorCode _DEFAULT_INIT_VALUE_FORFUNC_ (NULL), LPWSTR *pDetailMsg _DEFAULT_INIT_VALUE_FORFUNC_ (NULL));
// ͷ pkgmgr.dll صĶַ̬
PKGMGR_API void PackageManagerFreeString (LPWSTR lpString);
+#ifndef TEMPLATE_STRUCT
+#define TEMPLATE_STRUCT(_typename_) typedef struct _typename_##__ _typename_
+#endif // ! TEMPLATE_STRUCT
+ TEMPLATE_STRUCT (WRTAPPDATA);
+ typedef WRTAPPDATA *HWRTAPPDATA;
+ // Ӧݹͨ Package Family Name
+ PKGMGR_API HRESULT CreateAppDataManager (LPCWSTR lpFamilyName, HWRTAPPDATA *ppApplicationData, LPWSTR *pErrorCode, LPWSTR *pDetailMsg);
+ // ӱءκʱӦݴ洢ɾӦóݡ
+ PKGMGR_API HRESULT WRTAppDataClearAll (HWRTAPPDATA hAppData, LPWSTR *pErrorCode, LPWSTR *pDetailMsg);
#ifdef _DEFAULT_INIT_VALUE_
#undef _DEFAULT_INIT_VALUE_
#endif
diff --git a/pkgmgr/stdafx.h b/pkgmgr/stdafx.h
index c2220a4..1c04af3 100644
--- a/pkgmgr/stdafx.h
+++ b/pkgmgr/stdafx.h
@@ -32,3 +32,5 @@
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Management::Deployment;
+using namespace Windows::Management::Core;
+using namespace Windows::Storage;
diff --git a/pkgread/pkgread.cpp b/pkgread/pkgread.cpp
index ff4436d..db21d1d 100644
--- a/pkgread/pkgread.cpp
+++ b/pkgread/pkgread.cpp
@@ -1213,4 +1213,544 @@ LPWSTR GetPackageCapabilityDisplayName (LPCWSTR lpCapabilityName)
std::wstring ret = GetCapabilityDisplayName (capname);
if (IsNormalizeStringEmpty (ret)) return nullptr;
else return _wcsdup (ret.c_str ());
-}
\ No newline at end of file
+}
+
+void PackageReaderFreeString (LPWSTR lpStrFromThisDll)
+{
+ if (!lpStrFromThisDll) return;
+ free (lpStrFromThisDll);
+}
+
+// ========== Ƕ嵥ļĶȡ ==========
+#define ToHandleMRead(_cpp_ptr_) reinterpret_cast (_cpp_ptr_)
+#define ToPtrManifest(_cpp_ptr_) reinterpret_cast (_cpp_ptr_)
+HPKGMANIFESTREAD CreateManifestReader () { return ToHandleMRead (new manifest ()); }
+BOOL LoadManifestFromFile (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpFilePath)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return false;
+ return ptr->create (lpFilePath);
+}
+void DestroyManifestReader (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return;
+ return delete ptr;
+}
+WORD GetManifestType (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return PKGTYPE_UNKNOWN;
+ switch (ptr->type ())
+ {
+ case PackageType::unknown: return PKGTYPE_UNKNOWN;
+ case PackageType::single: return PKGTYPE_APPX;
+ case PackageType::bundle: return PKGTYPE_BUNDLE;
+ }
+ return PKGTYPE_UNKNOWN;
+}
+BOOL IsManifestValid (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return false;
+ return ptr->valid ();
+}
+WORD GetManifestRole (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return PKGROLE_UNKNOWN;
+ switch (ptr->type ())
+ {
+ case PackageType::unknown: return PKGROLE_UNKNOWN;
+ case PackageType::bundle: return PKGROLE_APPLICATION;
+ case PackageType::single: {
+ auto ar = ptr->appx_reader ();
+ switch (ar.package_role ())
+ {
+ case PackageRole::unknown: return PKGROLE_UNKNOWN;
+ case PackageRole::application: return PKGROLE_APPLICATION;
+ case PackageRole::framework: return PKGROLE_FRAMEWORK;
+ case PackageRole::resource: return PKGROLE_RESOURCE;
+ }
+ } break;
+ }
+ return PKGROLE_UNKNOWN;
+}
+// Identity
+LPWSTR GetManifestIdentityStringValue (_In_ HPKGMANIFESTREAD hReader, _In_ DWORD dwName)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto id = reader.identity ();
+ switch (LOWORD (dwName))
+ {
+ case PKG_IDENTITY_NAME: return _wcsdup (id.name ().c_str ());
+ case PKG_IDENTITY_PUBLISHER: return _wcsdup (id.publisher ().c_str ());
+ case PKG_IDENTITY_PACKAGEFAMILYNAME: return _wcsdup (id.package_family_name ().c_str ());
+ case PKG_IDENTITY_PACKAGEFULLNAME: return _wcsdup (id.package_full_name ().c_str ());
+ case PKG_IDENTITY_RESOURCEID: return _wcsdup (id.resource_id ().c_str ());
+ }
+ } break;
+ case PackageType::bundle: {
+ auto reader = ptr->bundle_reader ();
+ auto id = reader.identity ();
+ {
+ switch (LOWORD (dwName))
+ {
+ case PKG_IDENTITY_NAME: return _wcsdup (id.name ().c_str ());
+ case PKG_IDENTITY_PUBLISHER: return _wcsdup (id.publisher ().c_str ());
+ case PKG_IDENTITY_PACKAGEFAMILYNAME: return _wcsdup (id.package_family_name ().c_str ());
+ case PKG_IDENTITY_PACKAGEFULLNAME: return _wcsdup (id.package_full_name ().c_str ());
+ case PKG_IDENTITY_RESOURCEID: return _wcsdup (id.resource_id ().c_str ());
+ }
+ }
+ } break;
+ }
+ return nullptr;
+}
+BOOL GetManifestIdentityVersion (_In_ HPKGMANIFESTREAD hReader, _Out_ VERSION *pVersion)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return FALSE;
+ if (!pVersion) return FALSE;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto id = reader.identity ();
+ auto ver = id.version ();
+ *pVersion = VersionClassToStruct (ver);
+ return !ver.empty ();
+ } break;
+ case PackageType::bundle: {
+ auto reader = ptr->bundle_reader ();
+ auto id = reader.identity ();
+ {
+ auto ver = id.version ();
+ *pVersion = VersionClassToStruct (ver);
+ return !ver.empty ();
+ }
+ } break;
+ }
+ return FALSE;
+}
+BOOL GetManifestIdentityArchitecture (_In_ HPKGMANIFESTREAD hReader, _Out_ DWORD *pdwArchi)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return FALSE;
+ if (!pdwArchi) return FALSE;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto id = reader.identity ();
+ auto archi = id.architecture ();
+ DWORD ret = 0;
+ switch (archi)
+ {
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X86:
+ ret = PKG_ARCHITECTURE_X86; break;
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_ARM:
+ ret = PKG_ARCHITECTURE_ARM; break;
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X64:
+ ret = PKG_ARCHITECTURE_X64; break;
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_NEUTRAL:
+ ret = PKG_ARCHITECTURE_NEUTRAL; break;
+ case (APPX_PACKAGE_ARCHITECTURE)12: // ARM64
+ ret = PKG_ARCHITECTURE_ARM64; break;
+ }
+ *pdwArchi = ret;
+ return ret != PKG_ARCHITECTURE_UNKNOWN;
+ } break;
+ case PackageType::bundle: {
+ auto reader = ptr->bundle_reader ();
+ auto ids = reader.package_id_items ();
+ std::vector apps;
+ ids.application_packages (apps);
+ DWORD ret = 0;
+ for (auto &it : apps)
+ {
+ auto id = it.identity ();
+ auto archi = id.architecture ();
+ switch (archi)
+ {
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X86:
+ ret |= PKG_ARCHITECTURE_X86; break;
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_ARM:
+ ret |= PKG_ARCHITECTURE_ARM; break;
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X64:
+ ret |= PKG_ARCHITECTURE_X64; break;
+ case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_NEUTRAL:
+ ret |= PKG_ARCHITECTURE_NEUTRAL; break;
+ case (APPX_PACKAGE_ARCHITECTURE)12: // ARM64
+ ret |= PKG_ARCHITECTURE_ARM64; break;
+ }
+ }
+ *pdwArchi = ret;
+ return ret != PKG_ARCHITECTURE_UNKNOWN;
+ } break;
+ }
+ return FALSE;
+}
+// Properties
+LPWSTR GetManifestPropertiesStringValue (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpName)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto prop = reader.properties ();
+ return _wcsdup (prop.string_value (lpName ? lpName : L"").c_str ());
+ } break;
+ }
+ return nullptr;
+}
+HRESULT GetManifestPropertiesBoolValue (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpName, _Outptr_ BOOL *pRet)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return E_INVALIDARG;
+ if (!pRet) return E_INVALIDARG;
+ *pRet = FALSE;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ IAppxManifestReader *m = reader.manifest ();
+ if (!m) return E_FAIL;
+ CComPtr p;
+ HRESULT hr = m->GetProperties (&p);
+ if (FAILED (hr)) return hr;
+ return p->GetBoolValue (lpName, pRet);
+ } break;
+ }
+ return E_FAIL;
+}
+// Applications
+BOOL AddManifestApplicationItemGetName (_In_ LPCWSTR lpName)
+{
+ if (std::wnstring (lpName ? lpName : L"").empty ()) return FALSE;
+ return PushApplicationAttributeItem (lpName);
+}
+BOOL RemoveManifestApplicationItemGetName (_In_ LPCWSTR lpName)
+{
+ if (std::wnstring (lpName ? lpName : L"").empty ()) return FALSE;
+ return RemoveApplicationAttributeItem (lpName);
+}
+HAPPENUMERATOR GetManifestApplications (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto app = reader.applications ();
+ auto appvec = new app_enumerator ();
+ app.applications (*appvec);
+ return ToHandleAppEnumerator (appvec);
+ } break;
+ }
+ return nullptr;
+}
+void DestroyManifestApplications (_In_ HAPPENUMERATOR hEnumerator)
+{
+ auto ptr = ToPtrAppxApps (hEnumerator);
+ if (ptr) delete ptr;
+}
+// Resources
+HLIST_PVOID GetManifestResourcesLanguages (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ std::vector langs;
+ switch (ptr->type ())
+ {
+ case PackageType::single:
+ {
+ auto reader = ptr->appx_reader ();
+ auto res = reader.resources ();
+ res.languages (langs);
+ break;
+ }
+ case PackageType::bundle:
+ {
+ auto br = ptr->bundle_reader ();
+ auto res = br.package_id_items ();
+ res.enumerate ([&langs] (IAppxBundleManifestPackageInfo *inf) {
+ auto item = appx_info::appx_iditem (inf);
+ std::vector l;
+ auto qr = item.qualified_resources ();
+ qr.languages (l);
+ for (auto &it : l) push_unique (langs, it);
+ });
+ break;
+ }
+ default: return nullptr;
+ }
+ if (langs.empty ()) return nullptr;
+ size_t count = langs.size ();
+ size_t bytes = sizeof (LIST_PVOID) + sizeof (LPWSTR) * (count - 1);
+ auto list = (HLIST_PVOID)malloc (bytes);
+ ZeroMemory (list, bytes);
+ if (!list) return nullptr;
+ list->dwSize = 0;
+ for (auto &it : langs) list->alpVoid [list->dwSize ++] = _wcsdup (it.c_str ());
+ return list;
+}
+HLIST_LCID GetManifestResourcesLanguagesToLcid (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ std::vector langs;
+ switch (ptr->type ())
+ {
+ case PackageType::single:
+ {
+ auto reader = ptr->appx_reader ();
+ auto res = reader.resources ();
+ res.languages (langs);
+ break;
+ }
+ case PackageType::bundle:
+ {
+ auto br = ptr->bundle_reader ();
+ auto res = br.package_id_items ();
+ res.enumerate ([&langs] (IAppxBundleManifestPackageInfo *inf) {
+ auto item = appx_info::appx_iditem (inf);
+ std::vector l;
+ auto qr = item.qualified_resources ();
+ qr.languages (l);
+ for (auto &it : l) push_unique (langs, it);
+ });
+ break;
+ }
+ default: return nullptr;
+ }
+ if (langs.empty ()) return nullptr;
+ size_t len = sizeof (LIST_LCID) + sizeof (LCID) * langs.size ();
+ HLIST_LCID hList = (HLIST_LCID)malloc (len);
+ ZeroMemory (hList, len);
+ hList->dwSize = 0;
+ for (auto &it : langs)
+ {
+ LCID lcid = LocaleCodeToLcid (it);
+ if (lcid)
+ {
+ hList->aLcid [hList->dwSize ++] = lcid;
+ }
+ }
+ return hList;
+}
+HLIST_UINT32 GetManifestResourcesScales (_In_ HPKGMANIFESTREAD hReader)
+
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ std::vector scales;
+ switch (ptr->type ())
+ {
+ case PackageType::single:
+ {
+ auto reader = ptr->appx_reader ();
+ auto res = reader.resources ();
+ res.scales (scales);
+ break;
+ }
+ case PackageType::bundle:
+ {
+ auto br = ptr->bundle_reader ();
+ auto res = br.package_id_items ();
+ res.enumerate ([&scales] (IAppxBundleManifestPackageInfo *inf) {
+ auto item = appx_info::appx_iditem (inf);
+ std::vector s;
+ auto qr = item.qualified_resources ();
+ qr.scales (s);
+ for (auto &it : s) push_unique (scales, it);
+ });
+ break;
+ }
+ default: return nullptr;
+ }
+ if (scales.empty ()) return nullptr;
+ size_t len = sizeof (LIST_UINT32) + sizeof (UINT32) * scales.size ();
+ HLIST_UINT32 hList = (HLIST_UINT32)malloc (len);
+ ZeroMemory (hList, len);
+ hList->dwSize = 0;
+ for (auto &it : scales)
+ {
+ if (!it) continue;
+ hList->aUI32 [hList->dwSize ++] = it;
+ }
+ return hList;
+}
+DWORD GetManifestResourcesDxFeatureLevels (_In_ HPKGMANIFESTREAD hReader)
+
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return 0;
+ DWORD dwFlags = 0;
+ switch (ptr->type ())
+ {
+ case PackageType::single:
+ {
+ auto reader = ptr->appx_reader ();
+ auto res = reader.resources ();
+ std::vector dxlevels;
+ res.dx_feature_level (dxlevels);
+ for (auto &it : dxlevels)
+ {
+ switch (it)
+ {
+ case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_9:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL9; break;
+ case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_10:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL10; break;
+ case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_11:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL11; break;
+ case (DX_FEATURE_LEVEL)4:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL12; break;
+ }
+ }
+ break;
+ }
+ case PackageType::bundle:
+ {
+ auto br = ptr->bundle_reader ();
+ auto res = br.package_id_items ();
+ res.enumerate ([&dwFlags] (IAppxBundleManifestPackageInfo *inf) {
+ auto item = appx_info::appx_iditem (inf);
+ std::vector dxlevels;
+ auto qr = item.qualified_resources ();
+ qr.dx_feature_level (dxlevels);
+ for (auto &it : dxlevels)
+ {
+ switch (it)
+ {
+ case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_9:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL9; break;
+ case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_10:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL10; break;
+ case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_11:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL11; break;
+ case (DX_FEATURE_LEVEL)4:
+ dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL12; break;
+ }
+ }
+ });
+ break;
+ }
+ default: return 0;
+ }
+ return dwFlags;
+}
+// Dependencies
+HLIST_DEPINFO GetManifestDependencesInfoList (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ std::vector vec;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto deps = reader.dependencies ();
+ deps.dependencies (vec);
+ } break;
+ }
+ size_t len = sizeof (LIST_DEPINFO) + sizeof (DEPENDENCY_INFO) * vec.size ();
+ HLIST_DEPINFO hList = (HLIST_DEPINFO)malloc (len);
+ ZeroMemory (hList, len);
+ hList->dwSize = 0;
+ for (auto &it : vec)
+ {
+ auto &dep = hList->aDepInfo [hList->dwSize ++];
+ dep.lpName = _wcsdup (it.name.c_str ());
+ dep.lpPublisher = _wcsdup (it.publisher.c_str ());
+ dep.verMin = VersionClassToStruct (it.minversion);
+ }
+ return hList;
+}
+// Capabilities
+HLIST_PVOID GetManifestCapabilitiesList (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ std::vector caps;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto cap = reader.capabilities ();
+ std::vector vec;
+ cap.capabilities_names (vec);
+ for (auto &it : vec)
+ {
+ auto cname = std::wnstring (it.c_str ());
+ if (cname.empty ()) continue;
+ push_unique (caps, cname);
+ }
+ } break;
+ }
+ size_t len = sizeof (LIST_PVOID) + sizeof (LPWSTR) * caps.size ();
+ HLIST_PVOID hList = (HLIST_PVOID)malloc (len);
+ ZeroMemory (hList, len);
+ hList->dwSize = 0;
+ for (auto &it : caps)
+ {
+ hList->alpVoid [hList->dwSize ++] = (LPVOID)_wcsdup (it.c_str ());
+ }
+ return hList;
+}
+HLIST_PVOID GetManifestDeviceCapabilitiesList (_In_ HPKGMANIFESTREAD hReader)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return nullptr;
+ std::vector caps;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto cap = reader.capabilities ();
+ std::vector vec;
+ cap.device_capabilities (vec);
+ for (auto &it : vec)
+ {
+ auto cname = std::wnstring (it.c_str ());
+ if (cname.empty ()) continue;
+ push_unique (caps, cname);
+ }
+ } break;
+ }
+ size_t len = sizeof (LIST_PVOID) + sizeof (LPWSTR) * caps.size ();
+ HLIST_PVOID hList = (HLIST_PVOID)malloc (len);
+ ZeroMemory (hList, len);
+ hList->dwSize = 0;
+ for (auto &it : caps)
+ {
+ hList->alpVoid [hList->dwSize ++] = (LPVOID)_wcsdup (it.c_str ());
+ }
+ return hList;
+}
+// Prerequisite
+BOOL GetManifestPrerequisite (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpName, _Outptr_ VERSION *pVerRet)
+{
+ auto ptr = ToPtrManifest (hReader);
+ if (!ptr) return FALSE;
+ switch (ptr->type ())
+ {
+ case PackageType::single: {
+ auto reader = ptr->appx_reader ();
+ auto pre = reader.prerequisites ();
+ auto ver = pre.get_version (lpName ? lpName : L"");
+ *pVerRet = VersionClassToStruct (ver);
+ return !ver.empty ();
+ } break;
+ }
+ return FALSE;
+}
diff --git a/pkgread/pkgread.h b/pkgread/pkgread.h
index f5d4df7..42c62a3 100644
--- a/pkgread/pkgread.h
+++ b/pkgread/pkgread.h
@@ -87,7 +87,7 @@ extern "C"
#define PKGROLE_APPLICATION 1
#define PKGROLE_FRAMEWORK 2
#define PKGROLE_RESOURCE 3
-// ȡ
+ // ȡ
PKGREAD_API HPKGREAD CreatePackageReader ();
// ͨȡ
PKGREAD_API BOOL LoadPackageFromFile (_In_ HPKGREAD hReader, _In_ LPCWSTR lpFilePath);
@@ -286,6 +286,155 @@ extern "C"
// ȡʾ internetClient Ӧ Internet ӡصӦϵͳԵı
// ע⣺صַһҪͨ free ͷš
PKGREAD_API LPWSTR GetPackageCapabilityDisplayName (LPCWSTR lpCapabilityName);
+ // ͷŴӱзصַ
+ // ʵͨ free ͷżɣǵ⣬ôд˸
+ PKGREAD_API void PackageReaderFreeString (LPWSTR lpStrFromThisDll);
+
+ // ========= Ӧ嵥ĶȡһЩ͵Ǹõ =========
+
+ TEMPLATE_STRUCT (PKGMANIFESTREAD);
+ typedef PKGMANIFESTREAD *HPKGMANIFESTREAD;
+ // Manifest ȡ
+ // һ Manifest Reader ʼ״̬δκļ
+ PKGREAD_API HPKGMANIFESTREAD CreateManifestReader ();
+ // ļ Manifest
+ // ֵ֧룺
+ // - AppxManifest.xml
+ // - .appx / .msix
+ // - .appxbundle / .msixbundle
+ // سɹȡԶʶ Manifest ͡
+ PKGREAD_API BOOL LoadManifestFromFile (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpFilePath);
+ // ļ Manifest
+ // ֵ֧룺
+ // - AppxManifest.xml
+ // - .appx / .msix
+ // - .appxbundle / .msixbundle
+ // سɹȡԶʶ Manifest ͡
+ PKGREAD_API BOOL LoadManifestFromFile (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpFilePath);
+ // Manifest ȡã
+ // ͷڲԴڴ֮ʹá
+ PKGREAD_API void DestroyManifestReader (_In_ HPKGMANIFESTREAD hReader);
+ // ȡ Manifest ͡
+ // ֵ
+ // - PKGTYPE_APPX һ Appx / Msix
+ // - PKGTYPE_BUNDLE AppxBundle / MsixBundle
+ // - PKGTYPE_UNKNOWN δ֪δ
+ PKGREAD_API WORD GetManifestType (_In_ HPKGMANIFESTREAD hReader);
+ // ȡ Manifest ͡
+ // ֵ
+ // - PKGTYPE_APPX һ Appx / Msix
+ // - PKGTYPE_BUNDLE AppxBundle / MsixBundle
+ // - PKGTYPE_UNKNOWN δ֪δ
+ PKGREAD_API WORD GetManifestType (_In_ HPKGMANIFESTREAD hReader);
+ // ж Manifest ǷЧ
+ // Manifest ʧܡṹǷδأ FALSE
+ PKGREAD_API BOOL IsManifestValid (_In_ HPKGMANIFESTREAD hReader);
+ // ȡ Manifest ʾĽɫ
+ // ֵ
+ // - PKGROLE_APPLICATION Ӧð
+ // - PKGROLE_FRAMEWORK ܰ
+ // - PKGROLE_RESOURCE Դ
+ // - PKGROLE_UNKNOWN δ֪
+ //
+ // ˵
+ // - AppxBundleԶ PKGROLE_APPLICATION
+ PKGREAD_API WORD GetManifestRole (_In_ HPKGMANIFESTREAD hReader);
+ // ȡ Identity ֶַΡ
+ // dwName ȡֵ
+ // - PKG_IDENTITY_NAME
+ // - PKG_IDENTITY_PUBLISHER
+ // - PKG_IDENTITY_PACKAGEFAMILYNAME
+ // - PKG_IDENTITY_PACKAGEFULLNAME
+ // - PKG_IDENTITY_RESOURCEID
+ //
+ // ֵ
+ // - ɹ·ַ߸ͷţ
+ // - ʧܣ NULL
+ PKGREAD_API LPWSTR GetManifestIdentityStringValue (_In_ HPKGMANIFESTREAD hReader, _In_ DWORD dwName);
+#define GetManifestIdentityName(_In_hReader_) GetManifestIdentityStringValue (_In_hReader_, PKG_IDENTITY_NAME)
+#define GetManifestIdentityPublisher(_In_hReader_) GetManifestIdentityStringValue (_In_hReader_, PKG_IDENTITY_PUBLISHER)
+#define GetManifestIdentityPackageFamilyName(_In_hReader_) GetManifestIdentityStringValue (_In_hReader_, PKG_IDENTITY_PACKAGEFAMILYNAME)
+#define GetManifestIdentityPackageFullName(_In_hReader_) GetManifestIdentityStringValue (_In_hReader_, PKG_IDENTITY_PACKAGEFULLNAME)
+#define GetManifestIdentityResourceId(_In_hReader_) GetManifestIdentityStringValue (_In_hReader_, PKG_IDENTITY_RESOURCEID)
+ // ȡ Identity İ汾š
+ //
+ // pVersion ظʽ VERSION ṹ
+ // ֵ
+ // - TRUE ɹ
+ // - FALSE ʧܻ汾
+ PKGREAD_API BOOL GetManifestIdentityVersion (_In_ HPKGMANIFESTREAD hReader, _Out_ VERSION *pVersion);
+ // ȡֵ֧ļܹϢ
+ // ڵһ Appx صһܹ
+ // BundleӰܹϣλ
+ //
+ // ֵͨ pdwArchi ȡֵΪ PKG_ARCHITECTURE_* ꡣ
+ PKGREAD_API BOOL GetManifestIdentityArchitecture (_In_ HPKGMANIFESTREAD hReader, _Out_ DWORD *pdwArchi);
+ // ȡ Properties еֵַ
+ // lpName Ϊ "DisplayName"
+ // ֵ
+ // - ɹ·ַ߸ͷţ
+ // - ʧܣ NULL
+ //
+ // ˵
+ // - ڵһ Appx
+ PKGREAD_API LPWSTR GetManifestPropertiesStringValue (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpName);
+ // ȡ Properties еIJֵ
+ //
+ // pRet ز
+ // HRESULTʧԭ
+ //
+ // ˵
+ // - ڵһ Appx
+ PKGREAD_API HRESULT GetManifestPropertiesBoolValue (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpName, _Outptr_ BOOL *pRet);
+ // ӦöҪȡ Application
+ // FALSE ʾǷظ
+ PKGREAD_API BOOL AddManifestApplicationItemGetName (_In_ LPCWSTR lpName);
+ // ӦöƳָ Application
+ PKGREAD_API BOOL RemoveManifestApplicationItemGetName (_In_ LPCWSTR lpName);
+ // ȡ Applications ö
+ // һӦöֶ١
+ //
+ // ˵
+ // - ڵһ Appx
+ PKGREAD_API HAPPENUMERATOR GetManifestApplications (_In_ HPKGMANIFESTREAD hReader);
+ // Applications ö
+ PKGREAD_API void DestroyManifestApplications (_In_ HAPPENUMERATOR hEnumerator);
+ // ȡԴֵ֧бַʽ
+ // HLIST_PVOIDڲԪΪ LPWSTR
+ PKGREAD_API HLIST_PVOID GetManifestResourcesLanguages (_In_ HPKGMANIFESTREAD hReader);
+ // ȡԴֵ֧бLCID ʽ
+ // HLIST_LCID
+ PKGREAD_API HLIST_LCID GetManifestResourcesLanguagesToLcid (_In_ HPKGMANIFESTREAD hReader);
+ // ȡԴֵ֧űScale
+ // HLIST_UINT32
+ PKGREAD_API HLIST_UINT32 GetManifestResourcesScales (_In_ HPKGMANIFESTREAD hReader);
+ // ȡԴֵ֧ DirectX Feature Level
+ // ֵΪ PKG_RESOURCES_DXFEATURE_LEVEL* λϡ
+ PKGREAD_API DWORD GetManifestResourcesDxFeatureLevels (_In_ HPKGMANIFESTREAD hReader);
+ // ȡϢб
+ // HLIST_DEPINFOаơͰ汾
+ //
+ // ˵
+ // - ڵһ Appx
+ PKGREAD_API HLIST_DEPINFO GetManifestDependencesInfoList (_In_ HPKGMANIFESTREAD hReader);
+ // ȡ Capability бCapability
+ // صбԪΪ LPWSTR
+ //
+ // ˵
+ // - ڵһ Appx
+ PKGREAD_API HLIST_PVOID GetManifestCapabilitiesList (_In_ HPKGMANIFESTREAD hReader);
+ // ȡ Device Capability б
+ // صбԪΪ LPWSTR
+ //
+ // ˵
+ // - ڵһ Appx
+ PKGREAD_API HLIST_PVOID GetManifestDeviceCapabilitiesList (_In_ HPKGMANIFESTREAD hReader);
+ // ȡָǰͰ汾Ҫ
+ // lpName Ϊǰơ
+ // pVerRet ذ汾ṹ
+ // TRUE ʾڸǰ
+ PKGREAD_API BOOL GetManifestPrerequisite (_In_ HPKGMANIFESTREAD hReader, _In_ LPCWSTR lpName, _Outptr_ VERSION *pVerRet);
+
#ifdef _DEFAULT_INIT_VALUE_
#undef _DEFAULT_INIT_VALUE_
#endif
diff --git a/pkgread/readobj.h b/pkgread/readobj.h
index fbb603a..813d0f0 100644
--- a/pkgread/readobj.h
+++ b/pkgread/readobj.h
@@ -1336,3 +1336,202 @@ class package
appxreader appx_reader () const { return appxreader (*(IAppxPackageReader **)&this->appx); }
bundlereader bundle_reader () const { return bundlereader (*(IAppxBundleReader **)&this->bundle); }
};
+
+class appxmanifest: virtual public com_info_quote
+{
+ using Base = com_info_quote ;
+ template HRESULT get (IComPtr iptr, Fn func, ReturnType *retvalue) const { if (!iptr) return E_FAIL; return (iptr->*func) (retvalue); }
+ using Manifest = IAppxManifestReader;
+ public:
+ using Base::Base;
+ Manifest *manifest () { return pointer (); }
+ template HRESULT get_from_manifest (Func fn, _Outptr_ IComPtr *output) const
+ {
+ if (!pointer ()) return E_FAIL;
+ return get (pointer (), fn, output);
+ }
+ HRESULT get_identity (_Outptr_ IAppxManifestPackageId **output) const { return get_from_manifest (&Manifest::GetPackageId, output); }
+ appx_info::appx_id identity () const
+ {
+ IAppxManifestPackageId *ip = nullptr;
+ get_identity (&ip);
+ return appx_info::appx_id (ip);
+ }
+ appx_info::appx_res resources () const
+ {
+ return appx_info::appx_res (pointer ());
+ }
+ HRESULT get_properties (_Outptr_ IAppxManifestProperties **output) const { return get_from_manifest (&Manifest::GetProperties, output); }
+ appx_info::appx_prop properties () const
+ {
+ IAppxManifestProperties *ip = nullptr;
+ HRESULT hr = get_properties (&ip);
+ return appx_info::appx_prop (ip);
+ }
+ appx_info::appx_preq prerequisites () const
+ {
+ return appx_info::appx_preq (pointer ());
+ }
+ HRESULT get_applications (_Outptr_ IAppxManifestApplicationsEnumerator **output) const { return get_from_manifest (&Manifest::GetApplications, output); }
+ appx_info::appx_apps applications () const
+ {
+ IAppxManifestApplicationsEnumerator *ip = nullptr;
+ get_applications (&ip);
+ return appx_info::appx_apps (ip);
+ }
+ HRESULT get_capabilities (_Outptr_ APPX_CAPABILITIES *output) const { return get_from_manifest (&Manifest::GetCapabilities, output); }
+ HRESULT get_device_capabilities (_Outptr_ IAppxManifestDeviceCapabilitiesEnumerator **output) const { return get_from_manifest (&Manifest::GetDeviceCapabilities, output); }
+ appx_info::appx_capabs capabilities () const
+ {
+ APPX_CAPABILITIES caps;
+ IAppxManifestDeviceCapabilitiesEnumerator *ip = nullptr;
+ if (pointer ()) pointer ()->GetDeviceCapabilities (&ip);
+ auto im = pointer ();
+ if (SUCCEEDED (get_capabilities (&caps))) return appx_info::appx_capabs (ip, caps, im);
+ return appx_info::appx_capabs (ip);
+ }
+ HRESULT get_dependencies (_Outptr_ IAppxManifestPackageDependenciesEnumerator **output) const { return get_from_manifest (&Manifest::GetPackageDependencies, output); }
+ appx_info::appx_deps dependencies () const
+ {
+ IAppxManifestPackageDependenciesEnumerator *ip = nullptr;
+ get_dependencies (&ip);
+ return appx_info::appx_deps (ip);
+ }
+ PackageRole package_role () const
+ {
+ auto prop = properties ();
+ if (prop.framework ()) return PackageRole::framework;
+ try { if (prop.resource_package ()) return PackageRole::resource; }
+ catch (const std::exception &e) {}
+ auto app = applications ();
+ std::vector apps;
+ if (app.app_user_model_ids (apps)) return PackageRole::application;
+ else return PackageRole::unknown;
+ }
+};
+class bundlemanifest: virtual public com_info_quote
+{
+ using Base = com_info_quote ;
+ public:
+ using Base::Base;
+ template HRESULT get (IComPtr iptr, Fn func, ReturnType *retvalue) const { if (!iptr) return E_FAIL; return (iptr->*func) (retvalue); }
+ using Manifest = IAppxBundleManifestReader;
+ Manifest *manifest () { return pointer (); }
+ template HRESULT get_from_manifest (Func fn, _Outptr_ IComPtr *output) const
+ {
+ if (!pointer ()) return E_FAIL;
+ return get (pointer (), fn, output);
+ }
+ HRESULT get_identity (_Outptr_ IAppxManifestPackageId **output) const { return get_from_manifest (&Manifest::GetPackageId, output); }
+ appx_info::appx_id identity () const
+ {
+ IAppxManifestPackageId *ip = nullptr;
+ get_identity (&ip);
+ return appx_info::appx_id (ip);
+ }
+ HRESULT get_package_id_items (_Outptr_ IAppxBundleManifestPackageInfoEnumerator **output) const { return get_from_manifest (&Manifest::GetPackageInfoItems, output); }
+ appx_info::appx_iditems package_id_items () const
+ {
+ IAppxBundleManifestPackageInfoEnumerator *ip = nullptr;
+ get_package_id_items (&ip);
+ return appx_info::appx_iditems (ip);
+ }
+};
+
+HRESULT GetAppxManifestReader (_In_ LPCWSTR inputPath, _Outptr_ IAppxManifestReader **manifestReader)
+{
+ if (!manifestReader) return E_POINTER;
+ *manifestReader = nullptr;
+ HRESULT hr;
+ CComPtr stream;
+ CComPtr factory;
+ CComPtr packageReader;
+ hr = SHCreateStreamOnFileEx (
+ inputPath,
+ STGM_READ | STGM_SHARE_DENY_NONE,
+ FILE_ATTRIBUTE_NORMAL,
+ FALSE,
+ nullptr,
+ &stream
+ );
+ if (FAILED (hr)) return hr;
+ hr = CoCreateInstance (
+ __uuidof (AppxFactory),
+ nullptr,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARGS (&factory)
+ );
+ if (FAILED (hr)) return hr;
+ hr = factory->CreatePackageReader (stream, &packageReader);
+ if (SUCCEEDED (hr))
+ {
+ return packageReader->GetManifest (manifestReader);
+ }
+ hr = factory->CreateManifestReader (stream, manifestReader);
+ return hr;
+}
+HRESULT GetBundleManifestReader (_In_ LPCWSTR bundlePath, _Outptr_ IAppxBundleManifestReader **manifestReader)
+{
+ if (!manifestReader) return E_POINTER;
+ *manifestReader = nullptr;
+ HRESULT hr;
+ CComPtr stream;
+ CComPtr factory;
+ CComPtr bundleReader;
+ hr = SHCreateStreamOnFileEx (
+ bundlePath,
+ STGM_READ | STGM_SHARE_DENY_NONE,
+ FILE_ATTRIBUTE_NORMAL,
+ FALSE,
+ nullptr,
+ &stream
+ );
+ if (FAILED (hr)) return hr;
+ hr = CoCreateInstance (
+ __uuidof(AppxBundleFactory),
+ nullptr,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARGS (&factory)
+ );
+ if (FAILED (hr)) return hr;
+ hr = factory->CreateBundleReader (stream, &bundleReader);
+ if (FAILED (hr)) return hr;
+ hr = bundleReader->GetManifest (manifestReader);
+ if (FAILED (hr)) return hr = factory->CreateBundleManifestReader (stream, manifestReader);
+ return hr;
+}
+
+class manifest
+{
+ IAppxManifestReader *appx = nullptr;
+ IAppxBundleManifestReader *bundle = nullptr;
+ public:
+ ~manifest () { destroy (); }
+ manifest (const std::wstring &filepath = L"") { create (filepath); }
+ void destroy ()
+ {
+ if (appx) { appx->Release (); appx = nullptr; }
+ if (bundle) { bundle->Release (); bundle = nullptr; }
+ }
+ bool create (const std::wstring &filepath)
+ {
+ destroy ();
+ if (!IsFileExists (filepath)) return false;
+ HRESULT hr = GetBundleManifestReader (filepath.c_str (), &bundle);
+ if (SUCCEEDED (hr)) return true;
+ if (bundle) { bundle->Release (); bundle = nullptr; }
+ hr = GetAppxManifestReader (filepath.c_str (), &appx);
+ if (SUCCEEDED (hr)) return true;
+ if (appx) { appx->Release (); appx = nullptr; }
+ return false;
+ }
+ bool valid () const { return (bool)appx ^ (bool)bundle; }
+ PackageType type () const
+ {
+ if (appx) return PackageType::single;
+ if (bundle) return PackageType::bundle;
+ return PackageType::unknown;
+ }
+ appxmanifest appx_reader () const { return appxmanifest (*(IAppxManifestReader **)&this->appx); }
+ bundlemanifest bundle_reader () const { return bundlemanifest (*(IAppxBundleManifestReader **)&this->bundle); }
+};
\ No newline at end of file
diff --git a/priformatcli/priformatcli.cpp b/priformatcli/priformatcli.cpp
index 8d21bfd..6407810 100644
--- a/priformatcli/priformatcli.cpp
+++ b/priformatcli/priformatcli.cpp
@@ -915,4 +915,10 @@ BOOL IsMsResourceUri (LPCWSTR pResUri)
try { Uri ^uri = gcnew Uri (gcnew String (pResUri ? pResUri : L"")); delete uri; }
catch (Exception ^e) { return false; }
return true;
+}
+
+void PriFormatFreeString (LPWSTR lpStrFromThisDll)
+{
+ if (!lpStrFromThisDll) return;
+ free (lpStrFromThisDll);
}
\ No newline at end of file
diff --git a/priformatcli/priformatcli.h b/priformatcli/priformatcli.h
index d69ca90..6a6b5b5 100644
--- a/priformatcli/priformatcli.h
+++ b/priformatcli/priformatcli.h
@@ -73,6 +73,8 @@ extern "C" {
PRIFORMATCLI_API BOOL IsMsResourceUriFull (LPCWSTR pResUri);
// ߺжǷΪ MS-Resource URI
PRIFORMATCLI_API BOOL IsMsResourceUri (LPCWSTR pResUri);
+ // ߺͷű DLL صַ
+ PRIFORMATCLI_API void PriFormatFreeString (LPWSTR lpStrFromThisDll);
#ifdef _DEFAULT_VALUE_SET
#undef _DEFAULT_VALUE_SET
#endif
diff --git a/priread/ReadMe.txt b/priread/ReadMe.txt
deleted file mode 100644
index 98d5062..0000000
--- a/priread/ReadMe.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-========================================================================
- 动态链接库:priread 项目概述
-========================================================================
-
-应用程序向导已为您创建了此 priread DLL。
-
-本文件概要介绍组成 priread 应用程序的每个文件的内容。
-
-
-priread.vcxproj
- 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
-
-priread.vcxproj.filters
- 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
-
-priread.cpp
- 这是主 DLL 源文件。
-
-/////////////////////////////////////////////////////////////////////////////
-其他标准文件:
-
-StdAfx.h, StdAfx.cpp
- 这些文件用于生成名为 priread.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
-
-/////////////////////////////////////////////////////////////////////////////
-其他注释:
-
-应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/priread/dllmain.cpp b/priread/dllmain.cpp
deleted file mode 100644
index 260abc6..0000000
--- a/priread/dllmain.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// dllmain.cpp : DLL Ӧóڵ㡣
-#include "stdafx.h"
-
-BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
-{
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
-}
-
diff --git a/priread/localeex.h b/priread/localeex.h
deleted file mode 100644
index b528d56..0000000
--- a/priread/localeex.h
+++ /dev/null
@@ -1,163 +0,0 @@
-#pragma once
-#include
-#include
-static std::wstring StringToWString (const std::string &str, UINT codePage = CP_ACP)
-{
- if (str.empty ()) return std::wstring ();
- int len = MultiByteToWideChar (codePage, 0, str.c_str (), -1, nullptr, 0);
- if (len == 0) return std::wstring ();
- std::wstring wstr (len - 1, L'\0');
- MultiByteToWideChar (codePage, 0, str.c_str (), -1, &wstr [0], len);
- return wstr;
-}
-
-#undef GetLocaleInfo
-std::string GetLocaleInfoA (LCID code, LCTYPE type)
-{
- char buf [LOCALE_NAME_MAX_LENGTH] = {0};
- GetLocaleInfoA (code, type, buf, LOCALE_NAME_MAX_LENGTH);
- return buf;
-}
-std::wstring GetLocaleInfoW (LCID code, LCTYPE type)
-{
- WCHAR buf [LOCALE_NAME_MAX_LENGTH] = {0};
- GetLocaleInfoW (code, type, buf, LOCALE_NAME_MAX_LENGTH);
- return buf;
-}
-void GetLocaleInfo (LCID code, LCTYPE type, std::wstring &output)
-{
- output = GetLocaleInfoW (code, type);
-}
-void GetLocaleInfo (LCID code, LCTYPE type, std::string &output)
-{
- output = GetLocaleInfoA (code, type);
-}
-int GetLocaleInfoEx (std::wstring lpLocaleName, LCTYPE type, std::wstring &output)
-{
- WCHAR buf [LOCALE_NAME_MAX_LENGTH] = {0};
- int res = GetLocaleInfoEx (lpLocaleName.c_str (), type, buf, LOCALE_NAME_MAX_LENGTH);
- if (&output) output = std::wstring (buf);
- return res;
-}
-
-#undef SetLocaleInfo
-BOOL SetLocaleInfoA (LCID code, LCTYPE type, const std::string &lcData)
-{
- return SetLocaleInfoA (code, type, lcData.c_str ());
-}
-BOOL SetLocaleInfoW (LCID code, LCTYPE type, const std::wstring &lcData)
-{
- return SetLocaleInfoW (code, type, lcData.c_str ());
-}
-BOOL SetLocaleInfo (LCID code, LCTYPE type, const std::wstring &lcData)
-{
- return SetLocaleInfoW (code, type, lcData);
-}
-BOOL SetLocaleInfo (LCID code, LCTYPE type, const std::string &lcData)
-{
- return SetLocaleInfoA (code, type, lcData);
-}
-
-std::string GetLocaleRestrictedCodeFromLcidA (LCID lcid)
-{
- return GetLocaleInfoA (lcid, 89);
-}
-std::wstring GetLocaleRestrictedCodeFromLcidW (LCID lcid)
-{
- return GetLocaleInfoW (lcid, 89);
-}
-void GetLocaleRestrictedCodeFromLcid (LCID lcid, std::string &ret)
-{
- ret = GetLocaleRestrictedCodeFromLcidA (lcid);
-}
-void GetLocaleRestrictedCodeFromLcid (LCID lcid, std::wstring &ret)
-{
- ret = GetLocaleRestrictedCodeFromLcidW (lcid);
-}
-
-std::string GetLocaleElaboratedCodeFromLcidA (LCID lcid)
-{
- return GetLocaleInfoA (lcid, 90);
-}
-std::wstring GetLocaleElaboratedCodeFromLcidW (LCID lcid)
-{
- return GetLocaleInfoW (lcid, 90);
-}
-void GetLocaleElaboratedCodeFromLcid (LCID lcid, std::wstring &ret)
-{
- ret = GetLocaleElaboratedCodeFromLcidW (lcid);
-}
-void GetLocaleElaboratedCodeFromLcid (LCID lcid, std::string &ret)
-{
- ret = GetLocaleElaboratedCodeFromLcidA (lcid);
-}
-
-LCID LocaleCodeToLcidW (LPCWSTR localeCode)
-{
- BYTE buf [LOCALE_NAME_MAX_LENGTH * sizeof (WCHAR)] = {0};
- int res = GetLocaleInfoEx (localeCode, LOCALE_RETURN_NUMBER | LOCALE_ILANGUAGE, (LPWSTR)buf, LOCALE_NAME_MAX_LENGTH);
- LCID lcid = *((LCID *)buf);
- return lcid;
-}
-LCID LocaleCodeToLcidA (LPCSTR localeCode)
-{
- std::wstring lcWide = StringToWString (std::string (localeCode));
- return LocaleCodeToLcidW (lcWide.c_str ());
-}
-LCID LocaleCodeToLcid (const std::wstring &loccode)
-{
- return LocaleCodeToLcidW (loccode.c_str ());
-}
-LCID LocaleCodeToLcid (const std::string &loccode)
-{
- return LocaleCodeToLcidA (loccode.c_str ());
-}
-
-std::string GetLocaleRestrictedCodeA (LPCSTR lc)
-{
- return GetLocaleInfoA (LocaleCodeToLcidA (lc), 89);
-}
-std::string GetLocaleRestrictedCodeA (const std::string &lc)
-{
- return GetLocaleInfoA (LocaleCodeToLcidA (lc.c_str ()), 89);
-}
-std::wstring GetLocaleRestrictedCodeW (LPCWSTR lc)
-{
- return GetLocaleInfoW (LocaleCodeToLcidW (lc), 89);
-}
-std::wstring GetLocaleRestrictedCodeW (const std::wstring &lc)
-{
- return GetLocaleInfoW (LocaleCodeToLcidW (lc.c_str ()), 89);
-}
-std::wstring GetLocaleRestrictedCode (const std::wstring &lc) { return GetLocaleRestrictedCodeW (lc); }
-std::string GetLocaleRestrictedCode (const std::string &lc) { return GetLocaleRestrictedCodeA (lc); }
-
-std::string GetLocaleElaboratedCodeA (LPCSTR lc)
-{
- return GetLocaleInfoA (LocaleCodeToLcidA (lc), 90);
-}
-std::string GetLocaleElaboratedCodeA (const std::string &lc)
-{
- return GetLocaleInfoA (LocaleCodeToLcidA (lc.c_str ()), 90);
-}
-std::wstring GetLocaleElaboratedCodeW (LPCWSTR lc)
-{
- return GetLocaleInfoW (LocaleCodeToLcidW (lc), 90);
-}
-std::wstring GetLocaleElaboratedCodeW (const std::wstring &lc)
-{
- return GetLocaleInfoW (LocaleCodeToLcidW (lc.c_str ()), 90);
-}
-std::wstring GetLocaleElaboratedCode (const std::wstring &lc) { return GetLocaleElaboratedCodeW (lc); }
-std::string GetLocaleElaboratedCode (const std::string &lc) { return GetLocaleElaboratedCodeA (lc); }
-
-std::string LcidToLocaleCodeA (LCID lcid, char divide = '-')
-{
- return GetLocaleRestrictedCodeFromLcidA (lcid) + divide + GetLocaleElaboratedCodeFromLcidA (lcid);
-}
-std::wstring LcidToLocaleCodeW (LCID lcid, WCHAR divide = L'-')
-{
- return GetLocaleRestrictedCodeFromLcidW (lcid) + divide + GetLocaleElaboratedCodeFromLcidW (lcid);
-}
-std::wstring LcidToLocaleCode (LCID lcid, WCHAR divide = L'-') { return LcidToLocaleCodeW (lcid, divide); }
-std::string LcidToLocaleCode (LCID lcid, char divide = '-') { return LcidToLocaleCodeA (lcid, divide); }
\ No newline at end of file
diff --git a/priread/nstring.h b/priread/nstring.h
deleted file mode 100644
index ba0e231..0000000
--- a/priread/nstring.h
+++ /dev/null
@@ -1,456 +0,0 @@
-#pragma once
-#include
-#include
-#include
-namespace l0km
-{
- template , typename AL = std::allocator > inline std::basic_string toupper (const std::basic_string &src)
- {
- std::basic_string dst = src;
- static const std::locale loc;
- const std::ctype &ctype = std::use_facet > (loc);
- for (typename std::basic_string ::size_type i = 0; i < src.size (); ++ i)
- {
- dst [i] = ctype.toupper (src [i]);
- }
- return dst;
- }
- template , typename AL = std::allocator > inline std::basic_string tolower (const std::basic_string &src)
- {
- std::basic_string dst = src;
- static const std::locale loc;
- const std::ctype &ctype = std::use_facet > (loc);
- for (typename std::basic_string ::size_type i = 0; i < src.size (); ++ i)
- {
- dst [i] = ctype.tolower (src [i]);
- }
- return dst;
- }
- inline char toupper (char ch)
- {
- if (ch < -1) return ch;
- static const std::locale loc;
- return std::use_facet > (loc).toupper (ch);
- }
- inline char tolower (char ch)
- {
- if (ch < -1) return ch;
- static const std::locale loc;
- return std::use_facet > (loc).tolower (ch);
- }
- inline wchar_t toupper (wchar_t ch)
- {
- if (ch < -1) return ch;
- static const std::locale loc;
- return std::use_facet > (loc).toupper (ch);
- }
- inline wchar_t tolower (wchar_t ch)
- {
- if (ch < -1) return ch;
- static const std::locale loc;
- return std::use_facet > (loc).tolower (ch);
- }
- inline int toupper (int ch)
- {
- if (ch < -1) return ch;
- static const std::locale loc;
- return std::use_facet > (loc).toupper (ch);
- }
- inline int tolower (int ch)
- {
- if (ch < -1) return ch;
- static const std::locale loc;
- return std::use_facet > (loc).tolower (ch);
- }
-}
-template bool is_blank (ct &ch)
-{
- return ch == ct (' ') || ch == ct ('\t') || ch == ct ('\n');
-}
-template , typename AL = std::allocator > std::basic_string NormalizeString (const std::basic_string &str, bool upper = false, bool includemidblank = false)
-{
- typedef std::basic_string string_type;
- string_type result;
- if (str.empty ()) return result;
- auto begin_it = str.begin ();
- auto end_it = str.end ();
- while (begin_it != end_it && is_blank (*begin_it)) ++begin_it;
- while (end_it != begin_it && is_blank (*(end_it - 1))) --end_it;
- bool in_space = false;
- for (auto it = begin_it; it != end_it; ++ it)
- {
- if (is_blank (*it))
- {
- if (includemidblank)
- {
- if (!in_space)
- {
- result.push_back (E (' '));
- in_space = true;
- }
- }
- else
- {
- result.push_back (*it);
- in_space = true;
- }
- }
- else
- {
- result.push_back (*it);
- in_space = false;
- }
- }
- if (upper) return l0km::toupper (result);
- else return l0km::tolower (result);
-}
-template , typename AL = std::allocator > bool IsNormalizeStringEquals (const std::basic_string &l, const std::basic_string &r, bool includemidblank = false)
-{
- auto _local_strlen = [] (const E *p) -> size_t {
- size_t cnt = 0;
- while (*(p + cnt)) { cnt ++; }
- return cnt;
- };
- const E *pl = l.c_str ();
- const E *pr = r.c_str ();
- while (*pl && is_blank (*pl)) ++ pl;
- while (*pr && is_blank (*pr)) ++ pr;
- const E *el = l.c_str () + _local_strlen (l.c_str ());
- const E *er = r.c_str () + _local_strlen (r.c_str ());
- while (el > pl && is_blank (*(el - 1))) --el;
- while (er > pr && is_blank (*(er - 1))) --er;
- while (pl < el && pr < er)
- {
- if (includemidblank)
- {
- if (is_blank (*pl) && is_blank (*pr))
- {
- while (pl < el && is_blank (*pl)) ++pl;
- while (pr < er && is_blank (*pr)) ++pr;
- continue;
- }
- else if (is_blank (*pl))
- {
- while (pl < el && is_blank (*pl)) ++pl;
- continue;
- }
- else if (is_blank (*pr))
- {
- while (pr < er && is_blank (*pr)) ++pr;
- continue;
- }
- }
- if (l0km::tolower (*pl) != l0km::tolower (*pr)) return false;
- ++ pl;
- ++ pr;
- }
- while (pl < el && is_blank (*pl)) ++ pl;
- while (pr < er && is_blank (*pr)) ++ pr;
- return pl == el && pr == er;
-}
-template , typename AL = std::allocator > int64_t NormalizeStringCompare (const std::basic_string &l, const std::basic_string &r, bool includemidblank = false)
-{
- auto _local_strlen = [] (const E *p) -> size_t {
- size_t cnt = 0;
- while (*(p + cnt)) { cnt ++; }
- return cnt;
- };
- const E *pl = l.c_str ();
- const E *pr = r.c_str ();
- while (*pl && is_blank (*pl)) ++ pl;
- while (*pr && is_blank (*pr)) ++ pr;
- const E *el = l.c_str () + _local_strlen (l.c_str ());
- const E *er = r.c_str () + _local_strlen (r.c_str ());
- while (el > pl && is_blank (*(el - 1))) -- el;
- while (er > pr && is_blank (*(er - 1))) -- er;
- while (pl < el && pr < er)
- {
- if (includemidblank)
- {
- if (is_blank (*pl) && is_blank (*pr))
- {
- while (pl < el && is_blank (*pl)) ++pl;
- while (pr < er && is_blank (*pr)) ++pr;
- continue;
- }
- else if (is_blank (*pl))
- {
- while (pl < el && is_blank (*pl)) ++pl;
- continue;
- }
- else if (is_blank (*pr))
- {
- while (pr < er && is_blank (*pr)) ++pr;
- continue;
- }
- }
- E chl = l0km::tolower (*pl);
- E chr = l0km::tolower (*pr);
- if (chl != chr) return (int64_t)chl - (int64_t)chr;
- ++ pl;
- ++ pr;
- }
- while (pl < el && is_blank (*pl)) ++ pl;
- while (pr < er && is_blank (*pr)) ++ pr;
- if (pl == el && pr == er) return 0;
- if (pl == el) return -1;
- if (pr == er) return 1;
- return (int64_t)l0km::tolower (*pl) - (int64_t)l0km::tolower (*pr);
-}
-template bool IsNormalizeStringEquals (const CharT *l, const CharT *r, bool includemidblank = false)
-{
- if (!l || !r) return l == r;
- auto skip_blank = [] (const CharT *&p)
- {
- while (*p && is_blank (*p)) ++ p;
- };
- const CharT *p1 = l;
- const CharT *p2 = r;
- skip_blank (p1);
- skip_blank (p2);
- while (*p1 && *p2)
- {
- CharT ch1 = l0km::tolower (*p1);
- CharT ch2 = l0km::tolower (*p2);
- if (ch1 != ch2) return false;
- ++ p1;
- ++ p2;
- if (includemidblank)
- {
- if (is_blank (*p1) || is_blank (*p2))
- {
- skip_blank (p1);
- skip_blank (p2);
- }
- }
- }
- skip_blank (p1);
- skip_blank (p2);
- return *p1 == 0 && *p2 == 0;
-}
-template int64_t NormalizeStringCompare (const CharT *l, const CharT *r, bool includemidblank = false)
-{
- if (!l || !r) return l ? 1 : (r ? -1 : 0);
- auto skip_blank = [] (const CharT *&p)
- {
- while (*p && is_blank (*p)) ++ p;
- };
- const CharT *p1 = l;
- const CharT *p2 = r;
- skip_blank (p1);
- skip_blank (p2);
- while (*p1 && *p2)
- {
- CharT ch1 = l0km::tolower (*p1);
- CharT ch2 = l0km::tolower (*p2);
- if (ch1 != ch2) return (ch1 < ch2) ? -1 : 1;
- ++ p1;
- ++ p2;
- if (includemidblank)
- {
- if (is_blank (*p1) || is_blank (*p2))
- {
- skip_blank (p1);
- skip_blank (p2);
- }
- }
- }
- skip_blank (p1);
- skip_blank (p2);
- if (*p1 == 0 && *p2 == 0) return 0;
- if (*p1 == 0) return -1;
- return 1;
-}
-template , typename AL = std::allocator > bool IsNormalizeStringEmpty (const std::basic_string &str)
-{
- return IsNormalizeStringEquals (str, std::basic_string ());
-}
-template , typename AL = std::allocator > std::basic_string StringTrim (const std::basic_string &str, bool includemidblank = false)
-{
- typedef std::basic_string string_type;
- typedef typename string_type::size_type size_type;
- if (str.empty ()) return string_type ();
- size_type first = 0;
- size_type last = str.size ();
- while (first < last && is_blank (str [first])) ++first;
- while (last > first && is_blank (str [last - 1])) --last;
- if (first == last) return string_type ();
- string_type result;
- result.reserve (last - first);
- bool in_space = false;
- for (size_type i = first; i < last; ++ i)
- {
- if (is_blank (str [i]))
- {
- if (includemidblank)
- {
- if (!in_space)
- {
- result.push_back (E (' '));
- in_space = true;
- }
- }
- else
- {
- result.push_back (str [i]);
- in_space = true;
- }
- }
- else
- {
- result.push_back (str [i]);
- in_space = false;
- }
- }
- return result;
-}
-template , typename AL = std::allocator > size_t GetNormalizeStringLength (const std::basic_string &str, bool includemidblank = false)
-{
- typedef typename std::basic_string ::size_type size_type;
- if (str.empty ()) return 0;
- size_type first = 0, last = str.size ();
- while (first < last && is_blank (str [first])) ++first;
- while (last > first && is_blank (str [last - 1])) --last;
- if (first == last) return 0;
- size_t length = 0;
- bool in_space = false;
- for (size_type i = first; i < last; ++i)
- {
- if (is_blank (str [i]))
- {
- if (includemidblank)
- {
- if (!in_space)
- {
- ++ length;
- in_space = true;
- }
- }
- else
- {
- ++ length;
- in_space = true;
- }
- }
- else
- {
- ++ length;
- in_space = false;
- }
- }
- return length;
-}
-namespace std
-{
-
- template , typename al = std::allocator > class basic_nstring: public std::basic_string
- {
- using base = std::basic_string ;
- bool default_upper = false, default_include_blank_in_str = false;
- public:
- using typename base::size_type;
- using typename base::value_type;
- using base::base;
- basic_nstring (): base (), default_upper (false), default_include_blank_in_str (false) {}
- basic_nstring (const ct *pStr): base (pStr), default_upper (false), default_include_blank_in_str (false) {}
- basic_nstring (const base &str): base (str) {}
- basic_nstring (base &&str): base (std::move (str)) {}
- basic_nstring (const ct *data, size_type count): base (data, count), default_upper (false), default_include_blank_in_str (false) {}
- template basic_nstring (const ct (&arr) [N]) : base (arr, N) {}
- template basic_nstring (InputIt first, InputIt last): base (first, last), default_upper (false), default_include_blank_in_str (false) {}
- bool upper_default () const { return this->default_upper; }
- bool upper_default (bool value) { return this->default_upper = value; }
- bool include_blank_in_str_middle () const { return this->default_include_blank_in_str; }
- bool include_blank_in_str_middle (bool value) { return this->default_include_blank_in_str = value; }
- base normalize (bool upper, bool includemidblank) const
- {
- return NormalizeString (*this, upper, includemidblank);
- }
- base normalize (bool upper) const
- {
- return this->normalize (upper, default_include_blank_in_str);
- }
- base normalize () const { return this->normalize (default_upper); }
- base upper (bool includemidblank) const
- {
- return NormalizeString (*this, true, includemidblank);
- }
- base upper () const { return this->upper (default_include_blank_in_str); }
- base lower (bool includemidblank) const
- {
- return NormalizeString (*this, false, includemidblank);
- }
- base lower () const { return this->lower (default_include_blank_in_str); }
- base trim (bool includemidblank) const
- {
- return StringTrim (*this, includemidblank);
- }
- base trim () const { return this->trim (default_include_blank_in_str); }
- size_t length (bool includemidblank) const { return GetNormalizeStringLength (*this, includemidblank); }
- size_t length () const { return length (default_include_blank_in_str); }
- bool empty () const
- {
- return IsNormalizeStringEmpty (*this);
- }
- bool equals (const base &another, bool includemidblank) const
- {
- return IsNormalizeStringEquals (*this, another, includemidblank);
- }
- bool equals (const base &another) const { return equals (another, default_include_blank_in_str); }
- int64_t compare (const base &another, bool includemidblank) const
- {
- return NormalizeStringCompare (*this, another, includemidblank);
- }
- int64_t compare (const base &another) const { return compare (another, default_include_blank_in_str); }
- base &string () { return *this; }
- base to_string (bool upper, bool includemidblank) const { return this->normalize (upper, includemidblank); }
- base to_string (bool upper) const { return this->normalize (upper, default_include_blank_in_str); }
- base to_string () const { return this->normalize (default_upper); }
- bool operator == (const base &other) const { return equals (other, false); }
- bool operator != (const base &other) const { return !equals (other, false); }
- bool operator < (const base &other) const { return compare (other, false) < 0; }
- bool operator > (const base &other) const { return compare (other, false) > 0; }
- bool operator <= (const base &other) const { return compare (other, false) <= 0; }
- bool operator >= (const base &other) const { return compare (other, false) >= 0; }
- int64_t operator - (const base &other) const { return compare (other, false); }
- template , typename AL = std::allocator >
- static bool equals (const std::basic_string &l, const std::basic_string &r, bool remove_mid_blank = false)
- {
- return IsNormalizeStringEquals (l, r, remove_mid_blank);
- }
- template , typename AL = std::allocator >
- static int64_t compare (const std::basic_string &l, const std::basic_string &r, bool remove_mid_blank = false)
- {
- return NormalizeStringCompare (l, r, remove_mid_blank);
- }
- template , typename AL = std::allocator >
- static std::basic_string normalize (const std::basic_string &str, bool to_upper = false, bool remove_mid_blank = false)
- {
- return NormalizeString (str, to_upper, remove_mid_blank);
- }
- template , typename AL = std::allocator >
- static std::basic_string trim (const std::basic_string &str, bool remove_mid_blank = false)
- {
- return StringTrim (str, remove_mid_blank);
- }
- template , typename AL = std::allocator >
- static size_t length (const std::basic_string &str, bool remove_mid_blank = false)
- {
- return GetNormalizeStringLength (str, remove_mid_blank);
- }
- template , typename AL = std::allocator >
- static bool empty (const std::basic_string &str)
- {
- return IsNormalizeStringEmpty (str);
- }
- template , typename AL = std::allocator >
- static std::basic_nstring to_nstring (std::basic_string &str) { return std::basic_nstring (str); }
- template , typename AL = std::allocator >
- static std::basic_nstring toupper (const std::basic_nstring &str) { return l0km::toupper (str); }
- template , typename AL = std::allocator >
- static std::basic_nstring tolower (const std::basic_nstring &str) { return l0km::tolower (str); }
- };
-
- typedef basic_nstring nstring;
- typedef basic_nstring wnstring;
-}
\ No newline at end of file
diff --git a/priread/prifile.h b/priread/prifile.h
deleted file mode 100644
index 273703c..0000000
--- a/priread/prifile.h
+++ /dev/null
@@ -1,2671 +0,0 @@
-#pragma once
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include