问题标签 [mono.cecil]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1958 浏览

.net - “错误 'System.Void Mono.Cecil.AssemblyDefinition::.ctor()' 在另一个模块中声明,需要导入”

我正在使用最新版本的 Mono.cecil 我想要做的是我在单独的 dll 中有自定义属性,我想使用 mono.cecil 将属性添加到 sample.exe 中的每个方法,但我收到了错误

“错误 'System.Void Mono.Cecil.AssemblyDefinition::.ctor()' 在另一个模块中声明,需要导入”

任何人都可以帮我解决它吗?

期待您的帮助......

=================================

0 投票
2 回答
2241 浏览

c# - .NET CIL manipulation of evaluation stack

I have this sequence of CIL codes which I injected through the use of Mono.Cecil. However, the modified .NET C# application will not run.

Objective: Manually load and pop values from stack to display in Console.WriteLine

This is the simple main() program I modified:

However, the above code cannnot run. I tried changing blt.s to clt and br_true.s but it doesn't work either. Does anyone know if it is possible to attain my objective? Thanks.

EDIT: According to ECMA-335, III.1.7.5, there might be a backward branch constraint. Not sure if this is the case.

In particular, if that single-pass analysis arrives at an instruction, call it location X, that immediately follows an unconditional branch, and where X is not the target of an earlier branch instruction, then the state of the evaluation stack at X, clearly, cannot be derived from existing information. In this case, the CLI demands that the evaluation stack at X be empty.

0 投票
1 回答
797 浏览

.net - 如何添加以 Type 作为参数的自定义属性

我想使用 Mono.Cecil 为方法添加自定义属性。自定义属性的构造函数有一个System.Type. 我试图弄清楚如何使用 Mono.Cecil 创建这样的自定义属性以及 System.Type 参数的参数是什么。

我的属性定义如下:

到目前为止,我已经尝试过:

但这似乎不起作用。任何想法?

我已将代码更新如下

有什么建议么?

0 投票
1 回答
631 浏览

.net - 如何使用mono.cecil获取方法的参数值?

是否可以使用 mono.cecil 获取方法参数的值。我正在做的方法调用的拦截让我知道是否可行?

0 投票
1 回答
310 浏览

.net - Mono.Cecil 在方法插入后获取/解析方法的 RVA

如何在不重新加载整个模块的情况下解决我注入的方法的 RVA?
我总是得到 0 作为添加方法的 RVA。无论如何都可以在不编写和重新加载程序集的情况下检索 RVA?谢谢!

0 投票
1 回答
345 浏览

mono.cecil - Mono.Cecil 修改方法的 RVA

我想使用 Mono.Cecil 修改方法的 RVA。我注意到 2007 年有人问过类似的问题,但这在 0.95 中可行吗?

例如:methodA.RVA = 0x1234;

我了解 Mono.Cecil 在编译期间计算和编写 RVA,但无论如何要修改 RVA?不过,它可以使用 CFF 资源管理器来完成。

谢谢你。

0 投票
1 回答
1490 浏览

c# - AstBuilder 中的 ILSpy“无法解析程序集”

我想在我的程序集中反编译一个方法,它引用了例如“Microsoft.SharePoint.dll”,但我没有在机器上安装 SharePoint。如果我使用以下代码,我会得到 Mono.Cecil.AssemblyResolutionException '无法解析程序集 Microsoft.SharePoint ...'。

使用 ILSpy GUI,我可以毫无错误地加载我的程序集(在没有 SharePoint 的同一台机器上)。

我需要在我的代码中更改什么?

0 投票
1 回答
826 浏览

c# - 如何使用 Mono.Cecil 务实地更改 dll 的程序集名称?

我是 Cecil 类库的新手。发现文档不适用于 cecil。我现在需要更改给定的 dll 的程序集CashCountingLibrary.dll名称LibCashCounter.dll

我怎样才能使用 cecil 做到这一点?

注意:我需要务实而不是设计

0 投票
1 回答
1593 浏览

c# - 如何使用 Mono.Cecil 保存更改的程序集?

我有一个没有类的Mono.CecilAssemblyFactory版本。可能是 Cecil 类的 0.9 版本。有出路吗?

0 投票
1 回答
1230 浏览

c# - 获取通过 Assembly.load 加载其程序集的方法体的内存地址

我已经使用 Assembly.load() 将程序集 B 加载到程序集 A 的 appdomain 中。

B 有一个名为“X”的方法,我需要检索它的内存地址/指针。

我知道 B 在 assembly.load() 之后作为单个连续内存数据映射到内存中。我可以使用 GetHInstance(module) 到达这个位置。通过使用 RVA 偏移量来到达 B 的代码段将不起作用,因为 B 是使用原始偏移量映射的。

如何从 A 中检索 X 的内存地址?