-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c123108
Showing
30 changed files
with
17,638 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
jobs: | ||
build-windows: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.20.0 | ||
cache: true | ||
- run: go test -v ./... | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: filediver-win64 | ||
path: filediver.exe | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: build-windows | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: filediver-win64 | ||
- uses: actions/create-release@v1 | ||
id: create-new-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.run_number }} | ||
release_name: Release ${{ github.run_number }} | ||
- uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create-new-release.outputs.upload_url }} | ||
asset_path: ./filediver.exe | ||
asset_name: filediver-win64.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright 2024 Darwin Schuppan | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# FileDiver | ||
An unofficial Helldivers 2 game asset extractor. | ||
|
||
## Download | ||
- [Windows (64-bit)](https://github.com/xypwn/filediver/releases/latest/download/filediver-win64.exe) | ||
- [Linux (64-bit)](https://github.com/xypwn/filediver/releases/latest/download/filediver-linux-amd64) | ||
|
||
## Usage | ||
`$` `filediver` | ||
Simply running the app should automatically detect your installation directory and dump all files into the "extracted" directory in your current folder. | ||
|
||
`$` `filediver -o "custom_dir"` | ||
Will extract the files into a directory called "custom_dir". | ||
|
||
`$` `filediver -h` | ||
To print all options. | ||
|
||
## Features | ||
### File Types/Formats | ||
- **Audio**: Audiokinetic wwise bnk/wem; automatically converted to WAV | ||
- **Video**: Bink; automatically converted to MP4 (requires [FFmpeg](https://ffmpeg.org/download.html) to be installed) | ||
- **Textures**: Direct Draw Surface (.dds) | ||
|
||
Planned: models, bones, animations | ||
|
||
## Credits/Links | ||
This app builds on a lot of work from other people. This includes: | ||
- [Hellextractor by Xaymar](https://github.com/Xaymar/Hellextractor) | ||
- Basic binary file structure | ||
- Unhashed resource names/types (.txt files) | ||
- [vgmstream](https://github.com/vgmstream/vgmstream), [ww2ogg by hcs](https://github.com/hcs64/ww2ogg) and [bnkextr by eXpl0it3r](https://github.com/eXpl0it3r/bnkextr) | ||
- Wwise audio formats | ||
|
||
Some useful discussion on the topic of HD2 resource extraction: https://reshax.com/topic/507-helldivers-2-model-extraction-help/ | ||
|
||
## License | ||
Copyright (c) Darwin Schuppan | ||
|
||
FileDiver is licensed under the 3-Clause BSD License (https://opensource.org/license/bsd-3-clause). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// Implements LSb-First reader and writer for reading/writing arbitrary bit width | ||
// integers from/to normal go byte streams. | ||
// An example use case is Vorbis coding. | ||
// Note that this implementation is completely unoptimized. | ||
// The Writer needs to cache the byte it is about write, so FlushByte() must be | ||
// called to ensure the stream is re-aligned to 8bits and all data is written. | ||
package bitio | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
// Writes individual bits. | ||
// Bit order: LSb-First | ||
type Writer struct { | ||
io.Writer | ||
|
||
totalWritten int | ||
bitBuf uint8 | ||
bitBufLen uint8 | ||
} | ||
|
||
func NewWriter(w io.Writer) *Writer { | ||
return &Writer{Writer: w} | ||
} | ||
|
||
// n may be inaccurate if writing fails within byte | ||
// boundaries. | ||
func (w *Writer) Write(p []byte) (n int, err error) { | ||
for _, b := range p { | ||
if _, err := w.WriteBits(uint64(b), 8); err != nil { | ||
return n, err | ||
} | ||
n++ | ||
} | ||
return | ||
} | ||
|
||
func (w *Writer) WriteBit(b bool) error { | ||
if b { | ||
w.bitBuf |= 1 << w.bitBufLen | ||
} | ||
w.bitBufLen++ | ||
w.totalWritten++ | ||
|
||
if w.bitBufLen == 8 { | ||
if err := w.FlushByte(); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// Writes nb bits of b in LSb-First order. | ||
// Returns number of bits successfully written. | ||
func (w *Writer) WriteBits(b uint64, nb uint8) (n int, err error) { | ||
if nb >= 64 { | ||
panic("attempt to write more than 64 bits of uint64") | ||
} | ||
for i := uint8(0); i < nb; i++ { | ||
if err := w.WriteBit((b & (1 << i)) != 0); err != nil { | ||
return int(i), err | ||
} | ||
} | ||
return n, nil | ||
} | ||
|
||
// Arg format is: value, nBits, value, nBits... | ||
// Returns number of bits successfully written. | ||
func (w *Writer) WriteBitsMany(args ...uint64) (n int, err error) { | ||
if len(args)&1 != 0 { | ||
panic("expected even number of arguments") | ||
} | ||
for i := 0; i < len(args)/2; i++ { | ||
nb := args[2*i+1] | ||
if nb >= 64 { | ||
panic("attempt to write more than 64 bits of uint64") | ||
} | ||
nw, err := w.WriteBits(args[2*i], uint8(nb)) | ||
if err != nil { | ||
return n, err | ||
} | ||
n += nw | ||
} | ||
return | ||
} | ||
|
||
func (w *Writer) FlushByte() error { | ||
if w.IsAligned() { | ||
return nil | ||
} | ||
b := [1]byte{w.bitBuf} | ||
if _, err := w.Writer.Write(b[:]); err != nil { | ||
return err | ||
} | ||
w.bitBuf = 0 | ||
w.bitBufLen = 0 | ||
return nil | ||
} | ||
|
||
// Returns true if the writer is currently 8-bit aligned | ||
// (and thus flushing will do nothing). | ||
func (w *Writer) IsAligned() bool { | ||
return w.bitBufLen == 0 | ||
} | ||
|
||
func (w *Writer) BitsWritten() int { | ||
return w.totalWritten | ||
} | ||
|
||
// Reads individual bits. | ||
// Bit order: LSb-First | ||
type Reader struct { | ||
io.Reader | ||
|
||
totalRead int | ||
bitBuf uint8 | ||
bitBufLen uint8 | ||
} | ||
|
||
func NewReader(r io.Reader) *Reader { | ||
return &Reader{Reader: r} | ||
} | ||
|
||
// n may be inaccurate if reading fails within byte | ||
// boundaries. | ||
func (r *Reader) Read(p []byte) (n int, err error) { | ||
for n < len(p) { | ||
v, _, err := r.ReadBits(8) | ||
if err != nil { | ||
return n, err | ||
} | ||
p[n] = uint8(v) | ||
n++ | ||
} | ||
return | ||
} | ||
|
||
func (r *Reader) ReadBit() (bool, error) { | ||
if r.bitBufLen == 0 { | ||
var buf [1]byte | ||
if _, err := r.Reader.Read(buf[:]); err != nil { | ||
return false, err | ||
} | ||
r.bitBuf = buf[0] | ||
r.bitBufLen = 8 | ||
} | ||
|
||
r.totalRead++ | ||
r.bitBufLen-- | ||
return (r.bitBuf & (0x80 >> r.bitBufLen)) != 0, nil | ||
} | ||
|
||
func (r *Reader) ReadBits(nb uint8) (val uint64, n int, err error) { | ||
if nb >= 64 { | ||
panic("attempt to read more than 64 bits into uint64") | ||
} | ||
var res uint64 | ||
for i := uint8(0); i < nb; i++ { | ||
b, err := r.ReadBit() | ||
if err != nil { | ||
return 0, int(i), err | ||
} | ||
if b { | ||
res |= 1 << i | ||
} | ||
} | ||
return res, int(nb), nil | ||
} | ||
|
||
// Returns true if the reader is currently 8-bit aligned | ||
// (and thus is in sync with the underlying reader) | ||
func (r *Reader) IsAligned() bool { | ||
return r.bitBufLen == 0 | ||
} | ||
|
||
func (r *Reader) BitsRead() int { | ||
return r.totalRead | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package bitio_test | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/xypwn/filediver/bitio" | ||
) | ||
|
||
func TestBitio(t *testing.T) { | ||
b := &bytes.Buffer{} | ||
|
||
// Writing | ||
w := bitio.NewWriter(b) | ||
if _, err := w.WriteBits(0b1100, 4); err != nil { | ||
t.Error(err) | ||
} | ||
if _, err := w.WriteBits(0b111, 3); err != nil { | ||
t.Error(err) | ||
} | ||
if _, err := w.WriteBits(0b0010001, 7); err != nil { | ||
t.Error(err) | ||
} | ||
if _, err := w.WriteBitsMany( | ||
0b1101100111001, 13, | ||
0b00000, 5, | ||
); err != nil { | ||
t.Error(err) | ||
} | ||
if !w.IsAligned() { | ||
t.Error("expected w to be byte-aligned") | ||
} | ||
|
||
// Reading | ||
r := bitio.NewReader(b) | ||
if v, _, err := r.ReadBits(8); err != nil { | ||
t.Error(err) | ||
} else if v != 0b11111100 { | ||
t.Errorf("unexpected value: %08b", v) | ||
} | ||
if v, _, err := r.ReadBits(7); err != nil { | ||
t.Error(err) | ||
} else if v != 0b1001000 { | ||
t.Errorf("unexpected value: %07b", v) | ||
} | ||
if v, _, err := r.ReadBits(9); err != nil { | ||
t.Error(err) | ||
} else if v != 0b110011100 { | ||
t.Errorf("unexpected value: %09b", v) | ||
} | ||
if v, _, err := r.ReadBits(8); err != nil { | ||
t.Error(err) | ||
} else if v != 0b00000110 { | ||
t.Errorf("unexpected value: %08b", v) | ||
} | ||
if !r.IsAligned() { | ||
t.Error("expected r to be byte-aligned") | ||
} | ||
|
||
// Alignment and flushing | ||
if _, err := w.WriteBits(0b1111, 4); err != nil { | ||
t.Error(err) | ||
} | ||
if w.IsAligned() { | ||
t.Error("expected w to not be byte-aligned") | ||
} | ||
if err := w.FlushByte(); err != nil { | ||
t.Error(err) | ||
} | ||
if !w.IsAligned() { | ||
t.Error("expected w to be byte-aligned") | ||
} | ||
if v, _, err := r.ReadBits(6); err != nil { | ||
t.Error(err) | ||
} else if v != 0b001111 { | ||
t.Errorf("unexpected value: %06b", v) | ||
} | ||
if r.IsAligned() { | ||
t.Error("expected r to not be byte-aligned") | ||
} | ||
} |
Oops, something went wrong.