keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
857 stars 133 forks source link

[HELP] looking for string tokens inside binary file - how to do this when length is unknown? #221

Closed openstepmedia closed 1 year ago

openstepmedia commented 1 year ago

Hi! Thank you very much for this terrific library.

I am trying to understand if I can use this library to parse string tokens found in a binary file. The file I'm looking at is similar to .avi in that it is a media container, but it is not .avi format. In the file header I see this information:

HGCRLCRS       meta#bgn    <?xml version="1.0" encoding="utf-8"?><Root><META><AUDIO USECHNL="1023"><FMTNAME><![CDATA[Speex, 23.8 kBit/s, 16.0 kHz, Mono, Q7]]></FMTNAME><FMTDATA>
...
...
</PASSOVE></CRYPT></META></Root>meta#end

I am attempting to extract out the data that is embedded in the header as in the example above. So I am trying to collect all the data between the tokens: meta#bgn and meta#end

Is this possible with binary-parser?

Thanks!

keichi commented 1 year ago

Are you sure the offset and/or length of the metadata is not stored in the file header? Usually, a file header should have a fixed format. The assumption of this library is that the structure of the binary data is known.

openstepmedia commented 1 year ago

Thanks for you help. Unfortunately I don't see evidence of a fixed format. The file I'm looking at does not follow an open documented standard.

keichi commented 1 year ago

I see, in that case binary-parser isn't a good fit since it doesn't provide a feature to search for arbitrary patterns in a binary.