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
InsertDWORD(0);
InsertNonNTString("68XIRATS");
InsertDWORD(0xCF);
InsertDWORD(0);
InsertDWORD(0);
InsertDWORD(0);
InsertDWORD(0);
InsertNTString("USA");
InsertNTString("United States");
SendPacket(0x50);
This is in C++ Dev-C++Compiler
Are you calling recv() ?
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
you're missing a DWORD
Before sending 0x50, send Chr(1).
Quote from: Final on September 29, 2006, 06:22 PM
Do i have to send something before 0x50 by any chance
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
Like this?
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);
I still getting disconnected i dont understand wy
chr(0x01) not packet 0x01
1 single byte, w/o anything else.
~-~(HDX)~-~
Quote from: Final on September 29, 2006, 07:52 PM
Like this?
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);
I still getting disconnected i dont understand wy
::) not packet 0x01,
BYTE 0x01
im sorry but whats CHR()? im using c++ and how would i do a byte just add another DWORD? or WORD?
Quote from: Final on September 29, 2006, 08:00 PM
im sorry but whats CHR()? im using c++ and how would i do a byte just add another DWORD? or WORD?
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)~-~
send('\1');
Ok I have to this point
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,??);
but what goes in the last arguement were it says ??..?
No, use a packet reader! :'(.
Quote from: Joex86] link=topic=15807.msg159198#msg159198 date=1159586673]
No, use a packet reader! :'(.
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.
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.
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;
It appears you commented out the function to send the packet, try uncommenting the line and try it again.
BTW, this is so bad...:
char* filename=buffer+24;
char* valuestring = buffer+39;
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...
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
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..
I'm curious, what happens when someone does this:
2 Hide Hide 4 Send
0000 FF 25 08 00 .%..
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
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?
he's doing InsertDWORD(VerID) instead of InsertDWORD(Version)
Wait so im suppose to put Version instead of VerID?
After CHanges/
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..
what did i do wrong ?
Quote
2 Hide Hide 4 Send
0000 FF 25 08 00 .%..
Set size to 8, there is not 8 bytes of data there.
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
Userloser saves the day!
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?
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");
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
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?
you send 0x0E for all chat messages, whether it's a "/join Channel" or "Hi".
Thanks mate
Quote from: l2k-Shadow on September 30, 2006, 04:53 PM
you send 0x0E for all chat messages, whether it's a "/join Channel" or "Hi".
/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.
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
InsertNTString("unkownname");
InsertNTString("");
SendPacket(0x0A);
InsertDWORD(0x01);
InsertNTString("hello");
SendPacket(0x0C);
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
Would it mean anything if my key is muted?
Quote from: Final on September 30, 2006, 05:37 PM
Would it mean anything if my key is muted?
no, only if it is voided. sending flag 0x02 will force join a channel.
Am i doing this correctly?
Cuz i sometimes cant get in wierd.
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;
Quote from: Final on September 30, 2006, 07:35 PM
Am i doing this correctly?
Cuz i sometimes cant get in wierd.
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;
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).
well how would i go about changing it ? I dont understand you.
Quote from: Final on September 30, 2006, 08:29 PM
well how would i go about changing it ? I dont understand you.
lol... how about something along these lines?
char hashedpassword[19];
Quote from: l2k-Shadow on September 30, 2006, 09:09 PM
Quote from: Final on September 30, 2006, 08:29 PM
well how would i go about changing it ? I dont understand you.
lol... how about something along these lines?
char hashedpassword[19];
Usually hashes are 20 bytes, aren't they?
Quote from: MyndFyre[vL] on September 30, 2006, 11:56 PM
Quote from: l2k-Shadow on September 30, 2006, 09:09 PM
Quote from: Final on September 30, 2006, 08:29 PM
well how would i go about changing it ? I dont understand you.
lol... how about something along these lines?
char hashedpassword[19];
Usually hashes are 20 bytes, aren't they?
which is why it would be 19. arrays start at 0, or is there something i am mssing?
Quote from: l2k-Shadow on October 01, 2006, 12:07 AM
Quote from: MyndFyre[vL] on September 30, 2006, 11:56 PM
Quote from: l2k-Shadow on September 30, 2006, 09:09 PM
Quote from: Final on September 30, 2006, 08:29 PM
well how would i go about changing it ? I dont understand you.
lol... how about something along these lines?
char hashedpassword[19];
Usually hashes are 20 bytes, aren't they?
which is why it would be 19. arrays start at 0, or is there something i am mssing?
But C arrays are declared and initialized with the size, not the top index.
Yes dude its not size.
Quote from: l2k-Shadow on October 01, 2006, 12:07 AM
Quote from: MyndFyre[vL] on September 30, 2006, 11:56 PM
Quote from: l2k-Shadow on September 30, 2006, 09:09 PM
Quote from: Final on September 30, 2006, 08:29 PM
well how would i go about changing it ? I dont understand you.
lol... how about something along these lines?
char hashedpassword[19];
Usually hashes are 20 bytes, aren't they?
which is why it would be 19. arrays start at 0, or is there something i am mssing?
19 means 19 elements. 0 - 18 is 19 items. There is no 19th
Quote from: UserLoser on October 01, 2006, 12:38 AM
Quote from: l2k-Shadow on October 01, 2006, 12:07 AM
Quote from: MyndFyre[vL] on September 30, 2006, 11:56 PM
Quote from: l2k-Shadow on September 30, 2006, 09:09 PM
Quote from: Final on September 30, 2006, 08:29 PM
well how would i go about changing it ? I dont understand you.
lol... how about something along these lines?
char hashedpassword[19];
Usually hashes are 20 bytes, aren't they?
which is why it would be 19. arrays start at 0, or is there something i am mssing?
19 means 19 elements. 0 - 18 is 19 items. There is no 19th
right i get it now. thanks for clarifiying.
Thanks to that It logins more reccently heh thanks.
-Well I need some more help-
Ok ive having problems getting strings.
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;
}
use memchr() for your getstrings method, its very helpful
how would that work out? I read how it works but ? yah.
Quote from: Final on October 02, 2006, 05:26 PM
how would that work out? I read how it works but ? yah.
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.....
wy would i be looking for a character?
thats wy i said i didnt understand the use for this?
'\x0'
Thats why, you get the position of the null, and then use strcpy() to copy out the string.
~-~(HDX)~-~
Is their a problem with this because it sorta crashes my program?
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;
}
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.
so then sizeof() ??
Quote from: Final on October 03, 2006, 08:28 AM
so then sizeof() ??
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 (http://msdn2.microsoft.com/en-us/library/4s7x1k91.aspx)...
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 from: Final on October 03, 2006, 05:15 PM
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.
Something like that, but sizeof won't ever be what you need here.
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.
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.
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.
memcpy(packet,packet+ps,sizeof(packet+ps)+1);
So it deletes what i just used.
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
Why don't you do something like this:
// 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;
}
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.
//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.
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;
}
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;
Quote
sizeof(test) = 4
sizeof(*test) = 1
sizeof(packet) = 260
sizeof(packet+ps) = 4
MAX_PATH = 260
Do
not use sizeof, that is not what it is for.
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
char* debuff::getstring(char packet[MAX_PATH]){
char* value=packet+pos;
pos=pos+strlen(value);
return value;
}
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
Quote from: Final on October 03, 2006, 07:23 PM
the packet isint a char* its a char var[MAX_PATH];<---sorry about the max_path;
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:
char packet[255];
char* pck = &packet[0];
The brackets used in array notation are just implicit pointer arithmetic. For instance, the next two expressions are equivalent:
char value = packet[220];
char value = *(packet + (sizeof(char) * 220));
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.
i understand their the same but i was just saying i wassent declaring it as a char* i was using char [] dude chill out.
It's also worth noting that MAX_PATH is already defined in windows.h.
Quote from: warz on October 04, 2006, 12:17 AM
It's also worth noting that MAX_PATH is already defined in windows.h.
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