Hi,
I noticed in the most recent GMS patched HARepacker resurrected was not working.
Upon discussion with some friends in the community, I was notified that Elem8100 has found the solution(apologies if incorrect).
Apparently the wzVersionHeader is 2 bytes and is no longer part of the decrypted packet stream.
This means, that previously, the header.FStart would start at ~ 62 bytes into the stream. Now after v230, it will start at 60.
Fortunately the rest of the offsets and byte checks remained the same. However, wzVersionHeader is now a fix value of 777 as of V230.
So how to fix?
->Make sure header.FStart is 60 when you ReadUInt32().
->wzVersionHeader is now 777
->Calculate the hashversion for 777
->When saving the file, there is a +2 offset added to header.FStart. This will cause the file, after being saved, to read incorrectly and your .IMG won't be loaded
Some code below;
From internal WzFileParseStatus ParseMainWzDirectory(bool lazyParse = false)
Calculating the hasversion by Elem8100 the god (please teach me your ways <3)Code:this.wzVersionHeader = 0; if (!this.b64BitClient) if (this.Header.FSize >= 2) { this.wzVersionHeader = reader.ReadInt16(); Console.WriteLine("Version Header : " + this.wzVersionHeader); if (this.wzVersionHeader < 0xff && this.wzVersionHeader > 0) { Console.WriteLine("GMS < V230 detected"); } else { Console.WriteLine("GMS > V230 found"); this.wzVersionHeader = 777; //V230 reader.BaseStream.Position = this.header.FStart; } } else { this.wzVersionHeader = 777; reader.BaseStream.Position = this.header.FStart; }
You'll want to call the above code and set the versionhash before reader.Hash = this versionHash is calledCode://By Elem8100 int sum = 0; string versionStr = useWzVersionHeader.ToString(System.Globalization.CultureInfo.InvariantCulture); for (int j = 0; j < versionStr.Length; j++) { sum <<= 5; sum += (int)versionStr[j] + 1; } this.versionHash = (uint) sum; this.Version = 777; Console.WriteLine("Calculated Hash : " + this.versionHash);
Lastly the save function;
Well that should be it. With those changes in MapleLib, your HARepacker should be able to read v230.Code:public void SaveToDisk(string path, WzMapleVersion savingToPreferredWzVer = WzMapleVersion.UNKNOWN) { Console.WriteLine("Saving..."); // WZ IV if (savingToPreferredWzVer == WzMapleVersion.UNKNOWN) WzIv = WzTool.GetIvByMapleVersion(maplepLocalVersion); // get from local WzFile else WzIv = WzTool.GetIvByMapleVersion(savingToPreferredWzVer); // custom selected bool bIsWzIvSimilar = WzIv.SequenceEqual(wzDir.WzIv); // check if its saving to the same IV. wzDir.WzIv = WzIv; // MapleStory UserKey bool bIsWzUserKeyDefault = MapleCryptoConstants.IsDefaultMapleStoryUserKey(); // check if its saving to the same UserKey. // if (this.wzVersionHeader != 777) { CreateWZVersionHashv230(); } wzDir.SetVersionHash(versionHash); Console.WriteLine("Setting directory hash to : " + wzDir.hash); string tempFile = Path.GetFileNameWithoutExtension(path) + ".TEMP"; File.Create(tempFile).Close(); using (FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write)) { wzDir.GenerateDataFile(bIsWzIvSimilar ? null : WzIv, bIsWzUserKeyDefault, fs); } WzTool.StringCache.Clear(); using (WzBinaryWriter wzWriter = new WzBinaryWriter(File.Create(path), WzIv)) { wzWriter.Hash = versionHash; if (wzVersionHeader != 777) { uint totalLen = wzDir.GetImgOffsets(wzDir.GetOffsets(Header.FStart + 2)); Header.FSize = totalLen - Header.FStart; } else { uint totalLen = wzDir.GetImgOffsets(wzDir.GetOffsets(Header.FStart)); //Header.FStart is where the file starts reading the check byte V230 its 60 Header.FSize = totalLen - Header.FStart; } for (int i = 0; i < 4; i++) { wzWriter.Write((byte)Header.Ident[i]); } wzWriter.Write((long)Header.FSize); wzWriter.Write(Header.FStart); wzWriter.WriteNullTerminatedString(Header.Copyright); long extraHeaderLength = Header.FStart - wzWriter.BaseStream.Position; if (extraHeaderLength > 0) { wzWriter.Write(new byte[(int)extraHeaderLength]); } if (!b64BitClient) if (wzVersionHeader != 777) //V230 no need to write this anymore { Console.WriteLine("GMS <V230 Adding Version Header"); wzWriter.Write(wzVersionHeader); } wzWriter.Header = Header; wzDir.SaveDirectory(wzWriter); wzWriter.StringCache.Clear(); using (FileStream fs = File.OpenRead(tempFile)) { wzDir.SaveImages(wzWriter, fs); } File.Delete(tempFile); wzWriter.StringCache.Clear(); } Console.WriteLine("Finished saving"); GC.Collect(); GC.WaitForPendingFinalizers(); }
Disclaimer : I am EE not SWE. This is my interpretation of the solution and what I implemented. I t may not be the nicest code or maybe what I said wasn't exactly correct so I do apologize.
Also credits due to original owners of maplelib, harepacker, elem8100 etc.. etc...
Compiled version below
https://www.mediafire.com/file/c9mo2...0_Fix.rar/file
Enjoy



Reply With Quote
Good news,return to old way of wz.

