void Configurator::InitAMeteor() { m_cfg.InitAMeteor(); std::string str; #define SET_PATH(name, var) \ str = m_cfg.GetStr(name); \ if (!str.empty() && str[0] == '~') \ str = Glib::get_home_dir() + str.substr(1); \ m_##var = str; SET_PATH("BatteryPath", batteryPath); SET_PATH("SaveStatePath", sstatePath); SET_PATH("RomPath", romPath); #undef SET_PATH }
void Configurator::Init() { this->InitAMeteor(); std::string str; #define SET_PATH(name, var, def) \ str = this->GetStr(name); \ if (str.empty()) \ { \ this->SetStr(name, std::string("~") + def); \ str = Glib::get_home_dir() + def; \ } \ else if (str[0] == '~') \ str = Glib::get_home_dir() + str.substr(1); \ m_##var = str; \ MakePath(m_##var); SET_PATH("BatteryPath", batteryPath, "/.meteor/battery"); SET_PATH("SaveStatePath", sstatePath, "/.meteor/savestate"); SET_PATH("RomPath", romPath, ""); #undef SET_PATH }
void Settings::ProcessINI(){ // Extra stuff to make life easier #define GET_INT(a, b, c) m_appIni.GetInteger(a, b, c) #define SET_COLOR(a, b) m_colors.SetColor(a, RGB2COLORREF(b)) // Load colors SET_COLOR(Colors::SEL_COLOR, GET_INT("colors", "sel_color", 0)); SET_COLOR(Colors::INACTIVE_SEL_COLOR, GET_INT("colors", "inactive_sel_color", 0)); SET_COLOR(Colors::BK_COLOR, GET_INT("colors", "bk_color", 0)); SET_COLOR(Colors::CODELIST_ITEM_COLOR, GET_INT("colors", "codelist_item_color", 0)); SET_COLOR(Colors::CODELIST_CURRENTLINE_COLOR, GET_INT("colors", "codelist_currentline_color", 0)); // Load animate speed m_nums.SetNum(Nums::ANIMATE_SPEED, GET_INT("numbers", "animate_speed", 10)); m_nums.SetNum(Nums::STEP_INTO_EXTERN_INT, GET_INT("numbers", "step_into_extern_int", 0)); m_nums.SetNum(Nums::STEP_INTO_INT, GET_INT("numbers", "step_into_int", 0)); #undef SET_COLOR #define SET_FONT(a, b) m_fonts.SetFont(a, b); // Load fonts // TODO : Load fonts from INI file SET_FONT(Fonts::GUI_FONT, (HFONT)GetStockObject(DEFAULT_GUI_FONT)); SET_FONT(Fonts::MONOSPACE_FONT, (HFONT)GetStockObject(ANSI_FIXED_FONT)); #undef SET_FONT #undef GET_INT #define GET_STR(a, b, c) m_appIni.Get(a, b, c) #define SET_PATH(a, b) m_paths.SetPath(a, b) SET_PATH(Paths::BIOS_PATH, GET_STR("paths", "bios_path", "")); #undef SET_PATH #undef GET_STR }
NET_API_STATUS NetrReplSetInfo ( IN LPTSTR UncServerName OPTIONAL, IN DWORD Level, IN LPCONFIG_CONTAINER Buf, OUT LPDWORD ParmError OPTIONAL ) { NET_API_STATUS ApiStatus; DWORD OldRole; BOOL Impersonated = FALSE; BOOL Locked = FALSE; UNREFERENCED_PARAMETER( UncServerName ); // // Check for caller's errors. // NetpSetParmError( PARM_ERROR_UNKNOWN ); // Set in case we get bad level. #define RETURN_BAD_PARM( parm_error ) \ { \ NetpSetParmError( parm_error ); \ ApiStatus = ERROR_INVALID_PARAMETER; \ goto Cleanup; /* Don't forget to release lock... */ \ } if (Buf == NULL) { RETURN_BAD_PARM( PARM_ERROR_UNKNOWN ) /*NOTREACHED*/ } if ( !ReplConfigIsLevelValid( Level, TRUE ) ) { // Yes, allow setinfo lvl ApiStatus = ERROR_INVALID_LEVEL; goto Cleanup; } // // We need to check all fields before we set any. // if ( !ReplConfigIsApiRecordValid ( Level, (LPVOID) (Buf->Info0), // BUGBUG: nonportable? ParmError ) ) { ApiStatus = ERROR_INVALID_PARAMETER; // ParmError already set. goto Cleanup; } // // Impersonate caller, so security check (write to registry) reflects // the client's process, not the repl service process. // ApiStatus = NetpImpersonateClient(); if (ApiStatus != NO_ERROR) { goto Cleanup; } Impersonated = TRUE; // // Get exclusive lock on config variables, so we don't get confused by // another API thread. This also locks the matching registry data. // ACQUIRE_LOCK( ReplConfigLock ); Locked = TRUE; IF_DEBUG( REPLAPI ) { NetpKdPrint(( PREFIX_REPL "NetrReplSetInfo(server side): got config lock OK.\n" )); } // // Based on info level, do additional checking and updates. // switch (Level) { case 0 : { LPREPL_INFO_0 Buffer = (LPVOID) (Buf->Info0); if ( !ReplConfigIsRoleAllowed( NULL, Buffer->rp0_role ) ) { RETURN_BAD_PARM( 1 ) // Role is first field in struct. /*NOTREACHED*/ } // // Change permanent copy of registry data for the replicator. // This acts as our security check, too. // ApiStatus = ReplConfigWrite( NULL, // no server name Buffer->rp0_role, Buffer->rp0_exportpath, Buffer->rp0_exportlist, Buffer->rp0_importpath, Buffer->rp0_importlist, Buffer->rp0_logonusername, Buffer->rp0_interval, Buffer->rp0_pulse, Buffer->rp0_guardtime, Buffer->rp0_random ); if (ApiStatus != NO_ERROR) { goto Cleanup; // Don't forget to release lock... } // // Change in-memory copy of registry data for the replicator. // #define SET_LIST( globalName, fieldName ) \ { \ LPTSTR Source = Buffer->rp0_ ## fieldName; \ if ( (Source!=NULL) && ( (*Source) != TCHAR_EOS ) ) { \ if (globalName != NULL) { \ if (STRICMP(globalName, Source) == 0) { \ /* OK as is; nothing to do. */ \ } else { \ /* Old and new are different. Free old and alloc new. */ \ NetpMemoryFree( globalName ); \ globalName = NetpAllocTStrFromTStr( Source ); \ if (globalName == NULL) { \ ApiStatus = ERROR_NOT_ENOUGH_MEMORY; \ goto Cleanup; /* Don't forget to release lock... */ \ } \ } \ } else { \ /* New name but no old name. Alloc new. */ \ globalName = NetpAllocTStrFromTStr( Source ); \ if (globalName == NULL) { \ ApiStatus = ERROR_NOT_ENOUGH_MEMORY; \ goto Cleanup; /* Don't forget to release lock... */ \ } \ } \ } else if (globalName != NULL) { \ /* Old list but no new list. Free old. */ \ NetpMemoryFree( globalName ); \ globalName = NULL; \ } \ } #define SET_PATH( globalName, fieldName ) \ { \ LPTSTR Source = Buffer->rp0_ ## fieldName; \ NetpAssert( globalName != NULL ); \ if ( (Source!=NULL) && ( (*Source) != TCHAR_EOS ) ) { \ (void) STRCPY( globalName, Source ); \ } else { \ globalName[0] = TCHAR_EOS; \ } \ } // Note: because of possible shock to other code, set role last. SET_PATH( ReplConfigExportPath, exportpath ); // The UI will update REPL$ share to reflect new export path. // Repl svc may not be running as admin so can't do NetShareAdd? // BUGBUG: Hey, we impersonated, so maybe we can! SET_LIST( ReplConfigExportList, exportlist ); SET_PATH( ReplConfigImportPath, importpath ); RCGlobalFsTimeResolutionSecs = ReplGetFsTimeResolutionSecs( ReplConfigImportPath ); SET_LIST( ReplConfigImportList, importlist ); // BUGBUG: Set logonusername!!! ReplConfigInterval = Buffer->rp0_interval; ReplConfigPulse = Buffer->rp0_pulse; ReplConfigGuardTime = Buffer->rp0_guardtime; ReplConfigRandom = Buffer->rp0_random; // // If the role is not changing make sure the internal // variables are updated. // OldRole = ReplConfigRole; IF_DEBUG( REPLAPI ) { NetpKdPrint(( PREFIX_REPL "NetrReplSetInfo(server side): initing lists.\n" )); } if ( ReplRoleIncludesExport(Buffer->rp0_role) && ReplRoleIncludesExport(OldRole) ) { if (RMGlobalImportList != NULL) { NetpMemoryFree( RMGlobalImportList ); RMGlobalImportList = NULL; } // NOTE: ReplInitAnyList() assumes caller has config data lock. ApiStatus = ReplInitAnyList( (LPCTSTR) ReplConfigExportList, // uncanon & RMGlobalImportList, // canon list: alloc and set ptr (LPCTSTR) REPL_KEYWORD_EXPLIST, // config keyword name & RMGlobalImportCount ); // set entry count too if ( ApiStatus != NO_ERROR ) goto Cleanup; } if ( ReplRoleIncludesImport(Buffer->rp0_role) && ReplRoleIncludesImport(OldRole) ) { if (RCGlobalExportList != NULL) { NetpMemoryFree( RCGlobalExportList ); RCGlobalExportList = NULL; } // NOTE: ReplInitAnyList() assumes caller has config data lock. ApiStatus = ReplInitAnyList( (LPCTSTR) ReplConfigImportList, // uncanon & RCGlobalExportList, // canon list: alloc and set ptr (LPCTSTR) REPL_KEYWORD_IMPLIST, // config keyword name & RCGlobalExportCount ); // set entry count too if ( ApiStatus != NO_ERROR ) goto Cleanup; } // // Change the role, including all the side-effects (like // starting and stopping threads). Also set ReplConfigRole. // NOTE: ReplChangeRole assumes caller has exclusive lock on // ReplConfigLock. // IF_DEBUG( REPLAPI ) { NetpKdPrint(( PREFIX_REPL "NetrReplSetInfo(server side): changing role.\n" )); } ApiStatus = ReplChangeRole( Buffer->rp0_role ); NetpAssert( ApiStatus == NO_ERROR ); IF_DEBUG( REPLAPI ) { NetpKdPrint(( PREFIX_REPL "NetrReplSetInfo(server side): " "done changing role.\n" )); } // Don't forget to unimpersonate. } break; case 1000 : { LPREPL_INFO_1000 Buffer = (LPVOID) (Buf->Info1000); DWORD NewValue = Buffer->rp1000_interval; if ( !ReplIsIntervalValid( NewValue ) ) { RETURN_BAD_PARM( 1 ) // first field in structure. /*NOTREACHED*/ } // // Change permanent copy of registry data for the replicator. // This acts as our security check, too. // ApiStatus = ReplConfigWrite( NULL, // no server name ReplConfigRole, ReplConfigExportPath, ReplConfigExportList, ReplConfigImportPath, ReplConfigImportList, ReplConfigLogonUserName, NewValue, // new interval ReplConfigPulse, ReplConfigGuardTime, ReplConfigRandom ); if (ApiStatus != NO_ERROR) { goto Cleanup; // Don't forget to release lock... } ReplConfigInterval = NewValue; // Don't forget to unlock and unimpersonate. // BUGBUG: Notify anybody? } break; case 1001 : { LPREPL_INFO_1001 Buffer = (LPVOID) (Buf->Info1001); DWORD NewValue = Buffer->rp1001_pulse; if ( !ReplIsPulseValid( NewValue ) ) { RETURN_BAD_PARM( 1 ) // first field in structure. /*NOTREACHED*/ } // // Change permanent copy of registry data for the replicator. // This acts as our security check, too. // ApiStatus = ReplConfigWrite( NULL, // no server name ReplConfigRole, ReplConfigExportPath, ReplConfigExportList, ReplConfigImportPath, ReplConfigImportList, ReplConfigLogonUserName, ReplConfigInterval, NewValue, // new pulse ReplConfigGuardTime, ReplConfigRandom ); if (ApiStatus != NO_ERROR) { goto Cleanup; // Don't forget to release lock... } ReplConfigPulse = NewValue; // Don't forget to unlock and unimpersonate. // BUGBUG: Notify anybody? } break; case 1002 : { LPREPL_INFO_1002 Buffer = (LPVOID) (Buf->Info1002); DWORD NewValue = Buffer->rp1002_guardtime; if ( !ReplIsGuardTimeValid( NewValue ) ) { RETURN_BAD_PARM( 1 ) // first field in structure. /*NOTREACHED*/ } // // Change permanent copy of registry data for the replicator. // This acts as our security check, too. // ApiStatus = ReplConfigWrite( NULL, // no server name ReplConfigRole, ReplConfigExportPath, ReplConfigExportList, ReplConfigImportPath, ReplConfigImportList, ReplConfigLogonUserName, ReplConfigInterval, ReplConfigPulse, NewValue, // new guard time ReplConfigRandom ); if (ApiStatus != NO_ERROR) { goto Cleanup; // Don't forget to release lock... } ReplConfigGuardTime = NewValue; // Don't forget to unlock and unimpersonate. // BUGBUG: Notify anybody? } break; case 1003 : { LPREPL_INFO_1003 Buffer = (LPVOID) (Buf->Info1003); DWORD NewValue = Buffer->rp1003_random; if ( !ReplIsRandomValid( NewValue ) ) { RETURN_BAD_PARM( 1 ) // first field in structure. /*NOTREACHED*/ } // // Change permanent copy of registry data for the replicator. // This acts as our security check, too. // ApiStatus = ReplConfigWrite( NULL, // no server name ReplConfigRole, ReplConfigExportPath, ReplConfigExportList, ReplConfigImportPath, ReplConfigImportList, ReplConfigLogonUserName, ReplConfigInterval, ReplConfigPulse, ReplConfigGuardTime, NewValue ); // new random time if (ApiStatus != NO_ERROR) { goto Cleanup; // Don't forget to release lock... } ReplConfigRandom = NewValue; // Don't forget to unlock and unimpersonate. } break; default : NetpAssert( FALSE ); // Can't get here. } // // All done. // Cleanup: if (Impersonated) { (VOID) NetpRevertToSelf(); } if (Locked) { RELEASE_LOCK( ReplConfigLock ); } if (ApiStatus == NO_ERROR) { NetpSetParmError( PARM_ERROR_NONE ); } return (ApiStatus); } // NetpReplSetInfo