本文整理汇总了C#中dnlib.DotNet.EmbeddedResource类的典型用法代码示例。如果您正苦于以下问题:C# EmbeddedResource类的具体用法?C# EmbeddedResource怎么用?C# EmbeddedResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedResource类属于dnlib.DotNet命名空间,在下文中一共展示了EmbeddedResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Find
public void Find() {
var requiredTypes = new string[] {
"System.Reflection.Assembly",
"System.Object",
"System.Int32",
"System.String[]",
};
foreach (var type in module.Types) {
if (type.HasEvents)
continue;
if (!new FieldTypes(type).All(requiredTypes))
continue;
MethodDef regMethod, handler;
if (!BabelUtils.FindRegisterMethod(type, out regMethod, out handler))
continue;
var resource = BabelUtils.FindEmbeddedResource(module, type);
if (resource == null)
continue;
var decryptMethod = FindDecryptMethod(type);
if (decryptMethod == null)
throw new ApplicationException("Couldn't find resource type decrypt method");
resourceDecrypter.DecryptMethod = ResourceDecrypter.FindDecrypterMethod(decryptMethod);
InitXorKeys(decryptMethod);
resolverType = type;
registerMethod = regMethod;
encryptedResource = resource;
return;
}
}
示例2: decrypt
public byte[] decrypt(EmbeddedResource resource)
{
if (!CanDecrypt)
throw new ApplicationException("Can't decrypt resources");
var encryptedData = resource.GetResourceData();
return decrypt(encryptedData);
}
示例3: AssemblyInfo
public AssemblyInfo(byte[] data, EmbeddedResource resource, string asmFullName, string asmSimpleName, string extension) {
this.data = data;
this.resource = resource;
this.asmFullName = asmFullName;
this.asmSimpleName = asmSimpleName;
this.extension = extension;
}
示例4: AssemblyInfo
public AssemblyInfo(byte[] data, string fullName, string simpleName, string extension, EmbeddedResource resource) {
this.data = data;
this.fullName = fullName;
this.simpleName = simpleName;
this.extension = extension;
this.resource = resource;
}
示例5: Csvm
public Csvm(IDeobfuscatorContext deobfuscatorContext, ModuleDefMD 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.vmAssemblyRef != null)
this.vmAssemblyRef = module.ResolveAssemblyRef(oldOne.vmAssemblyRef.Rid);
}
示例6: EmbeddedAssemblyInfo
public EmbeddedAssemblyInfo(EmbeddedResource resource, byte[] data, string asmFullName, ModuleKind kind) {
this.resource = resource;
this.data = data;
this.asmFullName = asmFullName;
this.asmSimpleName = Utils.GetAssemblySimpleName(asmFullName);
this.kind = kind;
this.extension = DeobUtils.GetExtension(kind);
}
示例7: GetMethodsData
public virtual byte[] GetMethodsData(EmbeddedResource resource) {
var reader = resource.Data;
reader.Position = startOffset;
if ((reader.ReadInt32() & 1) != 0)
return Decompress(reader);
else
return reader.ReadRemainingBytes();
}
示例8: ResXProjectFile
public ResXProjectFile(ModuleDef module, string filename, string typeFullName, EmbeddedResource er) {
this.filename = filename;
TypeFullName = typeFullName;
embeddedResource = er;
newToOldAsm = new Dictionary<IAssembly, IAssembly>(new AssemblyNameComparer(AssemblyNameComparerFlags.All & ~AssemblyNameComparerFlags.Version));
foreach (var asmRef in module.GetAssemblyRefs())
newToOldAsm[asmRef] = asmRef;
}
示例9: Initialize
public void Initialize(ResourceDecrypter resourceDecrypter) {
if (decryptedData != null || stringDecrypterType == null)
return;
var resourceName = GetResourceName();
stringResource = DotNetUtils.GetResource(module, resourceName) as EmbeddedResource;
if (stringResource == null)
return;
Logger.v("Adding string decrypter. Resource: {0}", Utils.ToCsharpString(stringResource.Name));
decryptedData = resourceDecrypter.Decrypt(stringResource.GetResourceStream());
}
示例10: FindStringsResource
bool FindStringsResource(IDeobfuscator deob, ISimpleDeobfuscator simpleDeobfuscator, MethodDef cctor) {
if (stringsResource != null)
return true;
if (decrypterVersion <= StringDecrypterVersion.V3) {
stringsResource = DotNetUtils.GetResource(module, (module.Mvid ?? Guid.NewGuid()).ToString("B")) as EmbeddedResource;
if (stringsResource != null)
return true;
}
if (FindStringsResource2(deob, simpleDeobfuscator, cctor))
return true;
if (FindStringsResource2(deob, simpleDeobfuscator, stringDecrypterMethod))
return true;
return false;
}
示例11: Find
public void Find() {
foreach (var tmp in module.Resources) {
var resource = tmp as EmbeddedResource;
if (resource == null)
continue;
if (!resource.Name.String.EndsWith(".resources", StringComparison.Ordinal))
continue;
string ns, name;
SplitTypeName(resource.Name.String.Substring(0, resource.Name.String.Length - 10), out ns, out name);
var type = new TypeRefUser(module, ns, name, module).Resolve();
if (type == null)
continue;
if (!CheckDecrypterType(type))
continue;
encryptedResource = resource;
decrypterType = type;
break;
}
}
示例12: Execute
static void Execute(ILSpyTreeNode[] nodes)
{
if (!CanExecute(nodes))
return;
var rsrcListNode = Utils.GetResourceListTreeNode(nodes);
var module = ILSpyTreeNode.GetModule(nodes[0]);
Debug.Assert(module != null);
if (module == null)
throw new InvalidOperationException();
var dlg = new WF.OpenFileDialog {
RestoreDirectory = true,
Multiselect = true,
};
if (dlg.ShowDialog() != WF.DialogResult.OK)
return;
var fnames = dlg.FileNames;
if (fnames.Length == 0)
return;
var newNodes = new ResourceTreeNode[fnames.Length];
for (int i = 0; i < fnames.Length; i++) {
var fn = fnames[i];
try {
var rsrc = new EmbeddedResource(Path.GetFileName(fn), File.ReadAllBytes(fn), ManifestResourceAttributes.Public);
newNodes[i] = ResourceFactory.Create(module, rsrc);
}
catch (Exception ex) {
MainWindow.Instance.ShowMessageBox(string.Format("Error reading files: {0}", ex.Message));
return;
}
}
UndoCommandManager.Instance.Add(new CreateFileResourceCommand(rsrcListNode, newNodes));
}
示例13: DecryptResourceV41SL
protected static byte[] DecryptResourceV41SL(EmbeddedResource resource) {
var data = resource.GetResourceData();
byte k = data[0];
for (int i = 0; i < data.Length - 1; i++)
data[i + 1] ^= (byte)((k << (i & 5)) + i);
return InflateIfNeeded(data, 1, data.Length - 1);
}
示例14: TryCreateResourceElementSet
static ResourceElementSet TryCreateResourceElementSet(ModuleDef module, EmbeddedResource er) {
if (er == null)
return null;
er.Data.Position = 0;
if (!ResourceReader.CouldBeResourcesFile(er.Data))
return null;
try {
er.Data.Position = 0;
return ResourceReader.Read(module, er.Data);
}
catch {
return null;
}
}
示例15: CreateResXFile
ResXProjectFile CreateResXFile(ModuleDef module, EmbeddedResource er, ResourceElementSet set, string filename, string typeFullName, bool isSatellite) {
Debug.Assert(options.CreateResX);
if (!options.CreateResX)
throw new InvalidOperationException();
return new ResXProjectFile(module, filename, typeFullName, er) {
IsSatelliteFile = isSatellite,
};
}