Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- unsigned long GObjects = NULL;
- unsigned long GNames = NULL;
- #include "C:\TFL_SDK_GEN\MH\SDKheaders.h"
- #include "d3d.h"
- #pragma region SDK DEFINES
- // We include this now because DefFunc sets things needed within here
- unsigned long TheWorld = NULL;
- unsigned long ThePE = NULL;
- // A1 ? ? ? ? 8b ? ? 8b ? ? 25 ? 02 ? ?
- #define GObjects_Pattern "\xA1\x00\x00\x00\x00\x8B\x00\x00\x8B\x00\x00\x25\x00\x02\x00\x00"
- #define GObjects_Mask "x????x??x??xxxxx"
- #define GObjects_Offset 0x1
- // 8b 0d ? ? ? ? 83 3c 81 00 74
- // 8b 0d ? ? ? ? 53 55 8b 0c b1 text:008DFB2C mov ecx, dword_201C428
- #define GNames_Pattern "\x8b\x0d\x00\x00\x00\x00\x53\x55\x8b\x0c\xb1"
- #define GNames_Mask "xx????xxxxx"
- #define GNames_Offset 0x2
- // 8B 0D ? ? ? ? 89 74 24 2C 89 74 24 30 F3 0F 11 44 24 34
- // CaptureMemoryChartInfo
- // 8B 0D ? ? ? ? 85 C9 74 30 E8 54 24 56 00 85 C0 74 27 8B
- // 8B 0D ? ? ? ? 85 C9 74 30 E8
- #define TheWorld_Pattern "\x8B\x0D\x00\x00\x00\x00\x85\xC9\x74\x30\xE8"
- #define TheWorld_Mask "xx????xxxxx"
- #define TheWorld_Offset 0x2 // cuz 2* xx be4 ????
- // 55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83
- // 55 8B EC 6A FF 68 AE ? ? ? 64 A1 ? ? ? ? 50 83
- //55 8B EC 6A FF 68 9E 4E 90 01 64 A1 00 00 00 00 50 83
- //55 8B EC 6A FF 68 9E ? ? ? 64 A1 ? ? ? ? 50 83
- //
- //55 8B EC 6A FF 68 AE 51 90 01 64 A1 00 00 00 00 50 83 EC 7C A1 00 31 FA 01 33 C5 89 45 F0 53 56
- //55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 7C A1 00 31 FA GOOD
- //\x55\x8B\xEC\x6A\xFF\x68\x00\x00\x00\x00\x64\xA1\x00\x00\x00\x00\x50\x83\xEC\x7C\xA1 xxxxxx????xx????xxxxx
- #define ProcessEvent_Pattern "\x55\x8B\xEC\x6A\xFF\x68\x00\x00\x00\x00\x64\xA1\x00\x00\x00\x00\x50\x83\xEC\x40"
- #define ProcessEvent_Mask "xxxxxx????xx????xxxx"
- #define ProcessEvent_Offset 0x6
- #define PI 3.14159265
- DWORD dwProcessEvent = NULL;
- DWORD dwOldProcessEvent = NULL;
- DWORD dwOldEndScene = NULL;
- HANDLE PingThread = NULL;
- void DefFunc()
- {
- MODULEINFO miGame = TFLHACKT00LS::GetModuleInfo(NULL);
- GObjects = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)GObjects_Pattern, (char*)GObjects_Mask) + GObjects_Offset);
- GNames = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)GNames_Pattern, (char*)GNames_Mask) + GNames_Offset);
- TheWorld = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)TheWorld_Pattern, (char*)TheWorld_Mask) + TheWorld_Offset);
- }
- // Using this to find DLL path
- EXTERN_C IMAGE_DOS_HEADER __ImageBase;
- using namespace std;
- using boost::format;
- #pragma endregion
- /*
- //LOS tag for abilitiy
- //fixed waypointing, doesn't require mouse anymore (only things left that ever use virtual mouse is looting and mousetarget)
- Power Number |0| PowerSlot = 0 Usable = 1 Cooldown = 0 Slot 1
- Power Number |1| PowerSlot = 1 Usable = 1 Cooldown = 0 Slot 8
- Power Number |2| PowerSlot = 2 Usable = 1 Cooldown = 0 Slot 2
- Power Number |3| PowerSlot = 3 Usable = 1 Cooldown = 0 Slot 3
- Power Number |4| PowerSlot = 4 Usable = 1 Cooldown = 0 Slot 4
- Power Number |5| PowerSlot = 5 Usable = 1 Cooldown = 0 Slot 5
- Power Number |6| PowerSlot = 6 Usable = 1 Cooldown = 0 Slot 6
- Power Number |7| PowerSlot = 7 Usable = 1 Cooldown = 0 Slot 7
- Power Number |8| PowerSlot = 15 Usable = 1 Cooldown = 0 MedKit
- Power Number |9| PowerSlot = 16 Usable = 0 Cooldown = 0 Ultimate
- Power Number |10| PowerSlot = 17 Usable = 0 Cooldown = 0 Teamup Summon? Is usable as long as it's off cd though teamup may already be out
- TODO
- //check usable test while doing my is function for things like the pet ability and the teamup
- //allocate every function so they can be moved anywhere I want? possibly other files?
- //redo entire pick ability logic with a isabilityusable function and a useabilityfunction
- //seperate the bigger guitriggers and prepcharacter stuff and whatnot into functions
- //switch at certain level for onescript
- //stash itemgrid?
- //moveing in a different function check all that again....?
- //Rewrite midtown completely and allow for more options
- //Shiftclick? maybe through engine sigh or different thread?
- //There's gotta be a way to split a stack without all the mouse moving and whatnot...I really hate doing this
- //I can't get the damn POI's... really fuckin gay...
- dialogtarget stuff to determine if crafter is broken?
- damage meter mode (have to use mouseclicks or its gay)
- rewrite everything so we can just set a destination and thats where we wanna go, than use a single movement to go there
- might be useful at one point //GameViewPort->SetMouse(1, 1);
- even moves the OS point if it's there... it moves it all man
- MHBUDDY UI
- IF SERVICE GOES DOWN THEY STILL NEED TO BE ABLE TO USE LOCAL UI
- ultimates need the ultimate tag
- download rared debug file and attempt to place in correct location
- notify me when (add a list of words) (seen in any chat)
- force sync button / timered notification that you need to sync?
- crash restarter? auto-starter?
- community ratings for templates?
- Comments for templates?
- Change Ability template icons to names (much better, we don't need to show icons)
- Onescript System is automatically always copied first (than will be overwritten if needed from clones)
- Child Templates arnt Published??
- Forgot Password for people to email them their password
- New Ability Basic Stuff / TeamUp for basics
- Omega linker to ability file
- slot
- 0 = Costume
- 1 = Slot 1
- 2 = Slot 2
- 3 = Slot 3
- 4 = Slot 4
- 5 = Slot 5
- 7 = Medallion
- 8 = Artifact
- 9 = Relic
- 10 = Insignia
- 11 = Artifact
- 12 = Ring
- 13 = Legendary
- 14 = Artifact
- 15 = Uruforged
- */
- #pragma region Loggers
- // Logger Variables
- bool gDebug = false; // DEBUGGING
- bool gDebugLastSet = false;
- bool gDebug2 = false; // SUPER DEBUGGING
- bool gDebugRadius = false;
- bool gTerminalDebug = true;
- bool gGridDebug = false;
- bool gDynamicGridDebug = false;
- bool gPathDebug = false;
- bool gAvoidanceDebug = false;
- bool gLOSDEBUG = false;
- bool gDebugSpam = false;
- bool gRender = true;
- bool gExportChat = true;
- bool gCoolRoster = false;
- errno_t err;
- FILE *pFile;
- string pFileName = "logFile.txt";
- vector<string> PendingLogFile;
- vector<string> PendingDLogFile;
- vector<int> PendingSendText;
- long long microseconds_now() {
- static LARGE_INTEGER s_frequency;
- static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
- if (s_use_qpc) {
- LARGE_INTEGER now;
- QueryPerformanceCounter(&now);
- return (1000LL * now.QuadPart) / s_frequency.QuadPart;
- }
- else {
- return GetTickCount();
- }
- }
- string to_string(wchar_t* text)
- {
- if (text == NULL)
- return "NULL";
- wstring blah = text;
- string retval(blah.begin(), blah.end());
- return retval;
- }
- string to_string(wstring text)
- {
- wstring blah = text;
- string retval(blah.begin(), blah.end());
- return retval;
- }
- string to_string(bool text)
- {
- if (text)
- return "TRUE";
- else
- return "FALSE";
- }
- string to_string(float value)
- {
- std::stringstream ss;
- ss << std::setprecision(std::numeric_limits<float>::digits10 + 2);
- ss << value;
- return ss.str();
- }
- string to_hex(int num)
- {
- stringstream ss;
- ss << hex << num; // int decimal_value
- string res(ss.str());
- res = "0x" + res;
- return res;
- }
- wstring to_wstring(string text)
- {
- wchar_t buf[5000];
- swprintf_s(buf, L"%S", text.c_str());
- return buf;
- }
- void TimeStamp()
- {
- time_t rawtime;
- struct tm timeinfo;
- char buffer[128];
- time(&rawtime);
- localtime_s(&timeinfo, &rawtime);
- strftime(buffer, 80, "\n[%x %I:%M:%S %p]", &timeinfo);
- while (!pFile)
- {
- pFile = _fsopen(pFileName.c_str(), "a", _SH_DENYNO);
- }
- fprintf(pFile, "%s", buffer);
- fclose(pFile);
- }
- string TimeStampStr()
- {
- time_t rawtime;
- struct tm timeinfo;
- char buffer[128];
- time(&rawtime);
- localtime_s(&timeinfo, &rawtime);
- strftime(buffer, 80, "[%x %I:%M:%S %p]", &timeinfo);
- return buffer;
- }
- string TimeStampC(long long mytime)
- {
- struct tm timeinfo;
- char buffer[128];
- time_t rawtime = static_cast<time_t>(mytime / 1000);
- localtime_s(&timeinfo, &rawtime);
- strftime(buffer, 80, "[%I:%M:%S%p]", &timeinfo);
- return buffer;
- }
- template <typename T>
- T WriteLogFile(T t)
- {
- PendingLogFile.push_back(str(format("%1%") % t));
- PendingDLogFile.push_back(str(format("%1%") % t));
- return t;
- }
- template <typename T>
- T WriteLogFileD(T t)
- {
- if (gDebug)
- {
- PendingDLogFile.push_back(str(format("%1%") % t));
- }
- return t;
- }
- void WriteLogFile(wchar_t* szString)
- {
- char buffer[5000];
- sprintf_s(buffer, "%ls", szString);
- PendingLogFile.push_back(buffer);
- PendingDLogFile.push_back(buffer);
- }
- void WriteLogFile(wstring* szString)
- {
- char buffer[5000];
- sprintf_s(buffer, "%ls", szString);
- PendingLogFile.push_back(buffer);
- PendingDLogFile.push_back(buffer);
- }
- void WriteLogFileD(wchar_t* szString)
- {
- if (gDebug)
- {
- char buffer[5000];
- sprintf_s(buffer, "%ls", szString);
- PendingDLogFile.push_back(buffer);
- }
- }
- void WriteLogFileD(wstring* szString)
- {
- if (gDebug)
- {
- char buffer[5000];
- sprintf_s(buffer, "%ls", szString);
- PendingDLogFile.push_back(buffer);
- }
- }
- #pragma endregion
- #pragma region General Helper Functions
- void killProcessByName(string filename)
- {
- HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL);
- PROCESSENTRY32 pEntry;
- pEntry.dwSize = sizeof(pEntry);
- BOOL hRes = Process32First(hSnapShot, &pEntry);
- while (hRes)
- {
- if (boost::iequals(pEntry.szExeFile, filename))
- {
- HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, (DWORD)pEntry.th32ProcessID);
- if (hProcess != NULL)
- {
- TerminateProcess(hProcess, 9);
- CloseHandle(hProcess);
- }
- }
- hRes = Process32Next(hSnapShot, &pEntry);
- }
- CloseHandle(hSnapShot);
- }
- wstring replaceAll(wstring s, wstring f, wstring r) {
- unsigned int found = 0;
- while ((found = s.find(f, found)) != string::npos) {
- s.replace(found, f.length(), r);
- found += r.size();
- }
- return s;
- }
- string rev(string x)
- {
- auto a = x.begin();
- auto b = x.rbegin();
- while (a < b.base())
- swap(*a++, *b++);
- return x;
- }
- struct InvalidChar
- {
- bool operator()(char c) const {
- return !isprint((unsigned)c);
- }
- };
- string stripHTMLTags(string s) {
- s.erase(std::remove_if(s.begin(), s.end(), InvalidChar()), s.end());
- while (true) {
- unsigned int left = s.find("<");
- unsigned int right = s.find(">");
- if (left == string::npos || right == string::npos)
- break;
- s = s.erase(left, right - left + 1);
- }
- return s;
- }
- wstring stripHTMLTags(wstring s) {
- s.erase(std::remove_if(s.begin(), s.end(), InvalidChar()), s.end());
- while (true) {
- unsigned int left = s.find(L"<");
- unsigned int right = s.find(L">");
- if (left == string::npos || right == string::npos)
- break;
- s = s.erase(left, right - left + 1);
- }
- // Etc...
- return s;
- }
- bool CompareFloats(float A, float B)
- {
- return abs(A - B) < 0.001;
- }
- template<typename charT>
- struct my_equal {
- my_equal(const locale& loc) : loc_(loc) {}
- bool operator()(charT ch1, charT ch2) {
- return std::toupper(ch1, loc_) == std::toupper(ch2, loc_);
- }
- private:
- const locale& loc_;
- };
- // find substring (case insensitive)
- template<typename T>
- int ci_find_substr(const T& str1, const T& str2, const locale& loc = locale())
- {
- typename T::const_iterator it = std::search(str1.begin(), str1.end(),
- str2.begin(), str2.end(), my_equal<typename T::value_type>(loc));
- if (it != str1.end()) return it - str1.begin();
- else return -1; // not found
- }
- bool is_float(string line)
- {
- char* p;
- strtod(line.c_str(), &p);
- return *p == 0;
- }
- bool is_number2(string line)
- {
- char* p;
- strtol(line.c_str(), &p, 10);
- return *p == 0;
- }
- bool is_number(string line)
- {
- bool test = false;
- if (is_number2(line))
- test = true;
- if (is_float(line))
- test = true;
- return test;
- }
- vector<string> splitstring(const string &s, char delim) {
- stringstream ss(s);
- string item;
- vector<string> tokens;
- while (getline(ss, item, delim)) {
- tokens.push_back(item);
- }
- return tokens;
- }
- #pragma endregion
- string website = "mhbuddy.com";
- string websiteh = "http://";
- LPCWSTR website2 = L"MyBrowser";
- #pragma region Global Defines
- // GLOBAL DEFINES
- HWND MHhwnd;
- toolkit::VMTHook* hook[10]; //Pointer to the VMTHook class
- typedef void(__stdcall *tProcessEvent) (UFunction*, void*, void*);
- tProcessEvent pProcessEvent;
- UFunction *pUFunc = NULL; //pointers to proce+ssevent arguements
- void *pParms = NULL;
- void *pResult = NULL;
- UObject* *pCallObject = NULL;
- AMarvelPlayerController *pPlayerController = NULL;
- AMarvelPlayerCamera *pCamera = NULL;
- AMarvelEntity *pEntity = NULL;
- AMarvelHUD *mHUD = NULL;
- UWorld *World = NULL;
- UMarvelGameEngine *mEngine = NULL;
- UMarvelGFxUIManager *mManager = NULL;
- char FunctionName[256]; // Used for inside PE to compare events
- char DllPath[512]; // prev 260
- string BasePath;
- string LogFile;
- int gHookNumber = 0;
- bool gRunThreads = true;
- bool gCombatEnabled = true;
- enum gBotState
- {
- BS_LOGGING_IN = 0,
- BS_LOGGING_OUT = 1,
- BS_READY = 2,
- };
- int gBotState = 0;
- int gBotStateOld = 0;
- #pragma endregion
- #pragma region BOT SPECIFIC DEFINES
- // BOT SPECIFIC DEFINES
- string website3 = "/t.txt";
- string website4 = "ghostly";
- vector<FPowerDescriptor> AbilityDetails;
- string gVersion = "1.485";
- bool gVersionMatch = false;
- string gGUITrigger = "";
- float gPlayerSecondaryCurrent = 0.0f;
- float gPlayerSecondaryMax = 0.0f;
- bool gRunning = false;
- string gInGameName = "";
- string gDisplayedErrorMessage = "";
- bool gShouldCheckSettings = true;
- bool gRunningLast = false;
- bool gfuckingmouse = false;
- bool gUsingHoldAbility = false;
- bool gHasTeamUpOut = false;
- __int64 gUsingHoldAbilityTime;
- bool gUsingActivateAbility = false;
- __int64 gUsingActivateAbilityTime;
- bool gDebugUI = false;
- int gLastNotification = 99999;
- int gCurrentAbilityPage = 0;
- int gActivateAbilityNum = 0;
- int gGameStep = 0;
- int gSubGameStep = 0;
- int gSubSubGameStep = 0;
- int gOldGameStep = 99999;
- int gOldGameStep2 = 99999;
- int gTimerCheckpoint = 0;
- int gTimerGoto = 0;
- bool gPossessed = false;
- bool gNeedReconnecting = false;
- int gPrepCharacterStep = 0;
- int gPrepCharacterVar = 0;
- bool gPreppingCharacter = false;
- bool gPreppingGear = false;
- int gLastSlotMarkedasTrash = -1;
- int gCallGoto = 0;
- string gCallFile = "gamesteps.txt";
- bool gInventoryCountFirstRun = true;
- bool gGearCountFirstRun = true;
- int gInventoryCount = -1;
- int gInventoryCountOld = -1;
- bool gInsideaTimer = false;
- wchar_t gWBuffer[5000];
- string gLICENSE = "";
- string gLICENSE2 = "";
- string gUniqueKey = "";
- string gGAMESTEPFILE = "gamesteps.txt";
- string gPassword = "";
- string gUserName = "";
- string gABILITYFILE = "abilities.txt";
- string gLOOTRULEFILE = "lootrules.txt";
- bool gShouldRelog = true;
- bool gfuckhackers = false;
- bool gfuckhackers2 = true; // change this to false to enable md5 checking SECURITYCHECK
- bool gSessionValid = true;
- bool gSessionIp = true;
- bool gEnabledPing = false;
- bool gtesting = false;
- string gv1 = "";
- string gv2 = "";
- string gv3 = "";
- string gv4 = "";
- __int64 gWaitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- __int64 gWaitMedKitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- __int64 gLicenseCheckTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- __int64 gLoginTimer = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- int gLoginCount = 0;
- __int64 gTimerTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- __int64 gCurTime = NULL;
- __int64 gCurTimeS = NULL;
- __int64 gAfkStartCheck = NULL;
- __int64 gDonateTimeOut = NULL;
- __int64 gCraftTimeOut = NULL;
- __int64 gStashTimeOut = NULL;
- __int64 gTrashTimeOut = NULL;
- __int64 gStepResetCheck = NULL;
- __int64 gStepResetCheck2 = NULL;
- __int64 gCombatDisabledUntil = NULL;
- __int64 gAvoidanceDisabledUntil = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- __int64 gLastCombatDisable = NULL;
- __int64 gStatRunStart = NULL;
- __int64 gStatRunTotal = NULL;
- unsigned gStatBiggestNode = 0;
- float gStatBiggestDistance = 0.0f;
- int gTickCounter = 0;
- int gStatDeathRun = 0;
- int gStatDeathTotal = 0;
- bool gNeedInventoryUpdate = true;
- bool gCharacterSheetOpen = false;
- time_t gStatStartTime = NULL;
- int gStatRunCount = 0;
- float gMouseX, gMouseY;
- FVector gChaseStartLoc;
- FVector gAfkStartLoc;
- FVector gCellCenterPos;
- FVector gCellCenterNPos;
- FVector gCellCenterSPos;
- FVector gCellCenterEPos;
- FVector gCellCenterWPos;
- int gTermBossId = 9999;
- string gChatFile_Inc = "chat_inc.txt";
- string gChatFile_Out = "chat_out.txt";
- vector<string> gChat_Out;
- int gChat_ShouldFocus = 0;
- vector<string> gChat_Old;
- vector<string> gChat_New;
- __int64 gChat_Time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- #pragma endregion
- // UE3 HELPER FUNCTIONS
- #pragma region General UE3 Helper Functions
- bool IsPointOnLine(FVector a, FVector b, FVector c)
- {
- float crossproduct = (c.Y - a.Y) * (b.X - a.X) - (c.X - a.X) * (b.Y - a.Y);
- if (abs(crossproduct) > 0.1f)
- return false;
- float dotproduct = (c.X - a.X) * (b.X - a.X) + (c.Y - a.Y)*(b.Y - a.Y);
- if (dotproduct < 0.0f)
- return false;
- float squaredlengthba = (b.X - a.X)*(b.X - a.X) + (b.Y - a.Y)*(b.Y - a.Y);
- if (dotproduct > squaredlengthba)
- return false;
- return true;
- }
- FVector getNewPointOnLine(FVector start, FVector end, float distance)
- {
- float vx = end.X - start.X;
- float vy = end.Y - start.Y;
- float mag = sqrt(vx*vx + vy*vy);
- vx /= mag;
- vy /= mag;
- int px2 = (int)(start.X + vx * distance);
- int py2 = (int)(start.Y + vy * distance);
- return{ (float)px2, (float)py2, 0.0f };
- }
- FVector2D getNewPoint(FVector2D center, FVector2D edge, double degrees, float distance)
- {
- FVector2D result;
- double theta = degrees;
- float dx = edge.X - center.X;
- float dy = edge.Y - center.Y;
- float dist = sqrt(dx*dx + dy*dy);
- result.X = round((float)(cos(theta / 180.0*PI)*dx + sin(theta / 180.0*PI)*dy)*distance / dist + center.X);
- result.Y = round((float)(cos(theta / 180.0*PI)*dy - sin(theta / 180.0*PI)*dx)*distance / dist + center.Y);
- return result;
- }
- int roundUp(int numToRound, int multiple)
- {
- if (multiple == 0)
- return numToRound;
- int remainder = abs(numToRound) % multiple;
- if (remainder == 0)
- return numToRound;
- if (numToRound < 0)
- return -(abs(numToRound) - remainder);
- return numToRound + multiple - remainder;
- }
- float VectorDiff(FVector vec1, FVector vec2)
- {
- float distance = sqrt(pow(vec1.X - vec2.X, 2) + pow(vec1.Y - vec2.Y, 2));
- return distance;
- };
- template <class T> T* Cast(UObject* pObj)
- {
- return pObj && pObj->IsA(T::StaticClass()) ? (T*)pObj : NULL;
- }
- UObject* GetInstanceOf(UClass* Class)
- {
- static UObject* ObjectInstance;
- ObjectInstance = NULL;
- for (int i = 0; i < UObject::GObjObjects()->Count; ++i)
- {
- UObject* CheckObject = (*UObject::GObjObjects())(i);
- if (CheckObject && CheckObject->IsA(Class))
- {
- if (!strstr(CheckObject->GetFullName(), "Default"))
- ObjectInstance = CheckObject;
- }
- }
- return ObjectInstance;
- };
- FColor MakeColor(int R, int G, int B, int A)
- {
- FColor ReturnedColor;
- ReturnedColor.R = R;
- ReturnedColor.G = G;
- ReturnedColor.B = B;
- ReturnedColor.A = A;
- return ReturnedColor;
- }
- FColor Green = MakeColor(0, 255, 0, 255);
- FColor Yellow = MakeColor(255, 255, 0, 255);
- FColor Red = MakeColor(255, 0, 0, 255);
- FColor Blue = MakeColor(0, 0, 255, 255);
- FColor LightGreen = MakeColor(100, 255, 150, 120);
- FColor DarkGreen = MakeColor(100, 190, 60, 120);
- FColor White = MakeColor(255, 255, 255, 255);
- FColor Black = MakeColor(0, 0, 0, 0);
- FColor Pink = MakeColor(200, 0, 200, 255);
- FColor MenuBlack = MakeColor(0, 0, 0, 200);
- FColor MenuBlue = MakeColor(59, 209, 237, 150);
- FColor Orange = MakeColor(255, 128, 0, 255);
- #pragma endregion
- #pragma region Bot Related Helper Functions
- string MD5HASH = "";
- char DataReceived[256];
- std::string GetWebsiteData2(const std::string& server, const std::string& file)
- {
- if (boost::icontains(DllPath, website4))
- {
- WriteLogFile("\nData = ");
- }
- try
- {
- boost::asio::ip::tcp::iostream s(server, "http");
- s.expires_from_now(boost::posix_time::seconds(15));
- if (!s)
- {
- return "ERROR : " + s.error().message();
- }
- // ask for the file
- s << "GET " << file << " HTTP/1.0\r\n";
- s << "Host: " << server << "\r\n";
- s << "Accept: */*\r\n";
- s << "Cache-Control: no-cache, no-store, must-revalidate\r\n";
- s << "Pragma: no-cache\r\n";
- s << "Expires: Mon, 1 Jun 1995 01:00:00 GMT\r\n";
- s << "Connection: close\r\n\r\n";
- // Check that response is OK.
- std::string http_version;
- s >> http_version;
- unsigned int status_code;
- s >> status_code;
- std::string status_message;
- std::getline(s, status_message);
- if (!s && http_version.substr(0, 5) != "HTTP/")
- {
- return "ERROR";
- }
- if (status_code != 200)
- {
- return "ERROR WITH CODE - " + to_string(status_code);
- }
- // Process the response headers, which are terminated by a blank line.
- std::string header;
- while (std::getline(s, header) && header != "\r"){}
- // Write the remaining data to output.
- std::stringstream ss;
- ss << s.rdbuf();
- if (boost::icontains(DllPath, website4))
- {
- WriteLogFile(ss.str());
- }
- return ss.str();
- }
- catch (std::exception& e)
- {
- return e.what();
- }
- }
- bool SessionPing(string uniquekey)
- {
- // PING%OS_MorB%_Method
- //string morb = GetVariableValue("OS_MorB");
- //string meth = morb + "_Method";
- //string meth = GetVariableValue(meth);
- string v = "/instancecheck.php?uk=" + uniquekey + "&license=" + gLICENSE + "&em=" + gInGameName;
- v = GetWebsiteData2(website, v);
- if (boost::icontains(v, "EMERGENCY-SHUTDOWN"))
- gRunThreads = false;
- if (boost::icontains(v, "false"))
- {
- gSessionIp = true;
- if (boost::icontains(v, "IP MISMATCH"))
- gSessionIp = false;
- gSessionValid = false;
- return false;
- }
- gSessionValid = true;
- return true;
- }
- bool Validate()
- {
- for (int aa = 0; aa < 5; aa++)
- {
- char cbuffer[512] = "";
- string v = "/version.txt";
- v = GetWebsiteData2(website, v);
- gVersionMatch = false;
- if (boost::icontains(v, gVersion) || boost::icontains(v, "ERROR"))
- gVersionMatch = true;
- sprintf_s(cbuffer, "/openeshop/api/license/%s?domain=%s", gLICENSE.c_str(), website.c_str()); // original
- string test = GetWebsiteData2(website, cbuffer);
- sprintf_s(DataReceived, "%s", test.c_str());
- test = test.substr(0, 4);
- if (boost::iequals(test, "true"))
- {
- gfuckhackers = true;
- return true;
- }
- Sleep(500);
- }
- gfuckhackers = false;
- return false;
- }
- FString FSTRING(string text)
- {
- wchar_t buf[5000];
- swprintf_s(buf, L"%S", text.c_str());
- return{ buf, wcslen(buf) + 1, wcslen(buf) + 1 };
- }
- void myDrawBox(UCanvas *pCanvas, FColor Color, float CurX, float CurY, float width, float height, string label = "")
- {
- float OldCurX = pCanvas->CurX;
- float OldCurY = pCanvas->CurY;
- float OldCurZ = pCanvas->CurZ;
- FColor OldColor = pCanvas->DrawColor;
- float xrat, yrat;
- xrat = mHUD->viewportResolution.X / 1280.0f;
- yrat = mHUD->viewportResolution.Y / 720.0f;
- CurX = CurX * xrat;
- CurY = CurY * yrat;
- pCanvas->DrawColor = Color;
- pCanvas->SetPos(CurX - 15.0f, CurY - 22.0f, 0.0f);
- pCanvas->DrawText(FSTRING(label), false, 1.0f, 1.0f, NULL);
- pCanvas->SetPos(CurX, CurY, 0.0f);
- pCanvas->DrawBox(width * xrat, height * yrat);
- pCanvas->SetPos(OldCurX, OldCurY, OldCurZ);
- pCanvas->DrawColor = OldColor;
- }
- void myDrawLine(UCanvas *pCanvas, FColor Color, float CurX, float CurY, float CurX2, float CurY2)
- {
- float OldCurX = pCanvas->CurX;
- float OldCurY = pCanvas->CurY;
- float OldCurZ = pCanvas->CurZ;
- FColor OldColor = pCanvas->DrawColor;
- float xrat, yrat;
- xrat = mHUD->viewportResolution.X / 1280.0f;
- yrat = mHUD->viewportResolution.Y / 720.0f;
- CurX = CurX * xrat;
- CurY = CurY * yrat;
- CurX2 = CurX2 * xrat;
- CurY2 = CurY2 * yrat;
- pCanvas->DrawColor = Color;
- pCanvas->Draw2DLine(CurX, CurY, CurX2, CurY2, Color);
- pCanvas->SetPos(OldCurX, OldCurY, OldCurZ);
- pCanvas->DrawColor = OldColor;
- }
- void ShadowedText(UCanvas *pCanvas, WCHAR *text, FColor Color, float CurX, float CurY, float ScaleX = 1.0f, float ScaleY = 1.0f)
- {
- float OldCurX = pCanvas->CurX;
- float OldCurY = pCanvas->CurY;
- FColor OldColor = pCanvas->DrawColor;
- pCanvas->DrawColor = Black;
- FString text2;
- text2.Data = text;
- text2.Count = wcslen(text) + 1;
- text2.Max = text2.Count;
- pCanvas->DrawColor = Color;
- pCanvas->SetPos(CurX, CurY, 1.0f);
- pCanvas->DrawText(text2, false, ScaleX, ScaleY, NULL);
- pCanvas->SetPos(OldCurX, OldCurY, 1.0f);
- pCanvas->DrawColor = OldColor;
- }
- void LeftClickH()
- {
- HWND h = MHhwnd;
- DWORD mouseX = 0;// x coord of mouse
- DWORD mouseY = 0;// y coord of mouse
- PostMessage(h, WM_LBUTTONDOWN, 0, MAKELPARAM(mouseX, mouseY));
- PostMessage(h, WM_LBUTTONUP, 0, MAKELPARAM(mouseX, mouseY));
- }
- void LeftClickG()
- {
- mHUD->m_gameUI->HandleMouseEventInUnreal({ L"LeftMouseButton", 16, 16 }, { L"onPress", 8, 8 }); // doesn't get filtered to UI
- mHUD->m_gameUI->HandleMouseEventInUnreal({ L"LeftMouseButton", 16, 16 }, { L"onRelease", 10, 10 }); // doesn't get filtered to UI
- }
- void LeftClickU()
- {
- mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"LeftMouseButton", 16, 16 }, { L"onPress", 8, 8 });
- mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"LeftMouseButton", 16, 16 }, { L"onRelease", 10, 10 });
- }
- void RightClickG()
- {
- mHUD->m_gameUI->HandleMouseEventInUnreal({ L"RightMouseButton", 17, 17 }, { L"onPressAux", 11, 11 }); // doesn't get filtered to UI
- mHUD->m_gameUI->HandleMouseEventInUnreal({ L"RightMouseButton", 17, 17 }, { L"onRelease", 10, 10 }); // doesn't get filtered to UI
- }
- void RightClickU()
- {
- mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"RightMouseButton", 17, 17 }, { L"onPressAux", 11, 11 });
- mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"RightMouseButton", 17, 17 }, { L"onRelease", 10, 10 });
- }
- void MoveMouse(float x, float y)
- {
- if (mHUD)
- {
- float x1, x2, y1, y2, nx, ny;
- float xrat, yrat;
- xrat = mHUD->viewportResolution.X / mHUD->uiResolution.X;
- yrat = mHUD->viewportResolution.Y / mHUD->uiResolution.Y;
- x = x * xrat;
- y = y * yrat;
- x1 = mHUD->viewportResolution.X;
- x2 = mHUD->uiResolution.X;
- y1 = mHUD->viewportResolution.Y;
- y2 = mHUD->uiResolution.Y;
- nx = (x1 - x2) / 2;
- ny = (y1 - y2) / 2;
- mHUD->m_gameUI->MouseMC->SetPosition(x - nx, y - ny);
- }
- }
- void SendText(string str, bool iskey)
- {
- HWND h = MHhwnd;
- if (!iskey)
- {
- for (string::iterator it = str.begin(); it != str.end(); ++it)
- {
- PendingSendText.push_back(*it);
- }
- }
- else
- {
- PostMessage(h, WM_KEYDOWN, strtoul(str.c_str(), NULL, 16), 0);
- }
- return;
- }
- void PreventAFK()
- {
- HWND h = MHhwnd;
- PostMessage(h, WM_KEYDOWN, VK_LSHIFT, 0);
- SendMessage(h, WM_KEYDOWN, VK_LSHIFT, 0);
- }
- void Wait(int time)
- {
- gWaitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count() + time;
- }
- void Wait(double time)
- {
- gWaitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count() + (long long)time;
- }
- float calculateDistance(float x1, float y1, float x2, float y2)
- {
- float dist = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
- return dist;
- }
- bool isWithPerpDistance(float x1, float y1, float x2, float y2, float c1, float c2, float dist)
- {
- bool flagInside = false;
- float dist1, dist2;
- long long fucktimeout = microseconds_now() + 150;
- while (1)
- {
- if (microseconds_now() > fucktimeout)
- {
- WriteLogFileD("\nAvoidance Error Timeout");
- gAvoidanceDisabledUntil = gCurTime + 1000;
- break;
- }
- dist1 = calculateDistance(x1, y1, c1, c2);
- dist2 = calculateDistance(x2, y2, c1, c2);
- if ((dist1 <= dist) || (dist2 <= dist))
- {
- flagInside = true;
- break;
- }
- if (calculateDistance(x1, y1, x2, y2) < dist / 16)
- {
- break;
- }
- if (dist1 < dist2)
- {
- x2 = (x2 + x1) / 2;
- y2 = (y2 + y1) / 2;
- }
- else
- {
- x1 = (x2 + x1) / 2;
- y1 = (y2 + y1) / 2;
- }
- }
- return flagInside;
- }
- string regex_escape(const string& string_to_escape) {
- static const boost::regex re_boostRegexEscape(string("[.^$|()\\[\\]{}*+?\\\\]"));
- const string rep(string("\\\\&"));
- string result = regex_replace(string_to_escape, re_boostRegexEscape, rep, boost::match_default | boost::format_sed);
- return result;
- }
- UMarvelGFxPanel* GetPanelByName(string panelname)
- {
- for (int wp = 0; wp < mHUD->m_gameUI->ManagerMC->m_panels.Count; wp++)
- {
- if (boost::iequals(panelname, mHUD->m_gameUI->ManagerMC->m_panels(wp)->PanelName.GetName()))
- {
- return mHUD->m_gameUI->ManagerMC->m_panels(wp);
- }
- }
- return NULL;
- }
- FVector2D w2s(FVector worldloc)
- {
- FMatrix view = mHUD->ViewProjectionMatrix;
- float mX = 1280.0f * 0.5f;
- float mY = 720.0f * 0.5f;
- float x = worldloc.X;
- float y = worldloc.Y;
- float z = worldloc.Z;
- float w =
- view.XPlane.Z * x +
- view.YPlane.Z * y +
- view.ZPlane.Z * z +
- view.WPlane.Z;
- float vx =
- view.XPlane.X * x +
- view.YPlane.X * y +
- view.ZPlane.X * z +
- view.WPlane.X;
- float vy =
- view.XPlane.Y * x +
- view.YPlane.Y * y +
- view.ZPlane.Y * z +
- view.WPlane.Y;
- float nx = mX + mX * vx / w;
- float ny = mY - mY * vy / w;
- return{ nx, ny };
- }
- void SpitInfo(UGFxObject* obj, string name)
- {
- if (!obj)
- return;
- WriteLogFile("\n---------------\n");
- WriteLogFile(name);
- WriteLogFile("\nName = ");
- WriteLogFile(to_string(obj->ActionScriptString(FSTRING("toString")).Data));
- WriteLogFile(" ----- ");
- WriteLogFile(obj->GetString(FSTRING("_name")).Data);
- WriteLogFile("\nLength = ");
- WriteLogFile(obj->GetInt(FSTRING("length")));
- WriteLogFile("\nHeight = ");
- WriteLogFile(obj->GetInt(FSTRING("_height")));
- WriteLogFile("\nWidth = ");
- WriteLogFile(obj->GetInt(FSTRING("_width")));
- float x, y;
- obj->GetPosition(&x, &y);
- WriteLogFile("\nX = ");
- WriteLogFile(x);
- WriteLogFile("\nY = ");
- WriteLogFile(y);
- WriteLogFile("\n---------------");
- }
- void SpitString(UGFxObject* obj, string name)
- {
- if (!obj)
- return;
- WriteLogFile("\nStringInfo -- ");
- WriteLogFile(name);
- WriteLogFile(" ---- ");
- WriteLogFile(obj->GetString(FSTRING(name)).Data);
- }
- void SpitInt(UGFxObject* obj, string name)
- {
- if (!obj)
- return;
- WriteLogFile("\nIntInfo -- ");
- WriteLogFile(name);
- WriteLogFile(" ---- ");
- WriteLogFile(obj->GetInt(FSTRING(name)));
- }
- void SetIntInvoke(UGFxObject* object, string iname, int number)
- {
- FString TempMember = FSTRING(iname);
- TArray<FASValue> TempArgs;
- FASValue TempV;
- TempV.Type = AS_Null;
- TempArgs.Add(TempV);
- TempArgs.Data[0].Type = AS_Int;
- TempArgs.Data[0].N = 0;
- TempArgs.Data[0].I = number;
- TempArgs.Data[0].B = true;
- TempArgs.Data[0].S = { L"", 0, 0 };
- object->Invoke(TempMember, TempArgs);
- }
- void LClickObject(UGFxObject* object)
- {
- FString TempMember = { L"handleClick", wcslen(L"handleClick") + 1, wcslen(L"handleClick") + 1 };
- TArray<FASValue> TempArgs;
- FASValue TempV;
- TempV.Type = AS_Null;
- TempArgs.Add(TempV);
- TempArgs.Add(TempV);
- TempArgs.Data[0].S = { L"LeftMouseButton", wcslen(L"LeftMouseButton") + 1, wcslen(L"LeftMouseButton") + 1 };
- TempArgs.Data[0].Type = AS_String;
- TempArgs.Data[0].N = 0;
- TempArgs.Data[0].I = 0;
- TempArgs.Data[0].B = true;
- TempArgs.Data[1].Type = AS_Int;
- TempArgs.Data[1].N = 0;
- TempArgs.Data[1].I = 0;
- TempArgs.Data[1].B = true;
- TempArgs.Data[1].S = { L"", 0, 0 };
- object->Invoke(TempMember, TempArgs);
- }
- struct ABILITYDATA
- {
- string icon = "";
- int slot = -1;
- string cooldowntext = "";
- float cooldownscale = 1.0f;
- double cooldown = 0;
- __int64 offcooldown = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- float x = 1.0f;
- float y = 1.0f;
- float h = 1.0f;
- float w = 1.0f;
- bool visible = false;
- bool textureloaded = false;
- LPD3DXFONT font = NULL;
- LPDIRECT3DTEXTURE9 texture = NULL;
- };
- struct PAGEDATA
- {
- vector<ABILITYDATA> AbilityData;
- };
- vector<PAGEDATA> PageData;
- void LoadConfig()
- {
- // Gets the full path of our dll without the dll name
- string path(DllPath);
- path = path.substr(0, (path.find_last_of("\\")) + 1);
- path.append("config.txt");
- // CUSTOM KEYBINDS
- ifstream infile;
- string line;
- infile.open(path);
- if (infile.is_open())
- {
- while (getline(infile, line))
- {
- //SETTING VALUE SUBSETTING VALUE2
- boost::trim_left(line);
- boost::trim_right(line);
- vector<string> lines = splitstring(line, ',');
- if (boost::iequals(lines[0], "Page"))
- {
- //Page,#,Slot,#,PX,PY,H,W
- WriteLogFile("\nPage ");
- WriteLogFile(lines[1]);
- WriteLogFile(" Slot ");
- WriteLogFile(lines[2]);
- PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].visible = true;
- PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].x = stof(lines[3]);
- PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].y = stof(lines[4]);
- PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].h = stof(lines[5]) - 1.0f;
- PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].w = stof(lines[6]) - 1.0f;
- }
- }
- infile.close();
- }
- }
- bool gTestBool = false;
- int gTestNumber = 0;
- int gTestNumber2 = 0;
- int testnumber = 0;
- string RandomString(int len)
- {
- string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- int pos;
- while (str.size() != len) {
- pos = ((rand() % (str.size() - 1)));
- str.erase(pos, 1);
- }
- return str;
- }
- int currentpage = 0;
- FVector2D t_mousepos, r_mousepos;
- void MyRender2(UCanvas *pCanvas)
- {
- if (pCanvas)
- {
- wchar_t Blah[5000];
- float line = 15.0f;
- if (pPlayerController && pPlayerController->Agent)
- {
- swprintf_s(Blah, L"Current Page = %d", currentpage);
- ShadowedText(pCanvas, Blah, Yellow, 1.0f, 1 * line + 1.0f);
- swprintf_s(Blah, L"TMouse Pos = x %.1f y %.1f", t_mousepos.X, t_mousepos.Y);
- ShadowedText(pCanvas, Blah, Yellow, 1.0f, 2 * line + 1.0f);
- swprintf_s(Blah, L"Mouse Pos = x %.1f y %.1f", r_mousepos.X, r_mousepos.Y);
- ShadowedText(pCanvas, Blah, Yellow, 1.0f, 3 * line + 1.0f);
- //for (unsigned x = 0; x < PageData.size(); x++)
- //for (unsigned y = 0; y < PageData[x].AbilityData.size(); y++)
- //{
- //swprintf_s(Blah, L"Page = %d | Slot %d | Cooldown %.1f | Icon %S", x, PageData[x].AbilityData[y].slot, PageData[x].AbilityData[y].cooldown, PageData[x].AbilityData[y].icon.c_str());
- //ShadowedText(pCanvas, Blah, Yellow, 1.0f, 1 + ((x*8) + y) * line + 1.0f);
- //}
- }
- }
- }
- typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
- EndScene_t pEndScene;
- bool is_file_exist(const char *fileName)
- {
- std::ifstream infile(fileName);
- return infile.good();
- }
- void DrawLine(int X, int Y, int XX, int YY, float LineWidth, D3DCOLOR LineColor, bool Outlined, float OutlineWidth, D3DCOLOR OutlineColor)
- {
- D3DXVECTOR2 Points[2];
- Points[0] = D3DXVECTOR2(X, Y);
- Points[1] = D3DXVECTOR2(XX, YY);
- if (Outlined)
- {
- g_pLine->SetWidth(OutlineWidth * 2 + LineWidth);
- g_pLine->Draw(Points, 2, OutlineColor);
- }
- g_pLine->SetWidth(LineWidth);
- g_pLine->Draw(Points, 2, LineColor);
- }
- void DrawRect(int X, int Y, int Width, int Height, float LineWidth, D3DCOLOR LineColor, bool Outlined, bool Filled, float OutlineWidth, D3DCOLOR OutlineColor)
- {
- if (Filled)
- {
- if (Outlined)
- {
- DrawLine(X - OutlineWidth, Y + Height / 2, X + Width + OutlineWidth, Y + Height / 2, Height, OutlineColor, true, OutlineWidth, OutlineColor);
- }
- DrawLine(X, Y + Height / 2, X + Width, Y + Height / 2, Height, LineColor, false, 0, 0);
- }
- else
- {
- if (Outlined)
- {
- DrawLine(X, Y, X, Y + Height, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
- DrawLine(X, Y + Height, X + Width, Y + Height, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
- DrawLine(X + Width, Y + Height, X + Width, Y, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
- DrawLine(X + Width, Y, X, Y, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
- }
- else
- {
- DrawLine(X, Y, X, Y + Height, LineWidth, LineColor, false, 0, 0);
- DrawLine(X, Y + Height, X + Width, Y + Height, LineWidth, LineColor, false, 0, 0);
- DrawLine(X + Width, Y + Height, X + Width, Y, LineWidth, LineColor, false, 0, 0);
- DrawLine(X + Width, Y, X, Y, LineWidth, LineColor, false, 0, 0);
- }
- }
- }
- float px, py;
- float ex, ey, ew, eh;
- HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
- {
- if (!gRunThreads)
- return pEndScene(pDevice);
- pDevice->GetViewport(&g_ViewPort);
- if (g_ViewPort.Width != 1094.0f || g_ViewPort.Height != 821.0f)
- return pEndScene(pDevice);
- if (!sprite)
- { //D3DX_DEFAULT_NONPOW2
- D3DXCreateSprite(pDevice, &sprite);
- D3DXCreateLine(pDevice, &g_pLine); //Create lines
- }
- sprite->Begin(D3DXSPRITE_ALPHABLEND);
- for (int p = 0; p < 3; p++)
- for (int s = 0; s < 8; s++)
- {
- if (!PageData[p].AbilityData[s].visible)
- continue;
- if (!PageData[p].AbilityData[s].textureloaded)
- {
- PageData[p].AbilityData[s].textureloaded = true;
- string temp = BasePath + PageData[p].AbilityData[s].icon + ".tga";
- if (!is_file_exist(temp.c_str()))
- temp = BasePath + "40x40_placeholder.tga";
- WriteLogFile("\nLoading Texture = ");
- WriteLogFile(temp);
- if (PageData[p].AbilityData[s].texture)
- PageData[p].AbilityData[s].texture->Release();
- if (PageData[p].AbilityData[s].font)
- PageData[p].AbilityData[s].font->Release();
- D3DXCreateTextureFromFileExA(pDevice, temp.c_str(), PageData[p].AbilityData[s].h, PageData[p].AbilityData[s].w, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &PageData[p].AbilityData[s].texture);
- D3DXCreateFontA(pDevice, PageData[p].AbilityData[s].h, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &PageData[p].AbilityData[s].font);
- }
- float px = PageData[p].AbilityData[s].x + ((mHUD->viewportResolution.X - mHUD->uiResolution.X) / 2.0f);
- float py = PageData[p].AbilityData[s].y + ((mHUD->viewportResolution.Y - mHUD->uiResolution.Y) / 2.0f);
- D3DXVECTOR3 pos = D3DXVECTOR3(px, py, 0.0f);
- D3DCOLOR color;
- color = D3DCOLOR_ARGB(255, 255, 255, 255);
- D3DCOLOR color2;
- color2 = D3DCOLOR_ARGB(255, 255, 1, 1);
- D3DXMATRIX S, P;
- sprite->GetTransform(&P);
- sprite->Draw(PageData[p].AbilityData[s].texture, NULL, NULL, &pos, 0xFFFFFFFF);
- DrawRect(px - 1, py - 1, PageData[p].AbilityData[s].h + 1, PageData[p].AbilityData[s].w + 1, 1.0f, color, false, false, 0.0f, color);
- string text = PageData[p].AbilityData[s].cooldowntext;
- RECT rect;
- SetRect(&rect, px, py, px + PageData[p].AbilityData[s].h, py + PageData[p].AbilityData[s].w);
- float sfx = PageData[p].AbilityData[s].cooldownscale;
- float sfy = PageData[p].AbilityData[s].cooldownscale;
- RECT rect2, shad1, shad2;
- SetRect(&rect2, rect.left * sfx, rect.top * sfy, rect.right * sfx, rect.bottom * sfy);
- SetRect(&shad1, rect.left * sfx - 1, rect.top * sfy - 1, rect.right * sfx - 1, rect.bottom * sfy - 1);
- SetRect(&shad2, rect.left * sfx + 1, rect.top * sfy + 1, rect.right * sfx + 1, rect.bottom * sfy + 1);
- D3DXMatrixScaling(&S, 1.0f / sfx, 1.0f / sfy, 0.0f);
- sprite->SetTransform(&S);
- PageData[p].AbilityData[s].font->DrawTextA(sprite, text.c_str(), -1, &shad1, DT_NOCLIP | DT_CENTER | DT_VCENTER, color2);
- PageData[p].AbilityData[s].font->DrawTextA(sprite, text.c_str(), -1, &shad2, DT_NOCLIP | DT_CENTER | DT_VCENTER, color2);
- PageData[p].AbilityData[s].font->DrawTextA(sprite, text.c_str(), -1, &rect2, DT_NOCLIP | DT_CENTER | DT_VCENTER, color);
- sprite->SetTransform(&P);
- }
- //DrawRect(ex, ey, ew, eh, 2.0f, D3DCOLOR_ARGB(255, 255, 255, 255), false, false, 0.0f, D3DCOLOR_ARGB(255, 255, 255, 255));
- sprite->End();
- return pEndScene(pDevice);
- }
- bool runonce = true;
- void MyTick2()
- {
- if (!gRunThreads)
- return;
- __int64 gCurTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
- if (!pPlayerController)
- return;
- if (!pPlayerController->Agent)
- return;
- if (!World)
- {
- MODULEINFO miGame = TFLHACKT00LS::GetModuleInfo(NULL);
- TheWorld = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)TheWorld_Pattern, (char*)TheWorld_Mask) + TheWorld_Offset);
- World = *(UWorld**)TheWorld;
- mEngine = (UMarvelGameEngine*)GetInstanceOf(UMarvelGameEngine::StaticClass());
- }
- mHUD = pPlayerController->Agent->getMarvelHUD();
- gMouseX = (mHUD->eventGetMouseCoordinates(true).X) / (mHUD->viewportResolution.X / mHUD->uiResolution.X);
- gMouseY = (mHUD->eventGetMouseCoordinates(true).Y) / (mHUD->viewportResolution.Y / mHUD->uiResolution.Y);
- string ownerid = to_hex(pPlayerController->GetCurrentAvatarId().A);
- wchar_t favaid[5000];
- swprintf_s(favaid, L"%S", ownerid.c_str());
- r_mousepos = mHUD->m_gameUI->GetGFxMousePos();
- FVector2D mousepos;
- mousepos.X = r_mousepos.X - ((mHUD->viewportResolution.X - mHUD->uiResolution.X) / 2.0f);
- mousepos.Y = r_mousepos.Y - ((mHUD->viewportResolution.Y - mHUD->uiResolution.Y) / 2.0f);
- t_mousepos = mousepos;
- if (runonce)
- {
- pPlayerController->SetCurrentAvatarAbilitySet(0);
- currentpage = 0;
- runonce = false;
- }
- UGFxObject* activePowers = mHUD->m_gameUI->PowerPanel->GetObjectW(FSTRING("activePowers"), UGFxObject::StaticClass());
- for (int i = 0; i < 8; i++)
- {
- UGFxObject* power = activePowers->GetElementObject(i, UGFxObject::StaticClass());
- UGFxObject* icon_mc = power->GetObjectW(FSTRING("icon_mc"), UGFxObject::StaticClass());
- string iconname = to_string(icon_mc->GetString(FSTRING("_source")).Data);
- boost::replace_all(iconname, "img://MarvelUIIcons.", "");
- if (iconname != PageData[currentpage].AbilityData[i].icon)
- PageData[currentpage].AbilityData[i].textureloaded = false;
- PageData[currentpage].AbilityData[i].icon = iconname;
- PageData[currentpage].AbilityData[i].slot = i;
- PageData[currentpage].AbilityData[i].offcooldown = gCurTime + pPlayerController->GetAbilityCooldownTime(i).timeRemainingMS;
- }
- for (int p = 0; p < 3; p++)
- for (int i = 0; i < 8; i++)
- {
- double cooldowntime = PageData[p].AbilityData[i].offcooldown - gCurTime;
- if (cooldowntime < 0) cooldowntime = 0;
- PageData[p].AbilityData[i].cooldown = cooldowntime / 1000;
- if (cooldowntime >= 60000)
- {
- int cd = PageData[p].AbilityData[i].offcooldown - gCurTime;
- int m = (cd % (1000 * 60 * 60)) / (1000 * 60);
- int s = ((cd % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
- char buffer[5000];
- if (s < 10)
- sprintf_s(buffer, "%d:0%d", m,s);
- else
- sprintf_s(buffer, "%d:%d", m, s);
- PageData[p].AbilityData[i].cooldowntext = buffer;
- PageData[p].AbilityData[i].cooldownscale = 3.0f;
- }
- else if (cooldowntime > 0)
- {
- char buffer[5000];
- sprintf_s(buffer, "%.1f", PageData[p].AbilityData[i].cooldown);
- PageData[p].AbilityData[i].cooldowntext = buffer;
- PageData[p].AbilityData[i].cooldownscale = 2.5f;
- }
- else
- PageData[p].AbilityData[i].cooldowntext = "";
- }
- for (int wp = 0; wp < mHUD->m_gameUI->ManagerMC->m_panels.Count; wp++)
- {
- string PanelName = mHUD->m_gameUI->ManagerMC->m_panels(wp)->PanelName.GetName();
- if (boost::iequals(PanelName, "PowerPanel"))
- if (mHUD->m_gameUI->ManagerMC->m_panels(wp)->GetDisplayInfo().Visible)
- {
- //FASDisplayInfo test = mHUD->m_gameUI->ManagerMC->m_panels(wp)->GetDisplayInfo();
- //test.Visible = false;
- //mHUD->m_gameUI->ManagerMC->m_panels(wp)->SetDisplayInfo(test);
- }
- }
- if (GetAsyncKeyState(VK_CONTROL))
- if (World)
- if (World->Levels.Data)
- if (World->Levels.Data[0]->Actors.Data)
- for (int i = 0; i < World->Levels.Data[0]->Actors.Count; i++)
- { // start for loop
- AMarvelItem* Item = Cast<AMarvelItem>(World->Levels.Data[0]->Actors(i));
- if (Item)
- {
- UMarvelCommonTypes_FEntityId id;
- Item->GetEntityId(&id);
- FTooltipData test = mHUD->m_gameUI->GetTooltipForEntity(id, 1, id);
- test.bTopMost = true;
- if (Item->eventIsMousedOver())
- {
- Item->eventShowTooltip(test, true);
- break;
- }
- else
- Item->eventHideTooltip(true);
- }
- }
- mHUD->m_gameUI->PlayerHUDPanel->ActionScriptVoid(FSTRING("clearPanelPositioningMembers"));
- FString TempMember = { L"PlaceMouseCenter", wcslen(L"PlaceMouseCenter") + 1, wcslen(L"PlaceMouseCenter") + 1 };
- TArray<FASValue> TempArgs;
- FASValue TempV;
- TempV.Type = AS_Null;
- TempArgs.Add(TempV);
- TempArgs.Data[0].S = { L"", 0 ,0 };
- TempArgs.Data[0].Type = AS_Boolean;
- TempArgs.Data[0].N = 0;
- TempArgs.Data[0].I = 0;
- TempArgs.Data[0].B = false;
- UGFxObject* expbar = mHUD->m_gameUI->PlayerHUDPanel->GetObjectW(FSTRING("alternateExperienceBarFilled_mc"), UGFxObject::StaticClass());
- expbar->Invoke(TempMember, TempArgs);
- expbar->ActionScriptVoid(FSTRING("clearPanelPositioningMembers"));
- mHUD->m_gameUI->TooltipInWorldPanel->CallSwapDepths(99499);
- FASDisplayInfo test = mHUD->m_gameUI->TooltipInWorldPanel->GetDisplayInfo();
- test.Alpha = 200.0f;
- mHUD->m_gameUI->TooltipInWorldPanel->SetDisplayInfo(test);
- if (GetAsyncKeyState(VK_NUMPAD1))
- {
- float hp, hpmax;
- pPlayerController->Agent->GetEntityHealthAndMax(&hp, &hpmax);
- //WriteLogFile(str(format("\nCurrent HP = %1%/%2%") % hp % hpmax));
- float mana1, mana1max, mana2, mana2max;
- pPlayerController->Agent->GetEntityEnduranceAndMax(1, &mana1, &mana1max);
- pPlayerController->Agent->GetEntityEnduranceAndMax(0, &mana2, &mana2max);
- //WriteLogFile(str(format("\nCurrent Mana = %1%/%2% %3%/%4%") % mana1 % mana1max % mana2 % mana2max));
- Sleep(100);
- UGFxObject* expbar2 = mHUD->m_gameUI->PlayerHUDPanel->GetObjectW(FSTRING("alternateExperienceBarFilled_mc"), UGFxObject::StaticClass());
- //SpitInt(expbar2, "maxValue");
- //SpitInt(expbar2, "currentValue");
- for (int x = 0; x < mHUD->m_gameUI->PanelConfigData.Count; x++)
- {
- string panelname = to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_PanelName.Data);
- WriteLogFile("\nPanel = ");
- WriteLogFile(panelname);
- if (boost::icontains(panelname, "PlayerHudPanel"))
- {
- WriteLogFile(str(format("\n Panel Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_PanelName.Data)));
- WriteLogFile(str(format("\n Target Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_TargetName.Data)));
- WriteLogFile(str(format("\n Scale Mode = %1%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_ScaleMode));
- WriteLogFile(str(format("\n Stretched = %1%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_Stretched));
- WriteLogFile(str(format("\n Source Pins = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_SourceAttachmentPin.X % mHUD->m_gameUI->PanelConfigData.Data[x].PC_SourceAttachmentPin.Y));
- WriteLogFile(str(format("\n Target Pins = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TargetAttachmentPin.X % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TargetAttachmentPin.Y));
- WriteLogFile(str(format("\n PC_VirtualPixelOffset = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_VirtualPixelOffset.X % mHUD->m_gameUI->PanelConfigData.Data[x].PC_VirtualPixelOffset.Y));
- WriteLogFile(str(format("\n PC_TopLeftStretchPin = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TopLeftStretchPin.PA_XVal % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TopLeftStretchPin.PA_YVal));
- WriteLogFile(str(format("\n PC_PreferredLane Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_PreferredLane.Data)));
- WriteLogFile(str(format("\n Widget Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_WidgetClass.Data)));
- WriteLogFile(str(format("\n SWF Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_SWFName.Data)));
- //struct FPanelAnchor PC_BottomRightStretchPin; // 0x0058 (0x0020) [0x0000000000500000] ( CPF_NeedCtorLink )
- //TArray< struct FPanelConfig > PC_ChildPanelConfigs; // 0x0078 (0x000C) [0x0000000000500000] ( CPF_NeedCtorLink )
- //unsigned long PC_OpenOnStart : 1; // 0x009C (0x0004) [0x0000000000000000] [0x00000001]
- //unsigned long PC_VisibilityToggleable : 1; // 0x009C (0x0004) [0x0000000000000000] [0x00000002]
- //unsigned long PC_CanClickThrough : 1; // 0x009C (0x0004) [0x0000000000000000] [0x00000004]
- //unsigned long PC_EntityInteractPanel : 1; // 0x009C (0x0004) [0x0000000000000000] [0x00000008]
- //unsigned long PC_UseNewPlacementSystem : 1; // 0x009C (0x0004) [0x0000000000000000] [0x00000010]
- //struct FVector2D PC_OuterEdgePin; // 0x00AC (0x0008) [0x0000000000000000]
- //struct FVector2D PC_NewSourceAttachmentPin; // 0x00B4 (0x0008) [0x0000000000000000]
- //int PC_SortDepth; // 0x00BC (0x0004) [0x0000000000000000]
- //struct FPanelOpenData initOpenData;
- WriteLogFile("\nChild Count = ");
- WriteLogFile(mHUD->m_gameUI->PanelConfigData.Data[x].PC_ChildPanelConfigs.Count);
- }
- }
- }
- return;
- }
- void MyDebug(char *name)
- {
- WriteLogFile(name);
- WriteLogFile("\n");
- }
- void UpdatePowers(AMarvelHUD_eventSlottedPower_Parms* pParms)
- {
- int x = pParms->powerData.powerSlot;
- //if (x == 1) x = 8;
- //if (x == 0) x = 1;
- AbilityDetails[x] = pParms->powerData;
- }
- void SetSecondaryResource(AMarvelHUD_eventSetAvatarSecondaryResourceGauge_Parms* pParms)
- {
- gPlayerSecondaryCurrent = pParms->val;
- gPlayerSecondaryMax = pParms->MaxVal;
- }
- void PrintingSpecPower(UMarvelGFxGameUI_execToggleSpecializationPower_Parms* pParms)
- {
- WriteLogFile("\n-=--=- Activated Specialization --- ");
- WriteLogFile(pParms->PowerPrototypeId.Data);
- }
- void ChangeCurrentPage(AMarvelPlayerController_execSetCurrentAvatarAbilitySet_Parms* pParms)
- {
- currentpage = pParms->abilitySetIndex;
- }
- void TestFunction(UMarvelGFxGameUI_execOnContextMenuButtonClick_Parms* pParms)
- {
- WriteLogFile("\nClick");
- WriteLogFile(pParms->interactionMethods.A);
- WriteLogFile(" , ");
- WriteLogFile(pParms->interactionMethods.B);
- WriteLogFile("\nButton = ");
- WriteLogFile(pParms->buttonIndex);
- }
- void TestFunction2(AMarvelHUD_eventDrawMiniMapPOIs_Parms* pParms)
- {
- WriteLogFile("\nDrawing - ");
- WriteLogFile(pParms->miniMapPOIs.Count);
- }
- void TestFunction3(AMarvelHUD_eventSetAvatarExperience_Parms* pParms)
- {
- WriteLogFile("\n-------------------------------");
- WriteLogFile(str(format("\nAvatar ID = %1%") % pParms->avatarId.A));
- WriteLogFile(str(format("\nMax Level = %1%") % pParms->bMaxLevel));
- WriteLogFile(str(format("\nExperience = %1%") % to_string(pParms->experience.Data)));
- WriteLogFile(str(format("\nMax Exp = %1%") % to_string(pParms->maxExp.Data)));
- WriteLogFile(str(format("\nMin Exp = %1%\n\n") % to_string(pParms->minExp.Data)));
- }
- VOID WINAPI DispatchFunction()
- {
- if (pUFunc == NULL)
- return;
- strcpy_s(FunctionName, pUFunc->GetFullName());
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelGameViewportClient.GameSessionEnded") && gBotState == BS_READY)
- {
- gBotState = BS_LOGGING_OUT;
- gEnabledPing = false;
- pPlayerController = nullptr;
- mHUD = nullptr;
- World = nullptr;
- gDebugUI = false;
- Wait(10000);
- if (gRunning)
- {
- Wait(60000);
- gLoginTimer = gCurTime + 60000;
- gLoginCount = 0;
- WriteLogFile(str(format("\n%1%MHBuddy was running and I'm dced, I'll try to relog.") % TimeStampStr()));
- gNeedReconnecting = true;
- gShouldRelog = true;
- gRunning = false;
- }
- else
- {
- WriteLogFile(str(format("\n%1%MHBuddy was NOT running and I'm dced, I will not try to relog.") % TimeStampStr()));
- gShouldRelog = false;
- }
- return;
- }
- if (gRunThreads) // Stops everything safely if we attempt to uninject the dll
- {
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelGFxGameUI.IncrementAvatarAbilitySet") || !strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.IncrementAvatarAbilitySet"))
- {
- currentpage++;
- if (currentpage == 3)
- currentpage = 0;
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelGFxGameUI.DecrementAvatarAbilitySet") || !strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.DecrementAvatarAbilitySet"))
- {
- currentpage--;
- if (currentpage == -1)
- currentpage = 2;
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.SetCurrentAvatarAbilitySet"))
- {
- ChangeCurrentPage((AMarvelPlayerController_execSetCurrentAvatarAbilitySet_Parms*)pParms);
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.PossessAgent"))
- {
- World = nullptr;
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelHUD.SetAvatarSecondaryResourceGauge"))
- {
- SetSecondaryResource((AMarvelHUD_eventSetAvatarSecondaryResourceGauge_Parms*)pParms);
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelHUD.SlottedPower"))
- {
- UpdatePowers((AMarvelHUD_eventSlottedPower_Parms*)pParms);
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelGameViewportClient.PostRender"))
- {
- if (gRender)
- MyRender2(((UMarvelGameViewportClient_eventPostRender_Parms*)pParms)->Canvas);
- }
- if (!strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.PlayerTick"))
- {
- pPlayerController = (AMarvelPlayerController*)pCallObject;
- if (pPlayerController)
- {
- MyTick2();
- }
- }
- }
- }
- VOID __declspec(naked) ProxyFunction()
- {
- __asm
- {
- mov pCallObject, ecx
- push edx
- mov edx, dword ptr[esp + 0x8]
- mov pUFunc, edx
- mov edx, dword ptr[esp + 0xC]
- mov pParms, edx
- pop edx
- pushfd
- pushad
- }
- DispatchFunction();
- __asm
- {
- popad
- popfd
- jmp[dwOldProcessEvent]
- }
- }
- #pragma region All Hooking DLL Functions
- void GameHook()
- {
- AbilityDetails.clear();
- AbilityDetails.resize(9);
- PageData.clear();
- PageData.resize(3);
- for (unsigned i = 0; i < PageData.size(); i++)
- {
- PageData[i].AbilityData.clear();
- PageData[i].AbilityData.resize(8);
- }
- LoadConfig();
- dwProcessEvent = TFLHACKT00LS::FindPattern((DWORD)GetModuleHandle(nullptr), 0xbac000, reinterpret_cast<PBYTE>(ProcessEvent_Pattern), ProcessEvent_Mask);
- dwOldProcessEvent = (DWORD)DetourFunction((BYTE *)dwProcessEvent, (BYTE *)ProxyFunction);
- Wait(10000);
- DWORD VTable[3] = { 0 };
- DX_Init(VTable);
- DWORD EndSceneaddy = VTable[ES];
- //dwOldEndScene = (DWORD)DetourFunction((BYTE *)EndSceneaddy, (BYTE *)hkEndScene);
- //pEndScene = (EndScene_t)dwOldEndScene;
- }
- void OnUnload(HMODULE hModule)
- {
- while (true)
- {
- if ((GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_PAUSE)) || !gRunThreads)
- {
- WriteLogFile("\nUAW\n");
- Sleep(500);
- gRunThreads = false;
- Sleep(250);
- /*for (int p = 0; p < 3; p++)
- for (int s = 0; s < 8; s++)
- {
- if (PageData[p].AbilityData[s].texture) PageData[p].AbilityData[s].texture->Release();
- if (PageData[p].AbilityData[s].font) PageData[p].AbilityData[s].font->Release();
- }
- sprite->Release(); */
- Sleep(500);
- if (dwOldEndScene)
- DetourRemove(reinterpret_cast<PBYTE>(dwOldEndScene), reinterpret_cast<PBYTE>(hkEndScene));
- Sleep(2000);
- DetourRemove(reinterpret_cast<PBYTE>(dwOldProcessEvent), reinterpret_cast<PBYTE>(ProxyFunction));
- Sleep(100);
- // unload
- FreeLibraryAndExitThread(hModule, 0);
- // exit this thread
- ExitThread(0);
- }
- Sleep(100); // check it every second
- }
- }
- void LogFileExport(HMODULE hModule)
- {
- char DllPath2[512]; // prev 260
- GetModuleFileNameA((HINSTANCE)&__ImageBase, DllPath2, _countof(DllPath2));
- string path(DllPath2);
- path = path.substr(0, (path.find_last_of("\\")) + 1);
- path.append("logfile.txt");
- ofstream ofs;
- ofs.open(path, ofstream::out | ofstream::trunc);
- ofs.close();
- while (gRunThreads)
- {
- if (!PendingLogFile.empty())
- {
- int logsize = (int)PendingLogFile.size();
- ofs.open(path, ofstream::out | ofstream::app);
- if (ofs.is_open())
- {
- for (int i = 0; i < logsize; i++)
- {
- ofs << PendingLogFile[i];
- }
- PendingLogFile.erase(PendingLogFile.begin(), PendingLogFile.begin() + logsize);
- ofs.close();
- }
- }
- Sleep(25);
- }
- // exit this thread
- }
- BOOL CALLBACK EnumWindowsProcMy(HWND hwnd, LPARAM lParam)
- {
- DWORD lpdwProcessId;
- GetWindowThreadProcessId(hwnd, &lpdwProcessId);
- if (lpdwProcessId == lParam)
- {
- char NewName[256];
- GetWindowTextA(hwnd, NewName, 256);
- MHhwnd = hwnd;
- if (boost::icontains(NewName, "Marvel Heroes 2015") || boost::icontains(NewName, "Marvel Heroes 2016"))
- return FALSE;
- else
- return TRUE;
- }
- return TRUE;
- }
- void OnAttach(HMODULE hModule)
- {
- DisableThreadLibraryCalls(hModule);
- srand((unsigned)time(0));
- CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OnUnload, hModule, 0, NULL);
- CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LogFileExport, hModule, 0, NULL);
- GetModuleFileNameA((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
- string path(DllPath);
- path = path.substr(0, (path.find_last_of("\\")) + 1);
- BasePath = path + "Icons\\";
- WriteLogFile("\nBase Path = ");
- WriteLogFile(BasePath);
- path.append("LogFile.txt");
- pFileName = path;
- remove(pFileName.c_str());
- EnumWindows(EnumWindowsProcMy, GetCurrentProcessId());
- GameHook();
- }
- void DX_Init(DWORD* table)
- {
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"DX", NULL };
- RegisterClassEx(&wc);
- HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL);
- LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION);
- D3DPRESENT_PARAMETERS d3dpp;
- ZeroMemory(&d3dpp, sizeof(d3dpp));
- d3dpp.Windowed = TRUE;
- d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
- d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
- LPDIRECT3DDEVICE9 pd3dDevice;
- pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice);
- DWORD* pVTable = (DWORD*)pd3dDevice;
- pVTable = (DWORD*)pVTable[0];
- table[ES] = pVTable[42]; //EndScene address
- table[DIP] = pVTable[82]; //DrawIndexedPrimitive address
- table[RES] = pVTable[16]; //Reset address
- DestroyWindow(hWnd);
- UnregisterClassA("DX", wc.hInstance);
- pD3D->Release();
- }
- // DLL ATTACH
- BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- DefFunc();
- //CreateThread(0, 0, LoopFunction, 0, 0, 0);
- //CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LoopFunction, hModule, 0, NULL);
- CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OnAttach, hModule, 0, NULL);
- return true;
- }
- }
- #pragma endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement