Skip to content

Commit

Permalink
Fixed menu_hook conflict with tweak-enable-debug-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
j005u committed Apr 7, 2023
1 parent 5ad05b5 commit d077b21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ipk/control/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: wtfos-modloader
Version: 0.2.0
Version: 0.2.1
Maintainer: Joonas Trussmann <[email protected]>
Description: Configurable LD_PRELOAD injector for DJI services
Architecture: armv7-3.2
Expand Down
17 changes: 15 additions & 2 deletions menu_hook/jni/menu_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

static void *guiLib = 0;
static uint32_t (* getSelected)(void* this) = 0;
static unsigned int (* getSize)(void* this) = 0;
unsigned int numBaseItems = 0;

void __attribute__((constructor)) menu_hook_init() {
readApps(DESKTOP_DIR);
Expand Down Expand Up @@ -50,10 +52,21 @@ uint32_t _ZN18GlassRacingTopMenu11onMenuInputEP9MMSWidgetP13MMSInputEvent(void *

//(input_event + 4) == 3 //joystick button pressed.
if(((*(int *)input_event == 1) && (*(int *)(input_event + 4) == 3))){
if(numBaseItems == 0) {
if (getSize == 0){
getSize = dlsym (guiLib, "_ZN13MMSMenuWidget7getSizeEv");
if (getSize == 0)
{
printf("dlsym: %s\n", dlerror());
}
}
numBaseItems = getSize(menu_widget) - app_count;
}

int selected = getSelected(menu_widget);
//printf("SELECTED %d\n", selected);
if(selected > 3 && selected < 4 + app_count) {
int idx = selected - 4;
if(selected > (numBaseItems - 1) && selected < (numBaseItems + app_count)) {
int idx = selected - numBaseItems;
char cmd[255];
sprintf(&cmd, "sh -c '. /etc/mkshrc && %s'", apps[idx]->exec);
printf("menu_hook executing command %s", cmd);
Expand Down

0 comments on commit d077b21

Please sign in to comment.