#pragma once #include #include #include #include #include #include #include #include #include #include "rapidjson/writer.h" #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" #include #include "LoggerService.h" #include "ClientDTO.h" namespace Memory { static uint64_t base_addr = 0; static uint64_t ScanOffset = 0; static uint64_t RegionStart = 0; ////////////////// Scanner.cpp ////////////////// uint64_t PatternScan(std::vector signature, uint64_t baseAddr, int region = 0, uint64_t regionOffset = 0, bool Multiple = false, bool multipleRegions = false, uint64_t regionMaxOffset = 0); uint64_t TryPatternScan(std::vector signature, uint64_t baseAddr, int region = 0, uint64_t regionOffset = 0, bool Multiple = false, bool multipleRegions = false, uint64_t regionMaxOffset = 0, int retries = 0, std::string flagName = ""); std::vector PatternScanMultiple(std::vector signature, uint64_t baseAddr, int region = 0, uint64_t regionOffset = 0, bool multipleRegions = false, uint64_t regionMaxOffset = 0, int expectedValues = 0); uint64_t findRegionBaseAddress(uint64_t baseAddr, int region); ////////////////// ReadCemu.cpp ////////////////// typedef void* (*memory_getBaseType)(); uint64_t getBaseAddress(); DWORD read_memory(uint64_t Addr, const char* caller = ""); int swap_Endian(int number); std::vector read_bytes(uint64_t Addr, int bytes = 1, const char* caller = ""); float read_bigEndianFloat(uint64_t Addr, const char* caller = ""); int read_bigEndian4Bytes(uint64_t Addr, const char* caller = ""); int read_bigEndian4BytesOffset(uint64_t Addr, const char* caller = ""); std::string read_string(uint64_t Addr, int bytes = 50, const char* caller = ""); void write_bigEndianFloat(uint64_t Addr, float value, const char* caller = ""); void write_bigEndian4Bytes(uint64_t Addr, int value, const char* caller = ""); void write_byte(uint64_t Addr, BYTE byte, const char* caller = ""); void write_bytes(uint64_t Addr, std::vector bytes, const char* caller = ""); void write_string(uint64_t Addr, std::string string, int bytes = 0, const char* caller = ""); std::vector getNop(int length); std::string hexStr(std::vector data); std::string extractLocName(uint64_t Addr, int bytes = 50); bool CompareSignatures(std::vector First, std::vector Second, std::vector WildCards = { } ); uint64_t ReadPointers(uint64_t InitialAddress, std::vector readingOffsets, bool IncludeBaseAddress = false); void ValidateAddress(uint64_t address); ////////////////// CharacterClasses.cpp ////////////////// class World_class { public: float WorldTime = 0; int WorldDay = 0; uint64_t timeAddr; uint64_t dayAddr; void UpdateTime(); void SetWorldTime(float serverTime, int serverDay); std::string GetTime(); std::string GetDay(); std::string to_string_precision(float number, int precision); }; class Link_class { public: float Position[3]; float Speed[3] = { 0, 0, 0 }; float Rotation; int Animation; int Health; float atkup; int def; int IsEquipped; std::string Map; std::string Section; std::string Town; std::vector Equipment; std::map lastEquipment; rapidjson::Document WeaponDamages; uint64_t PosAddr; uint64_t RotAddr; uint64_t SpdAddr; uint64_t HealthAddr; uint64_t AnimAddr; uint64_t locationAddr; uint64_t townAddr; uint64_t porchAddr; uint64_t equippedAddr; uint64_t atkupAddr; uint64_t defAddr; uint64_t EqAddr; DWORD lastHealthUpdate; DWORD lastHealthReduce; void UpdatePosition(); void UpdateRotation(); void UpdateSpeed(); void UpdateAnimation(); void UpdateLocation(); int UpdateHealth(); void UpdateAtkDef(); std::vector ScanData(); int UpdateData(); void UpdatePlayerEquipment(); void UpdateIsEquipped(); void reduceHealth(int healthToReduce); rapidjson::Document readWeaponDamages(); std::map GetPosition(); std::string GetRotation(); std::string GetAnimation(); std::map GetSpeed(); std::map GetLocation(); std::string GetHealth(); std::map GetEquipment(); std::string GetAtkUp(); std::string GetDef(); std::string GetIsEquipped(); std::string GetDataString(); std::string to_string_precision(float number, int precision); void Teleport(float newPosition[3]); }; class Bomb { public: std::string BombType; uint64_t BaseAddress; float Pos[3]; int BombIndex; bool Exploded; bool Exists; //Bomb(std::string bombType, float initialPos[3]); void SetData(std::string bombType, float initialPos[3]); void UpdatePos(float newPosition[3]); private: uint64_t FindPosAddr(); bool RequestCreate(); }; class OtherPlayer_class { public: std::shared_mutex WeaponChangeMutex; bool WeaponChanged; unsigned int BaseAddress; uint64_t LeftHandWeapon; uint64_t RightHandWeapon; std::vector ArmorAddresses = {0, 0, 0, 0 ,0}; float Pos[3]; float Rot[3]; int isEquipped; uint64_t PosAddr; uint64_t RotAddr; uint64_t GlyphAddr; uint64_t baseAnimationAddr; uint64_t deleteAddr; uint64_t existsAddr; uint64_t isEqAddr; uint64_t NameAddr; uint64_t DisplayNameAddr; int counter; bool firstTime = TRUE; int playerNumber; bool glyphSync = FALSE; std::map UserBombs = { {"RemoteBomb", new Bomb()}, {"RemoteBomb2", new Bomb()}, {"RemoteBombCube", new Bomb()}, {"RemoteBombCube2", new Bomb()}}; std::vector multiplier_animation = { 1, 12, 23, 34, 45, 56, 67, 78, 88, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 87 }; std::vector multiplier_schedule = { 1, 8, 9, 10, 11, 12, 13, 14, 15, 2, 3, 4, 5, 6, 7 }; uint64_t lastSchedule = 0; uint64_t lastAnimation = 0; bool doAnimationSync = true; bool exists = false; std::map Equipment; DWORD attackTimer; float AttkUp; int Health; std::string Name; std::vector PosPoint = {0, 0, 0}; OtherPlayer_class(int PlayerNumber); uint64_t FindPosAddr(); void ClearPointers(); void FindWeapons(); void FindArmor(); void ClearWeapons(); void SetWeapons(); void SetArmor(); bool checkExists(); int spawnAction(std::vector local, std::vector server, bool shouldExist, bool isPrint); void setGlyphAddr(uint64_t GAddr); uint64_t ScanData(uint64_t offset); void setGlyph(float Position[3]); void setPosition(float Position[3]); void setRotation(float Rotation); void setAnimation(int Schedule, int Animation); std::vector findWeaponAddr(); void deleteActor(); void changeData(rapidjson::Value& playerData, float time, float coords[]); bool changeEq(rapidjson::Value& playerData); void setIsEquipped(int IsEquipped); void restartAnimations(); void changeName(std::string Name, int DisplayName); }; ////////////////// QuestSync.cpp ////////////////// class Quests_class { struct Quest { std::string Type; std::string Name; uint64_t Address; BYTE Value; bool beingChanged = false; bool changed = false; void updateValue() { if (beingChanged) return; BYTE newValue = Memory::read_bytes(this->Address, 1, __FUNCTION__)[0]; if (Type == "L" && Value == 0 && newValue > 0x00) changed = true; else if (newValue != Value && (newValue == 0x1 || newValue == 0x17 || newValue == 0x03)) changed = true; if (beingChanged) return; Value = newValue; } }; public: std::map QuestList; std::map numberOfQuests; std::vector changedQuests; int totalQuests = 0; std::vector questsToChange; uint64_t addingKorokAddress; uint64_t addingBoolAddress; uint64_t addingIntAddress; uint64_t addingItemAddress; uint64_t IsGetPlayerStole2Address; uint64_t DungeonClearCounterAddress; int koroksToAdd = 0; uint64_t boolFlagAddress; uint64_t intFlagAddress; uint64_t itemFlagAddress; std::vector boolsToChange; std::vector intsToChange; std::vector itemsToAdd; std::vector serverQuests; std::shared_mutex QuestMutex; bool (*IsPaused)(); rapidjson::Document readQuestFlags(); void scanQuestMemory(std::vector QuestsToSync); void readQuests(); void setup(std::vector questServerSettings, bool (*isPausedMethod)()); std::vector getChangedQuests(); DTO::QuestDTO* getQuestDTO(); bool updateQuests(bool eventStatus); void findAddingAddresses(uint64_t offset); void changeFlag(); void findBoolFlagToChange(); void findIntFlagToChange(); void findItemFlagToChange(); void resyncQuests(); std::string findQuest(std::string QuestName); }; ////////////////// multiplayerQuest.cpp ////////////////// static uint64_t pingAddress; static class MultiplayerQuest { public: static std::vector findMQuests(uint64_t offset); static void startMQuest(std::vector questsAddr); static void changeMQuestSvName(std::string serverName, uint64_t offset); static void changeMQuestPing(int ping); static void findMQuestPingAddress(uint64_t offset); static void changeMultiplayerQuestStatus(uint64_t addr, bool status); }; ////////////////// BombSyncer.cpp ////////////////// class BombSyncer { public: std::map Bombs; std::shared_mutex BombMutex; std::shared_mutex BombExplodeMutex; std::vector> BombAvailableAddresses = { {}, {}, {}, {} }; std::shared_mutex OtherPlayerBombsMutex; std::vector BombsToExplode = {}; std::vector BombsToClear = {}; void FindBombs(); uint64_t FindBombPosAddr(uint64_t baseAddr); std::tuple, std::vector, std::vector> GetBombPositions(); std::string to_string_precision(float number, int precision); }; static uint64_t MessageQuestAddr; static uint64_t MessageStringAddr; static DWORD LastMessageTime = -1; static std::vector MessageQueue = {}; ////////////////// MessagerService.cpp ////////////////// static class MessagerService { public: static void StartMessagerService(); static void DisplayMessage(); static void AddMessage(std::string Message); }; }