public override bool OnInitialize() { ModuleSectionNode section = Location; if (section == null || !Header) { return(false); } //Don't make a copy buffer here. //Use the original buffer to save memory buint * sPtr = (buint *)Header; VoidPtr ceil = section.Header + section._dataSize; while (!(PowerPC.Disassemble(*sPtr++) is PPCblr) && (int)sPtr < (int)ceil) { ; } _codeStart = (int)Header - (int)section.Header; _codeLen = (int)sPtr - (int)Header; _manager = new RelocationManager(null); _manager.UseReference(section, _codeStart); if (_codeLen > 0) { _manager.AddTag(0, FullName + " Start"); _manager.AddTag(_codeLen / 4 - 1, FullName + " End"); } return(false); }
/// <summary> /// Backups the task /// </summary> public void Backup() { _backup.Run(); if (!_useFileLog && _backup.ErrorsOrWarningsRegistered) { Console.ReadKey(); } PowerPC.DoTask(_powerTask); }
public PowerPCSQL ConvertToPowerPCSQL(PowerPC powerpc) { return(new PowerPCSQL() { IsSynchronized = powerpc.IsSynchronized, dateTimeOffPC = ConverterHelper.ConvertDateTimeToMillisec(powerpc.dateTimeOffPC).ToString(), dateTimeOnPC = ConverterHelper.ConvertDateTimeToMillisec(powerpc.dateTimeOnPC).ToString(), GUID = powerpc.GUID, IsActive = powerpc.IsActive, Date = ConverterHelper.ConvertDateWithoutTimeToMillisec(DateTime.Now) }); }
public async Task <int> SavePowerTimeToSql(PowerPC powerpc) { int result = 0; if (powerpc == null) { return(result); } try { if (sqliteService == null) { sqliteService = new SQLiteService <PowerPCSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName)); } } catch (Exception exp) { result = -1; sqliteService = null; } if (sqliteService != null) { try { //only for new guid insert new records, for old GUID only update timeOff List <PowerPCSQL> oldpowerpc = await sqliteService.GetWhere <PowerPCSQL>(x => x.GUID.Equals(powerpc.GUID) && x.IsActive); if (oldpowerpc != null && oldpowerpc.Count != 0) { foreach (var ppc in oldpowerpc) { ppc.dateTimeOffPC = ConverterHelper.ConvertDateTimeToMillisec(powerpc.dateTimeOffPC).ToString(); ppc.IsSynchronized = false; result = await sqliteService.Update(ppc); } } else { result = await sqliteService.Insert(converter.ConvertToPowerPCSQL(powerpc)); } } catch (Exception ex) { result = -1; var err = ex.Message; throw ex; } } return(result); }
public override bool OnInitialize() { ModuleSectionNode section = Location; if ((TargetSection == 1 || TargetModule.Equals("main.dol")) && ModuleMapLoader.MapFiles.ContainsKey(TargetModule)) { if (ModuleMapLoader.MapFiles[TargetModule].ContainsKey(TargetOffset)) { _name = ModuleMapLoader.MapFiles[TargetModule][TargetOffset]; } } if (section == null || !Header) { return(false); } //Don't make a copy buffer here. //Use the original buffer to save memory buint * sPtr = (buint *)Header; VoidPtr ceil = section.Header + section._dataSize; while (!(PowerPC.Disassemble(*sPtr++) is PPCblr) && (int)sPtr < (int)ceil) { ; } _codeStart = (int)Header - (int)section.Header; _codeLen = (int)sPtr - (int)Header; _manager = new RelocationManager(null); _manager.UseReference(section, _codeStart); if (_codeLen > 0) { _manager.AddTag(0, FullName + " Start"); _manager.AddTag(_codeLen / 4 - 1, FullName + " End"); } return(false); }
public async Task <int> UpdateOrCreatePowerPCtoSql(string guid) { int result = 0; PowerPC powerpc = new PowerPC() { dateTimeOnPC = DateTime.Now, dateTimeOffPC = DateTime.Now, GUID = guid, IsActive = true, IsSynchronized = false }; try { powerpcService = FactorySingleton.Factory.Get <PowerPcService>(); result = await powerpcService.SavePowerTimeToSql(powerpc); } catch (Exception e) { var err = e.Message; result = -1; } return(result); }
private void onBackupFinsihedHelper() { BackupClass.Dispose(); if (BackupFinished != null) { BackupFinished.Invoke(); } if (HearSoundWhenBackupCompleted) { Miscellaneous.DoBeeps(); } // in support mode we always opening log and do not perform power task if (_options.LoggingLevel == LogLevel.Support) { SupportManager.OpenWebLinkAsync(_fileLogFile); Environment.Exit(0); } else { if (ErrorsOrWarningsRegistered) { // user chose to shutdown PC or logoff from it. In this case we should // add a registry key in RunOnce section to show him log in browser // of backup when he will login into the system next time if ((PowerTask == PowerTask.Shutdown) || (PowerTask == PowerTask.Reboot) || (PowerTask == PowerTask.LogOff)) { NativeMethods.ScheduleOpeningFileAfterLoginOfUserIntoTheSystem(_fileLogFile); } else // Hibernate, Sleep, Nothing // we should open browser and perform required power operation { SupportManager.OpenWebLinkAsync(_fileLogFile); } } // No problems during backup registered. In this case we should notify // user that's all is ok else { // user is here and we can show him the message if (PowerTask == PowerTask.None) { MessageBox.Show(Translation.Current[180], ";-)", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0); } } PowerPC.DoTask(PowerTask); if (PowerTask == PowerTask.None && ErrorsOrWarningsRegistered) { ; } else { Environment.Exit(0); } } }