Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BOOL
- CreateHeartbeatPorter(
- VOID
- )
- {
- HeartbeatPorter = AllocateVirtualMemory((DWORD_PTR)NULL, SizeOfProc(HeartbeatPorterAsm), MEM_COMMIT | MEM_RESERVE);
- if (HeartbeatPorter == NULL) {
- return FALSE;
- }
- WriteBuffer((DWORD_PTR)HeartbeatPorter, HeartbeatPorterAsm, SizeOfProc(HeartbeatPorterAsm));
- HeartbeatPorterPreview = AllocateVirtualMemory((DWORD_PTR)NULL, SizeOfProc(HeartbeatPorterPreviewAsm), MEM_COMMIT | MEM_RESERVE);
- if (HeartbeatPorterPreview == NULL) {
- return FALSE;
- }
- WriteBuffer((DWORD_PTR)HeartbeatPorterPreview, HeartbeatPorterPreviewAsm, SizeOfProc(HeartbeatPorterPreviewAsm));
- return TRUE;
- }
- __declspec(naked)
- VOID
- HeartbeatPorterPreviewAsm(
- FLOAT TargetPositionX,
- FLOAT TargetPositionY,
- FLOAT TargetPositionZ,
- UINT Seconds,
- PUINT TimestampModifier
- )
- {
- __asm {
- push ebp
- mov ebp,esp
- pushad
- ;
- ; Get player base address
- ;
- push 90h
- mov eax,00468550h
- call eax ; ClntObjMgrGetActivePlayer
- push edx ; Player's GUID (HighPart)
- push eax ; Player's GUID (LowPart)
- mov edx,008364B4h ; '..\Object/ObjectClient/Player_C.h'
- mov ecx,10h ; TYPEMASK_PLAYER
- mov eax,00468460h
- call eax ; ClntObjMgrObjectPtr
- ;
- ; (eax) = player base
- mov esi,eax
- mov eax,1
- mov [esi+9E8h],eax ; Movement flags
- mov eax,TargetPositionX
- mov [esi+9B8h],eax ; X
- mov eax,TargetPositionY
- mov [esi+9BCh],eax ; Y
- mov eax,TargetPositionZ
- mov [esi+9C0h],eax ; Z
- mov edi,Seconds
- mov eax,[TimestampModifier]
- mov eax,[eax]
- add [eax],edi
- ;
- ; Get timestamp
- ;
- mov eax,0042C010h ; OsGetAsyncTimeMs
- call eax
- ;
- ; (eax) = timestamp
- ;
- ; Send heartbeat packet
- ;
- xor ebx,ebx
- push ebx ; Unknown1
- push ebx ; Unknown2
- push 0EEh ; Opcode (MSG_MOVE_HEARTBEAT)
- push eax ; Timestamp
- mov ecx,esi ; Player base
- mov eax,00600A30h ; CMovementData_C__SendSimpleMoveMessage
- call eax
- xor eax,eax
- mov [esi+9E8h],eax ; Movement flags
- popad
- mov esp,ebp
- pop ebp
- ret 14h
- }
- }
- BOOL
- StepTelePreview(
- FLOAT X,
- FLOAT Y,
- FLOAT Z,
- UINT Seconds
- )
- {
- INJDATA InjData;
- UINT _Seconds = Seconds * 1000;
- DWORD PlayerBase = ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer());
- BYTE CallHeartbeatPorterPreview[] =
- {
- 0x83, 0xC2, 0x0C, // add edx,0Ch
- 0x52, // push edx (TimestampModifier)
- 0x68, LOBYTE(LOWORD(_Seconds)), HIBYTE(LOWORD(_Seconds)), LOBYTE(HIWORD(_Seconds)), HIBYTE(HIWORD(_Seconds)), // push _Seconds (Seconds * 1000)
- 0x68, LOBYTE(LOWORD(*(LONG *)&Z)), HIBYTE(LOWORD(*(LONG *)&Z)), LOBYTE(HIWORD(*(LONG *)&Z)), HIBYTE(HIWORD(*(LONG *)&Z)), // push Z
- 0x68, LOBYTE(LOWORD(*(LONG *)&Y)), HIBYTE(LOWORD(*(LONG *)&Y)), LOBYTE(HIWORD(*(LONG *)&Y)), HIBYTE(HIWORD(*(LONG *)&Y)), // push Y
- 0x68, LOBYTE(LOWORD(*(LONG *)&X)), HIBYTE(LOWORD(*(LONG *)&X)), LOBYTE(HIWORD(*(LONG *)&X)), HIBYTE(HIWORD(*(LONG *)&X)), // push X
- 0xB8, LOBYTE(LOWORD(HeartbeatPorterPreview)), HIBYTE(LOWORD(HeartbeatPorterPreview)), //
- LOBYTE(HIWORD(HeartbeatPorterPreview)), HIBYTE(HIWORD(HeartbeatPorterPreview)), // mov eax,HeartbeatPorter
- 0xFF, 0xD0, // call eax
- 0x31, 0xC0, // xor eax,eax
- 0x50, // push eax
- 0x50, // push eax
- 0xB9, LOBYTE(LOWORD(PlayerBase)), HIBYTE(LOWORD(PlayerBase)), LOBYTE(HIWORD(PlayerBase)), HIBYTE(HIWORD(PlayerBase)), // mov ecx,PlayerBase
- 0xB8, 0x70, 0xAC, 0x5F, 0x00, // mov eax,005FAC70h (CGUnit_C__OnMoveUpdate)
- 0xFF, 0xD0 // call eax
- };
- if (PlayerBase != 0) {
- WriteBuffer((DWORD_PTR)HeartbeatPorterPreview, HeartbeatPorterPreviewAsm, SizeOfProc(HeartbeatPorterPreviewAsm));
- RtlZeroMemory(&InjData, sizeof(INJDATA));
- SuspendThread(hGameThread);
- if (!InjectHooking()) {
- ResumeThread(hGameThread);
- return FALSE;
- }
- InjData.JumpPointer = pEndScene;
- *(UINT *)InjData.Command = TimestampModifier;
- WriteBuffer((DWORD_PTR)EndSceneHook_Parameters, &InjData, sizeof(INJDATA));
- WriteDword((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_PARAMS, (DWORD)EndSceneHook_Parameters);
- WriteBuffer((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_FUNCTION, CallHeartbeatPorterPreview, ARRAYSIZE(CallHeartbeatPorterPreview));
- ResumeThread(hGameThread);
- return TRUE;
- }
- return FALSE;
- }
- __declspec(naked)
- VOID
- HeartbeatPorterAsm(
- FLOAT TargetPositionX,
- FLOAT TargetPositionY,
- FLOAT TargetPositionZ,
- UINT Seconds,
- FLOAT CurrentPositionX,
- FLOAT CurrentPositionY,
- FLOAT CurrentPositionZ,
- PUINT TimestampModifier,
- BOOL FinalPort
- )
- {
- __asm {
- push ebp
- mov ebp,esp
- pushad
- ;
- ; Get player base address
- ;
- push 90h
- mov eax,00468550h
- call eax ; ClntObjMgrGetActivePlayer
- push edx ; Player's GUID (HighPart)
- push eax ; Player's GUID (LowPart)
- mov edx,008364B4h ; '..\Object/ObjectClient/Player_C.h'
- mov ecx,10h ; TYPEMASK_PLAYER
- mov eax,00468460h
- call eax ; ClntObjMgrObjectPtr
- ;
- ; (eax) = player base
- mov esi,eax
- mov eax,1
- mov [esi+9E8h],eax ; Movement flags
- mov eax,TargetPositionX
- mov [esi+9B8h],eax ; X
- mov eax,TargetPositionY
- mov [esi+9BCh],eax ; Y
- mov eax,TargetPositionZ
- mov [esi+9C0h],eax ; Z
- mov eax,[00B41414h] ; (eax) = [s_curMgr]
- mov eax,[eax]
- add eax,0C0h
- mov eax,[eax]
- mov edi,00C4DA98h ; (edi) = Player GUID
- mov [edi],eax
- ;
- ; Add Seconds to TimestampModifier
- ;
- mov edi,Seconds
- mov eax,[TimestampModifier]
- mov eax,[eax]
- add [eax],edi
- ;
- ; Get timestamp
- ;
- mov eax,0042C010h ; OsGetAsyncTimeMs
- call eax
- ;
- ; (eax) = timestamp
- ;
- ; Send heartbeat packet
- ;
- xor ebx,ebx
- push ebx ; Unknown1
- push ebx ; Unknown2
- push 0EEh ; Opcode (MSG_MOVE_HEARTBEAT)
- push eax ; Timestamp
- mov ecx,esi ; Player base
- mov eax,00600A30h ; CMovementData_C__SendSimpleMoveMessage
- call eax
- xor eax,eax
- mov edi,00C4DA98h ; (edi) = Player GUID
- mov [edi],eax
- mov [esi+9E8h],eax ; Movement flags
- mov eax,FinalPort
- test eax,eax
- jnz Exit
- mov eax,CurrentPositionX
- mov [esi+9B8h],eax ; X
- mov eax,CurrentPositionY
- mov [esi+9BCh],eax ; Y
- mov eax,CurrentPositionZ
- mov [esi+9C0h],eax ; Z
- popad
- mov esp,ebp
- pop ebp
- ret 24h
- Exit:
- mov eax,[00B41414h] ; (eax) = [s_curMgr]
- mov eax,[eax]
- add eax,0C0h
- mov eax,[eax]
- mov edi,00C4DA98h ; (edi) = Player GUID
- mov [edi],eax
- popad
- mov esp,ebp
- pop ebp
- ret 24h
- }
- }
- BOOL
- StepTele(
- FLOAT X,
- FLOAT Y,
- FLOAT Z,
- UINT Seconds,
- BOOL FinalPort
- )
- {
- INJDATA InjData;
- VECTOR3D CurrentPosition = GetPosition();
- UINT _Seconds = Seconds * 1000;
- DWORD PlayerBase = ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer());
- BYTE CallHeartbeatPorter[] =
- {
- 0x68, (BYTE)FinalPort, 0x00, 0x00, 0x00, // push FinalPort
- 0x83, 0xC2, 0x0C, // add edx,0Ch
- 0x52, // push edx (TimestampModifier)
- 0x68, LOBYTE(LOWORD(*(LONG *)&CurrentPosition.Z)), HIBYTE(LOWORD(*(LONG *)&CurrentPosition.Z)), //
- LOBYTE(HIWORD(*(LONG *)&CurrentPosition.Z)), HIBYTE(HIWORD(*(LONG *)&CurrentPosition.Z)), // push CurrentPosition.Z
- 0x68, LOBYTE(LOWORD(*(LONG *)&CurrentPosition.Y)), HIBYTE(LOWORD(*(LONG *)&CurrentPosition.Y)), //
- LOBYTE(HIWORD(*(LONG *)&CurrentPosition.Y)), HIBYTE(HIWORD(*(LONG *)&CurrentPosition.Y)), // push CurrentPosition.Y
- 0x68, LOBYTE(LOWORD(*(LONG *)&CurrentPosition.X)), HIBYTE(LOWORD(*(LONG *)&CurrentPosition.X)), //
- LOBYTE(HIWORD(*(LONG *)&CurrentPosition.X)), HIBYTE(HIWORD(*(LONG *)&CurrentPosition.X)), // push CurrentPosition.X
- 0x68, LOBYTE(LOWORD(_Seconds)), HIBYTE(LOWORD(_Seconds)), LOBYTE(HIWORD(_Seconds)), HIBYTE(HIWORD(_Seconds)), // push _Seconds (Seconds * 1000)
- 0x68, LOBYTE(LOWORD(*(LONG *)&Z)), HIBYTE(LOWORD(*(LONG *)&Z)), LOBYTE(HIWORD(*(LONG *)&Z)), HIBYTE(HIWORD(*(LONG *)&Z)), // push Z
- 0x68, LOBYTE(LOWORD(*(LONG *)&Y)), HIBYTE(LOWORD(*(LONG *)&Y)), LOBYTE(HIWORD(*(LONG *)&Y)), HIBYTE(HIWORD(*(LONG *)&Y)), // push Y
- 0x68, LOBYTE(LOWORD(*(LONG *)&X)), HIBYTE(LOWORD(*(LONG *)&X)), LOBYTE(HIWORD(*(LONG *)&X)), HIBYTE(HIWORD(*(LONG *)&X)), // push X
- 0xB8, LOBYTE(LOWORD(HeartbeatPorter)), HIBYTE(LOWORD(HeartbeatPorter)), //
- LOBYTE(HIWORD(HeartbeatPorter)), HIBYTE(HIWORD(HeartbeatPorter)), // mov eax,HeartbeatPorter
- 0xFF, 0xD0 // call eax
- };
- if (PlayerBase != 0) {
- WriteBuffer((DWORD_PTR)HeartbeatPorter, HeartbeatPorterAsm, SizeOfProc(HeartbeatPorterAsm));
- RtlZeroMemory(&InjData, sizeof(INJDATA));
- SuspendThread(hGameThread);
- if (!InjectHooking()) {
- ResumeThread(hGameThread);
- return FALSE;
- }
- InjData.JumpPointer = pEndScene;
- *(UINT *)InjData.Command = TimestampModifier;
- WriteBuffer((DWORD_PTR)EndSceneHook_Parameters, &InjData, sizeof(INJDATA));
- WriteDword((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_PARAMS, (DWORD)EndSceneHook_Parameters);
- WriteBuffer((DWORD_PTR)EndSceneHook_InjectedCode + OFFSET_ESHOOK_FUNCTION, CallHeartbeatPorter, ARRAYSIZE(CallHeartbeatPorter));
- ResumeThread(hGameThread);
- return TRUE;
- }
- return FALSE;
- }
- DWORD
- WINAPI
- SetPositionThreadProc(
- PVOID ThreadParameter
- )
- {
- PVECTOR3D TargetPosition = (PVECTOR3D)ThreadParameter;
- VECTOR3D CurrentPosition;
- FLOAT Difference;
- UINT Seconds = 30;
- BOOL Success;
- WOWREALM CurrentRealm;
- UINT i;
- if (IsInGame()) {
- if (IsValidPosition(TargetPosition)) {
- if (!IsWin8orLater) {
- CurrentRealm = GetCurrentRealm();
- switch (CurrentRealm) {
- case REALM_FEENIX:
- case REALM_VALKYRIE:
- CurrentPosition = GetPosition();
- Difference = (FLOAT)sqrt(pow(CurrentPosition.X - TargetPosition->X, 2) +
- pow(CurrentPosition.Y - TargetPosition->Y, 2) +
- pow(CurrentPosition.Z - TargetPosition->Z, 2));
- if (Difference > 2) {
- FLOAT StartX = CurrentPosition.X;
- FLOAT StartY = CurrentPosition.Y;
- SetMovementFlag(MOVEFLAG_MOVE_STOP);
- for (i = 0; i < (Difference / (7.0f * Seconds)) - 1; i++) {
- StartX += (TargetPosition->X - StartX) / (Difference / (/* 7.0f * */Seconds));
- StartY += (TargetPosition->Y - StartY) / (Difference / (/* 7.0f * */Seconds));
- if (!(Success = StepTele(StartX, StartY, 2000, Seconds, FALSE))) {
- break;
- }
- Sleep(25);
- }
- if (Success) {
- Success = StepTele(TargetPosition->X, TargetPosition->Y, TargetPosition->Z, Seconds, TRUE);
- }
- }
- break;
- default:
- WriteBuffer(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer()) + OFFSET_UNIT_POSITION, TargetPosition, sizeof(VECTOR3D));
- SendSimpleMoveMessage(MSG_MOVE_HEARTBEAT);
- break;
- }
- }
- else {
- WriteBuffer(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer()) + OFFSET_UNIT_POSITION, TargetPosition, sizeof(VECTOR3D));
- }
- }
- else {
- AddErrorMessage("Invalid coordinates.");
- return 1;
- }
- }
- return 0;
- }
- BOOL
- SetPosition(
- FLOAT X,
- FLOAT Y,
- FLOAT Z
- )
- {
- PVECTOR3D TargetPosition;
- HANDLE hThread;
- DWORD ThreadId;
- TargetPosition = AllocateMemory(sizeof(VECTOR3D));
- if (TargetPosition == NULL) {
- FreeMemory(TargetPosition);
- return FALSE;
- }
- TargetPosition->X = X;
- TargetPosition->Y = Y;
- TargetPosition->Z = Z;
- hThread = CreateThread(
- NULL,
- 0,
- (LPTHREAD_START_ROUTINE)SetPositionThreadProc,
- TargetPosition,
- 0,
- &ThreadId
- );
- if (hThread == NULL) {
- FreeMemory(TargetPosition);
- return FALSE;
- }
- CloseHandle(hThread);
- // WriteBuffer(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer()) + OFFSET_UNIT_POSITION, TargetPosition, sizeof(VECTOR3D));
- // SendSimpleMoveMessage(MSG_MOVE_FALL_LAND);
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement