Giter VIP home page Giter VIP logo

libmpq's People

Contributors

forrestv avatar ge0rg avatar mbroemme avatar tilman2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

libmpq's Issues

Add support for MPQ version 3 and 4.

Newer versions of World of Warcraft (Wraith of the Lich King and Cataclysm) are using modern version of MPQ format. We need to support them as well.

Loads wrong values from a file in diabdat.mpq

File Sfx\Items\Titlemov.wav in DIABDAT.MPQ from Diablo 1 is read incorrectly with this library.

Correct values:

82 73 70 70 136 4 0 0 87 65 86 69 102 109 116 32 16 0 0 0 1 0 1 0 34 86 0 0 34 86 0 0 1 0 8 0 100 97 116 97 100 4 0 0 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 129 128 128 128 127 127 127 128 129 129 129 129 129 129 129 129 128 128 127 127 127 128 128 128 129 130 129 129 129 129 129 128 127 126 127 127 127 128 127 127 127 127 128 128 128 128 128 128 127 129 130 129 130 129 128 129 128 128 128 128 128 128 128 128 128 129 127 126 127 128 129 130 129 128 128 127 126 126 127 127 127 127 127 128 128 127 128 130 131 130 130 129 128 128 127 126 127 126 126 127 127 127 127 127 127 128 129 130 130 130 129 130 129 128 128 127 127 129 130 130 129 128 128 130 130 128 126 126 128 130 131 129 127 128 130 130 129 130 130 129 127 126 126 126 127 127 127 126 128 131 131 129 130 129 125 125 128 130 129 128 129 129 130 132 131 131 131 129 125 126 127 126 129 132 131 130 127 126 127 130 131 130 129 128 128 128 129 129 129 129 128 127 127 129 128 128 129 129 128 126 124 124 125 128 129 129 127 126 127 130 132 132 129 126 126 127 128 130 133 131 127 127 128 130 131 131 128 127 130 133 131 128 128 129 130 129 129 128 127 127 128 129 129 126 123 124 125 125 125 126 127 127 129 132 132 132 129 128 130 132 129 126 124 122 123 126 129 130 127 126 127 127 129 130 132 131 130 131 131 130 128 125 124 124 128 132 132 129 129 129 128 126 125 125 128 131 132 131 127 123 124 126 125 126 128 132 132 130 129 126 127 129 131 131 130 127 125 126 128 132 133 130 128 127 129 131 130 130 128 124 123 124 126 128 128 127 127 130 132 131 128 128 128 129 128 126 126 126 127 130 129 128 131 132 132 130 126 122 122 122 122 125 127 127 128 128 128 128 127 127 128 126 126 127 126 126 129 130 129 127 126 125 126 128 126 125 125 127 132 133 129 131 133 132 132 133 131 128 125 123 123 122 122 125 128 130 133 133 131 131 130 126 123 123 122 126 133 134 133 132 130 128 128 127 128 129 128 129 128 125 125 129 131 131 129 128 127 125 126 129 134 135 133 132 130 127 124 123 124 125 127 128 128 126 124 125 129 130 130 129 128 129 131 133 127 122 125 127 124 126 129 125 124 126 128 131 133 133 131 128 130 133 131 127 124 125 126 127 131 132 128 124 126 126 125 130 136 134 134 135 132 129 129 127 124 123 124 127 130 132 131 128 127 130 132 132 133 131 127 126 129 133 133 130 127 127 128 125 126 125 121 119 119 125 133 135 132 129 132 134 133 130 131 130 125 129 130 126 127 129 127 126 125 125 127 128 127 125 123 127 132 135 136 133 131 133 139 139 133 128 130 129 127 126 124 124 126 127 126 131 132 130 131 132 130 125 126 126 121 119 120 127 135 134 128 127 128 127 130 135 136 130 125 127 128 125 127 129 132 135 133 130 129 130 131 126 125 125 124 128 134 130 127 127 123 121 127 132 130 131 131 129 128 125 125 127 130 130 127 125 129 134 131 125 123 121 122 127 135 141 143 141 136 130 127 126 126 126 128 129 130 129 126 124 122 123 127 131 134 132 131 136 138 135 129 125 123 122 123 127 135 138 133 127 128 129 131 136 133 124 124 126 125 123 124 129 130 130 133 132 130 133 136 137 131 123 120 120 119 122 128 134 133 129 129 130 130 130 131 135 134 132 130 132 132 129 126 123 122 128 134 130 123 120 118 118 123 128 129 132 129 123 123 127 129 129 131 130 130 132 131 131 133 136 131 124 122 126 129 123 118 116 113 117 127 130 132 136 131 124 123 124 127 130 134 140 140 135 133 131 124 119 119 119 122 127 129 136 138 135 129 123 121 126 131 127 123 120 117 123 130 128 125 126 130 132 131 131 127 126 131 133 131 131 127 122 125 129 126 126 130 126 119 124 134 142 142 136 132 123 115 121 135 138 134 133 125 117 121 130 135 138 133 124 124 127 125 124 123 120 118 122 132 138 138 134 130 134 135 131 130 130 127 129 129 129 128 121 118 124 126 122 128 135 130 124 127 129 130 132 134 136 132 122 116 122 135 138 135 133 132 131 131 126 117 115 118 125 135 137 133 128 124 122 123 126 127 131 135 141 142 133 123 117 113 116 125 132 128 121 122 119 117 127 135 136 133 131 133 135 134 130 130 133 130 129 133 135 129 128 134 132 124 123 123 120 125 135 136 136 135 130 132 135 133 128 121 116 114 113 114 120 127 130 137 135 129 127 131 132 130 135 139 133 127 126 125 125 128 133 133 132 133 130 125 125 128 129 129 131 137 137 133 131 129 129 130 130 128 128 130 125 122 121 121 122 125 131 134 134 131 130 127 122 122 125 129 133 137 139 136 127 123 128 129 127 126 127 126 125 129 130 128 127 129 133 133 130 131 135 136 132 129 126 122 120 123 128 131 130 128 127 126 126 129 134 134 131 128 127 126 125 127 129 129 130 131 130 128 126 124 125 129 131 132 132 131 130 129 129 129 128 129 130 130 130 129 128 127 126 126 127 127 127 128 128 128 128 128 128 128 128 128 128 128 128 128

Values read by libmpq:

97 154 8 205 106 100 219 240 119 141 224 50 118 3 178 51 188 53 94 41 81 143 64 222 2 176 242 39 34 146 141 130 1 128 167 94 100 97 238 129 100 4 68 22 128 128 152 17 128 128 96 165 128 128 128 52 128 128 128 96 128 129 128 64 128 127 127 255 128 129 129 129 129 129 129 129 129 128 128 127 127 127 128 128 128 129 130 129 129 129 129 129 128 127 126 127 127 127 128 127 127 127 127 128 128 128 128 128 128 127 129 130 129 130 129 128 129 128 128 128 128 128 128 128 128 128 129 127 126 127 128 129 130 129 128 128 127 126 126 127 127 127 127 127 128 128 127 128 130 131 130 130 129 128 128 127 126 127 126 126 127 127 127 127 127 127 128 129 130 130 130 129 130 129 128 128 127 127 129 130 130 129 128 128 130 130 128 126 126 128 130 131 129 127 128 130 130 129 130 130 129 127 126 126 126 127 127 127 126 128 131 131 129 130 129 125 125 128 130 129 128 129 129 130 132 131 131 131 129 125 126 127 126 129 132 131 130 127 126 127 130 131 130 129 128 128 128 129 129 129 129 128 127 127 129 128 128 129 129 128 126 124 124 125 128 129 129 127 126 127 130 132 132 129 126 126 127 128 130 133 131 127 127 128 130 131 131 128 127 130 133 131 128 128 129 130 129 129 128 127 127 128 129 129 126 123 124 125 125 125 126 127 127 129 132 132 132 129 128 130 132 129 126 124 122 123 126 129 130 127 126 127 127 129 130 132 131 130 131 131 130 128 125 124 124 128 132 132 129 129 129 128 126 125 125 128 131 132 131 127 123 124 126 125 126 128 132 132 130 129 126 127 129 131 131 130 127 125 126 128 132 133 130 128 127 129 131 130 130 128 124 123 124 126 128 128 127 127 130 132 131 128 128 128 129 128 126 126 126 127 130 129 128 131 132 132 130 126 122 122 122 122 125 127 127 128 128 128 128 127 127 128 126 126 127 126 126 129 130 129 127 126 125 126 128 126 125 125 127 132 133 129 131 133 132 132 133 131 128 125 123 123 122 122 125 128 130 133 133 131 131 130 126 123 123 122 126 133 134 133 132 130 128 128 127 128 129 128 129 128 125 125 129 131 131 129 128 127 125 126 129 134 135 133 132 130 127 124 123 124 125 127 128 128 126 124 125 129 130 130 129 128 129 131 133 127 122 125 127 124 126 129 125 124 126 128 131 133 133 131 128 130 133 131 127 124 125 126 127 131 132 128 124 126 126 125 130 136 134 134 135 132 129 129 127 124 123 124 127 130 132 131 128 127 130 132 132 133 131 127 126 129 133 133 130 127 127 128 125 126 125 121 119 119 125 133 135 132 129 132 134 133 130 131 130 125 129 130 126 127 129 127 126 125 125 127 128 127 125 123 127 132 135 136 133 131 133 139 139 133 128 130 129 127 126 124 124 126 127 126 131 132 130 131 132 130 125 126 126 121 119 120 127 135 134 128 127 128 127 130 135 136 130 125 127 128 125 127 129 132 135 133 130 129 130 131 126 125 125 124 128 134 130 127 127 123 121 127 132 130 131 131 129 128 125 125 127 130 130 127 125 129 134 131 125 123 121 122 127 135 141 143 141 136 130 127 126 126 126 128 129 130 129 126 124 122 123 127 131 134 132 131 136 138 135 129 125 123 122 123 127 135 138 133 127 128 129 131 136 133 124 124 126 125 123 124 129 130 130 133 132 130 133 136 137 131 123 120 120 119 122 128 134 133 129 129 130 130 130 131 135 134 132 130 132 132 129 126 123 122 128 134 130 123 120 118 118 123 128 129 132 129 123 123 127 129 129 131 130 130 132 131 131 133 136 131 124 122 126 129 123 118 116 113 117 127 130 132 136 131 124 123 124 127 130 134 140 140 135 133 131 124 119 119 119 122 127 129 136 138 135 129 123 121 126 131 127 123 120 117 123 130 128 125 126 130 132 131 131 127 126 131 133 131 131 127 122 125 129 126 126 130 126 119 124 134 142 142 136 132 123 115 121 135 138 134 133 125 117 121 130 135 138 133 124 124 127 125 124 123 120 118 122 132 138 138 134 130 134 135 131 130 130 127 129 129 129 128 121 118 124 126 122 128 135 130 124 127 129 130 132 134 136 132 122 116 122 135 138 135 133 132 131 131 126 117 115 118 125 135 137 133 128 124 122 123 126 127 131 135 141 142 133 123 117 113 116 125 132 128 121 122 119 117 127 135 136 133 131 133 135 134 130 130 133 130 129 133 135 129 128 134 132 124 123 123 120 125 135 136 136 135 130 132 135 133 128 121 116 114 113 114 120 127 130 137 135 129 127 131 132 130 135 139 133 127 126 125 125 128 133 133 132 133 130 125 125 128 129 129 131 137 137 133 131 129 129 130 130 128 128 130 125 122 121 121 122 125 131 134 134 131 130 127 122 122 125 129 133 137 139 136 127 123 128 129 127 126 127 126 125 129 130 128 127 129 133 133 130 131 135 136 132 129 126 122 120 123 128 131 130 128 127 126 126 129 134 134 131 128 127 126 125 127 129 129 130 131 130 128 126 124 125 129 131 132 132 131 130 129 129 129 128 129 130 130 130 129 128 127 126 126 127 127 127 128 128 128 128 128 128 128 128 128 128 128 128 128

Upon inspecting, I can see that the file is encrypted but not compressed (flags are 0x80010000).

This means libmpq__decrypt_key is never called, so the decryption seed then ends up being 0.

According to StormLib, the correct key here is 2227372475.

Looks like StormLib generates the decryption key from the filename (although it does also have a heuristic to decrypt WAV files).

There should be a way to do something similar here as well.

Big-endian support

The library appears to read the 16-bit and 32-bit ints directly into structs via fread without byte-swapping them on big-endian platforms.

DevilutionX fork

Hi, to provide some context on the barrage of PRs: I want to replace StormLib in DevilutionX, a Diablo 1 source port, with libmpq.

To that end, I needed to make a number of fixes/enhancements to libmpq, all of which are here https://github.com/diasurgical/libmpq/

I'm simply upstreaming them piecemeal

Streaming API for files

It'd be very useful to have a streaming API for files with read/seek functions, so that it can be wrapped as e.g. SDL_RWops for audio streaming.

Look up file by hash

When looking up a file in multiple archives, it'd be useful to avoid recalculating the hash multiple times.

Compilation warning: taking address of packed member

_deps/libmpq-src/libmpq/mpq.c: In function ‘libmpq__block_open_offset’:
_deps/libmpq-src/libmpq/mpq.c:696:128: warning: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  696 |    if (libmpq__decrypt_key((uint8_t *)mpq_archive->mpq_file[file_number]->packed_offset, packed_size, mpq_archive->block_size, &mpq_archive->mpq_file[file_number]->seed) < 0) {
      |                                                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.