Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 General
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02.06.2006, 07:28   #1
astrid
Архивный участник
 
Join Date: May 2006
Posts: 55
Default [hex] variant of party invite fixing

First of all, big thanks to Aspire for his shares on this forum.
And of course thanks to all other devs

This party invite fix entirely based on shared information and analysis of linex and zzcat dlls

Code of dll (masm32) based on Aspire posted source:
Code:
.386
.model flat, stdcall
option casemap:none

include        \masm32\include\windows.inc
include        \masm32\include\user32.inc
includelib    \masm32\lib\user32.lib
include        \masm32\include\kernel32.inc
includelib    \masm32\lib\kernel32.lib
include        \masm32\include\masm32.inc
includelib    \masm32\lib\masm32.lib

.data?
szViewPacket   db   1024 dup (?)

.const
szDestClass db 'Notepad',0


__DEBUG__   equ   TRUE

ifdef   __DEBUG__
    include        \masm32\include\debug.inc
    includelib    \masm32\lib\debug.lib
endif

.code
PatchAddrProc proc
       ;this proc will run on dll load so here we must put WriteProcessMemory for automated memory modification. at this time i use olly to call dll :)
    ret
PatchAddrProc endp

_SendtoNotepad proc _lpsz;just utility to send debug info in windows notepad.
    local @hWinNotepad

    pushad
    invoke FindWindow,addr szDestClass,NULL
    .if eax
        mov    ecx,eax
        invoke ChildWindowFromPoint,ecx,20,20
    .endif
    .if eax
        mov    @hWinNotepad,eax
        mov    esi,_lpsz
        @@:
        lodsb
        or    al,al
        jz    @F
        movzx    eax,al
        invoke PostMessage,@hWinNotepad,WM_CHAR,eax,1
        jmp    @B
        @@:
    .endif
    popad
    ret
_SendtoNotepad endp


FUNC_GET_OBJECTID_1   equ   517B90h
FUNC_GET_OBJECTID_2   equ   58C8B6h
FUNC_GET_OBJECTID_3   equ   406970h
FUNC_GET_OBJECTID_4   equ   41E4D0h

;ObjectName to ObjectID conversion. this proc identical in zzcats dll and linex
GetCharObjectByName proc   uses ebx edi esi,_lpCharName
    local @CharObject[12]:byte
    local @szBuffer[148]:byte

    lea    eax,@szBuffer
    push    eax
    push    _lpCharName
    mov    eax,FUNC_GET_OBJECTID_1
    call    eax
    add    esp,08h

    sub    esp,124h
    mov    esi,esp
    xor    ebx,ebx
    mov    dword ptr [esi + 0120h],8Bh  
    mov    dword ptr [esi + 011Ch],ebx
    mov    word ptr ds:[esi + 4],bx

    lea    edx,@szBuffer
    push    edx
    mov    eax,FUNC_GET_OBJECTID_2
    call    eax     ;strlen
    add    esp,4

    push    eax
    lea    eax,@szBuffer
    push    eax
    mov    ecx,esi
    mov    eax,FUNC_GET_OBJECTID_3
    call    eax    

    lea    ecx,@CharObject
    push    ecx
    mov    ecx,16922550h
    mov    eax,FUNC_GET_OBJECTID_4
    call    eax

    mov    eax,dword ptr @CharObject
    ret
GetCharObjectByName endp

;this proc must be called from server. all packets from client will go here
RecvPacketProc proc   uses ebx edi esi
    local @szPacket[2048]:byte
    local @OpCode:dword      
    local @isC4Packet:dword  
    local @PacketSize:dword  
    local @OpCodeLen:dword

    local @lpstObject:dword
    local @ObjectID:dword

    pushad
    OFFSET_LENGTH equ 10h
    OFFSET_OPCODE equ 12h
    .if al == 029h;0x29 - party invite OpCode
        mov    ecx,ebx
        add    ecx,OFFSET_OPCODE + 1
        invoke GetCharObjectByName,ecx
        mov    @lpstObject,eax
    ;return from GetCharObjectByName must not be equal to zero, it will cause crash.
    ;zero will return if user /invite offline char. So we exit from proc.
        .if @lpstObject == 0
            popad
            ret
        .endif

        mov    eax,dword ptr [eax + 18h]
        mov    @ObjectID,eax
        ifdef __DEBUG__
            .const
                dbgRequestPartyMsg   db   'RequestParty Packet Received, the character id is %X',0Dh,0Ah,0
            .code
                invoke wsprintf,addr szViewPacket,addr dbgRequestPartyMsg,@ObjectID
                invoke _SendtoNotepad,addr szViewPacket
        endif

        mov    eax,@ObjectID
        mov    [ebx + OFFSET_OPCODE + 1],eax
        mov    dword ptr [ebx + OFFSET_OPCODE + 1 + sizeof dword],0
        mov    word ptr [ebx + OFFSET_OPCODE + 1 + sizeof dword + sizeof dword],599h
        mov    word ptr [ebx + OFFSET_LENGTH],0Bh
    .endif
    popad
    ret
RecvPacketProc endp

DLLMain proc   _hInstance,_dwReason,_dwReserved

    mov    eax,_dwReason
    .if eax == DLL_PROCESS_ATTACH
        mov    eax,_hInstance
        mov    hInstance,eax
        invoke PatchAddrProc
        mov    eax,TRUE
    .elseif eax == DLL_THREAD_ATTACH
        mov    eax,TRUE
    .elseif eax == DLL_THREAD_DETACH
        mov    eax,TRUE
    .elseif eax == DLL_PROCESS_DETACH
        mov    eax,TRUE
    .endif
    ret
DLLMain endp

end DLLMain

Now about place from we will call dll. In my server (C3 PP release) it looks like:
Code:
0050F945     3C AA          CMP AL,0AA;OpCode check
0050F947     72 1D          JB SHORT serveror.0050F966; here jump if OpCode less than 0хAA (С1-С2 packet)
0050F949    -E9 728B1A00    JMP serveror.006B84C0;here jump all others, in my case alt+m and /loc
we must patch it like this:

Code:
0050F945     3C AA          CMP AL,0AA
0050F947    -0F82 7A17EAFF  JB 006B8B4A;any free space in l2server where enough space to call dll and jump back
0050F94D    -E9 6E8B1A00    JMP serveror.006B84C0; jump to greater than 0xAA packets adress little shifted
Then in referenced free space we put:

Code:
006B8B4A   E8 7885CFFF      CALL patch.003B10C7;here must be exact adress of dlls RecvPacketProc entry point. in your case it may be different
006B8B4F  -E9 126EE5FF      JMP serveror.0050F966;after dll make their work just return
this work fine on my server, exept one thing: no random party loot

Now i have 1 big problem: client crash on multisell list select (server C3 PP release, client C3 551). May be somebody have some info about multisell packet?
astrid is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 23:50.