Lianzhong Upgrade Agreement Analysis 4

xiaoxiao2021-03-06  39

Lianzhong upgrade agreement analysis continuation (3)

Cloud Network (Jimzj@21cn.com)

Join

Let's go to analyze each command word as a description:

Before this, let's define the header structure of each package:

Typedef struct _tagpackhead

{

INT nCommand; // Command word

Int nDatalen; / / package length

Packhead, * lppackhead;

This structure has been used when you get a complete protocol package.

First, log in to user command

0x0000 00 02 00 80 C8 00 00 00 00 00 00 04 00 02 00 ... €? ..........

0x0010 00 00 00 79 6F 75 73-68 69 5F 31 39 38 31 00 .... DDDDD_1981.

0x0020 00 B3 03 00 00 00 00-C5 DC C5 DC C5 DC CC F8.? .....

0x0030 00 C5 00 00 00 00 00 00-C7 00 FF 00 00 00 00 00.? .....?  .....

0x0040 01 00 00 00 68 6F 6E 64-61 30 34 31 32 00 00 ... fffffff0412 ...

..................

From the data, the command word is 0x80000200. We don't have to know everything. What does it mean? Just find one of our data. From the color of the above sign, the front is the command word, what is red? Everyone wants to upgrade, it is four people. Oh, you will probably understand, this is the server allocated to each user, this is very important, because other instructions will no longer appear again, only one user ID. After several analysis, the number of the user is fixed. We sit down according to the seat, as shown below: (When you sit down in the hall, it is not a card)

1

0 ------ | ------ 2

3

A part of the package is the user's data, which is the information of each user, so our defined package structure is as follows:

Typedef struct _tagrespshjiuserregister

{

INT nflag0;

CHAR Cucount; // User number

CHAR CFLAG1;

CHAR CDAPAI;

CHAR CFLAG4;

RESPSHJIUSERREGISTER, * LPRESPSHJIUSERREGISTER;

Typedef struct _taggameuserinfo

{

CHAR CUSERNUM; // User Number

CHAR CFLAG1;

CHAR CFLAG2;

CHAR CFLAG3;

Char Cuser [20]; // User login name

CHAR CALIA [20]; // User Chinese Name

INT nflag4;

GameUserInfo, * lpGameuserinfo;

The user's name is 20 bytes, and the previous article has explained;

The DispatchPackets used in the AnalylyLinkRecvpack function are shown below: (This is to decompose each package)

Void __fastcall tfrmmain :: DispatchPackets (const char * ppack)

{

Packhead * ppackhead = (packhead *) PPACK; // Baotou IF (PPackhead-> NDataLen> max_command_size - sizeof (packhead) Return;

Switch (ppackhead-> ncommman)

{

Case resp_shji_user_register:

IF (ppackhead-> ndatalen> = sizeof (respshjiuserregister) sizeof (gameuserinfo)) // filter error package

{

RevgameUserInfo ((char *) (PPACKHEAD 1)); // Package content

}

Break;

.............................. .. ..

}

The function revGameUserInfo is to decompose user information. We have defined the structure of the package, so it is easy to obtain the user's information:

Void __fastcall tfrmmain :: RevGameUserInfo (Char * PPackContent)

{

RESPSHJIUSERREGISTER * PINFO = (RESPSHJIUSERREGISTER *) PPACKCONTENT;

INT NUSERCOUNT = PINFO-> Cucount;

FOR (int i = 0; I

{

GameUserInfo * Puser = (GameUserInfo *) (PINFO 1) i * sizeof (gameuserinfo);

Switch (Puser-> CUSERNUM)

{

Case pos_left: // Number of 0 users

PANELLEFT-> CAPTION = (String) Puser-> Calia;

Break;

Case Pos_top: // Number 1 user

Paneltop-> CAPTION = (string) PUSER-> CALIA;

Break;

Case POS_Right: // Number 2 user

PANELRIG-> CAPTION = (String) Puser-> Calia;

Break;

Case pos_bot: // Number 3 user

Panelbot-> CAPTION = (String) Puser-> Calia;

Break;

}

}

}

At this point, we get information about each user in the upgrade, huh, it is a bit of a bit of accomplishment, we take a little turtle, drink a tea. . . . .

转载请注明原文地址:https://www.9cbs.com/read-66910.html

New Post(0)