Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- #include <string>
- #include <vector>
- #include<map>
- #include "Detour.hpp"
- using uint64 = long long;
- class WoWObject
- {
- public:
- WoWObject()
- {
- Guid = 0;
- SummonedBy = 0;
- XPos = 0;
- YPos = 0;
- ZPos = 0;
- Rotation = 0;
- BaseAddress = 0;
- UnitFieldsAddress = 0;
- Type = 0;
- Name = "";
- CurrentHealth = 0;
- }
- uint64 Guid;
- long long int SummonedBy;
- float XPos;
- float YPos;
- float ZPos;
- float Rotation;
- int BaseAddress;
- int UnitFieldsAddress;
- int16_t Type;
- std::string Name;
- int CurrentHealth;
- };
- volatile bool shouldRemoveEndSceneInjection{};
- volatile bool endSceneUnhooked{};
- volatile bool should_exit{};
- std::map<std::string, Detour*> detours{};
- WoWObject* LocalPlayer = new WoWObject();
- WoWObject* TempObject = new WoWObject();
- inline int ClientConnection() { return *(int*)0x00D43318; }
- inline int ObjManager() { return ClientConnection() ? *(int*)(ClientConnection() + 0x2218) : 0; }
- inline uint64 GetLocalPlayerGuid()
- {
- if (ObjManager())
- return *(uint64*)(ObjManager() + 0xC0);
- return 0;
- }
- inline uint64 ClntObjMgrGetActivePlayer()
- {
- int objm = *(int*)(*(int*)(__readfsdword(0x2C) + 4 * *(int*)0x00E2563C) + 8);
- if (objm)
- return *(uint64*)(objm + 0xC0);
- return 0;
- }
- inline auto GetLocalPlayer() { return ((int(__cdecl*)())0x00402F40)(); }
- inline int GetObjectByGuidTypeCheck(uint64 guid, int typemask = -1)
- {
- return guid ? ((int(__cdecl*)(uint64, int, const char*, int))0x0046B610)(guid, typemask, nullptr, 0) : 0;
- }
- inline auto PerformanceCount() { return ((int(__cdecl*)())0x00749850)(); }
- inline auto GetTargetGuid() { return *(uint64*)0x00C6E960; }
- inline auto GetObjMan() { return *(int*)(*(int*)0x00D43318 + 0x2218); }
- inline auto GetAddrByGUID(long long guid) { return ((int(__cdecl*)(long long))0x0046B4E0)(guid); }
- //---------------- END SCENE DETOUR ------------------
- int __fastcall EndSceneDetour(int s_device, int edx) //is a __thiscall
- {
- if (*(int*)(s_device + 0x3864))
- {
- //printf("player pointer = %X\n", GetAddrByGUID(GetLocalPlayer()));
- LocalPlayer->BaseAddress = GetLocalPlayer();
- if (LocalPlayer->BaseAddress)
- {
- LocalPlayer->XPos = *(float*)(LocalPlayer->BaseAddress + 0xBF0);
- std::cout << LocalPlayer->XPos << std::endl;
- }
- }
- //-------- return to the original function (and remove injection if needed) --------
- auto det = detours["CGxDeviceD3d__ISceneEnd"];
- det->Restore();
- int res = ((int(__fastcall*)(int, int))det->target)(s_device, edx);
- if (shouldRemoveEndSceneInjection)
- {
- auto it = detours.find("CGxDeviceD3d__ISceneEnd");
- delete it->second;
- detours.erase(it);
- endSceneUnhooked = true;
- }
- else
- {
- det->Apply();
- }
- return res;
- }
- DWORD WINAPI hackthread(LPVOID param)
- {
- AllocConsole();
- SetConsoleTitle(L"_TBC_Cpp");
- FILE* stream;
- freopen_s(&stream, "CONOUT$", "w", stdout);
- detours["CGxDeviceD3d__ISceneEnd"] = new Detour(0x005AB230, (int)EndSceneDetour);
- //----------------------------------- loop here before exit ----------------------------------
- //wait for the numpad 7 to be pressed...
- while (!GetAsyncKeyState(VK_NUMPAD7)) { Sleep(250); }
- //tell the endscene hook to finish
- shouldRemoveEndSceneInjection = true;
- printf("Exiting...\n");
- //wait the endscene hook to finish...
- while (!endSceneUnhooked) {}
- // unhooks all detours we created
- for (auto& det : detours)
- delete det.second;
- detours.clear();
- auto conHandle = GetConsoleWindow();
- FreeConsole();
- PostMessage(conHandle, WM_CLOSE, 0, 0);
- FreeLibraryAndExitThread((HMODULE)param, NULL);
- return NULL;
- }
- BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- CreateThread(0, 0, hackthread, hModule, 0, 0); // Added hModule to be passed to hackthread
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment