-
Feb 21st, 2012, 10:54 AM
#1
Thread Starter
New Member
help with this vb code pls?
Hi there ,
I am looking in to a source code of yahoo messenger clone in vb6.0 , so obviously its winsock programming
so in The yahoo messenger header for yahoomessenger packet i see this declaration in the module,
Code:
YMSGPacket = "YMSG" & Chr(Int(Version / 256)) & Chr(Int(Version Mod 256)) & String(2, Chr(1)) & Chr(Int(Len(StrPacketType) / 256)) & Chr(Int(Len(StrPacketType) Mod 256)) & Chr(Int(StrComm / 256)) & Chr(Int(StrComm Mod 256)) & Mid(StrStat, 1, 4) & Mid(StrSession, 1, 4) & StrPacketType
tht code is the code which is sent through the winsock , I have a few more questions ,in what format is data senthrough winsockcomponent of visualbasic , string , hex ,binary or ascii
i see the mod 256 and / 256 code everywhere in this program , whats use of this statement
another code
Code:
TimSt = Chr$((((number And &HFF000000) / 256) / 256) / 256) & Chr$(((number And &HFF0000) / 256) / 256) & Chr$((number And &HFF00&) / 256) & Chr$(number And &HFF&)
every help would be greatly appreciated
thanks in advance
-
Feb 21st, 2012, 11:52 AM
#2
Re: help with this vb code pls?
/ 256 is simple division ... 1/4 = .25 4/2 = 2 ... etc.
mod 256 is a modulo operation, returns the remainder of a division... so 5 mod 3 is 2 4 mod 2 is 0 (2 goes into 4 evenly) 9 mod 3 is also 0, 11 mod 3 is 2 ...
-tg
-
Feb 21st, 2012, 12:06 PM
#3
Thread Starter
New Member
Re: help with this vb code pls?
Thanks for the reply sir,ok , i know the operators division and mod,but in the case of this Chr(Int(Version / 256)
so my question is whats the use of dividing by 256 or getting mod 256 , is to convert string or integer in to one peculiar form
sorry i am a noob
-
Feb 21st, 2012, 12:09 PM
#4
Re: help with this vb code pls?
Looks like a form of data packing I think... but I'm not sure...
-tg
-
Feb 21st, 2012, 12:11 PM
#5
Re: help with this vb code pls?
Everything has a use, why it is being done here I do not know.
In the case of CHR() and Mod 256 it would seem that the goal is to get a number < 256 and convert that to a character in the valid range of 0 - 255
Same with the division
-
Feb 21st, 2012, 12:23 PM
#6
Thread Starter
New Member
Re: help with this vb code pls?
ok thanks to both of you , as i got this code from a yahoo clone project , is there a possibility that this is code is to convert it in to a form yahoo recognises or which is exclusive to yahoo
btw its a yahoo messenger clone
-
Feb 21st, 2012, 07:57 PM
#7
Re: help with this vb code pls?
Originally Posted by pattrick_george
ok thanks to both of you , as i got this code from a yahoo clone project , is there a possibility that this is code is to convert it in to a form yahoo recognises or which is exclusive to yahoo
A good assumption I would think.
Going back to dividing by 256 multiple times. Data packing, as suggeted, is probably the reason. You can pack quite a bit information in a Long value type (32 bits, 4 bytes). Take an IP address for example, written out: 255.255.255.255 would consist of 15 characters, at 1 byte per character, 15 bytes. A Long value is just 4 bytes. That same value as a Long would be simply negative one & displayed in hex as: FFFFFFFF (where FF = 255). Example: A Long value can contain 4 values, each in the range of 0-255. Each of the 4 "tokens" of that Long are offset by 256. Typically bit masking and integer division is used to extract the 4 bytes of a Long, not real division.
But to the point now. We can tell you what the code is doing from a logical perspective. However, why it is doing what it is doing is only known to the author and others that are familiar with the target's requirements; that of Yahoo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|