Skip to content

Commit

Permalink
Disabled aimassit and autoclicker while in gui
Browse files Browse the repository at this point in the history
Disabled aimassit and autoclicker while in gui
  • Loading branch information
Lefraudeur authored Nov 2, 2023
2 parents 673ccdf + dff09dc commit ef84fc7
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 102 deletions.
4 changes: 2 additions & 2 deletions Ripterms Ghost.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@
<ClCompile Include="net\minecraft\block\state\IBlockState.cpp" />
<ClCompile Include="net\minecraft\client\entity\AbstractClientPlayer\AbstractClientPlayer.cpp" />
<ClCompile Include="net\minecraft\client\entity\EntityPlayerSP\EntityPlayerSP.cpp" />
<ClCompile Include="net\minecraft\client\gui\GuiScreen\GuiScreen.cpp" />
<ClCompile Include="net\minecraft\client\Minecraft\Minecraft.cpp" />
<ClCompile Include="net\minecraft\client\multiplayer\PlayerControllerMP\PlayerControllerMP.cpp" />
<ClCompile Include="net\minecraft\client\multiplayer\WorldClient\WorldClient.cpp" />
<ClCompile Include="net\minecraft\client\network\NetHandlerPlayClient\NetHandlerPlayClient.cpp" />
<ClCompile Include="net\minecraft\client\renderer\ActiveRenderInfo\ActiveRenderInfo.cpp" />
<ClCompile Include="net\minecraft\client\settings\GameSettings\GameSettings.cpp" />
<ClCompile Include="net\minecraft\client\settings\KeyBinding\KeyBinding.cpp" />
<ClCompile Include="net\minecraft\entity\EntityLivingBase\EntityLivingBase.cpp" />
Expand Down Expand Up @@ -250,11 +250,11 @@
<ClInclude Include="net\minecraft\block\state\IBlockState.h" />
<ClInclude Include="net\minecraft\client\entity\AbstractClientPlayer\AbstractClientPlayer.h" />
<ClInclude Include="net\minecraft\client\entity\EntityPlayerSP\EntityPlayerSP.h" />
<ClInclude Include="net\minecraft\client\gui\GuiScreen\GuiScreen.h" />
<ClInclude Include="net\minecraft\client\Minecraft\Minecraft.h" />
<ClInclude Include="net\minecraft\client\multiplayer\PlayerControllerMP\PlayerControllerMP.h" />
<ClInclude Include="net\minecraft\client\multiplayer\WorldClient\WorldClient.h" />
<ClInclude Include="net\minecraft\client\network\NetHandlerPlayClient\NetHandlerPlayClient.h" />
<ClInclude Include="net\minecraft\client\renderer\ActiveRenderInfo\ActiveRenderInfo.h" />
<ClInclude Include="net\minecraft\client\settings\GameSettings\GameSettings.h" />
<ClInclude Include="net\minecraft\client\settings\KeyBinding\KeyBinding.h" />
<ClInclude Include="net\minecraft\entity\EntityLivingBase\EntityLivingBase.h" />
Expand Down
12 changes: 6 additions & 6 deletions Ripterms Ghost.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@
<ClCompile Include="Ripterms\Hook\Module.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="net\minecraft\client\renderer\ActiveRenderInfo\ActiveRenderInfo.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="java\nio\FloatBuffer\FloatBuffer.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
Expand All @@ -219,6 +216,9 @@
<ClCompile Include="Ripterms\Hook\JavaHook.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="net\minecraft\client\gui\GuiScreen\GuiScreen.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Ripterms\Ripterms.h">
Expand Down Expand Up @@ -362,14 +362,14 @@
<ClInclude Include="Ripterms\GUI\GUI_conf.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="net\minecraft\client\renderer\ActiveRenderInfo\ActiveRenderInfo.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="java\nio\FloatBuffer\FloatBuffer.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="java\nio\IntBuffer\IntBuffer.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="net\minecraft\client\gui\GuiScreen\GuiScreen.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 0 additions & 4 deletions Ripterms/Cache/Cache.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Cache.h"
#include <iostream>
#include "../../net/minecraft/client/renderer/ActiveRenderInfo/ActiveRenderInfo.h"

Ripterms::Cache::Cache()
{
Expand All @@ -27,9 +26,6 @@ bool Ripterms::Cache::fillCache()
timer = theMinecraft.getTimer();
playerController = theMinecraft.getPlayerController();
sendQueue = thePlayer.getSendQueue();
//MODELVIEW = ActiveRenderInfo::getMODELVIEW();
//PROJECTION = ActiveRenderInfo::getPROJECTION();
//VIEWPORT = ActiveRenderInfo::getVIEWPORT();
}
return true;
}
3 changes: 0 additions & 3 deletions Ripterms/Cache/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ namespace Ripterms
GameSettings gameSettings{};
Timer timer{};
NetHandlerPlayClient sendQueue{};
FloatBuffer MODELVIEW{}; // not done
FloatBuffer PROJECTION{}; // not done
IntBuffer VIEWPORT{}; // not done

Map EMPTY_MAP{};
bool fillCache();
Expand Down
10 changes: 5 additions & 5 deletions Ripterms/Hook/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ void Ripterms::Hook::hook_JAVA_ENTRY_HOOK(void* a_detour_function_addr, void** a

uint8_t pre_call[] =
{
0x50, 0x51, 0x52, 0x41, 0x50, 0x41, 0x51, 0x41, 0x52, 0x41,
0x53, 0x48, 0x89, 0xD9, 0x4C, 0x89, 0xEA, 0x55, 0x48, 0x89, 0xE5,
0x48, 0x83, 0xEC, 0x20, 0x48, 0xB8
0x50, 0x51, 0x52, 0x41, 0x50, 0x41, 0x51, 0x41, 0x52, 0x41,
0x53, 0x48, 0x89, 0xD9, 0x4C, 0x89, 0xEA, 0x4D, 0x89, 0xF8,
0x55, 0x48, 0x89, 0xE5, 0x48, 0x83, 0xEC, 0x20, 0x48, 0xB8
};
memcpy(allocated_instructions, pre_call, sizeof(pre_call));
*((uint64_t*)(allocated_instructions + sizeof(pre_call))) = (uint64_t)a_detour_function_addr;
Expand All @@ -138,14 +138,14 @@ void Ripterms::Hook::hook_JAVA_ENTRY_HOOK(void* a_detour_function_addr, void** a
*((int32_t*)(target + 1)) = target_allocated_offset;

VirtualProtect(target, bytes_to_replace, original_protection, &original_protection);
VirtualProtect(allocated_instructions, 57 + bytes_to_replace, PAGE_EXECUTE_READ, &original_protection);
VirtualProtect(allocated_instructions, 60 + bytes_to_replace, PAGE_EXECUTE_READ, &original_protection);
}

void Ripterms::Hook::remove_JAVA_ENTRY_HOOK()
{
DWORD original_protection = 0;
VirtualProtect(target_function_addr, bytes_to_replace, PAGE_EXECUTE_READWRITE, &original_protection);
memcpy(target_function_addr, allocated_instructions + 52, bytes_to_replace);
memcpy(target_function_addr, allocated_instructions + 55, bytes_to_replace);
VirtualProtect(target_function_addr, bytes_to_replace, original_protection, &original_protection);
VirtualFree(allocated_instructions, 0, MEM_RELEASE);
}
Expand Down
30 changes: 28 additions & 2 deletions Ripterms/Hook/Hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <iostream>
#include <JNI/jni.h>
#include <vector>
#include <functional>
#include <type_traits>

namespace Ripterms
{
Expand Down Expand Up @@ -54,7 +54,33 @@ namespace Ripterms

namespace JavaHook
{
class JavaParameters
{
public:
inline JavaParameters(void* sp, void* thread) :
sp((uint64_t*)sp),
thread(thread)
{}
//primitive type only
template<typename T> inline T get_primitive_at(int index) const
{
return *((T*)(sp + index));
}
//index from right to left, 0 is last parameter
inline jobject get_jobject_at(int index) const
{
void* oop = *((void**)(sp + index));
return make_local(thread, oop, 0);
}

void* thread;
inline static jobject(*make_local)(void* thread, void* oop, int alloc_failure) = nullptr;
private:
uint64_t* sp;
};

void clean();
void add_to_java_hook(jmethodID methodID, void(*callback)(void*, void*));
bool init();
void add_to_java_hook(jmethodID methodID, void(*callback)(const JavaParameters& params));
}
}
36 changes: 30 additions & 6 deletions Ripterms/Hook/JavaHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
#include <functional>
#include <thread>

namespace
namespace //unique coding style lmao
{
std::unordered_map<void*, Ripterms::Hook*> hooks{};
std::unordered_map<void*, void(*)(void*, void*)> methods_to_hook{};
std::unordered_map<void*, void(*)(const Ripterms::JavaHook::JavaParameters& params)> methods_to_hook{};

//fastcall so that parameters are passed through rcx and rdx (Method* is in rbx, but JavaHook mov rcx, rbx)
void detour_i2i_entry(void* method_rbx, void* sp_r13)
void detour_i2i_entry(void* method_rbx, void* sp_r13, void* thread_r15)
{
if (methods_to_hook.contains(method_rbx))
{
methods_to_hook[method_rbx](method_rbx, sp_r13);
methods_to_hook[method_rbx]({sp_r13, thread_r15});
}
return;
}
Expand All @@ -27,7 +27,31 @@ void Ripterms::JavaHook::clean()
}
}

void Ripterms::JavaHook::add_to_java_hook(jmethodID methodID, void(*callback)(void*, void*))
bool Ripterms::JavaHook::init()
{
Module jvmdll("jvm.dll");
uint8_t make_local_pattern[] =
{
0x48, 0x85, 0xD2, 0x75, 0x03, 0x33, 0xC0, 0xC3,
0x48, 0x8B, 0x89, 0xD8, 0x00, 0x00, 0x00, 0xE9,
0x6C, 0xF7, 0xFF, 0xFF
};
JavaParameters::make_local = (jobject(*)(void*, void*, int))
jvmdll.pattern_scan(make_local_pattern, sizeof(make_local_pattern), PAGE_EXECUTE_READ);
if (!JavaParameters::make_local)
{
//try second pattern, for lower jvm versions
uint8_t make_local_pattern2[] =
{
0x48, 0x85, 0xD2, 0x75, 0x03, 0x33, 0xC0, 0xC3, 0x48, 0x8B, 0x49
};
JavaParameters::make_local = (jobject(*)(void*, void*, int))
jvmdll.pattern_scan(make_local_pattern2, sizeof(make_local_pattern2), PAGE_EXECUTE_READ);
}
return JavaParameters::make_local != nullptr;
}

void Ripterms::JavaHook::add_to_java_hook(jmethodID methodID, void(*callback)(const JavaParameters& params))
{
// hook size 8 bytes
// Method* in rbx
Expand All @@ -39,4 +63,4 @@ void Ripterms::JavaHook::add_to_java_hook(jmethodID methodID, void(*callback)(vo
if (!hooks.contains(i2i))
hooks.insert({ i2i, new Hook(8, i2i, detour_i2i_entry, nullptr, Hook::JAVA_ENTRY_HOOK) });
methods_to_hook.insert({ method, callback });
}
}
11 changes: 11 additions & 0 deletions Ripterms/Mappings/mappings_forge_1_7_10.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ R"(
"obfuscated": "field_71442_b",
"signature": "Lnet/minecraft/client/multiplayer/PlayerControllerMP;",
"static": false
},
{
"name": "currentScreen",
"obfuscated": "field_71462_r",
"signature": "Lnet/minecraft/client/gui/GuiScreen;",
"static": false
}
],
"methods": [
Expand Down Expand Up @@ -757,6 +763,11 @@ R"(
"static": false
}
]
},
"net/minecraft/client/gui/GuiScreen": {
"obfuscated": "net/minecraft/client/gui/GuiScreen",
"fields": [],
"methods": []
}
}
)";
Expand Down
11 changes: 11 additions & 0 deletions Ripterms/Mappings/mappings_lunar_1_16_5.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ R"(
"obfuscated": "gameMode",
"signature": "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;",
"static": false
},
{
"name": "currentScreen",
"obfuscated": "screen",
"signature": "Lnet/minecraft/client/gui/screens/Screen;",
"static": false
}
],
"methods": [
Expand Down Expand Up @@ -693,6 +699,11 @@ R"(
"static": false
}
]
},
"net/minecraft/client/gui/GuiScreen": {
"obfuscated": "net/minecraft/client/gui/screens/Screen",
"fields": [],
"methods": []
}
}
)";
Expand Down
11 changes: 11 additions & 0 deletions Ripterms/Mappings/mappings_lunar_1_7_10.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ R"(
"obfuscated": "playerController",
"signature": "Lnet/minecraft/client/multiplayer/PlayerControllerMP;",
"static": false
},
{
"name": "currentScreen",
"obfuscated": "currentScreen",
"signature": "Lnet/minecraft/client/gui/GuiScreen;",
"static": false
}
],
"methods": [
Expand Down Expand Up @@ -745,6 +751,11 @@ R"(
"static": false
}
]
},
"net/minecraft/client/gui/GuiScreen": {
"obfuscated": "net/minecraft/client/gui/GuiScreen",
"fields": [],
"methods": []
}
}
)";
Expand Down
31 changes: 9 additions & 22 deletions Ripterms/Mappings/mappings_lunar_1_8_9.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ R"(
"obfuscated": "playerController",
"signature": "Lnet/minecraft/client/multiplayer/PlayerControllerMP;",
"static": false
},
{
"name": "currentScreen",
"obfuscated": "currentScreen",
"signature": "Lnet/minecraft/client/gui/GuiScreen;",
"static": false
}
],
"methods": [
Expand Down Expand Up @@ -769,28 +775,9 @@ R"(
}
]
},
"net/minecraft/client/renderer/ActiveRenderInfo": {
"obfuscated": "net/minecraft/client/renderer/ActiveRenderInfo",
"fields": [
{
"name": "MODELVIEW",
"obfuscated": "MODELVIEW",
"signature": "Ljava/nio/FloatBuffer;",
"static": true
},
{
"name": "PROJECTION",
"obfuscated": "PROJECTION",
"signature": "Ljava/nio/FloatBuffer;",
"static": true
},
{
"name": "VIEWPORT",
"obfuscated": "VIEWPORT",
"signature": "Ljava/nio/IntBuffer;",
"static": true
}
],
"net/minecraft/client/gui/GuiScreen": {
"obfuscated": "net/minecraft/client/gui/GuiScreen",
"fields": [],
"methods": []
}
}
Expand Down
11 changes: 11 additions & 0 deletions Ripterms/Mappings/mappings_vanilla_1_8_9.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ R"(
"obfuscated": "c",
"signature": "Lbda;",
"static": false
},
{
"name": "currentScreen",
"obfuscated": "m",
"signature": "Laxu;",
"static": false
}
],
"methods": [
Expand Down Expand Up @@ -768,6 +774,11 @@ R"(
"static": false
}
]
},
"net/minecraft/client/gui/GuiScreen": {
"obfuscated": "axu",
"fields": [],
"methods": []
}
}
)";
Expand Down
Loading

0 comments on commit ef84fc7

Please sign in to comment.