How to decode binary/raw google protobuf data
protoc --decode [message_name] [.proto_file_path] < [binary_file_path]
,
where
- [message_name] is the name of the message object in the .proto file. If the message is inside a package in the .proto file, use
package_name.message_name
. - [.proto_file_path] is the path to the .proto file where the message is defined.
- [binary_file_path] is the path to the file you want to decode.
Example for the situation in the question (assuming that my.proto
and b.bin
are in your current working directory):
protoc --decode header my.proto < b.bin
You used --decode_raw
correctly, but your input does not seem to be a protobuf.
For --decode
, you need to specify the type name, like:
protoc --decode header my.proto < b.bin
However, if --decode_raw
reports a parse error than --decode
will too.
It would seem that the bytes you extracted via gdb are not a valid protobuf. Perhaps your addresses aren't exactly right: if you added or removed a byte at either end, it probably won't parse.
I note that according to the addresses you specified, the protobuf is only 9 bytes long, which is only enough space for three or four of the fields to be set. Is that what you are expecting? Perhaps you could post the bytes here.
EDIT:
The 10 bytes you added to your question appear to decode successfully using --decode_raw
:
$ echo 08ffff01100840f7d438 | xxd -r -p | protoc --decode_raw
1: 32767
2: 8
8: 928375
Cross-referencing the field numbers, we get:
u1: 32767
u2: 8
u6: 928375