Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:26:47+00:00 2026-06-13T12:26:47+00:00

I have a C++ application which is sending a serialized struct to my C#

  • 0

I have a C++ application which is sending a serialized struct to my C# app, and I would like to automatically copy the bytes directly to a new struct I created in C#. However, the struct sent over the network seems to have 3-byte blocks, which seems quite weird.

Here is C++ struct:

typedef struct ATTQueryAgentStateConfEvent_t {
  ATTWorkMode_t workMode;  /* enum type */
  ATTTalkState_t talkState;  /* enum type */
  long reasonCode;
  ATTWorkMode_t pendingWorkMode;   /* enum type */
  long pendingReasonCode;
} ATTQueryAgentStateConfEvent_t;

The struct I created in C#:

[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct ATTQueryAgentStateConfEvent_t
{
    public ATTWorkMode_t workMode;  /* enum type */
    public ATTTalkState_t talkState;  /* enum type */
    public long reasonCode;
    public ATTWorkMode_t pendingWorkMode;  /* enum type */
    public long pendingReasonCode;
};

And here are the bytes received from C++ app (the first 6 bytes seem to be some header):

02 00 68 00 30 0f 0a 01 03 0a 01 01 02 01 00 0a 01 ff 02 01 00
                        ^^       ^^       ^^       ^^       ^^

Above I have marked the values I am expecting to receive (3, 1, 0, -1, 0). I have experimented with different Pack values when defining the C# struct, but it is simply not parsed correctly. This is the command I am using to fill the struct in C#:

ATTQueryAgentStateConfEvent_t stateDetails = (ATTQueryAgentStateConfEvent_t)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(confPrivData.data, 6), typeof(ATTQueryAgentStateConfEvent_t));

Am I doing something wrong, or this C++ app is using some custom serializer? I would expect C++ enums and longs to be 4 bytes… I know I can extract the values byte by byte, but I would like to automate it, if possible. Thanks for any tips.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:26:48+00:00Added an answer on June 13, 2026 at 12:26 pm

    As said in my comment you gave no information about what serializer is being used. However, the format reminds me of Abstract Syntax Notation One (ASN1) and the example stream given is actually valid, i.e. type IDs match those specified in ASN1 (30 = SEQUENCE, 02 = INTEGER, …) You should find plenty of libraries being able to deserialize ASN1 streams, but I have no experience about C#, so I can’t give you any suggestion at this point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which I would like to enable push notifications on. I
I have an application which logs in into a webservice. I start a new
I have an application App2 to which I am sending a POST request from
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I have an application which requires sending sms from one user to another.On receiving
I have to make a newsletter sending utility application which will collect the list
I have an application which is sending me JSON object. Now I want to
I have a client application which is sending a request to a server. Server
I have a simple mail sending application which runs in python using Django. After
I have a facebook application which I communicate directly with users via email. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.