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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:31:55+00:00 2026-06-18T07:31:55+00:00

I’m currently trying to get this C code converted into C#. Since I’m not

  • 0

I’m currently trying to get this C code converted into C#.
Since I’m not really familiar with C I’d really apprecheate your help!

static unsigned char byte_table[2080] = {0};

First of, some bytearray gets declared but never filled which I’m okay with

BYTE* packet = //bytes come in here from a file
int unknownVal = 0;
int unknown_field0 = *(DWORD *)(packet + 0x08);
do
{
    *((BYTE *)packet + i) ^= byte_table[(i + unknownVal) & 0x7FF];
    ++i;
}
while (i <= packet[0]);

But down here.. I really have no idea how to translate this into C#
BYTE = byte[] right?

DWORD = double?
but how can (packet + 0x08) be translated? How can I add a hex to a bytearray? Oo

I’d be happy about anything that helps! 🙂

  • 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-18T07:31:56+00:00Added an answer on June 18, 2026 at 7:31 am

    In C, setting any set of memory to {0} will set the entire memory area to zeroes, if I’m not mistaken.

    That bottom loop can be rewritten in a simpler, C# friendly fashion.

    byte[] packet = arrayofcharsfromfile;
    int field = packet[8]+(packet[9]<<8)+(packet[10]<<16)+(packet[11]<<24); //Assuming 32 bit little endian integer
    int unknownval = 0;
    int i = 0;
    
    do //Why waste the newline? I don't know. Conventions are silly!
    {
        packet[i] ^= byte_table[(i+unknownval) & 0x7FF];
    } while( ++i <= packet[0] );
    

    field is set by taking the four bytes including and following index 8 and generating a 32 bit int from them.

    In C, you can cast pointers to other types, as is done in your provided snippet. What they’re doing is taking an array of bytes (each one 1/4 the size of a DWORD) and adding 8 to the index which advances the pointer by 8 bytes (since each element is a byte wide) and then treating that pointer as a DWORD pointer. In simpler terms, they’re turning the byte array in to a DWORD array, and then taking index 2, as 8/4=2.

    You can simulate this behavior in a safe fashion by stringing the bytes together with bitshifting and addition, as I demonstrated above. It’s not as efficient and isn’t as pretty, but it accomplishes the same thing, and in a platform agnostic way too. Not all platforms are little endian.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.