• Welcome to Valhalla Legends Archive.
 

[Resolved]0x3E Help please..

Started by Jaquio, March 02, 2006, 05:34 AM

Previous topic - Next topic

Jaquio

Alright, I decided to add realm connection into my bot and am having alot of trouble with it. How exactly do connect to the realm? I have looked around the forums and seen people talking about extracting the IP from recv'd packet 0x3E then connecting to the realm with it.. I have no idea what I am doing wrong.. Here is my recv'd 0x3E case code.


        Case &H3E
        'Debug.Print "Recv'd:0x3E"

        Server = Mid(data, 17, 8)
        ServIP = Mid(Server, 5, 4)
        AddChat D2Green, "Current realm server: " & MakeServ(ServIP)
       
        Debug.Print "Server:" & Server
        Debug.Print "Server IP:" & ServIP
       
        frmMain.wsRealm.Close
        frmMain.wsRealm.Connect MakeServ(ServIP), 6112


Here is my MakeServ function.


Public Function MakeServ(data As String) As String
    Dim intIP1 As String, intIP2 As String, intIP3 As String, intIP4 As String
   
    intIP1 = CLng("&H" & ToHex(Mid(data, 1, 1)))
        Debug.Print "1:" & intIP1
    intIP2 = CLng("&H" & ToHex(Mid(data, 2, 1)))
        Debug.Print "2:" & intIP2
    intIP3 = CLng("&H" & ToHex(Mid(data, 3, 1)))
        Debug.Print "3:" & intIP3
    intIP4 = CLng("&H" & ToHex(Mid(data, 4, 1)))
        Debug.Print "4:" & intIP4
       
    MakeServer = intIP1 & "." & intIP2 & "." & intIP3 & "." & intIP4
End Function


With that function I get "Run-time error '13': Type mismatch" at "intIP1 = CLng("&H" & ToHex(Mid(data, 1, 1)))" and every other ip. Any ideas as to what I am doing wrong?

Joe[x86]

#1
Public Function MakeServ(data as String) As String
    Dim IP(1 to 4) as String
    IP(1) = Asc(Mid(data, 1, 1))
    IP(2) = Asc(Mid(data, 2, 1))
    IP(3) = Asc(Mid(data, 3, 1))
    IP(4) = Asc(Mid(data, 4, 1))
    MakeServ = Join(IP, ".")
End Function


EDIT -
Have you considered using a Packet Debuffer Class?
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Jaquio

Nope, never considered using one. When I get home I will try what you have posted and add that Packet Debuffer class to my bot, thanks.

Jaquio

#3
Quote from: Joe on March 02, 2006, 07:16 AM

EDIT -
Have you considered using a Packet Debuffer Class?


How exactly do I use this class? I got errors on the 'GetWord' and 'GetDWord' functions. Anyidea why?

Also, now that MakeServ function you gave me. Gives me an 'Invalid procedure call or argument(Run-time error '5')" at


strIP(1) = Asc(Mid(data, 1, 1))


And at all the other strings.

Joe[x86]

QuoteAlso, now that MakeServ function you gave me. Gives me an 'Invalid procedure call or argument(Run-time error '5')"

Unfortunately I don't know for sure what's wrong with that, but I think using the packet debuffer will fix it.

QuoteHow exactly do I use this class? I got errors on the 'GetWord' and 'GetDWord' functions. Anyidea why?
http://www.javaop.com/~joe/VB6/modWORD.bas




Remember, you need to call MakeDWORD on RemoveDWORD before you pass it to MakeServer.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Jaquio

Alright Joe, I have the Debuffer class working now thanks. The problem is now, is that to remove multiple dwords, what would I need to do exactly? Or could you explain how to actually use this class? I understand how to use MakeDword and such.. Just removing them..

MyndFyre

Quote from: Jaquio on March 02, 2006, 09:19 PM
Alright Joe, I have the Debuffer class working now thanks. The problem is now, is that to remove multiple dwords, what would I need to do exactly? Or could you explain how to actually use this class? I understand how to use MakeDword and such.. Just removing them..
.RemoveDword
.RemoveDword

??

Duh...
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Jaquio

Ohh, so everytime I remove a dword or anything, it'll automaticly go onto the next dword or whatever I am removing?

MyndFyre

That's pretty much the point of a "debuffer" class, or as it is more correctly called, a Reader.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Jaquio

So, for the realms IP Address I would use the 4th DWord as the ip? Or is there something I am not understanding about ox3E?

MyndFyre

Quote from: Jaquio on March 02, 2006, 09:37 PM
So, for the realms IP Address I would use the 4th DWord as the ip? Or is there something I am not understanding about ox3E?

Well, let's see:
http://bnetdocs.valhallalegends.com/content.php?Section=m&Code=15

Quote
(DWORD)       Cookie
(DWORD)       Status
(DWORD[2])    MCP Chunk 1
(DWORD)       IP
(DWORD)       Port
(DWORD[12])    MCP Chunk 2
(STRING)     BNCS unique name
(WORD)       Unknown
...so it'd be something like

Cookie = GetDWord()
Status = GetDWord()
MCPChunk1Part1 = GetDWord()
MCPChunk1Part2 = GetDWord()
IPAddress= GetDWord()
Port = GetDWord()

.....

Is that somehow unclear?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Jaquio

#11
Why does it return numbers like this? "892481592" or "942683958"? :(

All the other clients connect just fine to BNet it's D2DV and D2XP I am having trouble with..

Nevermind, I cannot get this to work at all.. I guess having D2 enabled in my bot isn't a must.. I could just say forget it and try again some other time when I can figure out how to exact all I need from the recv'd data in 0x3E thanks for your help guys.

Sorc.Polgara

#12
Quote from: MyndFyre[vL] on March 02, 2006, 09:31 PM
That's pretty much the point of a "debuffer" class, or as it is more correctly called, a Reader.
Haha.  Don't know who originally came up with "debuffer", but when I was thinking of a name to call the packet reader class that I wrote in VB6 a long time ago to do the opposite of what a packet buffer class does, I  came up with calling it "debuffer" simply by the fact that "de" is a prefix meaning:
Quote
   1. Do or make the opposite of; reverse: decriminalize.
   2. Remove or remove from: delouse; deoxygenate.
   3. Out of: deplane; defenestration.
   4. Reduce; degrade: declass.
   5. Derived from: deverbative.

LordNevar

#13

     Case &H3E
        String1 = Mid$(Data, 5, 16)
        Server = MakeServer(Mid$(Mid$(Data, 17, 8), 5, 4))
        String2 = Mid$(Data, 29, 48)
        Username = Mid$(Data, 77, Len(Data) - 79)


This code seems like it should work with your MakeServer function, and should coincide with the rest of your buffer class.

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
The greatest trick the Devil ever pulled, was convincing the world he didn't exsist.

MyndFyre

Quote from: Jaquio on March 02, 2006, 09:55 PM
Why does it return numbers like this? "892481592" or "942683958"? :(

All the other clients connect just fine to BNet it's D2DV and D2XP I am having trouble with..
Because an IP adress is a 32-bit number.  Separating it into the dotted-quad notation is simply a somewhat-more-human-readable method of thinking about it.  But figure, any part of an IP address can range from 0 to 255.  Those are byte values.

Look at it this way too:
vL forums are hosted at 64.5.42.38.
That's 0x40.0x05.0x2a.0x26
Written in network byte order: 0x40052a26

That translates to: 1074080294

If you go to http://1074080294/, you'll get this server, but Apache doesn't like that HTTP GET request.

Google is 66.102.7.99.  0x42.0x66.0x07.0x63 -> 0x42660763 -> 1113982819 -> http://1113982819/ = Google.com.

There ya go.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.