Esempio n. 1
0
        internal WzPngProperty(WzBinaryReader reader, bool parseNow)
        {
            // Read compressed bytes
            width = reader.ReadCompressedInt();
            height = reader.ReadCompressedInt();
            format = reader.ReadCompressedInt();
            format2 = reader.ReadByte();
            reader.BaseStream.Position += 4;
            offs = reader.BaseStream.Position;
            int len = reader.ReadInt32() - 1;
            reader.BaseStream.Position += 1;

            if (len > 0)
            {
                if (parseNow)
                {
                    if (wzReader == null)
                    {
                        wzReader = reader;
                    }
                    compressedBytes = wzReader.ReadBytes(len);
                    ParsePng();
                }
                else
                    reader.BaseStream.Position += len;
            }
            wzReader = reader;
        }
Esempio n. 2
0
		/// <summary>
		/// Parses the wz list file
		/// </summary>
		public void ParseWzFile()
		{
			//WzTools.CreateWzKey(WzMapleVersion.GMS);//what?
			WzBinaryReader wzParser = new WzBinaryReader(new MemoryStream(wzFileBytes), WzIv);
			while (wzParser.PeekChar() != -1)
			{
				int Len = wzParser.ReadInt32();
				char[] List = new char[Len];
				for (int i = 0; i < Len; i++)
					List[i] = (char)wzParser.ReadInt16();
				wzParser.ReadUInt16();
				string Decrypted = wzParser.DecryptString(List);
				if (wzParser.PeekChar() == -1)
					if (Decrypted[Decrypted.Length - 1] == '/')
						Decrypted = Decrypted.TrimEnd("/".ToCharArray()) + "g"; // Last char should always be a g (.img)
				listEntries.Add(Decrypted);
			}
			wzParser.Close();
		}
Esempio n. 3
0
 /// <summary>
 /// Parses a wz list file on the disk
 /// </summary>
 /// <param name="filePath">Path to the wz file</param>
 public static List<string> ParseListFile(string filePath, byte[] WzIv)
 {
     List<string> listEntries = new List<string>();
     byte[] wzFileBytes = File.ReadAllBytes(filePath);
     WzBinaryReader wzParser = new WzBinaryReader(new MemoryStream(wzFileBytes), WzIv);
     while (wzParser.PeekChar() != -1)
     {
         int len = wzParser.ReadInt32();
         char[] strChrs = new char[len];
         for (int i = 0; i < len; i++)
             strChrs[i] = (char)wzParser.ReadInt16();
         wzParser.ReadUInt16(); //encrypted null
         string decryptedStr = wzParser.DecryptString(strChrs);
         listEntries.Add(decryptedStr);
     }
     wzParser.Close();
     int lastIndex= listEntries.Count - 1;
     string lastEntry = listEntries[lastIndex];
     listEntries[lastIndex] = lastEntry.Substring(0, lastEntry.Length - 1) + "g";
     return listEntries;
 }
 internal static IExtended ParseExtendedProp(WzBinaryReader reader, uint offset, int endOfBlock, string name, IWzObject parent, WzImage imgParent)
 {
     switch (reader.ReadByte())
     {
         case 0x1B:
             return ExtractMore(reader, offset, endOfBlock, name, reader.ReadStringAtOffset(offset + reader.ReadInt32()), parent, imgParent);
         case 0x73:
             return ExtractMore(reader, offset, endOfBlock, name, "", parent, imgParent);
         default:
             throw new System.Exception("Invlid byte read at ParseExtendedProp");
     }
 }
 internal static IExtended ExtractMore(WzBinaryReader reader, uint offset, int eob, string name, string iname, IWzObject parent, WzImage imgParent)
 {
     if (iname == "")
         iname = reader.ReadString();
     switch (iname)
     {
         case "Property":
             WzSubProperty subProp = new WzSubProperty(name) { Parent = parent };
             reader.BaseStream.Position += 2;
             subProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, subProp, imgParent));
             return subProp;
         case "Canvas":
             WzCanvasProperty canvasProp = new WzCanvasProperty(name) { Parent = parent };
             reader.BaseStream.Position++;
             if (reader.ReadByte() == 1)
             {
                 reader.BaseStream.Position += 2;
                 canvasProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, canvasProp, imgParent));
             }
             canvasProp.PngProperty = new WzPngProperty(reader, imgParent.parseEverything) { Parent = canvasProp };
             return canvasProp;
         case "Shape2D#Vector2D":
             WzVectorProperty vecProp = new WzVectorProperty(name) { Parent = parent };
             vecProp.X = new WzCompressedIntProperty("X", reader.ReadCompressedInt()) { Parent = vecProp };
             vecProp.Y = new WzCompressedIntProperty("Y", reader.ReadCompressedInt()) { Parent = vecProp };
             return vecProp;
         case "Shape2D#Convex2D":
             WzConvexProperty convexProp = new WzConvexProperty(name) { Parent = parent };
             int convexEntryCount = reader.ReadCompressedInt();
             convexProp.WzProperties.Capacity = convexEntryCount; //performance thing
             for (int i = 0; i < convexEntryCount; i++)
             {
                 convexProp.AddProperty(ParseExtendedProp(reader, offset, 0, name, convexProp, imgParent));
             }
             return convexProp;
         case "Sound_DX8":
             WzSoundProperty soundProp = new WzSoundProperty(name, reader, imgParent.parseEverything) { Parent = parent };
             return soundProp;
         case "UOL":
             reader.BaseStream.Position++;
             switch (reader.ReadByte())
             {
                 case 0:
                     return new WzUOLProperty(name, reader.ReadString()) { Parent = parent };
                 case 1:
                     return new WzUOLProperty(name, reader.ReadStringAtOffset(offset + reader.ReadInt32())) { Parent = parent };
             }
             throw new Exception("Unsupported UOL type");
         default:
             throw new Exception("Unknown iname: " + iname);
     }
 }
Esempio n. 6
0
		internal WzPngProperty(WzBinaryReader reader)
		{
			// Read compressed bytes
			width = reader.ReadCompressedInt();
			height = reader.ReadCompressedInt();
			format = reader.ReadCompressedInt();
			format2 = reader.ReadByte();
			reader.BaseStream.Position += 4;
			int len = reader.ReadInt32() - 1;
			reader.BaseStream.Position += 1;

			if (len > 0)
				compressedBytes = reader.ReadBytes(len);
		}