yifanlu / taiHEN

CFW framework for PS Vita
MIT License
302 stars 46 forks source link

my application won't boot with my plugin #45

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi, while my application boot, my plugin cause a stuck on boot image

#include <stdlib.h>
#include <stdio.h>
#include <taihen.h>

// handle to our hook
static tai_hook_ref_t app_start_ref;
// our hook for app entry
int hook_app_start(SceSize argc, const void *args) {
  printf("hello world!\n");
  return TAI_CONTINUE(int, app_start_ref, argc, args);
}
// our own plugin entry
int module_start(SceSize argc, const void *args) {
  taiHookFunctionExport(&app_start_ref,  // Output a reference
                        "AppName",       // Name of module being hooked
                        TAI_ANY_LIBRARY, // If there's multiple libs exporting this
                        0x935CD196,      // Special NID specifying module_start
                        hook_app_start); // Name of the hook function
  return (0);
}
TARGET  = testplugin
OBJS    = main.o

LIBS    = -ltaihen_stub -lSceLibc_stub

PREFIX  = arm-vita-eabi
CC      = $(PREFIX)-gcc
CFLAGS  = -g -Wl,-q -Wall -O3 -nostartfiles
ASFLAGS = $(CFLAGS)
TYPE = suprx
PSVITAIP = 192.168.1.14

all: $(TARGET).$(TYPE)

%.$(TYPE): %.velf
    vita-make-fself $< $@

%.velf: %.elf
    vita-elf-create $< $@ taihen.json

$(TARGET).elf: $(OBJS)
    $(CC) $(CFLAGS) $^ $(LIBS) -o $@

clean:
    @rm -rf $(TARGET).$(TYPE) $(TARGET).velf $(TARGET).elf $(OBJS)

send: $(TARGET).$(TYPE)
    curl -T $(TARGET).$(TYPE) ftp://$(PSVITAIP):1337/ux0:/data/$(TARGET).$(TYPE)
    @echo "Plugin sended."

pretty simple plugin, but doesn't work, I looked for a long time without solution. Thanks for your help :-)

yifanlu commented 7 years ago

Don't return 0, return the success constant.

ghost commented 7 years ago
#include <stdlib.h>
#include <stdio.h>
#include <psp2/kernel/modulemgr.h>
#include <taihen.h>

// handle to our hook
static tai_hook_ref_t app_start_ref;
// our hook for app entry
int hook_app_start(SceSize argc, const void *args) {
  printf("hello world!\n");
  return TAI_CONTINUE(int, app_start_ref, argc, args);
}
// our own plugin entry
int module_start(SceSize argc, const void *args) {
  taiHookFunctionExport(&app_start_ref,  // Output a reference
                        "Crunchyroll",       // Name of module being hooked
                        TAI_ANY_LIBRARY, // If there's multiple libs exporting this
                        0x935CD196,      // Special NID specifying module_start
                        hook_app_start); // Name of the hook function
  return SCE_KERNEL_START_SUCCESS;
}

Same problem :/, I have update taiHen (library and header) (but use taihen.json beta3 because beta4 doesn't have teihen.json)

yifanlu commented 7 years ago

are you using the latest toolchin?

yifanlu commented 7 years ago

old toolchain is not compatible with taihen anymore. part of the change is removal of json in elf create

ghost commented 7 years ago

i have compiled the new toolchain, after compiling the plugin and retrying, the app crash (C2-12828-1) and my psvita doesn't respond (Forced to make a hard reboot)

(I removed taihen.json from Makefile)

yifanlu commented 7 years ago

Can I see the entirety of your code?

ghost commented 7 years ago
#include <stdlib.h>
#include <stdio.h>
#include <psp2/kernel/modulemgr.h>
#include <taihen.h>

// our own plugin entry
int module_start(SceSize argc, const void *args) {
  printf("hello world!\n");
  return SCE_KERNEL_START_SUCCESS;
}
TARGET  = testplugin
OBJS    = main.o

LIBS    = -ltaihen_stub -lSceLibc_stub

PREFIX  = arm-vita-eabi
CC      = $(PREFIX)-gcc
CFLAGS  = -g -Wl,-q -Wall -O3 -nostartfiles
ASFLAGS = $(CFLAGS)
TYPE = suprx
PSVITAIP = 192.168.1.14

all: $(TARGET).$(TYPE)

%.$(TYPE): %.velf
    vita-make-fself $< $@

%.velf: %.elf
    vita-elf-create $< $@

$(TARGET).elf: $(OBJS)
    $(CC) $(CFLAGS) $^ $(LIBS) -o $@

clean:
    @rm -rf $(TARGET).$(TYPE) $(TARGET).velf $(TARGET).elf $(OBJS)

send: $(TARGET).$(TYPE)
    curl -T $(TARGET).$(TYPE) ftp://$(PSVITAIP):1337/ux0:/data/$(TARGET).$(TYPE)
    @echo "Plugin sended."

but the code below have the same problem (not a problem of code) (use the same Makefile)

#include <stdlib.h>
#include <stdio.h>
#include <psp2/kernel/modulemgr.h>
#include <taihen.h>

// handle to our hook
static tai_hook_ref_t app_start_ref;
// our hook for app entry
int hook_app_start(SceSize argc, const void *args) {
  printf("hello world!\n");
  return TAI_CONTINUE(int, app_start_ref, argc, args);
}
// our own plugin entry
int module_start(SceSize argc, const void *args) {
  taiHookFunctionExport(&app_start_ref,  // Output a reference
                        "Crunchyroll",       // Name of module being hooked
                        TAI_ANY_LIBRARY, // If there's multiple libs exporting this
                        0x935CD196,      // Special NID specifying module_start
                        hook_app_start); // Name of the hook function
  return SCE_KERNEL_START_SUCCESS;
}

I use Crunchyroll application if its can help you, I will try another application

EDIT: On message application (NPXS10014) the application stuck on boot, all of my toolchain (vita-toolchain + teihen is up-to-date)

ghost commented 7 years ago

Now work 👍

Example of "yourcustomexports.yml"

testplugin:
  attributes: 0
  version:
    major: 1
    minor: 1
  main:
    start: module_start

If your app won't boot, try other app :-)