// ------------------------------------------------------------------------
    /// <summary>
    /// Replaces the object.
    /// </summary>
    /// <param name='obj'>
    /// Object.
    /// </param>
    /// <param name='transition'>
    /// Transition.
    /// </param>
    /// <param name='wildcard'>
    /// Wildcard.
    /// </param>
    // ------------------------------------------------------------------------
    private void replaceObject( Transform obj, Transition transition, Wildcard wildcard )
    {
        if( wildcard.IsMatch( obj.name ) )
        {
            // we have to replace the object
            if( transition.Replacement == null )
            {
                DestroyImmediate( obj.gameObject, true );
            }
            else
            {
                Quaternion localRotation = Quaternion.identity;
                Vector3 localPosition = Vector3.zero;
                Vector3 localScale = Vector3.zero;

                switch( transition.TransformationType )
                {
                case 0: // source
                    {
                        localRotation = obj.localRotation;
                        localPosition = obj.localPosition;
                        localScale = obj.localScale;
                    }
                    break;
                case 1: // target
                    {
                        localRotation = transition.Replacement.transform.localRotation;
                        localPosition = transition.Replacement.transform.localPosition;
                        localScale = transition.Replacement.transform.localScale;
                    }
                    break;
                case 2: // combine
                    {
                        localRotation = transition.Replacement.transform.localRotation * obj.localRotation;
                        localPosition = obj.localRotation * transition.Replacement.transform.localPosition + obj.localPosition;
                        localScale = Vector3.Scale( transition.Replacement.transform.localScale, obj.localScale );
                    }
                    break;
                }

                Transform parent = obj.parent;
                DestroyImmediate( obj.gameObject, true );

                GameObject replacement = Instantiate( transition.Replacement ) as GameObject;
                replacement.name = transition.Replacement.name;
                replacement.transform.parent = parent;
                replacement.transform.localRotation = localRotation;
                replacement.transform.localPosition = localPosition;
                replacement.transform.localScale = localScale;
            }
        }
        else
        {
            // we have to use a separat list here because the internal child list might change while iterating
            List<Transform> children = new List<Transform>( obj.childCount );
            foreach( Transform child in obj )
                children.Add( child );

            foreach( Transform child in children )
                replaceObject( child, transition, wildcard );
        }
    }
    // ------------------------------------------------------------------------
    /// <summary>
    /// Recursive method adds objects to goList if their name matches the wildcard.
    /// </summary>
    /// <param name='obj'>
    /// The current object to check.
    /// </param>
    /// <param name='wildcard'>
    /// The wildcard used for matching.
    /// </param>
    /// <param name='goList'>
    /// Holds all matching object transform.
    /// </param>
    // ------------------------------------------------------------------------
    private void addObjectsToSet( Transform obj, Wildcard wildcard, HashSet<string> objectSet )
    {
        if( wildcard.IsMatch( obj.name ) )
            objectSet.Add( obj.name );

        foreach( Transform child in obj )
            addObjectsToSet( child, wildcard, objectSet );
    }
Beispiel #3
0
        public override void ExecuteCmdlet()
        {
            SecurityPrincipalInfoListResult response = null;
            ConsentStatusModel model = null;
            bool showAllUsers        = String.IsNullOrWhiteSpace(UserUpn);
            bool found = false;

            if (showAllUsers == false)
            {
                CreateWildcardPattern(UserUpn);
            }

            response = CallClient(() => Client.Principals.List(CollectionName), Client.Principals);

            if (response != null && response.SecurityPrincipalInfoList != null)
            {
                if (ExactMatch)
                {
                    SecurityPrincipalInfo userconsent = null;

                    userconsent = response.SecurityPrincipalInfoList.FirstOrDefault(user => user.SecurityPrincipal.SecurityPrincipalType == PrincipalType.User &&
                                                                                    String.Equals(user.SecurityPrincipal.Name, UserUpn, StringComparison.OrdinalIgnoreCase));

                    if (userconsent == null)
                    {
                        WriteErrorWithTimestamp("User: "******" does not exist in collection " + CollectionName);
                        found = false;
                    }
                    else
                    {
                        model = new ConsentStatusModel(userconsent);
                        WriteObject(model);
                        found = true;
                    }
                }
                else
                {
                    IEnumerable <SecurityPrincipalInfo> spList = null;

                    if (showAllUsers)
                    {
                        spList = response.SecurityPrincipalInfoList.Where(user => user.SecurityPrincipal.SecurityPrincipalType == PrincipalType.User);
                    }
                    else
                    {
                        spList = response.SecurityPrincipalInfoList.Where(user => user.SecurityPrincipal.SecurityPrincipalType == PrincipalType.User &&
                                                                          Wildcard.IsMatch(user.SecurityPrincipal.Name));
                    }

                    if (spList != null && spList.Count() > 0)
                    {
                        List <SecurityPrincipalInfo>      userConsents = new List <SecurityPrincipalInfo>(spList);
                        IComparer <SecurityPrincipalInfo> comparer     = new ServicePrincipalComparer();

                        userConsents.Sort(comparer);
                        foreach (SecurityPrincipalInfo consent in spList)
                        {
                            model = new ConsentStatusModel(consent);
                            WriteObject(model);
                        }
                        found = true;
                    }
                }
            }

            if (!found && !showAllUsers)
            {
                WriteVerboseWithTimestamp(String.Format("User '{0}' is not assigned to Collection '{1}'.", UserUpn, CollectionName));
            }
        }
Beispiel #4
0
        public override void ExecuteCmdlet()
        {
            GetStartMenuApplicationListResult result = null;
            bool getAllPrograms = false;
            bool found          = false;

            if (String.IsNullOrWhiteSpace(ProgramName))
            {
                getAllPrograms = true;
            }
            else
            {
                CreateWildcardPattern(ProgramName);
            }

            result = CallClient(() => Client.Publishing.StartMenuApplicationList(CollectionName), Client.Publishing);
            if (result != null && result.ResultList != null)
            {
                if (ExactMatch)
                {
                    StartMenuApplication application = null;
                    application = result.ResultList.FirstOrDefault(app => String.Equals(app.Name, ProgramName, StringComparison.InvariantCultureIgnoreCase));

                    if (application == null)
                    {
                        WriteErrorWithTimestamp("Program: " + ProgramName + " does not exist in collection " + CollectionName);
                        found = false;
                    }
                    else
                    {
                        WriteObject(application);
                        found = true;
                    }
                }
                else
                {
                    IEnumerable <StartMenuApplication> matchingApps = null;
                    if (getAllPrograms)
                    {
                        matchingApps = result.ResultList;
                    }
                    else if (UseWildcard)
                    {
                        matchingApps = result.ResultList.Where(app => Wildcard.IsMatch(app.Name));
                    }

                    if (matchingApps != null && matchingApps.Count() > 0)
                    {
                        List <StartMenuApplication>      applications = new List <StartMenuApplication>(matchingApps);
                        IComparer <StartMenuApplication> comparer     = new ApplicationComparer();
                        applications.Sort(comparer);
                        WriteObject(applications, true);
                        found = true;
                    }
                }
            }

            if (!found && !getAllPrograms)
            {
                WriteVerboseWithTimestamp(String.Format("Program '{0}' was not found in Collection '{1}'.", ProgramName, CollectionName));
            }
        }
Beispiel #5
0
 public void IsMatch_SingleWildcardReplacesOneCharacter_Succeeds()
 {
     Assert.That(Wildcard.IsMatch("dummy", "d?mmy"), Is.True);
 }
Beispiel #6
0
 public void IsMatch_SubstringWithoutLeadingWildcard_Fails()
 {
     Assert.That(Wildcard.IsMatch("dummy", "mm*"), Is.False);
 }
Beispiel #7
0
 public void IsMatch_SubstringWithTrailingWildcard_Succeeds()
 {
     Assert.That(Wildcard.IsMatch("dummy", "dum*"), Is.True);
 }
Beispiel #8
0
 public void IsMatch_WildcardInMiddle_Succeeds()
 {
     Assert.That(Wildcard.IsMatch("dummy", "d*y"), Is.True);
 }
Beispiel #9
0
 public void IsMatch_SubstringWithoutTrailingWildcard_Fails()
 {
     Assert.That(Wildcard.IsMatch("dummy", "*mm"), Is.False);
 }
 public override string[] ListFilesRelative(string domain, string path, string pattern, bool recursive)
 {
     return(GetObjects(domain, path, recursive).Where(x => Wildcard.IsMatch(pattern, Path.GetFileName(x.Name)))
            .Select(x => x.Name.Substring(MakePath(domain, path + "/").Length).TrimStart('/')).ToArray());
 }
 internal bool IsMatch(String verb, String path)
 {
     return(_path.IsSuffix(path) && _requestType.IsMatch(verb));
 }
Beispiel #12
0
 internal bool IsMatch(String verb, VirtualPath path)
 {
     return(_path.IsSuffix(path.VirtualPathString) && _requestType.IsMatch(verb));
 }
Beispiel #13
0
        //class Hashes
        //{
        //    public string[] install;
        //    public string[] encoding;
        //}

        static void Main(string[] args)
        {
            //HashSet<string> data = new HashSet<string>();
            //HashSet<string> installs = new HashSet<string>();

            //using (StreamReader sr = new StreamReader("list.txt"))
            //{
            //    string line1;

            //    while((line1 = sr.ReadLine()) != null)
            //    {
            //        data.Add(line1.Substring(19, 32));

            //        if (line1.Contains("install"))
            //        {
            //            installs.Add(line1.Substring(93, 32));
            //        }
            //    }
            //}

            ////foreach (var cfg in data)
            ////{
            ////    string url = string.Format("https://bnet.marlam.in/tpr/wow/config/{0}/{1}/{2}", cfg.Substring(0, 2), cfg.Substring(2, 2), cfg);

            ////    var stream = CDNIndexHandler.OpenFileDirect(url);

            ////    using (var fileStream = File.Create("builds\\" + cfg))
            ////    {
            ////        stream.CopyTo(fileStream);
            ////    }
            ////}

            //Dictionary<string, Hashes> data2 = new Dictionary<string, Hashes>();

            //foreach (var file in Directory.GetFiles("builds"))
            //{
            //    using(var sr = new StreamReader(file))
            //    {
            //        string line;

            //        while ((line = sr.ReadLine()) != null)
            //        {
            //            if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) // skip empty lines and comments
            //                continue;

            //            string[] tokens = line.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);

            //            if (tokens.Length != 2)
            //                throw new Exception("KeyValueConfig: tokens.Length != 2");

            //            var values = tokens[1].Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            //            var valuesList = values.ToList();

            //            if (!data2.ContainsKey(file))
            //                data2[file] = new Hashes();

            //            if (values[0] == "install")
            //            {
            //                data2[file].install = values;
            //            }

            //            if (values[0] == "encoding")
            //            {
            //                data2[file].encoding = values;
            //            }

            //            //sr.Data.Add(tokens[0].Trim(), valuesList);
            //        }
            //    }
            //}

            //Dictionary<string, string> realInstalls = new Dictionary<string, string>();

            //foreach(var kv in data2)
            //{
            //    for(int i = 6; i < kv.Value.install.Length; i++)
            //    {
            //        if (installs.Contains(kv.Value.install[i]))
            //        {
            //            //Console.WriteLine("{0} {1}", kv.Value.install[i], kv.Value.encoding[i]);

            //            realInstalls[kv.Value.install[i]] = kv.Value.encoding[i];
            //        }
            //    }
            //}

            //CASCConfig.ValidateData = false;

            //int buildIndex = 0;

            //foreach (var kvinstall in realInstalls)
            //{
            //    string url1 = string.Format("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2}", kvinstall.Key.Substring(0, 2), kvinstall.Key.Substring(2, 2), kvinstall.Key);

            //    BLTEStream instFile = new BLTEStream(CDNIndexHandler.OpenFileDirect(url1), new MD5Hash());

            //    InstallHandler install = new InstallHandler(new BinaryReader(instFile), null);

            //    //foreach(var ent  in install.GetEntries().Where(e => e.Name.Contains("MacOS")))
            //    //{
            //    //    Console.WriteLine(ent.Name);
            //    //}
            //    //continue;

            //    string url2 = string.Format("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2}", kvinstall.Value.Substring(0, 2), kvinstall.Value.Substring(2, 2), kvinstall.Value);

            //    BLTEStream encFile = new BLTEStream(CDNIndexHandler.OpenFileDirect(url2), new MD5Hash());

            //    EncodingHandler encoding = new EncodingHandler(new BinaryReader(encFile), null);

            //    string[] files = new string[] { "WowB.exe", "WowT.exe", "Wow.exe", "WowB-64.exe", "WowT-64.exe", "Wow-64.exe", "RenderService.exe", "RenderService-64.exe",
            //        @"World of Warcraft Public Test.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft Public Test.app\Contents\MacOS\World of Warcraft 64",
            //        @"World of Warcraft Beta.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft Beta.app\Contents\MacOS\World of Warcraft 64",
            //        @"World of Warcraft Retail.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft Retail.app\Contents\MacOS\World of Warcraft 64",
            //        @"World of Warcraft Test.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft.app\Contents\MacOS\World of Warcraft"
            //    };

            //    string outFolder = "build_" + buildIndex++;

            //    foreach (var file in files)
            //    {
            //        var entries = install.GetEntriesByName(file);

            //        foreach (var entry in entries)
            //        {
            //            bool ok = encoding.GetEntry(entry.MD5, out var encEntry);

            //            if (ok)
            //            {
            //                string chash = encEntry.Key.ToHexString().ToLower();

            //                Console.WriteLine("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2} {3}", chash.Substring(0, 2), chash.Substring(2, 2), chash, file);

            //                string url = string.Format("http://blzddist1-a.akamaihd.net/tpr/wow/data/{0}/{1}/{2}", chash.Substring(0, 2), chash.Substring(2, 2), chash);
            //                //string url = string.Format("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2}", chash.Substring(0, 2), chash.Substring(2, 2), chash);

            //                try
            //                {
            //                    var stream = CDNIndexHandler.OpenFileDirect(url);

            //                    BLTEStream blte3 = new BLTEStream(stream, new MD5Hash());

            //                    string outFile = Path.Combine(outFolder, chash + "_" + file);
            //                    string outDir = Path.GetDirectoryName(outFile);

            //                    if (!Directory.Exists(outDir))
            //                        Directory.CreateDirectory(outDir);

            //                    using (var fileStream = File.Create(outFile))
            //                    {
            //                        blte3.CopyTo(fileStream);
            //                    }
            //                }
            //                catch(Exception exc)
            //                {
            //                    Console.WriteLine(exc.Message);
            //                }
            //            }
            //        }
            //    }
            //}

            //ArmadilloCrypt crypt = new ArmadilloCrypt("sc1Dev");

            //var decr = crypt.DecryptFile(@"c:\Users\TOM_RUS\Downloads\e32f46c7245bfc154e43924555a5cf9f");

            //File.WriteAllBytes("test", decr);

            //byte[] keyBytes = new byte[16];

            //ArmadilloCrypt crypt = new ArmadilloCrypt(keyBytes);

            //string buildconfigfile = "9f6048f8bd01f38ec0be83f4a9fe5a10";

            //byte[] data = File.ReadAllBytes(buildconfigfile);

            //byte[] IV = buildconfigfile.Substring(16).ToByteArray();

            //unsafe
            //{
            //    fixed (byte* ptr = keyBytes)
            //    {
            //        for (ulong i = 0; i < ulong.MaxValue; i++)
            //        {
            //            for (ulong j = 0; j < ulong.MaxValue; j++)
            //            {
            //                byte[] decrypted = crypt.DecryptFile(IV, data);

            //                if (decrypted[0] == 0x23 && decrypted[1] == 0x20 && decrypted[2] == 0x42 && decrypted[3] == 0x75)
            //                {
            //                    Console.WriteLine("key found: {0} {1} ?", i, j);
            //                }

            //                *(ulong*)ptr = j;

            //                if (j % 1000000 == 0)
            //                    Console.WriteLine("{0}/{1}", j, ulong.MaxValue);
            //            }

            //            *(ulong*)(ptr + 8) = i;
            //        }
            //    }
            //}

            if (args.Length != 5)
            {
                Console.WriteLine("Invalid arguments count!");
                Console.WriteLine("Usage: CASCConsole <mode> <pattern|listfile> <destination> <localeFlags> <contentFlags>");
                return;
            }

            Console.WriteLine("Settings:");
            Console.WriteLine("    WowPath: {0}", Settings.Default.StoragePath);
            Console.WriteLine("    OnlineMode: {0}", Settings.Default.OnlineMode);

            Console.WriteLine("Loading...");

            BackgroundWorkerEx bgLoader = new BackgroundWorkerEx();

            bgLoader.ProgressChanged += BgLoader_ProgressChanged;

            //CASCConfig.LoadFlags |= LoadFlags.Install;

            CASCConfig config = Settings.Default.OnlineMode
                ? CASCConfig.LoadOnlineStorageConfig(Settings.Default.Product, "us")
                : CASCConfig.LoadLocalStorageConfig(Settings.Default.StoragePath);

            CASCHandler cascHandler = CASCHandler.OpenStorage(config, bgLoader);

            string       mode    = args[0];
            string       pattern = args[1];
            string       dest    = args[2];
            LocaleFlags  locale  = (LocaleFlags)Enum.Parse(typeof(LocaleFlags), args[3]);
            ContentFlags content = (ContentFlags)Enum.Parse(typeof(ContentFlags), args[4]);

            cascHandler.Root.LoadListFile(Path.Combine(Environment.CurrentDirectory, "listfile.txt"), bgLoader);
            CASCFolder root = cascHandler.Root.SetFlags(locale, content);

            //cascHandler.Root.MergeInstall(cascHandler.Install);

            Console.WriteLine("Loaded.");

            Console.WriteLine("Extract params:");
            Console.WriteLine("    Mode: {0}", mode);
            Console.WriteLine("    Pattern: {0}", pattern);
            Console.WriteLine("    Destination: {0}", dest);
            Console.WriteLine("    LocaleFlags: {0}", locale);
            Console.WriteLine("    ContentFlags: {0}", content);

            if (mode == "pattern")
            {
                Wildcard wildcard = new Wildcard(pattern, true, RegexOptions.IgnoreCase);

                foreach (var file in CASCFolder.GetFiles(root.Entries.Select(kv => kv.Value)))
                {
                    if (wildcard.IsMatch(file.FullName))
                    {
                        ExtractFile(cascHandler, file.FullName, dest);
                    }
                }
            }
            else if (mode == "listfile")
            {
                var names = File.ReadLines(pattern);

                foreach (var file in names)
                {
                    ExtractFile(cascHandler, file, dest);
                }
            }

            Console.WriteLine("Extracted.");
        }