Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 14:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



VB Packets Help ( Again :D )

Discussion on VB Packets Help ( Again :D ) within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old 08/29/2011, 00:32   #16
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
That's cause you're printing it as a string. you should NEVER use a string when you're working with packets which are byte packed.

keep it as a byte array and use a binaryreader too read the packet.

about the printing part you could do something like this:
C#
Code:
string Packet = "";
for(int i = 0; i < inStream.Length; i++)
{
      Packet += string.Format("{0:X2} ", inStream[i]);
}
Convert to vb
Code:
Dim Packet As String = ""
For i As Integer = 0 To inStream.Length - 1
	Packet += String.Format("{0:X2} ", inStream(i))
Next
now you have the packet as a string but in hex.
Owh and I don't know if the vb part is correct I used a converter.
kevin_owner is offline  
Thanks
1 User
Old 08/29/2011, 00:45   #17
 
DeXeee's Avatar
 
elite*gold: 0
Join Date: Aug 2009
Posts: 218
Received Thanks: 171
Quote:
Originally Posted by kevin_owner View Post
That's cause you're printing it as a string. you should NEVER use a string when you're working with packets which are byte packed.

keep it as a byte array and use a binaryreader too read the packet.

about the printing part you could do something like this:
C#
Code:
string Packet = "";
for(int i = 0; i < inStream.Length; i++)
{
      Packet += string.Format("{0:X2} ", inStream[i]);
}
Convert to vb
Code:
Dim Packet As String = ""
For i As Integer = 0 To inStream.Length - 1
	Packet += String.Format("{0:X2} ", inStream(i))
Next
now you have the packet as a string but in hex.
Owh and I don't know if the vb part is correct I used a converter.
Thanks for helping, i will try it !!

I got a lot of "00 00 00 00 00 00" at the end
Maybe too much, for about 15k
Visual :
DeXeee is offline  
Old 08/29/2011, 07:52   #18
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
Quote:
Originally Posted by DeXeee View Post
Thanks for helping, i will try it !!

I got a lot of "00 00 00 00 00 00" at the end
Maybe too much, for about 15k
Visual :
Guess why SRO sends size.
lesderid is offline  
Thanks
1 User
Old 08/29/2011, 11:32   #19
 
DeXeee's Avatar
 
elite*gold: 0
Join Date: Aug 2009
Posts: 218
Received Thanks: 171
Tnx guys, i make it

Code:
Dim inStream(10024) As Byte
        Dim DataLength As Integer = Client.Receive(inStream)
        Client.Receive(inStream, 0, CInt(Client.ReceiveBufferSize), SocketFlags.None)

        Dim Packet As String = ""
        For i As Integer = 0 To inStream.Length - 1
            Packet += String.Format("{0:X2} ", inStream(i))
        Next
        Packet = Mid(Packet, 1, DataLength)
        MsgBox(Packet)
DeXeee is offline  
Old 08/29/2011, 11:41   #20
 
InvincibleNoOB's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 4,277
Received Thanks: 2,990
Read the size only and then the rest of the packet
Client.Receive(tmpSize, 0, 2, 0);
//determine the actual size of the packet, if it is encrypted
Client.Receive(inStream, 2, actualSize+4, 0);
PWord(@instream.memory[0])^ = actualSize; //set the size
InvincibleNoOB is offline  
Thanks
2 Users
Old 08/29/2011, 12:26   #21
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
That is also a nice way too fix it InvincibleNoOb.

@DeXee the send and receive function also have a return value which is the amount of bytes send/received. so you could also use that one.
kevin_owner is offline  
Old 08/30/2011, 01:00   #22
 
InvincibleNoOB's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 4,277
Received Thanks: 2,990
The result of this function does not guarantee in any way that there's only 1 packet in the buffer.
InvincibleNoOB is offline  
Old 08/31/2011, 01:42   #23

 
sarkoplata's Avatar
 
elite*gold: 166
Join Date: Apr 2009
Posts: 2,341
Received Thanks: 2,661
I advise you using SilkroadSecurityApi , but still , if you wanna use diff. proxies , here you can apply what i posted on stealthex.
This code is written by GoneUp , my teacher when i was toooo beginner
You should create a class called "sPacket" first , add public objects there ( opcode , data , size etc.)
And you should start this with a thread , or your gui thread will freeze ^^
This was orginally written by GoneUp
Code:
Dim Recv as thread = new thread (addressof receiving)
recv.start()
Code:
Private Sub Receiving()
        Try
            Dim bytetoread As UInt16
            Do
                Dim Packet As New sPacket()
                Do
                    bytetoread = Client.Available
                    If bytetoread >= 6 Then
                        Dim buffer(6 - 1) As Byte
                        Client.Receive(buffer, 6, Net.Sockets.SocketFlags.None)
                        Packet.Lenght = BitConverter.ToUInt16(buffer, 0)
                        Packet.Opcode = BitConverter.ToUInt16(buffer, 2)
                        Packet.Direction = BitConverter.ToUInt16(buffer, 4)
                        Exit Do
                    Else
                        Threading.Thread.Sleep(10)
                    End If
                Loop
                Do 'it has a support to untck multiple packets too
                    bytetoread = Client.Available
                    If bytetoread >= Packet.Lenght Then
                        Dim buffer(Packet.Lenght - 1) As Byte
                        Client.Receive(buffer, Packet.Lenght, Net.Sockets.SocketFlags.None)
                        Packet.data = buffer
                        ParsePacket(Packet)
                        Exit Do
                    Else
                        Threading.Thread.Sleep(10)
                    End If
                Loop
            Loop
        Catch ex As Exception
        End Try

    End Sub
sarkoplata is offline  
Thanks
1 User
Old 09/02/2011, 17:25   #24
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
Case-insensitive code is so ugly.
lesderid is offline  
Thanks
1 User
Old 09/02/2011, 18:44   #25
 
elite*gold: 0
Join Date: Mar 2009
Posts: 2,693
Received Thanks: 3,160
Quote:
Originally Posted by lesderid View Post
Case-insensitive code is so ugly.
Code:
private void Receiving()
{
	try {
		UInt16 bytetoread = default(UInt16);
		do {
			sPacket Packet = new sPacket();
			do {
				bytetoread = Client.Available;
				if (bytetoread >= 6) {
					byte[] buffer = new byte[6];
					Client.Receive(buffer, 6, System.Net.Sockets.SocketFlags.None);
					Packet.Lenght = BitConverter.ToUInt16(buffer, 0);
					Packet.Opcode = BitConverter.ToUInt16(buffer, 2);
					Packet.Direction = BitConverter.ToUInt16(buffer, 4);
					break; 
				} else {
					System.Threading.Thread.Sleep(10);
				}
			} while (true);
			//it has a support to untck multiple packets too
			do {
				bytetoread = Client.Available;
				if (bytetoread >= Packet.Lenght) {
					byte[] buffer = new byte[Packet.Lenght];
					Client.Receive(buffer, Packet.Lenght, System.Net.Sockets.SocketFlags.None);
					Packet.data = buffer;
					ParsePacket(Packet);
					break;
		} else {
					System.Threading.Thread.Sleep(10);
				}
			} while (true);
		} while (true);
	} catch (Exception ex) {
	}

}
if you don't really like vb.net
LastThief is offline  
Old 09/02/2011, 23:17   #26
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
Quote:
Originally Posted by LastThief View Post
if you don't really like vb.net
I never said I don't like VB.Net (I don't, though), just case-insensitive code written it.

Btw, that C# code isn't really great either.
lesderid is offline  
Old 09/03/2011, 00:17   #27
 
DeXeee's Avatar
 
elite*gold: 0
Join Date: Aug 2009
Posts: 218
Received Thanks: 171
Hey guys, about HP, MP, MOB HP, current cord, golds, etc ... Can i get them with packets too ?
DeXeee is offline  
Old 09/03/2011, 01:10   #28

 
sarkoplata's Avatar
 
elite*gold: 166
Join Date: Apr 2009
Posts: 2,341
Received Thanks: 2,661
Quote:
Originally Posted by DeXeee View Post
Hey guys, about HP, MP, MOB HP, current cord, golds, etc ... Can i get them with packets too ?
If the thing you wanna get is shown in client , you can get it . Because client got it from packets , so yes you can.

@lesderid
It makes your life easier
sarkoplata is offline  
Thanks
1 User
Old 09/03/2011, 02:05   #29
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
@DeXee yes you can but sarkoplata already answerd your question

@sarkoplata
Quote:
It makes your life easier
I have to disagree. Sure for some people it can be easier but it makes it harder too switch to another lanuage. If you're used to not give variables the same it'll be harder to code in for example C#.
kevin_owner is offline  
Thanks
3 Users
Reply


Similar Threads Similar Threads
[Packets] Wie änder ich flyff packets?
07/16/2011 - Flyff Private Server - 19 Replies
HeyHo, Ich würde sehr gerne wissen wie man die Flyff Packets ändert... ich denke mal Zahlen ändern werden nicht ausreichen oder?
WHICH PACKETS....
04/24/2011 - Conquer Online 2 - 28 Replies
mind if anyone tell me which specific packets are used to send and receive packing of dbs into dbscrolls cuz i cant seem to get wpepro record packets for me..
[Packets]
06/19/2009 - Kal Online - 11 Replies
Hallo, so geht an die letzten Feinheiten meines Magebots. Wir sieht es mit Skillanimationen aus? Nehmen wir mal an Ice Magic ist 0x10 b 2, muss ich dann für das animationspacket (0x21 ka weis es gerade net auswendig) auch 2 senden? bzw gibt es fälle in dennen sich das unterscheidet? 2. Das Alte Thema Z-Coord... gibt es nen funktionierendes HeightDetour irgendwo im forum, oder nix public? Bin im mom in der Uni, wie sieht mit dem hier aus: 3. Weis einer die Nr vom Expell-Packet? Ich...
Need help with packets
07/28/2007 - Conquer Online 2 - 3 Replies
hello all When u use something in conquer. it sends a packet to conquer right? Whats something good to see what this packet is. Also how can u send this packet again, im new to this so i need some help.
Packets
07/17/2007 - Cabal Online - 7 Replies
Ok, I recorded some packets. I was sitting in desert scream with a level 1 blader. It had level 1 impact stab. After three impact stab casts without moving at all, this is what I get: 55 81 8E BF 04 1E 95 22 31 6D 19 49 F4 05 A1 3A 7B A8 8E 68 BA F1 74 68 C5 AD 4A 57 16 FF DF 02 A7 75 89 27 CF C5 E5 6C 43 5C 68 F0 AE 8E 9F 8C D3 2C 70 DA 54 78 D3 B3 74 CF 72 5F 8F 16 B8 5C 0B 13 28 A0 68 Five normal attacks in a row.



All times are GMT +1. The time now is 14:45.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.