public void MakeTorrentFromFile(string fullPath) { FileInfo myFile = new FileInfo(fullPath); long filesize = myFile.Length; this.MakeHash(fullPath); int pathNameSize = fullPath.LastIndexOf(@"\"); int fileNameSize = fullPath.Length - pathNameSize; string fileName = fullPath.Substring(pathNameSize + 1, fileNameSize - 1); string fullPathToSave = parent.folderToSave + "/" + fileName; TorrentDictionary mainDict = new TorrentDictionary(); TorrentDictionary infoDict = new TorrentDictionary(); TorrentString torr_name = new TorrentString { Value = fileName }; TorrentNumber torr_length = new TorrentNumber { Value = filesize }; TorrentNumber torr_piece_size = new TorrentNumber { Value = this.currentPieceSize }; TorrentString torr_encode = new TorrentString { Value = "UTF-8" }; TorrentString torr_pieces = new TorrentString { Value = sha1_full.ToString() }; TorrentString torr_createdBy = new TorrentString { Value = "Criado por TorrentBuild Simplificado." }; infoDict.Add("length", torr_length); infoDict.Add("name", torr_name); infoDict.Add("pieces", torr_pieces); infoDict.Add("piece length", torr_piece_size); mainDict.Add("created by", torr_createdBy); mainDict.Add("encoding", torr_encode); mainDict.Add("info", infoDict); using (FileStream fs = File.Open(fullPathToSave + ".torrent", FileMode.OpenOrCreate)) { byte[] bencodedDict = Encoding.ASCII.GetBytes(mainDict.BEncoded); fs.Write(bencodedDict, 0, bencodedDict.Length); } }
private void ReturnWithSave_Click(object sender, EventArgs e) { string[] strArray; if (this.BTCMDSelect.Checked) { strArray = Strings.Split(this.TornadoCommandLine.Text, "|", -1, CompareMethod.Binary); ArrayList list = new ArrayList(); foreach (string str in strArray) { TorrentList list3 = new TorrentList(); ArrayList list2 = new ArrayList(); foreach (string str2 in Strings.Split(Strings.Trim(str), ",", -1, CompareMethod.Binary)) { if (Strings.Trim(str2) != "") { TorrentString str3 = new TorrentString { Value = Strings.Trim(str2) }; list2.Add(str3); } } if (list2.Count > 0) { list3.Value = list2; list.Add(list3); } } MultiTrackerTiers.Value = list; } else if (this.BTGuiSelect.Checked) { strArray = Strings.Split(this.BitTornadoGUI.Text, "\n", -1, CompareMethod.Binary); ArrayList list4 = new ArrayList(); foreach (string str4 in strArray) { string mystr4 = ""; if (Strings.Right(str4, 1) == "\r") { mystr4 = Strings.Left(str4, Strings.Len(str4) - 1); } mystr4 = Strings.Trim(mystr4); TorrentList list6 = new TorrentList(); ArrayList list5 = new ArrayList(); foreach (string str5 in Strings.Split(mystr4, " ", -1, CompareMethod.Binary)) { if (Strings.Trim(str5) != "") { TorrentString str6 = new TorrentString { Value = Strings.Trim(str5) }; list5.Add(str6); } } if (list5.Count > 0) { list6.Value = list5; list4.Add(list6); } } MultiTrackerTiers.Value = list4; } this.Close(); }
public static int GetWebSeedData(ArrayList returnarray) { int count = 0; if (File.Exists(TorrentBuild.LocalPath + "wsa.configure")) { int fileNumber = FileSystem.FreeFile(); FileSystem.FileOpen(fileNumber, TorrentBuild.LocalPath + "wsa.configure", OpenMode.Binary, OpenAccess.Read, OpenShare.LockRead, -1); string str = Strings.Space((int) FileSystem.FileLen(TorrentBuild.LocalPath + "wsa.configure")); FileSystem.FileGet(fileNumber, ref str, -1L, false); FileSystem.FileClose(new int[] { fileNumber }); TorrentDictionary dictionary = new TorrentDictionary(); dictionary.Parse(str); if (dictionary.Contains("seedlist")) { TorrentList list = new TorrentList(); list = (TorrentList) dictionary["seedlist"]; returnarray = list.Value; count = returnarray.Count; } else { TorrentString str2 = new TorrentString(); TorrentString str3 = new TorrentString(); TorrentString str4 = new TorrentString(); TorrentString str5 = new TorrentString(); TorrentString str6 = new TorrentString(); str2 = (TorrentString) dictionary["seed1"]; str3 = (TorrentString) dictionary["seed2"]; str4 = (TorrentString) dictionary["seed3"]; str5 = (TorrentString) dictionary["seed4"]; str6 = (TorrentString) dictionary["seed5"]; ArrayList list2 = new ArrayList(); TorrentList list3 = new TorrentList(); if (str2.Value != "") { returnarray.Add(str2); count++; } if (str3.Value != "") { returnarray.Add(str3); count++; } if (str4.Value != "") { returnarray.Add(str4); count++; } if (str5.Value != "") { returnarray.Add(str5); count++; } if (str6.Value != "") { returnarray.Add(str6); count++; } } if (TorrentBuild.GenerateVerbose) { Interaction.MsgBox("Number of Webseeds loaded: " + Conversions.ToString(count), MsgBoxStyle.OkOnly, null); } } return count; }
private void SaveToMain_Click(object sender, EventArgs e) { IEnumerator enumerator = null; ArrayList list = new ArrayList(); try { enumerator = this.Blacklisted.Items.GetEnumerator(); while (enumerator.MoveNext()) { string str2 = Conversions.ToString(enumerator.Current); TorrentString str = new TorrentString { Value = str2 }; list.Add(str); } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } TorrentBuild.BlackListedFiles = list; }
public void MakeTorrentFromFolder(string fullPath) { string[] pathArray = Directory.GetFiles(fullPath, "*", SearchOption.AllDirectories); string[] relative_pathArray = new string[pathArray.Length]; int pathNameSize = fullPath.LastIndexOf(@"\"); int fileNameSize = fullPath.Length - pathNameSize; string fileName = fullPath.Substring(pathNameSize + 1, fileNameSize - 1); string fullPathToSave = parent.folderToSave + @"\" + fileName; TorrentDictionary mainDict = new TorrentDictionary(); TorrentDictionary infoDict = new TorrentDictionary(); ArrayList fileArrayList = new ArrayList(); TorrentList torr_fileList = new TorrentList(); for (int i = 0; i < pathArray.Length; i++) { FileInfo myFile = new FileInfo(pathArray[i]); long filesize = myFile.Length; relative_pathArray[i] = pathArray[i].Substring(fullPath.Length + 1); string[] path_splitted = relative_pathArray[i].Split('\\'); TorrentNumber torr_filesize = new TorrentNumber { Value = filesize }; ArrayList pathArrayList = new ArrayList(); TorrentDictionary itemDict = new TorrentDictionary(); foreach (string path_chunk in path_splitted) { TorrentString path_chunkString = new TorrentString { Value = path_chunk }; pathArrayList.Add(path_chunkString); } TorrentList torr_pathList = new TorrentList { Value = pathArrayList }; itemDict.Add("length", torr_filesize); itemDict.Add("path", torr_pathList); fileArrayList.Add(itemDict); if (i == pathArray.Length - 1) { MakeContinuousHash(pathArray[i], true); } else { MakeContinuousHash(pathArray[i], false); } } torr_fileList.Value = fileArrayList; infoDict.Add("files", torr_fileList); TorrentString torr_pieces = new TorrentString { Value = sha1_full.ToString() }; infoDict.Add("pieces", torr_pieces); TorrentNumber torr_pieceLength = new TorrentNumber { Value = this.currentPieceSize }; infoDict.Add("piece length", torr_pieceLength); TorrentString torr_name = new TorrentString { Value = fileName }; infoDict.Add("name", torr_name); TorrentString torr_createdBy = new TorrentString { Value = "Criado por TorrentBuild Simplificado." }; mainDict.Add("created by", torr_createdBy); TorrentString torr_encode = new TorrentString { Value = "UTF-8" }; mainDict.Add("encoding", torr_encode); mainDict.Add("info", infoDict); using (FileStream fs = File.Open(fullPathToSave + ".torrent", FileMode.OpenOrCreate)) { byte[] bencodedDict = Encoding.ASCII.GetBytes(mainDict.BEncoded); fs.Write(bencodedDict, 0, bencodedDict.Length); } }
public void MakeOneTorrentFromFolder() { long num = 0; long num6 = 0; long num8 = 0; long num9 = 0; long num12 = 0; string[] strArray = Directory.GetFiles(this.FileNameToMake.Text, "*", SearchOption.AllDirectories); if (Strings.Right(this.FileNameToMake.Text, 1) != @"\") { this.FileNameToMake.Text = this.FileNameToMake.Text + @"\"; } TorrentDictionary dictionary2 = new TorrentDictionary(); TorrentList list = new TorrentList(); ArrayList list2 = new ArrayList(); this.OptionalHashProgress.Maximum = strArray.GetLength(0) * CountMultiplier; foreach (string str10 in strArray) { if (this.IsFileCleared(str10)) { FileStream stream; byte[] hash; IEnumerator enumerator = null; TorrentDictionary dictionary3 = new TorrentDictionary(); TorrentNumber number2 = new TorrentNumber(); TorrentList list3 = new TorrentList(); ArrayList list4 = new ArrayList(); TorrentString str11 = new TorrentString(); number2.Value = FileSystem.FileLen(str10); num12 += FileSystem.FileLen(str10); if (this.AutomaticPieceSize.Checked) { num += number2.Value; } Array array = Strings.Right(str10, Strings.Len(str10) - Strings.Len(this.FileNameToMake.Text)).Split(new char[] { '\\' }); try { enumerator = array.GetEnumerator(); while (enumerator.MoveNext()) { string str13 = Conversions.ToString(enumerator.Current); if (str13 != "") { TorrentString str14 = new TorrentString { Value = str13 }; list4.Add(str14); } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } list3.Value = list4; dictionary3.Add("length", number2); dictionary3.Add("path", list3); StringBuilder builder = new StringBuilder(); HashChanger changer = new HashChanger(); if (number2.Value < 0x100000000L) { if (this.IncludeTiger.Checked) { string str16 = ""; this.TigerHash = new ThexThreaded(); TorrentString str15 = new TorrentString(); hash = this.TigerHash.GetTTH_Value(str10); Application.DoEvents(); int index = 0; foreach (byte num13 in hash) { str16 = str16 + Encoding.Default.GetString(hash, index, 1); index++; } str15.Value = str16; str16 = ""; hash = null; this.OptionalHashProgress.Value++; dictionary3.Add("tiger", str15); } GC.Collect(); } else { this.OptionalHashProgress.Value++; } if (this.IncludeSHA1.Checked) { TorrentString str17 = new TorrentString(); stream = new FileStream(str10, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); this.sha1.ComputeHash(stream); stream.Close(); Application.DoEvents(); hash = this.sha1.Hash; changer.bytehash = this.sha1.Hash; str17.Value = changer.rawhash; builder.Remove(0, builder.Length); hash = null; this.OptionalHashProgress.Value++; dictionary3.Add("sha1", str17); GC.Collect(); } if (this.IncludeMD5.Checked) { TorrentString str19 = new TorrentString(); stream = new FileStream(str10, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); builder = new StringBuilder(); this.md5.ComputeHash(stream); Application.DoEvents(); stream.Close(); foreach (byte num13 in this.md5.Hash) { builder.AppendFormat("{0:x2}", num13); } str19.Value = builder.ToString(); builder.Remove(0, builder.Length); hash = null; this.OptionalHashProgress.Value++; dictionary3.Add("md5sum", str19); GC.Collect(); } if (this.IncludeCRC32.Checked) { TorrentString str20 = new TorrentString(); CRC32 crc = new CRC32(); int num15 = 0; stream = new FileStream(str10, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); Stream stream2 = stream; stream = (FileStream) stream2; num15 = crc.GetCrc32(ref stream2); stream.Close(); Application.DoEvents(); str20.Value = string.Format("{0:X8}", num15); this.OptionalHashProgress.Value++; dictionary3.Add("crc32", str20); GC.Collect(); } if (this.IncludeED2K.Checked) { string str21 = ""; string str22 = ""; TorrentString str23 = new TorrentString(); this.GetED2KHash(str10, ref str22, ref str21); this.OptionalHashProgress.Value++; str23.Value = str21; dictionary3.Add("ed2k", str23); GC.Collect(); } list2.Add(dictionary3); } else { this.OptionalHashProgress.Maximum -= CountMultiplier; } } if (this.AutomaticPieceSize.Checked) { num9 = this.getautopiecesize(num); } else { num9 = Conversions.ToInteger(this.PieceSize.Text); } list.Value = list2; TorrentNumber number = new TorrentNumber { Value = num9 }; dictionary2.Add("files", list); dictionary2.Add("piece length", number); long upperBound = strArray.GetUpperBound(0); long num2 = 0L; long num3 = 0L; byte[] buffer = new byte[((int) num9) + 1]; byte[] bytes = new byte[0x15]; while (true) { if (this.IsFileCleared(strArray[(int) num2])) { this.FileHandling = File.Open(strArray[(int) num2], FileMode.Open, FileAccess.Read, FileShare.ReadWrite); if (GenerateVerbose) { Interaction.MsgBox("Current File: " + strArray[(int) num2] + "\n File offset for Piece 0 of this file: " + Conversions.ToString(num3), MsgBoxStyle.OkOnly, null); } break; } num2 += 1L; } Label_062B: Thread.Sleep(10); Application.DoEvents(); this.TorrentProgress.Value = (int) Math.Round((double) ((((double) num3) / ((double) num12)) * 100.0)); byte[] buffer4 = new byte[((int) (num9 - 1L)) + 1]; Label_0668: num6 = this.FileHandling.Read(buffer4, (int) num8, (int) (num9 - num8)); num8 += num6; if (!((num2 <= upperBound) & (num8 < num9))) { string str3 = ""; byte[] buffer5 = new byte[((int) (num8 - 1L)) + 1]; long num27 = num8 - 1L; for (long i = 0L; i <= num27; i += 1L) { buffer5[(int) i] = buffer4[(int) i]; } buffer4 = null; bytes = this.sha1.ComputeHash(buffer5); int num17 = 0; do { str3 = str3 + Encoding.Default.GetString(bytes, num17, 1); num17++; } while (num17 <= 0x13); bytes = null; num3 += num8; num8 = 0L; GC.Collect(); if (num3 >= num12) { this.FileHandling.Close(); if (GenerateVerbose) { Interaction.MsgBox("Size of files hashed: " + Conversions.ToString(num3) + " Size of files compared: " + Conversions.ToString(num12) + "\nNow Generating .torrent file", MsgBoxStyle.OkOnly, null); } this.TorrentProgress.Value = 100; string path = Strings.Left(this.FileNameToMake.Text, Strings.Len(this.FileNameToMake.Text) - 1) + ".torrent"; TorrentString str9 = new TorrentString { Value = str3 }; dictionary2.Add("pieces", str9); int num5 = Strings.Left(this.FileNameToMake.Text, Strings.Len(this.FileNameToMake.Text) - 1).LastIndexOf(@"\"); int num4 = Strings.Len(this.FileNameToMake.Text) - num5; string str8 = Strings.Right(Strings.Left(this.FileNameToMake.Text, Strings.Len(this.FileNameToMake.Text) - 1), num4 - 2); TorrentString str7 = new TorrentString { Value = str8 }; TorrentDictionary dictionary = new TorrentDictionary(); TorrentString str4 = new TorrentString(); dictionary2.Add("name", str7); str4.Value = this.AnnounceURL.Text; if (UseWSAConfig) { ArrayList returnarray = new ArrayList(); TorrentList list6 = new TorrentList(); int webSeedData = TorrentGenFamily.GetWebSeedData(returnarray); list6.Value = returnarray; if (webSeedData >= 1) { dictionary.Add("httpseeds", list6); } } TorrentString str2 = new TorrentString { Value = "Torrent Generated by VB.Net TorrentGen - Written by DWKnight" }; dictionary.Add("created by", str2); TorrentString str = new TorrentString(); if (Strings.Trim(this.TorrentComment.Text) != "") { str.Value = Strings.Trim(this.TorrentComment.Text); dictionary.Add("comment", str); } if (this.AnnounceURL.Text != "") { dictionary.Add("announce", str4); } if (this.PrivateTorrent.Checked) { TorrentNumber number3 = new TorrentNumber { Value = 1L }; dictionary2["private"] = number3; } dictionary.Add("info", dictionary2); TorrentString str5 = new TorrentString { Value = "UTF8" }; dictionary.Add("encoding", str5); if (this.MultiTrackerEnabled.Checked) { this.CheckMultitTrackerTiers(); dictionary.Add("announce-list", MultiTrackerGenerator.MultiTrackerTiers); } if (File.Exists(path)) { FileSystem.Kill(path); } int fileNumber = FileSystem.FreeFile(); FileSystem.FileOpen(fileNumber, path, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1); FileSystem.FilePut(fileNumber, dictionary.BEncoded, -1L, false); FileSystem.FileClose(new int[] { fileNumber }); GC.Collect(); if (this.MakeExternals.Checked) { string str26 = ""; string str28 = ""; string str29 = ""; string str30 = ""; string str32 = ""; string str34 = ""; IEnumerator enumerator2 = null; string expression = Strings.Left(this.FileNameToMake.Text, Strings.Len(this.FileNameToMake.Text) - 1); string str27 = expression + ".md5"; string str31 = expression + ".sha1"; string str25 = expression + ".ed2k"; string str33 = expression + ".tiger"; string[] strArray2 = Strings.Split(expression, @"\", -1, CompareMethod.Binary); strArray2[strArray2.GetUpperBound(0)] = Strings.Replace(strArray2[strArray2.GetUpperBound(0)], " ", ".", 1, -1, CompareMethod.Binary); strArray2[strArray2.GetUpperBound(0)] = Strings.Replace(strArray2[strArray2.GetUpperBound(0)], "_", ".", 1, -1, CompareMethod.Binary); foreach (string str35 in strArray2) { str29 = str29 + @"\" + str35; } str29 = Strings.Mid(str29, 2, Strings.Len(str29) - 1) + ".sfv"; LinkGeneration generation = new LinkGeneration(); HashChanger changer2 = new HashChanger(); try { enumerator2 = list2.GetEnumerator(); while (enumerator2.MoveNext()) { IEnumerator enumerator3 = null; TorrentDictionary current = (TorrentDictionary) enumerator2.Current; generation = new LinkGeneration(); TorrentString str36 = new TorrentString(); try { enumerator3 = ((IEnumerable) NewLateBinding.LateGet(current["path"], null, "value", new object[0], null, null, null)).GetEnumerator(); while (enumerator3.MoveNext()) { TorrentString str37 = (TorrentString) enumerator3.Current; str36 = str37; } } finally { if (enumerator3 is IDisposable) { (enumerator3 as IDisposable).Dispose(); } } if (this.IncludeMD5.Checked) { TorrentString str38 = new TorrentString(); str38 = (TorrentString) current["md5sum"]; str28 = str28 + str36.Value + " " + str38.Value + "\r\n"; } if (this.IncludeSHA1.Checked) { changer2 = new HashChanger { rawhash = Conversions.ToString(NewLateBinding.LateGet(current["sha1"], null, "value", new object[0], null, null, null)) }; str32 = str32 + str36.Value + " " + changer2.hexhash + "\r\n"; } if (this.IncludeTiger.Checked && current.Contains("tiger")) { changer2 = new HashChanger { rawhash = Conversions.ToString(NewLateBinding.LateGet(current["tiger"], null, "value", new object[0], null, null, null)) }; str34 = str34 + str36.Value + " " + changer2.base32 + "\r\n"; } if (this.IncludeCRC32.Checked) { str30 = Conversions.ToString(Operators.AddObject(Operators.AddObject(Operators.AddObject(str30 + str36.Value + " ", NewLateBinding.LateGet(current["crc32"], null, "value", new object[0], null, null, null)), '\r'), '\n')); } if (this.IncludeED2K.Checked) { generation.ED2KRaw = Conversions.ToString(NewLateBinding.LateGet(current["ed2k"], null, "Value", new object[0], null, null, null)); generation.FileSize = Conversions.ToLong(NewLateBinding.LateGet(current["length"], null, "Value", new object[0], null, null, null)); generation.FileName = str36.Value; str26 = str26 + generation.ClassicED2KLink + "\r\n"; str26 = str26 + str36.Value + " " + generation.ED2KHex + "\r\n"; } GC.Collect(); } } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } if (this.IncludeMD5.Checked) { if (File.Exists(str27)) { FileSystem.Kill(str27); } int num19 = FileSystem.FreeFile(); FileSystem.FileOpen(num19, str27, OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.Print(num19, new object[] { str28 }); FileSystem.FileClose(new int[] { num19 }); } if (this.IncludeTiger.Checked) { if (File.Exists(str33)) { FileSystem.Kill(str33); } int num20 = FileSystem.FreeFile(); FileSystem.FileOpen(num20, str33, OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.Print(num20, new object[] { str34 }); FileSystem.FileClose(new int[] { num20 }); } if (this.IncludeSHA1.Checked) { if (File.Exists(str31)) { FileSystem.Kill(str31); } int num21 = FileSystem.FreeFile(); FileSystem.FileOpen(num21, str31, OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.Print(num21, new object[] { str32 }); FileSystem.FileClose(new int[] { num21 }); } if (this.IncludeED2K.Checked) { if (File.Exists(str25)) { FileSystem.Kill(str25); } int num22 = FileSystem.FreeFile(); FileSystem.FileOpen(num22, str25, OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.Print(num22, new object[] { str26 }); FileSystem.FileClose(new int[] { num22 }); } if (this.IncludeCRC32.Checked) { if (File.Exists(str29)) { FileSystem.Kill(str29); } int num23 = FileSystem.FreeFile(); FileSystem.FileOpen(num23, str29, OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.Print(num23, new object[] { str30 }); FileSystem.FileClose(new int[] { num23 }); } } GC.Collect(); return; } goto Label_062B; } num2 += 1L; while (true) { if (num2 > strArray.GetUpperBound(0)) { goto Label_0668; } if (this.IsFileCleared(strArray[(int) num2])) { break; } num2 += 1L; } this.FileHandling.Close(); this.FileHandling = File.Open(strArray[(int) num2], FileMode.Open, FileAccess.Read, FileShare.ReadWrite); if (GenerateVerbose) { Interaction.MsgBox("Current File: " + strArray[(int) num2] + "\n File offset for Piece 0 of this file: " + Conversions.ToString(num3), MsgBoxStyle.OkOnly, null); } goto Label_0668; }
private void TorrentBuild_Load(object sender, EventArgs e) { string[] commandLineArgs = Environment.GetCommandLineArgs(); if (commandLineArgs.GetLength(0) > 1) { this.FileNameToMake.Text = commandLineArgs[1]; } TorrentString str3 = new TorrentString(); TorrentString str = new TorrentString(); TorrentString str2 = new TorrentString(); str3.Value = ".sfv"; str.Value = ".cdp"; str2.Value = ".cdt"; BlackListedFiles.Add(str3); BlackListedFiles.Add(str); BlackListedFiles.Add(str2); int length = Strings.Left(commandLineArgs[0], Strings.Len(commandLineArgs[0])).LastIndexOf(@"\"); LocalPath = Path.GetFullPath(Strings.Left(commandLineArgs[0], length)) + @"\"; if (File.Exists(LocalPath + "tgen.configure")) { int fileNumber = FileSystem.FreeFile(); FileSystem.FileOpen(fileNumber, LocalPath + "tgen.configure", OpenMode.Binary, OpenAccess.Read, OpenShare.LockRead, -1); string str4 = Strings.Space((int) FileSystem.FileLen(LocalPath + "tgen.configure")); FileSystem.FileGet(fileNumber, ref str4, -1L, false); FileSystem.FileClose(new int[] { fileNumber }); TorrentDictionary dictionary = new TorrentDictionary(); dictionary.Parse(str4); TorrentString str5 = new TorrentString(); TorrentNumber number2 = new TorrentNumber(); TorrentNumber number8 = new TorrentNumber(); TorrentNumber number7 = new TorrentNumber(); TorrentNumber number5 = new TorrentNumber(); TorrentString str6 = new TorrentString(); TorrentNumber number6 = new TorrentNumber(); TorrentNumber number9 = new TorrentNumber(); TorrentNumber number = new TorrentNumber(); TorrentNumber number3 = new TorrentNumber(); TorrentNumber number4 = new TorrentNumber(); str5 = (TorrentString) dictionary["tracker"]; number2 = (TorrentNumber) dictionary["piecesize"]; if (dictionary.Contains("externals")) { number4 = (TorrentNumber) dictionary["externals"]; this.MakeExternals.Checked = number4.Value > 0L; } if (dictionary.Contains("folder")) { number3 = (TorrentNumber) dictionary["folder"]; this.MakeSeparateTorrents.Checked = number3.Value > 0L; } if (dictionary.Contains("sha1")) { number8 = (TorrentNumber) dictionary["sha1"]; this.IncludeSHA1.Checked = number8.Value > 0L; } if (dictionary.Contains("md5")) { number7 = (TorrentNumber) dictionary["md5"]; this.IncludeMD5.Checked = number7.Value > 0L; } if (dictionary.Contains("crc")) { number5 = (TorrentNumber) dictionary["crc"]; this.IncludeCRC32.Checked = number5.Value > 0L; } if (dictionary.Contains("ed2k")) { number6 = (TorrentNumber) dictionary["ed2k"]; this.IncludeED2K.Checked = number6.Value > 0L; } if (dictionary.Contains("tiger")) { number9 = (TorrentNumber) dictionary["tiger"]; this.IncludeTiger.Checked = number9.Value > 0L; } if (dictionary.Contains("comment")) { str6 = (TorrentString) dictionary["comment"]; this.TorrentComment.Text = str6.Value; } if (dictionary.Contains("advanced")) { TorrentDictionary dictionary2 = new TorrentDictionary(); dictionary2 = (TorrentDictionary) dictionary["advanced"]; TorrentNumber number12 = new TorrentNumber(); TorrentNumber number11 = new TorrentNumber(); TorrentNumber number10 = new TorrentNumber(); number12 = (TorrentNumber) dictionary2["verbose"]; number11 = (TorrentNumber) dictionary2["usewsa"]; number10 = (TorrentNumber) dictionary2["delay"]; GenerateVerbose = number12.Value > 0L; UseWSAConfig = number11.Value > 0L; DelayMessages = number10.Value > 0L; } else { GenerateVerbose = true; UseWSAConfig = false; DelayMessages = true; } if (dictionary.Contains("blankblacklist")) { TorrentNumber number13 = new TorrentNumber(); if (number13.Value == -1L) { BlackListedFiles = new ArrayList(); } } if (dictionary.Contains("blacklist")) { TorrentList list = new TorrentList(); list = (TorrentList) dictionary["blacklist"]; BlackListedFiles = list.Value; } if (dictionary.Contains("multitracker")) { MultiTrackerGenerator.MultiTrackerTiers = (TorrentList) dictionary["multitracker"]; this.Multitracker.UpdateInput(); } if (dictionary.Contains("usemultitracker")) { TorrentNumber number14 = new TorrentNumber(); number14 = (TorrentNumber) dictionary["usemultitracker"]; this.MultiTrackerEnabled.Checked = number14.Value > 0L; } number = (TorrentNumber) dictionary["autopiece"]; this.AutomaticPieceSize.Checked = number.Value > 0L; this.AnnounceURL.Text = str5.Value; this.PieceSize.Text = Conversions.ToString(number2.Value); } this.AutomaticPieceSize_CheckedChanged(RuntimeHelpers.GetObjectValue(sender), e); GC.Collect(); }
private void SaveSettings_Click(object sender, EventArgs e) { this.AnnounceURL.Text = Strings.Trim(this.AnnounceURL.Text); TorrentString str = new TorrentString(); TorrentNumber number3 = new TorrentNumber(); TorrentNumber number11 = new TorrentNumber(); TorrentNumber number9 = new TorrentNumber(); TorrentNumber number7 = new TorrentNumber(); TorrentNumber number8 = new TorrentNumber(); TorrentNumber number12 = new TorrentNumber(); TorrentNumber number6 = new TorrentNumber(); TorrentNumber number = new TorrentNumber(); TorrentNumber number5 = new TorrentNumber(); TorrentDictionary dictionary = new TorrentDictionary(); TorrentNumber number14 = new TorrentNumber(); TorrentNumber number13 = new TorrentNumber(); TorrentNumber number4 = new TorrentNumber(); TorrentList list = new TorrentList(); TorrentString str2 = new TorrentString(); TorrentNumber number10 = new TorrentNumber(); list.Value = BlackListedFiles; number14.Value = (long) -(Convert.ToInt32(GenerateVerbose)); number13.Value = (long) -(Convert.ToInt32(UseWSAConfig)); number4.Value = (long) -(Convert.ToInt32(DelayMessages)); dictionary.Add("verbose", number14); dictionary.Add("usewsa", number13); dictionary.Add("delay", number4); str.Value = this.AnnounceURL.Text; number3.Value = Conversions.ToInteger(this.PieceSize.Text); number5.Value = (long) -(Convert.ToInt32(this.MakeSeparateTorrents.Checked)); number11.Value = (long) -(Convert.ToInt32(this.IncludeSHA1.Checked)); number9.Value = (long) -(Convert.ToInt32(this.IncludeMD5.Checked)); number7.Value = (long) -(Convert.ToInt32(this.IncludeCRC32.Checked)); number8.Value = (long) -(Convert.ToInt32(this.IncludeED2K.Checked)); number12.Value = (long) -(Convert.ToInt32(this.IncludeTiger.Checked)); number6.Value = (long) -(Convert.ToInt32(this.MakeExternals.Checked)); number.Value = (long) -(Convert.ToInt32(this.AutomaticPieceSize.Checked)); str2.Value = Strings.Trim(this.TorrentComment.Text); number10.Value = (long)-(Convert.ToInt32(this.MultiTrackerEnabled.Checked)); TorrentDictionary dictionary2 = new TorrentDictionary(); TorrentNumber number2 = new TorrentNumber(); TorrentList list2 = new TorrentList { Value = new ArrayList() }; if (list.BEncoded != list2.BEncoded) { dictionary2.Add("blacklist", list); number2.Value = 0L; } else { number2.Value = -1L; } if (MultiTrackerGenerator.MultiTrackerTiers.BEncoded != list2.BEncoded) { this.CheckMultitTrackerTiers(); dictionary2.Add("multitracker", MultiTrackerGenerator.MultiTrackerTiers); } dictionary2.Add("usemultitracker", number10); dictionary2.Add("blankblacklist", number2); dictionary2.Add("advanced", dictionary); dictionary2.Add("tracker", str); dictionary2.Add("piecesize", number3); dictionary2.Add("sha1", number11); dictionary2.Add("md5", number9); dictionary2.Add("crc", number7); dictionary2.Add("ed2k", number8); dictionary2.Add("tiger", number12); dictionary2.Add("externals", number6); dictionary2.Add("autopiece", number); dictionary2.Add("folder", number5); dictionary2.Add("comment", str2); int fileNumber = FileSystem.FreeFile(); if (File.Exists(LocalPath + "tgen.configure")) { FileSystem.Kill(LocalPath + "tgen.configure"); } FileSystem.FileOpen(fileNumber, LocalPath + "tgen.configure", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1); FileSystem.FilePut(fileNumber, dictionary2.BEncoded, -1L, false); FileSystem.FileClose(new int[] { fileNumber }); GC.Collect(); }
private void CheckMultitTrackerTiers() { IEnumerator enumerator = null; try { enumerator = MultiTrackerGenerator.MultiTrackerTiers.Value.GetEnumerator(); while (enumerator.MoveNext()) { IEnumerator enumerator2 = null; TorrentList current = (TorrentList) enumerator.Current; try { enumerator2 = current.Value.GetEnumerator(); while (enumerator2.MoveNext()) { TorrentString str2 = (TorrentString) enumerator2.Current; if (str2.Value == Strings.Trim(this.AnnounceURL.Text)) { return; } } continue; } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } TorrentString str = new TorrentString { Value = Strings.Trim(this.AnnounceURL.Text) }; TorrentList list = new TorrentList(); list.Value.Add(str); MultiTrackerGenerator.MultiTrackerTiers.Value.Add(list); GC.Collect(); }
public void MakeTorrentFromFile(string NameOfFile) { FileStream stream; string str6 = ""; string hexhash = ""; string str13 = ""; string str14 = ""; long filesize = FileSystem.FileLen(NameOfFile); TorrentString str10 = new TorrentString(); TorrentString str7 = new TorrentString(); TorrentString str5 = new TorrentString(); TorrentString str4 = new TorrentString(); TorrentString str12 = new TorrentString(); StringBuilder builder = new StringBuilder(); HashChanger changer = new HashChanger(); this.OptionalHashProgress.Maximum = CountMultiplier; this.OptionalHashProgress.Value = 0; if (filesize < 0x100000000L) { if (this.IncludeTiger.Checked) { this.TigerHash = new ThexThreaded(); changer = new HashChanger { bytehash = this.TigerHash.GetTTH_Value(NameOfFile) }; Application.DoEvents(); str12.Value = changer.rawhash; str13 = changer.base32; this.OptionalHashProgress.Value++; } } else { this.OptionalHashProgress.Value++; } if (this.IncludeSHA1.Checked) { changer = new HashChanger(); stream = new FileStream(NameOfFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); this.sha1.ComputeHash(stream); stream.Close(); Application.DoEvents(); changer.bytehash = this.sha1.Hash; str10.Value = changer.rawhash; hexhash = changer.hexhash; this.OptionalHashProgress.Value++; } if (this.IncludeMD5.Checked) { changer = new HashChanger(); stream = new FileStream(NameOfFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); this.md5.ComputeHash(stream); stream.Close(); changer.bytehash = this.md5.Hash; Application.DoEvents(); str7.Value = changer.hexhash; this.OptionalHashProgress.Value++; } if (this.IncludeCRC32.Checked) { CRC32 crc = new CRC32(); int num7 = 0; stream = new FileStream(NameOfFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); Stream stream2 = stream; stream = (FileStream) stream2; num7 = crc.GetCrc32(ref stream2); stream.Close(); str4.Value = string.Format("{0:X8}", num7); Application.DoEvents(); this.OptionalHashProgress.Value++; } if (this.IncludeED2K.Checked) { string str3 = ""; this.GetED2KHash(NameOfFile, ref str6, ref str3); this.OptionalHashProgress.Value++; str5.Value = str3; } this.FileHandling = File.Open(NameOfFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); byte[] bytes = new byte[0x15]; if (this.AutomaticPieceSize.Checked) { this.piecesizetouse = this.getautopiecesize(filesize); } else { this.piecesizetouse = Conversions.ToInteger(this.PieceSize.Text); } long num3 = 0L; this.FileHandling.Seek(0L, SeekOrigin.Begin); while (num3 < filesize) { this.TorrentProgress.Value = (int) Math.Round((double) ((((double) num3) / ((double) filesize)) * 100.0)); Application.DoEvents(); byte[] array = new byte[((int) this.piecesizetouse) + 1]; long num5 = this.FileHandling.Read(array, 0, (int) this.piecesizetouse); byte[] buffer = new byte[((int) (num5 - 1L)) + 1]; long num16 = num5 - 1L; for (long i = 0L; i <= num16; i += 1L) { buffer[(int) i] = array[(int) i]; } bytes = this.sha1.ComputeHash(buffer); int index = 0; do { str14 = str14 + Encoding.Default.GetString(bytes, index, 1); index++; } while (index <= 0x13); num3 += this.piecesizetouse; buffer = null; array = null; Thread.Sleep(10); GC.Collect(); } this.TorrentProgress.Value = 100; this.FileHandling.Close(); TorrentString str20 = new TorrentString(); int length = NameOfFile.LastIndexOf(@"\"); int num = Strings.Len(NameOfFile) - length; string str8 = Strings.Right(NameOfFile, num - 1); string str9 = Strings.Left(NameOfFile, length); TorrentString str19 = new TorrentString { Value = str8 }; TorrentString str17 = new TorrentString(); TorrentNumber number = new TorrentNumber { Value = filesize }; TorrentNumber number2 = new TorrentNumber { Value = this.piecesizetouse }; str20.Value = str14; str17.Value = "UTF8"; TorrentDictionary dictionary2 = new TorrentDictionary(); TorrentDictionary dictionary = new TorrentDictionary(); TorrentString str16 = new TorrentString { Value = this.AnnounceURL.Text }; dictionary.Add("length", number); dictionary.Add("name", str19); dictionary.Add("pieces", str20); dictionary.Add("piece length", number2); if (this.MultiTrackerEnabled.Checked) { this.CheckMultitTrackerTiers(); dictionary2.Add("announce-list", MultiTrackerGenerator.MultiTrackerTiers); } if (this.IncludeSHA1.Checked) { dictionary.Add("sha1", str10); } if (this.IncludeMD5.Checked) { dictionary.Add("md5sum", str7); } if (this.IncludeCRC32.Checked) { dictionary.Add("crc32", str4); } if (this.IncludeED2K.Checked) { dictionary.Add("ed2k", str5); } if (this.IncludeTiger.Checked) { dictionary.Add("tiger", str12); } if (UseWSAConfig) { ArrayList returnarray = new ArrayList(); TorrentList list2 = new TorrentList(); int webSeedData = TorrentGenFamily.GetWebSeedData(returnarray); list2.Value = returnarray; if (webSeedData >= 1) { dictionary2.Add("httpseeds", list2); } } TorrentString str2 = new TorrentString { Value = "Torrent Generated by VB.Net TorrentGen - Written by DWKnight" }; dictionary2.Add("created by", str2); TorrentString str = new TorrentString(); if (Strings.Trim(this.TorrentComment.Text) != "") { str.Value = Strings.Trim(this.TorrentComment.Text); dictionary2.Add("comment", str); } if (this.PrivateTorrent.Checked) { TorrentNumber number3 = new TorrentNumber { Value = 1L }; dictionary["private"] = number3; } dictionary2.Add("info", dictionary); if (this.AnnounceURL.Text != "") { dictionary2.Add("announce", str16); } dictionary2.Add("encoding", str17); int fileNumber = FileSystem.FreeFile(); string fileName = NameOfFile + ".torrent"; FileSystem.FileOpen(fileNumber, fileName, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1); FileSystem.FilePut(fileNumber, dictionary2.BEncoded, -1L, false); FileSystem.FileClose(new int[] { fileNumber }); bytes = null; if (this.MakeExternals.Checked) { if (this.IncludeSHA1.Checked) { int num11 = FileSystem.FreeFile(); FileSystem.FileOpen(num11, NameOfFile + ".sha1", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.PrintLine(num11, new object[] { str19.Value + " " + hexhash }); FileSystem.FileClose(new int[] { num11 }); } if ((filesize <= 0x118940000L) && this.IncludeTiger.Checked) { int num12 = FileSystem.FreeFile(); FileSystem.FileOpen(num12, NameOfFile + ".tiger", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.PrintLine(num12, new object[] { str19.Value + " " + str13 }); FileSystem.FileClose(new int[] { num12 }); } if (this.IncludeMD5.Checked) { int num13 = FileSystem.FreeFile(); FileSystem.FileOpen(num13, NameOfFile + ".md5", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.PrintLine(num13, new object[] { str19.Value + " " + str7.Value }); FileSystem.FileClose(new int[] { num13 }); } if (this.IncludeCRC32.Checked) { int num14 = FileSystem.FreeFile(); FileSystem.FileOpen(num14, NameOfFile + ".sfv", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.PrintLine(num14, new object[] { str19.Value + " " + str4.Value }); FileSystem.FileClose(new int[] { num14 }); } if (this.IncludeED2K.Checked) { LinkGeneration generation = new LinkGeneration { FileName = str19.Value, FileSize = number.Value, ED2KHex = str6 }; int num15 = FileSystem.FreeFile(); FileSystem.FileOpen(num15, NameOfFile + ".ed2k", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1); FileSystem.PrintLine(num15, new object[] { generation.ClassicED2KLink }); FileSystem.PrintLine(num15, new object[] { str19.Value + " " + generation.ED2KHex + "\r\n" }); FileSystem.FileClose(new int[] { num15 }); } } GC.Collect(); }