Add And Use patch_address()
minecraft-pi-docker/pipeline/head There was a failure building this commit Details

This commit is contained in:
TheBrokenRail 2020-10-02 19:28:31 -04:00
parent 73afa13af4
commit e5d1a0578c
3 changed files with 7 additions and 4 deletions

View File

@ -30,6 +30,7 @@ extern "C" {
void *overwrite(void *start, void *target);
void revert_overwrite(void *start, void *original);
void patch(void *start, unsigned char patch[]);
void patch_address(void *start, void *target);
#ifdef __cplusplus
}

View File

@ -66,3 +66,8 @@ void patch(void *start, unsigned char patch[]) {
memcpy(data, patch, 4);
END_PATCH(1);
}
void patch_address(void *start, void *target) {
unsigned char patch_data[4] = {target & 0xff, (target >> 8) & 0xff, (target >> 16) & 0xff, (target >> 24) & 0xff};
patch(start, patch_data);
}

View File

@ -185,8 +185,5 @@ __attribute__((constructor)) static void init() {
// Change Username
const char *username = get_username();
uint32_t username_addr = (uint32_t) username;
fprintf(stderr, "0x%08x", username_addr);
unsigned char username_patch[4] = {username_addr & 0xff, (username_addr >> 8) & 0xff, (username_addr >> 16) & 0xff, (username_addr >> 24) & 0xff};
patch((void *) 0x18fd4, username_patch);
patch_address((void *) 0x18fd4, username);
}