Michel D Michel D - 3 months ago 8
Vb.net Question

What is the type of this 4-byte data?

So I've got this piece of data here I'm trying to edit with a program.

The data consists of 2 single floats, then two unknown 4-byte data types and lastly a 32 bit int.

Here's the data in hex:

00 00 C8 41 00 00 70 41 00 20 00 00 7D 12 00 00 0A 00 00 00


After conversion they should be these numbers:

25.0 (float)
15.0 (float)
45 (???)
16 (???)
10 (int)


Please tell me what I'm missing or how to convert this.

Note: I'm just trying to convert the 2 unknown 4 byte data. I know how to convert integers and floats.

Edit: Here are some more known values of the same type:

00 40 00 00 -> 90
E3 18 00 00 -> 35
00 00 01 00 -> 360
55 15 00 00 -> 30


It has to do with angles/degrees of some kind.

Thanks

Answer

It's really not clear what you have done and what is needed to be done. Based on this question. You can convert your byte using System.BitConverter. Are you sure it's 16 and not 26 for your second angle?

    Dim data() As Byte = {&H0, &H0, &HC8, &H41, &H0, &H0, &H70, &H41, &H0, &H20, &H0, &H0, &H7D, &H12, &H0, &H0, &HA, &H0, &H0, &H0}

    Dim f1 As Single = System.BitConverter.ToSingle(data, 0)
    Dim f2 As Single = System.BitConverter.ToSingle(data, 4)
    Dim s1 As Int32 = CDbl(System.BitConverter.ToInt32(data, 8)) / 65536 * 360
    Dim s2 As Int32 = CDbl(System.BitConverter.ToInt32(data, 12)) / 65536 * 360
    Dim s3 As Int32 = System.BitConverter.ToInt32(data, 16)

Then you just need to do the reverse to get your bytes

    s1 = 180.0 / 360 * 65536

    Dim bytes() As Byte = System.BitConverter.GetBytes(s2)

    For Each b As Byte In bytes
        Console.Write(b.ToString("x"))
    Next

Now if your problem is opening the file, write the file or something else. Than it wasn't very clear to me.

Comments