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 3996634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:18:11+00:00 2026-05-20T07:18:11+00:00

Consider following structure where the length of both username and password is 17: struct

  • 0

Consider following structure where the length of both username and password is 17:

struct LoginPacket
{
    public int unk1;
    public string username;
    public string password;
}

Also this byte array

00 00 00 00 6A 6D 32 6D 65 00 72 00 7A 76 72 00 98 FD 18 00 A0 68 65 72 65 49 73
70 61 73 73 00 00 00 00 00 FF FF 31 2E 30 30 2E 30 30 00 00 00 C7 9D 72 00 04 00
00 31 2E 31 30 2E 32 37 00 0C 2C F6 24 16 2C F6 24 16

Is it possible to load this byte array into the above structure? There is something called Marshal, but it doesn’t quite work for me.

  • 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-05-20T07:18:11+00:00Added an answer on May 20, 2026 at 7:18 am

    Here you are, this answer uses the marshalling system in .NET. The structure itself contains the recipe on how to decipher a byte array. If you can’t do that, you need manual code.

    void Main()
    {
        byte[] bytes = new byte[]
        {
            0x00, 0x00, 0x00, 0x00, 0x6A, 0x6D, 0x32, 0x6D, 0x65, 0x00, 0x72, 0x00, 0x7A, 0x76, 0x72, 0x00, 0x98, 0xFD, 0x18, 0x00, 0xA0, 0x68, 0x65, 0x72, 0x65, 0x49, 0x73,
            0x70, 0x61, 0x73, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x2E, 0x30, 0x30, 0x2E, 0x30, 0x30, 0x00, 0x00, 0x00, 0xC7, 0x9D, 0x72, 0x00, 0x04, 0x00,
            0x00, 0x31, 0x2E, 0x31, 0x30, 0x2E, 0x32, 0x37, 0x00, 0x0C, 0x2C, 0xF6, 0x24, 0x16, 0x2C, 0xF6, 0x24, 0x16
        };
    
        var packet = BytesToStructure<LoginPacket>(bytes);
        packet.Dump();
    }
    
    static T BytesToStructure<T>(byte[] bytes)
    {
        int size = Marshal.SizeOf(typeof(T));
        if (bytes.Length < size)
            throw new Exception("Invalid parameter");
    
        IntPtr ptr = Marshal.AllocHGlobal(size);
        try
        {
            Marshal.Copy(bytes, 0, ptr, size);
            return (T)Marshal.PtrToStructure(ptr, typeof(T));
        }
        finally
        {
            Marshal.FreeHGlobal(ptr);
        }
    }
    
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet=CharSet.Ansi)]
    struct LoginPacket
    {
        public int unk1;
    
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=17)]
        public string username;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=17)]
        public string password;
    }
    

    When executed in LINQPad you get this:

    unk1: 0 
    username: jm2me 
    password: hereIspass
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

consider following: 1st APPROACH: public void f3() { f2(); f1(); } and this ...
Consider the following class structure: public class Foo<T> { public virtual void DoSomething() {
Consider the following structure: IEnumerable<IEnumerable<int>> collection = new[] { new [] {1, 2, 3},
Consider the following class hierarchy: public abstract class Entity { public virtual int Id
Please consider the following table structure (this is sample data, so please ignore the
Consider I have some big String in the following structure: parameter1|parameter2|parameter3|parameter4+\0 *Where parameter is
Consider the following string: No, @Username, I did not go to the supermarket yet
Consider the following directory structure: ROOT ------ images ............... logo.png ------ includes ............... vars.php
Consider the following data structure: List<Person> People; class Person { List<Car> Cars; List<Hobby> Hobbies;
consider my 'destinationURLLookUp.xml' file has the following structure <?xml version=1.0 encoding=UTF-8?> <destinationURLs xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> <destinationURL

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.