V-UniUsage.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:11k
源码类别:
模拟服务器
开发平台:
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...
- ;-----------------------------------------------------------------------------------
- pObj Macro Counter:REQ, Length:REQ, pMyObj:REQ
- Mov Eax, Counter
- IMul Eax, Eax, Length
- Add Eax, Offset pMyObj
- EndM
- VSetRect Macro posLEFT:REQ, posTOP:REQ, posRIGHT:REQ, posBOTTOM:REQ, pRECT:REQ
- push ecx
- invoke SetRect, pRECT, posLEFT, posTOP, posRIGHT, posBOTTOM
- pop ecx
- EndM
- GetFileLength Macro pFileName:REQ, pFile_Attribute_Data:REQ
- invoke GetFileAttributesEx, pFileName, NULL, edx ; NULL = GetFileExInfoStandard
- EndM
- fastalloc Macro AllocSpace:REQ, TypeAlloc:REQ
- IF TypeAlloc eq 1
- .If (V_ProcessHeapHandle == 0)
- Invoke GetProcessHeap
- Mov V_ProcessHeapHandle, Eax
- .Else
- Mov Eax, V_ProcessHeapHandle
- .EndIf
- Invoke HeapAlloc, Eax, NULL, AllocSpace
- .If (Eax == NULL)
- .EndIf
- ELSEIF TypeAlloc eq 2
- Invoke VirtualAlloc, NULL, AllocSpace, MEM_COMMIT, PAGE_EXECUTE_READWRITE
- .If (Eax == NULL)
- .EndIf
- ELSE
- ENDIF
- EndM
- FastDeAlloc Macro pBuffer:REQ, RegionSize:REQ, VirtualOrHeap:REQ
- IF VirtualOrHeap eq 1
- invoke VirtualFree, pBuffer, RegionSize, MEM_RELEASE
- ELSE
- invoke HeapFree, V_ProcessHeapHandle, HEAP_NO_SERIALIZE, pBuffer
- ENDIF
- EndM
- ReadThisFile Macro pFileName:REQ, pBufferSpace:REQ, pBytesReaded:REQ
- push ecx ;BytesReaded
- Invoke CreateFile, pFileName, GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL
- pop ecx
- Push Eax ;Save handler
- Invoke ReadFile, Eax, pBufferSpace, dword ptr StructFile.nFileSizeLow, ecx, NULL
- Pop Eax ;retun handler
- Invoke CloseHandle, Eax
- mov eax, pBufferSpace
- EndM
- .Const
- .Data?
- .Data
- .Code
- vprint Proc C vString:DWord, sRGB:DWord, Args:VarArg
- Local StringBuffer[MAXPRINTCHAR]:Byte
- Local LinesCounter:DWord
- Local TotalSize:DWord
- local msg:MSG
- Assume Eax:Ptr VPRINTs
- Invoke V_ZeroBuff, addr StringBuffer, MAXPRINTCHAR
- ;------------------------------------------------------------------------------------------------------------------------
- ;DONT EDIT THIS, ITS THE STACK ALIGMENT FOR USE THE PRINT SYSTEM IN A MORE "EASY WAY"
- ;------------------------------------------------------------------------------------------------------------------------
- Mov Eax, Args
- test eax, eax
- je @2
- lea edx, Args
- @1:
- push DWord Ptr [edx + Eax * 4]
- Sub Eax, 1
- test eax, eax
- jnz @1
- @2:
- ;------------------------------------------------------------------------------------------------------------------------
- push vString
- lea eax, StringBuffer
- push eax
- call wsprintf
- .If (VPrintTotalLines >= MAXPRINTLINES) ;If we exceed the max of print lines possible in window
- mov VPrintTotalLines, 0
- xor eax, eax
- .Repeat
- push eax
- pObj eax, SizeOf VPRINTs, pObjectPaint
- invoke V_ZeroBuff, addr [eax].vString, sizeof VPRINTs.vString ;Clean old text
- pop eax
- add eax, 1
- .Until (eax == MAXPRINTLINES)
- invoke InvalidateRect, GShWnd, NULL, TRUE ;Erase the background
- .Endif
- Invoke lstrlen, Addr StringBuffer
- Mov Edx, Eax
- pObj VPrintTotalLines, SizeOf VPRINTs, pObjectPaint
- Mov [Eax].vStringLength, Edx ;Save length
- push eax
- Invoke MemCopy, Addr StringBuffer, Addr [Eax].vString, Edx ;copy to virtual struct "String Buffer"
- pop eax
- Mov Ecx, sRGB
- Mov [Eax].vRGB, Ecx ;save RGB value into virtual struct
- Add VPrintTotalLines, 1 ;add one line added into global counter
- Mov VPrintNewLine, 1 ;lets print it
- mov eax, GShWnd
- mov msg.hwnd, eax
- mov msg.message, WM_PAINT
- invoke DispatchMessage, addr msg ;Update window now
- Ret
- vprint EndP
- V_VectorCreator Proc uses ecx pAllocStruct:DWord, pVectorConstructor:DWord, StructSize:DWord, InitTimes:DWord
- Local pAllocatedStruct:DWord
- Local Counter:DWord
- Mov Counter, 0
- mov Eax, pAllocStruct
- Mov Ecx, Eax
- .Repeat
- push ecx ;Avoid bugs in case you forget to use proc "uses ecx"
- Call pVectorConstructor ;call the vector constructor that must have proc uses ecx
- pop ecx ;Avoid bugs in case you forget to use proc "uses ecx"
- Add Ecx, StructSize
- Add Counter, 1
- Mov Eax, Counter
- .Until (Eax == InitTimes)
- Ret
- V_VectorCreator EndP
- V_ZeroBuff Proc pAddr:DWord, RepTimes:DWord
- push edi
- mov edi, pAddr
- mov ecx, RepTimes
- shr ecx, 2
- xor edx, edx
- xor eax, eax
- rep stosd
- pop edi
- Ret
- V_ZeroBuff EndP
- GetToken Proc pMemSpace:DWord, StartByte:Dword, Brackets:Dword
- Local IsComment:Dword
- Local BytesReaded:DWord
- Local TerminatedFile:Byte
- And TerminatedFile, 0
- And BytesReaded, 0
- And IsComment, 0
- invoke V_ZeroBuff, Addr SaveBytes, SizeOf SaveBytes
- mov ecx, StartByte
- .While (Ecx != -1) ;its a infinite loop
- Mov Eax, pMemSpace
- ;//////////////////////////////////
- ; Checkea End of file 00 Byte
- ;//////////////////////////////////
- .If (Byte Ptr Ds:[Eax + Ecx] == 0) ;ENDIFILE
- Mov TerminatedFile, 1
- .Break
- ;///////////////////////////////
- ; Check Comment / Character
- ;///////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 2FH)
- Add Ecx, 1
- mov IsComment, 1
- .Continue
- ;///////////////////////////////
- ; Check "09" byte
- ;///////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 09H)
- .If (BytesReaded == 0) || (IsComment == 1)
- add ecx, 1
- .Continue
- .endif
- add ecx, 1
- .break
- ;///////////////////////////////
- ; Check SPACE byte
- ;///////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 20H)
- .if (BytesReaded != 0)
- add ecx, 1 ;Ignore space
- .Break
- .elseif (IsComment == 1)
- add ecx, 1
- .Continue
- .else
- .endif
- add ecx, 1
- .Continue
- ;/////////////////////////////////
- ; Check ENTER (0D, 0A)
- ;/////////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 0DH) ;NEXT LINE:> FIRST BYTE
- Add Ecx, 1 ;Read Next Byte
- .If (Byte Ptr Ds:[Eax + Ecx] == 0AH) ;NEXT LINE:> SECOND BYTE
- add ecx, 1
- .if (IsComment == 1)
- mov IsComment, 0
- .continue
- .elseif (BytesReaded != 0) ;If i already read a byte
- .Break
- .else
- .endif
- .Endif
- .Continue
- ;/////////////////////////////////
- ; Save bytes into buffer
- ;/////////////////////////////////
- .Else
- .if (IsComment == 1)
- add ecx, 1
- .continue
- .endif
- Push Ecx ;save ECX in stack
- Lea Ebx, SaveBytes
- Mov Dl, Byte Ptr Ds:[Eax + Ecx]
- Mov Ecx, BytesReaded
- Mov Byte Ptr Ds:[Ebx + Ecx], Dl
- Add BytesReaded, 1
- Pop Ecx
- Add Ecx, 1
- .EndIf
- .EndW
- ;/////////////////////////////////
- ; Convert ASCII to DECIMAL
- ;/////////////////////////////////
- Push Ecx ;save ECX value
- Invoke atol, addr SaveBytes ; ASCII to HEX
- Pop Ecx
- Movsx Edx, TerminatedFile
- Ret
- GetToken EndP
- GetString Proc uses eax BufferFile:DWord, ReadFileByte:DWord
- Local fLength:DWord
- Local StartLong:Dword
- Local IsComment:Dword
- Invoke V_ZeroBuff, Addr StringToken, SizeOf StringToken
- And fLength, 0
- And StartLong, 0
- And IsComment, 0
- Xor Ebx, Ebx
- Mov Ecx, ReadFileByte
- Mov Eax, BufferFile
- .While (Ecx != -1) ;its a infinite loop
- ;//////////////////////////////////
- ; Checkea End of file 00 Byte
- ;//////////////////////////////////
- .If (Byte Ptr [Eax + Ecx] == 0)
- Xor Edx, Edx
- Mov Edx, 1
- .break
- ;///////////////////////////////
- ; Check SPACE byte
- ;///////////////////////////////
- .ElseIf (Byte Ptr [Eax + Ecx] == 20H) ;ESPACE
- .if (IsComment == 1)
- add ecx, 1
- .Continue
- .elseif (StartLong == 1)
- jmp SaveByte
- .elseif (fLength != 0)
- add ecx, 1
- .Break
- .else
- add ecx, 1
- .Continue
- .endif
- ;///////////////////////////////
- ; Check Comment / Character
- ;///////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 2FH)
- Add Ecx, 1
- mov IsComment, 1
- .Continue
- ;///////////////////////////////
- ; Check "09" byte
- ;///////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 09H)
- .If (fLength == 0) || (IsComment == 1)
- add ecx, 1
- .Continue
- .endif
- add ecx, 1
- .break
- ;///////////////////////////////
- ; Check <"> byte
- ;///////////////////////////////
- .ElseIf (Byte ptr [eax + ecx] == 22H) ;<">
- .if (IsComment == 1)
- add ecx, 1
- .Continue
- .endif
- .if (StartLong == 0 || StartLong == 1)
- add StartLong, 1
- add ecx, 1
- .if (StartLong == 2)
- add ecx, 1
- .break
- .endif
- .endif
- .continue ;Volvemos al loop
- ;/////////////////////////////////
- ; Check ENTER (0D, 0A)
- ;/////////////////////////////////
- .ElseIf (Byte Ptr Ds:[Eax + Ecx] == 0DH) ;NEXT LINE:> FIRST BYTE
- Add Ecx, 1 ;Read Next Byte
- .If (Byte Ptr Ds:[Eax + Ecx] == 0AH) ;NEXT LINE:> SECOND BYTE
- add ecx, 1
- .if (IsComment == 1)
- mov IsComment, 0
- .continue
- .elseif (fLength != 0) ;If i already read a byte
- .Break
- .else
- .endif
- .Endif
- .Continue
- ;/////////////////////////////////
- ; Save STRING
- ;/////////////////////////////////
- .Else
- SaveByte:
- .if (IsComment == 1)
- add ecx, 1
- .continue
- .endif
- Mov Dl, Byte Ptr Ds:[Eax + Ecx]
- Lea Esi, [StringToken]
- Mov Byte Ptr Ds:[Esi + Ebx], Dl
- Add Ecx, 1
- Add Ebx, 1
- Add fLength, 1
- .EndIf
- .Endw
- Ret
- GetString EndP