Giter VIP home page Giter VIP logo

Comments (4)

speige avatar speige commented on June 29, 2024

I think this is due to a bunch of fake & duplicated hash table values, making it hard to know which hash table records are real.

Some of the fake entries can be resolved using an external list files, and will successfully extract, but the binary data is garbage.
For example:
(PC)WorldEditMenu.html

I'm researching this more to see if I can fix it on my end with some Deep File Verification. Maybe not StormLib's job to handle this scenario.

from stormlib.

ladislav-zezula avatar ladislav-zezula commented on June 29, 2024

What you see is a fundamental problem of opening file by pseudo-name.

Unlike classic file open (FileName --> NameHash+HashTableIndex --> BlockIndex --> FileData), opening by pseudo-name goes directly into BlockIndex. Yes. The number in the name ("File00024483.blp" --> 24483) is the decimal block index. The extension is provided only when StormLib is able to determine it by file content, but it's generally ignored by SFileOpenFileEx.

Now we opened a file by block index, where to take that damn hash index?

When a file is opened by pseudo-name, StormLib tries to determine the hash index by searching which hash entry points to block table entry whose index is given in the pseudo name. This generally works well, except the case when MPQ has cross-linked files (multiple files names pointing to the same file data).

Cross-linked files may be legal (why couldn't multiple files have the same data, right?) or malformed (MPQ protectors slowing down MPQ opens).

Now I guess that the best (or "least-worst", if you want) way to fix it is to not return any hash entry when those two conditions are met:

  1. A file is open by pseudo-name
  2. Multiple hash table entries pointing to that block entry.

from stormlib.

speige avatar speige commented on June 29, 2024

Thanks for the explanation. I don't think this is a bug in StormLib, nor should StormLib handle it any better/differently, so I'm closing it.

I've been able to work around the issue by coding my own custom filename & hash verification methods. It's pretty complicated & WC3 specific. I'm basically regex scanning all extracted file contents for filenames & checking against SFileHasFile.

In my case if there are 2 hash entries pointing to 1 block I'd prefer to get ALL the possible hashes for a fileIndex, rather than 1st or none. But, there's no reason to make a breaking change to the StormLib API based on my specific use case & corrupted map. I can workaround the problem.

Thanks for the help!

from stormlib.

ladislav-zezula avatar ladislav-zezula commented on June 29, 2024

I made the fix described above in this PR: #316

Callers of SFileGetFileInfo(hFile, SFileInfoNameHash1, ...) must test the result of the call.

from stormlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.