Documentation
¶
Overview ¶
Package pklite decompresses MS-DOS executables that were packed with PKWARE's PKLITE.
PKLITE was released in 1990 by PKWARE as an executable packer. Unlike the legacy ZIP methods in the sibling packages (unshrink, explode, expand), PKLITE is not a ZIP compression method and has no method ID, so it cannot be registered with archive/zip. Instead it is a stand-alone decompressor that takes a packed file and returns the original executable.
PKLITE compressed .COM files (v1.00 to v2.01) and .EXE files of v1.05 to v1.12 are supported. The EXE support is limited to the large and small compression, scrambled decompressors and v1.20 files are not yet supported.
The compression is an LZ77 variant, with 16-bit little-endian bit words that are consumed from the least significant bit, and static Huffman codes for the match lengths and offsets. The format was documented by Jason Summers in the MIT licensed Deark project, which this package is based on.
Example ¶
Example demonstrates unpacking a PKLITE compressed COM file.
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/Defacto2/archive/pklite"
)
func main() {
data, err := os.ReadFile(filepath.Join("testdata", "D2_V115.COM"))
if err != nil {
fmt.Println(err)
return
}
out, err := pklite.Decompress(data)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%d bytes packed, %d bytes unpacked\n", len(data), len(out))
}
Output: 877 bytes packed, 4176 bytes unpacked
Index ¶
Examples ¶
Constants ¶
const (
// MaxSize is the maximum number of bytes that Decompress will return.
MaxSize = 1 << 20
)
Variables ¶
var ( ErrNotPKLITE = errors.New("pklite: not a supported compressed file") ErrCorrupt = errors.New("pklite: corrupt compressed data") ErrTruncated = errors.New("pklite: unexpected end of compressed data") )
var ErrUnsupported = errors.New("pklite: unsupported variant")
Functions ¶
func Decompress ¶
Decompress returns the original executable from a PKLITE compressed COM or EXE file.
Types ¶
This section is empty.