467,894 Members | 1,585 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,894 developers. It's quick & easy.

Serializing a data buffer from C++

I am relatively new to C# and .Net in general, but have been programming in
many other languages for more years than I want to recall.

I have a problem where an existing set of code (actually a Windows kernel
component developed by a company I do some work for) is returning
information to user space in the buffer from an IOCTL call in a 'streaming'
format that mixes variable length strings, 8-, 16-, 32-, and 64-bit integer
values. The code currently adds NULL bytes to force some alignment just to
keep some other code happy, but this can easily be removed if not needed.
The buffer contains some fixed header fields followed by zero or more 'rows'
or records, which are each variable length due to the fact that they contain
variable length strings.

<ReportID>
<ContextID>
<Record Count>
<More?>
NULL

<Record Length>
<String Data>
NULL
NULL

<Integer Value>
<Integer Value>

<Timestamp>

<String Data>
NULL
NULL
NULL

<IntegerValue>
<Record Length
<String Data>

<continued>

<continued>
NULL

<Integer Value>
<Integer Value>

<Timestamp>

<String Data>

<continued>

<continued>
NULL

<Integer Value>
NULL
NULL
NULL
NULL

I basically want to extract this information field by field and then use the
information to populate a DataSet, making the rows of data look like
information retrieved as if from a database query. I asked some people about
this and they indicated that serialization was the proper approach, but I am
not certain if I follow this.

Do I have to create two (2) classes, one for the header information and one
for the row data, and make each serializable?

The problem that I see is that the serialization process adds contextual
information for each data value being written serialized and the deserializa
tion process requires this information to be present in the stream that is
being read. All of the methods used to retrieve fields from the
SerializationInfo structure seem to require that I identify the field
information in some manner, which implies that this may be some sort of XML
object rather than a raw binary stream.

In my case all that I have is raw data! Presuming that all I have is a
buffer address for the beginning of the buffer above, how can I extract the
individual fields and then use them? I am will to create a class to hold the
retrieved values, but I would then need to use a different offset into the
buffer for each instance of these class objects.

-Ken
Nov 16 '05 #1
  • viewed: 1763
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aleksei Guzev | last post: by
10 posts views Thread by copx | last post: by
2 posts views Thread by Tobias Zimmergren | last post: by
reply views Thread by Ken Allen | last post: by
6 posts views Thread by Marco Herrn | last post: by
reply views Thread by olsonchris | last post: by
6 posts views Thread by Kyle Teague | last post: by
12 posts views Thread by Cagdas Ozgenc | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.