V-IntConnect.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:9k
源码类别:
模拟服务器
开发平台:
Asm
- ;EasyCodeName=Module1,1
- ;-----------------------------------------------------------------------------------
- ; VeMU
- ; Its a package that allows the user to set his own server of the game
- ; "MuOnline", this is not an emulator since i am not "emulating"
- ; what the actual games does, i am "creating" a method for set a Server
- ; of this Game.
- ;
- ; Copyright (C) 2010 Felipe Ya馿z
- ;
- ; This program is free software: you can redistribute it and/or modify
- ; it under the terms of the GNU General Public License as published by
- ; the Free Software Foundation, either version 3 of the License, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License
- ; along with this program. If not, see http://www.gnu.org/licenses/.
- ;-----------------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------------
- ; -----------------
- ; Coded /
- ; By /
- ; -={FeN$x)=-
- ; / Felipe Y.
- ; /
- ; -----------------
- ; Programming Lang: ASM
- ; Country: Chile
- ; My respect for all those who lost their lifes
- ; In the earthquake of my country...
- ; Let god take their spirits home...
- ;-----------------------------------------------------------------------------------
- Packet_Internal_Login Struct
- UniHeaders PacketHeaders <>
- GSPort Word ?
- ServerName Byte 50 Dup(0)
- ServerCode Word ?
- Packet_Internal_Login EndS
- .Const
- ;/////////////////////////////////
- ;Internal Clients uMSG IDs
- ;If you want to change
- ;Dont change the last bit
- ;Example:
- ; JSID equ XXX0
- ; JSID equ 1410
- ;Also remember to change in
- ;V_Sock_InternalRecv the
- ;editable value of optimisation
- ;/////////////////////////////////
- JSID equ 1400h ;uMSG ID for WndProc
- RankID equ 1401h ;uMSG ID for WndProc
- EventID equ 1402h ;uMSG ID for WndProc
- DS1ID equ 1403h ;uMSG ID for WndProc
- DS2ID equ 1404h ;uMSG ID for WndProc
- ExDBID equ 1405h ;uMSG ID for WndProc
- CSID equ 1406h ;uMSG ID for WndProc
- ;/////////////////////////////////
- ;/////////////////////////////////
- TCPType equ 0 ;TCP type protocol
- UDPType equ 1 ;UPD type protocol
- ;////////////////////////////////
- ;/////////////////////////
- ;Total of clients
- ;/////////////////////////
- TotalInternalClients equ 6 ;JS, DS1, DS2, EventChip, Ranking, ExDB, CS
- .Data?
- InternalClients DB SizeOf InternalClients_Struct * TotalInternalClients Dup(?) ;The 6 internal clients structs in this buffer
- .Data
- ;///////////////////////
- ;Aligned to 14 bytes
- ;Dont edit the align !
- ;//////////////////////
- InternalClientsNames DB "JoinServer", 0, 0, 0, 0
- DB "DataServer1", 0, 0, 0
- DB "DataServer2", 0, 0, 0
- DB "EventChip", 0, 0, 0, 0, 0
- DB "RankingServer", 0
- DB "ExDBServer", 0, 0, 0, 0
- DB "ConnectServer", 0
- .Code
- V_Sock_InitInternalClients Proc
- assume edx:ptr InternalClients_Struct
- lea edx, InternalClients
- xor eax, eax
- ;/////////////////////////////////////////
- ;Load all internal client info
- ;/////////////////////////////////////////
- .repeat
- push edx ;Save struct
- .if (eax == 0) ;JoinServer set info
- mov [edx].ProtocolAddr, offset V_JS_ProtocolCore
- mov [edx].TCPorUDP, TCPType ;TCP
- mov ecx, JSPort
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, JSID ;Set MsgID for sync select
- invoke szCopy, addr JSIP, addr [edx].IPorName
- .elseif (eax == 1) ;DataServer1 set info
- mov [edx].ProtocolAddr, offset V_DS_ProtocolCore
- mov [edx].TCPorUDP, TCPType ;TCP
- mov ecx, DS1Port
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, DS1ID ;Set MsgID for sync select
- invoke szCopy, addr DS1IP, addr [edx].IPorName
- .elseif (eax == 2) ;DataServer2 set info
- mov [edx].ProtocolAddr, offset V_DS_ProtocolCore
- mov [edx].TCPorUDP, TCPType ;TCP
- mov ecx, DS2Port
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, DS2ID ;Set MsgID for sync select
- invoke szCopy, addr DS2IP, addr [edx].IPorName
- .elseif (eax == 3) ;EventChip set info
- mov [edx].ProtocolAddr, offset V_Event_ProtocolCore
- mov [edx].TCPorUDP, TCPType ;TCP
- mov ecx, EventPort
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, EventID ;Set MsgID for sync select
- invoke szCopy, addr EventIP, addr [edx].IPorName
- .elseif (eax == 4) ;Ranking set info
- mov [edx].ProtocolAddr, offset V_Rank_ProtocolCore
- mov [edx].TCPorUDP, TCPType ;TCP
- mov ecx, RankPort
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, RankID ;Set MsgID for sync select
- invoke szCopy, addr RankIP, addr [edx].IPorName
- .elseif (eax == 5) ;ExDB set info
- mov [edx].ProtocolAddr, offset V_ExDB_ProtocolCore
- mov [edx].TCPorUDP, TCPType ;TCP
- mov ecx, ExDBPort
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, ExDBID ;Set MsgID for sync select
- invoke szCopy, addr ExDBIP, addr [edx].IPorName
- .elseif (eax == 6) ;CS set info
- mov [edx].ProtocolAddr, offset V_CS_ProtocolCore
- mov [edx].TCPorUDP, UDPType ;UDP
- mov ecx, CSPort
- mov [edx].Port, ecx ;Set port
- mov [edx].MSGID, CSID ;Set MsgID for sync select
- invoke szCopy, addr CSIP, addr [edx].IPorName
- .else
- .endif
- pop edx ;Return struct
- add edx, SizeOf InternalClients_Struct ;Next struct
- .until (edx == SizeOf InternalClients_Struct * TotalInternalClients)
- lea ecx, InternalClients
- xor edx, edx
- ;//////////////////////////////////////////////
- ;Connect all internal clients
- ;//////////////////////////////////////////////
- .repeat
- push edx
- imul edx, edx, SizeOf InternalClients_Struct
- add ecx, edx
- call V_Sock_SetAll ;Set internal connection
- pop edx
- push edx
- ;-----------------------------------------------------------------------
- RGB 255, 64, 64
- imul edx, edx, 14 ;14 Bytes aligment for strings
- add edx, offset InternalClientsNames
- Invoke vprint, $CTA0("[%s]:] Connected"), Eax, 1, Edx ;Display message
- ;-----------------------------------------------------------------------
- pop edx
- add edx, 1 ;Next struct
- .until (edx == TotalInternalClients)
- lea ecx, InternalClients
- xor edx, edx
- ;/////////////////////////////////////////
- ;Send packets to internal clients
- ;////////////////////////////////////////
- .repeat
- push edx
- .if (edx == 6) ;Load CS
- imul edx, edx, SizeOf InternalClients_Struct
- add ecx, edx
- call V_CS_InfoSend
- .elseif (edx == 0) || (edx == 1) || (edx == 2) ;JS, DS1 & DS2
- imul edx, edx, SizeOf InternalClients_Struct
- add ecx, edx
- call V_Sock_InternalLogin
- .endif
- pop edx
- add edx, 1 ;Next struct
- .until (edx == 7)
- Ret
- V_Sock_InitInternalClients EndP
- V_Sock_InternalAdmin Proc uMSG:UINT, lParam:LPARAM
- assume ecx:ptr InternalClients_Struct
- mov eax, uMSG
- xor eax, 14000h ;This is editable value if you edit the uMSG ID (optimisation value) !
- .If (eax > 6) ;If we exceeded the Interal clients ID
- .Else
- mov eax, lParam
- and eax, 0FFFFh
- .If (eax == FD_READ)
- mov ecx, uMSG
- and ecx, 0Fh ;Bite only
- imul ecx, ecx, SizeOf InternalClients_Struct
- add ecx, offset InternalClients ;Define the internal client struct
- call V_Sock_Recv ;Recv the packet
- .ElseIf (EAX == FD_WRITE) ;In case we couldnt send caused WSAEWOULDBLOCK
- mov ecx, uMSG
- and ecx, 0Fh ;Bite only
- imul ecx, ecx, SizeOf InternalClients_Struct
- add ecx, offset InternalClients ;Define the internal client struct
- mov eax, [ecx].pSendPacket
- mov edx, [ecx].LastLengthPacket
- invoke V_Sock_Send, eax, edx ;Send the packet we couldnt
- RGB 255, 64, 64
- mov edx, uMSG
- and edx, 0Fh ;Bite only
- imul edx, edx, 14 ;14 Bytes aligment for strings
- add edx, offset InternalClientsNames
- Invoke vprint, $CTA0("[%s]:] Retrying to send packet"), Eax, Edx
- .ElseIf (Eax == FD_CLOSE)
- RGB 255, 64, 64
- mov edx, uMSG
- and edx, 0Fh ;Bite only
- imul edx, edx, 14 ;14 Bytes aligment for strings
- add edx, offset InternalClientsNames
- Invoke vprint, $CTA0("[%s]:] FD-CLOSE Requested"), Eax, Edx
- Invoke SendMessage, GShWnd, WM_CLOSE, NULL, NULL
- .Else
- RGB 255, 64, 64
- mov edx, uMSG
- and edx, 0Fh ;Bite only
- imul edx, edx, 14 ;14 Bytes aligment for strings
- add edx, offset InternalClientsNames
- mov ecx, lParam
- and ecx, 0FFFFh
- Invoke vprint, $CTA0("[%s]:] Extrange notification [%d]"), Eax, Edx, Ecx
- Invoke SendMessage, GShWnd, WM_CLOSE, NULL, NULL
- .endif
- .endif
- assume ecx:nothing
- Ret
- V_Sock_InternalAdmin EndP
- V_Sock_InternalLogin Proc
- local MyStruct:Dword
- mov MyStruct, ecx
- lea eax, InternalPacket
- assume eax:ptr Packet_Internal_Login
- Mov Byte Ptr [eax].UniHeaders.PacketType, 0C1H
- Mov Byte Ptr [eax].UniHeaders.PacketLength, 58
- Mov Byte Ptr [eax].UniHeaders.Header, 0H
- Mov Byte Ptr [eax].UniHeaders.SubHeader, 1
- Mov edx, GSPort
- Mov Word Ptr [eax].GSPort, Dx
- push eax
- Invoke lstrcpy, Addr [eax].ServerName, Offset ServerName
- pop eax
- Mov ecx, ServerCode
- Mov Word Ptr [eax].ServerCode, Cx
- Mov Ecx, MyStruct
- Invoke V_Sock_Send, Addr InternalPacket, [eax].UniHeaders.PacketLength
- Ret
- V_Sock_InternalLogin EndP