Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <map>
- #include <string>
- #include <d3d9.h>
- #include "..\Microsoft DirectX SDK2010\Include\d3dx9core.h"
- #include "Memory\Detour.hpp"
- #include "Memory\Patch.hpp"
- #include "Util\Timer.hpp"
- #include "Util\Helpers.hpp"
- #include "Lua\Lua.hpp"
- #include "WowStuff\WowFuncs.hpp"
- #include "Objects\Spell.hpp"
- #include "Routines\PaladinLeveling.hpp"
- #include "Graphics.hpp"
- #include "ChatCommandHandler.hpp"
- volatile bool shouldRemovePresentSceneInjection{};
- volatile bool PresentSceneUnhooked{};
- std::map<std::string, MemoryOperation*> g_memops{};
- volatile bool should_exit{};
- volatile bool do_something{};
- int frameCount = 0;
- Graphics* graph = nullptr;
- timer afk_timer;
- int dummy_counter;
- inline void display(const std::string& name, const std::string& value)
- {
- if (!graph)
- return;
- auto line = name + " = " + value;
- graph->AddTextLine(line);
- }
- int __stdcall ResetDetour(int /*device*/, int /*pp*/);
- //---------------- END SCENE DETOUR ------------------
- int __fastcall PresentSceneDetour(int s_device, int edx, int mask) //is a thiscall
- {
- if (*(int*)(s_device + 0xF58) && *(int*)(s_device + 0x3B28))
- {
- auto scene = *(int*)(s_device + 0x397C);
- auto reset_ptr = *(int*)(*(int*)scene + 0x40);
- if (g_memops["Reset"] == nullptr)
- g_memops["Reset"] = new Detour(reset_ptr, (int)ResetDetour);
- OM_Pulse();
- if (frameCount % 30 == 0)
- {
- //printf("%d ", frameCount);
- printf(".");
- }
- if (frameCount == 0)
- chat("CppBot started.");
- if (graph == nullptr && scene)
- graph = new Graphics();
- if (afk_timer.elapsedTime() > 150)
- {
- afk_timer.start();
- *(int*)0x00B499A4 = PerformanceCount();
- }
- graph->Pulse(scene);
- auto lpa = GetLocalPlayer();
- if (lpa)
- {
- if (!ChatLine.empty())
- {
- HandleChatCommand(ChatLine);
- ChatLine = "";
- }
- auto me = LocalPlayer(GetLocalPlayer());
- if (!known_spells_updated)
- UpdateKnownSpells();
- #pragma region TestRegion
- // here is an area for random tests
- //if (do_something)
- if (frameCount % 10 == 0)
- {
- //auto sp = Spell("Aspect of the Hawk");
- //sp.Use(me->Guid());
- //*(int*)(me->addr + 0x1A64) = dummy_counter;
- //me.Race() = RACE_DWARF;
- //*(int*)me.DisplayId() = dummy_counter;
- //*(int*)me.NativeDisplayId() = dummy_counter;
- //me.UpdateDisplayInfo();
- //((int(__thiscall*)(int))0x006E1D70)(lpa);
- //printf("player pointer = %X\n", me.addr);
- //chat(std::to_string(dummy_counter));
- ++dummy_counter;
- do_something = false;
- }
- auto sp = Spell("Chimera Shot");
- /*display("IsAutoshooting", BoolToString(me->IsAutoshootingH()));
- display("GetAutoshooting", std::to_string(me->GetAutoshootingH()));*/
- if (target)
- {
- //display("target", target->Name());
- }
- #pragma endregion
- }
- Common();
- frameCount++;
- }
- //-------- return to the original function (and remove injection if needed) --------
- auto det = g_memops["CGxDeviceD3d__ScenePresent"];
- det->Restore();
- int res = ((int(__thiscall*)(int, int))det->target)(s_device, mask);
- if (shouldRemovePresentSceneInjection)
- {
- chat("Removing CGxDeviceD3d::ScenePresent injection");
- auto it = g_memops.find("CGxDeviceD3d__ScenePresent");
- delete it->second;
- g_memops.erase(it);
- if (graph != nullptr)
- delete graph;
- PresentSceneUnhooked = true;
- }
- else
- {
- det->Apply();
- }
- return res;
- }
- int __stdcall ResetDetour(int device, int pp)
- {
- printf("\nResetDetour\n");
- chat("ResetDetour");
- if (graph != nullptr)
- graph->ReleaseFont();
- //---------------- return to the original function ----------------
- auto det = g_memops["Reset"];
- det->Restore();
- int res = ((int(__stdcall*)(int, int))det->target)(device, pp);
- det->Apply();
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement