Advertisement
Guest User

Untitled

a guest
Feb 17th, 2015
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.25 KB | None | 0 0
  1. __declspec(naked)
  2. VOID
  3. ClientConnection__CharacterLogout_Hook(
  4.     VOID
  5.     )
  6. {
  7.     __asm {
  8.         push    ebp
  9.         mov     ebp,esp
  10.         sub     esp,18h                         ; Allocate space for local variables
  11.  
  12.         pushfd
  13.         pushad
  14.  
  15. ;
  16. ; Get player base address
  17. ;
  18.         push    90h    
  19.         mov     eax,00468550h
  20.         call    eax                             ; ClntObjMgrGetActivePlayer
  21.  
  22.         push    edx                             ; Player's GUID (HighPart)
  23.        push    eax                             ; Player's GUID (LowPart)
  24.         mov     edx,008364B4h                   ; '..\Object/ObjectClient/Player_C.h'
  25.         mov     ecx,10h                         ; TYPEMASK_PLAYER
  26.         mov     eax,00468460h
  27.         call    eax
  28. ;
  29. ; (eax) = player base
  30.  
  31. ;
  32. ; Check player faction
  33. ;
  34.         add     eax,8
  35.         mov     eax,[eax]
  36.         add     eax,8Ch                         ; UNIT_FIELD_FACTIONTEMPLATE
  37.         cmp     byte ptr [eax],1                ; Is the player alliance?
  38.         jz      PlayerIsAlliance                ; If so, use Stormwind as the zone for CMSG_ZONEUPDATE; otherwise use Orgrimmar
  39.  
  40.         mov     edx,665h                        ; (edx) = Orgrimmar zone ID
  41.         jmp     $+10
  42.  
  43. PlayerIsAlliance:
  44.         mov     edx,5EFh                        ; (edx) = Stormwind zone ID
  45.  
  46.         push    edx
  47.  
  48. ;
  49. ; Initialize CDataStore structure
  50. ;
  51.         xor     esi,esi
  52.         mov     [ebp-14h],esi                   ; m_data
  53.         mov     [ebp-10h],esi                   ; m_base
  54.         mov     [ebp-0Ch],esi                   ; m_alloc
  55.         mov     [ebp-8],esi                     ; m_size
  56.         mov     dword ptr [ebp-4],0FFFFFFFFh    ; m_read
  57.         mov     dword ptr [ebp-18h],007FF9E4h   ; CDataStore___vftable_
  58.  
  59. ;
  60. ; Put CMSG_ZONEUPDATE opcode
  61. ;
  62.         push    1F4h                            ; CMSG_ZONEUPDATE
  63.         lea     ecx,[ebp-18h]
  64.         mov     eax,00418190h
  65.         call    eax                             ; CDataStore__PutInt32
  66.  
  67. ;
  68. ; Put the zone ID
  69. ;
  70.         pop     edx
  71.         push    edx                             ; Zone ID
  72.         lea     ecx,[ebp-18h]
  73.         mov     eax,00418190h
  74.         call    eax                             ; CDataStore__PutInt32
  75.  
  76. ;
  77. ; Send the packet
  78. ;
  79.         lea     ecx,[ebp-18h]
  80.         mov     [ebp-4],esi
  81.         mov     eax,005AB630h
  82.         call    eax                             ; ClientServices_Send
  83.  
  84. ;
  85. ; CleanUp
  86. ;
  87.         cmp     dword ptr [ebp-0Ch],0FFFFFFFFh
  88.         mov     dword ptr [ebp-18h],007FF9E4h   ; CDataStore___vftable_
  89.         jz      Exit
  90.  
  91.         lea     eax,[ebp-0Ch]
  92.         push    eax
  93.         lea     ecx,[ebp-10h]
  94.         push    ecx
  95.         lea     edx,[ebp-14h]
  96.         push    edx
  97.         lea     ecx,[ebp-18h]
  98.         mov     eax,007FF9E8h
  99.         call    [eax]                           ; CDataStore__Release
  100. Exit:  
  101.         popad
  102.         popfd
  103.  
  104.         mov     eax,005AB006h
  105.         jmp     eax                             ; ClientConnection__CharacterLogout + 6
  106.     }
  107. }
  108.  
  109. VOID
  110. InstallCharacterLogoutHook(
  111.     VOID
  112.     )
  113. {
  114.     CharacterLogoutOriginalCode = DetourFunction((PVOID)FUNCTION_CLIENTCONNECTION_CHARACTERLOGOUT, ClientConnection__CharacterLogout_Hook);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement