daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Decompiled with JetBrains decompiler
  2. // Type: InstallApp
  3. // Assembly: InstallApp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: 185D0616-37A2-4BA1-8E54-2BF5912D1D2D
  5. // Assembly location: C:\Users\Ballads\Desktop\zztop\Microsoft.MinecraftUWP_8wekyb3d8bbwe\InstallApp.exe
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Reflection;
  11. using System.Security.Cryptography;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Xml;
  15. using Windows.Foundation;
  16. using Windows.Management.Deployment;
  17.  
  18. internal class InstallApp
  19. {
  20.   public static string userhash;
  21.  
  22.   public static string CreateMD5(string input)
  23.   {
  24.     using (MD5 md5 = MD5.Create())
  25.     {
  26.       byte[] bytes = Encoding.Unicode.GetBytes(input);
  27.       byte[] hash = md5.ComputeHash(bytes);
  28.       StringBuilder stringBuilder = new StringBuilder();
  29.       for (int index = 0; index < 5; ++index)
  30.         stringBuilder.Append(hash[index].ToString("x2"));
  31.       return stringBuilder.ToString();
  32.     }
  33.   }
  34.  
  35.   public static void InstallOptionalDeps(PackageManager pm)
  36.   {
  37.     List<Exception> exceptionList = new List<Exception>();
  38.     bool flag = true;
  39.     Console.Write("Registering any existing DLC packages...");
  40.     foreach (string directory in Directory.GetDirectories(".."))
  41.     {
  42.       if (!(Path.GetFileName(directory) == "AppFiles"))
  43.       {
  44.         try
  45.         {
  46.           // ISSUE: object of a compiler-generated type is created
  47.           // ISSUE: variable of a compiler-generated type
  48.           InstallApp.\u003C\u003Ec__DisplayClass1 cDisplayClass1 = new InstallApp.\u003C\u003Ec__DisplayClass1();
  49.           XmlDocument xmlDocument = new XmlDocument();
  50.           xmlDocument.Load(directory + "\\AppxManifest.xml");
  51.           if (!xmlDocument.DocumentElement.SelectSingleNode("//*[local-name()='Identity']").Attributes["Name"].Value.EndsWith("." + InstallApp.userhash))
  52.           {
  53.             XmlAttribute attribute1 = xmlDocument.DocumentElement.SelectSingleNode("//*[local-name()='Identity']").Attributes["Name"];
  54.             attribute1.Value = attribute1.Value + "." + InstallApp.userhash;
  55.             XmlAttribute attribute2 = xmlDocument.DocumentElement.SelectSingleNode("//*[local-name()='MainPackageDependency']").Attributes["Name"];
  56.             attribute2.Value = attribute2.Value + "." + InstallApp.userhash;
  57.             xmlDocument.Save(directory + "\\AppxManifest.xml");
  58.           }
  59.           // ISSUE: reference to a compiler-generated field
  60.           cDisplayClass1.opCompletedEvent = new ManualResetEvent(false);
  61.           Uri uri = new Uri(Path.GetFullPath(directory + "\\AppxManifest.xml"));
  62.           if (!uri.IsAbsoluteUri)
  63.             throw new FormatException("Manifest path invalid?!");
  64.           IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> operationWithProgress = pm.RegisterPackageAsync(uri, (IEnumerable<Uri>) null, (DeploymentOptions) 2);
  65.           // ISSUE: method pointer
  66.           operationWithProgress.put_Completed(new AsyncOperationWithProgressCompletedHandler<DeploymentResult, DeploymentProgress>((object) cDisplayClass1, __methodptr(\u003CInstallOptionalDeps\u003Eb__0)));
  67.           if (((IAsyncInfo) operationWithProgress).get_Status() == 0)
  68.           {
  69.             // ISSUE: reference to a compiler-generated field
  70.             cDisplayClass1.opCompletedEvent.WaitOne();
  71.           }
  72.           if (((IAsyncInfo) operationWithProgress).get_Status() == 3)
  73.             throw new Exception(operationWithProgress.GetResults().get_ErrorText());
  74.         }
  75.         catch (Exception ex)
  76.         {
  77.           flag = false;
  78.           exceptionList.Add(ex);
  79.         }
  80.       }
  81.     }
  82.     if (!flag)
  83.       throw new AggregateException("One or more DLC packages failed to register.", (IEnumerable<Exception>) exceptionList);
  84.     Console.ForegroundColor = ConsoleColor.Green;
  85.     Console.WriteLine("done!");
  86.     Console.ForegroundColor = ConsoleColor.Gray;
  87.   }
  88.  
  89.   public static void Main(string[] args)
  90.   {
  91.     Console.Write("Registering universal app...");
  92.     try
  93.     {
  94.       // ISSUE: object of a compiler-generated type is created
  95.       // ISSUE: variable of a compiler-generated type
  96.       InstallApp.\u003C\u003Ec__DisplayClass4 cDisplayClass4 = new InstallApp.\u003C\u003Ec__DisplayClass4();
  97.       PackageManager pm = new PackageManager();
  98.       XmlDocument xmlDocument1 = new XmlDocument();
  99.       xmlDocument1.Load("AppxManifest.xml");
  100.       string str = xmlDocument1.DocumentElement.SelectSingleNode("//*[local-name()='Identity']").Attributes["Name"].Value;
  101.       InstallApp.userhash = InstallApp.CreateMD5(Environment.UserName);
  102.       if (!str.EndsWith("." + InstallApp.userhash))
  103.       {
  104.         XmlAttribute attribute = xmlDocument1.DocumentElement.SelectSingleNode("//*[local-name()='Identity']").Attributes["Name"];
  105.         attribute.Value = attribute.Value + "." + InstallApp.userhash;
  106.         XmlDocument xmlDocument2 = new XmlDocument();
  107.         xmlDocument2.LoadXml("<rescap:Capability xmlns:rescap=\"http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities\" Name=\"packageQuery\"/>");
  108.         XmlNode xmlNode = xmlDocument1.DocumentElement.SelectSingleNode("//*[local-name()='Capabilities']");
  109.         XmlNode newChild = xmlNode.OwnerDocument.ImportNode((XmlNode) xmlDocument2.DocumentElement, true);
  110.         xmlNode.PrependChild(newChild);
  111.         xmlDocument1.Save("AppxManifest.xml");
  112.       }
  113.       // ISSUE: reference to a compiler-generated field
  114.       cDisplayClass4.opCompletedEvent = new ManualResetEvent(false);
  115.       Uri uri = new Uri(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\AppxManifest.xml");
  116.       if (!uri.IsAbsoluteUri)
  117.         throw new FormatException("The current path is somehow invalid?!");
  118.       IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> operationWithProgress = pm.RegisterPackageAsync(uri, (IEnumerable<Uri>) null, (DeploymentOptions) 2);
  119.       // ISSUE: method pointer
  120.       operationWithProgress.put_Completed(new AsyncOperationWithProgressCompletedHandler<DeploymentResult, DeploymentProgress>((object) cDisplayClass4, __methodptr(\u003CMain\u003Eb__3)));
  121.       if (((IAsyncInfo) operationWithProgress).get_Status() == 0)
  122.       {
  123.         // ISSUE: reference to a compiler-generated field
  124.         cDisplayClass4.opCompletedEvent.WaitOne();
  125.       }
  126.       if (((IAsyncInfo) operationWithProgress).get_Status() == 3)
  127.         throw new Exception(operationWithProgress.GetResults().get_ErrorText());
  128.       Console.ForegroundColor = ConsoleColor.Green;
  129.       Console.WriteLine("done!");
  130.       Console.ForegroundColor = ConsoleColor.Gray;
  131.       InstallApp.InstallOptionalDeps(pm);
  132.       Environment.Exit(0);
  133.     }
  134.     catch (Exception ex)
  135.     {
  136.       Console.ForegroundColor = ConsoleColor.Red;
  137.       Console.WriteLine("failed!");
  138.       Console.ForegroundColor = ConsoleColor.Gray;
  139.       Console.WriteLine(ex.ToString());
  140.       if (args.Length == 0)
  141.       {
  142.         Console.WriteLine("Press any key to continue . . . ");
  143.         Console.ReadKey();
  144.       }
  145.       Environment.Exit(-1);
  146.     }
  147.   }
  148. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top