Comments (3)
No, there's no method in dnlib that will tell you that.
You'll have to do what you wrote, check the current method's declaring type's interfaces and the base type. It's the base type that will complicate things because it's not always a TypeRef/TypeDef, it could be a TypeSpec. If so, you'd have to replace all generic parameters with the generic arguments on every method from then on.
Class1 : Class2<int, bool>
If Class2 has this method: T method1<T, U>(U u)
, you must first replace the generic params with the generic arguments and turn it into int method1<int, bool>(bool u)
before comparing it with your method. The code would be very similar to what the Importer class already does.
To compare methods, use the SigComparer class.
from dnlib.
Thank you very much for the help.
I will look into it and report back when I got it working (or not).
Btw is there a trick you are aware of that I could use to restructure the Ld* instructions just before a call when the signature of the method being called has changed?
I have to modify the parameter order of some methods (only internal) and of course I have to update all callsites.
I already found out all locations where the method is called, changed the parameter order and updated all instructions in the method.
What's left is updating the callsites.
Most of the time the ld* (ldc, ldloc, ldarg) commands are all neatly packed next to each other just in front of the call. But sometimes a value is consumed by the call that has been pushed on the evaluation stack many instructions further up, or even below (with a jump back up).
Some values might not even be loaded from anywhere at all. For example results of add,sub,mul or call. The whole thing gets especially complicated when there is a call-chain with no load/store commands in between...
Since there is no msil instruction to swap two items on the evaluation stack, I thought the best way to reorder the values would be to add additional local variables pop them in and push them in the needed order...
Is there a way / method in dnlib or de4dot that does something like a cleanup on a methodbody?
So all ld*s are directly in front of the call?
I think there surely is a better way to do this. What would you do?
from dnlib.
You could create a static method (set first argument to the 'this' instance) which uses the original parameter order which then calls the new method (be sure that you use the same call/callvirt instruction in this proxy method as the original code used).
Otherwise you'll just have to pop the args to temporary variables and then push them in the new order, like you said.
from dnlib.
Related Issues (20)
- Consider adding a net6.0 as an additional target framework HOT 2
- Error CS0246 The type or namespace name 'dnlib' could not be found (perhaps missing a using directive or an assembly reference). HOT 1
- Optimize properties on `TypeRef` and `TypeDef` HOT 3
- Import property without using typeof
- HasOverrides Generic Type HOT 2
- PDB Generated is wrong HOT 7
- Linux R2R mixed dll can't be saved. HOT 2
- Single File Executable Error: .NET data directory RVA is 0
- Potential feature: Support for 64 bit offsets and length in dnlib.IO HOT 2
- The precise method for calculating 'RVA'
- Can ITypeOrMethodDef implement IMemberDef? HOT 1
- InvalidOperationException when md rva isn't alignment HOT 5
- dnlib is missing NuGet package README file
- ModuleWriterException: Invalid section RVA HOT 1
- Should we update ReturnParameter when updating ReturnType? HOT 2
- .NET cannot install (UAC prompt when running installer)
- dnlib.DotNet.Writer.ModuleWriterException HOT 2
- "Expected a null constant." error when saving assembly with pdb HOT 6
- Why don't CreateGenericInstMethodSig HOT 25
- I already know how UnknownDeclaringType happen HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dnlib.