• Welcome to Valhalla Legends Archive.
 

Packet 0x79 Discussion

Started by Arthas, December 16, 2003, 10:54 PM

Previous topic - Next topic

Arthas

So, I read the thing onBnet Docs about 0x79, but I have a problem.

Where it says: (DWORD) Cookie?

Do I just enter in giberrish? EG: &H1 or &H0

Here's my response, that dosnt seem the work right.

With pBuffer
   .InsertDWORD &H0
   .InsertDWORD ClanTag
   .InsertNTString ClanCheiftain
   .InsertBYTE &H6
   .SendPacket frmMain.sckBnet, &H79
End With

I'm seriously confused about the clan tag part. How would I convert the tag to a dword?

Spht

Quote from: Arthas on December 16, 2003, 10:54 PM
So, I read the thing onBnet Docs about 0x79, but I have a problem.

Where it says: (DWORD) Cookie?

Do I just enter in giberrish? EG: &H1 or &H0

Here's my response, that dosnt seem the work right.

With pBuffer
   .InsertDWORD &H0
   .InsertDWORD ClanTag
   .InsertNTString ClanCheiftain
   .InsertBYTE &H6
   .SendPacket frmMain.sckBnet, &H79
End With

Since BNCS messages are handled asynchronously, a "cookie" or "query value" is needed to know which query the server is replying to. You can use whatever value you like (I suggest incrementing a tick with each sent query). The server will reply with the same "cookie" so you know which message the response is applying to so you can accurately display the necessary information.

Quote from: Arthas on December 16, 2003, 10:54 PMI'm seriously confused about the clan tag part. How would I convert the tag to a dword?

I'm not sure what you mean here. The clan's tag can be a maximum of 4 characters. The tag should already be a DWORD (32 bits), and should be handled that way interally because that is how it is handled on Battle.net. So no conversion should be needed anywhere.

Arthas

#2
I guess my real confusion is on how to extract the DWORD from the packet...

I've been doing it the newbie way all my life, and I'd like to know the best way to extract that dword. If you could tell me that'd be swell :)

Thanks,
-Arthas

MyndFyre

The DWORD is the same as using the PacketBuffer's .InsertNonNTString(String) subroutine.  On Battle.net, you end up seeing a lot of backward strings that look like DWORD (or 32-bit numbers).  Here's why:

Battle.net was probably programmed in C or C++ with a compiler that allows them to use multi-character literals (in C-based languages, you define a string literal with double quotes, e.g., "This is a string.", whereas a character literal uses single quotes, e.g., 'A').  C strings are always terminated with a null (0x00) byte.  A character literal is not, so let's say you have these two things defined in C:


char *ptr = "0123";
char val = '0123';


The first one would be encoded in memory like this:


30 31 32 33 00     0123.


The second one, as displayed, is:

30 31 32 33         0123


But because of Intel byte-order, the compiler reverses it and treats it like a 32-bit integer:

33 32 31 30        3210


So when you see a DWORD that seems like it should a string, that's what they mean.  The VB PacketBuffer class doesn't automatically reverse your string, so if you wanted the clan tag, for example, pIsS, you'd need to call
.InsertNonNTString("SsIp")

Cheers,

--Rob
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.

Arthas

With pBuffer
   .InsertDWORD Cookie?
   .InsertNonNTString StrReverse(ClanTag)
   .InsertNTString Trim(Cheiftain)
   .InsertBYTE &H6
   .SendPacket frmMain.sckBnet, &H79
End With

and this should work well? But it isnt... So :P - Confused.

Arthas

Nvm, figured it out.

With pBuffer
   .InsertNonNTString Cookie
   .InsertNonNTString StrReverse(Text1.text)
   .InsertNTString Trim(Text3.text)
   .InsertBYTE &H6
   .SendPacket frmMain.sckBnet, &H79
End With

Thanks Myndefyre :D