Example #1
0
/* Entry point */
extern "C" int Menu_Main(void)
{
    //!*******************************************************************
    //!                   Initialize function pointers                   *
    //!*******************************************************************
    //! do OS (for acquire) and sockets first so we got logging
    InitOSFunctionPointers();
    InitSocketFunctionPointers();

    log_init("192.168.1.103");
    log_print("Starting launcher\n");

    InitFSFunctionPointers();
    InitGX2FunctionPointers();
    InitSysFunctionPointers();
    InitVPadFunctionPointers();
    InitPadScoreFunctionPointers();
    InitAXFunctionPointers();
    InitCurlFunctionPointers();
    InstallExceptionHandler();

    log_print("Function exports loaded\n");

    //!*******************************************************************
    //!                    Initialize heap memory                        *
    //!*******************************************************************
    log_print("Initialize memory management\n");
    memoryInitialize();

    //!*******************************************************************
    //!                        Initialize FS                             *
    //!*******************************************************************
    log_printf("Mount SD partition\n");
    mount_sd_fat("sd");

    //!*******************************************************************
    //!                    Enter main application                        *
    //!*******************************************************************
    log_printf("Start main application\n");
    Application::instance()->exec();
    log_printf("Main application stopped\n");

    Application::destroyInstance();

    log_printf("Unmount SD\n");
    unmount_sd_fat("sd");
    log_printf("Release memory\n");
    memoryRelease();
    log_deinit();

    return 0;
}
Example #2
0
File: main.c Project: ajd4096/ddd
/* Entry point */
int Menu_Main(void)
{
    //!*******************************************************************
    //!                   Initialize function pointers                   *
    //!*******************************************************************
    //! do OS (for acquire) and sockets first so we got logging
    InitOSFunctionPointers();
    InitSocketFunctionPointers();
    InitFSFunctionPointers();
    InitVPadFunctionPointers();
    InitSysFunctionPointers();
    InitAocFunctionPointers();

    log_init("192.168.178.3");
    log_deinit();
    log_init("192.168.178.3");
    log_printf("Started %s\n", cosAppXmlInfoStruct.rpx_name);

    if(strcasecmp("men.rpx", cosAppXmlInfoStruct.rpx_name) == 0)
    {
        CheckPendingMetaDump();
        return EXIT_RELAUNCH_ON_LOAD;
    }
    else if(strlen(cosAppXmlInfoStruct.rpx_name) > 0 && strcasecmp("ffl_app.rpx", cosAppXmlInfoStruct.rpx_name) != 0)
    {
        StartDumper();
        return EXIT_RELAUNCH_ON_LOAD;
    }

    // initialize memory tables once on start
    memoryInitAreaTable();
    rpxRplTableInit();
    SetupKernelCallback();
    PatchMethodHooks();

    memoryInitialize();

    VPADInit();

    // Prepare screen
    int screen_buf0_size = 0;
    int screen_buf1_size = 0;

    // Init screen and screen buffers
    OSScreenInit();
    screen_buf0_size = OSScreenGetBufferSizeEx(0);
    screen_buf1_size = OSScreenGetBufferSizeEx(1);

    unsigned char *screenBuffer = MEM1_alloc(screen_buf0_size + screen_buf1_size, 0x40);

    OSScreenSetBufferEx(0, screenBuffer);
    OSScreenSetBufferEx(1, (screenBuffer + screen_buf0_size));

    OSScreenEnableEx(0, 1);
    OSScreenEnableEx(1, 1);

    char msg[80];
    uint8_t sel_ip = 3;
    int launchMethod = 0;
    int update_screen = 1;
    int vpadError = -1;
    VPADData vpad_data;
    u_serv_ip ip;
    ip.full = GetServerIp();
    int delay = 0;

    while (1)
    {
        // Read vpad
        VPADRead(0, &vpad_data, 1, &vpadError);

        if(update_screen)
        {
            OSScreenClearBufferEx(0, 0);
            OSScreenClearBufferEx(1, 0);

            // Print message
            PRINT_TEXT2(14, 1, "-- DDD v0.2 by Dimok --");
            PRINT_TEXT2(0, 5, "1.    Setup IP address of server application.");

            // Print ip digit selector
            uint8_t x_shift = 17 + 4 * sel_ip;
            PRINT_TEXT2(x_shift, 6, "vvv");

            PRINT_TEXT2(0, 7, "      Server IP: %3d.%3d.%3d.%3d", ip.digit[0], ip.digit[1], ip.digit[2], ip.digit[3]);

            PRINT_TEXT2(0, 10, "2.   Press A to install dumper and try to launch disc.");
            PRINT_TEXT2(0, 11, "  or Press X to install dumper and return to system menu.");

            PRINT_TEXT2(0, 13, "3.   Start the title to be dumped.");

            PRINT_TEXT2(0, 17, "Press home button to exit ...");


            OSScreenFlipBuffersEx(0);
            OSScreenFlipBuffersEx(1);
        }

        u32 pressedBtns = vpad_data.btns_d | vpad_data.btns_h;

        // Check for buttons
        // Home Button
        if (pressedBtns & VPAD_BUTTON_HOME) {
            launchMethod = 0;
            break;
        }
        // A Button
        if (pressedBtns & VPAD_BUTTON_A) {
            SetServerIp(ip.full);
            launchMethod = 1;
            break;
        }
        // A Button
        if (pressedBtns & VPAD_BUTTON_X) {
            SetServerIp(ip.full);
            launchMethod = 2;
            break;
        }
        // Left/Right Buttons
        if (vpad_data.btns_d & VPAD_BUTTON_LEFT )
        {
            if(sel_ip == 0)
                sel_ip = 3;
            else
                --sel_ip;
        }

        if (vpad_data.btns_d & VPAD_BUTTON_RIGHT)
        {
            sel_ip = ((sel_ip + 1) % 4);
        }

        // Up/Down Buttons
        if (pressedBtns & VPAD_BUTTON_UP)
        {
            if(--delay <= 0) {
                ip.digit[sel_ip]++;
                delay = (vpad_data.btns_d & VPAD_BUTTON_UP) ? 6 : 0;
            }
        }
        else if (pressedBtns & VPAD_BUTTON_DOWN)
        {
            if(--delay <= 0) {
                ip.digit[sel_ip]--;
                delay = (vpad_data.btns_d & VPAD_BUTTON_DOWN) ? 6 : 0;
            }
        }
        else {
            delay = 0;
        }

        // Button pressed ?
        update_screen = (pressedBtns & (VPAD_BUTTON_LEFT | VPAD_BUTTON_RIGHT | VPAD_BUTTON_UP | VPAD_BUTTON_DOWN)) ? 1 : 0;
        usleep(20000);
    }

	MEM1_free(screenBuffer);
	screenBuffer = NULL;

    log_deinit();

    memoryRelease();

    if(launchMethod == 0)
    {
        RestoreInstructions();
        return EXIT_SUCCESS;
    }
    else if(launchMethod == 1)
    {
        char buf_vol_odd[20];
        snprintf(buf_vol_odd, sizeof(buf_vol_odd), "%s", "/vol/storage_odd03");
        _SYSLaunchTitleByPathFromLauncher(buf_vol_odd, 18, 0);
    }
    else
    {
        SYSLaunchMenu();
    }

    return EXIT_RELAUNCH_ON_LOAD;
}
Example #3
0
int __entry_menu(int argc, char** argv) {
	InitOSFunctionPointers();
	InitVPadFunctionPointers();
	InitFSFunctionPointers();
	mount_sd_fat("sd");
	
	//Setup BATs for later
	InjectSyscall36((unsigned int)injectBAT);
	RunSyscall36();
	
	InstallExceptionHandler();
	
	initInputs();
	
	initVideo();
	videoDebugMessage(0, "All running!");
	
	//*((int*)0x04) = 4243;
	
	unsigned char* MEM2core = 0;
	unsigned int coreSize = 0;
	LoadFileToMem("sd://stella.elf", &MEM2core, &coreSize);

	void* core = (void*)CORES_BASE_ADDRESS;
	
	memcpy(core, MEM2core, coreSize); //Move core to MEM1
	free(MEM2core);
	
	int error = loadCore(core); //Load core symbols (UDynLoad)
	
	char buf[255];
	__os_snprintf(buf, 255, "Core loaded, error %d. Core at 0x%X", error, core);
	videoDebugMessage(1, buf);
	
	unsigned char* game = 0;
	unsigned int gameSize = 0;
	LoadFileToMem("sd://game.bin", &game, &gameSize);
	
	error = setupCore((void*)game, gameSize); //Initialise core
	
	__os_snprintf(buf, 255, "Setup core, error %d, game at %X size %X", error, game, gameSize);
	videoDebugMessage(2, buf);
	
	testVideoOutput();
	
	while (1) {
		pollInputs();
		if (UIInputCheckButton()) {
			break;
		}
	}
	
	
	
	//cleanup
	shutdownVideo();
	memset(core, 0, coreSize); //Delete core from memory or HBL will cry every time
	memset(game, 0, gameSize);
	InjectSyscall36((unsigned int)clearBAT);
	RunSyscall36();
	return 0;
}
Example #4
0
/* Entry point */
extern "C" int Menu_Main(void)
{
    //!*******************************************************************
    //!                   Initialize function pointers                   *
    //!*******************************************************************
    //! do OS (for acquire) and sockets first so we got logging
    InitOSFunctionPointers();
    InitSocketFunctionPointers();

    log_init(LOADIINE_LOGGER_IP);
    log_print("Starting Loadiine GX2 " LOADIINE_VERSION "\n");

    InitFSFunctionPointers();
    InitGX2FunctionPointers();
    InitSysFunctionPointers();
    InitVPadFunctionPointers();
    InitPadScoreFunctionPointers();
    InitAXFunctionPointers();
    InitCurlFunctionPointers();

    log_print("Function exports loaded\n");

    //!*******************************************************************
    //!                Initialize our kernel variables                   *
    //!*******************************************************************
    log_printf("Setup kernel variables\n");
    SetupKernelCallback();
    //!*******************************************************************
    //!                    Initialize heap memory                        *
    //!*******************************************************************
    log_print("Initialize memory management\n");
    memoryInitialize();

    //!*******************************************************************
    //!                        Initialize FS                             *
    //!*******************************************************************
    log_printf("Mount SD partition\n");
    mount_sd_fat("sd");

    //!*******************************************************************
    //!                       Patch Functions                            *
    //!*******************************************************************
    // We need to check if padcon should be enabled before hooking the functions
    log_printf("Load settings\n");
    CSettings::instance()->Load();

    int padmode = 0;
    switch(CSettings::getValueAsU8(CSettings::PadconMode))
    {
        case PADCON_ENABLED: {
            padmode = 1;
            log_printf("Padcon enabled\n");
            break;
        }
        default:
            break;
    }
    
    log_printf("Patch FS and loader functions\n");
    PatchMethodHooks(padmode);

    //!*******************************************************************
    //!                    Setup exception handler                       *
    //!*******************************************************************
    log_printf("Setup exception handler\n");
    setup_os_exceptions();

    //!*******************************************************************
    //!                    Enter main application                        *
    //!*******************************************************************
    log_printf("Start main application\n");
    Application::instance()->exec();
    log_printf("Main application stopped\n");

    Application::destroyInstance();
    
    CSettings::instance()->Save();
    CSettings::destroyInstance();

    log_printf("Unmount SD\n");
    unmount_sd_fat("sd");
    log_printf("Release memory\n");
    memoryRelease();
    log_printf("Loadiine peace out...\n");
    log_deinit();

    return 0;
}
Example #5
0
extern "C" int32_t Menu_Main(int32_t argc, char **argv) {
    if(gAppStatus == 2) {
        //"No, we don't want to patch stuff again.");
        return EXIT_RELAUNCH_ON_LOAD;
    }

    InitOSFunctionPointers();
    InitSocketFunctionPointers(); //For logging
    InitSysFunctionPointers();
    InitFSFunctionPointers();
    InitGX2FunctionPointers();
    InitSysFunctionPointers();
    InitVPadFunctionPointers();
    InitPadScoreFunctionPointers();
    InitAXFunctionPointers();
    InitProcUIFunctionPointers();

    log_init();

    DEBUG_FUNCTION_LINE("We have %d kb for plugins.\n",(PLUGIN_LOCATION_END_ADDRESS-getApplicationEndAddr())/1024);
    //setup_os_exceptions();

    DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
    DEBUG_FUNCTION_LINE("Sizeof dyn_linking_relocation_data_t %d\n",sizeof(dyn_linking_relocation_data_t));
    Init();

    init_kernel_syscalls();
    wups_init_kernel_syscalls();

    gGameTitleID = OSGetTitleID();

    int32_t result = 0;

    //Reset everything when were going back to the Mii Maker
    if(isInMiiMakerHBL()) {
        CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
        // Restore patches as the patched functions could change.
        RestorePatches();

        DynamicLinkingHelper::getInstance()->clearAll();

        //PluginLoader * pluginLoader  = PluginLoader::getInstance();
        //std::vector<PluginInformation *> pluginList = pluginLoader->getPluginInformation("sd:/wiiu/plugins/");
        //pluginLoader->loadAndLinkPlugins(pluginList);
        //pluginLoader->clearPluginInformation(pluginList);

        //!*******************************************************************
        //!                    Initialize heap memory                        *
        //!*******************************************************************
        DEBUG_FUNCTION_LINE("Initialize memory management\n");
        memoryInitialize();

        DEBUG_FUNCTION_LINE("Start main application\n");
        result = Application::instance()->exec();
        DEBUG_FUNCTION_LINE("Main application stopped result: %d\n",result);

        DEBUG_FUNCTION_LINE("Application::destroyInstance\n");
        Application::destroyInstance();

        DEBUG_FUNCTION_LINE("Release memory\n");
        memoryRelease();
        CSettings::destroyInstance();
        PluginLoader::destroyInstance();
    }

    if(result == APPLICATION_CLOSE_APPLY_MEMORY) {
        if(!MemoryMapping::isMemoryMapped()) {
            MemoryMapping::setupMemoryMapping();
        }
    }

    DEBUG_FUNCTION_LINE("Do relocations\n");

    std::vector<dyn_linking_relocation_entry_t *> relocations = DynamicLinkingHelper::getInstance()->getAllValidDynamicLinkingRelocations();
    DEBUG_FUNCTION_LINE("Found relocation information for %d functions\n",relocations.size());

    if(!DynamicLinkingHelper::getInstance()->fillRelocations(relocations)) {
        OSFatal("fillRelocations failed.");
    }

    if(!isInMiiMakerHBL()) {
        DEBUG_FUNCTION_LINE("Apply patches.\n");
        ApplyPatchesAndCallHookStartingApp();
        ConfigUtils::loadConfigFromSD();

        if(MemoryMapping::isMemoryMapped()) {
            DEBUG_FUNCTION_LINE("Mapping was already done. Running %016llX\n",gGameTitleID);
            readAndPrintSegmentRegister(NULL,NULL);
            MemoryMapping::readTestValuesFromMemory();
        } else {
            DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
            DEBUG_FUNCTION_LINE("<---------------- COPY PASTE ME START-----------------> \n");
            DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
            DEBUG_FUNCTION_LINE("Mapping was't done. Running %016llX\n",gGameTitleID);
            readAndPrintSegmentRegister(NULL,NULL);
            DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
            DEBUG_FUNCTION_LINE("<----------------- COPY PASTE ME END -----------------> \n");
            DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
        }
        return EXIT_RELAUNCH_ON_LOAD;
    }

    if(result == APPLICATION_CLOSE_APPLY || result == APPLICATION_CLOSE_APPLY_MEMORY) {
        CallHook(WUPS_LOADER_HOOK_INIT_KERNEL);
        CallHook(WUPS_LOADER_HOOK_INIT_FS);
        CallHook(WUPS_LOADER_HOOK_INIT_OVERLAY);
        CallHook(WUPS_LOADER_HOOK_INIT_PLUGIN);
        DEBUG_FUNCTION_LINE("Loading the system menu.\n");
        DeInit();
        SYSLaunchMenu();
        return EXIT_RELAUNCH_ON_LOAD;
    }

    DEBUG_FUNCTION_LINE("Let's go to back to the Homebrew Launcher\n");
    DEBUG_FUNCTION_LINE("Restoring the patched functions\n");
    RestorePatches();
    DEBUG_FUNCTION_LINE("Calling the plugin deinit hook\n");
    CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
    DEBUG_FUNCTION_LINE("Unmounting SD/USB devices\n");
    DeInit();
    DEBUG_FUNCTION_LINE("Bye bye!\n");
    return EXIT_SUCCESS;
}
Example #6
0
/* Entry point */
extern "C" int Menu_Main(void)
{
    //!*******************************************************************
    //!                   Initialize function pointers                   *
    //!*******************************************************************
    //! do OS (for acquire) and sockets first so we got logging
    InitOSFunctionPointers();
    InitSocketFunctionPointers();

    log_init(LOADIINE_LOGGER_IP);
    log_print("Starting Loadiine GX2 " LOADIINE_VERSION "\n");

    InitFSFunctionPointers();
    InitGX2FunctionPointers();
    InitSysFunctionPointers();
    InitVPadFunctionPointers();
    InitPadScoreFunctionPointers();
    InitAXFunctionPointers();
    InitCurlFunctionPointers();

    log_print("Function exports loaded\n");

    //!*******************************************************************
    //!                Initialize our kernel variables                   *
    //!*******************************************************************
    log_printf("Setup kernel variables\n");
    SetupKernelCallback();
    //!*******************************************************************
    //!                    Initialize heap memory                        *
    //!*******************************************************************
    log_print("Initialize memory management\n");
    memoryInitialize();

    //!*******************************************************************
    //!                        Initialize FS                             *
    //!*******************************************************************
    log_printf("Mount SD partition\n");
    mount_sd_fat("sd");

    //!*******************************************************************
    //!                       Patch Functions                            *
    //!*******************************************************************
    log_printf("Patch FS and loader functions\n");

    PatchMethodHooks();
    PatchSDK();

    //!*******************************************************************
    //!                    Setup exception handler                       *
    //!*******************************************************************
    log_printf("Setup exception handler\n");
    setup_os_exceptions();

    //!*******************************************************************
    //!                    Enter main application                        *
    //!*******************************************************************
    log_printf("Start main application\n");
    Application::instance()->exec();
    log_printf("Main application stopped\n");

    Application::destroyInstance();

    log_printf("Unmount SD\n");
    unmount_sd_fat("sd");
    log_printf("Release memory\n");
    memoryRelease();
    log_printf("Loadiine peace out...\n");
    log_deinit();

    return 0;
}
Example #7
0
/* Entry point */
extern "C" int Menu_Main(void)
{
    //!*******************************************************************
    //!                   Initialize function pointers                   *
    //!*******************************************************************
    //! do OS (for acquire) and sockets first so we got logging
    InitOSFunctionPointers();
    InitSocketFunctionPointers();

    log_init(LOADIINE_LOGGER_IP);
    log_print("Starting Loadiine GX2 " LOADIINE_VERSION "\n");

    InitFSFunctionPointers();
    InitGX2FunctionPointers();
    InitSysFunctionPointers();
    InitVPadFunctionPointers();
    InitPadScoreFunctionPointers();
    InitAXFunctionPointers();
    InitCurlFunctionPointers();

    InitAocFunctionPointers();
    InitACPFunctionPointers();



    log_printf("Function exports loaded\n");

    //!*******************************************************************
    //!                Initialize our kernel variables                   *
    //!*******************************************************************
    log_printf("Setup kernel variables\n");
    SetupKernelCallback();
    //!*******************************************************************
    //!                    Initialize heap memory                        *
    //!*******************************************************************
    log_print("Initialize memory management\n");
    memoryInitialize();

    //!*******************************************************************
    //!                        Initialize FS                             *
    //!*******************************************************************
    log_printf("Mount SD partition\n");
    mount_sd_fat("sd");

    //!*******************************************************************
    //!                       Read Configs for HID support               *
    //!*******************************************************************
    if(gConfig_done == HID_INIT_DONE) {
        log_print("Reading config files from SD Card\n");
        ConfigReader::getInstance(); //doing the magic automatically
        ConfigReader::destroyInstance();
        log_print("Done with reading config files from SD Card\n");
        gConfig_done = HID_SDCARD_READ;
    }

    //!*******************************************************************
    //!                       Patch Functions                            *
    //!*******************************************************************
    log_printf("Patch FS and loader functions\n");
    ApplyPatches();
    PatchSDK();

    //!*******************************************************************
    //!                    Setup exception handler                       *
    //!*******************************************************************
    log_printf("Setup exception handler\n");
    setup_os_exceptions();

    //!*******************************************************************
    //!                    Enter main application                        *
    //!*******************************************************************
    log_printf("Start main application\n");
    Application::instance()->exec();
    log_printf("Main application stopped\n");

    Application::destroyInstance();

    log_printf("Unmount SD\n");
    unmount_sd_fat("sd");
    log_printf("Release memory\n");
    memoryRelease();
    log_printf("Loadiine peace out...\n");
    //log_deinit();

    return 0;
}