示例#1
0
int
main( void )
{
  struct Library* EMU10kxBase;
  struct EMU10kxAC97* EMU10kxAC97;
  ULONG value;

  EMU10kxBase = OpenLibrary( "DEVS:AHI/emu10kx.audio", VERSION );
  
  if( EMU10kxBase == NULL )
  {
    Printf( "Unable to open DEVS:AHI/emu10kx.audio version %ld.\n", VERSION );
    return RETURN_FAIL;
  }

  Forbid();
  EMU10kxAC97 = (struct EMU10kxAC97*) FindSemaphore( EMU10KX_AC97_SEMAPHORE );
  if( EMU10kxAC97 != NULL )
  {
    ObtainSemaphore( &EMU10kxAC97->Semaphore );
  }
  Permit();

  if( EMU10kxAC97 == NULL )
  {
    CloseLibrary( EMU10kxBase );
    Printf( "Unable to find semaphore '%s'.\n", (ULONG) EMU10KX_AC97_SEMAPHORE );
    return RETURN_FAIL;
  }

  Printf( "%ld EMU10kx cards found.\n", EMU10kxAC97->Cards );
  
  value = CallHook( &EMU10kxAC97->GetFunc, (Object*) EMU10kxBase,
		    0, AC97_CD_VOL );

  Printf( "CD volume on card 0 is 0x%04lx\n", value );

  Printf( "Setting it to 0x0000.\n" );
  CallHook( &EMU10kxAC97->SetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL, 0 );

  Delay( 3 * 50 );

  Printf( "Restoring it.\n" );
  CallHook( &EMU10kxAC97->SetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL, value );

  Printf( "Exiting.\n" );
  
  if( EMU10kxAC97 != NULL )
  {
    ReleaseSemaphore( &EMU10kxAC97->Semaphore );
  }

  CloseLibrary( EMU10kxBase );

  return RETURN_OK;
}
示例#2
0
int main(void)
{
  LONG ret = 0;

  if((UtilityBase = OpenLibrary("utility.library", 37)))
  {
    if(GETINTERFACE(IUtility, UtilityBase))
    {
      printf("Hello! I am a ");

      ret = CallHook(&HelloHook, "portable Hook");

      printf("%ld\n", (long int)ret);

      DROPINTERFACE(IUtility);
    }

    CloseLibrary(UtilityBase);
  }

  return 0;
}
示例#3
0
    const char *ToPath(int idx, string base_folder = "")
    {
		auto path = (string)ToString(idx);

		base_folder = base_folder + "/";
        auto new_path = base_folder + path;

		my_suppress_lock();
        CallHook("PathCheck", new_path, 1);
		my_allow_lock();

        if (IsType(-1, LUA_TSTRING))
        {
            auto path = (string)ToString(-1);
            path = path.replace("!/", "");

            Remove(-1);

            return path.c_str();
        }

        return new_path;
    }
示例#4
0
文件: preview.c 项目: jalkanen/ppt
VOID RedrawPreview( FRAME *pwframe, EXTBASE *PPTBase )
{
    D(bug("RedrawPreview( %08X, xb=%08X )\n",pwframe, PPTBase ));

    if( pwframe->preview.pf_Hook ) {
        CallHook( pwframe->preview.pf_Hook, (Object *)pwframe, ~0 );
    } else {
        /*
         *  Send message to the main window
         */
        struct IBox *ibox;

        GetAttr(AREA_AreaBox, pwframe->preview.pf_RenderArea, (ULONG *)&ibox );
        QuickRender( pwframe, pwframe->preview.pf_win->RPort,
                     ibox->Top, ibox->Left,
                     ibox->Height, ibox->Width, PPTBase );

#if 0
        DoMethod( pwframe->parent->disp->Win, WM_REPORT_ID, GID_DW_AREA,
                  WMRIF_TASK, globals->maintask, TAG_DONE );
#endif
    }
}
示例#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;
}