本文整理汇总了C#中Writer.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Writer.Close方法的具体用法?C# Writer.Close怎么用?C# Writer.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Writer
的用法示例。
在下文中一共展示了Writer.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonApply_Click
private void buttonApply_Click(object sender, EventArgs e)
{
using (OpenFileDialog OFD = new OpenFileDialog())
{
OFD.Title = "Choose .exe files (32bit or 64bit)";
OFD.Filter = "Executable (*.exe)|*.exe";
OFD.FilterIndex = 0;
OFD.RestoreDirectory = true;
if (OFD.ShowDialog(this) == DialogResult.OK)
{
try
{
Plat platform = Plat.x32;
bool supported = false;
Reader reader = new Reader(OFD.FileName, Endian.Little);
uint[] addr = new uint[] { ADDRESS_X64, ADDRESS_X32 };
foreach (uint address in addr)
{
reader.Position = address;
if (reader.PeekString(4) == "2221")
{
if (address == ADDRESS_X64)
platform = Plat.x64;
supported = true;
break;
}
}
if (supported)
{
DialogResult result = MessageBox.Show("Backup ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
File.Copy(OFD.FileName, OFD.FileName + ".bk", true);
if (platform == Plat.x64)
{
Writer write = new Writer(OFD.FileName, Endian.Little);
foreach (uint offset in Offset64)
{
write.Position = offset;
write.Write(new byte[] { 0x32, 0x42 });
}
write.Close();
MessageBox.Show("Successfully", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("can not apply a patch to this application");
}
}
else
{
MessageBox.Show("cannot apply this patch on this version of the application", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
OFD.Dispose();
}
}
}
}
示例2: DecryptWrite
private string DecryptWrite(string path, Reader reader)
{
int multiplicator = 65536;
byte[] encryptData = new byte[AESKeys.Length * multiplicator];
byte[] decryptData = new byte[AESKeys.Length * multiplicator];
byte[] dataRiv = new byte[16];
Array.Copy(PackageData.pkg_data_riv, dataRiv, PackageData.pkg_data_riv.Length);
if (File.Exists(path + ".cache"))
File.Delete(path + ".cache");
FileStream streamWrite = new FileStream(path + ".cache", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
Writer write = new Writer(streamWrite, Endian.Little);
reader.Position = (uint)PackageData.data_offset;
reader.CurrentEndian = Endian.Little;
double split = (double)PackageData.data_size / (double)(AESKeys.Length * multiplicator);
UInt64 pieces = (UInt64)Math.Floor(split);
UInt64 data = (UInt64)PackageData.data_size % (UInt64)(AESKeys.Length * multiplicator);
if (data > 0)
pieces += 1;
ProgressBar.ValueInvoke(0);
for (UInt64 i = 0; i < pieces; i++)
{
if ((data > 0) && (i == (pieces - 1)))
{
encryptData = new byte[data];
decryptData = new byte[data];
}
encryptData = reader.ReadBytes(encryptData.Length);
byte[] key = new byte[encryptData.Length];
byte[] xor = new byte[encryptData.Length];
for (int pos = 0; pos < encryptData.Length; pos += AESKeys.Length)
{
Array.Copy(dataRiv, 0, key, pos, PackageData.pkg_data_riv.Length);
IncrementArray(ref dataRiv, PackageData.pkg_data_riv.Length - 1);
}
xor = Security.Rijndael.Encrypt(key, AESKeys, AESKeys, CipherMode.ECB, PaddingMode.None);
decryptData = XOR(encryptData, 0, xor.Length, xor);
write.Write(decryptData);
ProgressBar.ValueInvoke((int)((100 * i) / pieces));
}
write.Close();
streamWrite.Close();
ProgressBar.ValueInvoke(100);
return string.Format("{0}.{1}", path, "cache");
}
示例3: Test_PdfExportDeflatedStream_02
public static void Test_PdfExportDeflatedStream_02(String pdfFile, int objectId, string streamFile)
{
Writer w = null;
_tr.WriteLine("export stream object {0} pdf file \"{1}\" to \"{2}\"", objectId, pdfFile, streamFile);
PB_Pdf.PdfReader pr = new PB_Pdf.PdfReader(pdfFile);
try
{
IPdfObject obj = ReadPdfObject(pr, objectId, "Object");
if (obj.deflatedStream == null)
{
_tr.WriteLine("no stream");
return;
}
_tr.WriteLine("read data");
//IPdfInstruction[] instructions = PdfDataReader.PdfReadAll(obj.deflatedStream);
PdfDataReader pdr = new PdfDataReader(obj.deflatedStream);
//pdr.Trace += new TraceDelegate(_tr.WriteLine);
IPdfInstruction[] instructions = pdr.ReadAll();
_tr.WriteLine("{0} instructions", instructions.Length);
//var q = from instruction in instructions select instruction.opeString;
//foreach (string opeString in q.Distinct().OrderBy(opeString => opeString))
//{
// _tr.WriteLine(opeString);
//}
w = new Writer(streamFile, FileMode.Create);
foreach (IPdfInstruction instruction in instructions)
{
//_tr.WriteLine(instruction);
//w.WriteLine(instruction.ToString());
instruction.Export(w);
}
}
finally
{
if (w != null) w.Close();
pr.Close();
}
}
示例4: Test_PdfExportDeflatedStream_01
public static void Test_PdfExportDeflatedStream_01(string pdfFile, int idObject, string streamFile)
{
_tr.WriteLine("export stream object {0} of pdf file \"{1}\" to \"{2}\"", idObject, pdfFile, streamFile);
PB_Pdf.PdfReader pr = null;
Writer w = null;
try
{
pr = new PB_Pdf.PdfReader(pdfFile);
IPdfObject obj = ReadPdfObject(pr, idObject, "Object");
w = new Writer(streamFile, FileMode.Create);
if (obj.deflatedStream != null)
w.Write(obj.deflatedStream);
}
finally
{
if (pr != null) pr.Close();
if (w != null) w.Close();
}
}
示例5: Test_07
public static void Test_07()
{
string file = @"c:\pib\dev_data\exe\pdf\test.txt";
Writer fw = new Writer(file, FileMode.Create);
try
{
fw.Write("toto\n");
fw.Write("tata\n");
}
finally
{
fw.Close();
}
}