Skip to content

Commit

Permalink
Patch vtable if possible, log an error
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Jan 4, 2021
1 parent 3a9eddc commit 2a16784
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/core_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@

#include <mcpelauncher/linker.h>
#include <mcpelauncher/patch_utils.h>
#include <log.h>

std::shared_ptr<GameWindow> CorePatches::currentGameWindow;

void CorePatches::install(void *handle) {
// void* ptr = linker::dlsym(handle, "_ZN3web4http6client7details35verify_cert_chain_platform_specificERN5boost4asio3ssl14verify_contextERKSs");
// PatchUtils::patchCallInstruction(ptr, (void*) +[]() { return true; }, true);


void** vta = &((void**) linker::dlsym(handle, "_ZTV21AppPlatform_android23"))[2];
PatchUtils::VtableReplaceHelper vtr (handle, vta, vta);
vtr.replace("_ZN11AppPlatform16hideMousePointerEv", +[]() {
currentGameWindow->setCursorDisabled(true);
});
vtr.replace("_ZN11AppPlatform16showMousePointerEv", +[]() {
currentGameWindow->setCursorDisabled(false);
});
void * appPlatform = linker::dlsym(handle, "_ZTV21AppPlatform_android23");
if(appPlatform) {
void** vta = &((void**) appPlatform)[2];
PatchUtils::VtableReplaceHelper vtr (handle, vta, vta);
vtr.replace("_ZN11AppPlatform16hideMousePointerEv", +[]() {
currentGameWindow->setCursorDisabled(true);
});
vtr.replace("_ZN11AppPlatform16showMousePointerEv", +[]() {
currentGameWindow->setCursorDisabled(false);
});
} else {
Log::error("CorePatches", "Failed to patch vtable _ZTV21AppPlatform_android23 not found");
}
}

void CorePatches::setGameWindow(std::shared_ptr<GameWindow> gameWindow) {
Expand Down

0 comments on commit 2a16784

Please sign in to comment.