1
0
mirror of https://github.com/garraflavatra/go-fmp.git synced 2025-06-28 04:25:11 +00:00

Start at offset 8192

This commit is contained in:
2025-06-13 22:17:32 +02:00
parent 193f23a20c
commit b44c90da30
2 changed files with 9 additions and 3 deletions

View File

@ -41,6 +41,7 @@ func OpenFile(path string) (*FmpFile, error) {
ctx.numSectors = uint64((ctx.FileSize / sectorSize) - 1) ctx.numSectors = uint64((ctx.FileSize / sectorSize) - 1)
ctx.Sectors = make([]*FmpSector, 0) ctx.Sectors = make([]*FmpSector, 0)
currentPath := make([]uint64, 0) currentPath := make([]uint64, 0)
ctx.stream.Seek(2*sectorSize, io.SeekStart)
for { for {
sector, err := ctx.readSector() sector, err := ctx.readSector()
@ -99,7 +100,7 @@ func (ctx *FmpFile) readHeader() error {
} }
func (ctx *FmpFile) readSector() (*FmpSector, error) { func (ctx *FmpFile) readSector() (*FmpSector, error) {
println("------- Reading sector", ctx.currentSectorID) println("---------- Reading sector", ctx.currentSectorID)
buf := make([]byte, sectorHeaderSize) buf := make([]byte, sectorHeaderSize)
n, err := ctx.stream.Read(buf) n, err := ctx.stream.Read(buf)

View File

@ -1,6 +1,7 @@
package fmp package fmp
import ( import (
"encoding/hex"
"fmt" "fmt"
"io" "io"
) )
@ -10,7 +11,11 @@ func (sect *FmpSector) readChunks() error {
panic("chunks already read") panic("chunks already read")
} }
for { for {
pos := sect.ID*sectorSize - uint64(len(sect.Payload)) pos := (sect.ID+1)*sectorSize - uint64(len(sect.Payload))
if sect.Payload[0] == 0x00 && sect.Payload[1] == 0x00 {
break
}
chunk, err := sect.readChunk(sect.Payload) chunk, err := sect.readChunk(sect.Payload)
if chunk == nil { if chunk == nil {
@ -24,7 +29,7 @@ func (sect *FmpSector) readChunks() error {
break break
} }
if err != nil { if err != nil {
println(string(sect.Payload)) println(hex.EncodeToString(sect.Payload))
println("break2") println("break2")
return err return err
} }