From f4e0861c299d543422f6bbfe29afe286aa439af7 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Thu, 17 Dec 2020 22:22:56 -0500 Subject: [PATCH] Name Property + VTable Offsets --- Dockerfile.client | 5 +- debian/client/native/DEBIAN/control | 2 +- debian/client/virgl/DEBIAN/control | 2 +- mods/src/camera/camera.cpp | 2 +- mods/src/game_mode/game_mode.cpp | 11 ++--- mods/src/input/input.c | 18 +++---- mods/src/input/input.cpp | 10 ++-- mods/src/minecraft.h | 77 ++++++++++++++++++++++++++++- mods/src/misc/misc.cpp | 6 +-- mods/src/options/options.c | 12 ++--- mods/src/server/server.cpp | 31 ++++++------ mods/src/server/server_internal.h | 2 +- mods/src/textures/textures.cpp | 12 ++--- 13 files changed, 133 insertions(+), 57 deletions(-) diff --git a/Dockerfile.client b/Dockerfile.client index bb1293552..91d148393 100644 --- a/Dockerfile.client +++ b/Dockerfile.client @@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive RUN \ # Install Runtime Dependencies apt-get update && \ - apt-get install -y --no-install-recommends libgles1 libx11-6 libsdl1.2debian zlib1g libfreeimage3 libglfw3 xinput libxfixes3 && \ + apt-get install -y --no-install-recommends tini libgles1 libx11-6 libsdl1.2debian zlib1g libfreeimage3 libglfw3 xinput libxfixes3 && \ rm -rf /var/lib/apt/lists/* # Compile Environment @@ -45,4 +45,5 @@ COPY --from=build /app/minecraft-pi /app/minecraft-pi WORKDIR /app/minecraft-pi -ENTRYPOINT ./launcher +ENTRYPOINT ["/usr/bin/tini", "--"] +CMD ["./launcher"] diff --git a/debian/client/native/DEBIAN/control b/debian/client/native/DEBIAN/control index 33b97d8ba..6170fe27c 100644 --- a/debian/client/native/DEBIAN/control +++ b/debian/client/native/DEBIAN/control @@ -5,4 +5,4 @@ Description: Fun with Blocks Homepage: https://www.minecraft.net/en-us/edition/pi Architecture: all Depends: ${DEPENDENCIES} -Conflicts: minecraft-pi-virgl +Conflicts: minecraft-pi, minecraft-pi-virgl diff --git a/debian/client/virgl/DEBIAN/control b/debian/client/virgl/DEBIAN/control index 7429df483..843e7c3c6 100644 --- a/debian/client/virgl/DEBIAN/control +++ b/debian/client/virgl/DEBIAN/control @@ -5,4 +5,4 @@ Description: Fun with Blocks Homepage: https://www.minecraft.net/en-us/edition/pi Architecture: all Depends: ${DEPENDENCIES}, virgl-server -Conflicts: minecraft-pi-native +Conflicts: minecraft-pi, minecraft-pi-native diff --git a/mods/src/camera/camera.cpp b/mods/src/camera/camera.cpp index 001115a96..44b85b3f4 100644 --- a/mods/src/camera/camera.cpp +++ b/mods/src/camera/camera.cpp @@ -16,7 +16,7 @@ static unsigned char *EntityRenderDispatcher_injection(unsigned char *dispatcher (*EntityRenderDispatcher)(dispatcher); // Register TripodCameraRenderer - unsigned char *renderer = (unsigned char *) ::operator new(0x193); + unsigned char *renderer = (unsigned char *) ::operator new(TRIPOD_CAMERA_RENDERER_SIZE); (*TripodCameraRenderer)(renderer); (*EntityRenderDispatcher_assign)(dispatcher, (unsigned char) 0x5, renderer); diff --git a/mods/src/game_mode/game_mode.cpp b/mods/src/game_mode/game_mode.cpp index 9b08c8b62..ef06f2751 100644 --- a/mods/src/game_mode/game_mode.cpp +++ b/mods/src/game_mode/game_mode.cpp @@ -6,14 +6,13 @@ // Get Minecraft From Screen static unsigned char *get_minecraft_from_screen(unsigned char *screen) { - return *(unsigned char **) (screen + 0x14); + return *(unsigned char **) (screen + Screen_minecraft_property_offset); } // Redirect Create World Button To SimpleLevelChooseScreen #define WORLD_NAME "world" -#define SIMPLE_LEVEL_CHOOSE_SCREEN_SIZE 0x68 static void SelectWorldScreen_tick_injection(unsigned char *screen) { - bool create_world = *(bool *) (screen + 0xfc); + bool create_world = *(bool *) (screen + SelectWorldScreen_should_create_world_property_offset); if (create_world) { // Get New World Name std::string new_name = (*SelectWorldScreen_getUniqueLevelName)(screen, WORLD_NAME); @@ -24,13 +23,13 @@ static void SelectWorldScreen_tick_injection(unsigned char *screen) { unsigned char *minecraft = get_minecraft_from_screen(screen); (*Minecraft_setScreen)(minecraft, new_screen); // Finish - *(bool *) (screen + 0xf9) = true; + *(bool *) (screen + SelectWorldScreen_world_created_property_offset) = true; } else { (*SelectWorldScreen_tick)(screen); } } static void Touch_SelectWorldScreen_tick_injection(unsigned char *screen) { - bool create_world = *(bool *) (screen + 0x154); + bool create_world = *(bool *) (screen + Touch_SelectWorldScreen_should_create_world_property_offset); if (create_world) { // Get New World Name std::string new_name = (*Touch_SelectWorldScreen_getUniqueLevelName)(screen, WORLD_NAME); @@ -41,7 +40,7 @@ static void Touch_SelectWorldScreen_tick_injection(unsigned char *screen) { unsigned char *minecraft = get_minecraft_from_screen(screen); (*Minecraft_setScreen)(minecraft, new_screen); // Finish - *(bool *) (screen + 0x151) = true; + *(bool *) (screen + Touch_SelectWorldScreen_world_created_property_offset) = true; } else { (*Touch_SelectWorldScreen_tick)(screen); } diff --git a/mods/src/input/input.c b/mods/src/input/input.c index 20ad2a791..dace1d7ee 100644 --- a/mods/src/input/input.c +++ b/mods/src/input/input.c @@ -33,11 +33,11 @@ static void Minecraft_tickInput_injection(unsigned char *minecraft) { if (fix_bow && !is_right_click) { // GameMode Is Offset From minecraft By 0x160 // Player Is Offset From minecraft By 0x18c - unsigned char *game_mode = *(unsigned char **) (minecraft + 0x160); - unsigned char *player = *(unsigned char **) (minecraft + 0x18c); + unsigned char *game_mode = *(unsigned char **) (minecraft + Minecraft_game_mode_property_offset); + unsigned char *player = *(unsigned char **) (minecraft + Minecraft_player_property_offset); if (player != NULL && game_mode != NULL && (*Player_isUsingItem)(player)) { unsigned char *game_mode_vtable = *(unsigned char **) game_mode; - GameMode_releaseUsingItem_t GameMode_releaseUsingItem = *(GameMode_releaseUsingItem_t *) (game_mode_vtable + 0x5c); + GameMode_releaseUsingItem_t GameMode_releaseUsingItem = *(GameMode_releaseUsingItem_t *) (game_mode_vtable + GameMode_releaseUsingItem_vtable_offset); (*GameMode_releaseUsingItem)(game_mode, player); } } @@ -46,15 +46,15 @@ static void Minecraft_tickInput_injection(unsigned char *minecraft) { input_clear_input(); // Handle Functions - unsigned char *options = minecraft + 0x3c; + unsigned char *options = minecraft + Minecraft_options_property_offset; if (hide_gui_toggle % 2 != 0) { // Toggle Hide GUI - *(options + 0xec) = *(options + 0xec) ^ 1; + *(options + Options_hide_gui_property_offset) = *(options + Options_hide_gui_property_offset) ^ 1; } hide_gui_toggle = 0; if (third_person_toggle % 2 != 0) { // Toggle Third Person - *(options + 0xed) = *(options + 0xed) ^ 1; + *(options + Options_third_person_property_offset) = *(options + Options_third_person_property_offset) ^ 1; } third_person_toggle = 0; } @@ -97,9 +97,9 @@ static int32_t MouseBuildInput_tickBuild_injection(unsigned char *mouse_build_in // Use Attack/Place BuildActionIntention If No Other Valid BuildActionIntention Was Selected And This Was Not A Repeated Left Click if (ret != 0 && is_left_click == 1 && *build_action_intention_return == 0xa) { // Get Target HitResult - unsigned char *minecraft = *(unsigned char **) (local_player + 0xc90); - unsigned char *hit_result = minecraft + 0xc38; - int32_t hit_result_type = *(int32_t *) hit_result; + unsigned char *minecraft = *(unsigned char **) (local_player + LocalPlayer_minecraft_property_offset); + unsigned char *hit_result = minecraft + Minecraft_hit_result_property_offset; + int32_t hit_result_type = *(int32_t *) (hit_result + HitResult_type_property_offset); // Check if The Target Is An Entity Using HitResult if (hit_result_type == 1) { // Change BuildActionIntention To Attack/Place Mode (Place Will Not Happen Because The HitResult Is An Entity) diff --git a/mods/src/input/input.cpp b/mods/src/input/input.cpp index 232b57b49..fcf301c81 100644 --- a/mods/src/input/input.cpp +++ b/mods/src/input/input.cpp @@ -9,9 +9,9 @@ // Open Sign Screen static void LocalPlayer_openTextEdit_injection(unsigned char *local_player, unsigned char *sign) { - if (*(int *)(sign + 0x18) == 4) { - unsigned char *minecraft = *(unsigned char **) (local_player + 0xc90); - unsigned char *screen = (unsigned char *) ::operator new(0xd0); + if (*(int32_t *) (sign + TileEntity_id_property_offset) == 4) { + unsigned char *minecraft = *(unsigned char **) (local_player + LocalPlayer_minecraft_property_offset); + unsigned char *screen = (unsigned char *) ::operator new(TEXT_EDIT_SCREEN_SIZE); screen = (*TextEditScreen)(screen, sign); (*Minecraft_setScreen)(minecraft, screen); } @@ -44,10 +44,10 @@ static void TextEditScreen_updateEvents_injection(unsigned char *screen) { for (char key : input) { if (key == BACKSPACE_KEY) { // Handle Backspace - (*(Screen_keyPressed_t *) (vtable + 0x6c))(screen, BACKSPACE_KEY); + (*(Screen_keyPressed_t *) (vtable + Screen_keyPressed_vtable_offset))(screen, BACKSPACE_KEY); } else { // Handle Nrmal Key - (*(Screen_keyboardNewChar_t *) (vtable + 0x70))(screen, key); + (*(Screen_keyboardNewChar_t *) (vtable + Screen_keyboardNewChar_vtable_offset))(screen, key); } } } diff --git a/mods/src/minecraft.h b/mods/src/minecraft.h index 2989becf3..3b980ba15 100644 --- a/mods/src/minecraft.h +++ b/mods/src/minecraft.h @@ -35,6 +35,10 @@ static unsigned char **Tile_grass_carried = (unsigned char **) 0x181dd4; static float *InvGuiScale = (float *) 0x135d98; +// Tile + +static uint32_t Tile_id_property_offset = 0x8; + // Structures struct LevelSettings { @@ -52,6 +56,7 @@ struct RakNet_SystemAddress { // GameMode typedef void (*GameMode_releaseUsingItem_t)(unsigned char *game_mode, unsigned char *player); +static uint32_t GameMode_releaseUsingItem_vtable_offset = 0x5c; // Minecraft @@ -88,6 +93,31 @@ static Minecraft_isLevelGenerated_t Minecraft_isLevelGenerated = (Minecraft_isLe typedef int32_t (*Minecraft_isCreativeMode_t)(unsigned char *minecraft); static Minecraft_isCreativeMode_t Minecraft_isCreativeMode = (Minecraft_isCreativeMode_t) 0x17270; +static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t +static uint32_t Minecraft_server_side_network_handler_property_offset = 0x174; // ServerSideNetworkHandler * +static uint32_t Minecraft_rak_net_instance_property_offset = 0x170; // RakNetInstance * +static uint32_t Minecraft_level_property_offset = 0x188; // Level * +static uint32_t Minecraft_textures_property_offset = 0x164; // Textures * +static uint32_t Minecraft_game_mode_property_offset = 0x160; // GameMode * +static uint32_t Minecraft_player_property_offset = 0x18c; // LocalPlayer * +static uint32_t Minecraft_options_property_offset = 0x3c; // Options +static uint32_t Minecraft_hit_result_property_offset = 0xc38; // HitResult +static uint32_t Minecraft_progress_property_offset = 0xc60; // int32_t + +// HitResult + +static uint32_t HitResult_type_property_offset = 0x0; + +// Options + +static uint32_t Options_fancy_graphics_property_offset = 0x17; // unsigned char / bool +static uint32_t Options_split_controls_property_offset = 0x105; // int32_t +static uint32_t Options_peaceful_mode_property_offset = 0xe8; // unsigned char / bool +static uint32_t Options_3d_anaglyph_property_offset = 0x15; // unsigned char / bool +static uint32_t Options_ambient_occlusion_property_offset = 0x18; // unsigned char / bool +static uint32_t Options_hide_gui_property_offset = 0xec; // unsigned char / bool +static uint32_t Options_third_person_property_offset = 0xed; // unsigned char / bool + // MouseBuildInput typedef int32_t (*MouseBuildInput_tickBuild_t)(unsigned char *mouse_build_input, unsigned char *player, uint32_t *build_action_intention_return); @@ -99,10 +129,19 @@ static void *MouseBuildInput_tickBuild_vtable_addr = (void *) 0x102564; typedef int (*Player_isUsingItem_t)(unsigned char *player); static Player_isUsingItem_t Player_isUsingItem = (Player_isUsingItem_t) 0x8f15c; -// Player +static uint32_t Player_username_property_offset = 0xbf4; // char * + +// LocalPlayer static void *LocalPlayer_openTextEdit_vtable_addr = (void *) 0x106460; +static uint32_t LocalPlayer_minecraft_property_offset = 0xc90; // Minecraft * + +// ServerPlayer + +static uint32_t ServerPlayer_minecraft_property_offset = 0xc8c; // Minecraft * +static uint32_t ServerPlayer_guid_property_offset = 0xc08; // RakNetGUID + // Gui typedef void (*Gui_tick_t)(unsigned char *gui); @@ -114,6 +153,9 @@ static Gui_handleClick_t Gui_handleClick = (Gui_handleClick_t) 0x2599c; typedef void (*Gui_renderOnSelectItemNameText_t)(unsigned char *gui, int32_t param_1, unsigned char *font, int32_t param_2); static Gui_renderOnSelectItemNameText_t Gui_renderOnSelectItemNameText = (Gui_renderOnSelectItemNameText_t) 0x26aec; +static uint32_t Gui_minecraft_property_offset = 0x9f4; // Minecraft * +static uint32_t Gui_selected_item_text_timer_property_offset = 0x9fc; // float + // GameMode Constructors static void *CreatorMode = (void *) 0x1a044; @@ -129,8 +171,12 @@ static LevelData_getSpawnMobs_t LevelData_getSpawnMobs = (LevelData_getSpawnMobs typedef void (*Level_saveLevelData_t)(unsigned char *level); static Level_saveLevelData_t Level_saveLevelData = (Level_saveLevelData_t) 0xa2e94; +static uint32_t Level_players_property_offset = 0x60; // std::vector + // TextEditScreen +#define TEXT_EDIT_SCREEN_SIZE 0xd0 + typedef unsigned char *(*TextEditScreen_t)(unsigned char *text_edit_screen, unsigned char *sign); static TextEditScreen_t TextEditScreen = (TextEditScreen_t) 0x3a840; @@ -147,20 +193,31 @@ typedef void (*Screen_updateEvents_t)(unsigned char *screen); static Screen_updateEvents_t Screen_updateEvents = (Screen_updateEvents_t) 0x28eb8; typedef void (*Screen_keyboardNewChar_t)(unsigned char *screen, char key); +static uint32_t Screen_keyboardNewChar_vtable_offset = 0x70; + typedef void (*Screen_keyPressed_t)(unsigned char *screen, int32_t key); +static uint32_t Screen_keyPressed_vtable_offset = 0x6c; typedef void (*Screen_tick_t)(unsigned char *screen); +static uint32_t Screen_minecraft_property_offset = 0x14; // Minecraft * + // SelectWorldScreen static Screen_tick_t SelectWorldScreen_tick = (Screen_tick_t) 0x38a2c; static void *SelectWorldScreen_tick_vtable_addr = (void *) 0x104f78; +static uint32_t SelectWorldScreen_should_create_world_property_offset = 0xfc; // bool +static uint32_t SelectWorldScreen_world_created_property_offset = 0xf9; // bool + // Touch::SelectWorldScreen static Screen_tick_t Touch_SelectWorldScreen_tick = (Screen_tick_t) 0x3d96c; static void *Touch_SelectWorldScreen_tick_vtable_addr = (void *) 0x105780; +static uint32_t Touch_SelectWorldScreen_should_create_world_property_offset = 0x154; // bool +static uint32_t Touch_SelectWorldScreen_world_created_property_offset = 0x151; // bool + // ItemInstance #define ITEM_INSTANCE_SIZE 0xc @@ -173,14 +230,23 @@ typedef unsigned char *(*ItemInstance_constructor_extra_t)(unsigned char *item_i static ItemInstance_constructor_extra_t ItemInstance_constructor_title_extra = (ItemInstance_constructor_extra_t) 0x99918; static ItemInstance_constructor_extra_t ItemInstance_constructor_item_extra = (ItemInstance_constructor_extra_t) 0x99960; +static uint32_t ItemInstance_count_property_offset = 0x0; +static uint32_t ItemInstance_id_property_offset = 0x4; +static uint32_t ItemInstance_auxilary_property_offset = 0x8; + // FillingContainer typedef int32_t (*FillingContainer_addItem_t)(unsigned char *filling_container, unsigned char *item_instance); static FillingContainer_addItem_t FillingContainer_addItem = (FillingContainer_addItem_t) 0x92aa0; +// RakNetInstance + +static uint32_t RakNetInstance_peer_property_offset = 0x4; + // RakNet::RakPeer typedef struct RakNet_SystemAddress (*RakNet_RakPeer_GetSystemAddressFromGuid_t)(unsigned char *rak_peer, struct RakNet_RakNetGUID guid); +static uint32_t RakNet_RakPeer_GetSystemAddressFromGuid_vtable_offset = 0xd0; // ServerSideNetworkHandler @@ -194,6 +260,7 @@ static ServerSideNetworkHandler_getPlayer_t ServerSideNetworkHandler_getPlayer = // Entity typedef void (*Entity_die_t)(unsigned char *entity, unsigned char *cause); +static uint32_t Entity_die_vtable_offset = 0x130; // Inventory @@ -202,6 +269,8 @@ static Inventory_selectSlot_t Inventory_selectSlot = (Inventory_selectSlot_t) 0x // TripodCameraRenderer +#define TRIPOD_CAMERA_RENDERER_SIZE 0x193 + typedef unsigned char *(*TripodCameraRenderer_t)(unsigned char *renderer); static TripodCameraRenderer_t TripodCameraRenderer = (TripodCameraRenderer_t) 0x6583c; @@ -213,6 +282,10 @@ static EntityRenderDispatcher_t EntityRenderDispatcher = (EntityRenderDispatcher typedef void (*EntityRenderDispatcher_assign_t)(unsigned char *dispatcher, unsigned char entity_id, unsigned char *renderer); static EntityRenderDispatcher_assign_t EntityRenderDispatcher_assign = (EntityRenderDispatcher_assign_t) 0x6094c; +// TileEntity + +static uint32_t TileEntity_id_property_offset = 0x18; // int32_t + // ItemRenderer typedef float (*ItemRenderer_renderGuiItemCorrect_t)(unsigned char *font, unsigned char *textures, unsigned char *item_instance, int32_t param_1, int32_t param_2); @@ -278,6 +351,8 @@ static ServerSideNetworkHandler_displayGameMessage_t ServerSideNetworkHandler_di // SimpleChooseLevelScreen +#define SIMPLE_LEVEL_CHOOSE_SCREEN_SIZE 0x68 + typedef unsigned char *(*SimpleChooseLevelScreen_t)(unsigned char *simple_choose_level_screen, std::string const& world_name); static SimpleChooseLevelScreen_t SimpleChooseLevelScreen = (SimpleChooseLevelScreen_t) 0x31404; diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index 23a088099..b9b169de1 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -69,8 +69,8 @@ static void Gui_renderChatMessages_injection(unsigned char *gui, int32_t param_1 // Call Original Method (*Gui_renderChatMessages)(gui, param_1, param_2, param_3, font); // Calculate Selected Item Text Scale - unsigned char *minecraft = *(unsigned char **) (gui + 0x9f4); - int32_t screen_width = *(int32_t *) (minecraft + 0x20); + unsigned char *minecraft = *(unsigned char **) (gui + Gui_minecraft_property_offset); + int32_t screen_width = *(int32_t *) (minecraft + Minecraft_screen_width_property_offset); float scale = ((float) screen_width) * *InvGuiScale; // Render Selected Item Text (*Gui_renderOnSelectItemNameText)(gui, (int32_t) scale, font, param_1 - 0x13); @@ -81,7 +81,7 @@ static void Gui_tick_injection(unsigned char *gui) { // Call Original Method (*Gui_tick)(gui); // Handle Reset - float *selected_item_text_timer = (float *) (gui + 0x9fc); + float *selected_item_text_timer = (float *) (gui + Gui_selected_item_text_timer_property_offset); if (reset_selected_item_text_timer) { // Reset *selected_item_text_timer = 0; diff --git a/mods/src/options/options.c b/mods/src/options/options.c index 7297fedfc..281c32189 100644 --- a/mods/src/options/options.c +++ b/mods/src/options/options.c @@ -31,17 +31,17 @@ static void Minecraft_init_injection(unsigned char *this) { // Call Original Method (*Minecraft_init)(this); - unsigned char *options = this + 0x3c; + unsigned char *options = this + Minecraft_options_property_offset; // Enable Fancy Graphics - *(options + 0x17) = fancy_graphics; + *(options + Options_fancy_graphics_property_offset) = fancy_graphics; // Enable Crosshair In Touch GUI - *(options + 0x105) = 1; + *(options + Options_split_controls_property_offset) = 1; // Peaceful Mode - *(int32_t *) (options + 0xe8) = peaceful_mode ? 0 : 2; + *(int32_t *) (options + Options_split_controls_property_offset) = peaceful_mode ? 0 : 2; // 3D Anaglyph - *(options + 0x15) = anaglyph; + *(options + Options_3d_anaglyph_property_offset) = anaglyph; // Smooth Lighting - *(options + 0x18) = smooth_lighting; + *(options + Options_ambient_occlusion_property_offset) = smooth_lighting; } // Enable Touch GUI diff --git a/mods/src/server/server.cpp b/mods/src/server/server.cpp index 683417abd..3d603399b 100644 --- a/mods/src/server/server.cpp +++ b/mods/src/server/server.cpp @@ -113,7 +113,7 @@ static int last_progress = -1; static const char *last_message = NULL; static void print_progress(unsigned char *minecraft) { const char *message = (*Minecraft_getProgressMessage)(minecraft); - int32_t progress = *(int32_t *) (minecraft + 0xc60); + int32_t progress = *(int32_t *) (minecraft + Minecraft_progress_property_offset); if ((*Minecraft_isLevelGenerated)(minecraft)) { message = "Ready"; progress = -1; @@ -147,19 +147,19 @@ typedef void (*player_callback_t)(unsigned char *minecraft, std::string username // Get Vector Of Players In Level std::vector server_internal_get_players(unsigned char *level) { - return *(std::vector *) (level + 0x60); + return *(std::vector *) (level + Level_players_property_offset); } // Get Player's Username -std::string server_internal_get_server_player_username(unsigned char *player) { - return *(char **) (player + 0xbf4); +std::string server_internal_get_player_username(unsigned char *player) { + return *(char **) (player + Player_username_property_offset); } // Get Level From Minecraft unsigned char *server_internal_get_level(unsigned char *minecraft) { - return *(unsigned char **) (minecraft + 0x188); + return *(unsigned char **) (minecraft + Minecraft_level_property_offset); } // Get minecraft from ServerPlayer unsigned char *server_internal_get_minecraft(unsigned char *player) { - return *(unsigned char **) (player + 0xc8c); + return *(unsigned char **) (player + ServerPlayer_minecraft_property_offset); } // Find Players With Username And Run Callback @@ -170,7 +170,7 @@ static void find_players(unsigned char *minecraft, std::string target_username, for (std::size_t i = 0; i < players.size(); i++) { // Iterate Players unsigned char *player = players[i]; - std::string username = server_internal_get_server_player_username(player); + std::string username = server_internal_get_player_username(player); if (all_players || username == target_username) { // Run Callback (*callback)(minecraft, username, player); @@ -182,23 +182,23 @@ static void find_players(unsigned char *minecraft, std::string target_username, } } -static RakNet_RakNetGUID *get_rak_net_guid(unsigned char *player) { - return (RakNet_RakNetGUID *) (player + 0xc08); +static RakNet_RakNetGUID get_rak_net_guid(unsigned char *player) { + return *(RakNet_RakNetGUID *) (player + ServerPlayer_guid_property_offset); } static RakNet_SystemAddress get_system_address(unsigned char *rak_peer, RakNet_RakNetGUID guid) { unsigned char *rak_peer_vtable = *(unsigned char **) rak_peer; - RakNet_RakPeer_GetSystemAddressFromGuid_t RakNet_RakPeer_GetSystemAddressFromGuid = *(RakNet_RakPeer_GetSystemAddressFromGuid_t *) (rak_peer_vtable + 0xd0); + RakNet_RakPeer_GetSystemAddressFromGuid_t RakNet_RakPeer_GetSystemAddressFromGuid = *(RakNet_RakPeer_GetSystemAddressFromGuid_t *) (rak_peer_vtable + RakNet_RakPeer_GetSystemAddressFromGuid_vtable_offset); // Get SystemAddress return (*RakNet_RakPeer_GetSystemAddressFromGuid)(rak_peer, guid); } static unsigned char *get_rak_peer(unsigned char *minecraft) { - unsigned char *rak_net_instance = *(unsigned char **) (minecraft + 0x170); - return *(unsigned char **) (rak_net_instance + 0x4); + unsigned char *rak_net_instance = *(unsigned char **) (minecraft + Minecraft_rak_net_instance_property_offset); + return *(unsigned char **) (rak_net_instance + RakNetInstance_peer_property_offset); } // Get IP From Player static char *get_player_ip(unsigned char *minecraft, unsigned char *player) { - RakNet_RakNetGUID guid = *get_rak_net_guid(player); + RakNet_RakNetGUID guid = get_rak_net_guid(player); unsigned char *rak_peer = get_rak_peer(minecraft); RakNet_SystemAddress address = get_system_address(rak_peer, guid); // Get IP @@ -227,7 +227,7 @@ static void ban_callback(unsigned char *minecraft, std::string username, unsigne // Kill Player static void kill_callback(__attribute__((unused)) unsigned char *minecraft, __attribute__((unused)) std::string username, unsigned char *player) { unsigned char *player_vtable = *(unsigned char **) player; - Entity_die_t Entity_die = *(Entity_die_t *) (player_vtable + 0x130); + Entity_die_t Entity_die = *(Entity_die_t *) (player_vtable + Entity_die_vtable_offset); (*Entity_die)(player, NULL); INFO("Killed: %s", username.c_str()); } @@ -270,7 +270,7 @@ static void handle_server_stop(unsigned char *minecraft) { // Get ServerSideNetworkHandler From Minecraft static unsigned char *get_server_side_network_handler(unsigned char *minecraft) { - return *(unsigned char **) (minecraft + 0x174); + return *(unsigned char **) (minecraft + Minecraft_server_side_network_handler_property_offset); } // Handle Commands @@ -483,6 +483,7 @@ static void server_init() { overwrite_calls((void *) Level_saveLevelData, (void *) Level_saveLevelData_injection); // Exit handler signal(SIGINT, exit_handler); + signal(SIGTERM, exit_handler); // Print Chat To Log overwrite_calls((void *) Gui_addMessage, (void *) Gui_addMessage_injection); // Set Max Players diff --git a/mods/src/server/server_internal.h b/mods/src/server/server_internal.h index 92d555a7f..3f9a81f29 100644 --- a/mods/src/server/server_internal.h +++ b/mods/src/server/server_internal.h @@ -8,7 +8,7 @@ std::string server_internal_get_world_name(); unsigned char *server_internal_get_level(unsigned char *minecraft); std::vector server_internal_get_players(unsigned char *level); -std::string server_internal_get_server_player_username(unsigned char *player); +std::string server_internal_get_player_username(unsigned char *player); unsigned char *server_internal_get_minecraft(unsigned char *player); #endif \ No newline at end of file diff --git a/mods/src/textures/textures.cpp b/mods/src/textures/textures.cpp index a07665f5c..cf2e64387 100644 --- a/mods/src/textures/textures.cpp +++ b/mods/src/textures/textures.cpp @@ -12,7 +12,7 @@ static void Minecraft_tick_injection(unsigned char *minecraft, int32_t param_1, (*Minecraft_tick)(minecraft, param_1, param_2); // Tick Dynamic Textures - unsigned char *textures = *(unsigned char **) (minecraft + 0x164); + unsigned char *textures = *(unsigned char **) (minecraft + Minecraft_textures_property_offset); if (textures != NULL) { (*Textures_tick)(textures, true); } @@ -20,14 +20,14 @@ static void Minecraft_tick_injection(unsigned char *minecraft, int32_t param_1, // Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled static float ItemRenderer_renderGuiItemCorrect_injection(unsigned char *font, unsigned char *textures, unsigned char *item_instance, int32_t param_1, int32_t param_2) { - int32_t leaves_id = *(int32_t *) (*Tile_leaves + 0x8); - int32_t grass_id = *(int32_t *) (*Tile_grass + 0x8); + int32_t leaves_id = *(int32_t *) (*Tile_leaves + Tile_id_property_offset); + int32_t grass_id = *(int32_t *) (*Tile_grass + Tile_id_property_offset); // Replace Rendered Item With Carried Variant unsigned char *carried_item_instance = NULL; if (item_instance != NULL) { - int32_t id = *(int32_t *) (item_instance + 0x4); - int32_t count = *(int32_t *) item_instance; - int32_t auxilary = *(int32_t *) (item_instance + 0x8); + int32_t id = *(int32_t *) (item_instance + ItemInstance_id_property_offset); + int32_t count = *(int32_t *) (item_instance + ItemInstance_count_property_offset); + int32_t auxilary = *(int32_t *) (item_instance + ItemInstance_auxilary_property_offset); if (id == leaves_id) { carried_item_instance = (unsigned char *) ::operator new(ITEM_INSTANCE_SIZE); (*ItemInstance_constructor_title_extra)(carried_item_instance, *Tile_leaves_carried, count, auxilary);