Valhalla Legends Forums Archive | Visual Basic Programming | Val()

AuthorMessageTime
Yegg
I was reading up on the Val() function and I came to the conclusion that many of the older model bots used things like Val(Mid(cdkey, 5, 8)), just as an example. I don't see what the point of doing this is, won't you just receive the same code if you left out the Val() function? Or were they just using the Val() function so that the code for starcraft and for other clients would use the same stuff?
March 26, 2005, 9:49 PM
KkBlazekK
[quote]Val(Mid(cdkey, 5, 8))[/quote]

What bot uses that? Can you give a REAL example?
March 26, 2005, 10:15 PM
Yegg
No bot uses that, I even stated that that was just an example. I also said that "older model" bots used code like this. Here is an example, taken from the source of 0x51 Bot:
[code]dValue1 = Val(Mid$(sCDKey, 3, 7))[/code]
This would be for starcraft too.
March 26, 2005, 10:22 PM
KkBlazekK
I can't see why they would be doing that. :-\
March 26, 2005, 10:24 PM
Stealth
Val() simply returns the numeric value of a string's contents as a double. Use it carefully. Examples:

[code]
Val("-1") = -1.0
Val(",1") = 0.0
Val("2353") = 2353.0
Val("not a number") = 0.0
[/code]

The example will presumably take a Starcraft CDKey, which is stored in a string

[code]"1234567890123"[/code]

and extract 7 digits beginning at the 3rd using Mid():

[code]"3456789"[/code]

then convert it to a double using Val() so that it can be used in mathematical operations.

[code]3456789.0[/code]
March 26, 2005, 11:15 PM
Yegg
Val() can also do the following:
[code]Val("654gffd33") = 654[/code]
In that example (not above), it was used by the 0x51 Bot example.
March 26, 2005, 11:17 PM
R.a.B.B.i.T
You shouldn't use 0x51 Bot.  It's horrible.
March 27, 2005, 1:46 AM
UserLoser.
[quote author=rabbit link=topic=11050.msg105701#msg105701 date=1111888002]
You shouldn't use 0x51 Bot.  It's horrible.
[/quote]

Correction: You shouldn't use any open source VB bot.  They're all horrible.

(No, this isn't an attack at open source, it's just a proven fact that all open source VB bots are horrible)
March 27, 2005, 2:07 AM
Newby
[quote author=UserLoser link=topic=11050.msg105703#msg105703 date=1111889274]
Correction: You shouldn't use any open source VB bot.  They're all horrible.

(No, this isn't an attack at open source, it's just a proven fact that all open source VB bots are horrible)
[/quote]

Really?
March 27, 2005, 2:12 AM
Yegg
Well actually, I'm not even using Visual Basic. I'm using 0x51 Bot for learning purposes to create my own hashing functions written in Python. I created my own Val() function in Python, it does the exact same thing that it does in VB6. As long as a bot works, I find no harm in using any ideas from it.
March 27, 2005, 2:44 AM
UserLoser.
[quote author=Newby link=topic=11050.msg105704#msg105704 date=1111889565]
[quote author=UserLoser link=topic=11050.msg105703#msg105703 date=1111889274]
Correction: You shouldn't use any open source VB bot.  They're all horrible.

(No, this isn't an attack at open source, it's just a proven fact that all open source VB bots are horrible)
[/quote]

Really?
[/quote]

Yes, I already looked at that

[code]
Public Const CON_STATUS_CONNECTING = &H1
Public Const CON_STATUS_CONNECTED = &H2
Public Const CON_STATUS_RECONNECT_PENDING = &H4
Public Const CON_STATUS_LOGGEDIN = &H8
Public Const CON_STATUS_INCHAT = &H10
Public Const CON_STATUS_INGAME = &H12
[/code]

Broken values for a bitmask

[code]
Public Function GetDWORD(ByVal Data As String) As Long
   Dim a As String, b As String, C As String, D As String
   Dim tmp As String
   
   tmp = StrToHex(Data)
   
   a = Mid$(tmp, 1, 2)
   b = Mid$(tmp, 3, 2)
   C = Mid$(tmp, 5, 2)
   D = Mid$(tmp, 7, 2)
   
   tmp = D & C & b & a
   
   GetDWORD = CLng(Val("&H" & tmp))
End Function

Public Function GetWORD(ByRef Data As String) As Long
   Dim tmp As String
   Dim a As String
   Dim b As String
   
   tmp = StrToHex(Data)
   
   a = Mid$(tmp, 1, 2)
   b = Mid$(tmp, 3, 2)
   
   tmp = b & a
   
   GetWORD = CLng(Val("&H" & tmp))
End Function
[/code]

That's... horrible... use CopyMemory

[code]
Public Function MakeFILETIME(ByRef pFILETIME As Long) As String
   Dim tmpBuf As String * 8
   
   Call memmove(ByVal tmpBuf, ByVal pFILETIME, Len(tmpBuf))
   
   MakeFILETIME = tmpBuf
End Function
[/code]

Looks like that should be named MAKE8BYTELONGSTRING, why calling Len?  It's 8

[code]
ERROR_HANDLER:
   If Err.Number = 10048 Then
       iLocalPort = iLocalPort + 1
       
       With sckUDP
           .LocalPort = iLocalPort
           .Bind
       End With
   End If
[/code]

Use setsockopt to allow the address to be reused instead of bruteforcing it

[code]
   strCompName = String(255, MakeBYTE(0))
   strCompUsrName = String(255, MakeBYTE(0))
   
   lngCompNameSize = LenB(strCompName)
   lngCompUsrNameSize = LenB(strCompUsrName)
[/code]

Length is 510... why call LenB?

MakeBYTE(0)?  Why is it taking a 0 as a byte, copying it into a string, then returning it into a 8-bit value?

[code]
    Dim tmpInBuf As New clsPktInBuf
    Dim PktOutBuf As New clsPktOutBuf
[/code]

I see this over and over, and the classes are never destroyed.  You probably would want to delete those when you're done with them...

I can go on more... Please, just read my original statement and don't bother going against it
March 27, 2005, 2:50 AM
LoRd
BBBB is far from being done.  It lacks comments, and is yet to actually connect to Battle.net.  Many of the current functions and declarations are there just to get the job done while I focus on reversing certain functions from battle.snp/storm.dll which is my top priority.

I use Len() to ensure easy modifcation of the code which is much more important than the 0.000001 millisecond or w/e the exact speed difference may be, especially since this code may be used in multiple projects so the code may need to be changed slightly at a later time.  I wish Visual Basic supported compile-time functions because a sizeof() would be a big help here.

The typo in the connection status masks has already been fixed.

Generally, I only define objects in functions so the objects will be destroyed when the function collapses.  I have a few which are declared within a class scope, but that's because the class would not function properly without the objects, so there'd be no reason why you'd want to destroy them.

Please go on.  One of the benefits of programming open source is that users can comment on my code which helps me to find/fix bugs as well as improve certain things that I either haven't noticed or haven't gotten around to.
March 27, 2005, 3:15 AM
UserLoser.
[quote author=LoRd[nK] link=topic=11050.msg105714#msg105714 date=1111893331]
BBBB is far from being done.  It lacks comments, and is yet to actually connect to Battle.net.  Many of the current functions and declarations are there just to get the job done.

I use Len() to ensure easy modifcation of the code which is much more important than the 0.000000001 millisecond or w/e the exact amount difference in speed may be.

The typo in the connection status masks has already been fixed.

Generally, I only define constant classes in functions so the objects will be destroyed when the function collapses.

Please go on.  One of the benefits of programming open source is that users can comment on the code which helps me in finding/fixing bugs and improving code.
[/quote]

I hate to say this, but I feel good about you saying to go on with complaining about things as a benefit of open source projects.  Fix existing things and we'll see at a later time :P
March 27, 2005, 4:07 AM

Search