/** ** Load a game to file. ** ** @param filename File name to be loaded. */ void LoadGame(const std::string &filename) { // log will be enabled if found in the save game CommandLogDisabled = true; SaveGameLoading = true; //Wyrmgus start // SetDefaultTextColors(FontYellow, FontWhite); SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor); //Wyrmgus end LoadFonts(); LuaGarbageCollect(); InitUnitTypes(1); LuaLoadFile(filename); LuaGarbageCollect(); PlaceUnits(); const unsigned long game_cycle = GameCycle; const unsigned syncrand = SyncRandSeed; const unsigned synchash = SyncHash; InitModules(); LoadModules(); GameCycle = game_cycle; SyncRandSeed = syncrand; SyncHash = synchash; SelectionChanged(); }
SMJS_Plugin *LoadPlugin(const char *dir){ auto plugin = SMJS_Plugin::GetPluginByDir(dir); if(plugin != NULL) return plugin; bool isSandboxed = true; for(auto it = trustedPlugins.begin(); it != trustedPlugins.end(); ++it){ if(strcmp(dir, it->c_str()) == 0){ isSandboxed = false; break; } } plugin = new SMJS_Plugin(isSandboxed); char path[512]; smutils->BuildPath(Path_SM, path, sizeof(path), "plugins.js/%s", dir); plugin->SetDir(dir); plugin->SetPath(path); plugin->LoadModules(); plugin->CheckApi(); if(!plugin->LoadFile("Main.js", true)){ delete plugin; return NULL; } // Late loading if(smutils->IsMapRunning()){ HandleScope handle_scope(plugin->GetIsolate()); Context::Scope context_scope(plugin->GetContext()); auto hooks = plugin->GetHooks("OnMapStart"); for(auto it = hooks->begin(); it != hooks->end(); ++it){ (*it)->Call(plugin->GetContext()->Global(), 0, NULL); } for(int i = 0; i < sizeof(clients) / sizeof(clients[0]); ++i){ if(clients[i] == NULL) continue; v8::Handle<v8::Value> arg = clients[i]->GetWrapper(plugin); hooks = plugin->GetHooks("OnClientConnected"); for(auto it = hooks->begin(); it != hooks->end(); ++it){ (*it)->Call(plugin->GetContext()->Global(), 1, &arg); } if(clients[i]->inGame){ hooks = plugin->GetHooks("OnClientPutInGame"); for(auto it = hooks->begin(); it != hooks->end(); ++it){ (*it)->Call(plugin->GetContext()->Global(), 1, &arg); } } } } return plugin; }
/** Wczytuje algorytm opisany w pliku @param algo Wskaznik do konfigurowanego algorytmu */ void XMLConfigFile::LoadAlgorithm(Algorithm* algo) { TRACE("XMLConfigFile::LoadModules - Wczytywanie calego algorytmu...\n" ); LoadAlgorithmSettings(algo); LoadModules(algo); LoadParameters(algo); LoadConnections(algo); algo->Init(); TRACE( "XMLConfigFile::LoadModules - Algorytm wczytany\n" ); }
void InitializeSymbolLookup() { static bool bIsInitialized = false; if( bIsInitialized ) { return; } bIsInitialized = true; hApplicationProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ApplicationProcessId); if( hApplicationProcess == NULL ) { DWORD error = GetLastError(); DebugLog("OpenProcess failed: error = %d", error); return; } DWORD SymOpts = 0; SymOpts |= SYMOPT_ALLOW_ABSOLUTE_SYMBOLS; // SymOpts |= SYMOPT_CASE_INSENSITIVE; SymOpts |= SYMOPT_DEBUG; SymOpts |= SYMOPT_DEFERRED_LOADS; SymOpts |= SYMOPT_EXACT_SYMBOLS; SymOpts |= SYMOPT_FAIL_CRITICAL_ERRORS; SymOpts |= SYMOPT_LOAD_LINES; SymOpts |= SYMOPT_UNDNAME; SymSetOptions(SymOpts); if( !SymInitialize(hApplicationProcess, NULL, TRUE) ) // defer the loading of process modules { DWORD error = GetLastError(); DebugLog("SymInitialize failed: error = %d", error); return; } LoadModules(); DWORD FileSize = 0; DWORD64 dwBaseAddress = 0; DWORD64 result = SymLoadModuleExW(hApplicationProcess, NULL, app_filename, NULL, dwBaseAddress, FileSize, NULL, 0); if( result == 0 ) { DWORD error = GetLastError(); DebugLog("SymLoadModuleEx failed: error = %d", error); SymUnloadModule64(hApplicationProcess, dwBaseAddress); return; } }
int main(int argc, char *argv[]) { std::cout << "\nStarting TerraLib GeoWeb Services...\n" << std::endl; TerraLib::getInstance().initialize(); try { tws::core::init_terralib_web_services(); LoadModules(); //std::unique_ptr<tws::core::http_server> server = tws::core::http_server_builder::instance().build(TWS_DEFAULT_WEB_SERVER); std::unique_ptr<tws::core::http_server> server = tws::core::http_server_builder::instance().build("mongoose"); server->start(); UnloadModules(); } catch(const boost::exception& e) { if(const std::string* d = boost::get_error_info<tws::error_description>(e)) std::cout << "\n\nthe following error has occurried: " << *d << std::endl; else std::cout << "\n\nan unknown error has occurried" << std::endl; return EXIT_FAILURE; } catch(const std::exception& e) { std::cout << "\n\nthe following error has occurried: " << e.what() << std::endl; return EXIT_FAILURE; } catch(...) { std::cout << "\n\nan unknown error has occurried." << std::endl; return EXIT_FAILURE; } TerraLib::getInstance().finalize(); std::cout << "\nFinished TerraLib GeoWeb Services!\n" << std::endl; return EXIT_SUCCESS; }
/** * Entry point. */ extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp) { bool fExit = false; RTEXITCODE rcExit = ParseOptions(argc, argv, &fExit); if (rcExit == RTEXITCODE_SUCCESS && !fExit) { rcExit = LoadModules(); if (rcExit == RTEXITCODE_SUCCESS) { for (;;) RTThreadSleep(RT_INDEFINITE_WAIT); } } return rcExit; }
CImgCache::CImgCache(HMODULE hSelf) { mb_Quit = FALSE; mp_ShellLoader = NULL; ms_CachePath[0] = ms_LastStoragePath[0] = 0; //nWidth = nHeight = 0; nPreviewSize = 0; //nXIcon = nYIcon = nXIconSpace = nYIconSpace = 0; hbrBack = NULL; //nFieldX = nFieldY = 0; //memset(hField,0,sizeof(hField)); //memset(hFieldBmp,0,sizeof(hFieldBmp)); //memset(hOldBmp,0,sizeof(hOldBmp)); memset(CacheInfo,0,sizeof(CacheInfo)); mh_LoadDC = mh_DrawDC = NULL; mh_OldLoadBmp = mh_OldDrawBmp = mh_LoadDib = mh_DrawDib = NULL; mp_LoadDibBytes = NULL; mn_LoadDibBytes = 0; mp_DrawDibBytes = NULL; mn_DrawDibBytes = 0; memset(Modules,0,sizeof(Modules)); mn_ModuleCount = 0; mpsz_ModuleSlash = ms_ModulePath; if (GetModuleFileName(hSelf, ms_ModulePath, countof(ms_ModulePath))) { wchar_t* pszSlash = wcsrchr(ms_ModulePath, L'\\'); if (pszSlash) mpsz_ModuleSlash = pszSlash+1; } *mpsz_ModuleSlash = 0; // Prepare root storage file pathname SetCacheLocation(NULL); // По умолчанию - в %TEMP% // Загрузить "модули" LoadModules(); // Initialize interfaces mp_RootStorage = mp_CurrentStorage = NULL; // Initialize Com CoInitialize(NULL); //// Alpha blending //mh_MsImg32 = LoadLibrary(L"Msimg32.dll"); //if (mh_MsImg32) { // fAlphaBlend = (AlphaBlend_t)GetProcAddress(mh_MsImg32, "AlphaBlend"); //} else { // fAlphaBlend = NULL; //} }
int main (int argc, char **argv) { static quakeparms_t parms; float time, oldtime, newtime; signal(SIGFPE, SIG_IGN); SifInitRpc(0); LoadModules(); /* if(mcInit(MC_TYPE_MC) < 0) { printf("Failed to initialise memcard\n"); SleepThread(); } */ inithandle(); parms.memsize = 24*1024*1024; parms.membase = malloc (parms.memsize); parms.basedir = "."; COM_InitArgv (argc, argv); parms.argc = com_argc; parms.argv = com_argv; printf ("Host_Init\n"); Host_Init (&parms); start_ps2_timer(); oldtime = Sys_FloatTime () - 0.1; while (1) { // find time spent rendering last frame newtime = Sys_FloatTime (); time = newtime - oldtime; oldtime = newtime; Host_Frame (time); } stop_ps2_timer(); return 0; }
/** ** Load a game to file. ** ** @param filename File name to be loaded. */ void LoadGame(const std::string &filename) { //Wyrmgus start CleanPlayers(); //clean players, as they may not have been cleansed after a scenario CurrentCustomHero = nullptr; //otherwise the loaded game will have an extra hero for the current custom hero //Wyrmgus end // log will be enabled if found in the save game CommandLogDisabled = true; SaveGameLoading = true; //Wyrmgus start // SetDefaultTextColors(FontYellow, FontWhite); SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor); //Wyrmgus end LoadFonts(); //Wyrmgus start InitPlayers(); //Wyrmgus end LuaGarbageCollect(); InitUnitTypes(1); //Wyrmgus start CalculateItemsToLoad(); //Wyrmgus end LuaLoadFile(filename); LuaGarbageCollect(); PlaceUnits(); const unsigned long game_cycle = GameCycle; const unsigned long long current_total_hours = CDate::CurrentTotalHours; const unsigned syncrand = SyncRandSeed; const unsigned synchash = SyncHash; InitModules(); LoadModules(); GameCycle = game_cycle; CDate::CurrentTotalHours = current_total_hours; SyncRandSeed = syncrand; SyncHash = synchash; SelectionChanged(); }
void CleanUp() { #ifdef ENABLE_BACKTRACE onexit(); #endif sem_wait(&payguide::free_workers_lock); /* Cleaning up and exit */ /* Clean operators rules */ LoadModules(NULL); LoadOperators(NULL); if (payguide::modules_list!=NULL) { delete payguide::modules_list; payguide::modules_list=NULL; } if (payguide::operators_list!=NULL) { delete payguide::operators_list; payguide::operators_list=NULL; } if (payguide::workers_list!=NULL) { delete payguide::workers_list; payguide::workers_list=NULL; } UnLoadAllInitSO(); LogWrite(LOGMSG_SYSTEM, "(Clean up complete sucessful.)"); LogClose(); sem_post(&payguide::free_workers_lock); }
int main(int argc, char *argv[]) { // look for tws_app_server config file std::string config_file_name = tws::core::find_in_app_path("share/tws/config/tws_app_server.json"); if(config_file_name.empty()) { std::cerr << TE_TR("Could not find tws_app_server configuration file: 'tws_app_server.json'."); return EXIT_FAILURE; } try { // read config file std::unique_ptr<rapidjson::Document> config_doc(tws::core::open_json_file(config_file_name)); if(!config_doc->IsObject() || config_doc->IsNull()) throw tws::parse_error() << tws::error_description(TE_TR("error in array entry name in metadata.")); // get log file information const rapidjson::Value& jlog_file = (*config_doc)["log_file"]; std::string log_file = jlog_file.GetString(); // init logger TE_INIT_DEFAULT_LOGGER(log_file); // init TerraLib and TWS frameworks TE_LOG_INFO(TE_TR("Starting TerraLib GeoWeb Services...")); TerraLib::getInstance().initialize(); tws::core::init_terralib_web_services(); LoadModules(); // start default htp server const rapidjson::Value& jhttp_server = (*config_doc)["http_server"]; std::string http_server = jhttp_server.GetString(); std::unique_ptr<tws::core::http_server> server = tws::core::http_server_builder::instance().build(http_server); server->start(); UnloadModules(); TerraLib::getInstance().finalize(); TE_LOG_INFO(TE_TR("Finished TerraLib GeoWeb Services!")); } catch(const boost::exception& e) { if(const std::string* d = boost::get_error_info<tws::error_description>(e)) { boost::format err_msg(TE_TR("the following error has occurred: %1%.")); TE_LOG_ERROR((err_msg % *d).str()); } else { TE_LOG_ERROR(TE_TR("an unknown error has occurred")); } return EXIT_FAILURE; } catch(const std::exception& e) { boost::format err_msg(TE_TR("the following error has occurred: %1%.")); TE_LOG_ERROR((err_msg % e.what()).str()); return EXIT_FAILURE; } catch(...) { TE_LOG_ERROR(TE_TR("an unknown error has occurred.")); return EXIT_FAILURE; } return EXIT_SUCCESS; }
//u32 Loopmode=0; int _main( int argc, char *argv[] ) { s32 ret = 0; u8 MessageHeap[0x10]; //u32 MessageQueue=0xFFFFFFFF; BootStatus(0, 0, 0); thread_set_priority( 0, 0x79 ); // do not remove this, this waits for FS to be ready! thread_set_priority( 0, 0x50 ); thread_set_priority( 0, 0x79 ); //MessageQueue = ES_Init( MessageHeap ); ES_Init( MessageHeap ); BootStatus(1, 0, 0); #ifndef NINTENDONT_USB BootStatus(2, 0, 0); ret = SDHCInit(); if(!ret) { dbgprintf("SD:SDHCInit() failed:%d\r\n", ret ); BootStatusError(-2, ret); mdelay(2000); Shutdown(); } #endif BootStatus(3, 0, 0); fatfs = (FATFS*)malloca( sizeof(FATFS), 32 ); s32 res = f_mount( 0, fatfs ); if( res != FR_OK ) { dbgprintf("ES:f_mount() failed:%d\r\n", res ); BootStatusError(-3, res); mdelay(2000); Shutdown(); } BootStatus(4, 0, 0); BootStatus(5, 0, 0); int MountFail = 0; s32 fres = -1; while(fres != FR_OK) { fres = f_open(&GameFile, "/bladie", FA_READ|FA_OPEN_EXISTING); switch(fres) { case FR_OK: f_close(&GameFile); case FR_NO_PATH: case FR_NO_FILE: { fres = FR_OK; } break; default: case FR_DISK_ERR: { f_mount(0, 0); //unmount drive todo: retry could never work MountFail++; if(MountFail == 10) { BootStatusError(-5, fres); mdelay(2000); Shutdown(); } mdelay(5); } break; } } #ifdef NINTENDONT_USB BootStatus(6, s_size, s_cnt); s32 r = LoadModules(55); //dbgprintf("ES:ES_LoadModules(%d):%d\r\n", 55, r ); if( r < 0 ) { BootStatusError(-6, r); mdelay(2000); Shutdown(); } #endif BootStatus(7, s_size, s_cnt); ConfigInit(); BootStatus(8, s_size, s_cnt); SDisInit = 1; memset32((void*)0x13002800, 0, 0x30); sync_after_write((void*)0x13002800, 0x30); u32 HID_Thread = 0; bool UseHID = ConfigGetConfig(NIN_CFG_HID); if( UseHID ) { ret = HIDInit(); if(ret < 0 ) { dbgprintf("ES:HIDInit() failed\r\n" ); BootStatusError(-8, ret); mdelay(2000); Shutdown(); } write32(0x13003004, 0); sync_after_write((void*)0x13003004, 0x20); memset32((void*)0x13003420, 0, 0x1BE0); sync_after_write((void*)0x13003420, 0x1BE0); HID_Thread = thread_create(HID_Run, NULL, (u32*)0x13003420, 0x1BE0, 0x78, 1); thread_continue(HID_Thread); } BootStatus(9, s_size, s_cnt); DIinit(); BootStatus(10, s_size, s_cnt); EXIInit(); BootStatus(11, s_size, s_cnt); SIInit(); //fixes issues in some japanese games if((ConfigGetGameID() & 0xFF) == 'J') write32(HW_PPCSPEED, 0x2A9E0); //Tell PPC side we are ready! cc_ahbMemFlush(1); mdelay(1000); BootStatus(0xdeadbeef, s_size, s_cnt); /* write32( HW_PPCIRQFLAG, read32(HW_PPCIRQFLAG) ); write32( HW_ARMIRQFLAG, read32(HW_ARMIRQFLAG) ); set32( HW_PPCIRQMASK, (1<<31) ); set32( HW_IPC_PPCCTRL, 0x30 ); */ u32 Now = read32(HW_TIMER); u32 PADTimer = Now; bool SaveCard = false; if( ConfigGetConfig(NIN_CFG_LED) ) { set32(HW_GPIO_ENABLE, GPIO_SLOT_LED); clear32(HW_GPIO_DIR, GPIO_SLOT_LED); clear32(HW_GPIO_OWNER, GPIO_SLOT_LED); } write32(0xd8006a0, 0x30000004), mask32(0xd8006a8, 0, 2); while (1) { _ahbMemFlush(0); if(EXI_IRQ == true) { if(EXICheckTimer()) EXIInterrupt(); } if(SI_IRQ == true) { if((read32(HW_TIMER) - PADTimer) >= 65000) // about 29 times a second { SIInterrupt(); PADTimer = read32(HW_TIMER); } } if(DI_IRQ == true) { if(DI_Args->Buffer == 0xdeadbeef) DIInterrupt(); } else if(SaveCard == true) /* DI IRQ indicates we might read async, so dont write at the same time */ { if((read32(HW_TIMER) - Now) / 1898437 > 2) /* after 3 second earliest */ { EXISaveCard(); SaveCard = false; } } udelay(10); //wait for other threads //Baten Kaitos save hax if( read32(0) == 0x474B4245 ) { if( read32( 0x0073E640 ) == 0xFFFFFFFF ) { write32( 0x0073E640, 0 ); } } if( Streaming ) { if( (read32(HW_TIMER) * 19 / 10) - StreamTimer >= 5000000 ) { // dbgprintf("."); StreamOffset += 64*1024; if( StreamOffset >= StreamSize ) { StreamOffset = StreamSize; Streaming = 0; } StreamTimer = read32(HW_TIMER) * 19 / 10; } } if( DiscChangeIRQ ) { if( read32(HW_TIMER) * 128 / 243000000 > 2 ) { //dbgprintf("DIP:IRQ mon!\r\n"); set32( DI_SSTATUS, 0x3A ); sync_after_write((void*)DI_SSTATUS, 4); DIInterrupt(); DiscChangeIRQ = 0; } } _ahbMemFlush(1); DIUpdateRegisters(); EXIUpdateRegistersNEW(); SIUpdateRegisters(); if(EXICheckCard()) { Now = read32(HW_TIMER); SaveCard = true; } if(read32(DI_SCONFIG) == 0x1DEA) { while(DI_Args->Buffer != 0xdeadbeef) udelay(100); break; } cc_ahbMemFlush(1); } if( UseHID ) { /* we're done reading inputs */ thread_cancel(HID_Thread, 0); } thread_cancel(DI_Thread, 0); write32( DI_SCONFIG, 0 ); sync_after_write( (void*)DI_SCONFIG, 4 ); /* reset time */ while(1) { _ahbMemFlush(0); sync_before_read( (void*)DI_SCONFIG, 4 ); if(read32(DI_SCONFIG) == 0x2DEA) break; wait_for_ppc(1); cc_ahbMemFlush(1); } if( ConfigGetConfig(NIN_CFG_LED) ) clear32(HW_GPIO_OUT, GPIO_SLOT_LED); if( ConfigGetConfig(NIN_CFG_MEMCARDEMU) ) EXIShutdown(); IOSBoot((char*)0x13003020, 0, read32(0x13003000)); return 0; }
void init(void){ glist_init(&ModuleList); queue_init(&ReadyQueue,1000); LoadModules(&ModuleList); }
int _main( int argc, char *argv[] ) { //BSS is in DATA section so IOS doesnt touch it, we need to manually clear it //dbgprintf("memset32(%08x, 0, %08x)\n", &__bss_start, &__bss_end - &__bss_start); memset32(&__bss_start, 0, &__bss_end - &__bss_start); sync_after_write(&__bss_start, &__bss_end - &__bss_start); s32 ret = 0; u32 HID_Thread = 0, DI_Thread = 0; u8 MessageHeap[0x10]; //u32 MessageQueue=0xFFFFFFFF; BootStatus(0, 0, 0); thread_set_priority( 0, 0x79 ); // do not remove this, this waits for FS to be ready! thread_set_priority( 0, 0x50 ); thread_set_priority( 0, 0x79 ); //MessageQueue = ES_Init( MessageHeap ); ES_Init( MessageHeap ); BootStatus(1, 0, 0); #ifndef NINTENDONT_USB BootStatus(2, 0, 0); ret = SDHCInit(); if(!ret) { dbgprintf("SD:SDHCInit() failed:%d\r\n", ret ); BootStatusError(-2, ret); mdelay(2000); Shutdown(); } #endif BootStatus(3, 0, 0); fatfs = (FATFS*)malloca( sizeof(FATFS), 32 ); s32 res = f_mount( 0, fatfs ); if( res != FR_OK ) { dbgprintf("ES:f_mount() failed:%d\r\n", res ); BootStatusError(-3, res); mdelay(2000); Shutdown(); } BootStatus(4, 0, 0); BootStatus(5, 0, 0); int MountFail = 0; s32 fres = -1; FIL fp; while(fres != FR_OK) { fres = f_open(&fp, "/bladie", FA_READ|FA_OPEN_EXISTING); switch(fres) { case FR_OK: f_close(&fp); case FR_NO_PATH: case FR_NO_FILE: { fres = FR_OK; } break; default: case FR_DISK_ERR: { f_mount(0, NULL); //unmount drive todo: retry could never work MountFail++; if(MountFail == 10) { BootStatusError(-5, fres); mdelay(2000); Shutdown(); } mdelay(5); } break; } if(STATUS_ERROR == -7) { // FS check timed out on PPC side dbgprintf("FS check timed out\r\n"); mdelay(3000); Shutdown(); } } #ifndef NINTENDONT_USB s_size = 512; s_cnt = fatfs->n_fatent * fatfs->csize; #endif BootStatus(6, s_size, s_cnt); #ifdef NINTENDONT_USB s32 r = LoadModules(55); //dbgprintf("ES:ES_LoadModules(%d):%d\r\n", 55, r ); if( r < 0 ) { BootStatusError(-6, r); mdelay(2000); Shutdown(); } #endif BootStatus(7, s_size, s_cnt); ConfigInit(); if (ConfigGetConfig(NIN_CFG_LOG)) SDisInit = 1; // Looks okay after threading fix dbgprintf("Game path: %s\r\n", ConfigGetGamePath()); BootStatus(8, s_size, s_cnt); memset32((void*)0x13002800, 0, 0x30); sync_after_write((void*)0x13002800, 0x30); memset32((void*)0x13160000, 0, 0x20); sync_after_write((void*)0x13160000, 0x20); memset32((void*)0x13026500, 0, 0x100); sync_after_write((void*)0x13026500, 0x100); bool UseHID = ConfigGetConfig(NIN_CFG_HID); if( UseHID ) { ret = HIDInit(); if(ret < 0 ) { dbgprintf("ES:HIDInit() failed\r\n" ); BootStatusError(-8, ret); mdelay(2000); Shutdown(); } write32(0x13003004, 0); sync_after_write((void*)0x13003004, 0x20); HID_Thread = thread_create(HID_Run, NULL, HID_ThreadStack, 0x400, 0x78, 1); thread_continue(HID_Thread); } BootStatus(9, s_size, s_cnt); DIRegister(); DI_Thread = thread_create(DIReadThread, NULL, DI_ThreadStack, 0x400, 0x78, 1); thread_continue(DI_Thread); DIinit(true); BootStatus(10, s_size, s_cnt); GCAMInit(); EXIInit(); ret = Check_Cheats(); if(ret < 0 ) { dbgprintf("Check_Cheats failed\r\n" ); BootStatusError(-10, ret); mdelay(4000); Shutdown(); } BootStatus(11, s_size, s_cnt); bool PatchSI = !ConfigGetConfig(NIN_CFG_NATIVE_SI); if (PatchSI) SIInit(); StreamInit(); PatchInit(); //This bit seems to be different on japanese consoles u32 ori_ppcspeed = read32(HW_PPCSPEED); if((ConfigGetGameID() & 0xFF) == 'J') set32(HW_PPCSPEED, (1<<17)); else clear32(HW_PPCSPEED, (1<<17)); //write32( 0x1860, 0xdeadbeef ); // Clear OSReport area //Tell PPC side we are ready! cc_ahbMemFlush(1); mdelay(1000); BootStatus(0xdeadbeef, s_size, s_cnt); u32 Now = read32(HW_TIMER); u32 PADTimer = Now; u32 DiscChangeTimer = Now; u32 ResetTimer = Now; #ifdef NINTENDONT_USB u32 USBReadTimer = Now; #endif u32 Reset = 0; bool SaveCard = false; if( ConfigGetConfig(NIN_CFG_LED) ) { set32(HW_GPIO_ENABLE, GPIO_SLOT_LED); clear32(HW_GPIO_DIR, GPIO_SLOT_LED); clear32(HW_GPIO_OWNER, GPIO_SLOT_LED); } EnableAHBProt(-1); //disable AHBPROT write32(0xd8006a0, 0x30000004), mask32(0xd8006a8, 0, 2); //widescreen fix while (1) { _ahbMemFlush(0); //Check this. Purpose is to send another interrupt if wasn't processed /*if (((read32(0x14) != 0) || (read32(0x13026514) != 0)) && (read32(HW_ARMIRQFLAG) & (1 << 30)) == 0) { write32(HW_IPC_ARMCTRL, (1 << 0) | (1 << 4)); //throw irq }*/ #ifdef PATCHALL if (EXI_IRQ == true) { if(EXICheckTimer()) EXIInterrupt(); } #endif if ((PatchSI) && (SI_IRQ != 0)) { if (((read32(HW_TIMER) - PADTimer) > 7910) || (SI_IRQ & 0x2)) // about 240 times a second { SIInterrupt(); PADTimer = read32(HW_TIMER); } } if(DI_IRQ == true) { if(DI_CallbackMsg.result == 0) DIInterrupt(); } else if(SaveCard == true) /* DI IRQ indicates we might read async, so dont write at the same time */ { if((read32(HW_TIMER) - Now) / 1898437 > 2) /* after 3 second earliest */ { EXISaveCard(); SaveCard = false; } } #ifdef NINTENDONT_USB else if((read32(HW_TIMER) - USBReadTimer) / 1898437 > 9) /* Read random sector after about 10 seconds */ { DI_CallbackMsg.result = -1; sync_after_write(&DI_CallbackMsg, 0x20); IOS_IoctlAsync( DI_Handle, 2, NULL, 0, NULL, 0, DI_MessageQueue, &DI_CallbackMsg ); while(DI_CallbackMsg.result) { udelay(10); //wait for other threads BTUpdateRegisters(); } USBReadTimer = read32(HW_TIMER); } #endif udelay(10); //wait for other threads //Baten Kaitos save hax /*if( read32(0) == 0x474B4245 ) { if( read32( 0x0073E640 ) == 0xFFFFFFFF ) { write32( 0x0073E640, 0 ); } }*/ if ( DiscChangeIRQ == 1 ) { DiscChangeTimer = read32(HW_TIMER); DiscChangeIRQ = 2; } else if ( DiscChangeIRQ == 2 ) { if ( (read32(HW_TIMER) - DiscChangeTimer ) > 2 * 243000000 / 128) { //dbgprintf("DIP:IRQ mon!\r\n"); set32( DI_SSTATUS, 0x3A ); sync_after_write((void*)DI_SSTATUS, 4); DIInterrupt(); DiscChangeIRQ = 0; } } _ahbMemFlush(1); DIUpdateRegisters(); #ifdef PATCHALL EXIUpdateRegistersNEW(); GCAMUpdateRegisters(); BTUpdateRegisters(); #endif StreamUpdateRegisters(); CheckOSReport(); if(EXICheckCard()) { Now = read32(HW_TIMER); SaveCard = true; } if (PatchSI) { SIUpdateRegisters(); if (read32(DIP_IMM) == 0x1DEA) { DIFinishAsync(); break; } if (read32(DIP_IMM) == 0x3DEA) { if (Reset == 0) { dbgprintf("Fake Reset IRQ\n"); write32(EXI2DATA, 0x2); // Reset irq write32(HW_IPC_ARMCTRL, (1 << 0) | (1 << 4)); //throw irq Reset = 1; } } else if (Reset == 1) { write32(EXI2DATA, 0x10000); // send pressed ResetTimer = read32(HW_TIMER); Reset = 2; } /* The cleanup is not connected to the button press */ if (Reset == 2) { if ((read32(HW_TIMER) - ResetTimer) / 949219 > 0) //free after half a second { write32(EXI2DATA, 0); // done, clear write32(DIP_IMM, 0); Reset = 0; } } } if(read32(DIP_IMM) == 0x4DEA) PatchGame(); CheckPatchPrs(); if(read32(HW_GPIO_IN) & GPIO_POWER) { DIFinishAsync(); #ifdef PATCHALL BTE_Shutdown(); #endif Shutdown(); } //sync_before_read( (void*)0x1860, 0x20 ); //if( read32(0x1860) != 0xdeadbeef ) //{ // if( read32(0x1860) != 0 ) // { // dbgprintf( (char*)(P2C(read32(0x1860))), // (char*)(P2C(read32(0x1864))), // (char*)(P2C(read32(0x1868))), // (char*)(P2C(read32(0x186C))), // (char*)(P2C(read32(0x1870))), // (char*)(P2C(read32(0x1874))) // ); // } // write32(0x1860, 0xdeadbeef); // sync_after_write( (void*)0x1860, 0x20 ); //} cc_ahbMemFlush(1); } if( UseHID ) { /* we're done reading inputs */ thread_cancel(HID_Thread, 0); } IOS_Close(DI_Handle); //close game thread_cancel(DI_Thread, 0); DIUnregister(); write32( DIP_IMM, 0 ); /* reset time */ while(1) { if(read32(DIP_IMM) == 0x2DEA) break; wait_for_ppc(1); } if( ConfigGetConfig(NIN_CFG_LED) ) clear32(HW_GPIO_OUT, GPIO_SLOT_LED); if( ConfigGetConfig(NIN_CFG_MEMCARDEMU) ) EXIShutdown(); if (ConfigGetConfig(NIN_CFG_LOG)) closeLog(); #ifdef PATCHALL BTE_Shutdown(); #endif //unmount FAT device f_mount(0, NULL); #ifndef NINTENDONT_USB SDHCShutdown(); #endif //make sure we set that back to the original write32(HW_PPCSPEED, ori_ppcspeed); IOSBoot((char*)0x13003020, 0, read32(0x13003000)); return 0; }
int main(int argc, char *argv[]) { char hostname[MAXHOSTNAMELEN], *exec, rhook[NG_HOOKSIZ]; unsigned char response[1024]; const char *label, *prog, *provider, *acname; struct ngm_connect ngc; struct sigaction act; int ch, cs, ds, ret, optF, optd, optn, sz, f; const char *pidfile; prog = strrchr(argv[0], '/'); prog = prog ? prog + 1 : argv[0]; pidfile = NULL; exec = NULL; label = NULL; acname = NULL; provider = ""; optF = optd = optn = 0; while ((ch = getopt(argc, argv, "FP:a:de:l:n:p:")) != -1) { switch (ch) { case 'F': optF = 1; break; case 'P': pidfile = optarg; break; case 'a': acname = optarg; break; case 'd': optd = 1; break; case 'e': exec = optarg; break; case 'l': label = optarg; break; case 'n': optn = 1; NgSetDebug(atoi(optarg)); break; case 'p': provider = optarg; break; default: return usage(prog); } } if (optind >= argc || optind + 2 < argc) return usage(prog); if (exec != NULL && label != NULL) return usage(prog); if (exec == NULL) { if (label == NULL) label = provider; if (label == NULL) { fprintf(stderr, "%s: Either a provider, a label or an exec command" " must be given\n", prog); return usage(prog); } exec = (char *)alloca(sizeof DEFAULT_EXEC_PREFIX + strlen(label)); if (exec == NULL) { fprintf(stderr, "%s: Cannot allocate %d bytes\n", prog, (int)(sizeof DEFAULT_EXEC_PREFIX) + strlen(label)); return EX_OSERR; } strcpy(exec, DEFAULT_EXEC_PREFIX); strcpy(exec + sizeof DEFAULT_EXEC_PREFIX - 1, label); } if (acname == NULL) { char *dot; if (gethostname(hostname, sizeof hostname)) strcpy(hostname, "localhost"); else if ((dot = strchr(hostname, '.'))) *dot = '\0'; acname = hostname; } #ifndef NOKLDLOAD if (!LoadModules()) return EX_UNAVAILABLE; #endif /* Create a socket node */ if (NgMkSockNode(NULL, &cs, &ds) == -1) { perror("Cannot create netgraph socket node"); return EX_CANTCREAT; } /* Connect it up (and fill in `ngc') */ if ((ret = ConfigureNode(prog, argv[optind], provider, cs, ds, optd, &ngc)) != 0) { close(cs); close(ds); return ret; } if (!optF && daemon(1, 0) == -1) { perror("daemon()"); close(cs); close(ds); return EX_OSERR; } if (pidfile != NULL) { FILE *fp; if ((fp = fopen(pidfile, "w")) == NULL) { perror(pidfile); close(cs); close(ds); return EX_CANTCREAT; } else { fprintf(fp, "%d\n", (int)getpid()); fclose(fp); } } openlog(prog, LOG_PID | (optF ? LOG_PERROR : 0), LOG_DAEMON); if (!optF && optn) NgSetErrLog(nglog, nglogx); memset(&act, '\0', sizeof act); act.sa_handler = Farewell; act.sa_flags = 0; sigemptyset(&act.sa_mask); sigaction(SIGHUP, &act, NULL); sigaction(SIGINT, &act, NULL); sigaction(SIGQUIT, &act, NULL); sigaction(SIGTERM, &act, NULL); while (!ReceivedSignal) { if (*provider) syslog(LOG_INFO, "Listening as provider %s", provider); else syslog(LOG_INFO, "Listening"); switch (sz = NgRecvData(ds, response, sizeof response, rhook)) { case -1: syslog(LOG_INFO, "NgRecvData: %m"); break; case 0: syslog(LOG_INFO, "NgRecvData: socket closed"); break; default: if (optd) { char *dbuf, *ptr; ptr = dbuf = alloca(sz * 2 + 1); for (f = 0; f < sz; f++, ptr += 2) sprintf(ptr, "%02x", (u_char)response[f]); *ptr = '\0'; syslog(LOG_INFO, "Got %d bytes of data: %s", sz, dbuf); } } if (sz <= 0) { ret = EX_UNAVAILABLE; break; } Spawn(prog, acname, provider, exec, ngc, cs, ds, response, sz, optd); } if (pidfile) remove(pidfile); if (ReceivedSignal) { syslog(LOG_INFO, "Received signal %d, exiting", ReceivedSignal); signal(ReceivedSignal, SIG_DFL); raise(ReceivedSignal); /* NOTREACHED */ ret = -ReceivedSignal; } return ret; }
int video_thread(SceSize args, void *argp) { // Pixel coordinates: first = first luminant pixel to breach threshhold, last = ..., mid = ... Coord first, last, mid; int bufsize; int threshold = 200; // Luminance threshold. int showvideo = 0; // Show the actual video input? 0: No, 1: Yes // Camera buffers. PspUsbCamSetupVideoParam videoparam; static u8 buffer[MAX_STILL_IMAGE_SIZE] __attribute__((aligned(64))); static u8 work[68*1024] __attribute__((aligned(64))); static u32 framebuffer[480*272] __attribute__((aligned(64))); // Startup cursor position. cursor.x = 237, cursor.y = 50; old.x = 237, old.y = 50; // Setup the screenmap size and position. screenmap.x = 20; screenmap.y = 200; screenmap.w = 60; screenmap.h = 60; screenmap.gridcolor = 0xFFC09090; screenmap.fillcolor = 0xFFF0F0F0; screenmap.selcolor = 0xFFC0FFFF; // Create a start button. Button btnStart; btnStart.x = 420; btnStart.y = 250; btnStart.w = 50; btnStart.h = 12; btnStart.fillcolor = 0xFF00FFFF; btnStart.textcolor = 0xFF000000; btnStart.bordercolor = 0xFF000000; btnStart.shadowcolor = 0xFF888888; btnStart.bordersize = 1; btnStart.borderbevel = 0; btnStart.shadowsize = 0; btnStart.shadowdistance = 0; strcpy(btnStart.text, "Start"); strcpy(btnStart.name, "btnStart"); // Wait for camera to be connected. while (!connected) { clearScreen(0xFFF0F0F0); printTextScreenCenter(132, "Please connect the camera and press any button.", 0xFF009900); flipScreen(); sceDisplayWaitVblankStart(); sceKernelDelayThread(20000); } // Load the camera modules and start the decoder. if (LoadModules() < 0) sceKernelSleepThread(); if (StartUsb() < 0) sceKernelSleepThread(); if (sceUsbActivate(PSP_USBCAM_PID) < 0) sceKernelSleepThread(); if (InitJpegDecoder() < 0) sceKernelSleepThread(); while (1) { if ((sceUsbGetState() & 0xF) == PSP_USB_CONNECTION_ESTABLISHED) break; sceKernelDelayThread(50000); } //Setup video parameters and start video capture. memset(&videoparam, 0, sizeof(videoparam)); videoparam.size = sizeof(videoparam); videoparam.resolution = PSP_USBCAM_RESOLUTION_480_272; videoparam.framerate = PSP_USBCAM_FRAMERATE_30_FPS; videoparam.wb = PSP_USBCAM_WB_INCANDESCENT; videoparam.saturation = 125; videoparam.brightness = 100; videoparam.contrast = 64; videoparam.sharpness = 0; videoparam.effectmode = PSP_USBCAM_EFFECTMODE_NORMAL; videoparam.framesize = MAX_VIDEO_FRAME_SIZE; videoparam.evlevel = PSP_USBCAM_EVLEVEL_0_0; if (sceUsbCamSetupVideo(&videoparam, work, sizeof(work)) < 0) sceKernelExitDeleteThread(0); sceUsbCamAutoImageReverseSW(1); if (sceUsbCamStartVideo() < 0) sceKernelExitDeleteThread(0); while (running) { int i, j, lum = 0, tracking = 0; first.x = 0; first.y = 0; last.x = 0; last.y = 0; mid.x = old.x; mid.y = old.y; clearScreen(0xFFFFFFFF); // Capture the camera image into the framebuffer. bufsize = sceUsbCamReadVideoFrameBlocking(buffer, MAX_VIDEO_FRAME_SIZE); if (bufsize > 0) sceJpegDecodeMJpeg(buffer, bufsize, framebuffer, 0); // Analyze the camera image. for (i = 0; i < 272; i++) { for (j = 0; j < 480; j++) { if (showvideo) putPixelScreen(framebuffer[i * CAM_LINE_SIZE + j], j, i); // Show video input. // Calculate luminance (brightness as perceived by the eye) and compare versus threshhold. lum = (299 * R(framebuffer[i * CAM_LINE_SIZE + j]) + 587 * G(framebuffer[i * CAM_LINE_SIZE + j]) + 114 * B(framebuffer[i * CAM_LINE_SIZE + j])) / 1000; if (lum > threshold) { tracking = 1; if (aligned) putPixelScreen(0xFF0000FF, j, i); if ((first.x == 0) || (j < first.x)) first.x = j; if ((first.y == 0) || (i < first.y)) first.y = i; if ((last.x == 0) || (j > last.x)) last.x = j; if ((last.y == 0) || (i > last.y)) last.y = i; } } } if (tracking) { // Calculate directional movement and determine cursor position. mid.x = first.x + (abs((last.x - first.x)) / 2); mid.y = first.y + (abs((last.y - first.y)) / 2); checkDirection(mid, old); switch (direction) { case 0: cursor.x = old.x; cursor.y = old.y; break; case 1: cursor.x = first.x; cursor.y = first.y + (abs((last.y - first.y)) / 2); break; case 2: cursor.x = first.x; cursor.y = first.y; break; case 3: cursor.x = first.x + (abs((last.x - first.x)) / 2); cursor.y = first.y; break; case 4: cursor.x = last.x; cursor.y = first.y; break; case 5: cursor.x = last.x; cursor.y = first.y + (abs((last.y - first.y)) / 2); break; case 6: cursor.x = last.x; cursor.y = last.y; break; case 7: cursor.x = first.x + (abs((last.x - first.x)) / 2); cursor.y = last.y; break; case 8: cursor.x = first.x; cursor.y = last.y; break; }; //Uncomment the following lines to draw 'directional' markers on screen. /*if ((abs(last.x - first.x) > 15) || (abs(last.y - first.y) > 15)) { if ((direction > 0) && (direction <= 4)) { drawLineScreen(first.x, first.y, last.x, last.y, 0xFFC0C0C0); } else { drawLineScreen(last.x, last.y, first.x, first.y, 0xFFC0C0C0); } switch (direction) { case 0: break; case 1: drawLineScreen(last.x, last.y + ((last.y - first.y) / 2), first.x, first.y + ((last.y - first.y) / 2), 0xFFC0C0C0); break; // W case 2: drawLineScreen(last.x, last.y, first.x, first.y, 0xFFC0C0C0); break; // NW case 3: drawLineScreen(first.x + ((last.x - first.x) / 2), last.y, first.x + ((last.x - first.x) / 2), first.y, 0xFFC0C0C0); break; // N case 4: drawLineScreen(first.x, last.y, last.x, first.y, 0xFFC0C0C0); break; // NE case 5: drawLineScreen(first.x, first.y + ((last.y - first.y) / 2), last.x, first.y + ((last.y - first.y) / 2), 0xFFC0C0C0); break; // E case 6: drawLineScreen(first.x, first.y, last.x, last.y, 0xFFC0C0C0); break; // SE case 7: drawLineScreen(first.x + ((last.x - first.x) / 2), first.y, first.x + ((last.x - first.x) / 2), last.y, 0xFFC0C0C0); break; // S case 8: drawLineScreen(last.x, first.y, first.x, last.y, 0xFFC0C0C0); break; // SW }; drawLineScreen((first.x > last.x) ? last.x : first.x, (first.y > last.y) ? last.y : first.y, (first.x < last.x) ? last.x : first.x, (first.y < last.y) ? last.y : first.y, 0xFFC0C0C0); } else { drawRectScreen(0xFFC0C0C0, first.x, first.y, last.x - first.x, last.y - first.y); }*/ } else { printTextScreenCenter(10, "Please return to the playing area.", 0xFF0000FF); if (lastdirection == 0) { cursor.x = old.x; cursor.y = old.y; } //if ((aligned) && (!menu) && (_gameState = GAME_RUNNING)) HandlePauseGame(); } if (!aligned) { showvideo = 1; // Alignment Screen: wait for camera to be aligned to the playing area. printTextScreenCenter(126, "Please align the camera to the playing area.", 0xFFFFFFFF); printTextScreenCenter(136, "Drag the cursor to the \"Start\" button to continue.", 0xFFFFFFFF); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFF00FF00; aligned = 1; menu = 1; } drawButtonScreen(btnStart); if (aligned) { btnStart.fillcolor = 0xFF00FFFF; btnStart.x = 240 - (btnStart.w / 2); btnStart.y = 200; } } else if (menu) { showvideo = 0; // Menu Screen: show a splash, logo, menu, etc. printTextScreenCenter(126, "eyePSP Pong", 0xFF009900); printTextScreenCenter(136, "Please press the \"Start\" button to continue.", 0xFFFF0000); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFFC0FFC0; menu = 0; } drawButtonScreen(btnStart); } else { // Draw any game objects here. if (_gameState == GAME_PAUSED) { printTextScreenCenter(100, "Game Paused", COLOR_RED); if (tracking) _gameState = GAME_RUNNING; } else if (_gameState == GAME_RUNNING) { DrawMainText(); // Draw main graphics and supporting text to the screen. DrawPaddle(&_paddle); // Draws the paddle to the screen } else if (_gameState == GAME_CONTINUE) { char sbuffer[50]; sprintf(sbuffer, "%d Ball%s Remaining...", _resBalls, (_resBalls == 1) ? "" : "s"); printTextScreenCenter(100, sbuffer, 0xFF000088); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFFC0FFC0; _gameState = GAME_RUNNING; } drawButtonScreen(btnStart); } else if (_gameState == GAME_OVER) { // Draws game over graphics and waits for user to continue DrawGameOverMenu(); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFFC0FFC0; _gameState = GAME_RUNNING; } drawButtonScreen(btnStart); } } // Draw cursor (within boundaries) . if (tracking) { for (i = cursor.y - 5; i <= cursor.y + 5; i++) { if ((i > 0) && (i < 272)) putPixelScreen(!tracking ? 0xFF0000FF : 0xFF009900, cursor.x, i); } // y-axis for (j = cursor.x - 5; j <= cursor.x + 5; j++) { if ((j > 0) && (j < 480)) putPixelScreen(!tracking ? 0xFF0000FF : 0xFF009900, j, cursor.y); } // x-axis } old.x = cursor.x; old.y = cursor.y; lastdirection = direction; flipScreen(); sceDisplayWaitVblankStart(); sceKernelDelayThread(2000); } sceKernelExitDeleteThread(0); return 0; }
void BattlenetMgr::Load() { LoadComponents(); LoadModules(); }
ALERROR CUniverse::InitFromXML (SDesignLoadCtx &Ctx, CXMLElement *pElement, CResourceDb &Resources) // InitFromXML // // Initializes the universe from an XML database { ALERROR error; int i; CIDTable UNIDMap(FALSE, FALSE); m_bNoImages = Ctx.bNoResources; // Initialize code chain if (error = m_CC.Boot()) return error; if (error = InitCodeChainPrimitives()) return error; // Create some fonts m_MapLabelFont.Create(MAP_LABEL_TYPEFACE, 12); m_SignFont.Create(SIGN_TYPEFACE, 11, true); // Make sure we have the right version if (!Ctx.bNoVersionCheck) { DWORD dwVersion; // Make sure we have the latest version of the .XML dwVersion = (DWORD)pElement->GetAttributeInteger(VERSION_ATTRIB); if (fileGetProductVersion() > dwVersion) { if (Resources.IsUsingExternalGameFile()) Ctx.sError = CONSTLIT("External definitions file (Transcendence.xml) is obsolete.\nPlease remove 'Transcendence.xml' file from game folder."); else Ctx.sError = CONSTLIT("Source definitions file (Transcendence.xml) is obsolete.\nPlease download the latest version at http://www.neurohack.com/transcendence/Downloads.html."); return ERR_FAIL; } // Make sure we have the latest version of the .EXE dwVersion = (DWORD)pElement->GetAttributeInteger(MIN_VERSION_ATTRIB); if (fileGetProductVersion() < dwVersion) { Ctx.sError = CONSTLIT("Source definitions file (Transcendence.xml) requires a newer version of Transcendence.exe.\nPlease download the latest version at http://www.neurohack.com/transcendence/Downloads.html."); return ERR_FAIL; } } // Load the Main XML file for (i = 0; i < pElement->GetContentElementCount(); i++) { CXMLElement *pDesc = pElement->GetContentElement(i); if (strEquals(pDesc->GetTag(), IMAGES_TAG)) error = InitImages(Ctx, pDesc, Resources); else if (strEquals(pDesc->GetTag(), SOUNDS_TAG)) error = InitSounds(Ctx, pDesc, Resources); else if (strEquals(pDesc->GetTag(), STATION_TYPE_RESOURCES_TAG)) error = InitStationTypeResources(Ctx, pDesc); else if (strEquals(pDesc->GetTag(), STAR_SYSTEM_TYPES_TAG)) error = InitStarSystemTypes(Ctx, pDesc); else if (strEquals(pDesc->GetTag(), MODULES_TAG)) error = LoadModules(Ctx, pDesc); else error = LoadDesignElement(Ctx, pDesc); // Check for error if (error) return error; } return NOERROR; }
void StackWalkInit() { HANDLE hProcess = GetCurrentProcess(); hDbgHelp = LoadLibraryA("dbghelp.dll"); if (NULL != hDbgHelp) { char path[NtfsMaxPath] = {0}; char temp[NtfsMaxPath]; pSymInitialize = (pfnSymInitialize) GetProcAddress(hDbgHelp, "SymInitialize"); pSymCleanup = (pfnSymCleanup) GetProcAddress(hDbgHelp, "SymCleanup"); pSymGetOptions = (pfnSymGetOptions) GetProcAddress(hDbgHelp, "SymGetOptions"); pSymSetOptions = (pfnSymSetOptions) GetProcAddress(hDbgHelp, "SymSetOptions"); pStackWalk64 = (pfnStackWalk64) GetProcAddress(hDbgHelp, "StackWalk64"); pSymGetSymFromAddr64 = (pfnSymGetSymFromAddr64) GetProcAddress(hDbgHelp, "SymGetSymFromAddr64"); pSymFunctionTableAccess64 = (pfnSymFunctionTableAccess64) GetProcAddress(hDbgHelp, "SymFunctionTableAccess64"); pSymGetModuleBase64 = (pfnSymGetModuleBase64) GetProcAddress(hDbgHelp, "SymGetModuleBase64"); pSymGetModuleInfo64 = (pfnSymGetModuleInfo64) GetProcAddress(hDbgHelp, "SymGetModuleInfo64"); pSymLoadModule64 = (pfnSymLoadModule64) GetProcAddress(hDbgHelp, "SymLoadModule64"); if (GetCurrentDirectoryA(NtfsMaxPath, temp)) { temp[NtfsMaxPath - 1] = 0; xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, ";"); } if (GetModuleFileNameA(NULL, temp, NtfsMaxPath)) { temp[NtfsMaxPath - 1] = 0; ShortName(temp)[0] = 0; xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, ";"); } if (GetEnvironmentVariableA("_NT_SYMBOL_PATH", temp, NtfsMaxPath)) { temp[NtfsMaxPath - 1] = 0; xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, ";"); } if (GetEnvironmentVariableA("_NT_ALTERNATE_SYMBOL_PATH", temp, NtfsMaxPath)) { temp[NtfsMaxPath - 1] = 0; xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, ";"); } if (GetEnvironmentVariableA("SYSTEMROOT", temp, NtfsMaxPath)) { temp[NtfsMaxPath - 1] = 0; xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, ";"); xstrcat(temp, NtfsMaxPath, "\\system32"); xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, ";"); } if (GetEnvironmentVariableA("TEMP", temp, NtfsMaxPath)) { temp[NtfsMaxPath - 1] = 0; xstrcat(path, NtfsMaxPath, "SRV*"); xstrcat(path, NtfsMaxPath, temp); xstrcat(path, NtfsMaxPath, "\\websymbols*http://msdl.microsoft.com/download/symbols;"); } else { xstrcat(path, NtfsMaxPath, "SRC*C:\\temp\\websymbols*http://msdl.microsoft.com/download/symbols;"); } if (pSymInitialize(hProcess, path, false)) { DWORD options = pSymGetOptions(); options |= SYMOPT_DEBUG; pSymSetOptions(options); LoadModules(hProcess); } } }
void WorkInit() { /* Init logs */ LogInit(); if (payguide::working) LogWrite(LOGMSG_WARNING, "Initializing payuguide server... "); else LogWrite(LOGMSG_WARNING, "Restarting payuguide server... "); /* Load config file */ LogWrite(LOGMSG_SYSTEM, "Loading configuration file from /etc/payguide.cfg"); if (ReloadConfigValues("/etc/payguide.cfg")!=0) LogWrite(LOGMSG_WARNING, "Can't load /etc/payguide.cfg - using default values instead."); else LogWrite(LOGMSG_SYSTEM, "Configuration file /etc/payguide.cfg loaded."); if (pc_init_result==-1) { if (payguide::bind_interface!="all" && payguide::bind_interface!="ALL") pc_init_result=PCInit(payguide::pc_port, 100, payguide::bind_interface.c_str(), payguide::users_filename.c_str(), payguide::package_timeout); else pc_init_result=PCInit(payguide::pc_port, 100, NULL, payguide::users_filename.c_str(), payguide::package_timeout); } /* Loading pay modules from *.so files */ LogWrite(LOGMSG_SYSTEM, "Loading pay modules (*.so files)"); payguide::modules_list = LoadModules(payguide::modules_path.c_str()); LogWrite(LOGMSG_SYSTEM, "Pay modules loaded."); /* Loading default module */ payguide::null_pay_sys=GetPaySysBySoName("libnull.so"); if (payguide::null_pay_sys==NULL) { LogWrite(LOGMSG_CRITICAL, "Critical error - can't load NULL pay system (libnull.so)"); // std::cout << "Critical error - can't load NULL pay system (libnull.so)" << std::endl; payguide::quit=true; payguide::working=false; RemoveLockFile(); exit(1); } /* Loading operators */ LogWrite(LOGMSG_SYSTEM, "Loading operators..."); payguide::operators_list = LoadOperators(payguide::operators_path.c_str()); LogWrite(LOGMSG_SYSTEM, "Operators loaded."); /* Creating thread_min workers */ { char logmsg[256]; snprintf(logmsg, 255, "Creating %i threads...",payguide::thread_min);LogWrite(LOGMSG_SYSTEM,logmsg); } sem_wait(&payguide::free_workers_lock); payguide::workers_list = CreateWorkers(payguide::thread_min); payguide::working_workers=0; LogWrite(LOGMSG_SYSTEM, "Threads created."); /* Free worker is a first worker in list */ payguide::workers_list->ResetCursor(); payguide::free_worker=payguide::workers_list->GetNext(); sem_post(&payguide::free_workers_lock); /* Init MySQL database */ if (0==DBInit(&payguide::db_host, &payguide::db_name, &payguide::db_user, &payguide::db_password)) LogWrite(LOGMSG_SYSTEM, "Connection to MySQL database established."); else LogWrite(LOGMSG_ERROR, "Connection to MySQL database failed."); LoadAllInitSO(payguide::modules_init_path.c_str()); return; }
int main() { int fd, ret; int i; // Initialise SifInitRpc(0); LoadModules(); #ifdef TYPE_MC if(mcInit(MC_TYPE_MC) < 0) { printf("Failed to initialise memcard server!\n"); SleepThread(); } #else if(mcInit(MC_TYPE_XMC) < 0) { printf("Failed to initialise memcard server!\n"); SleepThread(); } #endif printf("\nMemory card library example code - by Sjeep\n\n"); // int mcGetInfo(int port, int slot, int* type, int* free, int* format); // // mcGetInfo retrieves memcard state info, such as the memcard type, free blocks and // the format status. // // mcGetInfo is passed pointers to three variables, which are filled upon completion // of the getinfo rpc command. The mcGetInfo return values are as follows: // // 0 : The same memory card has been connected since the last mcGetInfo call. // -1 : Switched to a formatted memory card. // -2 : Switched to an unformatted memory card. // -10 or less : The memory card could not be detected. // // NOTE: With the MCMAN/MCSERV, *format is always returned as 0 regardless of if // if the memcard is formatted or not. // Since this is the first call, -1 should be returned. mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format); mcSync(0, NULL, &ret); printf("mcGetInfo returned %d\n",ret); printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format); // Assuming that the same memory card is connected, this should return 0 mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format); mcSync(0, NULL, &ret); printf("mcGetInfo returned %d\n",ret); printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format); // int mcGetDir(int port, int slot, char *name, unsigned mode, int maxent, mcTable* table); // // mcGetDir retrieves the directory structure of a specific path on the memory card. // // The filename is relative to the root of the memory card. Wildcards such as '*' and '?' // may be used. "maxent" is the maximum number of mcTable elements your array specified // by "table" can hold. The mc_getdir return values are as follows: // // 0 or more : The number of file entries that were obtained. // -2 : The memory card is unformatted // -4 : A non-existant path was specified in the "name" parameter // -10 or less : The memory card could not be detected. mcGetDir(0, 0, "/*", 0, ARRAY_ENTRIES - 10, mcDir); mcSync(0, NULL, &ret); printf("mcGetDir returned %d\n\nListing of root directory on memory card:\n\n", ret); for(i=0; i < ret; i++) { if(mcDir[i].attrFile & MC_ATTR_SUBDIR) printf("[DIR] %s\n", mcDir[i].name); else printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte); } // Check if existing save is present fd = fioOpen("mc0:PS2DEV/icon.sys", O_RDONLY); if(fd <= 0) { printf("\nNo previous save exists, creating...\n"); if((ret = CreateSave()) < 0) { printf("Failed to create save! Errorno: %d\n",ret); SleepThread(); } } else { printf("\nPrevious save exists, listing directory\n\n"); ret = mcGetDir(0, 0, "/PS2DEV/*", 0, ARRAY_ENTRIES, mcDir); printf("mcGetDir returned %d\n\n", ret); for(i=0; i < ret; i++) { if(mcDir[i].attrFile & MC_ATTR_SUBDIR) printf("[DIR] %s\n", mcDir[i].name); else printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte); } } // Return to the browser, so you can see the PS2Dev icon :) SifExitRpc(); return 0; }
int main(int argc, char* argv[]) { init_log(); (void)argc; (void)argv; // [cobralib] unmount iso / eject cobra_send_fake_disc_eject_event(); cobra_umount_disc_image(); // Check if isolist.self is launching this app... FILE* fp_flag = fopen("/dev_hdd0/game/SISO00123/USRDIR/isolist_finished", "r"); if(fp_flag) { // load normally... fclose(fp_flag); *&fp_flag = NULL; // remove the launch flag... cellFsUnlink("/dev_hdd0/game/SISO00123/USRDIR/isolist_finished"); } else { // generate ISO list... sys_game_process_exitspawn((char*)ISOLIST_SELF, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); } if(!LoadModules()) { // error... (void)exit_app(); return 0; } // setup sys callback if(cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL) != CELL_OK) { // error... (void)exit_app(); return 0; } InputInit(); if(InitPSGLVideo(device, context, screen_width, screen_height, render_width, render_height)) { // clear vid on startup (void)render(true); // init font if(!font_init(render_width, render_height)) { bRun = false; } // init app core modules, ftp, settings, etc... if(!init_core()) { bRun = false; } // loop while(bRun) { cellSysutilCheckCallback(); (void)input(); (void)render(false); } } else { // error msg here... } (void)exit_app(); return 0; }