Questions tagged [kaitai-struct]

Kaitai Struct is a declarative language used to describe binary data structures.

Kaitai Struct is a DSL (domain-specific language), designed to describe binary data structures in human- and machine-readable way. Description of certain structure ("format") can be written once and then translated using a compiler into a source code for supported programming languages — and then used from any program in that language.

44 questions
1
vote
1 answer

Referencing Kaitai Struct file (ksy) in external ksy file in Kaitai Struct

I am trying to achieve files structuring in Kaitai Struct, means that I need to create ksy file can be referenced by another ksy file, so when i compile to my target language (java in my case) the java code will be optimized and reusing the commonly…
Ossama
  • 45
  • 3
1
vote
1 answer

Passing array parameter to Kaitai Struct user defined type

I'm trying Kaitai Struct to decode some data. I need to pass an array parameter, but ksc gives an error. Follow is an example code: meta: id: cat_34 seq: - id: test1 type: fixed([0,1,2]) types: fixed: params: - id: f_size …
Luis Peq
  • 13
  • 3
1
vote
1 answer

Referencing enums in external file in Kaitai Struct

I'd like to have a Kaitai Struct ksy file which references some enums and types in different external files. In the external files there I'd like to have only subtypes and enums definitions. This is the test file (test.ksy) that references the…
Rexxowski
  • 160
  • 10
1
vote
1 answer

Capture a three bytes two's complement signed integer with Kaitai

Kaitai Struct offers predefined types to capture, for example, signed 2-bytes integers (s2be) or signed 4-bytes integers (s4be) but there is no s3be and b24 captures 3-bytes unsigned integer…
Gab
  • 99
  • 2
  • 5
1
vote
1 answer

kaitai instance value ternary: can't combine output types

I've created a Kaitai Struct .ksy for two very similar Digilent log file formats. The second format (openlogger) is an extension of the first (openscope) with two additional fields in the struct. The scope is basically a single-channel logger; the…
Ben L
  • 192
  • 1
  • 7
1
vote
1 answer

What are the parser techniques implemented in kaitai struct? Does it implement backtracking?

I have to deal with a buffer of bytes. This buffer can have multiple grammars (A, B, C, .. , etc). For example: AxxxxBxxxxACxxx where x's are dirty bytes and I would like to skip them. (They don't match any grammar) I want to know if it is possible…
1
vote
1 answer

Call external code to determine number of times to repeat expression

I have a sequence that has an 'id' with a repeat expression that I need to repeat an unknown number times, and I'm not sure if this is currently supported. data_channels: seq: - id: fast_data type: u2 repeat: expr …
rhoward99
  • 15
  • 2
1
vote
1 answer

Exception in Kaitai Struct Code " java.nio.BufferUnderflowException"

I very newer to kaitai-struct and java. i have parsed .ksy file to target language java,, but after compiling in eclipse ide i am getting " java.nio.BufferUnderflowException". can someone help me.
1
vote
2 answers

Using ternary operator to calculate the length

I have a binary structure that has a length field in bits and the value field corresponding to that length. The value length is filled up with enough trailing bits to make the end of the field fall on an octet boundary. I need to calculate that that…
Sergii Bishyr
  • 8,331
  • 6
  • 40
  • 69
0
votes
0 answers

Taking a value of a TLV entry for later use within the kaitai-struct spec

Intro I am writing a EA BNK file format spec in kaitai-struct. The format is more fully described here, but I'll summarize the most relevant parts. The BNK file is basically an archive that may contain multiple sounds. Each sound entry in the BNK…
bluv
  • 126
  • 6
0
votes
1 answer

Kaitai struct - change default endianness based on a condition in the file

I'm dealing with files from two versions of a video game - one for the PC, one for the PS3. It's possible to tell which version of the game that a certain file comes from if the first four 4 bytes of the header - if struct.unpack_from("
vardonir
  • 135
  • 9
0
votes
0 answers

Kaitai Struct: how to remove 0 offsets from the array?

I have probably an ancient .ksy template seq: - {id: id_magic, type: u4} - {id: version, type: u2} - {id: num_blocks, type: u2} - {id: block_offsets, type: u4, repeat: expr, repeat-expr: num_blocks} The block_offsets get offset for…
0
votes
1 answer

datatype as parameter in kaitai (create generic kaitai type)

let's say I have the following two types: types: arrayf4: params: - id: size type: u4 seq: - id: member type: f4 repeat: expr repeat-expr: size arrays2: params: - id: size …
Serhii
  • 355
  • 2
  • 11
0
votes
0 answers

How to extract offset and byte run from the kaitai struct

An example of the table I am trying to extract offset, byte run and description from the kaitai struct template for that I have. How do I go about proceeding with it?
0
votes
1 answer

Get a flat map of all types from kaitai struct

I generated a simple parser in python with kaitai struct. Now I would like to achieve something similar that the kaitai web ide does in the hex view (https://ide.kaitai.io/devel/) to map the types to a binary byte by byte. How can I use the parser…
Fee
  • 719
  • 9
  • 24