Posted December 4, 20222 yr 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?
December 4, 20222 yr 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
December 4, 20222 yr Author @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?
December 4, 20222 yr @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, 20222 yr by BataBo More clarification
December 5, 20222 yr Author 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?
December 5, 20222 yr Author 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!
Create an account or sign in to comment