Advertisement
Guest User

Untitled

a guest
Feb 17th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 16.50 KB | None | 0 0
  1. BOOL
  2. CreateHeartbeatPorter(
  3.     VOID
  4.     )
  5. {
  6.     HeartbeatPorter = AllocateVirtualMemory((DWORD_PTR)NULL, SizeOfProc(HeartbeatPorterAsm), MEM_COMMIT | MEM_RESERVE);
  7.     if (HeartbeatPorter == NULL) {
  8.         return FALSE;
  9.     }
  10.     WriteBuffer((DWORD_PTR)HeartbeatPorter, HeartbeatPorterAsm, SizeOfProc(HeartbeatPorterAsm));
  11.  
  12.     HeartbeatPorterPreview = AllocateVirtualMemory((DWORD_PTR)NULL, SizeOfProc(HeartbeatPorterPreviewAsm), MEM_COMMIT | MEM_RESERVE);
  13.     if (HeartbeatPorterPreview == NULL) {
  14.         return FALSE;
  15.     }
  16.     WriteBuffer((DWORD_PTR)HeartbeatPorterPreview, HeartbeatPorterPreviewAsm, SizeOfProc(HeartbeatPorterPreviewAsm));
  17.  
  18.     return TRUE;
  19. }
  20.  
  21. __declspec(naked)
  22. VOID
  23. HeartbeatPorterPreviewAsm(
  24.     FLOAT TargetPositionX,
  25.     FLOAT TargetPositionY,
  26.     FLOAT TargetPositionZ,
  27.     UINT  Seconds,
  28.     PUINT TimestampModifier
  29.     )
  30. {
  31.     __asm {
  32.         push    ebp
  33.         mov     ebp,esp
  34.         pushad
  35.  
  36. ;
  37. ; Get player base address
  38. ;
  39.         push    90h    
  40.         mov     eax,00468550h
  41.         call    eax                             ; ClntObjMgrGetActivePlayer
  42.  
  43.         push    edx                             ; Player's GUID (HighPart)
  44.        push    eax                             ; Player's GUID (LowPart)
  45.         mov     edx,008364B4h                   ; '..\Object/ObjectClient/Player_C.h'
  46.         mov     ecx,10h                         ; TYPEMASK_PLAYER
  47.         mov     eax,00468460h
  48.         call    eax                             ; ClntObjMgrObjectPtr
  49. ;
  50. ; (eax) = player base
  51.  
  52.         mov     esi,eax
  53.  
  54.         mov     eax,1
  55.         mov     [esi+9E8h],eax                  ; Movement flags
  56.  
  57.         mov     eax,TargetPositionX
  58.         mov     [esi+9B8h],eax                  ; X
  59.  
  60.         mov     eax,TargetPositionY
  61.         mov     [esi+9BCh],eax                  ; Y
  62.  
  63.         mov     eax,TargetPositionZ
  64.         mov     [esi+9C0h],eax                  ; Z
  65.  
  66.         mov     edi,Seconds
  67.         mov     eax,[TimestampModifier]
  68.         mov     eax,[eax]
  69.         add     [eax],edi
  70.  
  71. ;
  72. ; Get timestamp
  73. ;
  74.         mov     eax,0042C010h                   ; OsGetAsyncTimeMs
  75.         call    eax
  76. ;
  77. ; (eax) = timestamp
  78.  
  79. ;
  80. ; Send heartbeat packet
  81. ;
  82.         xor     ebx,ebx
  83.         push    ebx                             ; Unknown1
  84.         push    ebx                             ; Unknown2
  85.         push    0EEh                            ; Opcode (MSG_MOVE_HEARTBEAT)
  86.         push    eax                             ; Timestamp
  87.         mov     ecx,esi                         ; Player base
  88.         mov     eax,00600A30h                   ; CMovementData_C__SendSimpleMoveMessage
  89.         call    eax
  90.  
  91.         xor     eax,eax
  92.         mov     [esi+9E8h],eax                  ; Movement flags
  93.  
  94.         popad
  95.         mov     esp,ebp
  96.         pop     ebp
  97.         ret     14h
  98.     }
  99. }
  100.  
  101. BOOL
  102. StepTelePreview(
  103.     FLOAT X,
  104.     FLOAT Y,
  105.     FLOAT Z,
  106.     UINT  Seconds
  107.     )
  108. {
  109.     INJDATA  InjData;
  110.     UINT     _Seconds = Seconds * 1000;
  111.     DWORD    PlayerBase = ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer());
  112.     BYTE     CallHeartbeatPorterPreview[] =
  113.     {
  114.         0x83, 0xC2, 0x0C,                                                                                                         // add edx,0Ch
  115.         0x52,                                                                                                                     // push edx (TimestampModifier)
  116.  
  117.         0x68, LOBYTE(LOWORD(_Seconds)), HIBYTE(LOWORD(_Seconds)), LOBYTE(HIWORD(_Seconds)), HIBYTE(HIWORD(_Seconds)),             // push _Seconds (Seconds * 1000)
  118.  
  119.         0x68, LOBYTE(LOWORD(*(LONG *)&Z)), HIBYTE(LOWORD(*(LONG *)&Z)), LOBYTE(HIWORD(*(LONG *)&Z)), HIBYTE(HIWORD(*(LONG *)&Z)), // push Z
  120.         0x68, LOBYTE(LOWORD(*(LONG *)&Y)), HIBYTE(LOWORD(*(LONG *)&Y)), LOBYTE(HIWORD(*(LONG *)&Y)), HIBYTE(HIWORD(*(LONG *)&Y)), // push Y
  121.         0x68, LOBYTE(LOWORD(*(LONG *)&X)), HIBYTE(LOWORD(*(LONG *)&X)), LOBYTE(HIWORD(*(LONG *)&X)), HIBYTE(HIWORD(*(LONG *)&X)), // push X
  122.  
  123.         0xB8, LOBYTE(LOWORD(HeartbeatPorterPreview)), HIBYTE(LOWORD(HeartbeatPorterPreview)),                                     //
  124.               LOBYTE(HIWORD(HeartbeatPorterPreview)), HIBYTE(HIWORD(HeartbeatPorterPreview)),                                     // mov eax,HeartbeatPorter
  125.         0xFF, 0xD0,                                                                                                               // call eax
  126.  
  127.         0x31, 0xC0,                                                                                                               // xor eax,eax
  128.         0x50,                                                                                                                     // push eax
  129.         0x50,                                                                                                                     // push eax
  130.         0xB9, LOBYTE(LOWORD(PlayerBase)), HIBYTE(LOWORD(PlayerBase)), LOBYTE(HIWORD(PlayerBase)), HIBYTE(HIWORD(PlayerBase)),     // mov ecx,PlayerBase
  131.         0xB8, 0x70, 0xAC, 0x5F, 0x00,                                                                                             // mov eax,005FAC70h (CGUnit_C__OnMoveUpdate)
  132.         0xFF, 0xD0                                                                                                                // call eax
  133.     };
  134.  
  135.     if (PlayerBase != 0) {
  136.         WriteBuffer((DWORD_PTR)HeartbeatPorterPreview, HeartbeatPorterPreviewAsm, SizeOfProc(HeartbeatPorterPreviewAsm));
  137.  
  138.         RtlZeroMemory(&InjData, sizeof(INJDATA));
  139.  
  140.         SuspendThread(hGameThread);
  141.  
  142.         if (!InjectHooking()) {
  143.             ResumeThread(hGameThread);
  144.             return FALSE;
  145.         }
  146.  
  147.         InjData.JumpPointer = pEndScene;
  148.         *(UINT *)InjData.Command = TimestampModifier;
  149.  
  150.         WriteBuffer((DWORD_PTR)EndSceneHook_Parameters, &InjData, sizeof(INJDATA));
  151.  
  152.         WriteDword((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_PARAMS, (DWORD)EndSceneHook_Parameters);
  153.         WriteBuffer((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_FUNCTION, CallHeartbeatPorterPreview, ARRAYSIZE(CallHeartbeatPorterPreview));
  154.  
  155.         ResumeThread(hGameThread);
  156.  
  157.         return TRUE;
  158.     }
  159.  
  160.     return FALSE;
  161. }
  162.  
  163. __declspec(naked)
  164. VOID
  165. HeartbeatPorterAsm(
  166.     FLOAT TargetPositionX,
  167.     FLOAT TargetPositionY,
  168.     FLOAT TargetPositionZ,
  169.     UINT  Seconds,
  170.     FLOAT CurrentPositionX,
  171.     FLOAT CurrentPositionY,
  172.     FLOAT CurrentPositionZ,
  173.     PUINT TimestampModifier,
  174.     BOOL  FinalPort
  175.     )
  176. {
  177.     __asm {
  178.         push    ebp
  179.         mov     ebp,esp
  180.         pushad
  181.  
  182. ;
  183. ; Get player base address
  184. ;
  185.         push    90h    
  186.         mov     eax,00468550h
  187.         call    eax                             ; ClntObjMgrGetActivePlayer
  188.  
  189.         push    edx                             ; Player's GUID (HighPart)
  190.        push    eax                             ; Player's GUID (LowPart)
  191.         mov     edx,008364B4h                   ; '..\Object/ObjectClient/Player_C.h'
  192.         mov     ecx,10h                         ; TYPEMASK_PLAYER
  193.         mov     eax,00468460h
  194.         call    eax                             ; ClntObjMgrObjectPtr
  195. ;
  196. ; (eax) = player base
  197.  
  198.         mov     esi,eax
  199.  
  200.         mov     eax,1
  201.         mov     [esi+9E8h],eax                  ; Movement flags
  202.  
  203.         mov     eax,TargetPositionX
  204.         mov     [esi+9B8h],eax                  ; X
  205.  
  206.         mov     eax,TargetPositionY
  207.         mov     [esi+9BCh],eax                  ; Y
  208.  
  209.         mov     eax,TargetPositionZ
  210.         mov     [esi+9C0h],eax                  ; Z
  211.  
  212.         mov     eax,[00B41414h]                 ; (eax) = [s_curMgr]
  213.         mov     eax,[eax]
  214.         add     eax,0C0h
  215.         mov     eax,[eax]
  216.         mov     edi,00C4DA98h                   ; (edi) = Player GUID
  217.         mov     [edi],eax
  218.  
  219. ;
  220. ; Add Seconds to TimestampModifier
  221. ;
  222.         mov     edi,Seconds
  223.         mov     eax,[TimestampModifier]
  224.         mov     eax,[eax]
  225.         add     [eax],edi
  226.  
  227. ;
  228. ; Get timestamp
  229. ;
  230.         mov     eax,0042C010h                   ; OsGetAsyncTimeMs
  231.         call    eax
  232. ;
  233. ; (eax) = timestamp
  234.        
  235. ;
  236. ; Send heartbeat packet
  237. ;
  238.         xor     ebx,ebx
  239.         push    ebx                             ; Unknown1
  240.         push    ebx                             ; Unknown2
  241.         push    0EEh                            ; Opcode (MSG_MOVE_HEARTBEAT)
  242.         push    eax                             ; Timestamp
  243.         mov     ecx,esi                         ; Player base
  244.         mov     eax,00600A30h                   ; CMovementData_C__SendSimpleMoveMessage
  245.         call    eax
  246.  
  247.         xor     eax,eax
  248.         mov     edi,00C4DA98h                   ; (edi) = Player GUID
  249.         mov     [edi],eax
  250.         mov     [esi+9E8h],eax                  ; Movement flags
  251.  
  252.         mov     eax,FinalPort
  253.         test    eax,eax
  254.         jnz     Exit
  255.  
  256.         mov     eax,CurrentPositionX
  257.         mov     [esi+9B8h],eax                  ; X
  258.  
  259.         mov     eax,CurrentPositionY
  260.         mov     [esi+9BCh],eax                  ; Y
  261.  
  262.         mov     eax,CurrentPositionZ
  263.         mov     [esi+9C0h],eax                  ; Z
  264.  
  265.         popad
  266.         mov     esp,ebp
  267.         pop     ebp
  268.         ret     24h
  269. Exit:
  270.         mov     eax,[00B41414h]                 ; (eax) = [s_curMgr]
  271.         mov     eax,[eax]
  272.         add     eax,0C0h
  273.         mov     eax,[eax]
  274.         mov     edi,00C4DA98h                   ; (edi) = Player GUID
  275.         mov     [edi],eax
  276.  
  277.         popad
  278.         mov     esp,ebp
  279.         pop     ebp
  280.         ret     24h
  281.     }
  282. }
  283.  
  284. BOOL
  285. StepTele(
  286.     FLOAT X,
  287.     FLOAT Y,
  288.     FLOAT Z,
  289.     UINT  Seconds,
  290.     BOOL  FinalPort
  291.     )
  292. {
  293.     INJDATA  InjData;
  294.     VECTOR3D CurrentPosition = GetPosition();
  295.     UINT     _Seconds = Seconds * 1000;
  296.     DWORD    PlayerBase = ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer());
  297.     BYTE     CallHeartbeatPorter[] =
  298.     {
  299.         0x68, (BYTE)FinalPort, 0x00, 0x00, 0x00,                                                                                  // push FinalPort
  300.  
  301.         0x83, 0xC2, 0x0C,                                                                                                         // add edx,0Ch
  302.         0x52,                                                                                                                     // push edx (TimestampModifier)
  303.  
  304.         0x68, LOBYTE(LOWORD(*(LONG *)&CurrentPosition.Z)), HIBYTE(LOWORD(*(LONG *)&CurrentPosition.Z)),                           //
  305.               LOBYTE(HIWORD(*(LONG *)&CurrentPosition.Z)), HIBYTE(HIWORD(*(LONG *)&CurrentPosition.Z)),                           // push CurrentPosition.Z
  306.         0x68, LOBYTE(LOWORD(*(LONG *)&CurrentPosition.Y)), HIBYTE(LOWORD(*(LONG *)&CurrentPosition.Y)),                           //
  307.               LOBYTE(HIWORD(*(LONG *)&CurrentPosition.Y)), HIBYTE(HIWORD(*(LONG *)&CurrentPosition.Y)),                           // push CurrentPosition.Y
  308.         0x68, LOBYTE(LOWORD(*(LONG *)&CurrentPosition.X)), HIBYTE(LOWORD(*(LONG *)&CurrentPosition.X)),                           //
  309.               LOBYTE(HIWORD(*(LONG *)&CurrentPosition.X)), HIBYTE(HIWORD(*(LONG *)&CurrentPosition.X)),                           // push CurrentPosition.X
  310.  
  311.         0x68, LOBYTE(LOWORD(_Seconds)), HIBYTE(LOWORD(_Seconds)), LOBYTE(HIWORD(_Seconds)), HIBYTE(HIWORD(_Seconds)),             // push _Seconds (Seconds * 1000)
  312.  
  313.         0x68, LOBYTE(LOWORD(*(LONG *)&Z)), HIBYTE(LOWORD(*(LONG *)&Z)), LOBYTE(HIWORD(*(LONG *)&Z)), HIBYTE(HIWORD(*(LONG *)&Z)), // push Z
  314.         0x68, LOBYTE(LOWORD(*(LONG *)&Y)), HIBYTE(LOWORD(*(LONG *)&Y)), LOBYTE(HIWORD(*(LONG *)&Y)), HIBYTE(HIWORD(*(LONG *)&Y)), // push Y
  315.         0x68, LOBYTE(LOWORD(*(LONG *)&X)), HIBYTE(LOWORD(*(LONG *)&X)), LOBYTE(HIWORD(*(LONG *)&X)), HIBYTE(HIWORD(*(LONG *)&X)), // push X
  316.  
  317.         0xB8, LOBYTE(LOWORD(HeartbeatPorter)), HIBYTE(LOWORD(HeartbeatPorter)),                                                   //
  318.               LOBYTE(HIWORD(HeartbeatPorter)), HIBYTE(HIWORD(HeartbeatPorter)),                                                   // mov eax,HeartbeatPorter
  319.         0xFF, 0xD0                                                                                                                // call eax
  320.     };
  321.  
  322.     if (PlayerBase != 0) {
  323.         WriteBuffer((DWORD_PTR)HeartbeatPorter, HeartbeatPorterAsm, SizeOfProc(HeartbeatPorterAsm));
  324.  
  325.         RtlZeroMemory(&InjData, sizeof(INJDATA));
  326.  
  327.         SuspendThread(hGameThread);
  328.  
  329.         if (!InjectHooking()) {
  330.             ResumeThread(hGameThread);
  331.             return FALSE;
  332.         }
  333.  
  334.         InjData.JumpPointer = pEndScene;
  335.         *(UINT *)InjData.Command = TimestampModifier;
  336.  
  337.         WriteBuffer((DWORD_PTR)EndSceneHook_Parameters, &InjData, sizeof(INJDATA));
  338.  
  339.         WriteDword((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_PARAMS, (DWORD)EndSceneHook_Parameters);
  340.         WriteBuffer((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_FUNCTION, CallHeartbeatPorter, ARRAYSIZE(CallHeartbeatPorter));
  341.  
  342.         ResumeThread(hGameThread);
  343.  
  344.         return TRUE;
  345.     }
  346.  
  347.     return FALSE;
  348. }
  349.  
  350. DWORD
  351. WINAPI
  352. SetPositionThreadProc(
  353.     PVOID ThreadParameter
  354.     )
  355. {
  356.     PVECTOR3D TargetPosition = (PVECTOR3D)ThreadParameter;
  357.     VECTOR3D  CurrentPosition;
  358.     FLOAT     Difference;
  359.     UINT      Seconds = 30;
  360.     BOOL      Success;
  361.     WOWREALM  CurrentRealm;
  362.     UINT      i;
  363.  
  364.     if (IsInGame()) {
  365.  
  366.         if (IsValidPosition(TargetPosition)) {
  367.  
  368.             if (!IsWin8orLater) {
  369.                 CurrentRealm = GetCurrentRealm();
  370.  
  371.                 switch (CurrentRealm) {
  372.  
  373.                 case REALM_FEENIX:
  374.                 case REALM_VALKYRIE:
  375.                     CurrentPosition = GetPosition();
  376.                     Difference = (FLOAT)sqrt(pow(CurrentPosition.X - TargetPosition->X, 2) +
  377.                                              pow(CurrentPosition.Y - TargetPosition->Y, 2) +
  378.                                              pow(CurrentPosition.Z - TargetPosition->Z, 2));
  379.  
  380.                     if (Difference > 2) {
  381.                         FLOAT StartX = CurrentPosition.X;
  382.                         FLOAT StartY = CurrentPosition.Y;
  383.  
  384.                         SetMovementFlag(MOVEFLAG_MOVE_STOP);
  385.  
  386.                         for (i = 0; i < (Difference / (7.0f * Seconds)) - 1; i++) {
  387.                             StartX += (TargetPosition->X - StartX) / (Difference / (/* 7.0f * */Seconds));
  388.                             StartY += (TargetPosition->Y - StartY) / (Difference / (/* 7.0f * */Seconds));
  389.  
  390.                             if (!(Success = StepTele(StartX, StartY, 2000, Seconds, FALSE))) {
  391.                                 break;
  392.                             }
  393.  
  394.                             Sleep(25);
  395.                         }
  396.  
  397.                         if (Success) {
  398.                             Success = StepTele(TargetPosition->X, TargetPosition->Y, TargetPosition->Z, Seconds, TRUE);
  399.                         }
  400.                     }
  401.  
  402.                     break;
  403.  
  404.                 default:
  405.                     WriteBuffer(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer()) + OFFSET_UNIT_POSITION, TargetPosition, sizeof(VECTOR3D));
  406.                     SendSimpleMoveMessage(MSG_MOVE_HEARTBEAT);
  407.                     break;            
  408.                 }
  409.                
  410.             }
  411.             else {
  412.                 WriteBuffer(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer()) + OFFSET_UNIT_POSITION, TargetPosition, sizeof(VECTOR3D));
  413.             }      
  414.         }
  415.         else {
  416.             AddErrorMessage("Invalid coordinates.");
  417.             return 1;
  418.         }
  419.     }  
  420.  
  421.     return 0;
  422. }
  423.  
  424. BOOL
  425. SetPosition(
  426.     FLOAT X,
  427.     FLOAT Y,
  428.     FLOAT Z
  429.     )
  430. {
  431.     PVECTOR3D TargetPosition;
  432.     HANDLE    hThread;
  433.     DWORD     ThreadId;
  434.  
  435.     TargetPosition = AllocateMemory(sizeof(VECTOR3D));
  436.     if (TargetPosition == NULL) {
  437.         FreeMemory(TargetPosition);
  438.         return FALSE;
  439.     }
  440.  
  441.     TargetPosition->X = X;
  442.     TargetPosition->Y = Y;
  443.     TargetPosition->Z = Z;
  444.  
  445.     hThread = CreateThread(
  446.                     NULL,
  447.                     0,
  448.                     (LPTHREAD_START_ROUTINE)SetPositionThreadProc,
  449.                     TargetPosition,
  450.                     0,
  451.                     &ThreadId
  452.                     );
  453.     if (hThread == NULL) {
  454.         FreeMemory(TargetPosition);
  455.         return FALSE;
  456.     }
  457.  
  458.     CloseHandle(hThread);
  459.  
  460.  
  461. //     WriteBuffer(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer()) + OFFSET_UNIT_POSITION, TargetPosition, sizeof(VECTOR3D));
  462. //     SendSimpleMoveMessage(MSG_MOVE_FALL_LAND);
  463.  
  464.     return TRUE;
  465. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement