From ab5b730e51a1448ab60b81016e39e8978220a65e Mon Sep 17 00:00:00 2001 From: CallowBlack Date: Thu, 19 May 2022 00:36:24 +0300 Subject: [PATCH 1/5] partially fix bug with line in character window bug can still occur if you change `No fog` checkbox to false while being in character window --- cheat-library/src/user/cheat/visuals/NoFog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cheat-library/src/user/cheat/visuals/NoFog.cpp b/cheat-library/src/user/cheat/visuals/NoFog.cpp index 82ac880..5f7bd4e 100644 --- a/cheat-library/src/user/cheat/visuals/NoFog.cpp +++ b/cheat-library/src/user/cheat/visuals/NoFog.cpp @@ -6,6 +6,7 @@ namespace cheat::feature { + static bool _prevEnabledState = false; NoFog::NoFog() : Feature(), NFEX(f_Enabled, "No Fog", "NoFog", "Visuals", false, false) { @@ -41,7 +42,11 @@ namespace cheat::feature void NoFog::OnGameUpdate() { - app::RenderSettings_set_fog(nullptr, !f_Enabled, nullptr); + if (_prevEnabledState != f_Enabled) + { + app::RenderSettings_set_fog(nullptr, !f_Enabled, nullptr); + _prevEnabledState = f_Enabled; + } } } From 4cab1e0d49b723c4dd4469ddb5afaed64af9bb68 Mon Sep 17 00:00:00 2001 From: RyujinZX Date: Thu, 26 May 2022 03:59:23 +0300 Subject: [PATCH 2/5] upd ryujin Update CD Reduce Update NoClip Add Show Chest Add Auto Cook --- cheat-library/cheat-library.vcxproj | 4 + cheat-library/cheat-library.vcxproj.filters | 12 + cheat-library/src/appdata/il2cpp-functions.h | 25 +- cheat-library/src/appdata/il2cpp-types.h | 256 ++++++++++++++++++ cheat-library/src/user/cheat/cheat.cpp | 6 +- cheat-library/src/user/cheat/player/NoCD.cpp | 36 ++- cheat-library/src/user/cheat/player/NoCD.h | 2 +- .../src/user/cheat/player/NoClip.cpp | 18 +- cheat-library/src/user/cheat/player/NoClip.h | 2 + .../user/cheat/visuals/ShowChestIndicator.cpp | 56 ++++ .../user/cheat/visuals/ShowChestIndicator.h | 25 ++ .../src/user/cheat/world/AutoCook.cpp | 107 ++++++++ cheat-library/src/user/cheat/world/AutoCook.h | 30 ++ 13 files changed, 558 insertions(+), 21 deletions(-) create mode 100644 cheat-library/src/user/cheat/visuals/ShowChestIndicator.cpp create mode 100644 cheat-library/src/user/cheat/visuals/ShowChestIndicator.h create mode 100644 cheat-library/src/user/cheat/world/AutoCook.cpp create mode 100644 cheat-library/src/user/cheat/world/AutoCook.h diff --git a/cheat-library/cheat-library.vcxproj b/cheat-library/cheat-library.vcxproj index 938c611..51a0a01 100644 --- a/cheat-library/cheat-library.vcxproj +++ b/cheat-library/cheat-library.vcxproj @@ -48,6 +48,8 @@ + + @@ -151,6 +153,8 @@ + + diff --git a/cheat-library/cheat-library.vcxproj.filters b/cheat-library/cheat-library.vcxproj.filters index 3403490..2520e7f 100644 --- a/cheat-library/cheat-library.vcxproj.filters +++ b/cheat-library/cheat-library.vcxproj.filters @@ -216,6 +216,12 @@ Header Files + + Header Files + + + Header Files + @@ -390,6 +396,12 @@ Source Files + + Source Files + + + Source Files + diff --git a/cheat-library/src/appdata/il2cpp-functions.h b/cheat-library/src/appdata/il2cpp-functions.h index 9be9d3a..5e20a3b 100644 --- a/cheat-library/src/appdata/il2cpp-functions.h +++ b/cheat-library/src/appdata/il2cpp-functions.h @@ -12,7 +12,7 @@ DO_APP_FUNC(0x013815E0, void, InLevelMapPageContext_OnMarkClicked, (InLevelMapPa DO_APP_FUNC(0x01390800, void, InLevelMapPageContext_OnMapClicked, (InLevelMapPageContext* __this, Vector2 screenPos, MethodInfo* method)); DO_APP_FUNC(0x0158AD40, bool, MapModule_IsAreaUnlock, (MBHLOBDPKEC* __this, uint32_t sceneID, uint32_t areaID, MethodInfo* method)); DO_APP_FUNC(0x05036C50, uint16_t, SimpleSafeUInt16_get_Value, (void* __this, LAFKDOLNGNA rawValue, MethodInfo* method)); - +DO_APP_FUNC(0x03427B90, uint32_t, SimpleSafeUInt32_get_Value, (void* __this, app::SimpleSafeUInt32 rawValue, MethodInfo* method)); // Map utility DO_APP_FUNC(0x04339D30, Rect, MonoInLevelMapPage_get_mapRect, (MonoInLevelMapPage* __this, MethodInfo* method)); @@ -42,9 +42,10 @@ DO_APP_FUNC(0x015E1C90, bool, Miscs_CheckTargetAttackable, (void* __this, BaseEn // Cooldown cheats DO_APP_FUNC(0x024D5450, bool, HumanoidMoveFSM_CheckSprintCooldown, (/* HumanoidMoveFSM */void* __this, MethodInfo* method)); DO_APP_FUNC(0x02548810, bool, LCAvatarCombat_IsEnergyMax, (void* __this, MethodInfo* method)); -DO_APP_FUNC(0x02546C10, bool, LCAvatarCombat_IsSkillInCD_1, (void* __this, void* skillInfo, MethodInfo* method)); DO_APP_FUNC(0x0254A170, void, LCAvatarCombat_ChangeEnergy_1, (LCAvatarCombat* __this, ElementType__Enum type, float value, DataPropOp__Enum state, MethodInfo* method)); DO_APP_FUNC(0x0254D660, bool, LCAvatarCombat_OnSkillStart, (LCAvatarCombat* __this, uint32_t skillID, float cdMultipler, MethodInfo* method)); +DO_APP_FUNC(0x02546C10, bool, LCAvatarCombat_IsSkillInCD_1, (LCAvatarCombat* __this, LCAvatarCombat_OMIIMOJOHIP* skillInfo, MethodInfo* method)); + DO_APP_FUNC(0x0112A110, void, ActorAbilityPlugin_AddDynamicFloatWithRange, (void* __this, String* key, float value, float min, float max, bool forceDoAtRemote, MethodInfo* method)); // Rapid fire @@ -123,9 +124,20 @@ DO_APP_FUNC(0x036B8AA0, void, FishingModule_OnExitFishingRsp, (void* __this, voi DO_APP_FUNC(0x036BB0B0, void, FishingModule_onFishChosenNotify, (void* __this, void* notify, MethodInfo* method)); -// Camera +// Visuals DO_APP_FUNC(0x0289DE30, void, SCameraModuleInitialize_SetWarningLocateRatio, (SCameraModuleInitialize* __this, double deltaTime, CameraShareData* data, MethodInfo* method)); +// Chest Indicator | RyujinZX#6666 +DO_APP_FUNC(0x0487E1D0, bool, LCIndicatorPlugin_DoCheck, (LCIndicatorPlugin* __this, MethodInfo* method)); +DO_APP_FUNC(0x0487F680, void, LCIndicatorPlugin_ShowIcon, (LCIndicatorPlugin* __this, MethodInfo* method)); +DO_APP_FUNC(0x0487CBF0, void, LCIndicatorPlugin_HideIcon, (LCIndicatorPlugin* __this, MethodInfo* method)); + +// Auto Cooking | RyujinZX#6666 +DO_APP_FUNC(0x01B91500, void, PlayerModule_RequestPlayerCook, (PlayerModule* __this, uint32_t recipeId, uint32_t avatarId, uint32_t qteQuality, uint32_t count, MethodInfo* method)); +DO_APP_FUNC(0x01B9E8F0, void, PlayerModule_OnPlayerCookRsp, (PlayerModule* __this, PlayerCookRsp* rsp, MethodInfo* method)); +DO_APP_FUNC(0x030E1000, void, CookingQtePageContext_UpdateProficiency, (CookingQtePageContext* __this, MethodInfo* method)); +DO_APP_FUNC(0x03AA2920, uint32_t, CookRecipeExcelConfig_get_maxProficiency, (CookRecipeExcelConfig* __this, MethodInfo* method)); + // Utility DO_APP_FUNC(0x015DD910, float, Miscs_CalcCurrentGroundWaterHeight, (void* __this, float x, float z, MethodInfo* method)); @@ -146,6 +158,7 @@ DO_APP_FUNC(0x014C88B0, void, ActorUtils_SyncAvatarMotion, (void* __this, int DO_APP_FUNC(0x02ECCFE0, Notify, Notify_CreateNotify_1, (void* __this, AJAPIFPNFKP__Enum type, Object* body, MethodInfo* method)); DO_APP_FUNC(0x04D3A960, float, SafeFloat_GetValue, (void* __this, SafeFloat safeFloat, MethodInfo* method)); +DO_APP_FUNC(0x04D3A770, SafeFloat, SafeFloat_SetValue, (void* __this, float value, MethodInfo* method)); DO_APP_FUNC(0x01645B20, void, Entity_SetPosition, (BaseEntity* __this, Vector3 position, bool someBool, MethodInfo* method)); DO_APP_FUNC(0x05102970, LCBaseCombat*, BaseEntity_GetBaseCombat, (BaseEntity* __this, MethodInfo* method)); @@ -176,7 +189,9 @@ DO_APP_FUNC(0x01560F70, List_1_MoleMole_BaseEntity_*, EntityManager_GetEntities, DO_APP_FUNC(0x05D07B50, Bounds, Utils_1_GetBounds, (void* __this, GameObject* go, MethodInfo* method)); -DO_APP_FUNC(0x024E0BA0, void, HumanoidMoveFSM_LateTick, (void* __this, float deltaTime, MethodInfo* method)); +// Modify | RyujinZX#6666 +DO_APP_FUNC(0x024E0BA0, void, HumanoidMoveFSM_LateTick, (app::HumanoidMoveFSM* __this, float deltaTime, MethodInfo* method)); + DO_APP_FUNC(0x03511760, bool, ScenePropManager_GetTreeTypeByPattern, (ScenePropManager* __this, String* pattern, ECGLPBEEEAA__Enum* treeType, MethodInfo* method)); DO_APP_FUNC(0x01997D90, void, NetworkManager_1_RequestHitTreeDropNotify, (NetworkManager_1* __this, Vector3 position, Vector3 hitPostion, ECGLPBEEEAA__Enum treeType, MethodInfo* method)); @@ -184,7 +199,7 @@ DO_APP_FUNC(0x0332CD30, uint64_t, GetTimestamp, (void* __this, MethodInfo* metho DO_APP_FUNC(0x017F43F0, bool, LoadingManager_IsLoaded, (LoadingManager* __this, MethodInfo* method)); -// Thanks to @RyujinZX +// Thanks to | RyujinZX DO_APP_FUNC(0x019C5D50, void, LCAbilityElement_ReduceModifierDurability, (LCAbilityElement* __this, int32_t modifierDurabilityIndex, float reduceDurability, Nullable_1_Single_ deltaTime, MethodInfo* method)); DO_APP_FUNC(0x035D8B70, BaseEntity*, GadgetEntity_GetOwnerEntity, (GadgetEntity* __this, MethodInfo* method)); diff --git a/cheat-library/src/appdata/il2cpp-types.h b/cheat-library/src/appdata/il2cpp-types.h index 38023b8..fbcceae 100644 --- a/cheat-library/src/appdata/il2cpp-types.h +++ b/cheat-library/src/appdata/il2cpp-types.h @@ -10435,6 +10435,37 @@ namespace app { struct LCCharacterCombat__Fields fields; }; + struct __declspec(align(8)) LCAvatarCombat_OMIIMOJOHIP__Fields { + uint32_t skillID; + struct AvatarSkillExcelConfig* config; + struct SafeFloat cdTimer; + struct SafeFloat currChargeCount; + struct SafeFloat costStamina; + bool canHold; + bool canTrigger; + bool useInAir; + struct HashSet_1_System_Int32_* canUseSkillStateWhiteList; + int32_t needMonitor; + bool isLocked; + bool ignoreCDMinusRatio; + bool forceCanDoSkill; + struct SafeFloat NFNMNLKPNHD; + struct SafeFloat EBIABBHAFFD; + struct SafeFloat HPDKMHFJFMI; + struct SafeFloat IBKPGNDMDBJ; + struct SafeFloat GBGBNALDDFM; + int32_t skillIndex; + int32_t prority; + float _costElem_k__BackingField; + int32_t _maxChargeCount_k__BackingField; + }; + + struct LCAvatarCombat_OMIIMOJOHIP { + struct LCAvatarCombat_OMIIMOJOHIP__Class* klass; + MonitorData* monitor; + struct LCAvatarCombat_OMIIMOJOHIP__Fields fields; + }; + struct LCAvatarCombat__Fields { struct LCCharacterCombat__Fields _; struct EntityTimer* _targetAtteTimer; @@ -10517,6 +10548,76 @@ namespace app { }; #endif + + struct HumanoidMoveFSM__Fields { + struct BaseComponentPlugin__Fields _; + struct HumanoidMoveFSMBaseMoveState* _curState; + int32_t fallOnGroundFirstFrame; + struct Dictionary_2_MoleMole_HumanoidMoveFSM_JJLCCKKCHPD_MoleMole_HumanoidMoveFSMBaseMoveState_* stateMapInfo; + struct VCHumanoidMoveData* _moveData; + struct VCHumanoidMoveConfig* _moveConfig; + struct VCHumanoidMove* _ownerMove; + struct Animator* _animator; + struct Rigidbody* _rigidbody; + struct AnimatorController* _animatorController; + void* OnMoveUpdateCallback; + void* OnAirUpdateCallback; + bool _initSyncWithCurrentTask; + bool _behaviourSet; + float _sendCombatNotifyTime; + bool enterSprintBS; + bool _positionRotationChanged_k__BackingField; + struct Transform* _transform; + struct Vector3 lateTickStartPosition; + struct Quaternion lateTickStartRotation; + int32_t _layerMaskScene; + int32_t _layerMaskDynamicBarrier; + int32_t layerMaskDynamicBarrierCheckAuthority; + bool ignoreOverallMoveWallProtectionCurrentFrame; + bool stopMoveWhenGoupstairs; + bool lastStopMoveWhenGoupstairs; + float climbGlobalRecovery; + bool autoGoUpstair; + bool forceDoNotSyncWhenReset; + float inSprintTime; + int32_t _lastCurrentStateHash; + int32_t _lastNextStateHash; + bool _firstLatetick; + bool _lastInForbiddenToggleMoveState; + bool _disableMotion4hiUpdateCurrentFrame; + int32_t _flyStateHash; + struct VCMoveIKController* _ikComp; + struct Transform* _lCalf; + struct Transform* _rCalf; + void* _weaponStandbyIKParams; + void* _normalStandbyIKParams; + void* _params; + float _lastSkirtBlendParam; + float _idealSkirtBlendParam; + float _lastIdealSkirtBlendParam; + float _lastSkirtWeight; + float _idealSkirtWeight; + float _lastSkirtPos; + float _idealSkirtPos; + void* _lastFrameAnimSpeedInfo; + void* _currentFrameAnimSpeedInfo; + bool _isInSprintCheckInterval; + bool _isInMuteSprintInterval; + float _timeAfterLastSprint; + uint32_t _lastFrameVelocityCheckBits; + bool _lastFrameVelocityCheckResult; + bool _remoteCheckLightCoreMove; + struct Vector3 _remoteCheckLightCoreMoveTarget; + }; + + struct HumanoidMoveFSM { + struct HumanoidMoveFSM__Class* klass; + MonitorData* monitor; + struct HumanoidMoveFSM__Fields fields; + }; + + + struct SCameraModuleInitialize__VTable { VirtualInvokeData Equals; VirtualInvokeData Finalize; @@ -10829,6 +10930,161 @@ namespace app { struct Nullable_1_Double_ _overrideMinElevation; }; + struct LCIndicatorPlugin__Fields { + struct BaseComponentPlugin__Fields _; + void* _timeCheckConditionKeys; + void* allConditions; + void* _owner; + bool unknow; + void* _levelGadget; + struct GadgetDataItem* _dataItem; + void* _tempLateData; + void* _configIndicator; + void* indicatorDominators; + bool _isIndicatorShow; + void* _checkTimer; + }; + + struct LCIndicatorPlugin { + struct LCIndicatorPlugin__Class* klass; + MonitorData* monitor; + struct LCIndicatorPlugin__Fields fields; + }; + + struct PlayerCookRsp__Fields { + struct MessageBase_1__Fields _; + int32_t retcode_; + struct CookRecipeData_1* recipeData_; + void* itemList_; + uint32_t qteQuality_; + uint32_t cookCount_; + void* extralItemList_; + }; + + struct PlayerCookRsp { + struct PlayerCookRsp__Class* klass; + MonitorData* monitor; + struct PlayerCookRsp__Fields fields; + }; + + struct MonoCookingQTEPage__Fields { + struct MonoUIProxy__Fields _; + struct MonoElementSwitch* _elementSwitch; + struct Transform* _cookNeedRoot; + struct GameObject* _addInfo; + struct Text* _addDescText; + struct GameObject* _iconState; + struct Transform__Array* _foodPanel; + struct MonoUIContainer* _makeBtn; + struct MonoUIContainer* _autoMakeBtn; + struct MonoUIContainer* _returnBtn; + struct GameObject* _qtePanel; + struct GameObject* _manualQteRoot; + struct GameObject* _autoQteRoot; + struct MonoCookGotPanel* _cookGotPanel; + struct Button* _endBtn; + struct RectTransform* _goodAreaTrans; + struct SmoothMask* _goodAreaFill; + struct RectTransform* _perfectAreaTrans; + struct SmoothMask* _perfectAreaFill; + struct RectTransform* _pointerTrans; + float _qteTime; + float _autoQteTime; + float _starQteDelay; + struct GameObject* _selectNumberRoot; + struct GameObject* _grpProficiency; + struct Text* _proficiencyText; + struct MonoUIContainer* _replaceBtn; + struct MonoBagProxySlot* _curRecipeItemSlot; + struct Text* _curRecipeFoodNum; + struct GameObject* _grpResult; + struct GameObject* _bonusAdditionalInfoIcon; + struct Text* _additionalInfoText; + struct GameObject* _grpJoypadButtons; + struct GameObject* _bagSlotPrefab; + struct List_1_MoleMole_MonoItemSlot_* _cookNeedList; + struct MonoCookAvatarSelect* _avatarPanel; + struct MonoAvatarIcon* _avatarIcon; + struct Transform* _avatarIconRoot; + }; + + struct MonoCookingQTEPage { + struct MonoCookingQTEPage__Class* klass; + MonitorData* monitor; + struct MonoCookingQTEPage__Fields fields; + }; + + struct CookingQtePageContext__Fields { + struct BasePageContext__Fields _; + struct MonoCookingQTEPage* _pageMono; + uint32_t _recipeId; + uint32_t _avatarId; + float _goodRangeStart; + float _goodRangeEnd; + float _perfectRangeStart; + float _perfectRangeEnd; + bool _qteStart; + float _qteTime; + float _qteBonusRange; + bool _isAuto; + int32_t _foodKind; + uint32_t _oldProficiency; + uint32_t _newProficiency; + uint32_t _maxProficiency; + uint32_t _curProficiency; + bool _upProficiencyStart; + float _upProficiencyTime; + bool _focusOnNeedItem; + int32_t _needItemIndex; + bool canAutoCook; + struct List_1_MoleMole_SimpleItemStruct_* _itemGotList; + bool _isAvatarPanelOpen; + uint32_t _toSelectAvatarId; + int32_t _toSelectAvatarIndex; + struct List_1_System_UInt32_* _avatarList; + }; + + struct CookingQtePageContext { + struct CookingQtePageContext__Class* klass; + MonitorData* monitor; + struct CookingQtePageContext__Fields fields; + }; + + struct CookRecipeData_1__Fields { + struct MessageBase_1__Fields _; + uint32_t recipeId_; + uint32_t proficiency_; + }; + + struct CookRecipeData_1 { + struct CookRecipeData_1__Class* klass; + MonitorData* monitor; + struct CookRecipeData_1__Fields fields; + }; + + struct __declspec(align(8)) CookRecipeExcelConfig__Fields { + struct SimpleSafeUInt32 idRawNum; + uint32_t _nameTextMapHash; + struct SimpleSafeUInt32 rankLevelRawNum; + struct String* _icon; + uint32_t _descTextMapHash; + struct UInt32__Array* _effectDesc; + int32_t _foodType; + int32_t _cookMethod; + bool _isDefaultUnlocked; + SimpleSafeUInt32 maxProficiencyRawNum; + struct IdCountConfig__Array* _qualityOutputVec; + struct IdCountConfig__Array* _inputVec; + struct String* _qteParam; + struct SimpleSafeUInt32__Array* _qteQualityWeightVec; + }; + + struct CookRecipeExcelConfig { + struct CookRecipeExcelConfig__Class* klass; + MonitorData* monitor; + struct CookRecipeExcelConfig__Fields fields; + }; + #if !defined(_GHIDRA_) && !defined(_IDA_) } #endif diff --git a/cheat-library/src/user/cheat/cheat.cpp b/cheat-library/src/user/cheat/cheat.cpp index 3b27994..4feb490 100644 --- a/cheat-library/src/user/cheat/cheat.cpp +++ b/cheat-library/src/user/cheat/cheat.cpp @@ -36,10 +36,12 @@ #include #include +#include #include #include #include +#include #include "GenshinCM.h" @@ -88,10 +90,12 @@ namespace cheat FEAT_INST(InteractiveMap), FEAT_INST(AutoFish), + FEAT_INST(AutoCook), FEAT_INST(NoFog), FEAT_INST(FPSUnlock), - FEAT_INST(CameraZoom) + FEAT_INST(CameraZoom), + FEAT_INST(ChestIndicator) }); #undef FEAT_INST diff --git a/cheat-library/src/user/cheat/player/NoCD.cpp b/cheat-library/src/user/cheat/player/NoCD.cpp index 2a09635..448e1a1 100644 --- a/cheat-library/src/user/cheat/player/NoCD.cpp +++ b/cheat-library/src/user/cheat/player/NoCD.cpp @@ -9,6 +9,8 @@ namespace cheat::feature static bool HumanoidMoveFSM_CheckSprintCooldown_Hook(void* __this, MethodInfo* method); static bool LCAvatarCombat_IsEnergyMax_Hook(void* __this, MethodInfo* method); static bool LCAvatarCombat_OnSkillStart(app::LCAvatarCombat* __this, uint32_t skillID, float cdMultipler, MethodInfo* method); + static bool LCAvatarCombat_IsSkillInCD_1(app::LCAvatarCombat* __this, app::LCAvatarCombat_OMIIMOJOHIP* skillInfo, MethodInfo* method); + static void ActorAbilityPlugin_AddDynamicFloatWithRange_Hook(void* __this, app::String* key, float value, float minValue, float maxValue, bool forceDoAtRemote, MethodInfo* method); @@ -16,15 +18,13 @@ namespace cheat::feature NoCD::NoCD() : Feature(), NF(f_AbilityReduce, "Reduce Skill/Burst Cooldown", "NoCD", false), - NF(f_AbilityReduceValue, "Reduce skill CD value", "NoCD", 0.1f), - + NF(f_TimerReduce, "Reduce Timer", "NoCD", 1.f), NF(f_UtimateMaxEnergy, "Burst max energy", "NoCD", false), NF(f_Sprint, "No Sprint Cooldown", "NoCD", false), NF(f_InstantBow, "Instant bow", "NoCD", false) - { HookManager::install(app::LCAvatarCombat_IsEnergyMax, LCAvatarCombat_IsEnergyMax_Hook); - HookManager::install(app::LCAvatarCombat_OnSkillStart, LCAvatarCombat_OnSkillStart); + HookManager::install(app::LCAvatarCombat_IsSkillInCD_1, LCAvatarCombat_IsSkillInCD_1); HookManager::install(app::HumanoidMoveFSM_CheckSprintCooldown, HumanoidMoveFSM_CheckSprintCooldown_Hook); HookManager::install(app::ActorAbilityPlugin_AddDynamicFloatWithRange, ActorAbilityPlugin_AddDynamicFloatWithRange_Hook); @@ -44,9 +44,9 @@ namespace cheat::feature "(Energy bubble may appear incomplete but still usable.)"); ConfigWidget("## AbilityReduce", f_AbilityReduce); ImGui::SameLine(); - ConfigWidget("Reduce Skill/Burst Cooldown", f_AbilityReduceValue, 0.1f, 0.2f, 1.0f, + ConfigWidget("Reduce Skill/Burst Cooldown", f_TimerReduce, 1.f, 1.f, 6.0f, "Reduce cooldowns of elemental skills and bursts.\n"\ - "The greater the value, the greater the cooldown."); + "The current value is the maximum value of the cooldown."); ConfigWidget(f_Sprint, "Removes delay in-between sprints."); @@ -86,7 +86,7 @@ namespace cheat::feature void NoCD::DrawStatus() { ImGui::Text("Cooldown\n[%s%s%s%s%s]", - f_AbilityReduce ? fmt::format("Reduce {:.1f}", f_AbilityReduceValue.value()).c_str() : "", + f_AbilityReduce ? fmt::format("Reduce {:.1f}", f_TimerReduce.value()).c_str() : "", f_AbilityReduce && (f_InstantBow || f_Sprint) ? "|" : "", f_InstantBow ? "Bow" : "", f_InstantBow && f_Sprint ? "|" : "", @@ -108,21 +108,37 @@ namespace cheat::feature return CALL_ORIGIN(LCAvatarCombat_IsEnergyMax_Hook, __this, method); } - // Multipler CoolDown Timer | RyujinZX#6666 + // Multipler CoolDown Timer Old | RyujinZX#6666 static bool LCAvatarCombat_OnSkillStart(app::LCAvatarCombat* __this, uint32_t skillID, float cdMultipler, MethodInfo* method) { NoCD& noCD = NoCD::GetInstance(); if (noCD.f_AbilityReduce) { if (__this->fields._targetFixTimer->fields._._timer_k__BackingField > 0) { - cdMultipler = noCD.f_AbilityReduceValue / 3; + cdMultipler = noCD.f_TimerReduce / 3; } else { - cdMultipler = noCD.f_AbilityReduceValue / 1; + cdMultipler = noCD.f_TimerReduce / 1; } } return CALL_ORIGIN(LCAvatarCombat_OnSkillStart, __this, skillID, cdMultipler, method); } + // Timer Speed Up / CoolDown Reduce New | RyujinZX#6666 + static bool LCAvatarCombat_IsSkillInCD_1(app::LCAvatarCombat* __this, app::LCAvatarCombat_OMIIMOJOHIP* skillInfo, MethodInfo* method) { + NoCD& noCD = NoCD::GetInstance(); + if (noCD.f_AbilityReduce) + { + auto cdTimer = app::SafeFloat_GetValue(nullptr, skillInfo->fields.cdTimer, nullptr); + + if (cdTimer > noCD.f_TimerReduce) + { + struct app::SafeFloat MyValueProtect = app::SafeFloat_SetValue(nullptr, noCD.f_TimerReduce - 1, nullptr); + skillInfo->fields.cdTimer = MyValueProtect; + } + } + return CALL_ORIGIN(LCAvatarCombat_IsSkillInCD_1, __this, skillInfo, method); + } + // Check sprint cooldown, we just return true if sprint no cooldown enabled. static bool HumanoidMoveFSM_CheckSprintCooldown_Hook(void* __this, MethodInfo* method) { diff --git a/cheat-library/src/user/cheat/player/NoCD.h b/cheat-library/src/user/cheat/player/NoCD.h index 0565056..d296da9 100644 --- a/cheat-library/src/user/cheat/player/NoCD.h +++ b/cheat-library/src/user/cheat/player/NoCD.h @@ -8,7 +8,7 @@ namespace cheat::feature { public: config::Field> f_AbilityReduce; - config::Field f_AbilityReduceValue; + config::Field f_TimerReduce; config::Field> f_UtimateMaxEnergy; config::Field> f_Sprint; diff --git a/cheat-library/src/user/cheat/player/NoClip.cpp b/cheat-library/src/user/cheat/player/NoClip.cpp index b2eb1ea..cb41200 100644 --- a/cheat-library/src/user/cheat/player/NoClip.cpp +++ b/cheat-library/src/user/cheat/player/NoClip.cpp @@ -9,11 +9,12 @@ namespace cheat::feature { - static void HumanoidMoveFSM_LateTick_Hook(void* __this, float deltaTime, MethodInfo* method); + static void HumanoidMoveFSM_LateTick_Hook(app::HumanoidMoveFSM* __this, float deltaTime, MethodInfo* method); app::Vector3 zero; NoClip::NoClip() : Feature(), NF(f_Enabled, "No clip", "NoClip", false), + NF(f_NoAnimation, "No Animation", "NoClip", false), NF(f_Speed, "Speed", "NoClip", 5.5f), NF(f_CameraRelative, "Relative to camera", "NoClip", true), NF(f_VelocityMode, "Velocity mode", "NoClip", false), @@ -38,6 +39,8 @@ namespace cheat::feature ConfigWidget("Enabled", f_Enabled, "Enables no-clip (fast speed + no collision).\n" \ "To move, use WASD, Space (go up), and Shift (go down)."); + ConfigWidget("No Animation", f_NoAnimation, "Disables player animations."); + ConfigWidget("Speed", f_Speed, 0.1f, 2.0f, 100.0f, "No-clip move speed.\n" \ "Not recommended setting above 5.0."); @@ -210,11 +213,18 @@ namespace cheat::feature // Disabling standard motion performing. // This disabling any animations, climb, jump, swim and so on. // But when it disabled, MoveSync sending our last position, so needs to update position in packet. - static void HumanoidMoveFSM_LateTick_Hook(void* __this, float deltaTime, MethodInfo* method) + static void HumanoidMoveFSM_LateTick_Hook(app::HumanoidMoveFSM* __this, float deltaTime, MethodInfo* method) { NoClip& noClip = NoClip::GetInstance(); - if (noClip.f_Enabled) - return; + + if (noClip.f_Enabled) { + if (!noClip.f_NoAnimation) { + __this->fields._layerMaskScene = 2; + } + else { + return; + } + } CALL_ORIGIN(HumanoidMoveFSM_LateTick_Hook, __this, deltaTime, method); } diff --git a/cheat-library/src/user/cheat/player/NoClip.h b/cheat-library/src/user/cheat/player/NoClip.h index 250872a..ecfc01d 100644 --- a/cheat-library/src/user/cheat/player/NoClip.h +++ b/cheat-library/src/user/cheat/player/NoClip.h @@ -11,6 +11,8 @@ namespace cheat::feature { public: config::Field> f_Enabled; + config::Field> f_NoAnimation; + config::Field f_Speed; config::Field f_CameraRelative; config::Field> f_VelocityMode; diff --git a/cheat-library/src/user/cheat/visuals/ShowChestIndicator.cpp b/cheat-library/src/user/cheat/visuals/ShowChestIndicator.cpp new file mode 100644 index 0000000..45e1bcd --- /dev/null +++ b/cheat-library/src/user/cheat/visuals/ShowChestIndicator.cpp @@ -0,0 +1,56 @@ +#include "pch-il2cpp.h" +#include "ShowChestIndicator.h" + +#include +#include + +namespace cheat::feature +{ + static bool IndicatorPlugin_DoCheck(app::LCIndicatorPlugin* __this, MethodInfo* method); + + ChestIndicator::ChestIndicator() : Feature(), + NF(f_Enabled, "Show Chest Indicator", "ShowChest", false) + { + HookManager::install(app::LCIndicatorPlugin_DoCheck, IndicatorPlugin_DoCheck); + } + + const FeatureGUIInfo& ChestIndicator::GetGUIInfo() const + { + static const FeatureGUIInfo info{ "ShowChest", "Visuals", false }; + return info; + } + + void ChestIndicator::DrawMain() + { + ConfigWidget(f_Enabled, "Show chests, game mechanics."); + } + + bool ChestIndicator::NeedStatusDraw() const + { + return f_Enabled; + } + + void ChestIndicator::DrawStatus() + { + ImGui::Text("Chest Indicator"); + } + + ChestIndicator& ChestIndicator::GetInstance() + { + static ChestIndicator instance; + return instance; + } + + static bool IndicatorPlugin_DoCheck(app::LCIndicatorPlugin* __this, MethodInfo* method) { + ChestIndicator& chestIndicator = ChestIndicator::GetInstance(); + if (chestIndicator.f_Enabled) + { + if (__this->fields._dataItem != nullptr) + { + // Base Chest not found, try improve + app::LCIndicatorPlugin_ShowIcon(__this, nullptr); + } + } + return CALL_ORIGIN(IndicatorPlugin_DoCheck, __this, method); + } +} \ No newline at end of file diff --git a/cheat-library/src/user/cheat/visuals/ShowChestIndicator.h b/cheat-library/src/user/cheat/visuals/ShowChestIndicator.h new file mode 100644 index 0000000..389706f --- /dev/null +++ b/cheat-library/src/user/cheat/visuals/ShowChestIndicator.h @@ -0,0 +1,25 @@ +#pragma once +#include +#include + +namespace cheat::feature +{ + + class ChestIndicator : public Feature + { + public: + config::Field> f_Enabled; + + static ChestIndicator& GetInstance(); + + const FeatureGUIInfo& GetGUIInfo() const override; + void DrawMain() override; + + virtual bool NeedStatusDraw() const override; + void DrawStatus() override; + + private: + ChestIndicator(); + }; +} + diff --git a/cheat-library/src/user/cheat/world/AutoCook.cpp b/cheat-library/src/user/cheat/world/AutoCook.cpp new file mode 100644 index 0000000..e61864e --- /dev/null +++ b/cheat-library/src/user/cheat/world/AutoCook.cpp @@ -0,0 +1,107 @@ +#include "pch-il2cpp.h" +#include "AutoCook.h" + +#include +#include + +namespace cheat::feature +{ + static void PlayerModule_RequestPlayerCook(app::PlayerModule* __this, uint32_t recipeId, uint32_t avatarId, uint32_t qteQuality, uint32_t count, MethodInfo* method); + static void PlayerModule_OnPlayerCookRsp(app::PlayerModule* __this, app::PlayerCookRsp* rsp, MethodInfo* method); + + static void CookingQtePageContext_UpdateProficiency(app::CookingQtePageContext* __this, MethodInfo* method); + static void CookingQtePageContext_SetProficiencyInfo(app::CookingQtePageContext* __this, MethodInfo* method); + static uint32_t CookRecipeExcelConfig_get_maxProficiency(app::CookRecipeExcelConfig* __this, MethodInfo* method); + + AutoCook::AutoCook() : Feature(), + NF(f_Enabled, "Auto Cooking", "AutoCook", false), + NF(f_Count, "Count Item", "AutoCook", 1), + NF(f_Quality, "Quality", "AutoCook", 1) + { + HookManager::install(app::PlayerModule_RequestPlayerCook, PlayerModule_RequestPlayerCook); + HookManager::install(app::PlayerModule_OnPlayerCookRsp, PlayerModule_OnPlayerCookRsp); + HookManager::install(app::CookingQtePageContext_UpdateProficiency, CookingQtePageContext_UpdateProficiency); + HookManager::install(app::CookRecipeExcelConfig_get_maxProficiency, CookRecipeExcelConfig_get_maxProficiency); + } + + const FeatureGUIInfo& AutoCook::GetGUIInfo() const + { + static const FeatureGUIInfo info{ "AutoCook", "World", true }; + return info; + } + + void AutoCook::DrawMain() + { + ConfigWidget(f_Enabled, "Automatic cooking."); + ConfigWidget("Count Item", f_Count, 1, 1, 100, + "How much to cook at a time.\n" \ + "(If the recipe is not fully explored, set it to 1.)"); + ConfigWidget("Quality Cooking", f_Quality, 1, 1, 3, "Quality of the cook."); + } + + bool AutoCook::NeedStatusDraw() const + { + return f_Enabled; + } + + void AutoCook::DrawStatus() + { + ImGui::Text("Auto Cook"); + } + + AutoCook& AutoCook::GetInstance() + { + static AutoCook instance; + return instance; + } + + // Auto Cooking | RyujinZX#6666 + + static void PlayerModule_RequestPlayerCook(app::PlayerModule* __this, uint32_t recipeId, uint32_t avatarId, uint32_t qteQuality, uint32_t count, MethodInfo* method) + { + AutoCook& autoCook = AutoCook::GetInstance(); + if (autoCook.f_Enabled) + { + qteQuality = autoCook.f_Quality; + count = autoCook.f_Count; + } + + return CALL_ORIGIN(PlayerModule_RequestPlayerCook, __this, recipeId, avatarId, qteQuality, count, method); + } + + static void PlayerModule_OnPlayerCookRsp(app::PlayerModule* __this, app::PlayerCookRsp* rsp, MethodInfo* method) { + AutoCook& autoCook = AutoCook::GetInstance(); + if (autoCook.f_Enabled) + { + rsp->fields.qteQuality_ = autoCook.f_Quality; + rsp->fields.cookCount_ = autoCook.f_Count; + + // Unlock Quick Cooking, It will reset after a restart, so it is better to study the recipe in full at once. + if (rsp->fields.recipeData_ != nullptr) + rsp->fields.recipeData_->fields.proficiency_ = autoCook.CookCount; + } + + return CALL_ORIGIN(PlayerModule_OnPlayerCookRsp, __this, rsp, method); + } + + static void CookingQtePageContext_UpdateProficiency(app::CookingQtePageContext* __this, MethodInfo* method) { + AutoCook& autoCook = AutoCook::GetInstance(); + if (autoCook.f_Enabled) + { + __this->fields._pageMono->fields._qteTime = 0; + __this->fields._pageMono->fields._autoQteTime = 0; + } + + return CALL_ORIGIN(CookingQtePageContext_UpdateProficiency, __this, method); + } + + static uint32_t CookRecipeExcelConfig_get_maxProficiency(app::CookRecipeExcelConfig* __this, MethodInfo* method) { + AutoCook& autoCook = AutoCook::GetInstance(); + if (autoCook.f_Enabled) + { + uint32_t maxCount = app::SimpleSafeUInt32_get_Value(nullptr, __this->fields.maxProficiencyRawNum, nullptr); + autoCook.CookCount = maxCount; + } + return CALL_ORIGIN(CookRecipeExcelConfig_get_maxProficiency, __this, method); + } +} \ No newline at end of file diff --git a/cheat-library/src/user/cheat/world/AutoCook.h b/cheat-library/src/user/cheat/world/AutoCook.h new file mode 100644 index 0000000..737e3c2 --- /dev/null +++ b/cheat-library/src/user/cheat/world/AutoCook.h @@ -0,0 +1,30 @@ +#pragma once +#include +#include + +namespace cheat::feature +{ + + class AutoCook : public Feature + { + public: + config::Field> f_Enabled; + config::Field f_Count; + config::Field f_Quality; + + uint32_t CookCount; + + static AutoCook& GetInstance(); + + const FeatureGUIInfo& GetGUIInfo() const override; + void DrawMain() override; + + virtual bool NeedStatusDraw() const override; + void DrawStatus() override; + + private: + + AutoCook(); + }; +} + From e2c9c9eae3a15712dc2b812af721b9ae2eb6110a Mon Sep 17 00:00:00 2001 From: CallowBlack Date: Thu, 26 May 2022 16:15:31 +0300 Subject: [PATCH 3/5] minor changes improvement `ImGui::BeginGroupPanel` fix typos fix warnings anti-debug bypass changes (implementation is private for now) --- cheat-base/src/cheat-base/PipeTransfer.cpp | 8 +- .../src/cheat-base/cheat/CheatManagerBase.cpp | 8 +- .../src/cheat-base/cheat/misc/Settings.cpp | 32 +- .../cheat-base/config/internal/FieldBase.h | 55 +- .../src/cheat-base/render/ImageLoader.cpp | 4 +- cheat-base/src/cheat-base/render/gui-util.cpp | 514 +++++++++--------- cheat-base/src/cheat-base/render/gui-util.h | 33 +- cheat-base/src/cheat-base/render/renderer.cpp | 8 +- cheat-base/src/cheat-base/util.cpp | 15 +- cheat-base/src/cheat-base/util.h | 2 + cheat-base/vendor/imgui | 2 +- cheat-library/cheat-library.vcxproj | 10 +- cheat-library/cheat-library.vcxproj.filters | 6 + .../src/user/cheat/ILPatternScanner.h | 2 +- cheat-library/src/user/cheat/debugger.cpp | 12 + cheat-library/src/user/cheat/debugger.h | 4 + cheat-library/src/user/cheat/esp/ESP.cpp | 48 +- .../src/user/cheat/esp/ESPRender.cpp | 34 +- .../src/user/cheat/imap/InteractiveMap.cpp | 40 +- cheat-library/src/user/cheat/misc/Debug.cpp | 3 +- cheat-library/src/user/cheat/misc/Hotkeys.cpp | 4 +- .../cheat/misc/sniffer/MessageManager.cpp | 2 + .../user/cheat/misc/sniffer/PacketInfo.cpp | 2 +- .../user/cheat/misc/sniffer/PacketParser.cpp | 12 +- .../user/cheat/misc/sniffer/PacketSniffer.cpp | 4 +- .../user/cheat/misc/sniffer/ProtoManager.cpp | 2 +- .../user/cheat/misc/sniffer/SnifferWindow.cpp | 5 +- .../misc/sniffer/messages/PacketData.cpp | 8 +- .../cheat/misc/sniffer/messages/PacketData.h | 4 +- .../src/user/cheat/world/AutoLoot.cpp | 16 +- .../src/user/cheat/world/AutoTreeFarm.cpp | 2 +- .../src/user/cheat/world/MobVacuum.cpp | 8 +- cheat-library/src/user/main.cpp | 66 +-- injector/src/main.cpp | 21 +- 34 files changed, 543 insertions(+), 453 deletions(-) create mode 100644 cheat-library/src/user/cheat/debugger.cpp create mode 100644 cheat-library/src/user/cheat/debugger.h diff --git a/cheat-base/src/cheat-base/PipeTransfer.cpp b/cheat-base/src/cheat-base/PipeTransfer.cpp index e4ef042..1dfa028 100644 --- a/cheat-base/src/cheat-base/PipeTransfer.cpp +++ b/cheat-base/src/cheat-base/PipeTransfer.cpp @@ -53,8 +53,8 @@ void PipeTransfer::ReadBytes(void* buffer, size_t size) if (size == 0 || !IsPipeOpened()) return; DWORD readCount = 0; - auto result = ReadFile(m_Pipe, buffer, size, &readCount, nullptr); - if (!result || readCount < size) + auto result = ReadFile(m_Pipe, buffer, static_cast(size), &readCount, nullptr); + if (!result || static_cast(readCount) < size) { LOG_LAST_ERROR("Failed read from pipe."); CloseHandle(m_Pipe); @@ -67,8 +67,8 @@ void PipeTransfer::WriteBytes(void* buffer, size_t size) if (size == 0 || !IsPipeOpened()) return; DWORD writenCount = 0; - auto result = WriteFile(m_Pipe, buffer, size, &writenCount, nullptr); - if (!result || writenCount < size) + auto result = WriteFile(m_Pipe, buffer, static_cast(size), &writenCount, nullptr); + if (!result || static_cast(writenCount) < size) { LOG_LAST_ERROR("Failed write to pipe."); CloseHandle(m_Pipe); diff --git a/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp b/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp index aa55871..314bb7d 100644 --- a/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp +++ b/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp @@ -113,7 +113,7 @@ namespace cheat void CheatManagerBase::DrawMenuSection(const std::string& sectionName, const std::vector& features) const { if (!sectionName.empty()) - BeginGroupPanel(sectionName.c_str(), ImVec2(-1, 0)); + ImGui::BeginGroupPanel(sectionName.c_str()); for (auto& feature : features) { @@ -123,7 +123,7 @@ namespace cheat } if (!sectionName.empty()) - EndGroupPanel(); + ImGui::EndGroupPanel(); } void CheatManagerBase::DrawProfileGlobalActivities() @@ -350,7 +350,7 @@ namespace cheat if (!moduleShowAny) continue; - BeginGroupPanel(moduleName.c_str(), ImVec2(-1, 0)); + ImGui::BeginGroupPanel(moduleName.c_str()); for (auto& [sectionName, features] : sections) { @@ -365,7 +365,7 @@ namespace cheat } } - EndGroupPanel(); + ImGui::EndGroupPanel(); } ImGui::End(); diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index d44fcf0..f5d40ec 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -31,7 +31,7 @@ namespace cheat::feature NF(f_HotkeyExit, "Hotkeys", "General::FastExit", Hotkey(VK_F12)) { - renderer::SetGlobalFontSize(f_FontSize); + renderer::SetGlobalFontSize(static_cast(f_FontSize)); f_HotkeyExit.value().PressedEvent += MY_METHOD_HANDLER(Settings::OnExitKeyPressed); } @@ -44,7 +44,7 @@ namespace cheat::feature void Settings::DrawMain() { - BeginGroupPanel("General", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("General"); { ConfigWidget(f_MenuKey, false, "Key to toggle main menu visibility. Cannot be empty.\n"\ @@ -53,12 +53,12 @@ namespace cheat::feature if (ConfigWidget(f_FontSize, 1, 8, 64, "Font size for cheat interface.")) { f_FontSize = std::clamp(f_FontSize.value(), 8, 64); - renderer::SetGlobalFontSize(f_FontSize); + renderer::SetGlobalFontSize(static_cast(f_FontSize)); } } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Logging", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Logging"); { bool consoleChanged = ConfigWidget(f_ConsoleLogging, "Enable console for logging information (changes will take effect after relaunch)"); @@ -75,37 +75,37 @@ namespace cheat::feature Logger::SetLevel(Logger::Level::None, Logger::LoggerType::FileLogger); } } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Status Window", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Status Window"); { ConfigWidget(f_StatusShow); ConfigWidget(f_StatusMove, "Allow moving of 'Status' window."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Info Window", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Info Window"); { ConfigWidget(f_InfoShow); ConfigWidget(f_InfoMove, "Allow moving of 'Info' window."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("FPS indicator", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("FPS indicator"); { ConfigWidget(f_FpsShow); ConfigWidget(f_FpsMove, "Allow moving of 'FPS Indicator' window."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Show Notifications", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Show Notifications"); { ConfigWidget(f_NotificationsShow, "Notifications on the bottom-right corner of the window will be displayed."); ConfigWidget(f_NotificationsDelay, 1,1,10000, "Delay in milliseconds between notifications."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Fast Exit", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Fast Exit"); { ConfigWidget("Enabled", f_FastExitEnable, @@ -120,7 +120,7 @@ namespace cheat::feature if (!f_FastExitEnable) ImGui::EndDisabled(); } - EndGroupPanel(); + ImGui::EndGroupPanel(); } Settings& Settings::GetInstance() diff --git a/cheat-base/src/cheat-base/config/internal/FieldBase.h b/cheat-base/src/cheat-base/config/internal/FieldBase.h index a1dfe90..9c7ebfb 100644 --- a/cheat-base/src/cheat-base/config/internal/FieldBase.h +++ b/cheat-base/src/cheat-base/config/internal/FieldBase.h @@ -2,23 +2,48 @@ #include "FieldEntry.h" #include "FieldSerialize.h" +#include +#include namespace config::internal { template class FieldBase { + using _FieldBaseT = FieldBase; public: using _ValueType = T; - explicit FieldBase() : p_Container(nullptr) {} + explicit FieldBase() : p_Container(nullptr), FieldChangedEvent(m_FieldChangedEvent) {} - explicit FieldBase(FieldSerialize* serializeFieldPtr) : p_Container(serializeFieldPtr) { } + explicit FieldBase(FieldSerialize* serializeFieldPtr) : p_Container(serializeFieldPtr), FieldChangedEvent(m_FieldChangedEvent) + { + p_Container->ChangedEvent += MY_METHOD_HANDLER(_FieldBaseT::OnFieldChanged); + } - explicit FieldBase(const std::shared_ptr>& serializeField) : p_Container(serializeField) { } + explicit FieldBase(const std::shared_ptr>& serializeField) : p_Container(serializeField), FieldChangedEvent(m_FieldChangedEvent) + { + p_Container->ChangedEvent += MY_METHOD_HANDLER(_FieldBaseT::OnFieldChanged); + } explicit FieldBase(const std::string friendlyName, const std::string name, const std::string section, T defaultValue, bool multiProfile = false) - : p_Container(std::make_shared>(friendlyName, name, section, defaultValue, multiProfile)) { } + : p_Container(std::make_shared>(friendlyName, name, section, defaultValue, multiProfile)), FieldChangedEvent(m_FieldChangedEvent) + { + p_Container->ChangedEvent += MY_METHOD_HANDLER(_FieldBaseT::OnFieldChanged); + } + + explicit FieldBase(const FieldBase& field) : + p_Container(field.p_Container), + m_FieldChangedEvent(), FieldChangedEvent(m_FieldChangedEvent) + { + p_Container->ChangedEvent += MY_METHOD_HANDLER(FieldBase::OnFieldChanged); + } + + ~FieldBase() + { + if (p_Container.get() != nullptr) + p_Container->ChangedEvent -= MY_METHOD_HANDLER(FieldBase::OnFieldChanged); + } std::string name() const { @@ -89,17 +114,39 @@ namespace config::internal FieldBase& operator=(std::shared_ptr>& other) { + p_Container->ChangedEvent -= MY_METHOD_HANDLER(FieldBase::OnFieldChanged); + p_Container = other; + p_Container->ChangedEvent += MY_METHOD_HANDLER(FieldBase::OnFieldChanged); return *this; } FieldBase& operator=(FieldSerialize* other) { + p_Container->ChangedEvent -= MY_METHOD_HANDLER(FieldBase::OnFieldChanged); + p_Container = std::make_shared>(other); + p_Container->ChangedEvent += MY_METHOD_HANDLER(FieldBase::OnFieldChanged); return *this; } + FieldBase& operator=(const FieldBase& other) + { + p_Container = other.p_Container; + p_Container->ChangedEvent += MY_METHOD_HANDLER(FieldBase::OnFieldChanged); + return *this; + } + + IEvent& FieldChangedEvent; + protected: + TEvent m_FieldChangedEvent; + std::shared_ptr> p_Container; + void OnFieldChanged(FieldEntry* entry) + { + m_FieldChangedEvent(value()); + } + }; } \ No newline at end of file diff --git a/cheat-base/src/cheat-base/render/ImageLoader.cpp b/cheat-base/src/cheat-base/render/ImageLoader.cpp index 73c9e5b..13a86c7 100644 --- a/cheat-base/src/cheat-base/render/ImageLoader.cpp +++ b/cheat-base/src/cheat-base/render/ImageLoader.cpp @@ -47,8 +47,8 @@ std::optional ImageLoader::GetImage(const std::string& i return {}; } - imageData.size.x = width; - imageData.size.y = height; + imageData.size.x = static_cast(width); + imageData.size.y = static_cast(height); s_Textures[imageName] = imageData; return imageData; } \ No newline at end of file diff --git a/cheat-base/src/cheat-base/render/gui-util.cpp b/cheat-base/src/cheat-base/render/gui-util.cpp index 70150d1..cb299c0 100644 --- a/cheat-base/src/cheat-base/render/gui-util.cpp +++ b/cheat-base/src/cheat-base/render/gui-util.cpp @@ -214,256 +214,7 @@ bool ConfigWidget(config::Field>& field, const char* desc #undef ShowDesc -// https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353 -struct GroupPanelInfo -{ - ImRect labelRect; - ImRect selectRect; -}; -static ImVector s_GroupPanelLabelStack; - -bool GroupPanelIsOpen(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiStorage* storage = window->DC.StateStorage; - - return storage->GetInt(id, 1) != 0; -} - -void GroupPanelSetOpen(ImGuiID id, bool open) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiStorage* storage = window->DC.StateStorage; - - storage->SetInt(id, open ? 1 : 0); -} - -bool BeginGroupPanel(const char* name, const ImVec2& size, bool node, SelectData* selectData) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - ImGui::PushID(name); - ImGui::BeginGroup(); - auto cursorPos = ImGui::GetCursorScreenPos(); - - auto itemSpacing = ImGui::GetStyle().ItemSpacing; - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); - - auto frameHeight = ImGui::GetFrameHeight(); - ImGui::BeginGroup(); - - ImVec2 effectiveSize = size; - if (size.x < 0.0f) - effectiveSize.x = ImGui::GetContentRegionAvail().x; - else - effectiveSize.x = size.x; - ImGui::Dummy(ImVec2(effectiveSize.x, 0.0f)); - - ImVec2 startPos = window->DC.CursorPos; - ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); - ImGui::SameLine(0.0f, 0.0f); - ImGui::BeginGroup(); - ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); - ImGui::SameLine(0.0f, 0.0f); - ImGui::TextUnformatted(name); - - auto labelMin = ImGui::GetItemRectMin(); - auto labelMax = ImGui::GetItemRectMax(); - ImGui::SameLine(0.0f, 0.0f); - - ImVec2 selectMin = {}; - ImVec2 selectMax = {}; - if (selectData != nullptr) - { - bool useText = true; - const char* selectAll = "Select all"; - auto textSize = ImGui::CalcTextSize(selectAll); - auto spaceSize = ImVec2(effectiveSize.x - textSize.x - 35.0f - labelMax.x + startPos.x, 0.0f); - if (spaceSize.x <= 0) - { - spaceSize = ImVec2(effectiveSize.x - 35.0f - labelMax.x + startPos.x, 0.0f); - useText = false; - } - ImGui::Dummy(spaceSize); - ImGui::SameLine(0.0f, 0.0f); - - selectData->changed = ImGui::Checkbox(useText ? selectAll : "", &selectData->toggle); - - selectMin = ImGui::GetItemRectMin(); - selectMax = ImGui::GetItemRectMax(); - } - - ImGui::SameLine(0.0f, 0.0f); - ImGui::Dummy(ImVec2(0.0, frameHeight + itemSpacing.y)); - - if (node) - { - labelMin.x = startPos.x; - - const ImVec2 text_size = ImGui::CalcTextSize(name); - const ImGuiID id = window->GetID(name); - - bool isOpen = GroupPanelIsOpen(id); - - bool hovered; - bool toggled = ImGui::ButtonBehavior({ labelMin, labelMax }, id, &hovered, nullptr, ImGuiButtonFlags_PressedOnClick); - if (toggled) - { - isOpen = !isOpen; - GroupPanelSetOpen(id, isOpen); - } - - const ImU32 text_col = ImGui::GetColorU32(ImGuiCol_Text); - ImGui::RenderArrow(window->DrawList, { cursorPos.x, cursorPos.y + text_size.y * 0.15f }, text_col, - isOpen ? ImGuiDir_Down : ImGuiDir_Right, 0.7f); - - if (!isOpen) - { - ImGui::PopStyleVar(2); - ImGui::EndGroup(); - ImGui::EndGroup(); - ImGui::EndGroup(); - ImGui::PopID(); - return false; - } - } - - ImGui::BeginGroup(); - - //ImGui::GetWindowDrawList()->AddRect(labelMin, labelMax, IM_COL32(255, 0, 255, 255)); - - ImGui::PopStyleVar(2); - -#if IMGUI_VERSION_NUM >= 17301 - ImGui::GetCurrentWindow()->ContentRegionRect.Max.x -= frameHeight * 0.5f; - ImGui::GetCurrentWindow()->WorkRect.Max.x -= frameHeight * 0.5f; - ImGui::GetCurrentWindow()->InnerRect.Max.x -= frameHeight * 0.5f; -#else - ImGui::GetCurrentWindow()->ContentsRegionRect.Max.x -= frameHeight * 0.5f; -#endif - ImGui::GetCurrentWindow()->Size.x -= frameHeight; - - auto itemWidth = ImGui::CalcItemWidth(); - ImGui::PushItemWidth(ImMax(0.0f, itemWidth - frameHeight)); - - s_GroupPanelLabelStack.push_back({ ImRect(labelMin, labelMax) , ImRect(selectMin, selectMax)}); - - return true; -} - -void EndGroupPanel() -{ - ImGui::PopItemWidth(); - - auto itemSpacing = ImGui::GetStyle().ItemSpacing; - - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); - - auto frameHeight = ImGui::GetFrameHeight(); - - ImGui::EndGroup(); - - //ImGui::GetWindowDrawList()->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(0, 255, 0, 64), 4.0f); - - ImGui::EndGroup(); - - ImGui::SameLine(0.0f, 0.0f); - ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); - ImGui::Dummy(ImVec2(0.0, frameHeight - frameHeight * 0.5f - itemSpacing.y)); - - ImGui::EndGroup(); - - auto itemMin = ImGui::GetItemRectMin(); - auto itemMax = ImGui::GetItemRectMax(); - //ImGui::GetWindowDrawList()->AddRectFilled(itemMin, itemMax, IM_COL32(255, 0, 0, 64), 4.0f); - - auto& info = s_GroupPanelLabelStack.back(); - s_GroupPanelLabelStack.pop_back(); - - ImVec2 halfFrame = ImVec2(frameHeight * 0.25f, frameHeight) * 0.5f; - ImRect frameRect = ImRect(itemMin + halfFrame, itemMax - ImVec2(halfFrame.x, 0.0f)); - - auto& labelRect = info.labelRect; - labelRect.Min.x -= itemSpacing.x; - labelRect.Max.x += itemSpacing.x; - - bool hasSelect = info.selectRect.Min.x != 0; - - if (!hasSelect) - { - for (int i = 0; i < 3; ++i) - { - switch (i) - { - // left half-plane - case 0: ImGui::PushClipRect(ImVec2(-FLT_MAX, -FLT_MAX), ImVec2(labelRect.Min.x, FLT_MAX), true); break; - // right half-plane - case 1: ImGui::PushClipRect(ImVec2(labelRect.Max.x, -FLT_MAX), ImVec2(FLT_MAX, FLT_MAX), true); break; - // bottom - case 2: ImGui::PushClipRect(ImVec2(labelRect.Min.x, labelRect.Max.y), ImVec2(labelRect.Max.x, FLT_MAX), true); break; - } - - ImGui::GetWindowDrawList()->AddRect( - frameRect.Min, frameRect.Max, - ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)), - halfFrame.x); - - ImGui::PopClipRect(); - } - } - else - { - auto& selectRect = info.selectRect; - selectRect.Min.x -= itemSpacing.x; - selectRect.Max.x += itemSpacing.x; - for (int i = 0; i < 5; ++i) - { - switch (i) - { - // left half-plane - case 0: ImGui::PushClipRect(ImVec2(-FLT_MAX, -FLT_MAX), ImVec2(labelRect.Min.x, FLT_MAX), true); break; - // label - select - case 1: ImGui::PushClipRect(ImVec2(labelRect.Max.x, -FLT_MAX), ImVec2(selectRect.Min.x, FLT_MAX), true); break; - // bottom label - case 2: ImGui::PushClipRect(ImVec2(labelRect.Min.x, labelRect.Max.y), ImVec2(labelRect.Max.x, FLT_MAX), true); break; - // bottom select - case 3: ImGui::PushClipRect(ImVec2(selectRect.Min.x, selectRect.Max.y), ImVec2(selectRect.Max.x, FLT_MAX), true); break; - // right hand-plane - case 4: ImGui::PushClipRect(ImVec2(selectRect.Max.x, -FLT_MAX), ImVec2(FLT_MAX, FLT_MAX), true); break; - } - - ImGui::GetWindowDrawList()->AddRect( - frameRect.Min, frameRect.Max, - ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)), - halfFrame.x); - - ImGui::PopClipRect(); - } - } - - - ImGui::PopStyleVar(2); - -#if IMGUI_VERSION_NUM >= 17301 - ImGui::GetCurrentWindow()->ContentRegionRect.Max.x += frameHeight * 0.5f; - ImGui::GetCurrentWindow()->WorkRect.Max.x += frameHeight * 0.5f; - ImGui::GetCurrentWindow()->InnerRect.Max.x += frameHeight * 0.5f; -#else - ImGui::GetCurrentWindow()->ContentsRegionRect.Max.x += frameHeight * 0.5f; -#endif - ImGui::GetCurrentWindow()->Size.x += frameHeight; - - ImGui::Dummy(ImVec2(0.0f, 0.0f)); - - ImGui::EndGroup(); - ImGui::PopID(); -} void AddUnderLine(ImColor col_) { @@ -663,8 +414,8 @@ float ImGui::CalcContrastRatio(const ImU32& backgroundColor, const ImU32& foreGr float lumFG = 0.2126 * colFG.x + 0.7152 * colFG.y + 0.0722 * colFG.z; return (ImMax(lumBG, lumFG) + 0.05) / (ImMin(lumBG, lumFG) + 0.05);*/ - float sa0 = ((backgroundColor >> IM_COL32_A_SHIFT) & 0xFF); - float sa1 = ((foreGroundColor >> IM_COL32_A_SHIFT) & 0xFF); + float sa0 = static_cast((backgroundColor >> IM_COL32_A_SHIFT) & 0xFF); + float sa1 = static_cast((foreGroundColor >> IM_COL32_A_SHIFT) & 0xFF); static float sr = 0.2126f / 255.0f; static float sg = 0.7152f / 255.0f; static float sb = 0.0722f / 255.0f; @@ -738,3 +489,264 @@ bool ImGui::DrawRenamePopup(std::string& out) } return false; } + +namespace ImGui +{ + struct GroupPanelHeaderBounds + { + ImRect left; + ImRect right; + bool collapsed; + }; + + static ImVector _groupPanelStack; + + static bool GroupPanelIsOpen(ImGuiID id) + { + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiStorage* storage = window->DC.StateStorage; + + return storage->GetInt(id, 1) != 0; + } + + static void GroupPanelSetOpen(ImGuiID id, bool open) + { + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiStorage* storage = window->DC.StateStorage; + + storage->SetInt(id, open ? 1 : 0); + } + + // Modified version of: https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353 + + bool BeginGroupPanel(const char* label, bool node, const ImVec2& size) + { + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const ImGuiID id = window->GetID(label); + ImGui::PushID(id); + + auto groupPanelPos = window->DC.CursorPos; + auto itemSpacing = ImGui::GetStyle().ItemSpacing; + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); + + ImGui::BeginGroup(); // Outer group + + ImVec2 effectiveSize = size; + if (size.x < 0.0f) + effectiveSize.x = ImGui::GetContentRegionAvail().x; + else + effectiveSize.x = size.x; + + ImGui::Dummy(ImVec2(effectiveSize.x, 0.0f)); // Adjusting group x size + + auto frameHeight = ImGui::GetFrameHeight(); + ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::SameLine(0.0f, 0.0f); // Inner group spacing + ImGui::BeginGroup(); // Inner group + + ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::SameLine(0.0f, 0.0f); // Name text spacing + ImGui::TextUnformatted(label); + + ImRect leftRect = { ImGui::GetItemRectMin(), ImGui::GetItemRectMax() }; + ImVec2 rightMax = ImVec2(groupPanelPos.x + effectiveSize.x - frameHeight, leftRect.Max.y); + ImRect rightRect = { { rightMax.x, leftRect.Min.x }, rightMax }; + ImGui::SameLine(0.0f, 0.0f); + + ImGui::Dummy(ImVec2(0.0, frameHeight + itemSpacing.y)); + + if (node) + { + leftRect.Min.x = groupPanelPos.x; + + const ImVec2 text_size = ImGui::CalcTextSize(label); + bool isOpen = GroupPanelIsOpen(id); + + bool hovered; + bool toggled = ImGui::ButtonBehavior(leftRect, id, &hovered, nullptr, ImGuiButtonFlags_PressedOnClick); + if (toggled) + { + isOpen = !isOpen; + GroupPanelSetOpen(id, isOpen); + } + + const ImU32 text_col = ImGui::GetColorU32(ImGuiCol_Text); + ImGui::RenderArrow(window->DrawList, { groupPanelPos.x, groupPanelPos.y + text_size.y * 0.15f }, text_col, + isOpen ? ImGuiDir_Down : ImGuiDir_Right, 0.7f); + + if (!isOpen) + { + ImGui::PopStyleVar(2); + ImGui::EndGroup(); + ImGui::EndGroup(); + ImGui::PopID(); + + _groupPanelStack.push_back({ leftRect, rightRect, true }); + return false; + } + } + + ImGui::PopStyleVar(2); + + ImGui::GetCurrentWindow()->ContentRegionRect.Max.x -= frameHeight * 0.5f; + ImGui::GetCurrentWindow()->WorkRect.Max.x -= frameHeight * 0.5f; + ImGui::GetCurrentWindow()->InnerRect.Max.x -= frameHeight * 0.5f; + ImGui::GetCurrentWindow()->Size.x -= frameHeight; + + auto itemWidth = ImGui::CalcItemWidth(); + ImGui::PushItemWidth(ImMax(0.0f, itemWidth - frameHeight)); + + _groupPanelStack.push_back({ leftRect, rightRect, false }); + return true; + } + + void EndGroupPanel() + { + IM_ASSERT(_groupPanelStack.Size > 0); // Mismatched BeginGroupPanel()/EndGroupPanel() calls + auto& info = _groupPanelStack.back(); + _groupPanelStack.pop_back(); + + if (info.collapsed) + return; + + ImGui::PopItemWidth(); + + auto itemSpacing = ImGui::GetStyle().ItemSpacing; + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); + + ImGui::EndGroup(); // Inner group + + auto frameHeight = ImGui::GetFrameHeight(); + ImGui::SameLine(0.0f, 0.0f); + ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); + ImGui::Dummy(ImVec2(0.0, frameHeight - frameHeight * 0.5f - itemSpacing.y)); + + ImGui::EndGroup(); // Outer group + + // Outer group rect + auto itemMin = ImGui::GetItemRectMin(); + auto itemMax = ImGui::GetItemRectMax(); + + ImVec2 halfFrame = ImVec2(frameHeight * 0.25f, frameHeight) * 0.5f; + ImRect frameRect = ImRect(itemMin + halfFrame, itemMax - ImVec2(halfFrame.x, 0.0f)); + + auto& leftRect = info.left; + leftRect.Min.x -= itemSpacing.x; + leftRect.Max.x += itemSpacing.x; + + bool hasRightPart = info.right.Min.x != info.right.Max.x; + auto& rightRect = info.right; + + if (hasRightPart) + { + rightRect.Min.x -= itemSpacing.x; + rightRect.Max.x += itemSpacing.x; + } + + // Drawing rectangle + for (int i = 0; i < (hasRightPart ? 5 : 3); ++i) + { + switch (i) + { + // left half-plane + case 0: ImGui::PushClipRect(ImVec2(-FLT_MAX, -FLT_MAX), ImVec2(leftRect.Min.x, FLT_MAX), true); break; + // right half-plane + case 1: ImGui::PushClipRect(ImVec2(leftRect.Max.x, -FLT_MAX), ImVec2(hasRightPart ? rightRect.Min.x : FLT_MAX, FLT_MAX), true); break; + // bottom + case 2: ImGui::PushClipRect(ImVec2(leftRect.Min.x, leftRect.Max.y), ImVec2(leftRect.Max.x, FLT_MAX), true); break; + // bottom select + case 3: ImGui::PushClipRect(ImVec2(rightRect.Min.x, rightRect.Max.y), ImVec2(rightRect.Max.x, FLT_MAX), true); break; + // right hand-plane + case 4: ImGui::PushClipRect(ImVec2(rightRect.Max.x, -FLT_MAX), ImVec2(FLT_MAX, FLT_MAX), true); break; + } + + ImGui::GetWindowDrawList()->AddRect( + frameRect.Min, frameRect.Max, + ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)), + halfFrame.x); + + ImGui::PopClipRect(); + } + + + ImGui::PopStyleVar(2); + + // Restore content region + ImGui::GetCurrentWindow()->ContentRegionRect.Max.x += frameHeight * 0.5f; + ImGui::GetCurrentWindow()->WorkRect.Max.x += frameHeight * 0.5f; + ImGui::GetCurrentWindow()->InnerRect.Max.x += frameHeight * 0.5f; + ImGui::GetCurrentWindow()->Size.x += frameHeight; + + // Add vertical spacing + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + + ImGui::PopID(); + } + + void NextGroupPanelHeaderItem(const ImVec2& size, bool rightAlign) + { + IM_ASSERT(size.x > 0.0f); // Size should be specified + IM_ASSERT(_groupPanelStack.Size > 0); // Mismatched BeginGroupPanel()/EndGroupPanel() calls + auto& info = _groupPanelStack.back(); + + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (rightAlign) + { + if (info.right.Min.x != info.right.Max.x) + info.right.Min.x -= g.Style.ItemSpacing.x; + + info.right.Min.x -= size.x; + } + else + info.left.Max.x += g.Style.ItemSpacing.x; + + window->DC.CursorPos.x = rightAlign ? info.right.Min.x : info.left.Max.x; + window->DC.CursorPos.y = info.left.Min.y - (size.y - ImGui::GetFrameHeight() + g.Style.FramePadding.y) / 2; + + if (!rightAlign) + info.left.Max.x += size.x; + } + + bool BeginSelectableGroupPanel(const char* label, bool& value, bool& changed, bool node, const ImVec2& size, const char* selectLabel) + { + bool opened = BeginGroupPanel(label, node, size); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + const ImVec2 label_size = CalcTextSize(selectLabel, NULL, true); + const float square_sz = GetFrameHeight(); + const ImVec2 checkbox_size = ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f); + + NextGroupPanelHeaderItem(checkbox_size, true); + changed = Checkbox(selectLabel, &value); + + ImGui::PopStyleVar(); + return opened; + } + + void EndSelectableGroupPanel() + { + EndGroupPanel(); + } + + ImVec2 CalcButtonSize(const char* label) + { + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + ImVec2 size = CalcItemSize({}, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); + return size; + } +} + diff --git a/cheat-base/src/cheat-base/render/gui-util.h b/cheat-base/src/cheat-base/render/gui-util.h index 27334a7..5087039 100644 --- a/cheat-base/src/cheat-base/render/gui-util.h +++ b/cheat-base/src/cheat-base/render/gui-util.h @@ -81,16 +81,6 @@ void DrawTextWithOutline(ImDrawList* drawList, ImFont* font, float fontSize, con void DrawTextWithOutline(ImDrawList* drawList, const ImVec2& screenPos, const char* text, const ImColor& textColor, float outlineThickness = 0.0f, OutlineSide sides = OutlineSide::All, const ImColor& outlineColor = ImColor(0.0f, 0.0f, 0.0f)); - -struct SelectData -{ - bool toggle; - bool changed; -}; - -bool BeginGroupPanel(const char* name, const ImVec2& size = ImVec2(-1, 0), bool node = false, SelectData* selectData = nullptr); -void EndGroupPanel(); - namespace ImGui { bool HotkeyWidget(const char* label, Hotkey& hotkey, const ImVec2& size = ImVec2(0, 0)); @@ -102,6 +92,16 @@ namespace ImGui void OpenRenamePopup(const std::string& initName); bool IsRenamePopupOpened(); bool DrawRenamePopup(std::string& out); + + bool BeginGroupPanel(const char* label, bool node = false, const ImVec2& size = ImVec2(-1.0f, 0.0f)); + void EndGroupPanel(); + + bool BeginSelectableGroupPanel(const char* label, bool& value, bool& changed, bool node = false, const ImVec2& size = ImVec2(-1.0f, 0.0f), const char* selectLabel = "Select"); + void EndSelectableGroupPanel(); + + void NextGroupPanelHeaderItem(const ImVec2& size, bool rightAlign = false); + + ImVec2 CalcButtonSize(const char* label); } float CalcWidth(const std::string_view& view); @@ -116,18 +116,29 @@ float GetMaxEnumWidth() } template -bool ComboEnum(const char* label, T* currentValue) +bool ComboEnum(const char* label, T* currentValue, std::vector* whitelist = nullptr) { auto name = magic_enum::enum_name(*currentValue); auto& current = *currentValue; bool result = false; static auto width = GetMaxEnumWidth(); + std::unordered_set whiteSet; + if (whitelist != nullptr) + { + for (auto& value : *whitelist) + { + whiteSet.insert(value); + } + } ImGui::SetNextItemWidth(width); if (ImGui::BeginCombo(label, name.data())) { for (auto& entry : magic_enum::enum_entries()) { + if (whitelist != nullptr && whiteSet.count(entry.first) == 0) + continue; + bool is_selected = (name == entry.second); if (ImGui::Selectable(entry.second.data(), is_selected)) { diff --git a/cheat-base/src/cheat-base/render/renderer.cpp b/cheat-base/src/cheat-base/render/renderer.cpp index caf7bdc..183ce23 100644 --- a/cheat-base/src/cheat-base/render/renderer.cpp +++ b/cheat-base/src/cheat-base/render/renderer.cpp @@ -122,7 +122,7 @@ namespace renderer for (int i = 0; i < _fontsCount; i++) { ImGuiIO& io = ImGui::GetIO(); - auto newFont = io.Fonts->AddFontFromMemoryTTF(_customFontData.data, _customFontData.size, (i + 1) * _fontSizeStep); + auto newFont = io.Fonts->AddFontFromMemoryTTF(_customFontData.data, _customFontData.size, static_cast((i + 1) * _fontSizeStep)); if (newFont == nullptr) return; @@ -185,8 +185,8 @@ namespace renderer POINT mPos; GetCursorPos(&mPos); ScreenToClient(hWnd, &mPos); - ImGui::GetIO().MousePos.x = mPos.x; - ImGui::GetIO().MousePos.y = mPos.y; + ImGui::GetIO().MousePos.x = static_cast(mPos.x); + ImGui::GetIO().MousePos.y = static_cast(mPos.y); ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); @@ -210,7 +210,7 @@ namespace renderer key = GET_XBUTTON_WPARAM(wParam); break; case WM_KEYUP: - key = wParam; + key = static_cast(wParam); break; default: keyUpEvent = false; diff --git a/cheat-base/src/cheat-base/util.cpp b/cheat-base/src/cheat-base/util.cpp index cacbad3..8741730 100644 --- a/cheat-base/src/cheat-base/util.cpp +++ b/cheat-base/src/cheat-base/util.cpp @@ -222,7 +222,7 @@ namespace util } std::vector base64_decode(std::string const& encoded_string) { - int in_len = encoded_string.size(); + size_t in_len = encoded_string.size(); int i = 0; int j = 0; int in_ = 0; @@ -233,7 +233,7 @@ namespace util char_array_4[i++] = encoded_string[in_]; in_++; if (i == 4) { for (i = 0; i < 4; i++) - char_array_4[i] = base64_chars.find(char_array_4[i]); + char_array_4[i] = static_cast(base64_chars.find(char_array_4[i])); // base64_chars len < 255 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); @@ -250,7 +250,7 @@ namespace util char_array_4[j] = 0; for (j = 0; j < 4; j++) - char_array_4[j] = base64_chars.find(char_array_4[j]); + char_array_4[j] = static_cast(base64_chars.find(char_array_4[j])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); @@ -261,4 +261,13 @@ namespace util return ret; } + + int64_t GetTimezoneBias() + { + _TIME_ZONE_INFORMATION timezoneInfo{}; + if (GetTimeZoneInformation(&timezoneInfo) == TIME_ZONE_ID_INVALID) + LOG_LAST_ERROR("Failed to get timezone."); + + return static_cast(timezoneInfo.Bias) * 60; + } } \ No newline at end of file diff --git a/cheat-base/src/cheat-base/util.h b/cheat-base/src/cheat-base/util.h index 1ffc634..48c09d3 100644 --- a/cheat-base/src/cheat-base/util.h +++ b/cheat-base/src/cheat-base/util.h @@ -42,6 +42,8 @@ namespace util std::string base64_encode(BYTE const* buf, unsigned int bufLen); std::vector base64_decode(std::string const&); + int64_t GetTimezoneBias(); + template std::string string_format(const std::string& format, Args ... args) diff --git a/cheat-base/vendor/imgui b/cheat-base/vendor/imgui index af916cd..47fb633 160000 --- a/cheat-base/vendor/imgui +++ b/cheat-base/vendor/imgui @@ -1 +1 @@ -Subproject commit af916cdf1aa41243b493c217c8d4256c04aa8921 +Subproject commit 47fb633e73f69e1ba57cef16cd077ddc4d97f0ee diff --git a/cheat-library/cheat-library.vcxproj b/cheat-library/cheat-library.vcxproj index 938c611..2a9ad7b 100644 --- a/cheat-library/cheat-library.vcxproj +++ b/cheat-library/cheat-library.vcxproj @@ -15,6 +15,10 @@ + + true + true + false true @@ -118,6 +122,10 @@ + + true + true + false true @@ -877,7 +885,7 @@ Level3 true - _AMD64_;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_WINDOWS;_USRDLL;_DEBUG;CHEATLIBRARY_EXPORTS;_PACKET_SNIFFER;%(PreprocessorDefinitions) + _AMD64_;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_WINDOWS;_USRDLL;_DEBUG;CHEATLIBRARY_EXPORTS;%(PreprocessorDefinitions) true Use pch-il2cpp.h diff --git a/cheat-library/cheat-library.vcxproj.filters b/cheat-library/cheat-library.vcxproj.filters index 3403490..7178a12 100644 --- a/cheat-library/cheat-library.vcxproj.filters +++ b/cheat-library/cheat-library.vcxproj.filters @@ -216,6 +216,9 @@ Header Files + + Header Files + @@ -390,6 +393,9 @@ Source Files + + Source Files + diff --git a/cheat-library/src/user/cheat/ILPatternScanner.h b/cheat-library/src/user/cheat/ILPatternScanner.h index 2c4d945..6a9dc71 100644 --- a/cheat-library/src/user/cheat/ILPatternScanner.h +++ b/cheat-library/src/user/cheat/ILPatternScanner.h @@ -27,7 +27,7 @@ protected: std::map> m_MethodInfoPattern; std::map> m_TypeInfoPattern; - // Maybe in some feature I do search method/type info by translated name, but not now, not now + // Maybe in future I do search method/type info by translated name, but not now, not now // std::map m_TranslationMap; std::map m_ApiMethodsCache; diff --git a/cheat-library/src/user/cheat/debugger.cpp b/cheat-library/src/user/cheat/debugger.cpp new file mode 100644 index 0000000..287c06f --- /dev/null +++ b/cheat-library/src/user/cheat/debugger.cpp @@ -0,0 +1,12 @@ +#include + +void DebuggerBypassPre() +{ + LOG_INFO("You have no implementation for anti-debugger bypass.\n\tSo if you try to attach VS debugger to process - game will crash."); + // Sry, implementation is private for now +} + +void DebuggerBypassPost() +{ + // Sry, implementation is privite for now +} \ No newline at end of file diff --git a/cheat-library/src/user/cheat/debugger.h b/cheat-library/src/user/cheat/debugger.h new file mode 100644 index 0000000..81d6115 --- /dev/null +++ b/cheat-library/src/user/cheat/debugger.h @@ -0,0 +1,4 @@ +#pragma once + +void DebuggerBypassPre(); // Phase before loading game library +void DebuggerBypassPost(); // Phase after loading game library \ No newline at end of file diff --git a/cheat-library/src/user/cheat/esp/ESP.cpp b/cheat-library/src/user/cheat/esp/ESP.cpp index 23edc7c..02dd140 100644 --- a/cheat-library/src/user/cheat/esp/ESP.cpp +++ b/cheat-library/src/user/cheat/esp/ESP.cpp @@ -61,53 +61,54 @@ namespace cheat::feature void ESP::DrawMain() { - if (BeginGroupPanel("General", ImVec2(-1, 0), true)) + if (ImGui::BeginGroupPanel("General", true)) { ConfigWidget("ESP Enabled", f_Enabled, "Show filtered object through obstacles."); ConfigWidget("Range (m)", f_Range, 1.0f, 1.0f, 200.0f); ConfigWidget(f_DrawBoxMode, "Select the mode of box drawing."); - ConfigWidget(f_DrawTracerMode, "Select the mode of tracer drawing."); + ConfigWidget(f_DrawTracerMode, "Select the mode of tracer drawing."); ConfigWidget(f_Fill); ConfigWidget(f_FillTransparency, 0.01f, 0.0f, 1.0f, "Transparency of filled part."); - if (f_DrawTracerMode.value() == DrawTracerMode::OffscreenArrows && - BeginGroupPanel("Arrow tracer options", ImVec2(-1, 0), true)) - { - ConfigWidget(f_TracerSize, 0.005f, 0.1f, 10.0f, "Size of tracer."); - ConfigWidget(f_ArrowRadius, 0.5f, 50.0f, 300.0f, "Radius of arrow."); - ConfigWidget(f_OutlineThickness, 0.005f, 0.0f, 10.0f, "Outline thickness of arrow."); - - EndGroupPanel(); - } + if (f_DrawTracerMode.value() == DrawTracerMode::OffscreenArrows) + { + if (ImGui::BeginGroupPanel("Arrow tracer options", true)) + { + ConfigWidget(f_TracerSize, 0.005f, 0.1f, 10.0f, "Size of tracer."); + ConfigWidget(f_ArrowRadius, 0.5f, 50.0f, 300.0f, "Radius of arrow."); + ConfigWidget(f_OutlineThickness, 0.005f, 0.0f, 10.0f, "Outline thickness of arrow."); + } + ImGui::EndGroupPanel(); + } ImGui::Spacing(); ConfigWidget(f_DrawName, "Draw name of object."); ConfigWidget(f_DrawDistance, "Draw distance of object."); ImGui::Spacing(); - ConfigWidget(f_FontSize, 0.05f, 1.0f, 100.0f, "Font size of name or distance."); + ConfigWidget(f_FontSize, 1, 1, 100, "Font size of name or distance."); ConfigWidget("## Font outline enabled", f_FontOutline); ImGui::SameLine(); ConfigWidget("Font outline", f_FontOutlineSize, 0.001f, 0.0f, 10.0f); ImGui::Spacing(); - if (BeginGroupPanel("Global colors", ImVec2(-1, 0), true)) + if (ImGui::BeginGroupPanel("Global colors", true)) { if (ConfigWidget(f_GlobalFontColor, "Color of line, name, or distance text font.")) m_FontContrastColor = ImGui::CalcContrastColor(f_GlobalFontColor); + ConfigWidget(f_GlobalBoxColor, "Color of box font."); ConfigWidget(f_GlobalLineColor, "Color of line font."); ConfigWidget(f_GlobalRectColor, "Color of rectangle font."); - EndGroupPanel(); } + ImGui::EndGroupPanel(); ConfigWidget(f_MinSize, 0.05f, 0.1f, 200.0f, "Minimum entity size as measured in-world.\n" \ "Some entities have either extremely small or no bounds at all.\n" \ "This parameter helps filter out entities that don't meet this condition."); - - EndGroupPanel(); } + ImGui::EndGroupPanel(); ImGui::Text("How to use item filters:\n\tLMB - Toggle visibility\n\tRMB - Open color picker"); ImGui::InputText("Search Filters", &m_Search); @@ -174,13 +175,10 @@ namespace cheat::feature if (validFilters.empty()) return; - SelectData selData - { - std::all_of(validFilters.begin(), validFilters.end(), [](const FilterInfo* filter) { return filter->first.value().m_Enabled; }), - false - }; + bool checked = std::all_of(validFilters.begin(), validFilters.end(), [](const FilterInfo* filter) { return filter->first.value().m_Enabled; }); + bool changed = false; - if (BeginGroupPanel(section.c_str(), ImVec2(-1, 0), true, &selData)) + if (ImGui::BeginSelectableGroupPanel(section.c_str(), checked, changed, true)) { for (auto& info : validFilters) { @@ -207,14 +205,14 @@ namespace cheat::feature ImGui::TreePop(); } - EndGroupPanel(); } + ImGui::EndSelectableGroupPanel(); - if (selData.changed) + if (changed) { for (auto& info : validFilters) { - info->first.value().m_Enabled = selData.toggle; + info->first.value().m_Enabled = checked; info->first.FireChanged(); } } diff --git a/cheat-library/src/user/cheat/esp/ESPRender.cpp b/cheat-library/src/user/cheat/esp/ESPRender.cpp index 0e37786..852a388 100644 --- a/cheat-library/src/user/cheat/esp/ESPRender.cpp +++ b/cheat-library/src/user/cheat/esp/ESPRender.cpp @@ -26,18 +26,20 @@ namespace cheat::feature::esp::render s_Camera = nullptr; + auto loadingManager = GET_SINGLETON(LoadingManager); + if (loadingManager == nullptr || !app::LoadingManager_IsLoaded(loadingManager, nullptr)) + return; + + SAFE_BEGIN(); auto camera = app::Camera_get_main(nullptr, nullptr); if (camera == nullptr) return; if (!app::Behaviour_get_isActiveAndEnabled(reinterpret_cast(camera), nullptr)) return; - - auto loadingManager = GET_SINGLETON(LoadingManager); - if (loadingManager == nullptr || !app::LoadingManager_IsLoaded(loadingManager, nullptr)) - return; - + s_Camera = camera; + SAFE_EEND(); } static void UpdateResolutionScale() @@ -65,11 +67,11 @@ namespace cheat::feature::esp::render if (screenHeight == pixelHeight && screenWidth == pixelWidth) return; - s_ScreenResolution.x = screenWidth; - s_ScreenResolution.y = screenHeight; + s_ScreenResolution.x = static_cast(screenWidth); + s_ScreenResolution.y = static_cast(screenHeight); - s_ResolutionScale.x = static_cast(screenWidth) / static_cast(pixelWidth); - s_ResolutionScale.y = static_cast(screenHeight) / static_cast(pixelHeight); + s_ResolutionScale.x = s_ScreenResolution.x / static_cast(pixelWidth); + s_ResolutionScale.y = s_ScreenResolution.y / static_cast(pixelHeight); SAFE_EEND(); } @@ -391,7 +393,7 @@ namespace cheat::feature::esp::render draw->AddLine(s_AvatarPosition, *screenPos, color); } -#define PI 3.14159265358979323846 +#define PI 3.14159265358979323846f static void DrawOffscreenArrows(game::Entity* entity, const ImColor& color) { @@ -438,10 +440,10 @@ namespace cheat::feature::esp::render entity_pos.x < 0 ? abs(entity_pos.x) : (entity_pos.x > screen_rect.Max.x ? entity_pos.x - screen_rect.Max.x : 0.0f), entity_pos.y < 0 ? abs(entity_pos.y) : (entity_pos.y > screen_rect.Max.y ? entity_pos.y - screen_rect.Max.y : 0.0f), }; - auto distance = std::pow(screen_outer_diff.x, 2) + std::pow(screen_outer_diff.y, 2); + float distance = static_cast(std::pow(screen_outer_diff.x, 2) + std::pow(screen_outer_diff.y, 2)); alpha = entity_pos.z < 0 ? 1.0f : (distance / nearThreshold); } - auto arrowColor = color; + auto arrowColor = color; // Copy arrowColor.Value.w = std::min(alpha, 1.0f); // Draw the arrow @@ -477,19 +479,19 @@ namespace cheat::feature::esp::render // Might need to be aware of performance hit but there shouldn't be any. ImGuiContext& g = *GImGui; ImFont* font = g.Font; - auto textSize = font->CalcTextSizeA(esp.f_FontSize, FLT_MAX, FLT_MAX, text.c_str()); + auto textSize = font->CalcTextSizeA(static_cast(esp.f_FontSize), FLT_MAX, FLT_MAX, text.c_str()); namePosition.x -= (textSize.x / 2.0f); namePosition.y -= esp.f_FontSize; } auto draw = ImGui::GetBackgroundDrawList(); - auto font = renderer::GetFontBySize(esp.f_FontSize); + auto font = renderer::GetFontBySize(static_cast(esp.f_FontSize)); // Outline if (esp.f_FontOutline) - DrawTextWithOutline(draw, font, esp.f_FontSize, namePosition, text.c_str(), color, esp.f_FontOutlineSize, OutlineSide::All, contrastColor); + DrawTextWithOutline(draw, font, static_cast(esp.f_FontSize), namePosition, text.c_str(), color, esp.f_FontOutlineSize, OutlineSide::All, contrastColor); else - draw->AddText(font, esp.f_FontSize, namePosition, color, text.c_str()); + draw->AddText(font, static_cast(esp.f_FontSize), namePosition, color, text.c_str()); } bool DrawEntity(const std::string& name, game::Entity* entity, const ImColor& color, const ImColor& contrastColor) diff --git a/cheat-library/src/user/cheat/imap/InteractiveMap.cpp b/cheat-library/src/user/cheat/imap/InteractiveMap.cpp index 749f125..0a072c8 100644 --- a/cheat-library/src/user/cheat/imap/InteractiveMap.cpp +++ b/cheat-library/src/user/cheat/imap/InteractiveMap.cpp @@ -112,7 +112,7 @@ namespace cheat::feature void InteractiveMap::DrawMenu() { - BeginGroupPanel("General"); + ImGui::BeginGroupPanel("General"); { ConfigWidget("Enabled", f_Enabled); ConfigWidget(f_SeparatedWindows, "Config and filters will be in separate windows."); @@ -121,25 +121,25 @@ namespace cheat::feature UpdateUserDataField(f_CompletedPointsJson, f_STCompletedPoints.value(), true); } } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Icon view"); + ImGui::BeginGroupPanel("Icon view"); { ConfigWidget(f_IconSize, 0.01f, 4.0f, 100.0f); ConfigWidget(f_MinimapIconSize, 0.01f, 4.0f, 100.0f); ConfigWidget(f_DynamicSize, "Icons will be sized dynamically depend to zoom size.\nMinimap icons don't affected."); ConfigWidget(f_ShowHDIcons, "Toggle icons to HD format."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Completed icon view"); + ImGui::BeginGroupPanel("Completed icon view"); { ConfigWidget(f_ShowCompleted, "Show completed points."); ConfigWidget(f_CompletePointTransparency, 0.01f, 0.0f, 1.0f, "Completed points transparency."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Item adjusting"); + ImGui::BeginGroupPanel("Item adjusting"); { ConfigWidget(f_AutoFixItemPositions, "Do fix positions to nearest to point.\n" "Only items with green line support this function."); @@ -157,9 +157,9 @@ namespace cheat::feature ConfigWidget(f_CheckObjectsDelay, 10, 100, 100000, "Adjusting items is power consumption operation.\n" "So rescanning will happen with specified delay."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Gather detecting"); + ImGui::BeginGroupPanel("Gather detecting"); { ConfigWidget(f_AutoDetectGatheredItems, "Enables detecting gathered items.\n" "It works only items what will be gathered after enabling this function.\n" @@ -168,16 +168,16 @@ namespace cheat::feature ConfigWidget(f_GatheredItemsDetectRange, 0.1f, 5.0f, 30.0f, "When entity was gathered finding nearest point in this range."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Manual completing"); + ImGui::BeginGroupPanel("Manual completing"); { ConfigWidget(f_CompleteNearestPoint, true, "When pressed, complete the nearest to avatar point."); ConfigWidget(f_RevertLatestCompletion, true, "When pressed, revert latest complete operation."); ConfigWidget(f_CompleteOnlyViewed, "Complete performed only to visible points."); ConfigWidget(f_PointFindRange, 0.5f, 0.0f, 200.0f, "Complete performs within specified range. If 0 - unlimited."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); } void InteractiveMap::DrawFilters(const bool searchFixed) @@ -223,13 +223,10 @@ namespace cheat::feature if (validLabels.empty()) continue; - SelectData selData - { - std::all_of(validLabels.begin(), validLabels.end(), [](const LabelData* label) { return label->enabled; }), - false - }; + bool checked = std::all_of(validLabels.begin(), validLabels.end(), [](const LabelData* label) { return label->enabled; }); + bool changed = false; - if (BeginGroupPanel(categoryName.c_str(), ImVec2(-1, 0), true, &selData)) + if (ImGui::BeginSelectableGroupPanel(categoryName.c_str(), checked, changed, true)) { if (ImGui::BeginTable("MarkFilters", 2)) { @@ -242,15 +239,14 @@ namespace cheat::feature } ImGui::EndTable(); } - - EndGroupPanel(); } + ImGui::EndSelectableGroupPanel(); - if (selData.changed) + if (changed) { for (const auto& label : validLabels) { - label->enabled = selData.toggle; + label->enabled = checked; } } diff --git a/cheat-library/src/user/cheat/misc/Debug.cpp b/cheat-library/src/user/cheat/misc/Debug.cpp index b289e9d..2bb08c4 100644 --- a/cheat-library/src/user/cheat/misc/Debug.cpp +++ b/cheat-library/src/user/cheat/misc/Debug.cpp @@ -438,7 +438,7 @@ namespace cheat::feature ImGui::TableHeadersRow(); ImGuiListClipper clipper; - clipper.Begin(entities.size()); + clipper.Begin(static_cast(entities.size())); while (clipper.Step()) for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++) { @@ -1037,6 +1037,7 @@ namespace cheat::feature } catch (nlohmann::detail::parse_error& parseError) { + UNREFERENCED_PARAMETER(parseError); LOG_ERROR("Failed to parse json"); } diff --git a/cheat-library/src/user/cheat/misc/Hotkeys.cpp b/cheat-library/src/user/cheat/misc/Hotkeys.cpp index 12e926e..750f3be 100644 --- a/cheat-library/src/user/cheat/misc/Hotkeys.cpp +++ b/cheat-library/src/user/cheat/misc/Hotkeys.cpp @@ -57,14 +57,14 @@ namespace cheat::feature for (auto& fields : multiLineSections) { - if (BeginGroupPanel((*fields)[0]->section().c_str(), ImVec2(-1, 0), true)) + if (ImGui::BeginGroupPanel((*fields)[0]->section().c_str(), true)) { for (auto& field : *fields) { ConfigWidget(*field, nullptr, true); } - EndGroupPanel(); } + ImGui::EndGroupPanel(); } ImGui::EndChild(); diff --git a/cheat-library/src/user/cheat/misc/sniffer/MessageManager.cpp b/cheat-library/src/user/cheat/misc/sniffer/MessageManager.cpp index 6636b07..10507cc 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/MessageManager.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/MessageManager.cpp @@ -39,6 +39,8 @@ namespace sniffer default: break; } + + return nullptr; } void MessageManager::ProcessMessage() diff --git a/cheat-library/src/user/cheat/misc/sniffer/PacketInfo.cpp b/cheat-library/src/user/cheat/misc/sniffer/PacketInfo.cpp index c22545b..d7c346a 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/PacketInfo.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/PacketInfo.cpp @@ -21,7 +21,7 @@ namespace sniffer uint32_t PacketInfo::id() const { - return m_Data.packetID; + return m_Data.messageID; } size_t PacketInfo::size() const diff --git a/cheat-library/src/user/cheat/misc/sniffer/PacketParser.cpp b/cheat-library/src/user/cheat/misc/sniffer/PacketParser.cpp index e5b8a78..ca0cdf4 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/PacketParser.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/PacketParser.cpp @@ -26,7 +26,7 @@ namespace sniffer bool PacketParser::Parse(PacketData& data) { - auto name = m_ProtoManager.GetName(data.packetID); + auto name = m_ProtoManager.GetName(data.messageID); if (!name) return false; @@ -34,7 +34,7 @@ namespace sniffer if (!head) return false; - auto message = m_ProtoManager.GetJson(data.packetID, data.messageRawData); + auto message = m_ProtoManager.GetJson(data.messageID, data.messageRawData); if (!message) return false; @@ -46,7 +46,7 @@ namespace sniffer bool PacketParser::IsUnionPacket(const PacketData& data) { - return m_UnionPacketIds.count(data.packetID) > 0; + return m_UnionPacketIds.count(data.messageID) > 0; } std::vector PacketParser::ParseUnionPacket(const PacketData& data) @@ -54,7 +54,7 @@ namespace sniffer if (!IsUnionPacket(data)) return {}; - auto parseFunction = m_UnionPacketIds[data.packetID]; + auto parseFunction = m_UnionPacketIds[data.messageID]; return (this->*parseFunction)(data); } @@ -64,10 +64,10 @@ namespace sniffer nestedPacketData.headRawData = parent.headRawData; nestedPacketData.headJson = parent.headJson; nestedPacketData.messageRawData = util::base64_decode(bodyEncoded); - nestedPacketData.packetID = packetID; + nestedPacketData.messageID = packetID; nestedPacketData.valid = true; nestedPacketData.ioType = parent.ioType; - nestedPacketData.parentID = parent.sequenceID(); + nestedPacketData.parentPacketID = parent.sequenceID(); if (packetID != 0) Parse(nestedPacketData); diff --git a/cheat-library/src/user/cheat/misc/sniffer/PacketSniffer.cpp b/cheat-library/src/user/cheat/misc/sniffer/PacketSniffer.cpp index 3c40038..a25a97a 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/PacketSniffer.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/PacketSniffer.cpp @@ -129,7 +129,7 @@ namespace cheat::feature auto dataSize = modifyData->modifiedData.size(); packet->data = new byte[dataSize](); memcpy_s(packet->data, dataSize, modifyData->modifiedData.data(), dataSize); - packet->dataLen = dataSize; + packet->dataLen = static_cast(dataSize); } break; case PacketModifyType::Unchanged: @@ -224,7 +224,7 @@ namespace cheat::feature } packetData.valid = true; - packetData.packetID = messageId; + packetData.messageID = messageId; packetData.headRawData = std::vector((size_t)headSize, 0); memcpy_s(packetData.headRawData.data(), headSize, data + 10, headSize); diff --git a/cheat-library/src/user/cheat/misc/sniffer/ProtoManager.cpp b/cheat-library/src/user/cheat/misc/sniffer/ProtoManager.cpp index b84dfd6..3a82161 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/ProtoManager.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/ProtoManager.cpp @@ -6,7 +6,7 @@ namespace sniffer { - static class ErrorCollector : public google::protobuf::compiler::MultiFileErrorCollector + class ErrorCollector : public google::protobuf::compiler::MultiFileErrorCollector { // Inherited via MultiFileErrorCollector virtual void AddError(const std::string& filename, int line, int column, const std::string& message) override diff --git a/cheat-library/src/user/cheat/misc/sniffer/SnifferWindow.cpp b/cheat-library/src/user/cheat/misc/sniffer/SnifferWindow.cpp index 08953a3..604ee5c 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/SnifferWindow.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/SnifferWindow.cpp @@ -437,6 +437,7 @@ namespace sniffer } catch (const std::regex_error& e) { + UNREFERENCED_PARAMETER(e); return false; } } @@ -465,7 +466,7 @@ namespace sniffer bool removed = false; auto name = fmt::format("Group {}", magic_enum::enum_name(m_Rule)); - BeginGroupPanel(name.c_str(), ImVec2(-1, 0)); + ImGui::BeginGroupPanel(name.c_str()); { ComboEnum("Rule", &m_Rule); @@ -498,7 +499,7 @@ namespace sniffer m_Filters.push_back(new Filter()); } - EndGroupPanel(); + ImGui::EndGroupPanel(); ImGui::PopID(); diff --git a/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.cpp b/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.cpp index 8ff4d58..d4b63ca 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.cpp +++ b/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.cpp @@ -7,8 +7,8 @@ void PacketData::Write(PipeTransfer* transfer) transfer->Write(ioType); transfer->Write(dataType); transfer->Write(valid); - transfer->Write(parentID); - transfer->Write(packetID); + transfer->Write(parentPacketID); + transfer->Write(messageID); transfer->Write(headRawData); transfer->Write(messageRawData); @@ -26,8 +26,8 @@ void PacketData::Read(PipeTransfer* transfer) transfer->Read(ioType); transfer->Read(dataType); transfer->Read(valid); - transfer->Read(parentID); - transfer->Read(packetID); + transfer->Read(parentPacketID); + transfer->Read(messageID); transfer->Read(headRawData); transfer->Read(messageRawData); diff --git a/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.h b/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.h index 1bd6bf7..d9faad9 100644 --- a/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.h +++ b/cheat-library/src/user/cheat/misc/sniffer/messages/PacketData.h @@ -26,9 +26,9 @@ public: bool valid; - uint64_t parentID; + uint64_t parentPacketID; - int16_t packetID; + int16_t messageID; std::vector headRawData; std::vector messageRawData; diff --git a/cheat-library/src/user/cheat/world/AutoLoot.cpp b/cheat-library/src/user/cheat/world/AutoLoot.cpp index 7606fe1..8875d18 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.cpp +++ b/cheat-library/src/user/cheat/world/AutoLoot.cpp @@ -47,7 +47,7 @@ namespace cheat::feature ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); - BeginGroupPanel("Auto-Pickup", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Auto-Pickup"); { ConfigWidget("Enabled", f_AutoPickup, "Automatically picks up dropped items.\n" \ "Note: Using this with custom range and low delay times is extremely risky.\n" \ @@ -56,9 +56,9 @@ namespace cheat::feature ImGui::SameLine(); ImGui::TextColored(ImColor(255, 165, 0, 255), "Read the note!"); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Custom Pickup Range", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Custom Pickup Range"); { ConfigWidget("Enabled", f_UseCustomRange, "Enable custom pickup range.\n" \ "High values are not recommended, as it is easily detected by the server.\n\n" \ @@ -68,18 +68,18 @@ namespace cheat::feature ImGui::SetNextItemWidth(100.0f); ConfigWidget("Range (m)", f_CustomRange, 0.1f, 0.5f, 40.0f, "Modifies pickup/open range to this value (in meters)."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Looting Speed", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Looting Speed"); { ImGui::SetNextItemWidth(100.0f); ConfigWidget("Delay Time (ms)", f_DelayTime, 1, 0, 1000, "Delay (in ms) between loot/open actions.\n" \ "Values under 200ms are unsafe.\nNot used if no auto-functions are on."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); ImGui::TableSetColumnIndex(1); - BeginGroupPanel("Auto-Treasure", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Auto-Treasure"); { ConfigWidget("Enabled", f_AutoTreasure, "Automatically opens chests and other treasures.\n" \ "Note: Using this with custom range and low delay times is extremely risky.\n" \ @@ -95,7 +95,7 @@ namespace cheat::feature ConfigWidget("Others", f_Others, "Book Pages, Spincrystals, etc."); ImGui::Unindent(); } - EndGroupPanel(); + ImGui::EndGroupPanel(); ImGui::EndTable(); } } diff --git a/cheat-library/src/user/cheat/world/AutoTreeFarm.cpp b/cheat-library/src/user/cheat/world/AutoTreeFarm.cpp index bd97207..ccdb84d 100644 --- a/cheat-library/src/user/cheat/world/AutoTreeFarm.cpp +++ b/cheat-library/src/user/cheat/world/AutoTreeFarm.cpp @@ -178,7 +178,7 @@ namespace cheat::feature auto& attackCount = s_AttackCountMap[position]; attackCount++; - if (attackCount > m_AttackPerTree) + if (attackCount > static_cast(m_AttackPerTree)) continue; } diff --git a/cheat-library/src/user/cheat/world/MobVacuum.cpp b/cheat-library/src/user/cheat/world/MobVacuum.cpp index b4392cf..f061315 100644 --- a/cheat-library/src/user/cheat/world/MobVacuum.cpp +++ b/cheat-library/src/user/cheat/world/MobVacuum.cpp @@ -40,23 +40,23 @@ namespace cheat::feature "Mobs within the specified radius will move\nto a specified distance in front of the player."); bool filtersChanged = false; - BeginGroupPanel("Monsters", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Monsters"); { filtersChanged |= ConfigWidget(f_IncludeMonsters, "Include monsters in vacuum."); filtersChanged |= ConfigWidget(f_MonsterCommon, "Common enemies."); ImGui::SameLine(); filtersChanged |= ConfigWidget(f_MonsterElites, "Elite enemies."); ImGui::SameLine(); filtersChanged |= ConfigWidget(f_MonsterBosses, "World and Trounce boss enemies."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); - BeginGroupPanel("Animals", ImVec2(-1, 0)); + ImGui::BeginGroupPanel("Animals"); { filtersChanged |= ConfigWidget(f_IncludeAnimals, "Include animals in vacuum."); filtersChanged |= ConfigWidget(f_AnimalDrop, "Animals you need to kill before collecting."); ImGui::SameLine(); filtersChanged |= ConfigWidget(f_AnimalPickUp, "Animals you can immediately collect."); ImGui::SameLine(); filtersChanged |= ConfigWidget(f_AnimalNPC, "Animals without mechanics."); } - EndGroupPanel(); + ImGui::EndGroupPanel(); if (filtersChanged) UpdateFilters(); diff --git a/cheat-library/src/user/main.cpp b/cheat-library/src/user/main.cpp index 0f29f63..9cb6a5c 100644 --- a/cheat-library/src/user/main.cpp +++ b/cheat-library/src/user/main.cpp @@ -6,23 +6,16 @@ #include #include +#include #include #include -bool StubTerminateProcess(); +#ifdef _DEBUG +#include +#endif void Run(HMODULE* phModule) { -#ifdef _DEBUG - Sleep(10000); -#else - while (GetModuleHandle("UserAssembly.dll") == nullptr) - { - Sleep(2000); - } - Sleep(15000); -#endif - ResourceLoader::SetModuleHandle(*phModule); // Init config @@ -43,43 +36,26 @@ void Run(HMODULE* phModule) il2cppi_new_console(); } - init_il2cpp(); +#ifdef _DEBUG + DebuggerBypassPre(); - if (StubTerminateProcess()) - LOG_INFO("TerminateProcess stubbed successfully."); - else - LOG_ERROR("Stub TerminateProcess failed."); + LOG_DEBUG("Waiting 10sec for loading game library."); + Sleep(10000); + + DebuggerBypassPost(); +#else + while (GetModuleHandle("UserAssembly.dll") == nullptr) + { + LOG_DEBUG("UserAssembly.dll isn't initialized, waiting for 2 sec."); + Sleep(2000); + } + LOG_DEBUG("Waiting 15sec for game initialize."); + Sleep(15000); +#endif + + init_il2cpp(); cheat::Init(); LOG_DEBUG("Config path is at %s", configPath.c_str()); - LOG_DEBUG("UserAssembly.dll is at 0x%p", il2cppi_get_base_address()); - LOG_DEBUG("UnityPlayer.dll is at 0x%p", il2cppi_get_unity_address()); -} - -BOOL WINAPI TerminateProcess_Hook(HANDLE hProcessUINT, UINT uExitCode) -{ - return TRUE; -} - -bool StubTerminateProcess() -{ - HMODULE hKernelBase = GetModuleHandle("kernelbase.dll"); - if (hKernelBase == NULL) - { - LOG_LAST_ERROR("Failed to get the kernelbase.dll handle."); - return false; - } - - FARPROC pTerminateProcess = GetProcAddress(hKernelBase, "TerminateProcess"); - if (pTerminateProcess == nullptr) - { - LOG_LAST_ERROR("Getting KernelBase::NtTerminateProcess failed."); - return false; - } - using TerminateProcess_Type = BOOL(*)(HANDLE, UINT); - - HookManager::install((TerminateProcess_Type)pTerminateProcess, TerminateProcess_Hook); - LOG_DEBUG("Terminate process hooked. Origin at 0x%p", HookManager::getOrigin(TerminateProcess_Hook)); - return true; } \ No newline at end of file diff --git a/injector/src/main.cpp b/injector/src/main.cpp index 0d15841..f70dbfb 100644 --- a/injector/src/main.cpp +++ b/injector/src/main.cpp @@ -14,7 +14,7 @@ const std::string ChinaGenshinProcName = "YuanShen.exe"; static CSimpleIni ini; -HANDLE OpenGenshinProcess(); +bool OpenGenshinProcess(HANDLE* phProcess, HANDLE* phThread); int main(int argc, char* argv[]) { @@ -31,8 +31,8 @@ int main(int argc, char* argv[]) ini.SetUnicode(); ini.LoadFile("cfg.ini"); - HANDLE hProcess = OpenGenshinProcess(); - if (hProcess == NULL) + HANDLE hProcess, hThread; + if (!OpenGenshinProcess(&hProcess, &hThread)) { std::cout << "Failed to open GenshinImpact process." << std::endl; return 1; @@ -60,10 +60,13 @@ int main(int argc, char* argv[]) InjectDLL(hProcess, currentDllPath.string()); #endif + Sleep(2000); + ResumeThread(hThread); + CloseHandle(hProcess); } -HANDLE OpenGenshinProcess() +bool OpenGenshinProcess(HANDLE *phProcess, HANDLE* phThread) { STARTUPINFOA startInfo{}; PROCESS_INFORMATION processInformation{}; @@ -74,7 +77,7 @@ HANDLE OpenGenshinProcess() LPSTR lpstr = commandline == nullptr ? nullptr : const_cast(commandline); if (!filePath) - return NULL; + return false; BOOL result = CreateProcessA(filePath->c_str(), lpstr, 0, 0, FALSE, CREATE_SUSPENDED, nullptr, nullptr, &startInfo, &processInformation); @@ -82,12 +85,12 @@ HANDLE OpenGenshinProcess() { LOG_LAST_ERROR("Failed to create game process."); LOG_ERROR("If you have problem with GenshinImpact.exe path. You can change it manually in cfg.ini."); - return NULL; + return false; } ini.SaveFile("cfg.ini"); - ResumeThread(processInformation.hThread); - - return processInformation.hProcess; + *phThread = processInformation.hThread; + *phProcess = processInformation.hProcess; + return true; } From 75c93bf406824b027ec4d91c93ce675d8fd3d300 Mon Sep 17 00:00:00 2001 From: CallowBlack Date: Thu, 26 May 2022 16:29:36 +0300 Subject: [PATCH 4/5] update `.gitignore` for `debugger.cpp` --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2ef9cb1..acf81a8 100644 --- a/.gitignore +++ b/.gitignore @@ -362,4 +362,5 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -enc_temp_folder/ \ No newline at end of file +enc_temp_folder/ +cheat-library/src/user/cheat/debugger.cpp \ No newline at end of file From 9e1d52f470e8ec5ea553367246fc2f18e40df6ab Mon Sep 17 00:00:00 2001 From: CallowBlack Date: Thu, 26 May 2022 16:38:38 +0300 Subject: [PATCH 5/5] fix `.gitignore` --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index acf81a8..020d887 100644 --- a/.gitignore +++ b/.gitignore @@ -363,4 +363,4 @@ MigrationBackup/ FodyWeavers.xsd enc_temp_folder/ -cheat-library/src/user/cheat/debugger.cpp \ No newline at end of file +debugger.cpp \ No newline at end of file