mirror of
https://github.com/360NENZ/Taiga74164-Akebi-GC.git
synced 2025-09-19 12:16:20 +08:00
Merge branch 'master' into AltGodMode-fix
This commit is contained in:
@ -41,15 +41,7 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketParser.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\GenshinCM.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\SnifferWindow.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\teleport\CustomTeleports.h" />
|
||||
<ClInclude Include="src\user\cheat\visuals\Browser.h" />
|
||||
<ClInclude Include="src\user\cheat\visuals\CameraZoom.h" />
|
||||
@ -95,18 +87,10 @@
|
||||
<ClInclude Include="src\user\cheat\misc\Debug.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\Hotkeys.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\ProtectionBypass.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketInfo.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketSniffer.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\ProtoManager.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\native.h" />
|
||||
<ClInclude Include="src\user\cheat\player\GodMode.h" />
|
||||
<ClInclude Include="src\user\cheat\player\InfiniteStamina.h" />
|
||||
@ -158,14 +142,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketParser.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\SnifferWindow.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\teleport\CustomTeleports.cpp" />
|
||||
<ClCompile Include="src\user\cheat\GenshinCM.cpp" />
|
||||
<ClCompile Include="src\user\cheat\visuals\Browser.cpp" />
|
||||
@ -209,18 +185,10 @@
|
||||
<ClCompile Include="src\user\cheat\misc\Debug.cpp" />
|
||||
<ClCompile Include="src\user\cheat\misc\Hotkeys.cpp" />
|
||||
<ClCompile Include="src\user\cheat\misc\ProtectionBypass.cpp" />
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketInfo.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketSniffer.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\ProtoManager.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\native.cpp" />
|
||||
<ClCompile Include="src\user\cheat\player\GodMode.cpp" />
|
||||
<ClCompile Include="src\user\cheat\player\InfiniteStamina.cpp" />
|
||||
@ -877,8 +845,8 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>CLibrary</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\obj\$(ProjectName)\</IntDir>
|
||||
<CustomBuildBeforeTargets>Run</CustomBuildBeforeTargets>
|
||||
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
|
||||
<CustomBuildAfterTargets>FinalizeBuildStatus</CustomBuildAfterTargets>
|
||||
@ -886,8 +854,8 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>CLibrary</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\obj\$(ProjectName)\</IntDir>
|
||||
<CustomBuildBeforeTargets>Run</CustomBuildBeforeTargets>
|
||||
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
|
||||
<CustomBuildAfterTargets>FinalizeBuildStatus</CustomBuildAfterTargets>
|
||||
@ -895,8 +863,8 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>CLibrary</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\obj\$(ProjectName)\</IntDir>
|
||||
<CustomBuildBeforeTargets>Run</CustomBuildBeforeTargets>
|
||||
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
|
||||
<CustomBuildAfterTargets>FinalizeBuildStatus</CustomBuildAfterTargets>
|
||||
@ -917,6 +885,7 @@
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -955,6 +924,7 @@ powershell -nop -c "& {sleep 20}"</Command>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -963,7 +933,7 @@ powershell -nop -c "& {sleep 20}"</Command>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalLibraryDirectories>$(OutDir);$(ProjectDir)vendor\lib\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>cheat-base.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>cheat-base.lib;ntdll.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@ -992,6 +962,7 @@ powershell -nop -c "& {sleep 15}"</Command>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<DiagnosticsFormat>Classic</DiagnosticsFormat>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -48,15 +48,9 @@
|
||||
<ClInclude Include="src\framework\pch-il2cpp.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketSniffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\ProtoManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\Debug.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -195,12 +189,6 @@
|
||||
<ClInclude Include="src\user\cheat\visuals\CameraZoom.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\SnifferWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketParser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\messages\MessageBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -264,15 +252,9 @@
|
||||
<ClCompile Include="src\framework\pch-il2cpp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketSniffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\ProtoManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\Debug.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -399,12 +381,6 @@
|
||||
<ClCompile Include="src\user\cheat\visuals\CameraZoom.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\SnifferWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketParser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\messages\MessageBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -11904,6 +11904,16 @@ namespace app {
|
||||
struct MoleMole_ActorModifier__Fields fields;
|
||||
};
|
||||
|
||||
struct Button_1 {
|
||||
struct Button_1__Class* klass;
|
||||
MonitorData* monitor;
|
||||
};
|
||||
|
||||
struct Slider_1 {
|
||||
struct Slider_1__Class* klass;
|
||||
MonitorData* monitor;
|
||||
};
|
||||
|
||||
#if !defined(_GHIDRA_) && !defined(_IDA_)
|
||||
}
|
||||
#endif
|
||||
|
@ -511,7 +511,7 @@ namespace cheat::feature
|
||||
ADD_FILTER_FIELD(mineral, NoctilucousJade);
|
||||
ADD_FILTER_FIELD(mineral, MagicalCrystalChunk);
|
||||
ADD_FILTER_FIELD(mineral, ScarletQuartz);
|
||||
ADD_FILTER_FIELD(mineral, StarSilver);
|
||||
ADD_FILTER_FIELD(mineral, Starsilver);
|
||||
ADD_FILTER_FIELD(mineral, WhiteIronChunk);
|
||||
ADD_FILTER_FIELD(mineral, DunlinsTooth);
|
||||
|
||||
|
@ -105,7 +105,7 @@ namespace cheat::game::filters
|
||||
std::vector<std::string> { "_OreNightBerth", "_ShiningNightBerthOre" } };
|
||||
SimpleFilter MagicalCrystalChunk = { app::EntityType__Enum_1::GatherObject, "_OreMagicCrystal" };
|
||||
SimpleFilter ScarletQuartz = { app::EntityType__Enum_1::GatherObject, "_OreDulinsBlood" };
|
||||
SimpleFilter StarSilver = { app::EntityType__Enum_1::GatherObject, "_OreMoonMeteor" };
|
||||
SimpleFilter Starsilver = { app::EntityType__Enum_1::GatherObject, "_OreMoonMeteor" };
|
||||
SimpleFilter WhiteIronChunk = { app::EntityType__Enum_1::GatherObject, "_OreMetal" };
|
||||
SimpleFilter DunlinsTooth = { app::EntityType__Enum_1::GatherObject, "_DunlinsTooth" };
|
||||
}
|
||||
@ -281,7 +281,7 @@ namespace cheat::game::filters
|
||||
mineral::IronChunk +
|
||||
mineral::NoctilucousJade +
|
||||
mineral::MagicalCrystalChunk +
|
||||
mineral::StarSilver +
|
||||
mineral::Starsilver +
|
||||
mineral::WhiteIronChunk
|
||||
};
|
||||
WhitelistFilter Doodads = {
|
||||
|
@ -105,7 +105,7 @@ namespace cheat::game::filters
|
||||
extern SimpleFilter NoctilucousJade;
|
||||
extern SimpleFilter MagicalCrystalChunk;
|
||||
extern SimpleFilter ScarletQuartz;
|
||||
extern SimpleFilter StarSilver;
|
||||
extern SimpleFilter Starsilver;
|
||||
extern SimpleFilter WhiteIronChunk;
|
||||
extern SimpleFilter DunlinsTooth;
|
||||
}
|
||||
|
@ -1777,7 +1777,7 @@ namespace cheat::feature
|
||||
INIT_FILTER(mineral, IronChunk);
|
||||
INIT_FILTER(mineral, NoctilucousJade);
|
||||
INIT_FILTER(mineral, MagicalCrystalChunk);
|
||||
INIT_FILTER(mineral, StarSilver);
|
||||
INIT_FILTER(mineral, Starsilver);
|
||||
INIT_FILTER(mineral, WhiteIronChunk);
|
||||
//INIT_FILTER(monster, AbyssMage);
|
||||
//INIT_FILTER(monster, FatuiAgent);
|
||||
|
@ -45,6 +45,9 @@ namespace sniffer
|
||||
while (true)
|
||||
{
|
||||
auto messagePtr = ReceiveMessage();
|
||||
if (messagePtr == nullptr)
|
||||
return {};
|
||||
|
||||
if (GetMessageIDByType<TMessage>() != messagePtr->messageID())
|
||||
{
|
||||
delete messagePtr;
|
||||
|
@ -1,145 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "PacketInfo.h"
|
||||
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
PacketInfo::PacketInfo(PacketData packetData)
|
||||
: m_Data(packetData),
|
||||
m_JObject(nlohmann::json::parse(packetData.messageJson)),
|
||||
m_Time(util::GetCurrentTimeMillisec()),
|
||||
m_DrawBeauty(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PacketIOType PacketInfo::type() const
|
||||
{
|
||||
return m_Data.ioType;
|
||||
}
|
||||
|
||||
uint32_t PacketInfo::id() const
|
||||
{
|
||||
return m_Data.messageID;
|
||||
}
|
||||
|
||||
size_t PacketInfo::size() const
|
||||
{
|
||||
return m_Data.messageRawData.size();
|
||||
}
|
||||
|
||||
int64_t PacketInfo::time() const
|
||||
{
|
||||
return m_Time;
|
||||
}
|
||||
|
||||
std::string PacketInfo::name() const
|
||||
{
|
||||
return m_Data.name;
|
||||
}
|
||||
|
||||
nlohmann::json PacketInfo::object() const
|
||||
{
|
||||
return m_JObject;
|
||||
}
|
||||
|
||||
void DrawPrimitive(const std::string& key, nlohmann::json& jsonPrimitive)
|
||||
{
|
||||
if (jsonPrimitive.is_boolean())
|
||||
{
|
||||
bool primitive = jsonPrimitive;
|
||||
ImGui::Checkbox(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_number_integer() || jsonPrimitive.is_number_unsigned())
|
||||
{
|
||||
int primitive = jsonPrimitive;
|
||||
ImGui::InputInt(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_number_float())
|
||||
{
|
||||
float primitive = jsonPrimitive;
|
||||
ImGui::InputFloat(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_string())
|
||||
{
|
||||
std::string primitive = jsonPrimitive;
|
||||
ImGui::InputText(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_null())
|
||||
{
|
||||
ImGui::Text("%s: <null>", key.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawObject(const std::string& key, nlohmann::json& jsonObject);
|
||||
|
||||
void DrawArray(const std::string& key, nlohmann::json& jsonArray)
|
||||
{
|
||||
ImGui::PushID(key.c_str());
|
||||
|
||||
if (ImGui::TreeNode(key.c_str()))
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& el : jsonArray)
|
||||
{
|
||||
DrawObject(std::to_string(i), el);
|
||||
i++;
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void DrawObject(const std::string& key, nlohmann::json& jsonObject)
|
||||
{
|
||||
if (jsonObject.is_array())
|
||||
DrawArray(key, jsonObject);
|
||||
else if (jsonObject.is_primitive())
|
||||
DrawPrimitive(key, jsonObject);
|
||||
else
|
||||
{
|
||||
ImGui::PushID(key.c_str());
|
||||
|
||||
if (ImGui::TreeNode(key.c_str()))
|
||||
{
|
||||
for (auto& el : jsonObject.items())
|
||||
DrawObject(el.key(), el.value());
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
void PacketInfo::Draw()
|
||||
{
|
||||
ImGui::PushID(this);
|
||||
|
||||
if (m_Header.empty())
|
||||
m_Header = fmt::format("[{}] {} | {}. Size: {}", magic_enum::enum_name(type()), id(), name(), size());
|
||||
|
||||
if (ImGui::TreeNode(m_Header.c_str()))
|
||||
{
|
||||
if (ImGui::Checkbox("## Beauty", &m_DrawBeauty) && m_DrawBeauty && m_JsonMessageBeauty.empty())
|
||||
{
|
||||
m_JsonMessageBeauty = m_JObject.dump(2);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
if (m_DrawBeauty)
|
||||
ImGui::InputTextMultiline("JSON Message", &m_JsonMessageBeauty);
|
||||
else
|
||||
ImGui::InputText("JSON Message", &m_Data.messageJson);
|
||||
|
||||
|
||||
DrawObject("Data", m_JObject);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "messages/PacketData.h"
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
class PacketInfo
|
||||
{
|
||||
public:
|
||||
PacketInfo(PacketData packetData);
|
||||
|
||||
PacketIOType type() const;
|
||||
uint32_t id() const;
|
||||
size_t size() const;
|
||||
int64_t time() const;
|
||||
std::string name() const;
|
||||
nlohmann::json object() const;
|
||||
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
nlohmann::json m_JObject;
|
||||
int64_t m_Time;
|
||||
|
||||
bool m_DrawBeauty;
|
||||
std::string m_JsonMessageBeauty;
|
||||
std::string m_Header;
|
||||
|
||||
PacketData m_Data;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,240 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "PacketParser.h"
|
||||
|
||||
#include "MessageManager.h"
|
||||
namespace sniffer
|
||||
{
|
||||
|
||||
PacketParser::PacketParser(const std::string& protoDirPath, const std::string& protoIDPath)
|
||||
: m_ProtoManager()
|
||||
{
|
||||
m_ProtoManager.Load(protoIDPath, protoDirPath);
|
||||
UpdateUnionPacketIDs();
|
||||
}
|
||||
|
||||
void PacketParser::SetProtoDir(const std::string& protoDir)
|
||||
{
|
||||
m_ProtoManager.LoadProtoDir(protoDir);
|
||||
UpdateUnionPacketIDs();
|
||||
}
|
||||
|
||||
void PacketParser::SetProtoIDPath(const std::string& protoIDPath)
|
||||
{
|
||||
m_ProtoManager.LoadProtoDir(protoIDPath);
|
||||
UpdateUnionPacketIDs();
|
||||
}
|
||||
|
||||
bool PacketParser::Parse(PacketData& data)
|
||||
{
|
||||
auto name = m_ProtoManager.GetName(data.messageID);
|
||||
if (!name)
|
||||
return false;
|
||||
|
||||
auto head = m_ProtoManager.GetJson("PacketHead", data.headRawData);
|
||||
if (!head)
|
||||
return false;
|
||||
|
||||
auto message = m_ProtoManager.GetJson(data.messageID, data.messageRawData);
|
||||
if (!message)
|
||||
return false;
|
||||
|
||||
data.name = *name;
|
||||
data.headJson = *head;
|
||||
data.messageJson = *message;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketParser::IsUnionPacket(const PacketData& data)
|
||||
{
|
||||
return m_UnionPacketIds.count(data.messageID) > 0;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseUnionPacket(const PacketData& data)
|
||||
{
|
||||
if (!IsUnionPacket(data))
|
||||
return {};
|
||||
|
||||
auto parseFunction = m_UnionPacketIds[data.messageID];
|
||||
return (this->*parseFunction)(data);
|
||||
}
|
||||
|
||||
PacketData PacketParser::CreateNestedPacket(const PacketData& parent, std::string bodyEncoded, int16_t packetID)
|
||||
{
|
||||
PacketData nestedPacketData = MessageManager::CreateMessage<PacketData>();
|
||||
nestedPacketData.headRawData = parent.headRawData;
|
||||
nestedPacketData.headJson = parent.headJson;
|
||||
nestedPacketData.messageRawData = util::base64_decode(bodyEncoded);
|
||||
nestedPacketData.messageID = packetID;
|
||||
nestedPacketData.valid = true;
|
||||
nestedPacketData.ioType = parent.ioType;
|
||||
nestedPacketData.parentPacketID = parent.sequenceID();
|
||||
|
||||
if (packetID != 0)
|
||||
Parse(nestedPacketData);
|
||||
|
||||
return nestedPacketData;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseUnionCmdNotify(const PacketData& data)
|
||||
{
|
||||
nlohmann::json cmdListObject = nlohmann::json::parse(data.messageJson);
|
||||
|
||||
std::vector<PacketData> packets;
|
||||
for (auto& cmd : cmdListObject["cmdList"])
|
||||
{
|
||||
auto nestedPacketData = CreateNestedPacket(data, cmd["body"], cmd["messageId"]);
|
||||
packets.push_back(nestedPacketData);
|
||||
|
||||
if (IsUnionPacket(nestedPacketData))
|
||||
{
|
||||
auto nestedNestedPackets = ParseUnionPacket(nestedPacketData);
|
||||
packets.insert(packets.end(), nestedNestedPackets.begin(), nestedNestedPackets.end());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
std::optional<PacketData> PacketParser::ParseAbilityInvokeEntry(const PacketData& parent, const nlohmann::json& entry)
|
||||
{
|
||||
static std::map<std::string, std::string> abilityArgument2Proto =
|
||||
{
|
||||
{ "ABILITY_META_MODIFIER_CHANGE", "AbilityMetaModifierChange" },
|
||||
{ "ABILITY_META_COMMAND_MODIFIER_CHANGE_REQUEST", "AbilityMetaCommandModifierChangeRequest" },
|
||||
{ "ABILITY_META_SPECIAL_FLOAT_ARGUMENT", "AbilityMetaSpecialFloatArgument" },
|
||||
{ "ABILITY_META_OVERRIDE_PARAM", "AbilityMetaOverrideParam" },
|
||||
{ "ABILITY_META_CLEAR_OVERRIDE_PARAM", "AbilityMetaClearOverrideParam" },
|
||||
{ "ABILITY_META_REINIT_OVERRIDEMAP", "AbilityMetaReinitOverridemap" },
|
||||
{ "ABILITY_META_GLOBAL_FLOAT_VALUE", "AbilityMetaGlobalFloatValue" },
|
||||
{ "ABILITY_META_CLEAR_GLOBAL_FLOAT_VALUE", "AbilityMetaClearGlobalFloatValue" },
|
||||
{ "ABILITY_META_ABILITY_ELEMENT_STRENGTH", "AbilityMetaAbilityElementStrength" },
|
||||
{ "ABILITY_META_ADD_OR_GET_ABILITY_AND_TRIGGER", "AbilityMetaAddOrGetAbilityAndTrigger" },
|
||||
{ "ABILITY_META_SET_KILLED_SETATE", "AbilityMetaSetKilledSetate" },
|
||||
{ "ABILITY_META_SET_ABILITY_TRIGGER", "AbilityMetaSetAbilityTrigger" },
|
||||
{ "ABILITY_META_ADD_NEW_ABILITY", "AbilityMetaAddNewAbility" },
|
||||
{ "ABILITY_META_REMOVE_ABILITY", "AbilityMetaRemoveAbility" },
|
||||
{ "ABILITY_META_SET_MODIFIER_APPLY_ENTITY", "AbilityMetaSetModifierApplyEntity" },
|
||||
{ "ABILITY_META_MODIFIER_DURABILITY_CHANGE", "AbilityMetaModifierDurabilityChange" },
|
||||
{ "ABILITY_META_ELEMENT_REACTION_VISUAL", "AbilityMetaElementReactionVisual" },
|
||||
{ "ABILITY_META_SET_POSE_PARAMETER", "AbilityMetaSetPoseParameter" },
|
||||
{ "ABILITY_META_UPDATE_BASE_REACTION_DAMAGE", "AbilityMetaUpdateBaseReactionDamage" },
|
||||
{ "ABILITY_META_TRIGGER_ELEMENT_REACTION", "AbilityMetaTriggerElementReaction" },
|
||||
{ "ABILITY_META_LOSE_HP", "AbilityMetaLoseHp" },
|
||||
{ "ABILITY_ACTION_TRIGGER_ABILITY", "AbilityActionTriggerAbility" },
|
||||
{ "ABILITY_ACTION_SET_CRASH_DAMAGE", "AbilityActionSetCrashDamage" },
|
||||
{ "ABILITY_ACTION_EFFECT", "AbilityActionEffect" },
|
||||
{ "ABILITY_ACTION_SUMMON", "AbilityActionSummon" },
|
||||
{ "ABILITY_ACTION_BLINK", "AbilityActionBlink" },
|
||||
{ "ABILITY_ACTION_CREATE_GADGET", "AbilityActionCreateGadget" },
|
||||
{ "ABILITY_ACTION_APPLY_LEVEL_MODIFIER", "AbilityActionApplyLevelModifier" },
|
||||
{ "ABILITY_ACTION_GENERATE_ELEM_BALL", "AbilityActionGenerateElemBall" },
|
||||
{ "ABILITY_ACTION_SET_RANDOM_OVERRIDE_MAP_VALUE", "AbilityActionSetRandomOverrideMapValue" },
|
||||
{ "ABILITY_ACTION_SERVER_MONSTER_LOG", "AbilityActionServerMonsterLog" },
|
||||
{ "ABILITY_ACTION_CREATE_TILE", "AbilityActionCreateTile" },
|
||||
{ "ABILITY_ACTION_DESTROY_TILE", "AbilityActionDestroyTile" },
|
||||
{ "ABILITY_ACTION_FIRE_AFTER_IMAGE", "AbilityActionFireAfterImage" },
|
||||
{ "ABILITY_MIXIN_AVATAR_STEER_BY_CAMERA", "AbilityMixinAvatarSteerByCamera" },
|
||||
{ "ABILITY_MIXIN_MONSTER_DEFEND", "AbilityMixinMonsterDefend" },
|
||||
{ "ABILITY_MIXIN_WIND_ZONE", "AbilityMixinWindZone" },
|
||||
{ "ABILITY_MIXIN_COST_STAMINA", "AbilityMixinCostStamina" },
|
||||
{ "ABILITY_MIXIN_ELITE_SHIELD", "AbilityMixinEliteShield" },
|
||||
{ "ABILITY_MIXIN_ELEMENT_SHIELD", "AbilityMixinElementShield" },
|
||||
{ "ABILITY_MIXIN_GLOBAL_SHIELD", "AbilityMixinGlobalShield" },
|
||||
{ "ABILITY_MIXIN_SHIELD_BAR", "AbilityMixinShieldBar" },
|
||||
{ "ABILITY_MIXIN_WIND_SEED_SPAWNER", "AbilityMixinWindSeedSpawner" },
|
||||
{ "ABILITY_MIXIN_DO_ACTION_BY_ELEMENT_REACTION", "AbilityMixinDoActionByElementReaction" },
|
||||
{ "ABILITY_MIXIN_FIELD_ENTITY_COUNT_CHANGE", "AbilityMixinFieldEntityCountChange" },
|
||||
{ "ABILITY_MIXIN_SCENE_PROP_SYNC", "AbilityMixinScenePropSync" },
|
||||
{ "ABILITY_MIXIN_WIDGET_MP_SUPPORT", "AbilityMixinWidgetMpSupport" }
|
||||
};
|
||||
|
||||
if (entry.count("abilityData") == 0 || entry.count("argumentType") == 0)
|
||||
return {};
|
||||
|
||||
std::string argumentType = entry["argumentType"];
|
||||
if (abilityArgument2Proto.count(argumentType) == 0)
|
||||
return {};
|
||||
|
||||
PacketData nestedPacketData = CreateNestedPacket(parent, entry["abilityData"]);
|
||||
nestedPacketData.name = abilityArgument2Proto[argumentType];
|
||||
|
||||
auto jsonData = m_ProtoManager.GetJson(nestedPacketData.name, nestedPacketData.messageRawData);
|
||||
nestedPacketData.messageJson = jsonData ? *jsonData : "{}";
|
||||
return nestedPacketData;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseAbilityInvocationsNotify(const PacketData& data)
|
||||
{
|
||||
auto combatJsonObject = nlohmann::json::parse(data.messageJson);
|
||||
std::vector<PacketData> packets = {};
|
||||
for (auto& invokeEntry : combatJsonObject["invokes"])
|
||||
{
|
||||
auto abilityPacketData = ParseAbilityInvokeEntry(data, invokeEntry);
|
||||
if (abilityPacketData)
|
||||
packets.push_back(*abilityPacketData);
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
std::optional<PacketData> PacketParser::ParseCombatInvokeEntry(const PacketData& parent, const nlohmann::json& entry)
|
||||
{
|
||||
static std::map<std::string, std::string> combateTypeProtos = {
|
||||
{ "ENTITY_MOVE", "EntityMoveInfo" },
|
||||
{ "COMBAT_EVT_BEING_HIT", "EvtBeingHitInfo" },
|
||||
{ "COMBAT_ANIMATOR_STATE_CHANGED", "EvtAnimatorStateChangedInfo" },
|
||||
{ "COMBAT_FACE_TO_DIR", "EvtFaceToDirInfo" },
|
||||
{ "COMBAT_SET_ATTACK_TARGET", "EvtSetAttackTargetInfo" },
|
||||
{ "COMBAT_RUSH_MOVE", "EvtRushMoveInfo" },
|
||||
{ "COMBAT_ANIMATOR_PARAMETER_CHANGED", "EvtAnimatorParameterInfo" },
|
||||
{ "SYNC_ENTITY_POSITION", "EvtSyncEntityPositionInfo" },
|
||||
{ "COMBAT_STEER_MOTION_INFO", "EvtCombatSteerMotionInfo" },
|
||||
{ "COMBAT_FORCE_SET_POSITION_INFO", "EvtCombatForceSetPosInfo" },
|
||||
{ "COMBAT_FORCE_SET_POS_INFO", "EvtCombatForceSetPosInfo" },
|
||||
{ "COMBAT_COMPENSATE_POS_DIFF", "EvtCompensatePosDiffInfo" },
|
||||
{ "COMBAT_MONSTER_DO_BLINK", "EvtMonsterDoBlink" },
|
||||
{ "COMBAT_FIXED_RUSH_MOVE", "EvtFixedRushMove" },
|
||||
{ "COMBAT_SYNC_TRANSFORM", "EvtSyncTransform" },
|
||||
{ "COMBAT_LIGHT_CORE_MOVE", "EvtLightCoreMove" }
|
||||
};
|
||||
|
||||
if (!entry["argumentType"].is_string())
|
||||
return {};
|
||||
|
||||
std::string argumentType = entry["argumentType"];
|
||||
|
||||
if (combateTypeProtos.count(argumentType) == 0)
|
||||
{
|
||||
LOG_WARNING("Failed to find argument type %s", argumentType.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
PacketData nestedPacketData = CreateNestedPacket(parent, entry["combatData"]);
|
||||
nestedPacketData.name = combateTypeProtos[argumentType];
|
||||
|
||||
auto jsonData = m_ProtoManager.GetJson(nestedPacketData.name, nestedPacketData.messageRawData);
|
||||
nestedPacketData.messageJson = jsonData ? *jsonData : "{}";
|
||||
return nestedPacketData;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseCombatInvocationsNotify(const PacketData& data)
|
||||
{
|
||||
auto combatJsonObject = nlohmann::json::parse(data.messageJson);
|
||||
std::vector<PacketData> packets = {};
|
||||
for (auto& invokeEntry : combatJsonObject["invokeList"])
|
||||
{
|
||||
auto combatPacketData = ParseCombatInvokeEntry(data, invokeEntry);
|
||||
if (combatPacketData)
|
||||
packets.push_back(*combatPacketData);
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
void PacketParser::UpdateUnionPacketIDs()
|
||||
{
|
||||
m_UnionPacketIds.clear();
|
||||
for (auto& [unionPacketName, parserFunc] : s_UnionPacketNames)
|
||||
{
|
||||
m_UnionPacketIds[m_ProtoManager.GetId(unionPacketName)] = parserFunc;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
#include "messages/PacketData.h"
|
||||
#include "ProtoManager.h"
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
class PacketParser
|
||||
{
|
||||
public:
|
||||
PacketParser(const std::string& protoDirPath, const std::string& protoIDPath);
|
||||
|
||||
void SetProtoDir(const std::string& protoDir);
|
||||
void SetProtoIDPath(const std::string& protoIDPath);
|
||||
|
||||
bool Parse(PacketData& data);
|
||||
bool IsUnionPacket(const PacketData& data);
|
||||
std::vector<PacketData> ParseUnionPacket(const PacketData& data);
|
||||
|
||||
private:
|
||||
PacketData CreateNestedPacket(const PacketData& parent, std::string bodyEncoded, int16_t packetID = 0);
|
||||
std::vector<PacketData> ParseUnionCmdNotify(const PacketData& data);
|
||||
|
||||
std::optional<PacketData> ParseAbilityInvokeEntry(const PacketData& parent, const nlohmann::json& entry);
|
||||
std::vector<PacketData> ParseAbilityInvocationsNotify(const PacketData& data);
|
||||
|
||||
std::optional<PacketData> ParseCombatInvokeEntry(const PacketData& parent, const nlohmann::json& entry);
|
||||
std::vector<PacketData> ParseCombatInvocationsNotify(const PacketData& data);
|
||||
|
||||
using UnionPacketParserFunc = std::vector<PacketData>(PacketParser::*)(const PacketData& data);
|
||||
inline static std::map<std::string, UnionPacketParserFunc> s_UnionPacketNames =
|
||||
{
|
||||
{ "UnionCmdNotify", &ParseUnionCmdNotify},
|
||||
|
||||
{ "EntityAbilityInvokeEntry", &ParseAbilityInvocationsNotify },
|
||||
{ "ClientAbilityInitFinishNotify", &ParseAbilityInvocationsNotify },
|
||||
{ "ClientAbilityChangeNotify", &ParseAbilityInvocationsNotify },
|
||||
{ "AbilityInvocationsNotify", &ParseAbilityInvocationsNotify },
|
||||
|
||||
{ "CombatInvocationsNotify", &ParseCombatInvocationsNotify}
|
||||
};
|
||||
|
||||
sniffer::ProtoManager m_ProtoManager;
|
||||
std::map<uint32_t, UnionPacketParserFunc> m_UnionPacketIds;
|
||||
|
||||
void UpdateUnionPacketIDs();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,18 +11,12 @@
|
||||
namespace cheat::feature
|
||||
{
|
||||
PacketSniffer::PacketSniffer() : Feature(),
|
||||
NF(m_CapturingEnabled, "Capturing", "PacketSniffer", false),
|
||||
NF(m_ManipulationEnabled, "Manipulation", "PacketSniffer", false),
|
||||
NF(m_PipeEnabled, "Pipe", "PacketSniffer", false)
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
, NF(m_ProtoDirPath, "Proto Dir Path", "PacketSniffer", ""),
|
||||
NF(m_ProtoIDFilePath, "Proto ID File Path", "PacketSniffer", ""),
|
||||
m_PacketParser(m_ProtoDirPath, m_ProtoIDFilePath)
|
||||
#endif
|
||||
NF(f_CaptureEnabled, "Capturing", "PacketSniffer", false),
|
||||
NF(f_ManipulationEnabled, "Manipulation", "PacketSniffer", false),
|
||||
NF(f_PipeName, "Pipe name", "PacketSniffer", "genshin_packet_pipe")
|
||||
|
||||
{
|
||||
sniffer::MessageManager::Connect("genshin_packet_pipe");
|
||||
sniffer::MessageManager::Connect(f_PipeName.value());
|
||||
|
||||
HookManager::install(app::Kcp_KcpNative_kcp_client_send_packet, KcpNative_kcp_client_send_packet_Hook);
|
||||
HookManager::install(app::MoleMole_KcpClient_TryDequeueEvent, KcpClient_TryDequeueEvent_Hook);
|
||||
@ -34,80 +28,14 @@ namespace cheat::feature
|
||||
return info;
|
||||
}
|
||||
|
||||
bool PacketSniffer::OnCapturingChanged()
|
||||
{
|
||||
#ifdef _PACKET_SNIFFER
|
||||
if (!m_CapturingEnabled)
|
||||
return true;
|
||||
|
||||
if (!m_ProtoDirPath.value().empty() && !m_ProtoIDFilePath.value().empty())
|
||||
{
|
||||
m_PacketParser.SetProtoIDPath(m_ProtoIDFilePath);
|
||||
m_PacketParser.SetProtoDir(m_ProtoDirPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PacketSniffer::DrawMain()
|
||||
{
|
||||
|
||||
//ImGui::Text("Dev: for working needs server for named pipe 'genshin_packet_pipe'.\nCheck 'packet-handler' project like example.");
|
||||
if (ConfigWidget(m_CapturingEnabled, "Enabling capturing of packet info and sending to pipe, if it exists."))
|
||||
{
|
||||
bool result = OnCapturingChanged();
|
||||
if (!result)
|
||||
{
|
||||
m_CapturingEnabled = false;
|
||||
ImGui::OpenPopup("Error");
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("Error"))
|
||||
{
|
||||
ImGui::Text("Please fill 'Proto Dir Path' and 'Proto ID File Path' before enabling capture.");
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
auto& window = sniffer::SnifferWindow::GetInstance();
|
||||
ConfigWidget(window.m_Show, "Show capturing window.");
|
||||
|
||||
ConfigWidget(m_PipeEnabled, "Enable sending of packet data to pipe with name 'genshin_packet_pipe'.\n"\
|
||||
"This feature can be used with external monitoring tools.");
|
||||
//ConfigWidget(m_ManipulationEnabled, "Enabling manipulation packet feature, that allows to replace, block incoming/outcoming packets." \
|
||||
// "\nThis feature often needs, to read-write pipe operation, so can decrease network bandwidth.");
|
||||
|
||||
if (m_CapturingEnabled)
|
||||
{
|
||||
ImGui::Text("These parameters can only be changed when 'Capturing' is disabled.");
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
|
||||
ConfigWidget(m_ProtoDirPath, "Path to directory containing Genshin .proto files.");
|
||||
ConfigWidget(m_ProtoIDFilePath, "Path to JSON file containing packet id->packet name info.");
|
||||
|
||||
if (m_CapturingEnabled)
|
||||
ImGui::EndDisabled();
|
||||
#else
|
||||
ImGui::Text("When capture is enabled, raw packet data will be send to named pipe: 'genshin_packet_pipe'.");
|
||||
ImGui::Text("'Raw' means that you should to parse protobuf structure by yourself.");
|
||||
#endif
|
||||
ImGui::Text("Dev: for working needs server for named pipe with specified name.\nCheck 'packet-handler' project like example.");
|
||||
ConfigWidget(f_PipeName, "Pipe name for connecting. Changes will apply after next game launch.");
|
||||
ConfigWidget(f_CaptureEnabled, "Enable capturing of packet info and sending to pipe, if it exists.");
|
||||
ConfigWidget(f_ManipulationEnabled, "Enable blocking and modifying packets by sniffer, can cause network lags.");
|
||||
}
|
||||
|
||||
void PacketSniffer::DrawExternal()
|
||||
{
|
||||
#ifdef _PACKET_SNIFFER
|
||||
auto& window = sniffer::SnifferWindow::GetInstance();
|
||||
if (window.m_Show)
|
||||
window.Draw();
|
||||
#endif
|
||||
}
|
||||
|
||||
PacketSniffer& PacketSniffer::GetInstance()
|
||||
{
|
||||
static PacketSniffer instance;
|
||||
@ -141,7 +69,10 @@ namespace cheat::feature
|
||||
|
||||
bool PacketSniffer::OnPacketIO(app::KcpPacket_1* packet, PacketIOType type)
|
||||
{
|
||||
if (!m_CapturingEnabled)
|
||||
if (!sniffer::MessageManager::IsConnected())
|
||||
return true;
|
||||
|
||||
if (!f_CaptureEnabled)
|
||||
return true;
|
||||
|
||||
PacketData packetData = ParseRawPacketData((char*)packet->data, packet->dataLen);
|
||||
@ -149,30 +80,10 @@ namespace cheat::feature
|
||||
return true;
|
||||
|
||||
packetData.ioType = type;
|
||||
packetData.blockModeEnabled = m_ManipulationEnabled;
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
bool parsed = m_PacketParser.Parse(packetData);
|
||||
if (!parsed)
|
||||
return true;
|
||||
|
||||
sniffer::SnifferWindow::GetInstance().OnPacketIO({packetData});
|
||||
#endif
|
||||
|
||||
packetData.blockModeEnabled = f_ManipulationEnabled;
|
||||
sniffer::MessageManager::Send(packetData);
|
||||
|
||||
bool canceled = m_ManipulationEnabled && ProcessModifiedData(packet);
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
if (m_PacketParser.IsUnionPacket(packetData))
|
||||
{
|
||||
for (auto& nestedPacketData : m_PacketParser.ParseUnionPacket(packetData))
|
||||
{
|
||||
sniffer::SnifferWindow::GetInstance().OnPacketIO({ nestedPacketData });
|
||||
sniffer::MessageManager::Send(nestedPacketData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
bool canceled = f_ManipulationEnabled && ProcessModifiedData(packet);
|
||||
|
||||
return !canceled;
|
||||
}
|
||||
|
@ -12,41 +12,25 @@
|
||||
|
||||
#include "MessageManager.h"
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
#include "PacketParser.h"
|
||||
#include "PacketInfo.h"
|
||||
#endif
|
||||
|
||||
namespace cheat::feature
|
||||
{
|
||||
|
||||
class PacketSniffer : public Feature
|
||||
{
|
||||
public:
|
||||
config::Field<bool> m_CapturingEnabled;
|
||||
config::Field<bool> m_ManipulationEnabled;
|
||||
config::Field<bool> m_PipeEnabled;
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
config::Field<std::string> m_ProtoDirPath;
|
||||
config::Field<std::string> m_ProtoIDFilePath;
|
||||
#endif
|
||||
config::Field<bool> f_CaptureEnabled;
|
||||
config::Field<bool> f_ManipulationEnabled;
|
||||
config::Field<std::string> f_PipeName;
|
||||
|
||||
static PacketSniffer& GetInstance();
|
||||
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
|
||||
void DrawExternal() final;
|
||||
|
||||
private:
|
||||
#ifdef _PACKET_SNIFFER
|
||||
sniffer::PacketParser m_PacketParser;
|
||||
#endif
|
||||
PacketSniffer();
|
||||
PacketData ParseRawPacketData(char* encryptedData, uint32_t length);
|
||||
bool OnCapturingChanged();
|
||||
|
||||
PacketData ParseRawPacketData(char* encryptedData, uint32_t length);
|
||||
static char* EncryptXor(void* content, uint32_t length);
|
||||
static bool KcpClient_TryDequeueEvent_Hook(void* __this, app::ClientKcpEvent* evt, MethodInfo* method);
|
||||
static int32_t KcpNative_kcp_client_send_packet_Hook(void* kcp_client, app::KcpPacket_1* packet, MethodInfo* method);
|
||||
|
@ -1,125 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "ProtoManager.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
|
||||
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
|
||||
{
|
||||
LOG_ERROR("Error while parsing %s file, line %d, column %d, error: %s\n", filename.c_str(), line, column, message.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
void ProtoManager::LoadProtoDir(const std::string& dirPath)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
diskTree = std::shared_ptr<google::protobuf::compiler::DiskSourceTree>(new google::protobuf::compiler::DiskSourceTree());
|
||||
if (!dirPath.empty())
|
||||
diskTree->MapPath("", dirPath);
|
||||
|
||||
auto errorCollector = new ErrorCollector();
|
||||
importer = std::shared_ptr<google::protobuf::compiler::Importer>(new google::protobuf::compiler::Importer(diskTree.get(), errorCollector));
|
||||
factory = std::shared_ptr<google::protobuf::DynamicMessageFactory>(new google::protobuf::DynamicMessageFactory(importer->pool()));
|
||||
}
|
||||
|
||||
void ProtoManager::LoadIDFile(const std::string& filepath)
|
||||
{
|
||||
if (filepath.empty())
|
||||
return;
|
||||
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
nameMap.clear();
|
||||
|
||||
std::ifstream file;
|
||||
file.open(filepath);
|
||||
if (!file.is_open())
|
||||
{
|
||||
LOG_WARNING("Failed to load proto id file.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto content = nlohmann::json::parse(file);
|
||||
for (nlohmann::json::iterator it = content.begin(); it != content.end(); ++it)
|
||||
{
|
||||
auto id = std::stoi(it.key().c_str());
|
||||
nameMap[id] = it.value();
|
||||
idMap[it.value()] = id;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
google::protobuf::Message* ProtoManager::ParseMessage(const std::string& name, std::vector<byte> data)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
auto fileDescriptor = importer->Import(name + ".proto");
|
||||
if (fileDescriptor == nullptr || fileDescriptor->message_type_count() == 0)
|
||||
return nullptr;
|
||||
|
||||
auto message = factory->GetPrototype(fileDescriptor->message_type(0))->New();
|
||||
|
||||
std::string stringData((char*)data.data(), data.size());
|
||||
message->ParseFromString(stringData);
|
||||
return message;
|
||||
}
|
||||
|
||||
ProtoManager::ProtoManager() {}
|
||||
|
||||
void ProtoManager::Load(const std::string& idFilePath, const std::string& protoDir)
|
||||
{
|
||||
LoadIDFile(idFilePath);
|
||||
LoadProtoDir(protoDir);
|
||||
}
|
||||
|
||||
std::optional <std::string> ProtoManager::GetJson(const std::string& name, std::vector<byte>& data)
|
||||
{
|
||||
auto message = ParseMessage(name, data);
|
||||
if (message == nullptr)
|
||||
{
|
||||
LOG_ERROR("Failed to parse message with name %s.", name.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string jsonMessage = {};
|
||||
google::protobuf::util::MessageToJsonString(*message, &jsonMessage);
|
||||
|
||||
delete message;
|
||||
|
||||
return jsonMessage;
|
||||
}
|
||||
|
||||
std::optional<std::string> ProtoManager::GetJson(uint32_t id, std::vector<byte>& data)
|
||||
{
|
||||
auto name = GetName(id);
|
||||
if (!name)
|
||||
return {};
|
||||
|
||||
return GetJson(*name, data);
|
||||
}
|
||||
|
||||
std::optional<std::string> ProtoManager::GetName(uint32_t id)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
if (nameMap.count(id) == 0)
|
||||
{
|
||||
LOG_WARNING("Failed to find proto with id %u", id);
|
||||
return {};
|
||||
}
|
||||
|
||||
return nameMap[id];
|
||||
}
|
||||
|
||||
uint16_t ProtoManager::GetId(const std::string& name)
|
||||
{
|
||||
return idMap.count(name) == 0 ? 0 : idMap[name];
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
#include <google/protobuf/compiler/importer.h>
|
||||
#include <google/protobuf/dynamic_message.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/util/json_util.h>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
class ProtoManager
|
||||
{
|
||||
public:
|
||||
ProtoManager();
|
||||
|
||||
std::optional<std::string> GetJson(uint32_t id, std::vector<byte>& data);
|
||||
std::optional<std::string> GetJson(const std::string& name, std::vector<byte>& byte);
|
||||
std::optional<std::string> GetName(uint32_t id);
|
||||
uint16_t GetId(const std::string& name);
|
||||
|
||||
void Load(const std::string& idFilePath, const std::string& protoDir);
|
||||
void LoadIDFile(const std::string& filepath);
|
||||
void LoadProtoDir(const std::string& dirPath);
|
||||
|
||||
private:
|
||||
std::mutex _mutex;
|
||||
std::shared_ptr<google::protobuf::compiler::Importer> importer;
|
||||
std::shared_ptr<google::protobuf::DynamicMessageFactory> factory;
|
||||
std::shared_ptr<google::protobuf::compiler::DiskSourceTree> diskTree;
|
||||
|
||||
std::map<uint16_t, std::string> nameMap;
|
||||
std::map<std::string, uint16_t> idMap;
|
||||
|
||||
google::protobuf::Message* ParseMessage(const std::string& name, std::vector<byte> data);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,547 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "SnifferWindow.h"
|
||||
#include <imgui_internal.h>
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
#include <regex>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
SnifferWindow& SnifferWindow::GetInstance()
|
||||
{
|
||||
static SnifferWindow instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static auto nameCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.name() < b.name(); };
|
||||
static auto sizeCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.size() < b.size(); };
|
||||
static auto idCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.id() < b.id(); };
|
||||
static auto typeCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.type() < b.type(); };
|
||||
static auto timeCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.time() < b.time(); };
|
||||
|
||||
void SnifferWindow::OnPacketIO(const PacketInfo& info)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(m_CapturePacketLock);
|
||||
|
||||
if (m_SortValue == SortValue::Time)
|
||||
{
|
||||
m_CapturedPackets.push_back(info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.push_back(info);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m_SortValue)
|
||||
{
|
||||
case sniffer::SnifferWindow::SortValue::Name:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Size:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, sizeCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Id:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, idCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Type:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, typeCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
void SnifferWindow::Draw()
|
||||
{
|
||||
|
||||
const std::lock_guard<std::mutex> lock(m_CapturePacketLock);
|
||||
|
||||
bool showPrev = m_Show;
|
||||
bool windowShowed = ImGui::Begin("Packet sniffer", m_Show);
|
||||
|
||||
if (showPrev != m_Show)
|
||||
m_Show.FireChanged();
|
||||
|
||||
if (!windowShowed)
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ComboEnum("## SortValue", &m_SortValue))
|
||||
{
|
||||
switch (m_SortValue)
|
||||
{
|
||||
case sniffer::SnifferWindow::SortValue::Name:
|
||||
m_CapturedPackets.sort(nameCompare);
|
||||
m_CachedPackets.sort(nameCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Size:
|
||||
m_CapturedPackets.sort(sizeCompare);
|
||||
m_CachedPackets.sort(sizeCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Id:
|
||||
m_CapturedPackets.sort(idCompare);
|
||||
m_CachedPackets.sort(idCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Type:
|
||||
m_CapturedPackets.sort(typeCompare);
|
||||
m_CachedPackets.sort(typeCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Time:
|
||||
m_CapturedPackets.sort(timeCompare);
|
||||
m_CachedPackets.sort(timeCompare);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ComboEnum("Sort ## SortType", &m_SortType);
|
||||
|
||||
m_FilterGroup.Draw(false);
|
||||
|
||||
if (ImGui::Button("Apply filter"))
|
||||
{
|
||||
m_CachedPackets.clear();
|
||||
for (auto& info : m_CapturedPackets)
|
||||
{
|
||||
if (m_FilterGroup.Execute(info))
|
||||
{
|
||||
m_CachedPackets.push_back(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Clear history"))
|
||||
{
|
||||
m_CapturedPackets.clear();
|
||||
m_CachedPackets.clear();
|
||||
}
|
||||
|
||||
ImGui::BeginChild("Packets");
|
||||
|
||||
if (m_SortType == SortType::Asc)
|
||||
{
|
||||
for (auto& info : m_CachedPackets)
|
||||
info.Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto it = m_CachedPackets.rbegin(); it != m_CachedPackets.rend(); it++)
|
||||
it->Draw();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
SnifferWindow::SnifferWindow() :
|
||||
NF(m_Show, "Show capturing window", "SnifferWindow", false),
|
||||
m_SortType(SortType::Desc),
|
||||
m_SortValue(SortValue::Time)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Filter::Draw(bool canBeRemoved)
|
||||
{
|
||||
ImGui::PushID(this);
|
||||
ComboEnum("## ObjectType", &m_ObjectType); ImGui::SameLine();
|
||||
ComboEnum("## CompareType", &m_CompareType); ImGui::SameLine();
|
||||
|
||||
if (m_ObjectType != ObjectType::AnyValue)
|
||||
{
|
||||
ImGui::SetNextItemWidth(200);
|
||||
ImGui::InputText("## Key", &m_KeyPattern); ImGui::SameLine();
|
||||
}
|
||||
|
||||
if (m_ObjectType == ObjectType::AnyValue || m_ObjectType == ObjectType::KeyValue)
|
||||
{
|
||||
ImGui::SetNextItemWidth(200);
|
||||
ImGui::InputText("## Value", &m_ObjectPattern); ImGui::SameLine();
|
||||
}
|
||||
|
||||
bool removed = false;
|
||||
if (canBeRemoved && ImGui::Button("Remove"))
|
||||
removed = true;
|
||||
|
||||
ImGui::PopID();
|
||||
return removed;
|
||||
}
|
||||
|
||||
static std::vector<std::string> StringSplit(const std::string& delimiter, const std::string& content)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
size_t pos = 0;
|
||||
size_t prevPos = 0;
|
||||
std::string token;
|
||||
while ((pos = content.find(delimiter, prevPos)) != std::string::npos) {
|
||||
token = content.substr(prevPos, pos - prevPos);
|
||||
tokens.push_back(token);
|
||||
prevPos = pos + delimiter.length();
|
||||
}
|
||||
tokens.push_back(content.substr(prevPos));
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static bool ApplyCompareString(const std::string& value, const std::string& pattern, Filter::CompareType compare)
|
||||
{
|
||||
std::string lowerValue = value;
|
||||
std::transform(lowerValue.begin(), lowerValue.end(), lowerValue.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
std::string lowerPattern = pattern;
|
||||
std::transform(lowerPattern.begin(), lowerPattern.end(), lowerPattern.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
switch (compare)
|
||||
{
|
||||
case sniffer::Filter::CompareType::Regex:
|
||||
{
|
||||
std::regex _regex(lowerPattern.c_str());
|
||||
return std::regex_match(lowerValue, _regex);
|
||||
}
|
||||
case sniffer::Filter::CompareType::Equal:
|
||||
return lowerValue == lowerPattern;
|
||||
case sniffer::Filter::CompareType::Contains:
|
||||
return lowerValue.find(lowerPattern) != std::string::npos;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static bool ApplyCompareAnyType(const nlohmann::json& object, const T& value, Filter::CompareType compare)
|
||||
{
|
||||
switch (compare)
|
||||
{
|
||||
case sniffer::Filter::CompareType::Equal:
|
||||
return object == value;
|
||||
case sniffer::Filter::CompareType::Less:
|
||||
return object < value;
|
||||
case sniffer::Filter::CompareType::LessEqual:
|
||||
return object <= value;
|
||||
case sniffer::Filter::CompareType::More:
|
||||
return object > value;
|
||||
case sniffer::Filter::CompareType::MoreEqual:
|
||||
return object >= value;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ApplyCompareValue(const nlohmann::json& object, const std::string& pattern, Filter::CompareType compare)
|
||||
{
|
||||
if (object.is_string())
|
||||
return ApplyCompareString(object, pattern, compare);
|
||||
|
||||
if (object.is_boolean())
|
||||
{
|
||||
if (compare != Filter::CompareType::Equal)
|
||||
return false;
|
||||
|
||||
bool value = pattern == "true" || pattern == "1";
|
||||
return object == value;
|
||||
}
|
||||
|
||||
if (!object.is_number())
|
||||
return false;
|
||||
|
||||
if (object.is_number_float())
|
||||
{
|
||||
auto value = std::stof(pattern);
|
||||
return ApplyCompareAnyType(object, value, compare);
|
||||
}
|
||||
|
||||
if (object.is_number_integer())
|
||||
{
|
||||
auto value = std::stoi(pattern);
|
||||
return ApplyCompareAnyType(object, value, compare);
|
||||
}
|
||||
|
||||
if (object.is_number_unsigned())
|
||||
{
|
||||
auto value = std::stoul(pattern);
|
||||
return ApplyCompareAnyType(object, value, compare);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HasValue(const nlohmann::json& object, const std::string& pattern, Filter::CompareType compare)
|
||||
{
|
||||
if (object.is_array())
|
||||
{
|
||||
for (auto& nested : object)
|
||||
{
|
||||
if (HasValue(nested, pattern, compare))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (object.is_object())
|
||||
{
|
||||
for (auto& item : object.items())
|
||||
{
|
||||
if (HasValue(item.value(), pattern, compare))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return ApplyCompareValue(object, pattern, compare);
|
||||
}
|
||||
|
||||
bool Filter::FindAnyValue(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_ObjectPattern.empty())
|
||||
return true;
|
||||
|
||||
return HasValue(info.object(), m_ObjectPattern, m_CompareType);
|
||||
}
|
||||
|
||||
bool Filter::FindAnyKey(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_KeyPattern.empty())
|
||||
return true;
|
||||
|
||||
return !FindKeys(info, true).empty();
|
||||
}
|
||||
|
||||
bool Filter::FindKeyValue(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_KeyPattern.empty())
|
||||
return true;
|
||||
|
||||
auto objects = FindKeys(info);
|
||||
for (auto& obj : objects)
|
||||
{
|
||||
if (ApplyCompareValue(info.object(), m_ObjectPattern, m_CompareType))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::vector<nlohmann::json> FindKey(const nlohmann::json& object, const std::string& pattern, Filter::CompareType compareType, bool onlyFirst, bool recursive)
|
||||
{
|
||||
std::vector<nlohmann::json> objects;
|
||||
|
||||
if (object.is_array())
|
||||
{
|
||||
if (!recursive)
|
||||
return objects;
|
||||
|
||||
for (auto& nested : object)
|
||||
{
|
||||
auto nestedResult = FindKey(nested, pattern, compareType, onlyFirst, recursive);
|
||||
if (nestedResult.size() > 0)
|
||||
{
|
||||
objects.insert(objects.end(), nestedResult.begin(), nestedResult.end());
|
||||
if (onlyFirst)
|
||||
return objects;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (object.is_object())
|
||||
{
|
||||
for (auto& item : object.items())
|
||||
{
|
||||
bool correct = ApplyCompareString(item.key(), pattern, compareType);
|
||||
if (!correct)
|
||||
{
|
||||
if (recursive)
|
||||
{
|
||||
auto nestedResult = FindKey(item.value(), pattern, compareType, onlyFirst, recursive);
|
||||
if (nestedResult.size() > 0)
|
||||
{
|
||||
objects.insert(objects.end(), nestedResult.begin(), nestedResult.end());
|
||||
if (onlyFirst)
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
objects.push_back(item.value());
|
||||
if (onlyFirst)
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
return objects;
|
||||
|
||||
}
|
||||
|
||||
std::vector<nlohmann::json> Filter::FindKeys(const sniffer::PacketInfo& info, bool onlyFirst)
|
||||
{
|
||||
auto equalType = m_ObjectType == ObjectType::KeyValue ? CompareType::Regex : m_CompareType;
|
||||
auto tokens = StringSplit("::", m_KeyPattern);
|
||||
|
||||
std::string& mainToken = tokens[0];
|
||||
if (tokens.size() == 1)
|
||||
{
|
||||
auto mainObjects = FindKey(info.object(), mainToken, equalType, onlyFirst, true);
|
||||
return mainObjects;
|
||||
}
|
||||
|
||||
auto objects = FindKey(info.object(), m_KeyPattern, equalType, false, true);
|
||||
|
||||
for (auto it = tokens.begin() + 1; it != tokens.end(); it++)
|
||||
{
|
||||
if (objects.empty())
|
||||
return {};
|
||||
|
||||
bool last_token = (tokens.end() - 1) == it;
|
||||
bool _onlyFirst = onlyFirst && last_token;
|
||||
|
||||
objects = FindKey(objects, *it, equalType, _onlyFirst, false);
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
||||
bool Filter::Execute(const sniffer::PacketInfo& info)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (m_ObjectType)
|
||||
{
|
||||
case sniffer::Filter::ObjectType::KeyValue:
|
||||
return FindKeyValue(info);
|
||||
case sniffer::Filter::ObjectType::AnyKey:
|
||||
return FindAnyKey(info);
|
||||
case sniffer::Filter::ObjectType::AnyValue:
|
||||
return FindAnyValue(info);
|
||||
case sniffer::Filter::ObjectType::Name:
|
||||
return ApplyCompareString(info.name(), m_KeyPattern, m_CompareType);
|
||||
case sniffer::Filter::ObjectType::PacketId:
|
||||
return ApplyCompareString(std::to_string(info.id()), m_KeyPattern, m_CompareType);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (const std::regex_error& e)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nlohmann::json Filter::Serialize()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
Filter::Filter()
|
||||
: m_CompareType(CompareType::Equal),
|
||||
m_ObjectType(ObjectType::KeyValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Filter::Filter(nlohmann::json& object)
|
||||
: Filter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool FilterGroup::Draw(bool canBeRemoved)
|
||||
{
|
||||
ImGui::PushID(this);
|
||||
|
||||
bool removed = false;
|
||||
auto name = fmt::format("Group {}", magic_enum::enum_name(m_Rule));
|
||||
ImGui::BeginGroupPanel(name.c_str());
|
||||
{
|
||||
ComboEnum("Rule", &m_Rule);
|
||||
|
||||
if (canBeRemoved)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Remove"))
|
||||
removed = true;
|
||||
}
|
||||
|
||||
std::optional<IFilter*> removeFilter = {};
|
||||
for (auto& filter : m_Filters)
|
||||
{
|
||||
if (filter->Draw())
|
||||
removeFilter = filter;
|
||||
}
|
||||
|
||||
if (removeFilter)
|
||||
{
|
||||
m_Filters.remove(*removeFilter);
|
||||
delete* removeFilter;
|
||||
}
|
||||
|
||||
if (ImGui::Button("Add group", ImVec2(70, 0)))
|
||||
m_Filters.push_back(new FilterGroup());
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Add filter", ImVec2(70, 0)))
|
||||
m_Filters.push_back(new Filter());
|
||||
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
bool FilterGroup::Execute(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_Filters.empty())
|
||||
return true;
|
||||
|
||||
for (auto& filter : m_Filters)
|
||||
{
|
||||
bool result = filter->Execute(info);
|
||||
if (m_Rule == Rule::AND && !result)
|
||||
return false;
|
||||
|
||||
if (m_Rule == Rule::NOT && result)
|
||||
return false;
|
||||
|
||||
if (m_Rule == Rule::OR && result)
|
||||
return true;
|
||||
}
|
||||
return m_Rule != Rule::OR;
|
||||
}
|
||||
|
||||
|
||||
nlohmann::json FilterGroup::Serialize()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
FilterGroup::FilterGroup() :
|
||||
m_Rule(Rule::AND),
|
||||
m_Filters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FilterGroup::FilterGroup(nlohmann::json& object) : FilterGroup()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
#pragma once
|
||||
#include "PacketInfo.h"
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
|
||||
class IFilter
|
||||
{
|
||||
public:
|
||||
virtual bool Draw(bool canBeRemoved = true) = 0;
|
||||
virtual bool Execute(const sniffer::PacketInfo& info) = 0;
|
||||
virtual nlohmann::json Serialize() = 0;
|
||||
};
|
||||
|
||||
|
||||
class Filter : public IFilter
|
||||
{
|
||||
public:
|
||||
enum class CompareType
|
||||
{
|
||||
Regex, Equal, Contains, Less, LessEqual, More, MoreEqual
|
||||
};
|
||||
|
||||
enum class ObjectType
|
||||
{
|
||||
KeyValue, AnyKey, AnyValue, Name, PacketId
|
||||
};
|
||||
|
||||
virtual bool Draw(bool canBeRemoved = true) override;
|
||||
virtual bool Execute(const sniffer::PacketInfo& info) override;
|
||||
|
||||
virtual nlohmann::json Serialize() override;
|
||||
|
||||
Filter();
|
||||
Filter(nlohmann::json& object);
|
||||
private:
|
||||
|
||||
bool FindAnyValue(const sniffer::PacketInfo& info);
|
||||
bool FindAnyKey(const sniffer::PacketInfo& info);
|
||||
bool FindKeyValue(const sniffer::PacketInfo& info);
|
||||
std::vector<nlohmann::json> FindKeys(const sniffer::PacketInfo& info, bool onlyFirst = false);
|
||||
|
||||
CompareType m_CompareType;
|
||||
ObjectType m_ObjectType;
|
||||
|
||||
std::string m_KeyPattern;
|
||||
std::string m_ObjectPattern;
|
||||
};
|
||||
|
||||
class FilterGroup : public IFilter
|
||||
{
|
||||
public:
|
||||
|
||||
enum class Rule
|
||||
{
|
||||
AND, OR, NOT
|
||||
};
|
||||
|
||||
virtual bool Draw(bool canBeRemoved = true) override;
|
||||
virtual bool Execute(const sniffer::PacketInfo& info) override;
|
||||
|
||||
virtual nlohmann::json Serialize() override;
|
||||
|
||||
FilterGroup();
|
||||
FilterGroup(nlohmann::json& object);
|
||||
|
||||
private:
|
||||
Rule m_Rule;
|
||||
std::list<IFilter*> m_Filters;
|
||||
|
||||
};
|
||||
|
||||
class SnifferWindow
|
||||
{
|
||||
public:
|
||||
config::Field<bool> m_Show;
|
||||
|
||||
SnifferWindow(SnifferWindow const&) = delete;
|
||||
void operator=(SnifferWindow const&) = delete;
|
||||
|
||||
static SnifferWindow& GetInstance();
|
||||
void OnPacketIO(const PacketInfo& info);
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
enum class SortValue
|
||||
{
|
||||
Time, Name, Size, Id, Type
|
||||
};
|
||||
|
||||
enum class SortType
|
||||
{
|
||||
Desc, Asc
|
||||
};
|
||||
|
||||
SortValue m_SortValue;
|
||||
SortType m_SortType;
|
||||
|
||||
std::list<sniffer::PacketInfo> m_CapturedPackets;
|
||||
std::list<sniffer::PacketInfo> m_CachedPackets;
|
||||
|
||||
std::mutex m_CapturePacketLock;
|
||||
|
||||
FilterGroup m_FilterGroup;
|
||||
|
||||
SnifferWindow();
|
||||
};
|
||||
}
|
||||
|
@ -5,36 +5,16 @@ void PacketData::Write(PipeTransfer* transfer)
|
||||
{
|
||||
transfer->Write(blockModeEnabled);
|
||||
transfer->Write(ioType);
|
||||
transfer->Write(dataType);
|
||||
transfer->Write(valid);
|
||||
transfer->Write(parentPacketID);
|
||||
transfer->Write(messageID);
|
||||
transfer->Write(headRawData);
|
||||
transfer->Write(messageRawData);
|
||||
|
||||
if (dataType == PacketDataType::Parsed)
|
||||
{
|
||||
transfer->Write(name);
|
||||
transfer->Write(headJson);
|
||||
transfer->Write(messageJson);
|
||||
}
|
||||
}
|
||||
|
||||
void PacketData::Read(PipeTransfer* transfer)
|
||||
{
|
||||
transfer->Read(blockModeEnabled);
|
||||
transfer->Read(ioType);
|
||||
transfer->Read(dataType);
|
||||
transfer->Read(valid);
|
||||
transfer->Read(parentPacketID);
|
||||
transfer->Read(messageID);
|
||||
transfer->Read(headRawData);
|
||||
transfer->Read(messageRawData);
|
||||
|
||||
if (dataType == PacketDataType::Parsed)
|
||||
{
|
||||
transfer->Read(name);
|
||||
transfer->Read(headJson);
|
||||
transfer->Read(messageJson);
|
||||
}
|
||||
}
|
||||
|
@ -9,165 +9,355 @@
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <helpers.h>
|
||||
#include <regex>
|
||||
#include <imgui_internal.h>
|
||||
#include "shlwapi.h"
|
||||
|
||||
namespace cheat::feature
|
||||
{
|
||||
CustomTeleports::CustomTeleports() : Feature(),
|
||||
NF(f_DebugMode, "Debug Mode", "CustomTeleports", false) // Soon to be added
|
||||
{ }
|
||||
const FeatureGUIInfo &CustomTeleports::GetGUIInfo() const
|
||||
{
|
||||
static const FeatureGUIInfo info{"Custom Teleports", "Teleport", true};
|
||||
return info;
|
||||
}
|
||||
CustomTeleports::CustomTeleports() : Feature(),
|
||||
NF(f_DebugMode, "Debug Mode", "CustomTeleports", false), // Soon to be added
|
||||
NF(f_Enabled, "Custom Teleport", "CustomTeleports", false),
|
||||
NF(f_Next, "Teleport Next", "CustomTeleports", Hotkey(VK_OEM_6)),
|
||||
NF(f_Previous, "Teleport Previous", "CustomTeleports", Hotkey(VK_OEM_4))
|
||||
{
|
||||
f_Next.value().PressedEvent += MY_METHOD_HANDLER(CustomTeleports::OnNextKeyPressed);
|
||||
f_Previous.value().PressedEvent += MY_METHOD_HANDLER(CustomTeleports::OnPreviousKeyPressed);
|
||||
}
|
||||
const FeatureGUIInfo& CustomTeleports::GetGUIInfo() const
|
||||
{
|
||||
static const FeatureGUIInfo info{ "Custom Teleports", "Teleport", true };
|
||||
return info;
|
||||
}
|
||||
|
||||
void CustomTeleports::DrawMain()
|
||||
{
|
||||
auto &entityManager = game::EntityManager::instance();
|
||||
auto &MapTeleport = MapTeleport::GetInstance();
|
||||
static std::string teleportName;
|
||||
ImGui::InputText("Teleport name", &teleportName);
|
||||
static std::vector<std::pair<std::string, app::Vector3>> teleports;
|
||||
app::Vector3 pos = app::ActorUtils_GetAvatarPos(nullptr);
|
||||
if (ImGui::Button("Add teleport"))
|
||||
{
|
||||
// check if already added
|
||||
bool found = false;
|
||||
for (const auto &[name, pos] : teleports)
|
||||
{
|
||||
if (name == teleportName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// check if name is valid and doesnt contain special characters
|
||||
if (teleportName.find_first_of("\\/:*?\"<>|") != std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
void CustomTeleports::DrawMain()
|
||||
{
|
||||
auto& entityManager = game::EntityManager::instance();
|
||||
auto& MapTeleport = MapTeleport::GetInstance();
|
||||
static std::string teleportName;
|
||||
static std::string search;
|
||||
app::Vector3 pos = app::ActorUtils_GetAvatarPos(nullptr);
|
||||
|
||||
teleports.push_back({teleportName, pos});
|
||||
ImGui::InputText("Teleport name", &teleportName);
|
||||
if (ImGui::Button("Add Teleport"))
|
||||
{
|
||||
// check if name is valid and doesnt contain special characters
|
||||
if (teleportName.find_first_of("\\/:*?\"<>|") != std::string::npos)
|
||||
return;
|
||||
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
if (!std::filesystem::exists(dir))
|
||||
std::filesystem::create_directory(dir);
|
||||
std::ofstream ofs(dir / (teleportName + ".json"));
|
||||
nlohmann::json j;
|
||||
j["name"] = teleportName;
|
||||
j["position"] = {pos.x, pos.y, pos.z};
|
||||
ofs << j;
|
||||
teleportName.clear();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload"))
|
||||
{
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
auto result = std::filesystem::directory_iterator(dir);
|
||||
teleports.clear();
|
||||
for (auto &file : result)
|
||||
{
|
||||
// check if already added
|
||||
if (std::any_of(teleports.begin(), teleports.end(), [](const auto& pair)
|
||||
{ return pair.first == teleportName; }))
|
||||
return;
|
||||
|
||||
if (file.path().extension() != ".json")
|
||||
continue;
|
||||
selectedIndex = -1;
|
||||
teleports.push_back({ teleportName, pos });
|
||||
|
||||
std::string name = file.path().stem().string();
|
||||
if (file.is_directory())
|
||||
continue;
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
if (!std::filesystem::exists(dir))
|
||||
std::filesystem::create_directory(dir);
|
||||
std::ofstream ofs(dir / (teleportName + ".json"));
|
||||
nlohmann::json j;
|
||||
j["name"] = teleportName;
|
||||
j["position"] = { pos.x, pos.y, pos.z };
|
||||
ofs << j;
|
||||
teleportName.clear();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload"))
|
||||
{
|
||||
selectedIndex = -1;
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
auto result = std::filesystem::directory_iterator(dir);
|
||||
teleports.clear();
|
||||
for (auto& file : result)
|
||||
{
|
||||
if (file.path().extension() != ".json")
|
||||
continue;
|
||||
|
||||
std::ifstream ifs(file.path());
|
||||
nlohmann::json j;
|
||||
ifs >> j;
|
||||
teleports.push_back({j["name"], {j["position"][0], j["position"][1], j["position"][2]}});
|
||||
LOG_INFO("Loaded teleport %s", name.c_str());
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
// open directory
|
||||
if (ImGui::Button("Open Folder"))
|
||||
{
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
ShellExecuteA(NULL, "open", dir.string().c_str(), NULL, NULL, SW_SHOW);
|
||||
}
|
||||
std::string name = file.path().stem().string();
|
||||
if (file.is_directory())
|
||||
continue;
|
||||
|
||||
static std::string jsonInput;
|
||||
ImGui::InputTextMultiline("JSON input", &jsonInput, ImVec2(0, 50), ImGuiInputTextFlags_AllowTabInput);
|
||||
std::ifstream ifs(file.path());
|
||||
nlohmann::json j;
|
||||
ifs >> j;
|
||||
teleports.push_back({ j["name"], {j["position"][0], j["position"][1], j["position"][2]} });
|
||||
LOG_INFO("Loaded teleport %s", name.c_str());
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
// open directory
|
||||
if (ImGui::Button("Open Folder"))
|
||||
{
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
ShellExecuteA(NULL, "open", dir.string().c_str(), NULL, NULL, SW_SHOW);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
static std::string jsonInput;
|
||||
if (ImGui::Button("Load from JSON"))
|
||||
{
|
||||
selectedIndex = -1;
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
LOG_INFO("Defined dir");
|
||||
if (!std::filesystem::exists(dir))
|
||||
std::filesystem::create_directory(dir);
|
||||
nlohmann::json j;
|
||||
try
|
||||
{
|
||||
j = nlohmann::json::parse(jsonInput);
|
||||
}
|
||||
catch (nlohmann::json::parse_error& e)
|
||||
{
|
||||
LOG_ERROR("Failed to parse JSON: %s", e.what());
|
||||
return;
|
||||
}
|
||||
LOG_INFO("Parsed JSON");
|
||||
std::string teleportName = j["name"];
|
||||
app::Vector3 pos = { j["position"][0], j["position"][1], j["position"][2] };
|
||||
teleports.push_back({ teleportName, pos });
|
||||
LOG_INFO("Loaded teleport %s", teleportName.c_str());
|
||||
std::ofstream ofs(dir / (teleportName + ".json"));
|
||||
ofs << jsonInput;
|
||||
jsonInput.clear();
|
||||
}
|
||||
ImGui::InputTextMultiline("JSON input", &jsonInput, ImVec2(0, 50), ImGuiInputTextFlags_AllowTabInput);
|
||||
|
||||
if (ImGui::Button("Load from JSON"))
|
||||
{
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
LOG_INFO("Defined dir");
|
||||
if (!std::filesystem::exists(dir))
|
||||
std::filesystem::create_directory(dir);
|
||||
nlohmann::json j;
|
||||
try
|
||||
{
|
||||
j = nlohmann::json::parse(jsonInput);
|
||||
}
|
||||
catch (nlohmann::json::parse_error &e)
|
||||
{
|
||||
LOG_ERROR("Failed to parse JSON: %s", e.what());
|
||||
return;
|
||||
}
|
||||
LOG_INFO("Parsed JSON");
|
||||
std::string teleportName = j["name"];
|
||||
app::Vector3 pos = {j["position"][0], j["position"][1], j["position"][2]};
|
||||
teleports.push_back({teleportName, pos});
|
||||
LOG_INFO("Loaded teleport %s", teleportName.c_str());
|
||||
std::ofstream ofs(dir / (teleportName + ".json"));
|
||||
ofs << jsonInput;
|
||||
jsonInput.clear();
|
||||
}
|
||||
ConfigWidget("Teleport Next", f_Next, true, "Press to teleport next of selected");
|
||||
ConfigWidget("Teleport Previous", f_Previous, true, "Press to teleport previous of selected");
|
||||
ConfigWidget("Enable",
|
||||
f_Enabled,
|
||||
"Enable teleport-through-list functionality\n" \
|
||||
"Usage:\n" \
|
||||
"1. Put Checkmark to the teleports you want to teleport using hotkey\n" \
|
||||
"2. Single click the teleport (with checkmark) to select where you want to start\n" \
|
||||
"3. You can now press Next or Previous Hotkey to Teleport through the Checklist\n" \
|
||||
"Initially it will teleport the player to the selection made\n" \
|
||||
"Note: Double click or click the arrow to open teleport details");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Delete Checked"))
|
||||
{
|
||||
if (!teleports.empty()) {
|
||||
std::vector<std::string> teleportNames;
|
||||
// get all teleport names by index
|
||||
for (auto& i : checkedIndices) {
|
||||
teleportNames.push_back(teleports.at(i).first);
|
||||
if (selectedIndex == i) selectedIndex = -1;
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Teleports"))
|
||||
{
|
||||
std::string search;
|
||||
ImGui::InputText("Search", &search);
|
||||
for (const auto &[teleportName, position] : teleports)
|
||||
{
|
||||
// find without case sensitivity
|
||||
if (search.empty() || std::search(teleportName.begin(), teleportName.end(), search.begin(), search.end(), [](char a, char b)
|
||||
{ return std::tolower(a) == std::tolower(b); }) != teleportName.end())
|
||||
{
|
||||
if (ImGui::TreeNode(teleportName.data()))
|
||||
{
|
||||
ImGui::Text("Position: %.3f, %.3f, %.3f", position.x, position.y, position.z);
|
||||
if (ImGui::Button("Teleport"))
|
||||
{
|
||||
auto &mapTeleport = MapTeleport::GetInstance();
|
||||
mapTeleport.TeleportTo(position);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Remove"))
|
||||
{
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
// delete file
|
||||
std::filesystem::remove(dir / (teleportName + ".json"));
|
||||
auto it = std::find_if(teleports.begin(), teleports.end(), [&teleportName](const auto &pair)
|
||||
{ return pair.first == teleportName; });
|
||||
if (it != teleports.end())
|
||||
teleports.erase(it);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Warning: Removing a teleport will remove the file from the directory. It will be lost forever.");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
for (auto& name : teleportNames) {
|
||||
auto dir = std::filesystem::current_path();
|
||||
dir /= "teleports";
|
||||
// delete file
|
||||
std::filesystem::remove(dir / (name + ".json"));
|
||||
// remove from list
|
||||
teleports.erase(std::remove_if(teleports.begin(), teleports.end(), [&name](const auto& pair)
|
||||
{ return pair.first == name; }), teleports.end());
|
||||
}
|
||||
checkedIndices.clear();
|
||||
UpdateIndexName();
|
||||
}
|
||||
|
||||
CustomTeleports& CustomTeleports::GetInstance()
|
||||
{
|
||||
static CustomTeleports instance;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Warning: This will delete the file from the directory and\nremove the teleport from the list. It will be lost forever.");
|
||||
|
||||
if (ImGui::TreeNode("Teleports"))
|
||||
{
|
||||
|
||||
// using natural sort instead of ascii sort
|
||||
std::sort(teleports.begin(), teleports.end(), [](const auto& a, const auto& b)
|
||||
{ return StrCmpLogicalW(std::wstring(a.first.begin(), a.first.end()).c_str(), std::wstring(b.first.begin(), b.first.end()).c_str()) < 0; });
|
||||
|
||||
bool allSearchChecked = std::includes(checkedIndices.begin(), checkedIndices.end() ,searchIndices.begin(), searchIndices.end()) && !searchIndices.empty();
|
||||
bool allChecked = (checkedIndices.size() == teleports.size() && !teleports.empty()) || allSearchChecked;
|
||||
ImGui::Checkbox("All", &allChecked);
|
||||
if (ImGui::IsItemClicked()) {
|
||||
if (!teleports.empty()) {
|
||||
if (allChecked) {
|
||||
selectedIndex = -1;
|
||||
if (!searchIndices.empty()) {
|
||||
checkedIndices.erase(searchIndices.begin(), searchIndices.end());
|
||||
}
|
||||
else {
|
||||
checkedIndices.clear();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!searchIndices.empty()) {
|
||||
checkedIndices.insert(searchIndices.begin(), searchIndices.end());
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < teleports.size(); i++)
|
||||
checkedIndices.insert(i);
|
||||
}
|
||||
}
|
||||
UpdateIndexName();
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::InputText("Search", &search);
|
||||
unsigned int index = 0;
|
||||
searchIndices.clear();
|
||||
for (const auto& [teleportName, position] : teleports)
|
||||
{
|
||||
// find without case sensitivity
|
||||
if (search.empty() || std::search(teleportName.begin(), teleportName.end(), search.begin(), search.end(), [](char a, char b)
|
||||
{ return std::tolower(a) == std::tolower(b); }) != teleportName.end())
|
||||
{
|
||||
// sets are sorted by default and does not allow duplicates
|
||||
// which works in favor here.
|
||||
if (!search.empty()) {
|
||||
searchIndices.insert(index);
|
||||
}
|
||||
|
||||
bool checked = std::any_of(checkedIndices.begin(), checkedIndices.end(), [&index](const auto& i) { return i == index; });
|
||||
bool selected = index == selectedIndex;
|
||||
|
||||
ImGui::Checkbox(("##Index" + std::to_string(index)).c_str(), &checked);
|
||||
if (ImGui::IsItemClicked(0)) {
|
||||
if (checked) {
|
||||
if (selected) selectedIndex = -1;
|
||||
checkedIndices.erase(index);
|
||||
}
|
||||
else {
|
||||
checkedIndices.insert(index);
|
||||
}
|
||||
UpdateIndexName();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(("TP##Button" + std::to_string(index)).c_str()))
|
||||
{
|
||||
auto& mapTeleport = MapTeleport::GetInstance();
|
||||
mapTeleport.TeleportTo(position);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, selected ? IM_COL32(40, 90, 175, 255) : IM_COL32(255, 255, 255, 255));
|
||||
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth;
|
||||
if (selected) nodeFlags |= ImGuiTreeNodeFlags_Selected;
|
||||
bool node_open = ImGui::TreeNodeEx(teleportName.data(), nodeFlags);
|
||||
if (ImGui::IsItemClicked() && checked) {
|
||||
if (!selected) {
|
||||
selectedIndex = index;
|
||||
selectedByClick = true;
|
||||
}
|
||||
else {
|
||||
selectedIndex = -1;
|
||||
selectedByClick = false;
|
||||
}
|
||||
UpdateIndexName();
|
||||
}
|
||||
if (node_open)
|
||||
{
|
||||
ImGui::Text("Position: %.3f, %.3f, %.3f", position.x, position.y, position.z);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomTeleports::NeedStatusDraw() const
|
||||
{
|
||||
return f_Enabled;
|
||||
}
|
||||
|
||||
void CustomTeleports::DrawStatus()
|
||||
{
|
||||
ImGui::Text("Custom Teleport\n[%s]", selectedIndexName);
|
||||
}
|
||||
|
||||
void CustomTeleports::OnNextKeyPressed()
|
||||
{
|
||||
if (!f_Enabled || selectedIndex < 0)
|
||||
return;
|
||||
|
||||
auto& mapTeleport = MapTeleport::GetInstance();
|
||||
app::Vector3 position;
|
||||
|
||||
if (selectedByClick) {
|
||||
position = teleports.at(selectedIndex).second;
|
||||
selectedByClick = false;
|
||||
}
|
||||
else {
|
||||
std::vector list(checkedIndices.begin(), checkedIndices.end());
|
||||
if (selectedIndex == list.back())
|
||||
return;
|
||||
|
||||
auto index = std::distance(list.begin(), std::find(list.begin(), list.end(), selectedIndex));
|
||||
position = teleports.at(list.at(index + 1)).second;
|
||||
selectedIndex = list.at(index + 1);
|
||||
}
|
||||
mapTeleport.TeleportTo(position);
|
||||
UpdateIndexName();
|
||||
}
|
||||
|
||||
void CustomTeleports::OnPreviousKeyPressed()
|
||||
{
|
||||
if (!f_Enabled || selectedIndex < 0)
|
||||
return;
|
||||
|
||||
auto& mapTeleport = MapTeleport::GetInstance();
|
||||
app::Vector3 position;
|
||||
|
||||
if (selectedByClick) {
|
||||
position = teleports.at(selectedIndex).second;
|
||||
selectedByClick = false;
|
||||
}
|
||||
else {
|
||||
std::vector list(checkedIndices.begin(), checkedIndices.end());
|
||||
if (selectedIndex == list.front())
|
||||
return;
|
||||
|
||||
auto index = std::distance(list.begin(), std::find(list.begin(), list.end(), selectedIndex));
|
||||
position = teleports.at(list.at(index - 1)).second;
|
||||
selectedIndex = list.at(index - 1);
|
||||
}
|
||||
mapTeleport.TeleportTo(position);
|
||||
UpdateIndexName();
|
||||
}
|
||||
|
||||
void CustomTeleports::UpdateIndexName() {
|
||||
std::string name(selectedIndex == -1 || checkedIndices.empty() ? "" : teleports.at(selectedIndex).first);
|
||||
|
||||
// abbreviate teleport names that are too long
|
||||
if (name.length() > 15) {
|
||||
std::string shortened;
|
||||
std::regex numsExp("[\\d]+");
|
||||
std::regex firstCharsExp("\\b[A-Za-z]");
|
||||
|
||||
std::sregex_iterator wordItr(name.begin(), name.end(), firstCharsExp);
|
||||
while (wordItr != std::sregex_iterator()) {
|
||||
for (unsigned i = 0; i < wordItr->size(); i++) {
|
||||
shortened.append((*wordItr)[i]);
|
||||
}
|
||||
wordItr++;
|
||||
}
|
||||
|
||||
std::sregex_iterator numItr(name.begin(), name.end(), numsExp);
|
||||
while (numItr != std::sregex_iterator()) {
|
||||
for (unsigned i = 0; i < numItr->size(); i++) {
|
||||
shortened.append(" ");
|
||||
shortened.append((*numItr)[i]);
|
||||
}
|
||||
numItr++;
|
||||
}
|
||||
name = shortened;
|
||||
}
|
||||
selectedIndexName = name;
|
||||
|
||||
}
|
||||
|
||||
CustomTeleports& CustomTeleports::GetInstance()
|
||||
{
|
||||
static CustomTeleports instance;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <cheat-base/cheat/Feature.h>
|
||||
#include <cheat-base/config/Config.h>
|
||||
#include <set>
|
||||
|
||||
namespace cheat::feature
|
||||
{
|
||||
@ -11,10 +12,26 @@ namespace cheat::feature
|
||||
{
|
||||
public:
|
||||
config::Field<config::Toggle<Hotkey>> f_DebugMode;
|
||||
config::Field<config::Toggle<Hotkey>> f_Enabled;
|
||||
config::Field<Hotkey> f_Next;
|
||||
config::Field<Hotkey> f_Previous;
|
||||
static CustomTeleports& GetInstance();
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
|
||||
virtual bool NeedStatusDraw() const override;
|
||||
void DrawStatus() override;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::string, app::Vector3>> teleports;
|
||||
std::set<unsigned int> checkedIndices;
|
||||
std::set<unsigned int> searchIndices;
|
||||
bool selectedByClick = false;
|
||||
int selectedIndex = -1;
|
||||
std::string selectedIndexName;
|
||||
CustomTeleports();
|
||||
void OnNextKeyPressed();
|
||||
void OnPreviousKeyPressed();
|
||||
void UpdateIndexName();
|
||||
};
|
||||
}
|
@ -13,13 +13,13 @@ namespace cheat::feature
|
||||
static Browser& GetInstance();
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
virtual bool NeedStatusDraw() const override;
|
||||
bool NeedStatusDraw() const override;
|
||||
void DrawStatus() override;
|
||||
|
||||
private:
|
||||
SafeQueue<uint32_t> toBeUpdate;
|
||||
SafeValue<int64_t> nextUpdate;
|
||||
int f_DelayUpdate = 20.f;
|
||||
int f_DelayUpdate = 20;
|
||||
void OnGameUpdate();
|
||||
Browser();
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ namespace cheat::feature
|
||||
private:
|
||||
SafeQueue<uint32_t> toBeUpdate;
|
||||
SafeValue<int64_t> nextUpdate;
|
||||
int f_DelayUpdate = 100.f;
|
||||
int f_DelayUpdate = 100;
|
||||
|
||||
void OnGameUpdate();
|
||||
PaimonFollow();
|
||||
|
@ -27,7 +27,7 @@ namespace cheat::feature
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
|
||||
virtual bool NeedStatusDraw() const override;
|
||||
bool NeedStatusDraw() const override;
|
||||
void DrawStatus() override;
|
||||
|
||||
bool CheckFile(const std::string& name);
|
||||
@ -35,7 +35,7 @@ namespace cheat::feature
|
||||
private:
|
||||
SafeQueue<uint32_t> toBeUpdate;
|
||||
SafeValue<int64_t> nextUpdate;
|
||||
int f_DelayUpdate = 100.f;
|
||||
int f_DelayUpdate = 100;
|
||||
|
||||
void OnGameUpdate();
|
||||
ProfileChanger();
|
||||
|
@ -17,6 +17,10 @@ namespace cheat::feature
|
||||
NF(f_AutoPickup, "Auto-pickup drops", "AutoLoot", false),
|
||||
NF(f_AutoTreasure, "Auto-open treasures", "AutoLoot", false),
|
||||
NF(f_UseCustomRange, "Use custom pickup range", "AutoLoot", false),
|
||||
NF(f_PickupFilter, "Pickup filter", "AutoLoot", false),
|
||||
NF(f_PickupFilter_Animals, "Animals filter", "AutoLoot", true),
|
||||
NF(f_PickupFilter_DropItems, "Drop items filter", "AutoLoot", true),
|
||||
NF(f_PickupFilter_Resources, "Resources filter", "AutoLoot", true),
|
||||
NF(f_Chest, "Chests", "AutoLoot", false),
|
||||
NF(f_Leyline, "Leylines", "AutoLoot", false),
|
||||
NF(f_Investigate, "Search points", "AutoLoot", false),
|
||||
@ -57,7 +61,7 @@ namespace cheat::feature
|
||||
ImGui::TextColored(ImColor(255, 165, 0, 255), "Read the note!");
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
|
||||
|
||||
ImGui::BeginGroupPanel("Custom Pickup Range");
|
||||
{
|
||||
ConfigWidget("Enabled", f_UseCustomRange, "Enable custom pickup range.\n" \
|
||||
@ -69,7 +73,7 @@ namespace cheat::feature
|
||||
ConfigWidget("Range (m)", f_CustomRange, 0.1f, 0.5f, 40.0f, "Modifies pickup/open range to this value (in meters).");
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
|
||||
|
||||
ImGui::BeginGroupPanel("Looting Speed");
|
||||
{
|
||||
ImGui::SetNextItemWidth(100.0f);
|
||||
@ -77,7 +81,7 @@ namespace cheat::feature
|
||||
"Values under 200ms are unsafe.\nNot used if no auto-functions are on.");
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::BeginGroupPanel("Auto-Treasure");
|
||||
{
|
||||
@ -97,22 +101,30 @@ namespace cheat::feature
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::BeginGroupPanel("Pickup Filter");
|
||||
{
|
||||
ConfigWidget("Enabled", f_PickupFilter, "Enable pickup filter.\n");
|
||||
ConfigWidget("Animals", f_PickupFilter_Animals, "Fish, Lizard, Frog, Flying animals."); ImGui::SameLine();
|
||||
ConfigWidget("Drop Items", f_PickupFilter_DropItems, "Material, Mineral, Artifact."); ImGui::SameLine();
|
||||
ConfigWidget("Resources", f_PickupFilter_Resources, "Everything beside Animals and Drop Items (Plants, Books, etc).");
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
}
|
||||
|
||||
bool AutoLoot::NeedStatusDraw() const
|
||||
{
|
||||
return f_AutoPickup || f_AutoTreasure || f_UseCustomRange;
|
||||
{
|
||||
return f_AutoPickup || f_AutoTreasure || f_UseCustomRange || f_PickupFilter;
|
||||
}
|
||||
|
||||
void AutoLoot::DrawStatus()
|
||||
{
|
||||
ImGui::Text("Auto Loot\n[%s%s%s%s%s%s]",
|
||||
ImGui::Text("Auto Loot\n[%s%s%s%s%s]",
|
||||
f_AutoPickup ? "AP" : "",
|
||||
f_AutoPickup && (f_AutoTreasure || f_UseCustomRange) ? "|" : "",
|
||||
f_AutoTreasure ? "AT" : "",
|
||||
f_AutoTreasure && f_UseCustomRange ? "|" : "",
|
||||
f_UseCustomRange ? fmt::format("CR{:.1f}m", f_CustomRange.value()).c_str() : "",
|
||||
f_AutoTreasure ? fmt::format("{}AT", f_AutoPickup ? "|" : "").c_str() : "",
|
||||
f_UseCustomRange ? fmt::format("{}CR{:.1f}m", f_AutoPickup || f_AutoTreasure ? "|" : "", f_CustomRange.value()).c_str() : "",
|
||||
f_PickupFilter ? fmt::format("{}PF", f_AutoPickup || f_AutoTreasure || f_UseCustomRange ? "|" : "").c_str() : "",
|
||||
f_AutoPickup || f_AutoTreasure ? fmt::format("|{}ms", f_DelayTime.value()).c_str() : ""
|
||||
);
|
||||
}
|
||||
@ -131,7 +143,7 @@ namespace cheat::feature
|
||||
auto itemModule = GET_SINGLETON(MoleMole_ItemModule);
|
||||
if (itemModule == nullptr)
|
||||
return false;
|
||||
|
||||
|
||||
auto entityId = entity->fields._runtimeID_k__BackingField;
|
||||
if (f_DelayTime == 0)
|
||||
{
|
||||
@ -215,6 +227,17 @@ namespace cheat::feature
|
||||
{
|
||||
if (f_AutoPickup || f_UseCustomRange) {
|
||||
float pickupRange = f_UseCustomRange ? f_CustomRange : 3.5f;
|
||||
if (f_PickupFilter)
|
||||
{
|
||||
if (!f_PickupFilter_Animals && entity->fields.entityType == app::EntityType__Enum_1::EnvAnimal ||
|
||||
!f_PickupFilter_DropItems && entity->fields.entityType == app::EntityType__Enum_1::DropItem ||
|
||||
!f_PickupFilter_Resources && entity->fields.entityType == app::EntityType__Enum_1::GatherObject)
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto& manager = game::EntityManager::instance();
|
||||
result = manager.avatar()->distance(entity) < pickupRange;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ namespace cheat::feature
|
||||
config::Field<config::Toggle<Hotkey>> f_AutoPickup;
|
||||
config::Field<config::Toggle<Hotkey>> f_AutoTreasure;
|
||||
config::Field<config::Toggle<Hotkey>> f_UseCustomRange;
|
||||
config::Field<config::Toggle<Hotkey>> f_PickupFilter;
|
||||
|
||||
config::Field<int> f_DelayTime;
|
||||
config::Field<float> f_CustomRange;
|
||||
@ -21,6 +22,10 @@ namespace cheat::feature
|
||||
config::Field<bool> f_Investigate;
|
||||
config::Field<bool> f_QuestInteract;
|
||||
config::Field<bool> f_Others;
|
||||
|
||||
config::Field<bool> f_PickupFilter_Animals;
|
||||
config::Field<bool> f_PickupFilter_DropItems;
|
||||
config::Field<bool> f_PickupFilter_Resources;
|
||||
|
||||
static AutoLoot& GetInstance();
|
||||
|
||||
|
Reference in New Issue
Block a user