diff --git a/VERSION b/VERSION index 9fa5f12..f470771 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.10 +2.3.11 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5a231c8..824eb6d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +**2.3.11** +* ``--version`` Command Line Option +* TPS Measured In Benchmark & Server +* Front-Facing Third-Person +* GLESv1 Comparability Layer +* Miscellaneous Bug Fixes + **2.3.10** * Add Crash Report Dialog * Disable V-Sync By Default diff --git a/images/start.png b/images/start.png index fd41a23..eb3bb65 100644 Binary files a/images/start.png and b/images/start.png differ diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index 40a8dec..787811a 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -229,30 +229,6 @@ void bootstrap(int argc, char *argv[]) { // Get Binary Directory char *binary_directory = get_binary_directory(); - // Resolve Binary Path & Set MCPI_DIRECTORY - { - // Log - DEBUG("Resolving File Paths..."); - - // Resolve Full Binary Path - char *full_path = NULL; - safe_asprintf(&full_path, "%s/" MCPI_BINARY, binary_directory); - char *resolved_path = realpath(full_path, NULL); - ALLOC_CHECK(resolved_path); - free(full_path); - - // Set MCPI_EXECUTABLE_PATH - set_and_print_env("MCPI_EXECUTABLE_PATH", resolved_path); - - // Set MCPI_VANILLA_ASSETS_PATH - { - chop_last_component(&resolved_path); - string_append(&resolved_path, "/data"); - set_and_print_env("MCPI_VANILLA_ASSETS_PATH", resolved_path); - free(resolved_path); - } - } - // Set MCPI_REBORN_ASSETS_PATH { char *assets_path = realpath("/proc/self/exe", NULL); @@ -263,6 +239,20 @@ void bootstrap(int argc, char *argv[]) { free(assets_path); } + // Resolve Binary Path & Set MCPI_DIRECTORY + char *resolved_path = NULL; + { + // Log + DEBUG("Resolving File Paths..."); + + // Resolve Full Binary Path + char *full_path = NULL; + safe_asprintf(&full_path, "%s/" MCPI_BINARY, binary_directory); + resolved_path = realpath(full_path, NULL); + ALLOC_CHECK(resolved_path); + free(full_path); + } + // Fix MCPI Dependencies { // Log @@ -283,7 +273,7 @@ void bootstrap(int argc, char *argv[]) { #endif // Patch - patch_mcpi_elf_dependencies(linker); + patch_mcpi_elf_dependencies(resolved_path, linker); // Free Linker Path if (linker != NULL) { @@ -296,6 +286,19 @@ void bootstrap(int argc, char *argv[]) { } } + // Set MCPI_VANILLA_ASSETS_PATH + { + char *assets_path = strdup(resolved_path); + ALLOC_CHECK(assets_path); + chop_last_component(&assets_path); + string_append(&assets_path, "/data"); + set_and_print_env("MCPI_VANILLA_ASSETS_PATH", assets_path); + free(assets_path); + } + + // Free Resolved Path + free(resolved_path); + // Configure LD_LIBRARY_PATH { // Log diff --git a/launcher/src/patchelf.c b/launcher/src/patchelf.c index d770b9d..0d73717 100644 --- a/launcher/src/patchelf.c +++ b/launcher/src/patchelf.c @@ -9,10 +9,7 @@ // Duplicate MCPI Executable Into /tmp #define TMP_DIR "/tmp/.minecraft-pi-patched" -static void duplicate_mcpi_executable() { - // Get Original Path - const char *original_path = getenv("MCPI_EXECUTABLE_PATH"); - +static void duplicate_mcpi_executable(const char *original_path) { // Ensure Temporary Directory { // Check If It Exists @@ -89,9 +86,9 @@ static void duplicate_mcpi_executable() { } \ _macro_return_code; \ }) -void patch_mcpi_elf_dependencies(const char *linker) { +void patch_mcpi_elf_dependencies(const char *original_path, const char *linker) { // Duplicate MCPI executable into /tmp so it can be modified. - duplicate_mcpi_executable(); + duplicate_mcpi_executable(original_path); // Get Path char *exe = getenv("MCPI_EXECUTABLE_PATH"); diff --git a/launcher/src/patchelf.h b/launcher/src/patchelf.h index 4697681..02d42bd 100644 --- a/launcher/src/patchelf.h +++ b/launcher/src/patchelf.h @@ -4,7 +4,7 @@ extern "C" { #endif -void patch_mcpi_elf_dependencies(const char *linker); +void patch_mcpi_elf_dependencies(const char *original_path, const char *linker); char *patch_get_interpreter(const char *file); #ifdef __cplusplus diff --git a/libreborn/include/libreborn/elf.h b/libreborn/include/libreborn/elf.h index a59c214..da46b0c 100644 --- a/libreborn/include/libreborn/elf.h +++ b/libreborn/include/libreborn/elf.h @@ -13,9 +13,9 @@ extern "C" { #endif -// Find And Iterate Over All .text Sections In Current Binary -typedef void (*text_section_callback_t)(ElfW(Addr) section, ElfW(Word) size, void *data); -void iterate_text_sections(const char *exe, text_section_callback_t callback, void *data); +// Find And Iterate Over All Segments In Current Binary +typedef void (*segment_callback_t)(ElfW(Addr) section, ElfW(Word) size, void *data); +void iterate_segments(segment_callback_t callback, void *data); #ifdef __cplusplus } diff --git a/libreborn/src/patch/patch.c b/libreborn/src/patch/patch.c index e849958..91ffcea 100644 --- a/libreborn/src/patch/patch.c +++ b/libreborn/src/patch/patch.c @@ -117,7 +117,7 @@ void _overwrite_calls(const char *file, int line, void *start, void *target) { data.replacement = code_block; data.found = 0; - iterate_text_sections(getenv("MCPI_EXECUTABLE_PATH"), overwrite_calls_callback, &data); + iterate_segments(overwrite_calls_callback, &data); // Increment Code Block Position increment_code_block(); diff --git a/libreborn/src/util/elf.c b/libreborn/src/util/elf.c index 03fb393..f60b273 100644 --- a/libreborn/src/util/elf.c +++ b/libreborn/src/util/elf.c @@ -1,53 +1,28 @@ #include -// Find And Iterate Over All .text Sections In Current Binary -void iterate_text_sections(const char *exe, text_section_callback_t callback, void *data) { - // Load Main Binary - FILE *file_obj = fopen(exe, "rb"); - - // Verify Binary - if (!file_obj) { - ERR("Unable To Open Binary"); - } - - // Get File Size - fseek(file_obj, 0L, SEEK_END); - long int file_size = ftell(file_obj); - fseek(file_obj, 0L, SEEK_SET); - - // Map File To Pointer - unsigned char *file_map = (unsigned char *) mmap(0, file_size, PROT_READ, MAP_PRIVATE, fileno(file_obj), 0); - - // Parse ELF - ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_map; - ElfW(Shdr) *elf_section_headers = (ElfW(Shdr) *) (file_map + elf_header->e_shoff); - int elf_section_header_count = elf_header->e_shnum; - - // Locate Section Names - ElfW(Shdr) elf_shstrtab = elf_section_headers[elf_header->e_shstrndx]; - unsigned char *elf_shstrtab_p = file_map + elf_shstrtab.sh_offset; - - // Track .text Sections - int text_sections = 0; - - // Iterate Sections - for (int i = 0; i < elf_section_header_count; ++i) { - ElfW(Shdr) header = elf_section_headers[i]; - char *name = (char *) (elf_shstrtab_p + header.sh_name); - // Check Section Type - if (strcmp(name, ".text") == 0) { - // .text Section - (*callback)(header.sh_addr, header.sh_size, data); - text_sections++; +// Find And Iterate Over All Segments In Current Binary +typedef struct { + segment_callback_t callback; + void *data; +} dl_iterate_callback_data; +static int dl_iterate_callback(struct dl_phdr_info *info, __attribute__((unused)) size_t size, void *data) { + dl_iterate_callback_data *callback_data = (dl_iterate_callback_data *) data; + // Only Search Current Program + if (strcmp(info->dlpi_name, "") == 0) { + for (int i = 0; i < info->dlpi_phnum; i++) { + // Only Executable Segemnts + if (info->dlpi_phdr[i].p_type == PT_LOAD && (info->dlpi_phdr[i].p_flags & PF_X) != 0) { + // Callback + (*callback_data->callback)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, info->dlpi_phdr[i].p_memsz, callback_data->data); + } } } - - // Ensure At Least .text Section Was Scanned - if (text_sections < 1) { - ERR("Unable To Find .text Sectons"); - } - - // Unmap And Close File - munmap(file_map, file_size); - fclose(file_obj); + return 0; +} +void iterate_segments(segment_callback_t callback, void *data) { + dl_iterate_callback_data callback_data = { + .callback = callback, + .data = data + }; + dl_iterate_phdr(dl_iterate_callback, (void *) &callback_data); }