简体   繁体   English

重新创建基于序列化字节数组的类

[英]Recreate Class based on Serialized Byte Array

I would like to ask this Question. 我想问这个问题。 I have not found anything on google about this. 我还没有在Google上找到关于此的任何信息。

Is there a way to recreate a class based on a serialized byte array? 有没有一种方法可以基于序列化的字节数组重新创建类? I know that it is a serialized object. 我知道这是一个序列化的对象。 That was created from a c++ object. 那是从c ++对象创建的。 But I don't know anything about the object itself. 但是我对对象本身一无所知。

I think I could recreate the structure of the object by myself, but it would be much work. 我想我可以自己重新创建对象的结构,但这将是很多工作。 So is there a way to automate the analysis of a byte serialized object? 那么,有没有一种方法可以自动分析字节序列化对象?

Otherwise I would have to go through every byte by hand and try to convert it info an int, float, string, ... by hand. 否则,我将不得不手工遍历每个字节并尝试将其转换为int,float,string等信息。

I would really appreciate your help, i know i was not specific, but here is an example: 我真的很感谢您的帮助,我知道我并不具体,但是这里有一个例子:

00000000  10 10 00 00 03 E3 00 2B  00 0C 36 BE 4F 56 31 00  .......+..6.OV1.
00000010  00 86 00 00 00 00 00 00  00 00 00 00 03 6B 67 6B  .............kgk
00000020  6B 6B 6B 6B 6B 6B AB 5D  C4 28 D3 4B 77 29 D0 6E  kkkkkk.].(.Kw).n
00000030  EB 54 6B 6B 6B 6B 6B 6B  6B 6B 64 43 FF 2E 9F A5  .TkkkkkkkkdC....
00000040  13 28 B2 BC F7 2E EB 1F  76 29 6C 5B 72 2A 6B 6B  .(......v)l[r*kk
00000050  6B 6B 6B 6B 6B 6B 6C AC  A5 2A 6B 6B A3 29 6B 94  kkkkkkl..*kk.)k.
00000060  6E 6B 6F 6B 6B 6B E2 3E  A6 6B 6B 6B 6B 6B 6E 75  nkokkk.>.kkkkknu
00000070  FF 2E 65 F9 E7 28 6F 8F  F7 2E 96 49 FF 2E AF 17  ..e..(o....I....
00000080  E7 28 88 B6 F7 2E                                 .(....          

Thanks in advance. 提前致谢。

Addition: It should contain at least 6 Float values. 加法:它至少应包含6个浮点值。 Position (x,y,z) and Viewpoint coordinates (x,y,z,angle). 位置(x,y,z)和视点坐标(x,y,z,角度)。 The Coordinates would be sent as float values. 坐标将作为浮点值发送。 Additionally there would be at least two strings included that would be exactly 4 characters long. 另外,将包括至少两个字符串,它们的长度恰好为4个字符。

Addition2: I do not know how it is serialized or with what. Addition2:我不知道它是如何序列化的或者是什么。 I can only tell you what has to be in there. 我只能告诉你那里有什么。 Also I am looking for a way to automatically convert it into a data structure that is readable. 我也在寻找一种自动将其转换为可读数据结构的方法。 Is there any way to try and convert the bytes and check if the output value makes any sense, and do this automated? 有什么方法可以尝试转换字节并检查输出值是否有意义,并且可以自动执行吗?

Addition3: I do not know how the c++ class looks like, I do not have access to it. Addition3:我不知道c ++类的外观,我无法访问它。

It is possible to serialize in C#. 可以在C#中进行序列化。 (Check this out for more information.) However, it won't work by going from C++ to C#. (检查出以获取更多信息。)但是,它不会从C ++将C#工作。 However, all you need to do is setup a protocol/standard... Then have your class in C# read in (using BinaryReader or something) the byte[] and build the class that way. 但是,您所需要做的就是设置协议/标准...然后让C#中的类读入(使用BinaryReader或其他方法) byte[]并以此方式构建类。

There is no an easy answer to your question because there is no default C++ binary serialization format like in .NET. 您的问题没有简单的答案,因为没有像.NET中那样的默认C ++二进制序列化格式。 Hence you will have to make binary reverse engineering of this data. 因此,您将不得不对该数据进行二进制逆向工程。

Because you said a class contains at least few floating points along with two strings, I would start from serializing similar class with one string and float field with two typical C++ serialization libraries: 因为您说过一个类至少包含几个浮点数和两个字符串,所以我将从使用一个字符串序列化相似的类和使用两个典型的C ++序列化库序列化float字段开始:

and compare with your data. 并与您的数据进行比较 If you know the values stored in sample data, try to find them and compare with similar data from those serializers. 如果您知道样本数据中存储的值,请尝试查找它们并与那些序列化器中的类似数据进行比较。

However, answering your main questions, automatic tools do exists that can help you. 但是,在回答您的主要问题时, 确实存在可以帮助您的自动工具 I would start from searching for automated protocol analysis because most of the work and tools are related to network protocols analysis - which is similar to your problems as both tries to understand unknown structure of binary data. 我将从搜索自动化协议分析开始,因为大多数工作和工具都与网络协议分析相关-与您的问题类似,因为两者都试图理解二进制数据的未知结构。 Nevertheless, most tools I've seen so far were more academical one, like Polyglot , The Protocol Informatics Project or PROTOS . 不过,到目前为止,我所见过的大多数工具都是学术性更高的工具,例如PolyglotProtocol Informatics ProjectPROTOS If you are happy to have Mac OS X based system, you can use great Synalaze It! 如果您很高兴拥有基于Mac OS X的系统,则可以使用出色的Synalaze It! tool to help you a little. 工具可以帮助您一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM