public List <QuestionForms> GetVBRStartAddressandSizeQuestions(Mbr anMbr) { var questionList = new List <QuestionForms> { }; var vbrsList = VbrHelpers.GetVBRListFromMBR(anMbr, ref aLogger); Random rnd = new Random(); var number = 1; foreach (var v in vbrsList) { if (v.IsEmptyPartition()) { continue; } List <string> options = new List <string>(); for (int i = 0; i < 5; i++) { var rndNum = rnd.Next(v.BootSectorStartLocationByte() / 2, v.BootSectorStartLocationByte() * 3); if ((rndNum & 0xFF00) == v.BootSectorStartLocationByte()) { i--; continue; } //to avoid equal to the correct answer options.Add((rndNum & 0xFF00).ToString("X8")); } options.Add(v.BootSectorStartLocationByte().ToString("X8")); //Start Address Question questionList.Add( new QuestionForms(new Question($"Start Address of Volume {number}", GetMBRString(ref anMbr), v.BootSectorStartLocationByte().ToString("X8"), "Convert LBA Address (see VBR Structure) From Little Endian, Then Multiply by boot sector size", options, 3, QuizHelper.QuestionDifficulty.Hard), QuizHelper.InputValueType.HexVlaue)); List <string> sizeoptions = new List <string>(); for (int i = 0; i < 5; i++) { var rndNum = rnd.Next(v.Size / 2, v.Size * 3); if ((rndNum & 0xFF00) == v.Size) { i--; continue; } //to avoid equal to the correct answer sizeoptions.Add((rndNum & 0xFF00).ToString("X8")); } sizeoptions.Add(v.Size.ToString("X8")); //Size Question questionList.Add( new QuestionForms(new Question($"Size of Volume {number}", GetMBRString(ref anMbr), v.Size.ToString("X8"), "Convert Size (see VBR Structure) From Little Endian, Then Multiply by boot sector size", sizeoptions, 3, QuizHelper.QuestionDifficulty.Hard), QuizHelper.InputValueType.HexVlaue)); } return(questionList); }
// METHODS private int howmanyactivedisksanswer() { if (anMbr == null) { aLogger.LogMessage("MBR IS EMPTY. Did you forgot to load an MBR? ", LogMsgType.Warning); throw new Exception("MBR IS EMPTY. Did you forgot to load an MBR? "); } var vbrList = VbrHelpers.GetVBRListFromMBR(anMbr, ref aLogger); int number = 0; foreach (var vbr in vbrList) { if (!vbr.IsEmptyPartition()) { number++; } } return(number); }
private void printVbrsBtn_Click(object sender, EventArgs e) { if (anMbr == null) { aLogger.LogMessage("mbr is empty (maybe not loaded yet!), end function!", LogMsgType.Warning); return; } var vbrsList = VbrHelpers.GetVBRListFromMBR(anMbr, ref aLogger); foreach (var v in vbrsList) { Printer.PrintHorizentalLine(ref richTextBox1, 80, '-', true); richTextBox1.AppendText($"Printing {v.Description}", Color.Magenta, true); richTextBox1.AppendText("\n"); Printer.PrintHorizentalLine(ref richTextBox1, 80, '-', true); if (!v.IsEmptyPartition()) { Printer.PrintStructureValues(v.Structure, ref richTextBox1, ref aLogger); } } }