Comments (4)
It work fine now, thank you, We can do more something magical
from jitex.
That's because GetManifestResourceStream is a R2R method and called before even Jitex load.
Normally, that can be resolved in this way:
MethodHelper.DisableR2R(method);
MethodHelper.ForceRecompile(method);
However, ForceRecompile did not worked for this method...
I'll open a bug and try to fix it.
from jitex.
"Fixed" on version 6.4.2.
However, GetManifestResourceStream is used internally on Jitex and as i said before, GetManifestResourceStream is a ReadyToRun method and called before Jitex load. To intercept him, you need prepare InterceptCall (intercepting any method before GetManifestResourceStream), disable ReadyToRun and force recompile on next call.
Below, you can see a example how to intercept, get and change parameter value:
//Get RuntimeAssembly.GetManifestResourceStream(string)
MethodInfo method = Type.GetType("System.Reflection.RuntimeAssembly")
.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(w => w.Name == "GetManifestResourceStream").ElementAt(1);
JitexManager.MethodResolver += context =>
{
if (context.Method == method || context.Method.Name.Contains(nameof(MethodStubIntercept)))
context.InterceptCall();
};
JitexManager.Interceptor += async context =>
{
//Just ignore our MethodStubIntercept
if (context.Method.Name.Contains(nameof(MethodStubIntercept)))
return;
string resourceName = context.GetParameterValue<string>(0);
Console.WriteLine("Resource name: " + resourceName); //show parameter value
context.SetParameterValue(0, "app.manifest"); //Change parameter value from "---" to "app.manifest"
};
//Just to prepare InterceptCall
MethodStubIntercept();
MethodHelper.DisableReadyToRun(method); //Disable ReadyToRun on method
MethodHelper.ForceRecompile(method); //Force recompile
Assembly.GetExecutingAssembly().GetManifestResourceStream("----"); //returns GetManifestResourceStream("app.manifest")
[MethodImpl(MethodImplOptions.NoInlining)]
static void MethodStubIntercept() { }
In most of cases, you don't need to prepare InterceptCall, however in this case, you need to do that.
Let me know if works for you.
from jitex.
Just a adjusment on my response.
If you don't need intercept call, you can do just this:
//Get RuntimeAssembly.GetManifestResourceStream(string)
MethodInfo method = Type.GetType("System.Reflection.RuntimeAssembly")
.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(w => w.Name == "GetManifestResourceStream").ElementAt(1);
JitexManager.MethodResolver += context =>
{
Console.WriteLine(context.Method.Name);
};
MethodStubIntercept();
MethodHelper.DisableReadyToRun(method); //Disable ReadyToRun on method
MethodHelper.ForceRecompile(method); //Force recompile
Assembly.GetExecutingAssembly().GetManifestResourceStream("----");
[MethodImpl(MethodImplOptions.NoInlining)]
static void MethodStubIntercept() { }
from jitex.
Related Issues (20)
- ForceRecompile not working with virtual methods
- Virtual pointers are overwriting ctor
- Add support to event after method compiled
- Support for .NET 6.0
- Add support to intercept call when is a ctor
- Can Jitex still intercept methods that have already been JIT-compiled? HOT 9
- Intercept method with multiple ret instructions
- Handling exception on intercept method
- Support to ARM64 HOT 1
- Add support to .NET 7
- Add support to disable R2R on mac
- Add support to .NET 8 HOT 2
- Any chance for x86? HOT 13
- Add support to .NET 9 HOT 1
- Internal CLR Error on .NET 7-windows HOT 3
- How to Inject the lib to an Aseembly? HOT 2
- Hook Encoding.GetString
- classes and methods that inherit from MarshalByRefObject
- Need help
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 jitex.