»Admiral Kirk Posted August 8, 2006 Report Posted August 8, 2006 Ok, trying to add New User Registration functionality to SubChat2. Ive gotten most of my information from MERVBot as far as the packets definition. Now, hop back a few packets, to the password Response packet. According to my do!@#$%^&*entation, the 19th byte is a boolean which should be 1 if the server is requesting a Registration Form. It seams that every time I login with an unkown user name I get the response code of 1 (unkown player) but the Registration Form Request byte is 0 (not requested) which is the same as it is when I login with an existing login name and get a response code of 0 (good login). Going beyond that, I just decided to send the Registration Form whenever I got a response code of 1, but the server seams to completely ignore it. I dont know if its because it didnt request it (no idea why it didnt) or if the Registration Data is malformed. Any information from anyone who has gotten the registration form to work would be GREATLY appreciated. Thanks in Advance. Kirk
»Ceiu Posted August 9, 2006 Report Posted August 9, 2006 Well, !@#$%^&*uming youre sending the password packet correctly, this is the code I used to handle the response: case 0x0A: // password packet response // Send Registration Information... if(objPacket.get(19) != 0) { this.sendRegistrationForm(SystemInfo.getName(), SystemInfo.getEmail(), SystemInfo.getCity(), SystemInfo.getState(), SystemInfo.getSex(), SystemInfo.getAge()); } // Re-send password packet if necessary... if(objPacket.get(1) == 1) { this.sendP!@#$%^&*wordPacket(true, this.objLoginInfo[0], this.objLoginInfo[1], SystemInfo.getMachineID(), SystemInfo.getTimeZoneBias(), SystemInfo.getPermissionID()); } else { this.handleEvent(new LoginResponse(this, objPacket)); } break; ...And construction of the registration packet, complete with javadoc: /** * Will never be public. 0 1 Type Byte 0x17 1 32 Real Name *1 33 64 E-Mail *1 97 32 City *1 129 24 State *1 153 1 Sex *2 154 1 Age 155 1 Connecting From: Home (Boolean) 156 1 Connecting From: Work (Boolean) 157 1 Connecting From: School (Boolean) 158 4 Processor Type 162 4 ? Unknown 166 40 Windows Registration: Real Name 206 40 Windows Registration: Organization 246 40 Display\0000:DriverDesc 286 40 Monitor\0000:DriverDesc 326 40 Modem\0000:DriverDesc 366 40 Modem\0001:DriverDesc 406 40 Mouse\0000:DriverDesc 446 40 Net\0000:DriverDesc 486 40 Net\0001:DriverDesc 526 40 Printer\0000:DriverDesc 566 40 MEDIA\0000:DriverDesc 606 40 MEDIA\0001:DriverDesc 646 40 MEDIA\0002:DriverDesc 686 40 MEDIA\0003:DriverDesc 726 40 MEDIA\0004:DriverDesc *1 - Real name, E-mail, City, State are null-terminated strings *2 - Sex is either 'F' or 'M' */ private void sendRegistrationForm(String strName, String strEmail, String strCity, String strState, char cSex, byte bAge) { if(strName == null || strEmail == null || strCity == null || strState == null) { throw new IllegalArgumentException(); } ByteBuffer objPacket = ByteBuffer.allocate(766).order(ByteOrder.LITTLE_ENDIAN); objPacket.put(0, (byte) 0x17); Tools.stringfill(strName, 0, objPacket.array(), 1, 32); Tools.stringfill(strEmail, 0, objPacket.array(), 33, 64); Tools.stringfill(strCity, 0, objPacket.array(), 97, 32); Tools.stringfill(strState, 0, objPacket.array(), 129, 24); objPacket.put(153, (byte) (cSex & 0xFF)); objPacket.put(154, bAge); objPacket.put(155, (byte) 0x01); // Connecting From ...Home objPacket.put(156, (byte) 0x01); // ...Work objPacket.put(157, (byte) 0x01); // ...School objPacket.putInt(158, 0x5678); // Processor... Maybe fix this later. objPacket.putShort(162, (short) 0xC000); // Magic Number #1 objPacket.putShort(164, (short) 2036); // Magic Number #2 Tools.stringfill("Cerium", 0, objPacket.array(), 166, 40); // Windows Reg Info: Real Name Tools.stringfill("Hybrid", 0, objPacket.array(), 206, 40); // Windows Reg Info: Organization Arrays.fill(objPacket.array(), 246, 766, (byte) 0x00); // Not sending hardware info, sorry. super.postPacket(objPacket, true); }
»Admiral Kirk Posted August 9, 2006 Author Report Posted August 9, 2006 That all looks right. Only problem is that Byte 19 never comes in as 1, even when I attempt to login with an unknown user name. Byte 1 does come back as 1 but Byte 19 is still 0. Here is my understanding of the password Packet Offset Length Description 0 1 Type byte 1 1 Boolean: New user *1 2 32 Name 34 32 password 66 4 Machine ident *2 70 1 ConnectType *3 71 2 Timezone bias 73 2 ? 75 2 Client version *4 77 4 ? memory checksum, Set to = 444 81 4 ? memory checksum, Set to = 555 85 4 Permission ident 89 12 ? And ya know... As im sitting here typing out this reply.. Mabye it has something to do with that New User Byte up thier in the password packet? Is that important? And if so, how might one determine if the user about to be logged in is a new user? Or should that bit be set on a subsequent password packet if we recieve a response of 1 (unkown user)?
»Admiral Kirk Posted August 9, 2006 Author Report Posted August 9, 2006 Yess... Now I see. The first PW response comes with a response of 0x01 and reg of 0x00 then you send another PW packet with New User byte set, and then it response with a 0x00 and reg of 0x01. And I should assume it will come back with something other than 0x01 if the user name given is entirly illegal? Ok.. I think this is all making sense now, lets see if I can get it working ^^
»Admiral Kirk Posted August 9, 2006 Author Report Posted August 9, 2006 Sweet! Works like a champ! Thanks Cerium!
»Ceiu Posted August 10, 2006 Report Posted August 10, 2006 Yeah, sorry about that; I was half asleep when I replied. Anyway, the first argument in my SendP!@#$%^&*wordPacket function is a boolean value for new user. Youve already got the rest figured out so...
Recommended Posts