Author | Message | Time |
---|---|---|
Final | Whats up i just started working on a bot need some help with 0x50 packet i Send it out But i dont recieve anything back. Heres my Setup [code] InsertDWORD(0); InsertNonNTString("68XIRATS"); InsertDWORD(0xCF); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertNTString("USA"); InsertNTString("United States"); SendPacket(0x50); [/code] This is in C++ Dev-C++Compiler | September 29, 2006, 11:15 PM |
Myndfyr | Are you calling recv() ? | September 29, 2006, 11:21 PM |
Final | shit wow that was fast lol Ok i figured out what i did wrong I didnt setup socket well but now that i send it it disconnects me . Do i have to send something before 0x50 by any chance | September 29, 2006, 11:22 PM |
l2k-Shadow | you're missing a DWORD | September 30, 2006, 12:18 AM |
HeRo | Before sending 0x50, send Chr(1). | September 30, 2006, 12:19 AM |
Ringo | [quote author=Final link=topic=15807.msg159177#msg159177 date=1159572148] Do i have to send something before 0x50 by any chance [/quote] Yeah, you need to send a protocol byte 0x01 for game, 0x02 for FTP file transfer. If there is still a problem, and your socket is set up right, you will need to post a packet capture of your program, so we can pick through it :) Checking a packet capture from your program Vs a packet capture from the client your trying to emulate, should help you alot with issues like this one :P | September 30, 2006, 12:20 AM |
Final | Like this? [code] SendPacket(0x01); InsertDWORD(0); InsertNonNTString("68XIRATS"); InsertDWORD(0xCF); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertNTString("USA"); InsertNTString("United States"); SendPacket(0x50); [/code] I still getting disconnected i dont understand wy | September 30, 2006, 12:52 AM |
HdxBmx27 | chr(0x01) not packet 0x01 1 single byte, w/o anything else. ~-~(HDX)~-~ | September 30, 2006, 12:57 AM |
l2k-Shadow | [quote author=Final link=topic=15807.msg159185#msg159185 date=1159577552] Like this? [code] SendPacket(0x01); InsertDWORD(0); InsertNonNTString("68XIRATS"); InsertDWORD(0xCF); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertDWORD(0); InsertNTString("USA"); InsertNTString("United States"); SendPacket(0x50); [/code] I still getting disconnected i dont understand wy [/quote] ::) not packet 0x01, BYTE 0x01 | September 30, 2006, 12:57 AM |
Final | im sorry but whats CHR()? im using c++ and how would i do a byte just add another DWORD? or WORD? | September 30, 2006, 1:00 AM |
HdxBmx27 | [quote author=Final link=topic=15807.msg159188#msg159188 date=1159578012] im sorry but whats CHR()? im using c++ and how would i do a byte just add another DWORD? or WORD? [/quote] Well considering a Word is 2 bytes And a DWord is 2 words That would make a DWord 4 bytes.... just use send(0x01) or w/e the function to send data through your socket is in Cpp ~-~(HDX)~-~ | September 30, 2006, 1:02 AM |
rabbit | send('\1'); | September 30, 2006, 1:05 AM |
Final | Ok I have to this point [code] DWORD logontype=*(unsigned long *)(buffer+4); servertoken=*(unsigned long *)(buffer+sizeof(logontype)); DWORD UPDValue=*(unsigned long *)(buffer+sizeof(servertoken)); int time=(int)(buffer+sizeof(UPDValue)); char* verfile=buffer+sizeof(time); char* valuestring=buffer+sizeof(verfile); int checkrev; checkrev=checkRevisionFlat(valuestring,"STAR/Starcraft.exe","STAR/storm.dll","STAR/battle.snp",time,??); [/code] but what goes in the last arguement were it says ??..? | September 30, 2006, 1:08 AM |
JoeTheOdd | No, use a packet reader! :'(. | September 30, 2006, 3:24 AM |
l2k-Shadow | [quote author=Joe[x86] link=topic=15807.msg159198#msg159198 date=1159586673] No, use a packet reader! :'(. [/quote] Yeah I second that that will make your code... much cleaner and better. now that we're past that part, you are reading the packet wrong. logontype - fine servertoken - fine UPDValue (fyi it's UDP) - fine time - that value is a FILETIME so it is 8 bytes long. definitely not an int. verfile - that's fine just remember that BNCSUtil's CheckRevision() wants the mpq number, not the whole file, use extractMPQNumber() function valuestring - fine in last field goes your checksum variable, which is the whole point of doing CheckRevision(), the return value simply tells you if the function succeeded or not. | September 30, 2006, 4:09 AM |
Final | Ok a friend of mine has been helping me out but we werent able to get a 0x51 in return can someone look over my 0x51 pakcet put together. [code] case SID_AUTH_INFO: { addchat("[BNET]Recieved 0x50"); servertoken= *(unsigned long *)(buffer + 8); char filename[256];//=buffer+24; char valuestring[256];// = buffer+39; strcpy(filename,buffer+24); strcpy(valuestring,buffer+39); clienttoken = GetTickCount(); int checkrev; int checkmpq; unsigned long checkSum = 0; checkmpq=extractMPQNumber(filename); if(checkmpq!=-1){ checkrev=checkRevisionFlat(valuestring,"C:\\STAR\\starcraft.exe","C:\\STAR\\storm.dll","C:\\STAR\\battle.snp",checkmpq,&checkSum); if(checkrev!=0){ unsigned long decoder=kd_create("2268812361134",13); if(decoder!=-1){ long hashLength=kd_calculateHash(decoder,clienttoken,servertoken); if(hashLength!=0){ char keyHash[hashLength]; kd_getHash(decoder,keyHash); if(keyHash!=0){ int prod=kd_product(decoder); if(prod!=0){ int pub=kd_val1(decoder); if(pub!=0){ char exeInformation[300]; memset(exeInformation,0x0,300); unsigned int Version; int VerID = getExeInfo("C:\\STAR\\starcraft.exe", exeInformation, 300, &Version,0x1); if(VerID!=0){ InsertDWORD(clienttoken); InsertDWORD(VerID); InsertDWORD(checkSum); InsertDWORD(1); InsertDWORD(0); InsertDWORD(13); InsertDWORD(prod); InsertDWORD(pub); InsertDWORD(0); InsertNonNTString(keyHash); InsertNonNTString(exeInformation); InsertNTString("Franky N."); SendPacket(0x51); addchat("[BNET]Sent 0x51"); }else{ addchat("Public is Incorrect"); } }else{ addchat("Product is Incorrect"); } }else{ addchat("VerId is Incorrect"); } }else{ addchat("KeyHash is Incorrect"); } }else{ addchat("HashLength is Incorrect"); } }else{ addchat("Key Is Incorrect"); } }else{ addchat("Error CheckRevision"); } }else{ addchat("Error Mpq File"); } } break; [/code] | September 30, 2006, 6:13 AM |
UserLoser | It appears you commented out the function to send the packet, try uncommenting the line and try it again. BTW, this is so bad...: [code] char* filename=buffer+24; char* valuestring = buffer+39; [/code] You can't do that...try using something like strcpy or similiar. i.e. char filename[size]; strcpy(filename, buffer+24); Should also have paths for files like "C:\\Starcraft\\Storm.dll", etc. Not "C:/Starcraft/Storm.dll" Also, use the tab key and whitespace please. It's horrific seeing and reading code like that... | September 30, 2006, 6:35 AM |
Final | I commented it out for debuging purposes. I just do that so i can check everything else i have done it without commented out and it dont work. I tried what you said and iit still aint working do you see anything else that might be wrong. HERE ARE MY LOGS [code] 1 Hide Hide 59 Send 0000 01 FF 50 3A 00 00 00 00 00 36 38 58 49 52 41 54 ..P:.....68XIRAT 0010 53 CF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 S............... 0020 00 00 00 00 00 00 00 00 00 55 53 41 00 55 6E 69 .........USA.Uni 0030 74 65 64 20 53 74 61 74 65 73 00 ted States. 2 Hide Hide 4 Send 0000 FF 25 08 00 .%.. 3 Hide Hide 116 Send 0000 FF 51 74 00 B9 92 31 21 27 00 00 00 7B 6A 94 81 .Qt...1!'...{j.. 0010 01 00 00 00 00 00 00 00 0D 00 00 00 01 00 00 00 ................ 0020 80 15 32 00 00 00 00 00 83 97 AC EF 6B C9 AF C3 ..2.........k... 0030 08 38 4E AF D0 2D C6 DD EA C1 E5 87 87 AE 4D F3 .8N..-........M. 0040 55 10 44 73 74 61 72 63 72 61 66 74 2E 65 78 65 U.Dstarcraft.exe 0050 20 30 39 2F 33 30 2F 30 36 20 30 35 3A 33 38 3A 09/30/06 05:38: 0060 32 34 20 31 32 31 36 35 31 32 46 72 61 6E 6B 79 24 1216512Franky 0070 20 4E 2E 00 N.. [/code] | September 30, 2006, 6:54 AM |
Yegg | I'm curious, what happens when someone does this: [code]2 Hide Hide 4 Send 0000 FF 25 08 00 .%..[/code] He didn't include the data for that packet. In your 0x51 packet, you failed to include a 0x00 after the exe information string. You did include one after your cdkey owner name string. Is the owner name FrankyN. (yes, with the period)? Other things can be wrong, but the Battle.net protocol is not something I know well or try to know well. I happened to know some about what your packets were missing. Edit: It may be possible that your 0x51 packet has 2 extra, unnecessary DWORDs in there. According to [quote](DWORD) Client Token (DWORD) EXE Version (DWORD) EXE Hash (DWORD) Number of keys in this packet (BOOLEAN) Using Spawn (32-bit) For Each Key: (DWORD) Key Length (DWORD) CD key's product value (DWORD) CD key's public value (DWORD) Unknown (0) (DWORD[5]) Hashed Key Data (STRING) Exe Information (STRING) CD Key owner name[/quote] from BnetDocs, your packet's information does not match up size-wise. Of your 14 DWORDs, they should equal exactly 56 bytes of space. Yours equals 63 bytes. So, it isn't really 2 extra DWORDs added. I'm not entirely sure what you did. Edit: Something else looks wrong. Your exe version is 0x27? | September 30, 2006, 12:10 PM |
l2k-Shadow | he's doing InsertDWORD(VerID) instead of InsertDWORD(Version) | September 30, 2006, 1:46 PM |
Final | Wait so im suppose to put Version instead of VerID? After CHanges/ [code] 1 Hide Hide 59 Send 0000 01 FF 50 3A 00 00 00 00 00 36 38 58 49 52 41 54 ..P:.....68XIRAT 0010 53 CF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 S............... 0020 00 00 00 00 00 00 00 00 00 55 53 41 00 55 6E 69 .........USA.Uni 0030 74 65 64 20 53 74 61 74 65 73 00 ted States. 2 Hide Hide 4 Send 0000 FF 25 08 00 .%.. 3 Hide Hide 117 Send 0000 FF 51 75 00 28 07 27 23 01 00 0E 01 5C 5E D9 15 .Qu.(.'#....\^.. 0010 01 00 00 00 00 00 00 00 0D 00 00 00 01 00 00 00 ................ 0020 80 15 32 00 00 00 00 00 61 F1 90 37 CC 50 76 94 ..2.....a..7.Pv. 0030 8A 78 63 D7 1C D0 1A 18 0C 1D 69 0E A2 CA F5 6A .xc.......i....j 0040 9D 20 44 73 74 61 72 63 72 61 66 74 2E 65 78 65 . Dstarcraft.exe 0050 20 30 39 2F 33 30 2F 30 36 20 30 35 3A 33 38 3A 09/30/06 05:38: 0060 32 34 20 31 32 31 36 35 31 32 00 46 72 61 6E 6B 24 1216512.Frank 0070 79 20 4E 2E 00 y N.. [/code] what did i do wrong ? | September 30, 2006, 5:12 PM |
UserLoser | [quote] [code] 2 Hide Hide 4 Send 0000 FF 25 08 00 .%.. [/code] [/quote] Set size to 8, there is not 8 bytes of data there. | September 30, 2006, 5:29 PM |
Final | dude thats the ping packet. EDIT OH DEAR GOD IT WAS THE FUCKING PING PACKET. Bot Initialized Version 1.0.0 <-1:45:17>: [BNET]Connecting <-1:45:17>: [BNET]Connected <-1:45:17>: [BNET]Sent 0x50 <-1:45:17>: [BNET]Recieved 0x25 <-1:45:17>: [BNET]Sent 0x25 <-1:45:17>: [BNET]Recieved 0x50 <-1:45:17>: [BNET]Sent 0x51 <-1:45:17>: [BNET]Recieved 0x51 <-1:45:17>: [BNET]Passed challenge <-1:45:17>: [BNET]Sent 0x29 <-1:45:17>: [BNET]Recieved 0x29 <-1:45:17>: [BNET]Login Was Successfull <-1:45:17>: [BNET]You have Entered Chat | September 30, 2006, 5:39 PM |
HeRo | Userloser saves the day! | September 30, 2006, 7:35 PM |
Final | I got another problem though How do i join chat like were i talk and stuff. Im here. ok I recieve 0x29 but I dont know what to do afterwards? [code] addchat("[BNET]Login Was Successfull"); InsertNonNTString("tenb"); SendPacket(0x14); InsertNTString("Unkownname"); InsertNTString(""); SendPacket(0x0A); InsertDWORD(productid); SendPacket(0x0B); InsertDWORD(0x01); InsertNTString("hello"); SendPacket(0x0C); addchat("Joining a channel"); connected=true; addchat("[BNET]You have Entered Chat"); [/code] | September 30, 2006, 9:17 PM |
l2k-Shadow | 0x0A -> 0x0C joins chat. Make sure that the name you are connecting with is "Unknownname" since that's what you're using for the string. 0x14 and 0x0B are optional packets and do not have to be sent. After you are in chat look into parsing 0x0F | September 30, 2006, 9:36 PM |
Final | NICE A friend was helping me out and i was able to connect and into a channel awsome. I got another question Lets say im chatting do i have to use packets to send like /wisper /join /me or do i just sent the chat packet? | September 30, 2006, 9:49 PM |
l2k-Shadow | you send 0x0E for all chat messages, whether it's a "/join Channel" or "Hi". | September 30, 2006, 9:53 PM |
Final | Thanks mate | September 30, 2006, 10:06 PM |
Myndfyr | [quote author=l2k-Shadow link=topic=15807.msg159249#msg159249 date=1159653196] you send 0x0E for all chat messages, whether it's a "/join Channel" or "Hi". [/quote] /join <channelName> does not need to be a chat message, though. You can parse the message and use 0x0c SID_JOINCHANNEL to join a channel as well. | September 30, 2006, 10:13 PM |
Final | Hey I need some help for some reason when i use these packets to go into channel HELLO i go to the void what am i doing wrong [code] InsertNTString("unkownname"); InsertNTString(""); SendPacket(0x0A); InsertDWORD(0x01); InsertNTString("hello"); SendPacket(0x0C); [/code] | September 30, 2006, 10:18 PM |
UserLoser | Sending channel join flag type 1 with a name like that will most likely send you to the wrong place. 1 is for joining product specific channels | September 30, 2006, 10:32 PM |
Final | Would it mean anything if my key is muted? | September 30, 2006, 10:37 PM |
l2k-Shadow | [quote author=Final link=topic=15807.msg159256#msg159256 date=1159655857] Would it mean anything if my key is muted? [/quote] no, only if it is voided. sending flag 0x02 will force join a channel. | September 30, 2006, 10:56 PM |
Final | Am i doing this correctly? Cuz i sometimes cant get in wierd. [code] case 0x000: { addchat("[BNET]Passed challenge"); char hashedpassword[MAX_PATH]; doubleHashPassword(bnet_password,clienttoken,servertoken,hashedpassword); InsertDWORD(clienttoken); InsertDWORD(servertoken); InsertNonNTString(hashedpassword);//Hashed Password// InsertNTString(bnet_username); SendPacket(0x29); addchat("[BNET]Sent 0x29"); }break; [/code] | October 1, 2006, 12:35 AM |
l2k-Shadow | [quote author=Final link=topic=15807.msg159266#msg159266 date=1159662949] Am i doing this correctly? Cuz i sometimes cant get in wierd. [code] case 0x000: { addchat("[BNET]Passed challenge"); char hashedpassword[MAX_PATH]; doubleHashPassword(bnet_password,clienttoken,servertoken,hashedpassword); InsertDWORD(clienttoken); InsertDWORD(servertoken); InsertNonNTString(hashedpassword);//Hashed Password// InsertNTString(bnet_username); SendPacket(0x29); addchat("[BNET]Sent 0x29"); }break; [/code] [/quote] the password hash will always be 20 bytes long for OLS clients, so try changing that... also make sure your client token is static throughout the entire login sequence (however that won't make a difference here). | October 1, 2006, 1:20 AM |
Final | well how would i go about changing it ? I dont understand you. | October 1, 2006, 1:29 AM |
l2k-Shadow | [quote author=Final link=topic=15807.msg159273#msg159273 date=1159666176] well how would i go about changing it ? I dont understand you. [/quote] lol... how about something along these lines? [code] char hashedpassword[19]; [/code] | October 1, 2006, 2:09 AM |
Myndfyr | [quote author=l2k-Shadow link=topic=15807.msg159274#msg159274 date=1159668587] [quote author=Final link=topic=15807.msg159273#msg159273 date=1159666176] well how would i go about changing it ? I dont understand you. [/quote] lol... how about something along these lines? [code] char hashedpassword[19]; [/code] [/quote] Usually hashes are 20 bytes, aren't they? | October 1, 2006, 4:56 AM |
l2k-Shadow | [quote author=MyndFyre[vL] link=topic=15807.msg159278#msg159278 date=1159678570] [quote author=l2k-Shadow link=topic=15807.msg159274#msg159274 date=1159668587] [quote author=Final link=topic=15807.msg159273#msg159273 date=1159666176] well how would i go about changing it ? I dont understand you. [/quote] lol... how about something along these lines? [code] char hashedpassword[19]; [/code] [/quote] Usually hashes are 20 bytes, aren't they? [/quote] which is why it would be 19. arrays start at 0, or is there something i am mssing? | October 1, 2006, 5:07 AM |
Myndfyr | [quote author=l2k-Shadow link=topic=15807.msg159279#msg159279 date=1159679232] [quote author=MyndFyre[vL] link=topic=15807.msg159278#msg159278 date=1159678570] [quote author=l2k-Shadow link=topic=15807.msg159274#msg159274 date=1159668587] [quote author=Final link=topic=15807.msg159273#msg159273 date=1159666176] well how would i go about changing it ? I dont understand you. [/quote] lol... how about something along these lines? [code] char hashedpassword[19]; [/code] [/quote] Usually hashes are 20 bytes, aren't they? [/quote] which is why it would be 19. arrays start at 0, or is there something i am mssing? [/quote] But C arrays are declared and initialized with the size, not the top index. | October 1, 2006, 5:23 AM |
Final | Yes dude its not size. | October 1, 2006, 5:37 AM |
UserLoser | [quote author=l2k-Shadow link=topic=15807.msg159279#msg159279 date=1159679232] [quote author=MyndFyre[vL] link=topic=15807.msg159278#msg159278 date=1159678570] [quote author=l2k-Shadow link=topic=15807.msg159274#msg159274 date=1159668587] [quote author=Final link=topic=15807.msg159273#msg159273 date=1159666176] well how would i go about changing it ? I dont understand you. [/quote] lol... how about something along these lines? [code] char hashedpassword[19]; [/code] [/quote] Usually hashes are 20 bytes, aren't they? [/quote] which is why it would be 19. arrays start at 0, or is there something i am mssing? [/quote] 19 means 19 elements. 0 - 18 is 19 items. There is no 19th | October 1, 2006, 5:38 AM |
l2k-Shadow | [quote author=UserLoser link=topic=15807.msg159282#msg159282 date=1159681130] [quote author=l2k-Shadow link=topic=15807.msg159279#msg159279 date=1159679232] [quote author=MyndFyre[vL] link=topic=15807.msg159278#msg159278 date=1159678570] [quote author=l2k-Shadow link=topic=15807.msg159274#msg159274 date=1159668587] [quote author=Final link=topic=15807.msg159273#msg159273 date=1159666176] well how would i go about changing it ? I dont understand you. [/quote] lol... how about something along these lines? [code] char hashedpassword[19]; [/code] [/quote] Usually hashes are 20 bytes, aren't they? [/quote] which is why it would be 19. arrays start at 0, or is there something i am mssing? [/quote] 19 means 19 elements. 0 - 18 is 19 items. There is no 19th [/quote] right i get it now. thanks for clarifiying. | October 1, 2006, 5:52 AM |
Final | Thanks to that It logins more reccently heh thanks. -Well I need some more help- Ok ive having problems getting strings. [code] class debuff { public: char packet[MAX_PATH]; int ps; void setpos(int set); void newpacket(char buffer[MAX_PATH]); WORD getword(); DWORD getdword(); char* getstring(); void skipfiletime(); }; void debuff::newpacket(char buffer[MAX_PATH]){ memcpy(packet,buffer,sizeof(buffer)+1); ps=4; } WORD debuff::getword(){ WORD value=*(unsigned long*)(packet+ps); ps=ps+2; return value; } DWORD debuff::getdword(){ DWORD value=*(unsigned long*)(packet+ps); ps=ps+4; return value; } char* debuff::getstring(){ char* value=packet+ps; ps=ps+strlen(value); return value; } void debuff::skipfiletime(){ ps=ps+8; } [/code] | October 1, 2006, 6:10 AM |
Spilled[DW] | use memchr() for your getstrings method, its very helpful | October 2, 2006, 6:49 PM |
Final | how would that work out? I read how it works but ? yah. | October 2, 2006, 10:26 PM |
Spilled[DW] | [quote author=Final link=topic=15807.msg159309#msg159309 date=1159827986] how would that work out? I read how it works but ? yah. [/quote] hrmm.... well lets see.... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_crt_memchr.asp First parameter would be a pointer to the actual buffer which in this case is the packet, Next parameter is the character to look for, for example 'c'., and the final parameter is the size of the buffer. Return value is the location.... what don't you get? you can find an example on that link. Just use the return value and strcpy() to copy the string and return..... | October 3, 2006, 12:26 AM |
Final | wy would i be looking for a character? thats wy i said i didnt understand the use for this? | October 3, 2006, 1:25 AM |
HdxBmx27 | '\x0' Thats why, you get the position of the null, and then use strcpy() to copy out the string. ~-~(HDX)~-~ | October 3, 2006, 2:51 AM |
Final | Is their a problem with this because it sorta crashes my program? [code] char* debuff::getstring(){ char* p; if(memchr(packet+ps, '\x0',strlen(packet)-ps)) { strcpy(p, packet+ps); ps += strlen(p) + 1; } else { memcpy(p, packet+ps,strlen(packet)-ps); p[strlen(packet) - ps] = '\x0'; ps = strlen(packet); } return p; } [/code] | October 3, 2006, 4:35 AM |
UserLoser | Can't use strlen for binary streams of data, like Battle.net messages, for example. strlen ends when it finds a null character, the server gives you the length of the message. | October 3, 2006, 1:24 PM |
Final | so then sizeof() ?? | October 3, 2006, 1:28 PM |
UserLoser | [quote author=Final link=topic=15807.msg159360#msg159360 date=1159882139] so then sizeof() ?? [/quote] No, not at all. It really helps to learn the language first for simple stream manipulation and learn the proper use of operators such as sizeof... | October 3, 2006, 1:46 PM |
Final | dude i understand the language its header files you should say.?w/e thats besides the point i was in math class and thinking the function over all day cuz im bored so i just like doing that. So what im doing is getting the null ending of the string its location then thats my end? and i start were my position is on the packet correct? sizeof() works by getting the size of the arguement without stoping at 0x00 strlen does the the same but stops when it meets one of those. | October 3, 2006, 10:15 PM |
UserLoser | [quote author=Final link=topic=15807.msg159375#msg159375 date=1159913732] dude i understand the language its header files you should say.?w/e thats besides the point i was in math class and thinking the function over all day cuz im bored so i just like doing that. So what im doing is getting the null ending of the string its location then thats my end? and i start were my position is on the packet correct? sizeof() works by getting the size of the arguement without stoping at 0x00 strlen does the the same but stops when it meets one of those. [/quote] Something like that, but sizeof won't ever be what you need here. | October 3, 2006, 10:36 PM |
Final | oh no i understand the use of it dont worry i just thout you were suggesting it for some reason im stupid EVERYONE in valhalla hates me. | October 3, 2006, 11:17 PM |
UserLoser | We don't hate you, we are not going to hold your hand down the correct path--instead we will lead you to it so you can carry on on your own. | October 3, 2006, 11:36 PM |
Final | its not that i always get yelled at for mispelling sniff. Once i got dist cuz i was mexican sniff. And i understand if you spoon feed i cant learn ANYTHING. common knoledge yet so many do it. Need to make this post meaningfull cuz this is way off topic. Ok ive been doing this. [code] memcpy(packet,packet+ps,sizeof(packet+ps)+1); [/code] So it deletes what i just used. | October 3, 2006, 11:43 PM |
UserLoser | Again, youu can't use sizeof for this. Look at the structure of the packet header and think what useful information is inside of it for correctly handling packets from the server | October 3, 2006, 11:54 PM |
Myndfyr | Why don't you do something like this: [code] // Please note: I'm assuming packet is the char* containing your packet // data, and ps is the offset into the packet that you're currently at. int debuff::nextStrLen() const { char* pCur = packet + ps; char* pStart = pCur; // assume at least a size of 1 for a null terminator (empty string) int nLen = 1; while (*pCur != 0) pCur++; return pStart - pCur; } #define E_BUFFER_TOO_SMALL 0xDEADC0DE int debuf::getStr(char* result, int bufferSize) { char* pStart = packet + ps; int strLen = nextStrLen(); if (bufferSize < strLen) return E_BUFFER_TOO_SMALL; memcpy(result, const_cast<const char*>(packet), strLen); ps += strLen; return strLen; } [/code] To get the length of the next string, use nextStrLen(). This function returns the length of the next null-terminated string and includes the additional null terminaotr. To get the next string, use getStr(char*, int). You are required to pass the buffer to which the string will be copied (the function does not allocate a new string), as well as the length of the buffer. The buffer must be at least nextStrLen() bytes long; if the function detects that this is not the case, it will return E_BUFFER_TOO_SMALL, a negative value. | October 4, 2006, 12:18 AM |
Final | //message sent to userloser added after mynd's sorry. Ok watch i did this because sizeof() dosent stop at a null so sizeof(packet+ps); would get size of everything after packet+ps without stoping giving me me all info. //to mynd the packet isint a char* its a char var[MAX_PATH];<---sorry about the max_path; but i use that to get the pos to the next data in packet unused. heres my code. [code] WORD debuff::getword(){ WORD value=*(unsigned long*)(packet+ps); ps=ps+2; memcpy(packet,packet+ps,sizeof(packet+ps)+1); return value; } DWORD debuff::getdword(){ DWORD value=*(unsigned long*)(packet+ps); ps=ps+4; memcpy(packet,packet+ps,sizeof(packet+ps)+1); return value; } [/code] | October 4, 2006, 12:23 AM |
UserLoser | [code] const int MAX_PATH = 260; int ps = 3; char *test = "this is a test"; char packet[MAX_PATH] = { 0xff, 0x25, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04 }; cout << "sizeof(test) = " << sizeof(test) << endl; cout << "sizeof(*test) = " << sizeof(*test) << endl; cout << "sizeof(packet) = " << sizeof(packet) << endl; cout << "sizeof(packet+ps) = " << sizeof(packet+ps) << endl; cout << "MAX_PATH = " << MAX_PATH << endl; [/code] [quote] sizeof(test) = 4 sizeof(*test) = 1 sizeof(packet) = 260 sizeof(packet+ps) = 4 MAX_PATH = 260 [/quote] Do not use sizeof, that is not what it is for. | October 4, 2006, 12:53 AM |
Final | ok i guess i wasent passing the buffer right it just does not like so i just did this functionname(buffer){ //data } Im having issues though how would i get the size because of the pos like wtf do i do [code] char* debuff::getstring(char packet[MAX_PATH]){ char* value=packet+pos; pos=pos+strlen(value); return value; } [/code] It wont add or i d k because when i get a message from someone it dosent get the message only username ? --Never mind i just added a 1 after strlen() forgot about the 0x00 | October 4, 2006, 1:00 AM |
Myndfyr | [quote author=Final link=topic=15807.msg159387#msg159387 date=1159921395] the packet isint a char* its a char var[MAX_PATH];<---sorry about the max_path; [/quote] This is precisely what UserLoser means by his remark that you should learn the language. A char array (like you said char var[MAX_PATH]) is exactly the same as a char*. For instance, you could: [code] char packet[255]; char* pck = &packet[0]; [/code] The brackets used in array notation are just implicit pointer arithmetic. For instance, the next two expressions are equivalent: [code] char value = packet[220]; char value = *(packet + (sizeof(char) * 220)); [/code] So, as you can see, the bracket operator just adds the product of the size of the value and the index to the base location in memory of the array and dereferences it. | October 4, 2006, 2:44 AM |
Final | i understand their the same but i was just saying i wassent declaring it as a char* i was using char [] dude chill out. | October 4, 2006, 3:03 AM |
warz | It's also worth noting that MAX_PATH is already defined in windows.h. | October 4, 2006, 5:17 AM |
UserLoser | [quote author=warz link=topic=15807.msg159402#msg159402 date=1159939069] It's also worth noting that MAX_PATH is already defined in windows.h. [/quote] I didn't include windows.h because I used an already existing project for school for this example and didn't want to modify the included files | October 4, 2006, 2:31 PM |