Valhalla Legends Forums Archive | Battle.net Bot Development | A question about the Warcraft III Clan System

AuthorMessageTime
Arthas
I connect my bot through BNLS... Connects 3RAW on just fine and dandy, but I do NOT recieve my clan's list in 0x65/0x7D.

I assume it has something to do with sending my 0x0a packet, but BNetDocs, or anywhere else dosn't specify anything about it.

I packetlogged my bot, and no luck getting anything. What's up here? I mean I don't recieve the packet at all =/

-Arthas
September 30, 2003, 4:15 AM
SiMi
Well you could have if you didnt use CSB. Im not exactly sure whats wrong with it but i dont think it has to do with the 0x0A packet.
September 30, 2003, 4:32 AM
Arthas
Pardon, here's my problem:

What do I send when I recieve 0x75? ;D

I'm confused, all I get is FF , 10 chars long. My packet logger wont even pick it up...

-Arthas
September 30, 2003, 4:36 AM
Spht
[quote author=Arthas link=board=17;threadid=2897;start=0#msg22613 date=1064896604]
Pardon, here's my problem:

What do I send when I recieve 0x75? ;D

I'm confused, all I get is FF , 10 chars long. My packet logger wont even pick it up...

-Arthas
[/quote]

You don't have to reply to that message. It's just there to let you know of what clan you're in and your position in that clan.
September 30, 2003, 3:12 PM
UserLoser
[quote author=Arthas link=board=17;threadid=2897;start=0#msg22610 date=1064895317]
I connect my bot through BNLS... Connects 3RAW on just fine and dandy, but I do NOT recieve my clan's list in 0x65/0x7D.
[/quote]

0x65 requests friends list, and server sends it back with friends list and each friends current info.
0x66 - a friend update, such as joining/exiting Battle.net.
0x67 - friend added to friends' list
0x68 - friend removed
0x69 - promoted/demoted

I only havn't fully supported those yet, so I'm not going to give any information on it (I could be wrong on some info)

As for clan packets, all i know of is 0x72 is you have been invited to a clan.
:)
September 30, 2003, 8:46 PM
Arthas
Okay, so what do I send in 0x65?

I'm confused because my packet logger cant packet log war3 :-P I'm using WPE Pro ALpha.

I also have ethreal but I dont have a clue what to put in the "Interface" box.

They should have these packets in bnetdocs :D
September 30, 2003, 10:12 PM
Arthas
Thanks!
September 30, 2003, 11:16 PM
iago
[quote author=Arthas link=board=17;threadid=2897;start=0#msg22666 date=1064959935]
Okay, so what do I send in 0x65?

I'm confused because my packet logger cant packet log war3 :-P I'm using WPE Pro ALpha.

I also have ethreal but I dont have a clue what to put in the "Interface" box.

They should have these packets in bnetdocs :D
[/quote]

If you have a NIC card, interface will be autofilled, just select your card.

Otherwise, I don't think you can use ethereal.
September 30, 2003, 11:27 PM
Arthas
K, my question is yet to be answered, what do I send to recieve my clan list?
September 30, 2003, 11:54 PM
Spht
[quote author=Arthas link=board=17;threadid=2897;start=0#msg22666 date=1064959935]
Okay, so what do I send in 0x65?
[/quote]

0x65 has no content.

[quote author=Arthas link=board=17;threadid=2897;start=0#msg22688 date=1064966050]
K, my question is yet to be answered, what do I send to recieve my clan list?
[/quote]

Send 0x7d to request your clan's member list. The format is basic for this one: it is one DWORD which is the "cookie" (query value). The server's response is pretty straight forward.
October 1, 2003, 12:39 AM
Arthas
Cookie? Query value?

You mean what I recieve in 0x75?... Right?
October 1, 2003, 12:45 AM
Spht
[quote author=Arthas link=board=17;threadid=2897;start=0#msg22701 date=1064969140]
Cookie? Query value?

You mean what I recieve in 0x75?... Right?
[/quote]

Huh? I already told you about 0x75 - read up.
October 1, 2003, 12:46 AM
Arthas
Yes, sorry, but what do you mean by Query Value?
October 1, 2003, 12:50 AM
Spht
[quote author=Arthas link=board=17;threadid=2897;start=0#msg22708 date=1064969441]
Yes, sorry, but what do you mean by Query Value?
[/quote]

Any unique value chosen by you which you can assign to requests so that you can identify them when they are received (since there is no promise that you'll get them in the order you requested them).

If you are only going to request member list once, it may not matter what you use as your query value.
October 1, 2003, 12:55 AM
Arthas
[quote author=Spht link=board=17;threadid=2897;start=15#msg22710 date=1064969733]
Any unique value chosen by you which you can assign to requests so that you can identify them when they are received (since there is no promise that you'll get them in the order you requested them).

If you are only going to request member list once, it may not matter what you use as your query value.
[/quote]

Okay, so I can insert any dword I want? EG: InsertDWORD 615
Nevertheless, I dont get a response from BNet when I send that.
October 1, 2003, 1:06 AM
Arthas
Here is what I send... yet I get no reply. This is right after I send 0x46 btw.

[code]
pBuffer.InsertDWORD 41
pBuffer.SendPacket sckBnet, &H7D
[/code]

I got it working once before using that code, but it all of a sudden just stopped sending me it... o_O I'm confused.
October 1, 2003, 2:41 AM
Stealth
[code]
pBuffer.InsertDWORD &H1
pBuffer.SendPacket &H7D
[/code]

I'm using a value of 1 based off of a packetlog I ran at one point, it's been working great. Could the server be ignoring your request because your cookie isn't.. right somehow? Try sending 1.
October 1, 2003, 3:00 AM
Arthas
Thanks stealth, but this is really *FUCKED* up now. Pardon my language...

Here's the scoop, now my Select Case PacketID isnt recognizing the packet unless I get a msgbox to show me the packetid's.

Here's the code:

Where [code]PacketID = Asc(Mid(data, 2, 1))[/code]

Working:(Uncommented MsgBox)
[code]
MsgBox hex(PacketID)

Select Case PacketID
Case &H0
[/code]

Not working:(Commented MsgBox)
[code]
'MsgBox hex(PacketID)

Select Case PacketID
Case &H0
[/code]

Help. O_O
October 1, 2003, 3:18 AM
Arthas
It's as if I need a little delay somewhere... Though BNet still sends me the packet my bot wont recieve it.
October 1, 2003, 3:50 AM
SiMi
Maybe some of the data recived from the winsock_dataarrival got filtered out through that sub? Best of all; try debugging!

[quote author=Arthas link=board=17;threadid=2897;start=15#msg22728 date=1064980205]
It's as if I need a little delay somewhere... Though BNet still sends me the packet my bot wont recieve it.
[/quote]
How would you know if bnet sends you the packet if you dont get it? :-X
October 1, 2003, 5:07 AM
Zakath
[quote author=Simi link=board=17;threadid=2897;start=15#msg22730 date=1064984858]
How would you know if bnet sends you the packet if you dont get it?
[/quote]

A packet log, of course. You mean to tell me you've never used one in the process of writing a bot? I used mine all the time when I was first getting my packet handling set up, plus I needed it quite a bit when I was first adding support for D2 realms.
October 1, 2003, 5:24 AM
Spht
[quote author=St0rm.iD link=board=17;threadid=2897;start=15#msg22735 date=1065005715]
[quote author=iago link=board=17;threadid=2897;start=0#msg22698 date=1064968452]
[quote author=St0rm.iD link=board=17;threadid=2897;start=0#msg22682 date=1064964822]
WHAT THE FUCK WHY WAS MY POST DELETED
[/quote]

It was oviously useless or offtopic, much like that one. I would suggest also deleting that one and mine.
[/quote]

No, it was a link to wiki.ik0ns.com, with documentation for the packets he was inquiring about.
[/quote]

Maybe next time you should copy the necessary content into your post as a formulated answer, instead of just pasting a link to another server.
October 1, 2003, 2:02 PM
Arthas
Here here Zakath, WPE has been my best friend ;D

Anyways, I'm still stuck. It seems I have to pause for a while when recieving 0x46(BNet News Packet) in order to "recieve" 0x7d. I've looked at my recieve 0x46 code, and there's nothing up that would trigger a sudden loss of packet recieving. Though there is a loop in my recieve 0x46 code, maybe that would do it?
October 1, 2003, 10:03 PM
Arthas
Nvm...... My entire program just needs to pause for some retarded reason.
October 1, 2003, 11:10 PM
SiMi
[quote author=Zakath link=board=17;threadid=2897;start=15#msg22733 date=1064985851]
[quote author=Simi link=board=17;threadid=2897;start=15#msg22730 date=1064984858]
How would you know if bnet sends you the packet if you dont get it?
[/quote]

A packet log, of course. You mean to tell me you've never used one in the process of writing a bot? I used mine all the time when I was first getting my packet handling set up, plus I needed it quite a bit when I was first adding support for D2 realms.
[/quote]
No, thats not what i meant.... I meant if bnet sends the packet but you never get it on your client (they sent it but you never got it).
October 2, 2003, 1:47 AM
UserLoser
This would be helpful in your case: DebugOutput by Grok
October 2, 2003, 8:40 PM
Arta
[quote author=Simi link=board=17;threadid=2897;start=15#msg22772 date=1065059274]
[quote author=Zakath link=board=17;threadid=2897;start=15#msg22733 date=1064985851]
[quote author=Simi link=board=17;threadid=2897;start=15#msg22730 date=1064984858]
How would you know if bnet sends you the packet if you dont get it?
[/quote]

A packet log, of course. You mean to tell me you've never used one in the process of writing a bot? I used mine all the time when I was first getting my packet handling set up, plus I needed it quite a bit when I was first adding support for D2 realms.
[/quote]
No, thats not what i meant.... I meant if bnet sends the packet but you never get it on your client (they sent it but you never got it).
[/quote]

That would never happen. If it does, it's your program's fault. TCP/IP guarantees delivery.
October 3, 2003, 12:19 AM
Myndfyr
Something that happened to me (that might be happening to you), which could explain that sometimes you get a packet and sometimes you don't, is that bnet is lumping more than one packet into a single Send() call.

So if you're getting a load of data from the server, make sure the data length is equivalent to the packet length. IF NOT - copy the data from data(packetLength) to data(receivedDataLength) into a new array and parse THAT. Then repeat. Careful - this can emulate a directly recursive method depending on how you implemented it (mine was not implemented such that it would be recursive, but it still entered an endless loop.

As Arta pointed out, TCP/IP is a reliable transport service - if a packet fails to send, the sender is notified (I think that's called a NACK) and the packet is re-sent. A failed packet is not reported to your program.
October 3, 2003, 1:14 AM
Adron
Note that you'll get a half packet too.
October 3, 2003, 1:22 AM
Arthas
The case: If I dont pause, my bot dosnt recieve the packet. I packet logged 5 times to be certain, and when my bot dosnt recieve the packet... The packet is still packaged into it's own independant packet and sent to ME because my computer picks it up. I use WPE, I target my bot, packet log, the packet logger catches the packet, yet my bot dosnt.

If I pause however... I ALWAYS catch the packet. I'm going to try this Debug Output thing. Thanks for the help, but I'd appreciate some more:)
October 3, 2003, 5:59 AM
St0rm.iD
Sounds like a race condition to me.
October 4, 2003, 10:31 PM
Arthas
Race condition? BTW, DebugOutput didnt do anything for me
October 5, 2003, 4:49 AM
UserLoser
[quote author=Arthas link=board=17;threadid=2897;start=30#msg23031 date=1065329361]
Race condition? BTW, DebugOutput didnt do anything for me
[/quote]

If you just put that on your DataArrival/Recieve, you won't need a packet logger, and you'll see all incoming data to your bot
October 5, 2003, 4:55 AM
Adron
If it's that function grok or someone posted, you'll have to print it too. It's really just bin2hexdump.
October 5, 2003, 11:50 AM
Arthas
I fixed it, I found out wtf was going on.....................

Thanks for the help all, but I once again, am full of questions!

BNet splits a packet in 2 if it is to big, eg, a clan packet. How do I merge the two together?
October 5, 2003, 8:40 PM
Soul Taker
https://davnit.net/bnet/vL/phpbbs/index.php?board=17;action=display;threadid=2912;start=0
Believe that kinda thing was discussed there.
October 5, 2003, 8:44 PM
Arthas
Still, I'm stumped as to WHY I'd have to pause my entire program for the packets to merge by themselves... o_O
October 5, 2003, 10:43 PM
Zakath
When a Windows socket receives data, it's placed into an internal buffer. When you (or the built-in Winsock controller VB uses) issue a recv call on the socket, whatever data is there is copied into the buffer you supply (so you can manipulate it). If you always call recv the instant new data arrives, you'll always receive packets that get cut into pieces as they are: in pieces. By sleeping, I would guess you're causing your program to wait long enough before issuing the recv that both halves of the packet are received and buffered internally, so then the subsequent call can grab the whole packet at once.

However, you generally do want to issue recv as soon as data is received, so...you need to add support for constructing packets when they get split in pieces. :)
October 5, 2003, 11:02 PM
Arthas
Call me a newb, but this works quite well...

In my Data Arrival function:
[code]
lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
If Not Mid(StrToHex(strBuffer), 1, 2) = "FF" Then
strBuffer = p1 + strBuffer
p1 = ""
Parse (Left(strBuffer, lngLen))
End If

If Len(strBuffer) < lngLen Then
p1 = strBuffer
Exit Sub
End If
[/code]

It just waits until I recieve the last parts of the packet, then constructs them, think that should do the trick for everything I'll encounter regarding Bnet?[code][/code]
October 6, 2003, 2:39 AM
Arta
No. I'm not a VB programmer but if I understand your post properly, it's demonstrating a fundamental lack of understanding about data, how it's stored, represented and used - you should read up on it. For example, the first line looks like it's taking the (numeric) length field of a packet, converting it into a string, concatenating it with "&H", and converting it back into a number - that's silly. Perhaps you're suffering from a common misconception: data is not sent as 'hex'. Data is just that - data - a bunch of bytes. Hex (Or more rightly, hexadecimal) is just a way of formatting that data to make it easier to read. Converting a length field - or any other numeric field - to it's hex representation and then back to a number is silly because the data is already a number to begin with.

Checking to see if the first byte of the buffer is FF is a good idea, and something that most people do, but your code here doesn't look very robust. What happens when new data arrives if the buffer contains a half-packet? Is it put onto the end of the buffer? If so, where are you storing the length of the buffer? How are you updating the buffer after you process a packet so that the packet you dealt with is removed properly? What happens when you get two packets in one go? Will it process the first one and then ignore the second? Without seeing the rest of your code I can't tell but there are probably quite a few improvements you could make.


HTH.
October 6, 2003, 3:00 AM
Arthas
How do I get bytes from a string?

EG: ÿh to bytes

I always dealt with my common misconception as fact for my bot, though now this should help me much if you could tell me...
October 6, 2003, 4:47 AM
Arta
They're bytes already. AFAIK, you can just use Mid() to extract a string. I don't know about numbers - As I said, I'm not a VB programmer. If no one who is feels like replying on this thread, I'd suggest finding an open source packet buffer (I think BotDev has one). You should be able to read through the source and figure out what functions like GetDWORD() (or equivalent) do. Incidentally, it's a great deal easier, in my experience, to use a packet class that provides easy methods for retrieving data from packets. It simplifies your packet processing functions and makes your code much more readable.

If you find something in there you can't make sense of, post it here and I'll do my best to help.
October 6, 2003, 11:52 AM
Soul Taker
I use CopyMemory to change such things to a long (check MSDN).
October 6, 2003, 12:53 PM
Adron
[quote author=Arta[vL] link=board=17;threadid=2897;start=30#msg23160 date=1065441124]
They're bytes already. AFAIK, you can just use Mid() to extract a string. I don't know about numbers - As I said, I'm not a VB programmer. If no one who is feels like replying on this thread, I'd suggest finding an open source packet buffer (I think BotDev has one). You should be able to read through the source and figure out what functions like GetDWORD() (or equivalent) do. Incidentally, it's a great deal easier, in my experience, to use a packet class that provides easy methods for retrieving data from packets. It simplifies your packet processing functions and makes your code much more readable.

If you find something in there you can't make sense of, post it here and I'll do my best to help.
[/quote]


Typically, the GetDWORD function will do pretty much what he did. Could also turn his

[code]
lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
[/code]

into

[code]
lngLen = Asc(Mid(strBuffer, 3, 1)) + Asc(Mid(strBuffer, 4, 1)) * 256
[/code]
October 6, 2003, 4:21 PM
St0rm.iD
Let me explain in pseudo:

Define two procedures:
on_data: called when raw data is received. This procedure should store it in a global/instance buffer. Basically, just append the data on the end of it. Then, call dispatch_message.

dispatch_message: this procedure is responsible for dispatching packets to their appropriate handler method. You should follow this algorithm:

1. If length of buffer is less than 4, return
2. If buffer doesn't start with 0xff, throw error
3. If we've made it to here, it looks like a complete battle.net packet header. Grab the 2nd byte in the buffer. We'll call it cmd
4. Convert the 3rd and 4th bytes in the buffer to a little-endian dword (n).
5. If length of buffer is less than n, return, we didn't get a full packet.
6. Otherwise, take the first n bytes from the front of the buffer (msg) and remove them from the buffer.
7. Using a select case/switch/cond/etc logic structure, decide what procedure should handle data for packet type cmd.
8. Pass msg to cmd
9. Go back to step one. You can use a goto, loop, or recursive call. Recursive call is easiest but does have a very very slight risk of a call stack overflow if someone spams the hell out of you

This could be optimized by saving the length of the buffer in a variable so we don't have to count it each time. Could also cache the 3rd and 4th byte dword.

I hope you enjoyed today's algorithm. Stay tuned.

Wait a minute, you probably didn't even read this post. Why did I even bother typing it?
October 6, 2003, 7:15 PM
Arthas
Storm, I read it, and that helped a little bit, mostly on the edition of some new knowledge into my packet handling functions, thanks for that.

On a second note, my uber newbie skills pile up even more.

In the 0x68 packet(Remove Friend), it's just the index, my code works until it hits 10, which is all of a sudden "A", 11 "B", 12 "C", ect. I'm confused, should I make a function that turns A into 10, B into 12, C into 13, or is there a better way of going about this?

EG:

Index = Mid(data, len(data), 2)

Index can be anything in between 0 and 9, after that it starts to be letters(Last I checked letters weren't numbers...).

So, that's why I ask how do I change hex into bytes.

To my knowledge, 2 digits in hex = 1 byte. Now in 0x68, 0D isnt a number, though the index is still 13. You probably know all this and get the question anyways... Help! :)
October 6, 2003, 9:41 PM
Skywing
[quote author=Arthas link=board=17;threadid=2897;start=45#msg23207 date=1065476493]
Storm, I read it, and that helped a little bit, mostly on the edition of some new knowledge into my packet handling functions, thanks for that.

On a second note, my uber newbie skills pile up even more.

In the 0x68 packet(Remove Friend), it's just the index, my code works until it hits 10, which is all of a sudden "A", 11 "B", 12 "C", ect. I'm confused, should I make a function that turns A into 10, B into 12, C into 13, or is there a better way of going about this?

EG:

Index = Mid(data, len(data), 2)

Index can be anything in between 0 and 9, after that it starts to be letters(Last I checked letters weren't numbers...).

So, that's why I ask how do I change hex into bytes.

To my knowledge, 2 digits in hex = 1 byte. Now in 0x68, 0D isnt a number, though the index is still 13. You probably know all this and get the question anyways... Help! :)
[/quote]
What datatype is Index?
October 6, 2003, 10:35 PM
Zakath
Yes, if it's a numerical type, most (all?) programming languages supply a means for dealing with hexadecimal numbers. For instance, in C and C++, adding "0x" to the front of the number prompts the compiler that it's in hex.
October 6, 2003, 10:43 PM
Arthas
[quote author=Skywing link=board=17;threadid=2897;start=45#msg23217 date=1065479741]
What datatype is Index?
[/quote]

Index is a byte, what exactly do you mean by datatype besides that?
October 6, 2003, 10:45 PM
Skywing
[quote author=Arthas link=board=17;threadid=2897;start=45#msg23219 date=1065480303]
[quote author=Skywing link=board=17;threadid=2897;start=45#msg23217 date=1065479741]
What datatype is Index?
[/quote]

Index is a byte, what exactly do you mean by datatype besides that?
[/quote]
You are storing it in an integral type, then. You can print it out using hex or decimal, but the internal representation (and thus the value) of the variable are independant of which base you use to display it.
October 6, 2003, 10:54 PM
Arthas
Thanks, I got it all working right
October 7, 2003, 2:44 AM
Kp
[quote author=Arthas link=board=17;threadid=2897;start=45#msg23207 date=1065476493]
Storm, I read it[/quote]Someone actually took $t0rm's advice! It's the end of the world!
October 7, 2003, 3:55 PM
St0rm.iD
I think he was just saying that to prove he read my post, not neccessarily used it or anything.
October 7, 2003, 7:20 PM

Search