简体   繁体   中英

Recreate Class based on Serialized Byte Array

I would like to ask this Question. I have not found anything on google about this.

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. 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.

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. Position (x,y,z) and Viewpoint coordinates (x,y,z,angle). The Coordinates would be sent as float values. Additionally there would be at least two strings included that would be exactly 4 characters long.

Addition2: I do not know how it is serialized or with what. 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.

It is possible to serialize in C#. (Check this out for more information.) However, it won't work by going from C++ to 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.

There is no an easy answer to your question because there is no default C++ binary serialization format like in .NET. 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:

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 . If you are happy to have Mac OS X based system, you can use great Synalaze It! tool to help you a little.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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