Exemple #1
0
        static void Main(string[] args)
        {
            var file = args.Length == 0 ? GetFile() : args[0];

            if (string.IsNullOrWhiteSpace(file))
                return;
            if (!File.Exists(file))
                Console.WriteLine($"File \"{file}\" not exists.");

            var outPutDirectoty = Path.Combine(Path.GetDirectoryName(file), @"Cracked");

            var assembly = Assembly.LoadFrom(file);

            rm = new ResourceManager("app", assembly);
            var mainAssembly = rm.GetObject(guid);

            var filedInfo = rm.GetType().GetField("_resourceSets", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
            var resourceSets = filedInfo.GetValue(rm) as Dictionary<string, ResourceSet>;
            var resourceSet = resourceSets["zh-CN"];

            foreach (DictionaryEntry item in resourceSet)
            {
                var key = item.Key as string;
                var value = item.Value as byte[];
                if (key == "zip.dll")
                    continue;

                var ms = UnZip(value);
                ms.Seek(0L, SeekOrigin.Begin);
                if (!Directory.Exists(outPutDirectoty))
                    Directory.CreateDirectory(outPutDirectoty);

                var fileName = (key == guid) ? Path.GetFileName(file) : GetName(key);

                FileStream dumpFile = new FileStream(Path.Combine(outPutDirectoty, fileName), FileMode.Create, FileAccess.ReadWrite);
                ms.WriteTo(dumpFile);
            }

            Console.WriteLine("Finished..");
            Console.ReadKey();
        }