• Welcome to Valhalla Legends Archive.
 

C++ Basic Connection

Started by Trunning, March 27, 2010, 03:25 AM

Previous topic - Next topic

Trunning

Stepping through lines, hitting the ProductID initialization, sets it to "1144144982".

l)ragon

Quote from: Trunning on April 27, 2010, 01:28 PM
Stepping through lines, hitting the ProductID initialization, sets it to "1144144982".
keep stepping untill that reads 0 1144144982 = d2dv
edit: 1144144982= 0x44324456 = 'D2DV'
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

rabbit

Shouldn't it be inserted as VD2D?
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Yegg

#48
Quote from: rabbit on April 27, 2010, 05:21 PM
Shouldn't it be inserted as VD2D?

It is. Putting those single quotes around it will take care of the byte order.
If you look at the hex dump of the packet he showed u, where "VD2D" should appear, it is instead filled with nulls.

Trunning: I just noticed you're doing the following in your code
void *data = malloc(0x200);

You're using data as the variable for storing data from the server. First off, even if you never think the response is going to be larger than 0x200 for a given packet, it makes more sense to use a design where you can dynamically allocate the correct amount of memory.
Second, why not declare data as a char* and cast the malloc() response as a char*?

rabbit

Quote from: Yegg on April 27, 2010, 07:03 PM
Quote from: rabbit on April 27, 2010, 05:21 PM
Shouldn't it be inserted as VD2D?

It is. Putting those single quotes around it will take care of the byte order.
If you look at the hex dump of the packet he showed u, where "VD2D" should appear, it is instead filled with nulls.

Trunning: I just noticed you're doing the following in your code
void *data = malloc(0x200);

You're using data as the variable for storing data from the server. First off, even if you never think the response is going to be larger than 0x200 for a given packet, it makes more sense to use a design where you can dynamically allocate the correct amount of memory.
Second, why not declare data as a char* and cast the malloc() response as a char*?
Why wouldn't I do something as silly as pay attention to what he wrote?  Pffffffff.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Trunning

Quote from: Yegg on April 27, 2010, 07:03 PM
Quote from: rabbit on April 27, 2010, 05:21 PM
Shouldn't it be inserted as VD2D?

It is. Putting those single quotes around it will take care of the byte order.
If you look at the hex dump of the packet he showed u, where "VD2D" should appear, it is instead filled with nulls.

Trunning: I just noticed you're doing the following in your code
void *data = malloc(0x200);

You're using data as the variable for storing data from the server. First off, even if you never think the response is going to be larger than 0x200 for a given packet, it makes more sense to use a design where you can dynamically allocate the correct amount of memory.
Second, why not declare data as a char* and cast the malloc() response as a char*?

That was Hdx's code, I'll change to what you suggested.

Still nothing on why D2DV isn't being sent?

Hdx

#51
The void* doesn't really matter, as the data will be typecasted to a struct. So a pointer is a pointer is a pointer. Only time casting it to a specific type like char* is useful is when you are accessing it like an array.

Anyways, the code for reading data isn't the issue.
Its the code for building the auth packet.

Debugging, what is ProductID at when you reach:
   memcpy(buffer, &pkt, pkt_size);
?

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning


Yegg

Quote from: Trunning on April 28, 2010, 02:27 AM
It's 0 there.

See what happens if you remove the line with memset.

Hdx

if you do that, your struct will have random data in it.
Anyways, quit pointing him at places where you know the problem isn't.

pkt.ProductID = 'D2DV'; <~~It gets properly set here
pkt.VerByte = 0x00;
pkt.ProductID = 0x00;
pkt.LocalIP = inet_addr("192.168.1.100");
pkt.TimeZone = 600;
pkt.LocaleID = 0x00;
pkt.LangID = GetUserDefaultLangID();

pkt.CountryAbbr = (char*)malloc(4);
pkt.CountryName = (char*)malloc(14);
strcpy(pkt.CountryAbbr, "USA");
strcpy(pkt.CountryName, "United States");

int pkt_size = sizeof(pkt) - 8;

pkt.Header.bHead = 0xFF;
pkt.Header.bID = 0x50;
pkt.Header.wLen = pkt_size + 18;

char *buffer;

buffer = (char*)malloc(pkt.Header.wLen);
memcpy(buffer, &pkt, pkt_size); <~~~~Its 0 Here

Now step through the code, and look for a line where the debugger says the it looses its value.
It's a fairly obvious bug, but hey! You can't learn if you don't try!

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Yegg

#55
Probably has something to do with this:
pkt.ProductID = 'D2DV';
pkt.VerByte = 0x00;
pkt.ProductID = 0x00;


ProductID is set twice.

Hdx

Quote from: Yegg on April 28, 2010, 03:45 PM
Probably has something to do with this:
pkt.ProductID = 'D2DV';
pkt.VerByte = 0x00;
pkt.ProductID = 0x00;


ProductID is set twice.
Thats what I was getting at yes...

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

Oh wow, can't believe it was that simple. Anyway, now at least I'm receiving 0x25 then 0x50 back.

With the code, I'm receiving 0x25, but I've tried a couple of methods based on it to receive 0x50, but failed. Can I get an example of 0x50, then I should be fine. Thanks.

Hdx

Just send valid information in your c->s 0x50 Read: Version Byte
Also, if you can parse out 0x25, then you should be able to parse out 0x50. As the code should be generic.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

As I said in my last post, I attempted and failed. Also if I were to manage to receive 0x50 properly, I don't know how to access certain parts of data. It's not like the send me a struct that contains.
(DWORD) Logon Type
(DWORD) Server Token
(DWORD) UDPValue *
(FILETIME) MPQ filetime
(STRING) IX86ver filename
(STRING) ValueString

|