Jump to content

Recommended Posts

Hey hey,

I want to send packets to a server.

The basic struct of the CommandLogin3 is the following(in my knowledge):

 

1 byte Header

31 byte loginname

17 byte password

16 byte encryption key 

Result = 65 Bytes

Now the problem: The server I want to connect expects 66 bytes and not 65 bytes.

anyone knows the structure of the login paket? 

Link to comment
https://metin2.dev/topic/10494-packet-commadnlogin3/
Share on other sites

1 hour ago, Necessary said:

Hey hey,

I want to send packets to a server.

The basic struct of the CommandLogin3 is the following(in my knowledge):

 

1 byte Header

31 byte loginname

17 byte password

16 byte encryption key 

Result = 65 Bytes

Now the problem: The server I want to connect expects 66 bytes and not 65 bytes.

anyone knows the structure of the login paket? 

#pragma pack instructs the compiler to pack structure members with particular alignment. Most compilers, when you declare a struct, will insert padding between members to ensure that they are aligned to appropriate addresses in memory (usually a multiple of the type's size). This avoids the performance penalty (or outright error) on some architectures associated with accessing variables that are not aligned properly. For example, given 4-byte integers and the following struct:

struct Test
{
   char AA;
   int BB;
   char CC;
};

The compiler could choose to lay the struct out in memory like this:

|   1   |   2   |   3   |   4   |  

| AA(1) | pad.................. |
| BB(1) | BB(2) | BB(3) | BB(4) | 
| CC(1) | pad.................. |

and sizeof(Test) would be 4 × 3 = 12, even though it only contains 6 bytes of data. The most common use case for the #pragma (to my knowledge) is when working with hardware devices where you need to ensure that the compiler does not insert padding into the data and each member follows the previous one. With #pragma pack(1), the struct above would be laid out like this:

|   1   |

| AA(1) |
| BB(1) |
| BB(2) |
| BB(3) |
| BB(4) |
| CC(1) |

And sizeof(Test) would be 1 × 6 = 6.

With #pragma pack(2), the struct above would be laid out like this:

|   1   |   2   | 

| AA(1) | pad.. |
| BB(1) | BB(2) |
| BB(3) | BB(4) |
| CC(1) | pad.. |

And sizeof(Test) would be 2 × 4 = 8.

 

 

 

Use pragma pack

  • Love 1
Link to comment
https://metin2.dev/topic/10494-packet-commadnlogin3/#findComment-61868
Share on other sites

First of all thanks for your answer. Im programming in c# so i use   [StructLayout(LayoutKind.Sequential, Pack = 1)] and it works.

Handshake paket works, Keyagreement, keyagreement_completed works too. But the login paket (CommandLogin3) only sends 65 bytes.

If i login with original metin2client and sniff the pakets it sends 66 bytes, my program only sends 65 ..

maybe they changed the structure?

Link to comment
https://metin2.dev/topic/10494-packet-commadnlogin3/#findComment-61881
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.