本文整理汇总了C#中Mono.Cecil.EmbeddedResource类的典型用法代码示例。如果您正苦于以下问题:C# EmbeddedResource类的具体用法?C# EmbeddedResource怎么用?C# EmbeddedResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedResource类属于Mono.Cecil命名空间,在下文中一共展示了EmbeddedResource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: decrypt
public byte[] decrypt(EmbeddedResource resource)
{
if (!CanDecrypt)
throw new ApplicationException("Can't decrypt resources");
var encryptedData = resource.GetResourceData();
return decrypt(encryptedData);
}
开发者ID:ostuda,项目名称:de4dot,代码行数:7,代码来源:ResourceDecrypter.cs
示例2: checkHandlerMethod
protected override bool checkHandlerMethod(MethodDefinition method)
{
if (!method.IsStatic || !method.HasBody)
return false;
EmbeddedResource resource = null;
var instructions = method.Body.Instructions;
for (int i = 0; i < instructions.Count; i++) {
var instrs = DotNetUtils.getInstructions(instructions, i, OpCodes.Ldstr, OpCodes.Call);
if (instrs == null)
continue;
var s = instrs[0].Operand as string;
var calledMethod = instrs[1].Operand as MethodReference;
if (s == null || calledMethod == null)
continue;
resource = DotNetUtils.getResource(module, SA_Utils.getAssemblySimpleName(s)) as EmbeddedResource;
if (resource != null)
break;
}
if (resource == null)
return false;
embeddedAssembliesResource = resource;
Log.v("Found embedded assemblies resource {0}", Utils.toCsharpString(embeddedAssembliesResource.Name));
return true;
}
开发者ID:ostuda,项目名称:de4dot,代码行数:28,代码来源:ResourceResolverInfo.cs
示例3: canDecryptResource
public bool canDecryptResource(EmbeddedResource resource)
{
var info = getEmbeddedAssemblyInfo(resource);
if (info == null || !info.isCompressed)
return true;
return resourceDecrypter.CanDecrypt;
}
开发者ID:ostuda,项目名称:de4dot,代码行数:7,代码来源:AssemblyResolver.cs
示例4: Embedd
void Embedd(string fullPath)
{
logger.LogMessage(string.Format("\tEmbedding '{0}'", fullPath));
var fileStream = File.OpenRead(fullPath);
streams.Add(fileStream);
var resource = new EmbeddedResource("costura." + Path.GetFileName(fullPath).ToLowerInvariant(), ManifestResourceAttributes.Private, fileStream);
moduleReader.Module.Resources.Add(resource);
}
开发者ID:uniquegodwin,项目名称:Costura,代码行数:8,代码来源:ResourceEmbedder.cs
示例5: Process
public void Process(EmbeddedResource embeddedResource, ResourceWriter resourceWriter)
{
if (_bamlStreams.Count == 0)
return;
WriteCollectedBamlStreams(resourceWriter);
PatchGenericThemesBaml(resourceWriter);
}
开发者ID:jinjingcai2014,项目名称:il-repack,代码行数:8,代码来源:BamlStreamCollector.cs
示例6: Csvm
public Csvm(IDeobfuscatorContext deobfuscatorContext, ModuleDefinition module, Csvm oldOne)
{
this.deobfuscatorContext = deobfuscatorContext;
this.module = module;
if (oldOne.resource != null)
this.resource = (EmbeddedResource)module.Resources[oldOne.module.Resources.IndexOf(oldOne.resource)];
if (oldOne.vmAssemblyReference != null)
this.vmAssemblyReference = module.AssemblyReferences[oldOne.module.AssemblyReferences.IndexOf(oldOne.vmAssemblyReference)];
}
开发者ID:Joelone,项目名称:de4dot,代码行数:9,代码来源:Csvm.cs
示例7: VisitEmbeddedResource
public override void VisitEmbeddedResource(EmbeddedResource res)
{
// TODO: Description?
IResourceWriter resourceWriter = module.Builder.DefineResource(res.Name, "",
(System.Reflection.ResourceAttributes)res.Flags);
resourceWriter.AddResource(res.Name, res.Data);
resourceWriter.Generate();
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:9,代码来源:DynamicResourceBuilder.cs
示例8: AddResourceFile
/// <summary>
/// Adds infromation about embedded resource file in Mono.Cecil format into list.
/// </summary>
/// <param name="item">Embedded resouce file information in Mono.Cecil format.</param>
/// <param name="count">Number of recource items in this resouce file.</param>
public void AddResourceFile(
EmbeddedResource item,
UInt32 count)
{
var correctFileName = Path.ChangeExtension(item.Name, ".tinyresources");
var nameStringId = _context.StringTable.GetOrCreateStringId(correctFileName);
_resouces.Add(new Tuple<UInt16, UInt32>(nameStringId, count));
}
开发者ID:Roddoric,项目名称:Monkey.Robotics,代码行数:14,代码来源:TinyResourceFileTable.cs
示例9: Embed
private string Embed(string prefix, string fullPath, bool compress)
{
var resourceName = String.Format("{0}{1}", prefix, Path.GetFileName(fullPath).ToLowerInvariant());
if (ModuleDefinition.Resources.Any(x => x.Name == resourceName))
{
LogInfo(string.Format("\tSkipping '{0}' because it is already embedded", fullPath));
return resourceName;
}
if (compress)
{
resourceName = String.Format("{0}{1}.zip", prefix, Path.GetFileName(fullPath).ToLowerInvariant());
}
LogInfo(string.Format("\tEmbedding '{0}'", fullPath));
var checksum = CalculateChecksum(fullPath);
var cacheFile = Path.Combine(cachePath, String.Format("{0}.{1}", checksum, resourceName));
var memoryStream = new MemoryStream();
if (File.Exists(cacheFile))
{
using (var fileStream = File.Open(cacheFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
fileStream.CopyTo(memoryStream);
}
}
else
{
using (var cacheFileStream = File.Open(cacheFile, FileMode.CreateNew, FileAccess.Write, FileShare.Read))
{
using (var fileStream = File.Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
if (compress)
{
using (var compressedStream = new DeflateStream(memoryStream, CompressionMode.Compress, true))
{
fileStream.CopyTo(compressedStream);
}
}
else
{
fileStream.CopyTo(memoryStream);
}
}
memoryStream.Position = 0;
memoryStream.CopyTo(cacheFileStream);
}
}
memoryStream.Position = 0;
streams.Add(memoryStream);
var resource = new EmbeddedResource(resourceName, ManifestResourceAttributes.Private, memoryStream);
ModuleDefinition.Resources.Add(resource);
return resourceName;
}
开发者ID:kbdavis07,项目名称:Costura,代码行数:56,代码来源:ResourceEmbedder.cs
示例10: RelativeBasedOnNamespace
public void RelativeBasedOnNamespace()
{
var expected = new EmbeddedResource("AssemblyName.Namespace1.ResourceName", ManifestResourceAttributes.Public, (Stream) null);
var definition = ModuleDefinition.CreateModule("AssemblyName", ModuleKind.Dll);
definition.Resources.Add(expected);
var moduleWeaver = new ModuleWeaver
{
ModuleDefinition = definition
};
var actual = moduleWeaver.FindResource("ResourceName", "AssemblyName.Namespace1", null, null);
Assert.AreEqual(expected, actual);
}
开发者ID:huoxudong125,项目名称:Resourcer,代码行数:12,代码来源:ResourceFinderTests.cs
示例11: RelativeBasedOnDirUpTwoLevelsMultipleNamespaces
public void RelativeBasedOnDirUpTwoLevelsMultipleNamespaces()
{
var expected = new EmbeddedResource("AssemblyName.ResourceName", ManifestResourceAttributes.Public, (Stream) null);
var definition = ModuleDefinition.CreateModule("AssemblyName", ModuleKind.Dll);
definition.Resources.Add(expected);
var moduleWeaver = new ModuleWeaver
{
ModuleDefinition = definition
};
var actual = moduleWeaver.FindResource(@"..\..\ResourceName", "BadPrefix", @"Namespace1\Namespace2", null);
Assert.AreEqual(expected, actual);
}
开发者ID:huoxudong125,项目名称:Resourcer,代码行数:12,代码来源:ResourceFinderTests.cs
示例12: Main
static void Main(string[] args)
{
// TODO: Smarter handling of command line parameters if there ever are additional ones
if (args.Length < 4 || args.Length == 5 || args.Length > 6)
{
Console.Error.WriteLine("Expected arguments: <Assembly-Path> <New-Assembly-Path> <Resource-Name> <Resource-Path> [-snk <Strong-Name-Key-Path>]");
Environment.Exit(1);
}
else if (args.Length == 6 && args[4] != "-snk")
{
Console.Error.WriteLine("Available options are:");
Console.Error.WriteLine("\t-snk: Path to strong name key file (.snk).");
Environment.Exit(1);
}
var assemblyPath = args[0];
var newAssemblyPath = args[1];
var resourceName = args[2];
var resourcePath = args[3];
var snkPath = args.Length == 6 ? args[5] : null;
var assemblyDef = AssemblyDefinition.ReadAssembly(assemblyPath);
Console.WriteLine("Loaded assembly " + assemblyDef);
// TODO: Support other modules than MainModule
var resources = assemblyDef.MainModule.Resources;
var selectedResource = resources.FirstOrDefault(x => x.Name == resourceName);
if (selectedResource != null)
{
var newResource = new EmbeddedResource(resourceName, selectedResource.Attributes, File.ReadAllBytes(resourcePath));
resources.Remove(selectedResource);
resources.Add(newResource);
if (snkPath == null)
assemblyDef.Write(newAssemblyPath);
else
{
Console.WriteLine("Using strong name key file " + snkPath);
assemblyDef.Write(newAssemblyPath, new WriterParameters() { StrongNameKeyPair = new StrongNameKeyPair(File.ReadAllBytes(snkPath)) });
}
Console.WriteLine("Replaced embedded resource " + resourceName + " successfully!");
}
else
{
Console.Error.WriteLine("Could not find a resource with name " + resourceName);
Console.Error.WriteLine("Available resources: " + String.Join(", ", resources.Select(x => x.Name).DefaultIfEmpty("<none>")));
}
}
开发者ID:qerub,项目名称:ReplaceEmbeddedAssemblyResource,代码行数:52,代码来源:Program.cs
示例13: removeDecryptedResource
public byte[] removeDecryptedResource(EmbeddedResource resource)
{
if (resource == null)
return null;
var info = getEmbeddedAssemblyInfo(resource);
if (info == null)
return null;
var data = decryptResource(info);
if (!assemblyResolverInfo.EmbeddedAssemblyInfos.Remove(info))
throw new ApplicationException(string.Format("Could not remove resource {0}", Utils.toCsharpString(info.resourceName)));
return data;
}
开发者ID:ostuda,项目名称:de4dot,代码行数:14,代码来源:AssemblyResolver.cs
示例14: initialize
public void initialize()
{
if (resolveHandler == null)
return;
if (isV3) {
simpleDeobfuscator.deobfuscate(resolveHandler);
simpleDeobfuscator.decryptStrings(resolveHandler, deob);
resource = DeobUtils.getEmbeddedResourceFromCodeStrings(module, resolveHandler);
if (resource == null) {
Log.w("Could not find resource of encrypted resources");
return;
}
}
}
开发者ID:Predator75,项目名称:de4dot,代码行数:15,代码来源:ResourceResolver.cs
示例15: decryptResource
byte[] decryptResource(EmbeddedResource resource)
{
using (var rsrcStream = resource.GetResourceStream()) {
using (var reader = new BinaryReader(rsrcStream)) {
var key = reader.ReadString();
var data = reader.ReadBytes((int)(rsrcStream.Length - rsrcStream.Position));
var cryptoTransform = new DESCryptoServiceProvider {
Key = Encoding.ASCII.GetBytes(key),
IV = Encoding.ASCII.GetBytes(key),
}.CreateDecryptor();
var memStream = new MemoryStream(data);
using (var reader2 = new BinaryReader(new CryptoStream(memStream, cryptoTransform, CryptoStreamMode.Read))) {
return reader2.ReadBytes((int)memStream.Length);
}
}
}
}
开发者ID:ldh0227,项目名称:de4dot,代码行数:17,代码来源:ResourceDecrypter.cs
示例16: Commit
void Commit()
{
var n = _form.TreeViewHandler.SelectedNode;
var r = (Resource)n.Tag;
if (r is EmbeddedResource)
{
var er = (EmbeddedResource)r;
var detailType = (SimpleAssemblyExplorer.ClassEditResourceHandler.DetailTypes)_form.DetailsTabPage.Tag;
var data = Encoding.Unicode.GetBytes(_textbox.Text);
if (detailType == ClassEditResourceHandler.DetailTypes.TextResource)
{
var newEr = new EmbeddedResource(er.Name, er.Attributes, data);
var ad = _form.TreeViewHandler.GetCurrentAssembly();
ad.MainModule.Resources.Remove(er);
ad.MainModule.Resources.Add(newEr);
n.Tag = newEr;
}
else if (detailType == ClassEditResourceHandler.DetailTypes.ResourcesRowAsText)
{
var row = _form.ResourceDataGrid.CurrentRow;
string key = _form.ResourceHandler.GetNameCellValue(row);
var newEr = _form.ResourceHandler.ReplaceResource(er, key, data);
var ad = _form.TreeViewHandler.GetCurrentAssembly();
ad.MainModule.Resources.Remove(er);
ad.MainModule.Resources.Add(newEr);
n.Tag = newEr;
var rowIndex = row.Index;
_form.ResourceHandler.InitResource(newEr);
row = _form.ResourceDataGrid.Rows[rowIndex];
_form.ResourceDataGrid.CurrentCell = row.Cells[0];
row.Selected = true;
_form.ResourceDataGrid.FirstDisplayedScrollingRowIndex = rowIndex > 10 ? rowIndex - 10 : 0;
}
else
{
throw new NotImplementedException();
}
}
_form.SetStatusText("Changes committed.");
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:45,代码来源:ClassEditTextViewHandler.cs
示例17: Main
static int Main(string[] args)
{
string inputFile = null, outputFile = null;
var opts = new OptionSet()
{
{"i|input=", "Input file",
i => inputFile = i},
{"o|output=", "Output file",
o => outputFile = o}
};
var files = opts.Parse(args);
if (string.IsNullOrWhiteSpace(inputFile))
{
Console.WriteLine("No assembly specified as embedding target. Please use the -i option.");
return -1;
}
if (outputFile == null)
{
Console.WriteLine("Overwriting target assembly {0}", inputFile);
outputFile = inputFile;
}
if (files.Count <= 0)
{
Console.WriteLine("No input files specified");
return -1;
}
Console.WriteLine("Reading {0}", inputFile);
var module = ModuleDefinition.ReadModule(inputFile);
foreach (var file in files)
{
Console.WriteLine("Embedding {0}", file);
var bytes = File.ReadAllBytes(file);
var resname = file.Replace("/", ".");
var resource = new EmbeddedResource(resname, ManifestResourceAttributes.Public, bytes);
module.Resources.Add(resource);
}
Console.WriteLine("Writing {0}", outputFile);
module.Write(outputFile);
return 0;
}
开发者ID:kocubinski,项目名称:clojure-clr,代码行数:41,代码来源:Program.cs
示例18: dumpEmbeddedFile
void dumpEmbeddedFile(EmbeddedResource resource, string assemblyName, string extension, string reason)
{
DeobfuscatedFile.createAssemblyFile(resourceDecrypter.decrypt(resource.GetResourceStream()), Utils.getAssemblySimpleName(assemblyName), extension);
addResourceToBeRemoved(resource, reason);
}
开发者ID:huliang,项目名称:de4dot,代码行数:5,代码来源:Deobfuscator.cs
示例19: ResourcesFileTreeNode
public ResourcesFileTreeNode(EmbeddedResource er)
: base(er)
{
this.LazyLoading = true;
}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:5,代码来源:ResourcesFileTreeNode.cs
示例20: Bind
/// <summary>
/// Bind a ressource.
/// </summary>
/// <param name="resource">resource to bind</param>
public void Bind(EmbeddedResource resource)
{
CleanUp();
if (resource != null)
{
IByteProvider provider = new DynamicByteProvider(resource.Data);
provider.Changed += new EventHandler(byteProvider_Changed);
provider.LengthChanged += new EventHandler(byteProvider_LengthChanged);
hexBox.ByteProvider = provider;
_resource = resource;
hexBox.ReadOnly = false;
} else
{
hexBox.ReadOnly = true;
}
UpdateSizeStatus();
ManageAbility();
}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:25,代码来源:HexEditorControl.cs
注:本文中的Mono.Cecil.EmbeddedResource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论