payload_extract_go

package module
v0.0.0-...-5457ca2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

README

Payload Extract

Golang android payload extraction, another python impl here:payload_extract_py

Function

  • Support print payload informatoin
  • Support extract from zip or url rom file
  • Multi thread support
  • Native c lzma decompress performance

Build

Native

  • Install gcc
    example on archlinux:
sudo pacman -S gcc base-devel
  • Build
go build -ldflags="-s -w" -trimpath -o payload_extract_go cmd/main.go

Example build for windows on archlinux

  • Install mingw32
sudo pacman -S mingw-w64-gcc
  • Install vcpkg and setup liblzma
vcpkg install --triplet=x64-mingw-static liblzma
  • Build with cross toolchain Example build for windows:
export GOOS=windows
export GOARCH=amd64
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
export CGO_ENABLED=1

cmake -B build -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DSTATIC=ON \
  -DVCPKG_HOME=/path/to/vcpkg \
  -DVCPKG_TARGET_TRIPLET=x64-mingw-static \
  -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build

# output:build/payload_extract_go.exe

Usage

Usage of ./main:
  -P    do not extract, print partitions info
  -T int
        thread pool workers (default 12)
  -X value
        extract partitions
  -i string
        input payload bin/zip/url
  -o string
        output directory (default "out")

proto copied from

Thanks

Documentation

Index

Constants

View Source
const PAYLOAD_MAGIC = "CrAU"

Variables

View Source
var Logger = log.New(log.Writer(), "payload_extract:", log.Flags())

Functions

func BadPayload

func BadPayload(msg any) error

func ExtractPartitionsFromPayload

func ExtractPartitionsFromPayload(
	reader io.ReadSeeker,
	partitions_name []string,
	out_dir string,
	max_workers int,
)

func InitPayloadInfo

func InitPayloadInfo(reader io.ReadSeeker) (*update_engine.DeltaArchiveManifest, error)

func PrintPartitionsInfo

func PrintPartitionsInfo(manifest *update_engine.DeltaArchiveManifest, partitions_name []string)

Types

type PayloadHdr

type PayloadHdr struct {
	Magic          [4]byte
	Version        uint64
	ManifestLen    uint64
	ManifestSigLen uint32
}

func (*PayloadHdr) Decode

func (p *PayloadHdr) Decode(data []byte) error

func (*PayloadHdr) HdrSize

func (p *PayloadHdr) HdrSize() int

type ReaderAtCloser

type ReaderAtCloser interface {
	ReadAt([]byte, int64) (int, error)
	Close() error
}

type UrlRangeReaderAt

type UrlRangeReaderAt struct {
	// contains filtered or unexported fields
}

UrlRangeReaderAt reads data from a URL supporting HTTP Range requests. It implements io.ReaderAt and attempts to reuse the underlying HTTP stream for consecutive ReadAt calls to improve performance on sequential patterns.

func NewUrlRangeReaderAt

func NewUrlRangeReaderAt(url string) *UrlRangeReaderAt

NewUrlRangeReaderAt creates a new UrlRangeReaderAt for the given URL. It uses a default http.Client.

func (*UrlRangeReaderAt) Close

func (r *UrlRangeReaderAt) Close() error

func (*UrlRangeReaderAt) ReadAt

func (r *UrlRangeReaderAt) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements the io.ReaderAt interface. It reads len(p) bytes from the URL starting at byte offset off. It attempts to reuse the internal stream if 'off' is contiguous with the end of the previous read from the stream.

func (*UrlRangeReaderAt) Size

func (r *UrlRangeReaderAt) Size() int64

type ZipPayloadReader

type ZipPayloadReader struct {
	// contains filtered or unexported fields
}

func NewZipPayloadReader

func NewZipPayloadReader(reader io.ReaderAt, size int64) (*ZipPayloadReader, error)

func (*ZipPayloadReader) Close

func (r *ZipPayloadReader) Close() error

func (*ZipPayloadReader) Read

func (r *ZipPayloadReader) Read(p []byte) (int, error)

func (*ZipPayloadReader) ReadAt

func (r *ZipPayloadReader) ReadAt(p []byte, off int64) (int, error)

func (*ZipPayloadReader) Seek

func (r *ZipPayloadReader) Seek(off int64, whence int) (int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL