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 by efe.ozyer

5 Years
Discussion Span
Last Post by tinstaafl

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 by tinstaafl

Votes + Comments
Thanks !! Nice Logic !!

It's well done so thanks bro, please add me facebook.com/efe.ozyer

Edited by efe.ozyer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.