Valhalla Legends Forums Archive | Battle.net Bot Development | [C++] SID_AUTH_ACCOUNTLOGON

AuthorMessageTime
Okee
I've been adding the necessary Warcraft 3 functions to my C++ bot, using BNCSutil, and the nls_ functions (nls_get_M1, etc) all say the first variable NLS cannot be converted from a long to a nls_t *. My NLS variables is declared as a long because I've been using the BNCSutil Test App as a refrence, and the NLS variable is there is declared as a long also.

I type-casted the argument as (nls_t *)NLS, but got IP banned so I bet thats messing the data up somehow.

How should the NLS variable be declared?
May 20, 2005, 4:48 AM
Okee
Edit:

I renamed this topic to SID_AUTH_ACCOUNTLOGON because I seem to think that the problem may lie more-so within my function for sending this packet. This packet seems rather simple after completing 0x51, etc, but yet I get ip banned after sending it. Here's my function for sending the packet...

[code]
void SendAuthLogon(void) {
char Var_A[32];

if(!NLS) {
NLS = (int)nls_init(username, password);
if(!NLS)
print("Failed to initialize NLS!\n");
}

nls_get_A((nls_t *)NLS, Var_A);

add(Var_A);
add(username);
sendpacket(SID_AUTH_ACCOUNTLOGON);
}
[/code]

Simple enough? The reason I was asking about the variable type nls_t from BNCSutil, was because the variable in this function named NLS is of type long, and when being passed to the function nls_get_A, reports an error saying 'cannot convert from long to nls_t *'.

Has anyone else tried to use BNCSutil and C++ to create a bot? Maybe somebody knows what I could be doing wrong?

Also, the line:
[code]NLS = (int)nls_init(username, password);[/code]

seems strange. if i dont typecast the nls_init function it gives the error
error C2440: '=' : cannot convert from 'nls_t *' to 'long'

I dunno. I've been at this thing for awhile now, and it's just frustrating me. Maybe I need to take a break from it for awhile. heh. Any help is appreciated though, as usual.

Edit:

I figured id add some packet logs of mine vs. bncs util test app on uswest.

My SID_AUTH_LOGONACCOUNT
[quote]

8  Hide  Hide  51  Send 
0000  FF 53 33 00 C9 6A D3 DB 5C 0A 1A 9E F1 C3 16 CA    .S3..j..\.......
0010  D3 F0 F6 02 72 DE 5A 0C 9B 0F F0 3B EB D8 85 1D    ....r.Z....;....
0020  F4 EF C2 66 EC DC AA 00 4F 6B 65 65 5B 74 65 73    ...f....Okee[tes
0030  74 5D 00                                          t].
[/quote]

BNCS util test apps SID_AUTH_LOGONACCOUNT
[quote]

7  Hide  Hide  47  Send 
0000  FF 53 2F 00 4D CE 6C F7 03 4A BB 08 98 0B 21 CF    .S/.M.l..J....!.
0010  B7 FD 7E 5D 10 33 58 AE 68 2B 7C 11 7B 00 6F 96    ..~].3X.h+|.{.o.
0020  9B 8D DA E3 4F 6B 65 65 5B 74 65 73 74 5D 00      ....Okee[test].
[/quote]

Hm, mine seems to be a bit longer?
May 22, 2005, 5:19 AM
K
What is the type of your NLS variable?
It should be of type nls_t*, which it looks like it is not.
May 22, 2005, 5:41 AM
Okee
[code]
unsigned long NLS;
[/code]

I changed my NLS variable to..

[code]
nls_t *NLS;
[/code]

I still get ip banned, but here's my new packet log..

[quote]
8  Hide  Hide  51  Send 
0000  FF 53 33 00 59 F1 CC FC A5 9D 8B 8E A7 3C 3B 45    .S3.Y........<;E
0010  C2 67 C8 C1 94 9F 1A FF 98 07 13 F3 A4 3A 5D CF    .g...........:].
0020  14 33 10 4D EC DC AA 00 4F 6B 65 65 5B 74 65 73    .3.M....Okee[tes
0030  74 5D 00                                          t].

[/quote]
May 22, 2005, 5:53 AM
shadypalm88
Three things stuck out at me: you're passing Var_A to add() without specifying its length, the packet you're sending is longer, and there's a null byte before the username in your packet.

The add() function is interpreting Var_A as a null-terminated string, which it is not.  Thus it is reading past the end of Var_A until it reaches a null byte.

And please consult nls.h before the VB example.  Warnings and errors about implicit casts to/from integers and pointers, "cannot convert from X to Y" do not mean "blindly insert a typecast".  Check for logical errors and typos first: always try to understand the meaning of the message, and exactly why you're getting it.
May 22, 2005, 6:28 AM
Okee
Okay. I now get a reply to this packet, but it always replies with Account does not exist. 0x01.
I've gone onto the server and create the account, so I know it exists.

Here's my revised code
[code]
void SendAuthLogon(void) {
char Var_A[32];

NLS = nls_init(username, password);
if(!NLS)
print("Failed to initialize NLS!\n");

nls_get_A(NLS, Var_A);

add(Var_A, strlen(Var_A));
add(username);  // should this be null terminated?
sendpacket(SID_AUTH_ACCOUNTLOGON);
}
[/code]

and a packet log
[quote]
8  Hide  Hide  50  Send 
0000  FF 53 32 00 07 4D 81 9A 9A 84 FB F3 18 EF 50 EA    .S2..M........P.
0010  09 92 2B FB 9C 28 7A 33 17 42 52 E6 C3 D2 13 11    ..+..(z3.BR.....
0020  03 06 2E D5 EC DC AA 4F 6B 65 65 5B 74 65 73 74    .......Okee[test
0030  5D 00                                              ].

9  Hide  Hide  72  Recv 
0000  FF 53 48 00 01 00 00 00 00 00 00 00 00 00 00 00    .SH.............
0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
0020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
0040  00 00 00 00 00 00 00 00                            ........
[/quote]

Anyone see why it might think I'm trying to logon with a different account?

Edit: Okay, I was thinking that somehow my username and password variables might be containing something I didn't expect them to. What I did was replace the line..
[code]
NLS = nls_init(username, password);
[/code]

with

[code]
NLS = nls_init("Okee[test]", "mypassword");
[/code]

and it worked. I'm not sure what could be wrong with my variables because they seem to contain what I want them to when I print them out. Anyways, Ill keep looking into this.
May 22, 2005, 8:59 PM
shadypalm88
[quote author=Okee link=topic=11645.msg113421#msg113421 date=1116795594]
[code]
add(Var_A, strlen(Var_A));
[/code]
[/quote]

From the man page for strlen:
[quote author=man strlen(3)]
DESCRIPTION
     The strlen() function computes the length of the string s.

RETURN VALUES
     The strlen() function returns the number of characters that precede the
     terminating NUL character.[/quote]
In other words, strlen only works for null-terminated strings.  Remember, the length of the A variable is always 32 bytes.
May 22, 2005, 9:22 PM
Okee
Man, I was on my way to post this just now. I had actually just realized that while looking at my function. I changed it, and it works. Damned strlen function has got me now a few times.
May 22, 2005, 9:25 PM

Search