I have seen the online game plug-in production (7)

xiaoxiao2021-03-06  45

In this chapter, we mainly study the production and sending of the package, and the same method we use is Delphi Winsock2 to make. I have said that only Winsock1 in Delphi, Winsock2 needs to be packaged, and I will not introduce how to encapsulate it. Let's take a step in our packaging package and send it: First, we should know that the package is divided into two sections, one is IP, one is the agreement (TCP, UDP, other protocols), IP is like a postal code, identify Where is your packet? Where is it, and the agreement records the format and checks of the package you want to use. The agreement in online games is generally defined. To crack the online game is the most important thing is Learn to crack the online game agreement online game agreement, in order not to affect the safety of the current online game, I will introduce the package and sending of the network protocol with the UDP protocol. Next, we can start to look at the whole process of the entire package: 1) We want to start SOCK2, then the WSAStartup function to use, the usage is as follows: Integer WsaStartup (WSData: TWSA_DATA); in the program WVersionRequired Our incoming value is $ 0002, WSDATA is the structure of TWSA_DATA. 2) Use the socket function to create and get the socket handle; Integer Socket (AF: Integer, struct: integer, protocol: integer); Note is that in our package package is full of IP headers, so our struct parameter here The parameter value to be passed is 2, indicating that the header is included. This function returns the value of the Winsocket just created. 3) Use the setsockopt function to set the SOCK options; integer setsockopt (s: integer, level: integer, optName: integer, optval: pchar, optlen: integer; incoming Socket handle in S, in this program The value of the Level input is 0 indicates IP (if it is 6 indicates TCP, 17 means UDP, etc.), and the OPTNAME writes 2, while the initial value of OptVal fills in 1, Optlen is OptVal size. 4) Next we have to divide a few steps to implement the build package: 1. Convert IP to the SOCK address, use inet_addr to convert.

Longint INET_ADDR (CP: PCHAR); 2. Define the total size of the package, the version of the IP is IP structure: the total package size = IP header size UDP header size UDP message size, IP version, in this program The structure of 4, 3, fill in the IP Baotou: ip.Ipverlen: = IP version shl 4; ip.iptos: = 0; // IP service type ip.iptotallength: =; // Tap Size IP.IPID : = 0; // Unique identifier, generally set to 0 ip.ipoffset: = 0; // Offset field ip.ipttl: = 128; // Time ip.ipprotocol: = $ 11; // Define protocol IP.IPCHECKSUM : = 0; // Total number IP.IPSRCADDR: =; // Source address ip.ipdestaddr: =; // Target Address 4, Fill in the UDP Baotou: udp.srcportno: =; // Source port number udp.dstportno : =; // Target port number udp.udplength: =; // UDP package size udp.udpchecksum: =; // Total number 5, put the IP header, UDP header and message, put into the cache. 6, define remote information: remove.Family: = 2; Remote.port: =; // Remote port remote.addr.addr: =; // Remote Address 5) We use Sendto to send a package, usage as follows: Integer Sendto (S : Integer, Var Buf: Integer, Var Len: Integer, Var Flags: Integer, Var Addrto: Tsock_addr; Tolen: Integer; Inced to Socket handle, BUF is a packet that is just built, Len is incoming package The total length has just been calculated. Flag is an incoming mark here we are set to 0, the target address sent by AddTO, where we are incoming Remote, and Tolen is written in the size of the Remote. 6) In the end, don't forget to use CloseSocket (SH) to close Socket and use WSacleanup to shut down Winsock. The last thing to say is that this transmission method can only send a fully crafted network protocol. If you want to send data in the middle of someone else's program, you can only use APIHOOK or do an intermediate layer in Winsock2. If you have any questions, you need to discuss with me, please send an email to microprogramer@hotmail.com or QQ: 24259132. Author Blog:

http://blog.9cbs.neet/mprogramer/

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

New Post(0)