Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 14:47

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 31 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: VB6 JA q3fill sort of thing problem...
PostPosted: 19 Mar 2011 10:10 

Joined: 04 Mar 2011 17:15
Posts: 17
ohai ;o
So um I was messing around the other day and I thought ''why not make q3fill''...
And so I tried.
I made a q3huff dll and used it in vb6, got the right challenge of the server, everything.
But for some random reason I get a responce from the server saying:
No or bad challenge for address.

Here's my code. I hope you guys can help.

Code:
Private Sub Command4_Click()
    Winsock3.RemoteHost = Text1.Text
    Winsock3.RemotePort = CInt(Text2.Text)
    Winsock4.RemoteHost = Text1.Text
    Winsock4.RemotePort = CInt(Text2.Text)
    Winsock3.SendData "????????getchallenge"
End Sub

Private Sub Winsock3_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
Winsock3.GetData Data, , bytesTotal
Challenge = Right(Data, Len(Data) - 22)

Dim packet As String

If Challenge <> "" Then
    packet = "????????connect " & _
    Chr(34) & _
    "\challenge\" & Challenge & _
    "\qport\" & Text2.Text & _
    "\protocol\26\" & _
    "name\" & Text7.Text & "\" & _
    "rate\24000\" & _
    "snaps\38\" & _
    "model\cultist\" & _
    "forcepowers\7-1-030000000000000330\" & _
    "color1\4\" & _
    "color2\4\" & _
    "handicap\100\" & _
    "sex\male\" & _
    "cg_predictItems\1\" & _
    "saber1\dual_1\" & _
    "saber2\none\" & _
    "char_color_red\255\" & _
    "char_color_green\255\" & _
    "char_color_blue\255\" & _
    "teamtask\0" & _
    Chr(34)
    Dim NewSize As Long
    NewSize = Huff_CompressPacket(packet, 12, Len(packet))
    MsgBox packet
    Winsock4.SendData packet
    Else
    MsgBox "No or bad challenge for address/", vbCritical, "Error"
End If
End Sub

Private Sub Winsock4_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
Winsock4.GetData Data, , bytesTotal
Text9.Text = Replace(Replace(Data, vbLf, vbNewLine), "????????", "")
'Challenge = Right(Data, Len(Data) - 22)
End Sub


Top
 Profile  
 
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 19 Mar 2011 22:37 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
yyyygetchallenge xxx
yyyychallengeresponse asdfasdfasdf
yyyyconnect \challenge\asdfasdfasdf

so you must be sure at 100% that your challenge is exactly the same returned by the getchallenge packet


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 20 Mar 2011 10:00 

Joined: 04 Mar 2011 17:15
Posts: 17
wait a sec...
yyygetchallenge xxx?
I just sent yyygetchallenge :l
What should this 'xxx' be?


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 20 Mar 2011 16:19 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
usually xxx is just xxx :)
you can use anything you want, I guess that originally it wanted to be like a possible additional handshake mechanism but it's totally ignored.
all the games use xxx by default


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 20 Mar 2011 21:51 

Joined: 04 Mar 2011 17:15
Posts: 17
._. well it's still not working...Guess that's just vb6's gayness :d
Thanks anyway...

Btw I'm wondering about this...
Huff_CompressPacket(packet, 12, Len(packet))
I guess in C it would be
Huff_CompressPacket(packet, 12, sizeof(packet));

Is it supposed to be sizeof(packet) or sizeof(packet) - 1 or something else...


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 20 Mar 2011 22:27 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
no in C it's just the exact size of the packet.
sizeof() tells the size of the memory taken by the buffer so it's not good for this work, that's why in my code I use the exact size of the packet like "len" or "p - buff" depending by the code.
the "sizeof(packet)-1" is used when you have data specified in a #define or in a buffer[] because the C compiler places ever a zero after it so that -1 doesn't count this addition


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 21 Mar 2011 12:31 

Joined: 04 Mar 2011 17:15
Posts: 17
._. well that was a big "bla-bla-bla" in my head...
Anyway can you see ANYTHING and I mean ANYTHING wrong with my code <.<?
Cuz I'm srsly hopeless. Even the guys at JACoders don't know lol!


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 21 Mar 2011 16:40 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
yes... the whole code :)
I'm a C boy, you can't ask me what is wrong in a VB code.

I hope you have visualized the content of the packet and the grabbed challenge to know if it's correct while running the program, right?

are you sure there are no bad chars like line feed (0x0a) or space (0x20) before/after the challenge you grab?


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 21 Mar 2011 19:44 

Joined: 04 Mar 2011 17:15
Posts: 17
Checked my code...over 10 times...and noap, no weird chars.
And you can go ahead and try to explain stuff in C I know both ;o


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 21 Mar 2011 23:09 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
if the challenge is correct then the problem could be just the connect packet.
in case of doubts you can verify it with my q3ts tool:
http://aluigi.org/testz/q3ts.zip

start it with double click and connect your code to 127.0.0.1 on port 27960.
it should help you a lot with the debugging of this stuff because it automatically decompress the connect packet and show it in hex and string mode.


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 22 Mar 2011 13:46 

Joined: 04 Mar 2011 17:15
Posts: 17
Image
Seems the last quote sign got cut off :/
No idea why lul it's in the code.

Btw I noticed this just now...
Image


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 23 Mar 2011 01:43 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
maybe it's caused by how you calculate the length of the packet.
remember that when you compress it will be also generated NULL bytes (0x00) so if Len(packet) considers them then the problem is perfectly normal


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 23 Mar 2011 15:03 

Joined: 04 Mar 2011 17:15
Posts: 17
I'm not sure it does ;o How can I find out...?


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 23 Mar 2011 23:56 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
you already have it, NewSize is the correct length


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 24 Mar 2011 12:17 

Joined: 04 Mar 2011 17:15
Posts: 17
Wait a sec I got confused...
What should I do now?


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 24 Mar 2011 15:06 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
the NewSize variable returned by Huff_CompressPacket contains the correct total size of the compressed packet to send


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 24 Mar 2011 16:08 

Joined: 04 Mar 2011 17:15
Posts: 17
Oh I get it...well k I'll give this a go...


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 01 Apr 2011 12:42 

Joined: 04 Mar 2011 17:15
Posts: 17
Ok I did that, but still nothing.
I tried, in jka to do /connect localhost:27960 (aka your tools shet) and I saw the same packet, followed by some DATA: shit. Any ideas?


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 02 Apr 2011 18:46 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
yes, give up.
if after all these suggestion, informations and examples with source code about a so simple thing you have still problems I guess that giving up is the only option.


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 03 Apr 2011 08:46 

Joined: 04 Mar 2011 17:15
Posts: 17
D: Well f*ck. I rly wanted to make that thing -.-
Well k...


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 07 Apr 2011 20:13 

Joined: 07 Apr 2011 20:05
Posts: 4
Dont give up!, here is a code I wrote a long ass time ago for VB6, you need the attached DLL aswell (its a dll made from aluigi's code)

Functions that interact with the q3huff.dll:
Code:
Private Declare Function Huff_CompressPacket Lib "q3huff.dll" (msg As Byte, ByVal offset As Long, ByVal cursize As Long) As Long
Private Declare Function Huff_DecompressPacket Lib "q3huff.dll" (msg As Byte, ByVal offset As Long, ByVal cursize As Long, ByVal maxsize As Long) As Long

Public Sub CompressPacket(ByRef Data() As Byte)
Dim c          As Long
Dim intLen     As Long
Dim maxLen     As Long
Dim i_buffer() As Byte      'input  buffer
Dim o_buffer() As Byte      'output buffer
   
    i_buffer = Data
   
    maxLen = UBound(i_buffer) * 4
    ReDim Preserve i_buffer(maxLen) As Byte
   
    intLen = Huff_CompressPacket(i_buffer(0), 12, UBound(Data) + 1)
    ReDim o_buffer(intLen - 1) As Byte
   
    For c = 0 To (intLen - 1)
        o_buffer(c) = i_buffer(c)
    Next c
   
    Data = o_buffer
    Erase i_buffer, o_buffer
End Sub

Public Sub DecompressPacket(ByRef Data() As Byte)
Dim c          As Long
Dim maxLen     As Long
Dim intLen     As Long
Dim i_buffer() As Byte      'input  buffer
Dim o_buffer() As Byte      'output buffer

    i_buffer = Data
   
    maxLen = UBound(i_buffer) * 4
    ReDim Preserve i_buffer(maxLen) As Byte
   
    intLen = Huff_DecompressPacket(i_buffer(0), 12, UBound(Data) + 1, maxLen)
    ReDim o_buffer(intLen - 1) As Byte
   
    For c = 0 To (intLen - 1)
        o_buffer(c) = i_buffer(c)
    Next c
   
    Data = o_buffer
    Erase i_buffer, o_buffer
End Sub


That was the hard part, now make sure you also include the winsock (called it: ws) component:
Code:
Public Sub GetChallenge(ip As String, port As String)
Dim packet As String
Dim Data() As Byte

    ws.Close
    ws.Connect ip, port
    packet = "????????getchallenge"
    Data = StrConv(packet, vbFromUnicode)
    ws.SendData Data
End Sub

Public Sub PlayerJoin(ip As String, port As String)
Dim packet As String
Dim Data() As Byte
    ws.Close
    ws.Connect ip, port
    packet = "????????connect " & Chr(34) & "\challenge\" & challenge & "\qport\43586\protocol\26\name\\rate\25000\snaps\20\model\cultist/red\forcepowers\7-1-030330\color1\1\color2\11\handicap\200\sex\male\cg_predictItems\1\saber1\single_8\saber2\none\char_color_red\255\char_color_green\0\char_color_blue\0\teamtask\0" & Chr(34)
    Data = StrConv(packet, vbFromUnicode)
    CompressPacket Data
    ws.SendData Data
End Sub


Have fun!


Attachments:
q3huff.zip [10.65 KiB]
Downloaded 54 times
Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 08 Apr 2011 15:23 

Joined: 04 Mar 2011 17:15
Posts: 17
Noap...still nothing...
Your code just turned the packet into a pair of ??????????s ._.
Mine makes it right, and according to BobaFett, if it gives me the challenge error then it can read my packet.
So the problem is in the challenge, but I am 110% sure it's correct so yah I give up :l


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 08 Apr 2011 23:33 

Joined: 07 Apr 2011 20:05
Posts: 4
SpioR wrote:
Noap...still nothing...
Your code just turned the packet into a pair of ??????????s ._.
Mine makes it right, and according to BobaFett, if it gives me the challenge error then it can read my packet.
So the problem is in the challenge, but I am 110% sure it's correct so yah I give up :l

Just installed VB6 again to try my code, worked flawlessly.. make sure you use the dll I attached. Turns it into a pair of ????? because as the code says, its compressing the packet before sending it. Also notice it isn't straight up c&p, I provided you with a function to get the challenge but you need to take care of the arriving challenge packet from the server on your own. Also notice the name var in the string. Would provide you with the fully working source but I would like to see you try a bit more.


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 09 Apr 2011 12:17 

Joined: 04 Mar 2011 17:15
Posts: 17
._. I've spent like...idk how long trying to make that shit. Ain't that suffering enough D:


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 09 Apr 2011 21:28 

Joined: 07 Apr 2011 20:05
Posts: 4
Allright here you go, I normally dont do this but since I dont use vb anymore...


Attachments:
Server Test Source.zip [14.11 KiB]
Downloaded 51 times
Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 09 Apr 2011 22:41 

Joined: 04 Mar 2011 17:15
Posts: 17
THanks. I'll let you know how it turned out tomorrow. Getting late...


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 10 Apr 2011 10:13 

Joined: 04 Mar 2011 17:15
Posts: 17
Noap I'm getting yyyydisconnect... o.o


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 10 Apr 2011 17:32 

Joined: 07 Apr 2011 20:05
Posts: 4
The source works, try different servers.


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 14 Apr 2011 08:48 

Joined: 04 Mar 2011 17:15
Posts: 17
Noap nothing o.O


Top
 Profile  
 
 Post subject: Re: VB6 JA q3fill sort of thing problem...
PostPosted: 04 Jun 2011 14:20 

Joined: 04 Mar 2011 17:15
Posts: 17
Well if anyone is interested I fixed it. The problem was that I had to send the challenge & the connect packet from the same winsock, which I didn't. No biggie :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 31 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: