Original War Support Bug Tracker
star_faded.png
Please log in to bookmark issues
enhancement_small.png
CLOSED  Enhancement #289  -  PakView extract wav music files
Posted Feb 17, 2016 - updated Sep 18, 2017
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
icon_info.png This issue has been closed with status "Done" and resolution "RESOLVED".
Issue details
  • Type of issue
    Enhancement
  • Status
     
    Done
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     theultramage
  • Owned by
    Not owned by anyone
  • Estimated time
    Not estimated
  • Time spent
    No time spent
  • Category
    Not determined
  • Resolution
    RESOLVED
  • Priority
    Not determined
  • Targetted for
    icon_milestones.png Not determined
Issue description
PakView will not extract the wav files in Data2.owp's Hudba\, it skips them. I'd like to finally make it work.

In 2010 I did some RE work, found the ADPCM decoder in owarfull.dll and wrote a crude hook for pakview.exe to extract the audio data in pcm wave format. Then I sent my findings to Stucuk, but it seems it didn't go anywhere. Today I found myself re-extracting the files again to encode them as flac, and thought I'd try poking about the subject again.

All the files I produced back then are available at https://netvor.tk/svn/storage/games/Original%20War/ and the contents of that e-mail are in PakHook-20100206.rar/!readme.txt. The readme explains what was hooked, how the audio was decoded and where it was integrated into pakview. The rar file contains a ready-to-go pakview_hooked.exe which will successfully extract all the wav music, except RuInt.wav which decodes wrong.

For some reason, when trying to extract the music wav files, PakView calls WriteFile() with a buffer containing X bytes of adpcm data but asking to write 4*X bytes, resulting in ERROR_INVALID_USER_BUFFER. This mistake prevents it from at least extracting the raw form of the file. But even if that worked, the files require a custom decoder.

To locate the ADPCM decoder, find the function that uses the array { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8, } and does bit shifting. Note that the file itself is not valid - it has a standard 44-byte wav header that claims it's raw PCM, but is followed by (I believe) 14 bytes (1+4+4+1+4) of some sort of custom data, and a repeating sequence of "256 bytes of one channel, 256 bytes of the other channel, and 6 (2+1+2+1) bytes of some sort of state (possibly to allow random seeking). The code to turn this mess into a pcm stream is right there, although I don't know why my stuff broke on RuInt.wav.