Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

Commit

Permalink
dlsym() wrapper generator script (work-in-progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMrARM committed Jan 10, 2018
1 parent 233c911 commit 66e58ff
Show file tree
Hide file tree
Showing 39 changed files with 3,288 additions and 364 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ endif()
include_directories(${PNG_INCLUDE_DIRS})
include_directories(eglut)
include_directories(libs/rapidxml)
include_directories(hybris/include)

set(HYBRIS_SOURCES hybris/src/cache.c hybris/src/dlfcn.c hybris/src/hooks.c hybris/src/hooks_shm.c hybris/src/logging.c hybris/src/properties.c hybris/src/strlcpy.c hybris/src/ctype.c hybris/src/sysconf.c hybris/src/jb/dlfcn.c hybris/src/jb/linker.c hybris/src/jb/linker_environ.c hybris/src/jb/linker_format.c hybris/src/jb/rt.c)
set(EGLUT_SOURCES eglut/eglut.c eglut/eglut_x11.c)

set(COMMON_SOURCE_FILES src/common.cpp src/hook.cpp src/linux_appplatform.cpp src/minecraft/types.cpp src/minecraft/ImagePickingCallback.h src/minecraft/FilePickerSettings.h src/minecraft/Common.h src/minecraft/Xbox.h src/minecraft/string.cpp src/minecraft/string.h src/base64.cpp src/base64.h src/async_result_util.h src/extract.cpp src/extract.h src/path_helper.cpp src/path_helper.h src/log.cpp src/log.h)
set(COMMON_SOURCE_FILES src/common.cpp src/hook.cpp src/linux_appplatform.cpp src/minecraft/types.cpp src/minecraft/ImagePickingCallback.h src/minecraft/FilePickerSettings.h src/minecraft/Common.h src/minecraft/Xbox.h src/minecraft/string.cpp src/minecraft/string.h src/base64.cpp src/base64.h src/async_result_util.h src/extract.cpp src/extract.h src/path_helper.cpp src/path_helper.h src/log.cpp src/log.h src/minecraft/symbols.cpp src/minecraft/symbols.h)
set(CLIENT_SOURCE_FILES src/main.cpp src/amdfix.s src/linux_appplatform.cpp src/msa.cpp src/msa.h src/msa_token.h src/msa_network.cpp src/msa_network.h src/xboxlive.h src/xboxlive.cpp src/cll.cpp src/cll.h)
set(CLIENT_SOURCE_FILES_CEF src/browser.cpp src/browser.h src/xbox_login_browser.h src/xbox_login_browser.cpp src/initial_setup_browser.cpp src/initial_setup_browser.h)
set(CLIENT_SOURCE_FILES_PLAYAPI gplay_api/src/config.h gplay_api/src/config.cpp src/google_login_browser.h src/google_login_browser.cpp src/google_play_helper.cpp src/google_play_helper.h)
Expand Down
40 changes: 9 additions & 31 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "symbols/egl_symbols.h"
#include "symbols/fmod_symbols.h"
#include "symbols/libm_symbols.h"
#include "minecraft/symbols.h"
#include "minecraft/gl.h"
#include "minecraft/AppPlatform.h"
#include "minecraft/MinecraftGame.h"
Expand Down Expand Up @@ -177,7 +178,7 @@ static void minecraft_keyboard(char str[5], int action) {
}
std::stringstream ss;
ss << str;
Keyboard::Keyboard_feedText(ss.str(), false, 0);
Keyboard::feedText(ss.str(), false, 0);
}
}
bool modCTRL = false;
Expand All @@ -195,10 +196,10 @@ static void minecraft_keyboard_special(int key, int action) {
}
int mKey = getKeyMinecraft(key);
if (action == EGLUT_KEY_PRESS) {
Keyboard::Keyboard_feed((unsigned char) mKey, 1);
Keyboard::feed((unsigned char) mKey, 1);
//Keyboard::states[mKey] = 1;
} else if (action == EGLUT_KEY_RELEASE) {
Keyboard::Keyboard_feed((unsigned char) mKey, 0);
Keyboard::feed((unsigned char) mKey, 0);
//Keyboard::states[mKey] = 0;
}
}
Expand All @@ -210,7 +211,7 @@ static void minecraft_paste(const char* str, int len) {
l = 3;
else if ((c & 0b11100000) == 0b11000000)
l = 2;
Keyboard::Keyboard_feedText(mcpe::string(&str[i], (size_t) l), false, 0);
Keyboard::feedText(mcpe::string(&str[i], (size_t) l), false, 0);
}
}
static void minecraft_close() {
Expand Down Expand Up @@ -545,39 +546,17 @@ int main(int argc, char *argv[]) {

mcpe::string::empty = (mcpe::string*) hybris_dlsym(handle, "_ZN4Util12EMPTY_STRINGE");

Common::Common_getGameVersionStringNet = (mcpe::string (*)()) hybris_dlsym(handle, "_ZN6Common23getGameVersionStringNetEv");
minecraft_symbols_init(handle);

Log::info("Launcher", "Game version: %s", Common::Common_getGameVersionStringNet().c_str());
XboxLiveHelper::getCLL()->setAppVersion(Common::Common_getGameVersionStringNet().std());

gl::getOpenGLVendor = (mcpe::string (*)()) hybris_dlsym(handle, "_ZN2gl15getOpenGLVendorEv");
gl::getOpenGLRenderer = (mcpe::string (*)()) hybris_dlsym(handle, "_ZN2gl17getOpenGLRendererEv");
gl::getOpenGLVersion = (mcpe::string (*)()) hybris_dlsym(handle, "_ZN2gl16getOpenGLVersionEv");
gl::getOpenGLExtensions = (mcpe::string (*)()) hybris_dlsym(handle, "_ZN2gl19getOpenGLExtensionsEv");
mce::Platform::OGL::OGL_initBindings = (void (*)()) hybris_dlsym(handle, "_ZN3mce8Platform3OGL12InitBindingsEv");
Log::info("Launcher", "Game version: %s", Common::getGameVersionStringNet().c_str());
XboxLiveHelper::getCLL()->setAppVersion(Common::getGameVersionStringNet().std());

AppPlatform::myVtable = (void**) hybris_dlsym(handle, "_ZTV11AppPlatform");
AppPlatform::_singleton = (AppPlatform**) hybris_dlsym(handle, "_ZN11AppPlatform10mSingletonE");
AppPlatform::AppPlatform_construct = (void (*)(AppPlatform*)) hybris_dlsym(handle, "_ZN11AppPlatformC2Ev");
AppPlatform::AppPlatform_initialize = (void (*)(AppPlatform*)) hybris_dlsym(handle, "_ZN11AppPlatform10initializeEv");
AppPlatform::AppPlatform__fireAppFocusGained = (void (*)(AppPlatform*)) hybris_dlsym(handle, "_ZN11AppPlatform19_fireAppFocusGainedEv");

App::App_init = (void (*)(App*, AppContext&)) hybris_dlsym(handle, "_ZN3App4initER10AppContext");
MinecraftGame::MinecraftGame_construct = (void (*)(MinecraftGame*, int, char**)) hybris_dlsym(handle, "_ZN13MinecraftGameC2EiPPc");
MinecraftGame::MinecraftGame_destruct = (void (*)(MinecraftGame*)) hybris_dlsym(handle, "_ZN13MinecraftGameD2Ev");
MinecraftGame::MinecraftGame_update = (void (*)(MinecraftGame*)) hybris_dlsym(handle, "_ZN13MinecraftGame6updateEv");
MinecraftGame::MinecraftGame_setRenderingSize = (void (*)(MinecraftGame*, int, int)) hybris_dlsym(handle, "_ZN13MinecraftGame16setRenderingSizeEii");
MinecraftGame::MinecraftGame_setUISizeAndScale = (void (*)(MinecraftGame*, int, int, float)) hybris_dlsym(handle, "_ZN13MinecraftGame17setUISizeAndScaleEiif");
MinecraftGame::MinecraftGame_getPrimaryUserOptions = (std::shared_ptr<Options> (*)(MinecraftGame*)) hybris_dlsym(handle, "_ZN13MinecraftGame21getPrimaryUserOptionsEv");

Options::Options_getFullscreen = (bool (*)(Options*)) hybris_dlsym(handle, "_ZNK7Options13getFullscreenEv");
Options::Options_setFullscreen = (void (*)(Options*, bool)) hybris_dlsym(handle, "_ZN7Options13setFullscreenEb");

Mouse::feed = (void (*)(char, char, short, short, short, short)) hybris_dlsym(handle, "_ZN5Mouse4feedEccssss");

Keyboard::states = (int*) hybris_dlsym(handle, "_ZN8Keyboard7_statesE");
Keyboard::Keyboard_feed = (void (*)(unsigned char, int)) hybris_dlsym(handle, "_ZN8Keyboard4feedEhi");
Keyboard::Keyboard_feedText = (void (*)(const mcpe::string&, bool, unsigned char)) hybris_dlsym(handle, "_ZN8Keyboard8feedTextERKSsbh");

xbox::services::xbox_services_error_code_category = (void* (*)()) hybris_dlsym(handle, "_ZN4xbox8services33xbox_services_error_code_categoryEv");
pplx::task_completion_event_java_rps_ticket::task_completion_event_java_rps_ticket_set = (void (*)(pplx::task_completion_event_java_rps_ticket*, xbox::services::system::java_rps_ticket)) hybris_dlsym(handle, "_ZNK4pplx21task_completion_eventIN4xbox8services6system15java_rps_ticketEE3setES4_");
Expand All @@ -597,7 +576,6 @@ int main(int argc, char *argv[]) {
xbox::services::system::auth_config::auth_config_set_xtoken_composition = (void (*)(xbox::services::system::auth_config*, std::vector<xbox::services::system::token_identity_type>)) hybris_dlsym(handle, "_ZN4xbox8services6system11auth_config22set_xtoken_compositionESt6vectorINS1_19token_identity_typeESaIS4_EE");
xbox::services::system::auth_config::auth_config_xbox_live_endpoint = (mcpe::string const& (*)(xbox::services::system::auth_config*)) hybris_dlsym(handle, "_ZNK4xbox8services6system11auth_config18xbox_live_endpointEv");
xbox::services::java_interop::get_java_interop_singleton = (std::shared_ptr<xbox::services::java_interop> (*)()) hybris_dlsym(handle, "_ZN4xbox8services12java_interop26get_java_interop_singletonEv");
Social::MultiplayerXBL::MultiplayerXBL_MultiplayerXBL = (void (*)(Social::MultiplayerXBL*)) hybris_dlsym(handle, "_ZN6Social14MultiplayerXBLC2Ev");

Log::info("Launcher", "Creating window");
eglutInitWindowSize(windowWidth, windowHeight);
Expand All @@ -622,7 +600,7 @@ int main(int argc, char *argv[]) {
platform->initialize();

Log::trace("Launcher", "Initializing OpenGL bindings");
mce::Platform::OGL::initBindings();
mce::Platform::OGL::InitBindings();

Log::trace("Launcher", "Initializing MinecraftGame (create instance)");
client = new MinecraftGame(argc, argv);
Expand Down
6 changes: 1 addition & 5 deletions src/minecraft/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ struct AppContext {
class App {

public:
static void (*App_init)(App*, AppContext&);

void** vtable;

void init(AppContext& ctx) {
App_init(this, ctx);
}
void init(AppContext& ctx);

void quit() {
((void (*)(App*)) vtable[26])(this);
Expand Down
19 changes: 5 additions & 14 deletions src/minecraft/AppPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,17 @@ class AppPlatform {

public:
static void** myVtable;

static void (*AppPlatform_construct)(AppPlatform*);
static void (*AppPlatform_initialize)(AppPlatform*);
static void (*AppPlatform__fireAppFocusGained)(AppPlatform*);
static AppPlatform** _singleton;

void** vtable;
char filler[0xA0 - sizeof(void**)];
long long usedMemory, totalMemory, availableMemory;
char filler2[0x1000];

AppPlatform() {
AppPlatform_construct(this);
}
AppPlatform();

static AppPlatform** _singleton;
void _fireAppFocusGained() {
AppPlatform__fireAppFocusGained(this);
}
void initialize() {
AppPlatform_initialize(this);
}
void _fireAppFocusGained();

void initialize();

};
6 changes: 1 addition & 5 deletions src/minecraft/AutomationClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ class AutomationClient {

public:

static void (*AutomationClient_construct)(AutomationClient*, IMinecraftApp&);

char filler[0x300];

AutomationClient(IMinecraftApp& a) {
AutomationClient_construct(this, a);
}
AutomationClient(IMinecraftApp& a);


};
Expand Down
6 changes: 1 addition & 5 deletions src/minecraft/CommandOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class CommandOutput {

public:

static std::vector<CommandOutputMessage> const& (*CommandOutput_getMessages)(CommandOutput const*);

std::vector<CommandOutputMessage> const& getMessages() const {
return CommandOutput_getMessages(this);
}
std::vector<CommandOutputMessage> const& getMessages() const;

};
18 changes: 5 additions & 13 deletions src/minecraft/CommandOutputSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,24 @@

class CommandOrigin;
class CommandOutput;
namespace Automation { class AutomationClient; }

class CommandOutputSender {

public:

static void (*CommandOutputSender_construct)(CommandOutputSender*, Automation::AutomationClient&);
static void (*CommandOutputSender_destruct)(CommandOutputSender*);
static void (*CommandOutputSender_send)(CommandOutputSender*, CommandOrigin const&, CommandOutput const&);
static std::vector<mcpe::string> (*CommandOutputSender_translate)(std::vector<mcpe::string> const&);

static std::vector<mcpe::string> translate(std::vector<mcpe::string> const& v) {
return CommandOutputSender_translate(v);
}
static std::vector<mcpe::string> translate(std::vector<mcpe::string> const& v);

CommandOutputSender(Automation::AutomationClient& automationClient) {
CommandOutputSender_construct(this, automationClient);
}
CommandOutputSender(Automation::AutomationClient& automationClient);

virtual ~CommandOutputSender() {
CommandOutputSender_destruct(this);
}

virtual void send(CommandOrigin const& origin, CommandOutput const& output) {
CommandOutputSender_send(this, origin, output);
}
virtual void send(CommandOrigin const& origin, CommandOutput const& output);

virtual void registerOutputCallback() { }
virtual void registerOutputCallback();

};
2 changes: 1 addition & 1 deletion src/minecraft/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
class Common {

public:
static mcpe::string (*Common_getGameVersionStringNet)();
static mcpe::string getGameVersionStringNet();

};
6 changes: 1 addition & 5 deletions src/minecraft/DedicatedServerCommandOrigin.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ class DedicatedServerCommandOrigin : public CommandOrigin {

public:

static void (*DedicatedServerCommandOrigin_construct)(DedicatedServerCommandOrigin*, mcpe::string const&, Minecraft&);

char filler[0x1C];

DedicatedServerCommandOrigin(mcpe::string const& s, Minecraft& m) {
DedicatedServerCommandOrigin_construct(this, s, m);
}
DedicatedServerCommandOrigin(mcpe::string const& s, Minecraft& m);

};
6 changes: 1 addition & 5 deletions src/minecraft/FilePathManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ class FilePathManager {

char filler[0x20];

static void (*FilePathManager_construct)(FilePathManager*, mcpe::string, bool);

FilePathManager(mcpe::string str, bool b) {
FilePathManager_construct(this, std::move(str), b);
}
FilePathManager(mcpe::string, bool);


};
11 changes: 3 additions & 8 deletions src/minecraft/I18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ class SkinRepository;
class I18n {

public:

static mcpe::string (*I18n_get)(mcpe::string const&, std::vector<mcpe::string> const&);
static void (*I18n_chooseLanguage)(mcpe::string const&);
static void (*I18n_loadLanguages)(ResourcePackManager&, SkinRepository*, mcpe::string const&);

static void loadLanguages(ResourcePackManager& m, SkinRepository* r, mcpe::string const& s) {
I18n_loadLanguages(m, r, s);
}
static mcpe::string get(mcpe::string const&, std::vector<mcpe::string> const&);
static void chooseLanguage(mcpe::string const&);
static void loadLanguages(ResourcePackManager&, SkinRepository*, mcpe::string const&);

};
6 changes: 3 additions & 3 deletions src/minecraft/ImagePickingCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class ImagePickingCallback {

public:
virtual ~ImagePickingCallback();
virtual void onImagePickingSuccess(const mcpe::string&);
virtual void onImagePickingCanceled();
virtual ~ImagePickingCallback() = 0;
virtual void onImagePickingSuccess(const mcpe::string&) = 0;
virtual void onImagePickingCanceled() = 0;

};
4 changes: 2 additions & 2 deletions src/minecraft/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Keyboard {

public:

static void (*Keyboard_feed)(unsigned char, int);
static void (*Keyboard_feedText)(const mcpe::string&, bool, unsigned char);
static void feed(unsigned char, int);
static void feedText(mcpe::string const&, bool, unsigned char);

static int* states;

Expand Down
12 changes: 2 additions & 10 deletions src/minecraft/LevelSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ class LevelSettings {

public:

static void (*LevelSettings_construct)(LevelSettings*);
static void (*LevelSettings_construct2)(LevelSettings*, LevelSettings const&);

int seed; // 4
int gametype; // 8
int difficulty; // c
Expand All @@ -22,12 +19,7 @@ class LevelSettings {
bool mpGame, lanBroadcast, xblBroadcast, commandsEnabled, texturepacksRequired, overrideSavedSettings; // 2d, 2e, 2f, 30, 31, 32~34
char filler[0x300];

LevelSettings() {
LevelSettings_construct(this);
}
LevelSettings(LevelSettings const& org) {
//memcpy((void*) this, (void const*) &org, sizeof(LevelSettings));
LevelSettings_construct2(this, org);
}
LevelSettings();
LevelSettings(LevelSettings const& org);

};
6 changes: 1 addition & 5 deletions src/minecraft/Minecraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ class Minecraft {

public:

static MinecraftCommands* (*Minecraft_getCommands)(Minecraft*);

MinecraftCommands* getCommands() {
return Minecraft_getCommands(this);
}
MinecraftCommands* getCommands();

};
11 changes: 2 additions & 9 deletions src/minecraft/MinecraftCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@ class MinecraftCommands {

public:

static void (*MinecraftCommands_setOutputSender)(MinecraftCommands*, std::unique_ptr<CommandOutputSender>);
static MCRESULT (*MinecraftCommands_requestCommandExecution)(MinecraftCommands*, std::unique_ptr<CommandOrigin>, mcpe::string const&, int, bool);
void setOutputSender(std::unique_ptr<CommandOutputSender> sender) const;

void setOutputSender(std::unique_ptr<CommandOutputSender> sender) {
MinecraftCommands_setOutputSender(this, std::move(sender));
}

MCRESULT requestCommandExecution(std::unique_ptr<CommandOrigin> o, mcpe::string const& s, int i, bool b) {
MinecraftCommands_requestCommandExecution(this, std::move(o), s, i, b);
}
MCRESULT requestCommandExecution(std::unique_ptr<CommandOrigin> o, mcpe::string const& s, int i, bool b) const;

};
14 changes: 4 additions & 10 deletions src/minecraft/MinecraftEventing.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#pragma once

#include "string.h"

class IPackTelemetry {};

class MinecraftEventing : public IPackTelemetry {

public:

static void (*MinecraftEventing_construct)(MinecraftEventing*, mcpe::string const&);

static void (*MinecraftEventing_init)(MinecraftEventing*);

char filler[0x100];

MinecraftEventing(std::string const& str) {
MinecraftEventing_construct(this, str);
}
MinecraftEventing(mcpe::string const& str);

void init() {
MinecraftEventing_init(this);
}
void init();

};
Loading

0 comments on commit 66e58ff

Please sign in to comment.