This commit is contained in:
TheBrokenRail 2022-05-29 22:54:57 -04:00
parent 1743626113
commit 0dd0706f52
9 changed files with 67 additions and 85 deletions

View File

@ -1 +1 @@
2.3.10 2.3.11

View File

@ -1,5 +1,12 @@
# Changelog # 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** **2.3.10**
* Add Crash Report Dialog * Add Crash Report Dialog
* Disable V-Sync By Default * Disable V-Sync By Default

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 154 KiB

View File

@ -229,30 +229,6 @@ void bootstrap(int argc, char *argv[]) {
// Get Binary Directory // Get Binary Directory
char *binary_directory = 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 // Set MCPI_REBORN_ASSETS_PATH
{ {
char *assets_path = realpath("/proc/self/exe", NULL); char *assets_path = realpath("/proc/self/exe", NULL);
@ -263,6 +239,20 @@ void bootstrap(int argc, char *argv[]) {
free(assets_path); 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 // Fix MCPI Dependencies
{ {
// Log // Log
@ -283,7 +273,7 @@ void bootstrap(int argc, char *argv[]) {
#endif #endif
// Patch // Patch
patch_mcpi_elf_dependencies(linker); patch_mcpi_elf_dependencies(resolved_path, linker);
// Free Linker Path // Free Linker Path
if (linker != NULL) { 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 // Configure LD_LIBRARY_PATH
{ {
// Log // Log

View File

@ -9,10 +9,7 @@
// Duplicate MCPI Executable Into /tmp // Duplicate MCPI Executable Into /tmp
#define TMP_DIR "/tmp/.minecraft-pi-patched" #define TMP_DIR "/tmp/.minecraft-pi-patched"
static void duplicate_mcpi_executable() { static void duplicate_mcpi_executable(const char *original_path) {
// Get Original Path
const char *original_path = getenv("MCPI_EXECUTABLE_PATH");
// Ensure Temporary Directory // Ensure Temporary Directory
{ {
// Check If It Exists // Check If It Exists
@ -89,9 +86,9 @@ static void duplicate_mcpi_executable() {
} \ } \
_macro_return_code; \ _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 into /tmp so it can be modified.
duplicate_mcpi_executable(); duplicate_mcpi_executable(original_path);
// Get Path // Get Path
char *exe = getenv("MCPI_EXECUTABLE_PATH"); char *exe = getenv("MCPI_EXECUTABLE_PATH");

View File

@ -4,7 +4,7 @@
extern "C" { extern "C" {
#endif #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); char *patch_get_interpreter(const char *file);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -13,9 +13,9 @@
extern "C" { extern "C" {
#endif #endif
// Find And Iterate Over All .text Sections In Current Binary // Find And Iterate Over All Segments In Current Binary
typedef void (*text_section_callback_t)(ElfW(Addr) section, ElfW(Word) size, void *data); typedef void (*segment_callback_t)(ElfW(Addr) section, ElfW(Word) size, void *data);
void iterate_text_sections(const char *exe, text_section_callback_t callback, void *data); void iterate_segments(segment_callback_t callback, void *data);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -117,7 +117,7 @@ void _overwrite_calls(const char *file, int line, void *start, void *target) {
data.replacement = code_block; data.replacement = code_block;
data.found = 0; 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 Position
increment_code_block(); increment_code_block();

View File

@ -1,53 +1,28 @@
#include <libreborn/elf.h> #include <libreborn/elf.h>
// Find And Iterate Over All .text Sections In Current Binary // Find And Iterate Over All Segments In Current Binary
void iterate_text_sections(const char *exe, text_section_callback_t callback, void *data) { typedef struct {
// Load Main Binary segment_callback_t callback;
FILE *file_obj = fopen(exe, "rb"); void *data;
} dl_iterate_callback_data;
// Verify Binary static int dl_iterate_callback(struct dl_phdr_info *info, __attribute__((unused)) size_t size, void *data) {
if (!file_obj) { dl_iterate_callback_data *callback_data = (dl_iterate_callback_data *) data;
ERR("Unable To Open Binary"); // Only Search Current Program
} if (strcmp(info->dlpi_name, "") == 0) {
for (int i = 0; i < info->dlpi_phnum; i++) {
// Get File Size // Only Executable Segemnts
fseek(file_obj, 0L, SEEK_END); if (info->dlpi_phdr[i].p_type == PT_LOAD && (info->dlpi_phdr[i].p_flags & PF_X) != 0) {
long int file_size = ftell(file_obj); // Callback
fseek(file_obj, 0L, SEEK_SET); (*callback_data->callback)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, info->dlpi_phdr[i].p_memsz, callback_data->data);
// 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++;
} }
} }
// Ensure At Least .text Section Was Scanned
if (text_sections < 1) {
ERR("Unable To Find .text Sectons");
} }
return 0;
// Unmap And Close File }
munmap(file_map, file_size); void iterate_segments(segment_callback_t callback, void *data) {
fclose(file_obj); dl_iterate_callback_data callback_data = {
.callback = callback,
.data = data
};
dl_iterate_phdr(dl_iterate_callback, (void *) &callback_data);
} }