[FONT="Times New Roman"]Nein, aber es gibt die Res-File Struktur von Xadet auf seiner Homepage (und noch viel mehr!)
001.using System;
002.using System.IO;
003.using System.Text;
004.
005.namespace Res_Example
006.{
007. class Program
008. {
009. /// <summary>
010. /// Type of .res file we are dealing with
011. /// </summary>
012. enum FileType
013. {
014. Normal = 0,
015. Obfuscated = 1
016. }
017.
018. /// <summary>
019. /// Structure of a resource file generated from the file header
020. /// </summary>
021. struct ResourceFile
022. {
023. public string FileName;
024. public int Size;
025. public int Crc32;
026. public int Offset;
027. };
028.
029. /// <summary>
030. /// File path we want to extract
031. /// Obviously we could use the "string[] args" in Main to get the file path but this is merely an example
032. /// </summary>
033. const string FILE_PATH = @"C:\Program Files (x86)\Gpotato\Flyff\World\DuKrr\DuKrr.res";
034.
035. #region Member Declarations
036.
037. static byte xorKey;
038. static FileType fileType;
039.
040. static ResourceFile[] resourceFiles;
041.
042. static string rootPath;
043.
044. #endregion
045.
046. static void Main(string[] args)
047. {
048. ExtractRes(FILE_PATH);
049. }
050.
051. /// <summary>
052. /// Open and collect information from a Flyff .res file
053. /// Then extract all of the files to the same folder as the .res file
054. /// </summary>
055. /// <param name="filePath">File path of the .res file</param>
056. static void ExtractRes(string filePath)
057. {
058. DateTime start = DateTime.Now;
059.
060. BinaryReader fh = new BinaryReader(File.OpenRead(filePath));
061. rootPath = Path.GetDirectoryName(filePath);
062.
063. xorKey = fh.ReadByte();
064. fileType = (FileType)fh.ReadByte();
065.
066. int headerSize = fh.ReadInt32();
067. byte[] header = fh.ReadBytes(headerSize);
068.
069. for (int i = 0; i < headerSize; i++)
070. header[i] = (byte)((16 * (xorKey ^ (byte)~header[i])) | ((xorKey ^ (byte)~header[i]) >> 4));
071.
072. // Open the header in a stream (a lot easier than using something like BitConverter)
073. BinaryReader headerStream = new BinaryReader(new MemoryStream(header));
074.
075. headerStream.ReadBytes(7); // Unknown
076.
077. short fileCount = headerStream.ReadInt16();
078. resourceFiles = new ResourceFile[fileCount];
079.
080. for (int i = 0; i < fileCount; i++)
081. {
082. short stringLength = headerStream.ReadInt16();
083.
084. resourceFiles[i] = new ResourceFile()
085. {
086. FileName = Encoding.ASCII.GetString(headerStream.ReadBytes(stringLength)),
087. Size = headerStream.ReadInt32(),
088. Crc32 = headerStream.ReadInt32(), // Haven't checked but it's the only logical thing I can think of
089. Offset = headerStream.ReadInt32(),
090. };
091. }
092.
093. headerStream.Close();
094.
095. // Extract and save all of the files
096. for (int i = 0; i < fileCount; i++)
097. ExtractFile(resourceFiles[i], fh);
098.
099. fh.Close();
100.
101. Console.WriteLine("Extraction Completed in {0}.{1} Seconds", (DateTime.Now - start).Seconds, (DateTime.Now - start).Milliseconds);
102. Console.ReadLine();
103. }
104.
105. /// <summary>
106. /// Extract a resource file from the Flyff .res format
107. /// </summary>
108. /// <param name="resourceFile">Resource structure for the file</param>
109. /// <param name="fh">File handler for the .res file</param>
110. static void ExtractFile(ResourceFile resourceFile, BinaryReader fh)
111. {
112. Console.WriteLine("Extracting File: {0}", resourceFile.FileName);
113.
114. string filePath = string.Format(@"{0}\{1}", rootPath, resourceFile.FileName);
115.
116. if (!File.Exists(filePath))
117. File.Create(filePath).Close();
118.
119. fh.BaseStream.Seek(resourceFile.Offset, SeekOrigin.Begin);
120.
121. byte[] fileBuffer = fh.ReadBytes(resourceFile.Size);
122.
123. // If the file type of "Obfuscated", use the same method as we used to deobfuscate the file header
124. if (fileType == FileType.Obfuscated)
125. {
126. for (int i = 0; i < resourceFile.Size; i++)
127. fileBuffer[i] = (byte)((16 * (xorKey ^ (byte)~fileBuffer[i])) | ((xorKey ^ (byte)~fileBuffer[i]) >> 4));
128. }
129.
130. // Write the buffer to the file
131. File.WriteAllBytes(filePath, fileBuffer);
132. }
133. }
134.}
Alles anzeigen
[/FONT]