CodeExplorer Posted December 4, 2022 Posted December 4, 2022 Where is MethodDesc::Call ??? Framework 4.0 https://www.oreilly.com/library/view/shared-source-cli/059600351X/ch06s02.html Quote execution of managed code can be found in MethodDesc::Call, which we discussed in Chapter 5 (and which can be found in sscli/clr/src/vm/method.cpp). Is not inside method.cpp, in fact I can't find there any method starting with "Call" Alternatives? Any other simple way of executing .NET methods at low level? 1
kao Posted December 4, 2022 Posted December 4, 2022 If you're reading a book from 2003, perhaps you should also look at the source code from that time period. https://github.com/SSCLI/sscli_20021101/blob/master/clr/src/vm/method.cpp#L522-L531 1 1
CodeExplorer Posted December 4, 2022 Author Posted December 4, 2022 @kao: Doesn't help, I need to run methods in Framework 4.0 not on old Framework, in Framework 4.0 that method "MethodDesc::Call" seems to be missing! Alternatives? 1
BataBo Posted December 4, 2022 Posted December 4, 2022 (edited) @CodeExplorer you can use MethodDesc::GetMultiCallableAddrOfCode function to obtain pointer to the method which you can later invoke,call it with CORINFO_ACCESS_LDFTN and then later on you can invoke the code directly or wrap it up into a managed delagate and invoke like that Edited December 4, 2022 by BataBo More clarification 1
CodeExplorer Posted December 5, 2022 Author Posted December 5, 2022 I did find MethodDesc::CallDescr(), but there is a problem: dotnet-coreclr-master\src\vm\interpreter.cpp // The m_argDescs array is constructed in the following "canonical" order: // 1. 'this' pointer // 2. signature arguments // 3. return buffer // 4. type parameter -or- vararg cookie // // argOffsets_ is passed in this order, and serves to establish the offsets to arguments // when the interpreter is invoked using the native calling convention (i.e., not directly). // // When the interpreter is invoked directly, the arguments will appear in the same order // and form as arguments passed to MethodDesc::CallDescr(). This ordering is as follows: // 1. 'this' pointer // 2. return buffer // 3. signature arguments // // MethodDesc::CallDescr() does not support generic parameters or varargs functions. (the problem) MethodDesc::GetMultiCallableAddrOfCode has no parameter, this calls DoPrestub on that method?
CodeExplorer Posted December 5, 2022 Author Posted December 5, 2022 I was wrong, MethodDesc::GetMultiCallableAddrOfCode has one parameter method.cpp PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags /*=CORINFO_ACCESS_LDFTN*/) { CONTRACTL { THROWS; GC_TRIGGERS; INJECT_FAULT(COMPlusThrowOM()); } CONTRACTL_END PCODE ret = TryGetMultiCallableAddrOfCode(accessFlags); if (ret == NULL) { GCX_COOP(); // We have to allocate funcptr stub ret = GetLoaderAllocator()->GetFuncPtrStubs()->GetFuncPtrStub(this); } return ret; } Unfortunate from what I could see doesn't call DoPrestub!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now