BYTE GetByte(char* sBuf, int& index)
    int t_index = index;
    return (BYTE)(*(sBuf+t_index));

int GetShort(char* sBuf, int& index)
    index += 2;
    return *(short*)(sBuf+index-2);

and i cannot convert this

Edited 3 Years Ago by efe.ozyer

Thanks for reply, so GetByte reading bytes from server/client packet not convert,
Byte size 2, Short size 4, DWORD size 8
String size comin with packet

Simple packet : 15 + D75EBC0F + 5811

char *pBuff = 15D75EBC0F5811 
Byte Val1 = GetByte(pBuff, index);
DWORD Val2 = GetDWORD(pBuff, index);
Short Val3 = GetShort(pBuff, index);

I think this will do the trick DWORD is 32-bit unsigned integer, short is signed 16-bit integer. I assumed that all the values are in Hexadecimal, thus the ',16' in the parameter list of the convert functions. Take that out for any that are decimal or change it to the proper value of whatever the base is(

    string packet = "15D75EBC0F5811"
    byte val1 = Convert.ToByte(packet.substring(0,2),16)
    uint32 val2 = Convert.ToUint32(packet.substring(2,8),16)
    int16 val3 = Convert.ToInt16(packet.substring(10),16)

Some of my syntax might not be 100%, I'm doing this off the top of my head.

Edited 3 Years Ago by tinstaafl

Thanks !! Nice Logic !!

It's well done so thanks bro, please add me

Edited 3 Years Ago by efe.ozyer

This article has been dead for over six months. Start a new discussion instead.