Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CPMAddPackage("gh:TsudaKageyu/minhook@1.3.4")
CPMAddPackage("gh:brampedgex/mnemosyne#48078d302fa3ba9e22b80ca69eadf27811caf361")
CPMAddPackage("gh:nlohmann/json@3.12.0")
CPMAddPackage("gh:BasedInc/libhat@0.6.0")
CPMAddPackage("gh:skypjack/entt#fe8d7d78c4823e8a66a050bf86f5c6318cf76ce7")

target_include_directories(Latite PRIVATE
"include"
Expand All @@ -16,4 +17,5 @@ target_link_libraries(Latite PRIVATE
mnemosyne
nlohmann_json
libhat::libhat
EnTT::EnTT
)
25 changes: 5 additions & 20 deletions src/client/Latite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,14 @@ DWORD __stdcall startThreadImpl(HINSTANCE dll) {
}

std::vector<std::pair<SigImpl*, SigImpl*>> sigList = {
MVSIG(Misc::minecraftGamePointer),
MVSIG(MainWindow__windowProcCallback),
MVSIG(LevelRenderer_renderLevel),
MVSIG(Offset::LevelRendererPlayer_origin),
MVSIG(Offset::MinecraftGame_cursorGrabbed),
MVSIG(Components::moveInputComponent),
MVSIG(Options_getGamma),
MVSIG(Options_getPerspective),
MVSIG(Options_getHideHand),
MVSIG(ClientInstance_grabCursor),
MVSIG(ClientInstance_releaseCursor),
MVSIG(Level_tick),
MVSIG(MultiPlayerLevel__subTick),
MVSIG(ChatScreenController_sendChatMessage),
MVSIG(GameCore_handleMouseInput),
MVSIG(MinecraftGame_onDeviceLost),
Expand All @@ -301,27 +297,17 @@ DWORD __stdcall startThreadImpl(HINSTANCE dll) {
MVSIG(RakPeer_GetAveragePing),
MVSIG(ClientInputUpdateSystem_tickBaseInput),
MVSIG(LocalPlayer_applyTurnDelta),
MVSIG(Vtable::TextPacket),
MVSIG(Vtable::SetTitlePacket),
MVSIG(Components::runtimeIDComponent),
MVSIG(CameraViewBob),
MVSIG(ItemStackBase_getHoverName),
MVSIG(Vtable::CommandRequestPacket),
MVSIG(Vtable::Level),
MVSIG(Misc::uiColorMaterial),
MVSIG(Tessellator_begin),
MVSIG(Tessellator_vertex),
MVSIG(Tessellator_color),
MVSIG(MeshHelpers_renderMeshImmediately),
MVSIG(BaseActorRenderContext_BaseActorRenderContext),
MVSIG(ItemRenderer_renderGuiItemNew),
MVSIG(BaseAttributeMap_getInstance),
MVSIG(UIControl_getPosition),
MVSIG(MinecraftGame_getPrimaryClientInstance),
MVSIG(Components::actorTypeComponent),
MVSIG(UIControl_updateCachedPosition),
MVSIG(ActorRenderDispatcher_render),
MVSIG(LevelRendererPlayer_renderOutlineSelection),
MVSIG(Components::attributesComponent),
MVSIG(Dimension_getSkyColor),
MVSIG(Dimension_getTimeOfDay),
MVSIG(Dimension_tick),
Expand All @@ -330,15 +316,14 @@ DWORD __stdcall startThreadImpl(HINSTANCE dll) {
MVSIG(MinecraftPackets_createPacket),
MVSIG(Actor_attack),
MVSIG(GuiData__addMessage),
MVSIG(Components::actorEquipmentPersistentComponent),
MVSIG(_updatePlayer),
MVSIG(GameArguments__onUri),
MVSIG(RenderMaterialGroup__common),
MVSIG(GuiData_displayClientMessage),
MVSIG(Misc::gameCorePointer),
MVSIG(MouseInputVector),
MVSIG(BaseActorRenderer_renderText),
MVSIG(AppPlatformGDK_releaseMouse)
MVSIG(AppPlatformGDK_releaseMouse),
MVSIG(Misc::Platform_GameCore),
MVSIG(Misc::mouseDevice),
};

new (configMgrBuf) ConfigManager();
Expand Down
5 changes: 2 additions & 3 deletions src/client/Latite.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ class Latite final : public Listener {

static constexpr std::string_view version = "v2.6.2";
static constexpr std::array<std::string_view, 3> supportedMinecraftVersions = {
"1.26.10",
"1.26.11",
"1.26.12",
"1.26.20",
"1.26.21"
};

[[nodiscard]] static constexpr bool supportsMinecraftVersion(std::string_view version) noexcept {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ThirdPersonNametag.h"
#include <mc/Addresses.h>

static constexpr size_t instructionSize = 6;
static constexpr size_t instructionSize = 2;
static char originalBytes[instructionSize] = {};
static void* instructionPointer = nullptr;

Expand Down
43 changes: 20 additions & 23 deletions src/client/memory/hook/hooks/GeneralHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "client/event/events/MouseReleaseEvent.h"
#include "client/screen/ScreenManager.h"
#include "mc/common/client/game/GameCore.h"
#include "mc/common/client/game/MouseInputPacket.h"
#include "mc/common/client/game/MouseDevice.h"

namespace {
std::shared_ptr<Hook> Level_tickHook;
std::shared_ptr<Hook> MultiPlayerLevel__subTickHook;
std::shared_ptr<Hook> ChatScreenController_sendChatMesageHook;
std::shared_ptr<Hook> GameRenderer_renderCurrentFrameHook;
//std::shared_ptr<Hook> Keyboard_feedHook;
Expand Down Expand Up @@ -41,18 +41,15 @@ namespace {
std::shared_ptr<Hook> AppPlatformGDK_releaseMouseHook;
}

void GenericHooks::Level_tick(SDK::Level* level) {
if (level == SDK::ClientInstance::get()->minecraft->getLevel()) {
// Clientside level
// dispatch clientside tick event..
TickEvent ev(level);
Latite::getEventing().dispatch(ev);
Latite::getClientMessageQueue().doPrint(100);
void GenericHooks::MultiPlayerLevel__subTick(SDK::Level* level) {
TickEvent ev(level);
Latite::getEventing().dispatch(ev);
Latite::getClientMessageQueue().doPrint(100);

PluginManager::Event sEv{L"world-tick", {}, false};
Latite::getPluginManager().dispatchEvent(sEv);
}
Level_tickHook->oFunc<decltype(&Level_tick)>()(level);
PluginManager::Event sEv{L"world-tick", {}, false};
Latite::getPluginManager().dispatchEvent(sEv);

MultiPlayerLevel__subTickHook->oFunc<decltype(&MultiPlayerLevel__subTick)>()(level);
}

void* GenericHooks::ChatScreenController_sendChatMessage(void* controller, std::string& message) {
Expand Down Expand Up @@ -118,14 +115,14 @@ LRESULT GenericHooks::MainWindow__windowProcCallback(HWND hwnd, UINT msg, WPARAM
bool GenericHooks::GameCore_handleMouseInput(void* a1, void* a2, void* a3) { // Made up name
const auto res = GameCore_handleMouseInputHook->oFunc<decltype(&GameCore_handleMouseInput)>()(a1, a2, a3);

static auto mouseInputVector = reinterpret_cast<std::vector<MouseInputPacket>*>(Signatures::MouseInputVector.result);
const auto mouse = SDK::MouseDevice::get();

for (size_t i = 0; i < mouseInputVector->size(); i++) { // This method sucks so fucking bad, but gets the job done
auto& start = mouseInputVector->at(i);
auto it = std::next(mouseInputVector->begin(), i);
for (size_t i = 0; i < mouse->inputs.size(); i++) { // This method sucks, but gets the job done
auto& start = mouse->inputs.at(i);
auto it = std::next(mouse->inputs.begin(), i);

const auto button = start.type;
const auto state = start.state;
const auto button = start.action;
const auto state = start.data;

if (button > 0) {
Vec2& mousePos = SDK::ClientInstance::get()->cursorPos;
Expand Down Expand Up @@ -157,14 +154,14 @@ bool GenericHooks::GameCore_handleMouseInput(void* a1, void* a2, void* a3) { //

PluginManager::Event ev{L"click", values, true};
if (Latite::getPluginManager().dispatchEvent(ev)) {
mouseInputVector->erase(it);
mouse->inputs.erase(it);
continue;
}
}

ClickEvent ev{ button, static_cast<char>(state) };
if (Eventing::get().dispatch(ev))
mouseInputVector->erase(it);
mouse->inputs.erase(it);
}

return res;
Expand Down Expand Up @@ -420,8 +417,8 @@ GenericHooks::GenericHooks() : HookGroup("General") {
//LoadLibraryWHook = addHook(reinterpret_cast<uintptr_t>(&::LoadLibraryA), hkLoadLibraryW);


Level_tickHook = addHook(Signatures::Level_tick.result,
Level_tick, "Level::tick");
MultiPlayerLevel__subTickHook = addHook(Signatures::MultiPlayerLevel__subTick.result,
MultiPlayerLevel__subTick, "Level::tick");

ChatScreenController_sendChatMesageHook = addHook(Signatures::ChatScreenController_sendChatMessage.result,
ChatScreenController_sendChatMessage, "ChatScreenController::sendChatMessage");
Expand Down
2 changes: 1 addition & 1 deletion src/client/memory/hook/hooks/GeneralHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <mc/common/client/renderer/game/CameraComponent.h>

class GenericHooks : public HookGroup {
static void __fastcall Level_tick(SDK::Level* level);
static void __fastcall MultiPlayerLevel__subTick(SDK::Level* level);
static void* __fastcall ChatScreenController_sendChatMessage(void* controller, std::string& message);
static void* __fastcall GameRenderer_renderCurrentFrame(void* rend);
static LRESULT __fastcall MainWindow__windowProcCallback(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
Expand Down
Loading
Loading