本文整理汇总了C#中AssemblyDef类的典型用法代码示例。如果您正苦于以下问题:C# AssemblyDef类的具体用法?C# AssemblyDef怎么用?C# AssemblyDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssemblyDef类属于命名空间,在下文中一共展示了AssemblyDef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: isForm
public static bool isForm(AssemblyDef asm)
{
bool result = false;
foreach (ModuleDef current in asm.Modules)
{
foreach (TypeDef current2 in current.Types)
{
foreach (TypeDef current3 in current2.NestedTypes)
{
foreach (MethodDef current4 in current3.Methods)
{
if (current4.Name == "InitializeComponent")
{
result = true;
}
}
}
foreach (MethodDef current5 in current2.Methods)
{
if (current5.Name == "InitializeComponent")
{
result = true;
}
}
}
}
return result;
}
示例2: AddToCache
/// <summary>
/// Add an assembly to the assembly cache
/// </summary>
/// <param name="asm">The assembly</param>
/// <returns>
/// <c>true</c> if <paramref name="asm" /> is cached, <c>false</c> if it's not
/// cached because some other assembly with the exact same full name has already been
/// cached or if <paramref name="asm" /> is <c>null</c>.
/// </returns>
public bool AddToCache(AssemblyDef asm)
{
if (_cache.ContainsKey(asm))
return false;
_cache[asm] = asm;
return true;
}
示例3: GetBaseDirectory
string GetBaseDirectory(AssemblyDef asm, ModuleDef mod) {
if (string.IsNullOrEmpty(mod.Location))
return string.Empty;
try {
return Path.GetDirectoryName(mod.Location);
}
catch {
return string.Empty;
}
}
示例4: AssemblyOptions
public AssemblyOptions(AssemblyDef asm) {
HashAlgorithm = asm.HashAlgorithm;
Version = asm.Version;
Attributes = asm.Attributes;
PublicKey = asm.PublicKey;
Name = asm.Name;
Culture = asm.Culture;
ClrVersion = Module.ClrVersion.DefaultVersion;
CustomAttributes.AddRange(asm.CustomAttributes);
DeclSecurities.AddRange(asm.DeclSecurities);
}
示例5: DeobfuscateAssembly
public override AssemblyDef DeobfuscateAssembly(AssemblyDef asmDef)
{
Ctx.Assembly = asmDef;
Ctx.OriginalMD = (Ctx.Assembly.ManifestModule as ModuleDefMD);
InitializePipelines();
Pipelines["preRoutines"].Process();
Pipelines["routines"].Process();
return Ctx.Assembly;
}
示例6: ResolveCLRNamespaces
IEnumerable<string> ResolveCLRNamespaces(AssemblyDef assembly, string ns) {
foreach (var attr in assembly.CustomAttributes.FindAll("System.Windows.Markup.XmlnsDefinitionAttribute")) {
Debug.Assert(attr.ConstructorArguments.Count == 2);
var xmlNs = attr.ConstructorArguments[0].Value;
var clrNs = attr.ConstructorArguments[1].Value;
Debug.Assert(xmlNs is UTF8String && clrNs is UTF8String);
if ((UTF8String)xmlNs == ns)
yield return (UTF8String)clrNs;
}
}
示例7: InjectSettings
private void InjectSettings(AssemblyDef asm)
{
var ep = asm.ManifestModule.EntryPoint;
var settingsMethod = ep.DeclaringType.FindMethod(new UTF8String("InitializeSettings"));
if (settingsMethod == null)
throw new ComponentMissingException("Failed to locate InitializeSettings method in stub");
settingsMethod.Body.Instructions[0].Operand = _settings.Hostname;
settingsMethod.Body.Instructions[2].OpCode = OpCodes.Ldc_I4;
settingsMethod.Body.Instructions[2].Operand = _settings.Port;
settingsMethod.Body.Instructions[4].OpCode = OpCodes.Ldc_I4;
settingsMethod.Body.Instructions[4].Operand = _settings.ReconnectDelay*1000;
}
示例8: CopyTo
public AssemblyDef CopyTo(AssemblyDef asm) {
asm.HashAlgorithm = HashAlgorithm;
asm.Version = Version;
asm.Attributes = Attributes;
asm.PublicKey = PublicKey;
asm.Name = Name ?? UTF8String.Empty;
asm.Culture = Culture;
asm.CustomAttributes.Clear();
asm.CustomAttributes.AddRange(CustomAttributes);
asm.DeclSecurities.Clear();
asm.DeclSecurities.AddRange(DeclSecurities);
return asm;
}
示例9: FetchSubversion1_9
private static DeobfuscatorBase FetchSubversion1_9(AssemblyDef asmDef)
{
foreach (var type in asmDef.ManifestModule.Types)
{
if (type.Name.String.StartsWith("Lzma") && type.HasNestedTypes && type.NestedTypes.Count == 6)
{
// Weak 1.9L detection
return Activator.CreateInstance<Deobfuscator19L>();
}
}
return Activator.CreateInstance<Deobfuscator19R>();
}
示例10: GetResult
public override DocumentTreeNodeFilterResult GetResult(AssemblyDef asm) {
var thisFlag = VisibleMembersFlags.AssemblyDef;
var visibleFlags = thisFlag | VisibleMembersFlags.ModuleDef |
VisibleMembersFlags.Namespace | VisibleMembersFlags.AnyTypeDef |
VisibleMembersFlags.FieldDef | VisibleMembersFlags.MethodDef |
VisibleMembersFlags.InstanceConstructor | VisibleMembersFlags.PropertyDef |
VisibleMembersFlags.EventDef | VisibleMembersFlags.AssemblyRef |
VisibleMembersFlags.BaseTypes | VisibleMembersFlags.DerivedTypes |
VisibleMembersFlags.ModuleRef | VisibleMembersFlags.ResourceList |
VisibleMembersFlags.MethodBody | VisibleMembersFlags.ParamDefs |
VisibleMembersFlags.ParamDef | VisibleMembersFlags.Locals |
VisibleMembersFlags.Local | VisibleMembersFlags.Resource |
VisibleMembersFlags.ResourceElement | VisibleMembersFlags.Other |
VisibleMembersFlags.Attributes;
return FilterFile(thisFlag, visibleFlags);
}
示例11: WriteAssembly
protected void WriteAssembly(AssemblyDef asm, IDecompilerOutput output, DecompilationContext ctx) {
DecompileInternal(asm, output, ctx);
output.WriteLine();
PrintEntryPoint(asm.ManifestModule, output);
var peImage = TryGetPEImage(asm.ManifestModule);
if (peImage != null) {
WriteCommentBegin(output, true);
uint ts = peImage.ImageNTHeaders.FileHeader.TimeDateStamp;
var date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(ts);
var dateString = date.ToString(CultureInfo.CurrentUICulture.DateTimeFormat);
output.Write(string.Format(dnSpy_Decompiler_Resources.Decompile_Timestamp, ts, dateString), BoxedTextColor.Comment);
WriteCommentEnd(output, true);
output.WriteLine();
}
output.WriteLine();
}
示例12: GetFiles
IEnumerable<string> GetFiles(AssemblyDef asm, ModuleDef mod) {
var baseDir = GetBaseDirectory(asm, mod);
if (string.IsNullOrEmpty(baseDir))
yield break;
var baseDirs = new List<string>();
baseDirs.Add(baseDir);
//TODO: Add all privatePath dirs found in app.config
foreach (var bd in baseDirs) {
foreach (var dir in GetDirectories(baseDir)) {
var name = Path.GetFileName(dir);
if (!IsValidCulture(name))
continue;
yield return Path.Combine(dir, asm.Name + ".resources.dll");
yield return Path.Combine(dir, asm.Name, asm.Name + ".resources.dll");
}
}
}
示例13: Write
public void Write(ISyntaxHighlightOutput output, ILanguage language, AssemblyDef asm, bool showToken, bool showAssemblyVersion, bool showAssemblyPublicKeyToken)
{
output.Write(asm.Name, IsExe(asm.ManifestModule) ? TextTokenKind.AssemblyExe : TextTokenKind.Assembly);
bool showAsmVer = showAssemblyVersion;
bool showPublicKeyToken = showAssemblyPublicKeyToken && !PublicKeyBase.IsNullOrEmpty2(asm.PublicKeyToken);
if (showAsmVer || showPublicKeyToken) {
output.WriteSpace();
output.Write("(", TextTokenKind.Operator);
bool needComma = false;
if (showAsmVer) {
if (needComma)
output.WriteCommaSpace();
needComma = true;
output.Write(asm.Version);
}
if (showPublicKeyToken) {
if (needComma)
output.WriteCommaSpace();
needComma = true;
var pkt = asm.PublicKeyToken;
if (PublicKeyBase.IsNullOrEmpty2(pkt))
output.Write("null", TextTokenKind.Keyword);
else
output.Write(pkt.ToString(), TextTokenKind.Number);
}
output.Write(")", TextTokenKind.Operator);
}
WriteToken(output, asm, showToken);
}
示例14: Write
/// <summary>
/// Writes an assembly
/// </summary>
/// <param name="output">Output</param>
/// <param name="decompiler">Decompiler</param>
/// <param name="asm">Assembly</param>
/// <param name="showToken">true to write tokens</param>
/// <param name="showAssemblyVersion">true to write version</param>
/// <param name="showAssemblyPublicKeyToken">true to write public key token</param>
public void Write(ITextColorWriter output, IDecompiler decompiler, AssemblyDef asm, bool showToken, bool showAssemblyVersion, bool showAssemblyPublicKeyToken) {
output.Write(IsExe(asm.ManifestModule) ? BoxedTextColor.AssemblyExe : BoxedTextColor.Assembly, asm.Name);
bool showAsmVer = showAssemblyVersion;
bool showPublicKeyToken = showAssemblyPublicKeyToken && !PublicKeyBase.IsNullOrEmpty2(asm.PublicKeyToken);
if (showAsmVer || showPublicKeyToken) {
output.WriteSpace();
output.Write(BoxedTextColor.Punctuation, "(");
bool needComma = false;
if (showAsmVer) {
if (needComma)
output.WriteCommaSpace();
needComma = true;
output.Write(asm.Version);
}
if (showPublicKeyToken) {
if (needComma)
output.WriteCommaSpace();
needComma = true;
var pkt = asm.PublicKeyToken;
if (PublicKeyBase.IsNullOrEmpty2(pkt))
output.Write(BoxedTextColor.Keyword, "null");
else
output.Write(BoxedTextColor.Number, pkt.ToString());
}
output.Write(BoxedTextColor.Punctuation, ")");
}
WriteToken(output, asm, showToken);
}
示例15: ReadModule
/// <summary>
/// Reads a module
/// </summary>
/// <param name="fileRid">File rid</param>
/// <param name="owner">The assembly owning the module we should read</param>
/// <returns>A new <see cref="ModuleDefMD"/> instance or <c>null</c> if <paramref name="fileRid"/>
/// is invalid or if it's not a .NET module.</returns>
internal ModuleDefMD ReadModule(uint fileRid, AssemblyDef owner)
{
var fileDef = ResolveFile(fileRid);
if (fileDef == null)
return null;
if (!fileDef.ContainsMetaData)
return null;
var fileName = GetValidFilename(GetBaseDirectoryOfImage(), UTF8String.ToSystemString(fileDef.Name));
if (fileName == null)
return null;
ModuleDefMD module;
try {
module = ModuleDefMD.Load(fileName);
}
catch {
module = null;
}
if (module != null) {
// share context
module.context = context;
var asm = module.Assembly;
if (asm != null && asm != owner)
asm.Modules.Remove(module);
}
return module;
}