解码没有模式的protobuf [英] Decoding protobuf without schema
问题描述
是否可以使用工具或任何将二进制数据解码为可读格式的工具来解码没有模式的 protobuf 序列化文件?
Is it possible to decode protobuf serialized files without schema with tools or anything that would decode the binary data to readable format?
推荐答案
您经常可以推断架构.事实上,IIRC 这个protoc"工具有一组参数(--decode_raw
, iirc),它可以精确地做到这一点——做出明智的猜测.然而,这是一种猜测——格式不明确,因为多种不同类型的数据可以存储在相同的机制中——例如,一个长度为前缀的块可能是:
You can often deduce the schema. In fact, IIRC the "protoc" tool has a set of parameters (--decode_raw
, iirc) where it will do precisely that - making informed guesses. However, it is a guess - the format is ambiguous in that multiple different types of data can be stored in the same mechanisms - for example, a length-prefixed chunk could be:
- 一个子对象(任何用户类型)
- 一个压缩数组(各种原始类型)
- utf-8 字符串
- 一个原始字节[]
- 可能还有一些我忘记了
同样,一个 4 字节的固定宽度块可以是一个固定宽度的整数,也可以是一个浮点数;整数可以是有符号或无符号的.
Likewise, a 4-byte fixed-width chunk could be a fixed-width integer, or a float; the integer could be signed or unsigned.
这篇关于解码没有模式的protobuf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!