Reflexil | The .NET Assembly Editor | Cybersecurity library
kandi X-RAY | Reflexil Summary
kandi X-RAY | Reflexil Summary
The .NET Assembly Editor
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Reflexil
Reflexil Key Features
Reflexil Examples and Code Snippets
Community Discussions
Trending Discussions on Reflexil
QUESTION
I have been playing with Reflector and Reflexil, but when I created a static method, it didn't work. On some ispection, I found that methods have 2 different parameters/flags: IsStatic
and HasThis
.
What is the diference? Or is there no difference and one of the flags is simply unused? I have looked at extension methods and constructors, however extension methods are marked as normal static methods, and constructors as normal member methods (in regard to these 2 flags).
...ANSWER
Answered 2017-Mar-18 at 21:57Reflexil displays together two sets of flags - method atttributes from the method definition in case of IsStatic, and calling conventions from the method signature definition in case of HasThis.
Method attributes contain general information about a specific method, like its accessibility, abstract/virtual/sealed status etc. (e.g. Static
), while the signature is what the method takes and returns and how, which can be separated into several calling conventions.
The managed calling conventions are DEFAULT
, VARARG
, HASTHIS
and EXPLICITTHIS
. HASTHIS
(instance
in CIL) simply means that the this
instance is internally passed as the first argument to the method (referenced by ldarg.0
).
HASTHIS
is useful in places where you would only be able to use a method signature, like in function pointers or the calli
instruction (both unavailable in C#, though not in C++/CLI). However, EXPLICITTHIS
would be more appropriate on these occasions.
The Static
flag may not be needed for methods, but is certainly required for fields, as they have no calling convention, so probably consistency is the reason.
So, conceptually they are a bit different, but technically mean the same thing.
While in theory a non-static method may not need a this
reference, setting both flags at the same time is prohibited, and ilasm doesn't allow me to construct a method with both flags on or off, setting them both based only on the presence of the static
keyword.
Extension methods are only a C# thing, the "this" reference is the actual first parameter of the method and the rest is syntactic sugar.
QUESTION
Okay so I have an app that I have been tasked with editing that source is not available and due to confidentiality I cannot share the app/code - I realize that makes these kind of questions challenging but since I have done this before I believe it to be something simple I am overlooking.
I have performed this in the past and the only difference is that this is a new build using 4.5 and latest C# compiler etc.
Here's the scenario:
I can open the app, and read it properly and edit the IL. In fact, I can edit it without issue using reflexil both in Reflection desktop (latest), Telerik (my usual go-to) also using updated reflexil, then I also tried dnSpy latest nightly 3.0.1.
Heck, thinking I was losing my mind I even opened it using older GreyDragon, also edited some IL, saved the exe assembly, and even IL directly in the entry point main still does not execute as changed but as the prior unchanged original, yet in ALL those tools, if I re-open the previously edited and saved assembly exe, it DOES in all cases properly show the changes, both in decompiled C# as well as in the corresponding IL instructions.
The only thing that I can pinpoint could differ again is newer targeted dotnet version and it being compiled in a newer C# compiler/ver.
So, is there any reason that the latest version of C# Rosylyn etc. would prevent IL editing methods (and virtually every tool that can do IL editing) that previously worked from working now, almost as if a secondary instruction backup table etc. that holds a copy of original unedited that would be executing?
Or, could a specific "setting" of assembly regeneration be causing this behavior?
Let's start with the big picture of what some fundamental roadblock I may be missing before I start trying to describe finer details.
Again sorry for not having actual code to share but hopefully a real guru will know what's going on and have ideas. Thanks!
...ANSWER
Answered 2017-Mar-01 at 23:12Posting my own answer cannot believe I missed this.
The answer is even though it's not installed as an assembly in the GAC, this app behavior changed and I missed that somehow a process ran NGEN.EXE against it to compile the NI native image to a NATIVE IMAGE and install it - which then contains cached version of the friggin machine code in question - exactly what my gut said was happening I just needed to find that "backup copy".
QUESTION
I'm trying to use Reflexil to log a string in an existing method in a dll I haven't got the source code to. The problem is, I can add a method that uses System.IO because I'm trying to add it to a dll that didn't use file writing before and can't add references.
Is there some log writing command that is accessible through System.dll I can use?
...ANSWER
Answered 2017-Feb-06 at 20:51This is a partial solution to the problem
I modified the original constructor to a normal method Created a new constructor and matched the signature then called the new method with the addition of the logging code
For now this compiles, but for some reason the exe crashes the second it starts
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Reflexil
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page