Пример #1
0
int32_t isInMiiMakerHBL() {
    if (OSGetTitleID != 0 && (
                OSGetTitleID() == 0x000500101004A200 || // mii maker eur
                OSGetTitleID() == 0x000500101004A100 || // mii maker usa
                OSGetTitleID() == 0x000500101004A000 ||// mii maker jpn
                OSGetTitleID() == 0x0005000013374842)) {
        return 1;
    }
    return 0;
}
Пример #2
0
void TCPServer::StartTCPThread(TCPServer * server){
    s32 priority = 28;
    if(OSGetTitleID() == 0x00050000101c9300 || //The Legend of Zelda Breath of the Wild JPN
       OSGetTitleID() == 0x00050000101c9400 || //The Legend of Zelda Breath of the Wild USA
       OSGetTitleID() == 0x00050000101c9500 || //The Legend of Zelda Breath of the Wild EUR
       OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
       OSGetTitleID() == 0x00050000101a3c00){  //The Binding of Isaac: Rebirth USA
        priority = 10;
        printf("TCPServer::StartTCPThread(line %d): This game needs higher thread priority. We set it to %d\n",__LINE__,priority);
    }
    TCPServer::pThread = ControllerPatcherThread::create(TCPServer::DoTCPThread, (void*)server, ControllerPatcherThread::eAttributeAffCore2,priority);
    TCPServer::pThread->resumeThread();
}
Пример #3
0
void
WHBProcInit()
{
   uint64_t titleID = OSGetTitleID();

   // Homebrew Launcher does not like the standard ProcUI application loop,
   // so instead we disable the home buttom menu and use the home button
   // to trigger an exit.
   if (titleID == HBL_TITLE_ID ||
       titleID == MII_MAKER_JPN_TITLE_ID ||
       titleID == MII_MAKER_USA_TITLE_ID ||
       titleID == MII_MAKER_EUR_TITLE_ID) {
      // Important: OSEnableHomeButtonMenu must come before ProcUIInitEx.
      OSEnableHomeButtonMenu(FALSE);
      sFromHBL = TRUE;
   }

   sMainCore = OSGetCoreId();
   sRunning = TRUE;
   ProcUIInitEx(&procSaveCallback, NULL);
   ProcUIRegisterCallback(PROCUI_CALLBACK_HOME_BUTTON_DENIED, &procHomeButtonDenied, NULL, 100);
}
Пример #4
0
int LoadXmlParameters(ReducedCosAppXmlInfo * xmlInfo, const char *rpx_name, const char *path)
{
    //--------------------------------------------------------------------------------------------
    // setup default data
    //--------------------------------------------------------------------------------------------
    memset(xmlInfo, 0, sizeof(ReducedCosAppXmlInfo));
    xmlInfo->version_cos_xml = 18;             // default for most games
    xmlInfo->os_version = 0x000500101000400A;  // default for most games
    xmlInfo->title_id = OSGetTitleID();        // use mii maker ID
    xmlInfo->app_type = 0x80000000;            // default for most games
    xmlInfo->cmdFlags = 0;                     // default for most games
    strlcpy(xmlInfo->rpx_name, rpx_name, sizeof(xmlInfo->rpx_name));
    xmlInfo->max_size = 0x40000000;            // default for most games
    xmlInfo->avail_size = 0;                   // default for most games
    xmlInfo->codegen_size = 0;                 // default for most games
    xmlInfo->codegen_core = 1;                 // default for most games
    xmlInfo->max_codesize = 0x03000000;        // i think this is the best for most games
    xmlInfo->overlay_arena = 0;                // only very few have that set to 1
    xmlInfo->exception_stack0_size = 0x1000;   // default for most games
    xmlInfo->exception_stack1_size = 0x1000;   // default for most games
    xmlInfo->exception_stack2_size = 0x1000;   // default for most games
    xmlInfo->sdk_version = 20909;              // game dependent, lets take the one from mii maker
    xmlInfo->title_version = 0;                // game dependent, we say its 0
    //--------------------------------------------------------------------------------------------
    char* path_copy = (char*)malloc(FS_MAX_MOUNTPATH_SIZE);
    if (!path_copy)
        return -1;

    char* xmlNodeData = (char*)malloc(XML_BUFFER_SIZE);
    if(!xmlNodeData) {
        free(path_copy);
        return -3;
    }

    // create path
    snprintf(path_copy, FS_MAX_MOUNTPATH_SIZE, "%s/cos.xml", path);

    char* xmlData = NULL;
    u32 xmlSize = 0;

    if(LoadFileToMem(path_copy, (u8**) &xmlData, &xmlSize) > 0)
    {
        // ensure 0 termination
        xmlData[XML_BUFFER_SIZE-1] = 0;


        if(XML_GetNodeText(xmlData, "version", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 10);
            xmlInfo->version_cos_xml = value;
        }
        if(XML_GetNodeText(xmlData, "cmdFlags", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 10);
            xmlInfo->cmdFlags = value;
        }
        // always use RPX name from FS
        //if(XML_GetNodeText(xmlData, "argstr", xmlNodeData, XML_BUFFER_SIZE))
        //{
        //    strlcpy(xmlInfo->rpx_name, xmlNodeData, sizeof(xmlInfo->rpx_name));
        //}
        if(XML_GetNodeText(xmlData, "avail_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->avail_size = value;
        }
        if(XML_GetNodeText(xmlData, "codegen_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->codegen_size = value;
        }
        if(XML_GetNodeText(xmlData, "codegen_core", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->codegen_core = value;
        }
        if(XML_GetNodeText(xmlData, "max_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->max_size = value;
        }
        if(XML_GetNodeText(xmlData, "max_codesize", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->max_codesize = value;
        }
        if(XML_GetNodeText(xmlData, "overlay_arena", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->overlay_arena = value;
        }
        if(XML_GetNodeText(xmlData, "default_stack0_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->default_stack0_size = value;
        }
        if(XML_GetNodeText(xmlData, "default_stack1_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->default_stack1_size = value;
        }
        if(XML_GetNodeText(xmlData, "default_stack2_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->default_stack2_size = value;
        }
        if(XML_GetNodeText(xmlData, "default_redzone0_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->default_redzone0_size = value;
        }
        if(XML_GetNodeText(xmlData, "default_redzone1_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->default_redzone1_size = value;
        }
        if(XML_GetNodeText(xmlData, "default_redzone2_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->default_redzone2_size = value;
        }
        if(XML_GetNodeText(xmlData, "exception_stack0_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->exception_stack0_size = value;
        }
        if(XML_GetNodeText(xmlData, "exception_stack1_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->exception_stack0_size = value;
        }
        if(XML_GetNodeText(xmlData, "exception_stack2_size", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->exception_stack0_size = value;
        }
    }

    //! free previous XML data memory
    free(xmlData);

    // create path
    snprintf(path_copy, FS_MAX_MOUNTPATH_SIZE, "%s/app.xml", path);

    if(LoadFileToMem(path_copy, (u8**) &xmlData, &xmlSize) > 0)
    {
        // ensure 0 termination
        xmlData[XML_BUFFER_SIZE-1] = 0;

        //--------------------------------------------------------------------------------------------
        // version tag is still unknown where it is used
        //--------------------------------------------------------------------------------------------
        if(XML_GetNodeText(xmlData, "os_version", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint64_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->os_version = value;
        }
        if(XML_GetNodeText(xmlData, "title_id", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint64_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->title_id = value;

        }
        if(XML_GetNodeText(xmlData, "title_version", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->title_version = value;
        }
        if(XML_GetNodeText(xmlData, "sdk_version", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 10);
            xmlInfo->sdk_version = value;
        }
        if(XML_GetNodeText(xmlData, "app_type", xmlNodeData, XML_BUFFER_SIZE))
        {
            uint32_t value = m_strtoll(xmlNodeData, 0, 16);
            xmlInfo->app_type = value;
        }
        //--------------------------------------------------------------------------------------------
        // group_id tag is still unknown where it is used
        //--------------------------------------------------------------------------------------------
    }

    free(xmlData);
    free(xmlNodeData);
    free(path_copy);

    return 0;
}
Пример #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;
}