MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-f8f9f26e940480624825f6bddbea86e70fc4aa746c4dd8efa7d98dcb477000ed/Microsoft/InfoCards/ExportFileRequest.cs
2022-08-18 06:28:56 -05:00

115 lines
4.0 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.ExportFileRequest
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 1D4D5564-A025-490C-AF1D-DF4FBB709D1F
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-f8f9f26e940480624825f6bddbea86e70fc4aa746c4dd8efa7d98dcb477000ed.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Schema;
namespace Microsoft.InfoCards
{
internal class ExportFileRequest : UIAgentRequest
{
private string m_filename;
private string m_passphrase;
private string[] m_cardIds;
public ExportFileRequest(
IntPtr rpcHandle,
Stream inArgs,
Stream outArgs,
ClientUIRequest parent)
: base(rpcHandle, inArgs, outArgs, parent)
{
}
protected override void OnMarshalInArgs()
{
BinaryReader reader = (BinaryReader) new InfoCardBinaryReader(this.InArgs, Encoding.Unicode);
this.m_filename = Utility.DeserializeString(reader);
this.m_passphrase = Utility.DeserializeString(reader);
uint length = reader.ReadUInt32();
this.m_cardIds = new string[(IntPtr) length];
for (uint index = 0; index < length; ++index)
this.m_cardIds[(IntPtr) index] = Utility.DeserializeString(reader);
}
protected override void OnProcess()
{
InfoCardTrace.Assert(!string.IsNullOrEmpty(this.m_filename), "No file name was specified");
InfoCardTrace.Assert(!string.IsNullOrEmpty(this.m_passphrase), " No passphrase specified for the file");
StoreConnection connection = StoreConnection.GetConnection();
try
{
RoamingStoreFile roamingStoreFile = new RoamingStoreFile();
try
{
for (int index = 0; index < this.m_cardIds.Length; ++index)
{
InfoCard infoCard = new InfoCard(new Uri(this.m_cardIds[index]));
infoCard.Get(connection);
infoCard.GetMasterKey(connection);
roamingStoreFile.Cards.Add(infoCard);
}
using (FileStream output = new FileStream(this.m_filename, FileMode.Create))
{
using (XmlWriter writer = XmlWriter.Create((Stream) output, new XmlWriterSettings()
{
CloseOutput = false
}))
{
roamingStoreFile.WriteTo(this.m_passphrase, writer);
writer.Flush();
}
output.Flush();
}
}
finally
{
foreach (InfoCard card in (IEnumerable<InfoCard>) roamingStoreFile.Cards)
card.ClearSensitiveData();
}
AuditLog.AuditStoreExport();
}
catch (XmlSchemaValidationException ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new ExportException(SR.GetString("SchemaValidationFailed"), (Exception) ex));
}
catch (XmlException ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new ExportException(SR.GetString("InvalidImportFile"), (Exception) ex));
}
catch (UnauthorizedAccessException ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new ExportException(SR.GetString("ImportInaccesibleFile"), (Exception) ex));
}
catch (IOException ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new ExportException(SR.GetString("InvalidImportFile"), (Exception) ex));
}
catch (ArgumentException ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new ExportException(SR.GetString("ImportInaccesibleFile"), (Exception) ex));
}
catch (SerializationIncompleteException ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new ExportException(SR.GetString("FailedToSerializeObject", (object) ex.ObjectType), (Exception) ex));
}
finally
{
connection.Close();
}
}
protected override void OnMarshalOutArgs()
{
}
}
}